# HG changeset patch # User edogawaconan # Date 1413463117 -32400 # Node ID 8cba59d07798631994a8e696327468ed3db24ea9 Initial import. diff -r 000000000000 -r 8cba59d07798 index.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.php Thu Oct 16 21:38:37 2014 +0900 @@ -0,0 +1,99 @@ +".h($title).""); +} +function print_header() +{ + global $link_prefix, $link_base, $to_dir; + $path_tree = link_to('/', '[root]') . "/"; + foreach ($to_dir as $level => $dir) + { + if($dir) + { + $link = "/"; + for ($i = 0; $i <= $level; $i++) { $link .= "$to_dir[$i]/"; } + $path_tree .= link_to($link, $dir)."/"; + } + } + header('Content-Type: text/html; charset=utf-8'); + echo " + + Index of ", h(rtrim($link_base,"/")."/"), " + +

Index of $path_tree

"; +} +function nice_size($size) +{ + static $unit = array('B', 'KB', 'MB', 'GB', 'TB'); + for ($i = 0; $size >= 1000 && $i < count($unit); $i++) { $size /= 1000; } + if ($i == 0) { return(sprintf("%d %s", $size, $unit[$i])); } + else { return(sprintf("%.2f %s", $size, $unit[$i])); } +} +function file_rows($files, $is_dir) +{ + global $path, $link_base, $link_prefix; + static $unit = array('B', 'KB', 'MB', 'GB', 'TB'); + $file_rows = ""; + if ($is_dir) + { + $file_suffix = "/"; + if($link_base != $link_prefix) + { + $file_rows .= "".link_to(dirname($link_base),"..").""; + } + } else { $file_suffix = ""; } + foreach($files as $file) + { + $file_stat = stat("$path/".$file); + $file_rows .= "". + link_to("$link_base/".$file, $file.$file_suffix)."". + h(strftime("%a %d-%b-%G %H:%M", $file_stat['mtime'])).""; + if ($is_dir) { $file_rows .= "[dir]"; } + else { $file_rows .= nice_size($file_stat['size']); } + $file_rows .= ""; + } + return $file_rows; +} +function print_list() +{ + global $dirs, $files; + echo "", + "", + "", + "", + "", + "", file_rows($dirs, true), file_rows($files, false), "", + "
FileDateSize
"; +} +function print_footer() +{ +echo ""; +} +print_header(); +print_list(); +print_footer(); +?>