示例#1
0
function get_path_list($path)
{
    $rt = array('dir' => array(array('name' => "..", 'path' => dirname($path) . "/")), 'file' => array());
    $path = get_sys_path($path);
    $handle = opendir($path);
    if (!$handle) {
        return $rt;
    }
    while ($file = readdir($handle)) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (is_file($path . "/" . $file)) {
            $ext = pathinfo($file, PATHINFO_EXTENSION);
            if (in_ext_list($ext)) {
                $rt['file'][] = array('name' => get_utf8_path($file), 'path' => get_utf8_path(realpath($path . "/" . $file)), 'size' => format_size(filesize($path . "/" . $file)));
            }
        } elseif (is_dir($path . "/" . $file)) {
            $rt['dir'][] = array('name' => get_utf8_path($file), 'path' => get_utf8_path(realpath($path . "/" . $file) . "/"));
        }
    }
    closedir($handle);
    return $rt;
}
示例#2
0
 * User: loveyu
 * Date: 2015/12/9
 * Time: 0:17
 */
require_once "common.php";
if (!is_login()) {
    show_403("Please login.");
}
$path = isset($_GET['path']) ? $_GET['path'] : "";
$ext = pathinfo($path, PATHINFO_EXTENSION);
if (empty($path)) {
    show_403("No empty.");
}
if (!in_ext_list($ext)) {
    show_403("No support.");
}
$path = get_sys_path($path);
if (!is_file($path)) {
    show_403("No found.");
}
$size = filesize($path);
header("Content-Type: image/{$ext}");
header("Content-Length: {$size}");
header("Content-Disposition:filename=" . basename($path));
flush();
$fp = fopen($path, "r");
while (!feof($fp)) {
    echo fread($fp, 65536);
    flush();
}
fclose($fp);
示例#3
0
<?php

/**
 * User: loveyu
 * Date: 2015/12/8
 * Time: 23:14
 */
require_once "common.php";
check_login();
$path = isset($_GET['path']) ? $_GET['path'] : null;
if (empty($path)) {
    header("Location: ?path=" . urlencode(get_default_path()));
    exit;
}
header("Content-Type: text/html; charset=utf-8");
if (!is_dir(get_sys_path($path))) {
    die("路径不存在");
}
$map = get_path_list($path);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>列表</title>
    <link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">