龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php 简单的PHP web文件分享

时间:2014-07-10 15:00来源:网络整理 作者:网络 点击:
分享到:
简单的PHP web文件分享 [代码片段(43行)]
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>private file box</title>
</head>

<body>
    <h2>private file box</h2>
    <?php
    function list_file_url() {
        exec ( "/bin/ls", $res, $rc );
        //echo "<pre>";
        // var_dump ( $res );
        // var_dump ( $rc );
        // echo "</pre>";

        if (0 == $rc) {
            //echo count ( $res ) . "<br />";
            //echo "<br />";

            for($i = 0; $i < count ( $res ); $i ++) {
                if ($res[$i] != "index.php") {
                    //echo $res [$i] . "<br />";
                    $encoded_url = urlencode($res[$i]);
                    $encoded_url = str_replace("+","%20",$encoded_url);
                    $encoded_filename = iconv("GBK","UTF-8",$res[$i]);
                    $encoded_temp_filename = explode(".",$encoded_filename);
                    $encoded_filename = $encoded_temp_filename[0];   

                    echo "<a href=\\"./$encoded_url\\">$encoded_filename</a>";
                    echo "<br />";
                    echo "<br />";
                }
            }
        }
    }

    list_file_url ();
    ?>
</body>

</html>
//该片段来自于http://outofmemory.cn
精彩图集

赞助商链接