<?php
if ($_GET["act"] == "get" && $_GET["path"] != "") {
getFile($_GET["path"]);
exit;
}
?>
<html>
<head>
<title>
PHP Explorer
</title>
</head>
<style>
a {text-decoration:none;}
a.dir {color:red;}
a.file {color:green;}
body {margin-left:50px;}
</style>
<body>
<?php
define("BR", "<br>");
function getFile($path) {
/*$minutes = 10;
set_time_limit(60 * $minutes);*/
set_time_limit(0);
$file = realpath($path);
header("Content-Type: application/save");
header("Content-Transfer-Encoding: Binary");
header("Content-length: " . filesize($file));
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
readfile ("$file");
}
function seeDir($path) {
$me = $_SERVER["PHP_SELF"];
$path = realpath($path);
$G = "/";
if (strpos($path, "/") === false) {$G = "\\";}
echo "<span onclick='window.location=\"$me\";' style='cursor:pointer;color:blue;'>Home</span> ";
echo "<b>Path: </b>" . $path . " <span onclick='history.back(1);' style='cursor:pointer;color:blue;'>Back</span>" . BR;
$sd = array(); $f = array();
$i = 0;
$handle = @opendir($path);
if (!$handle) {
echo "<b>PVH:</b> Handle is NULL";
return;
}
while (($entry = readdir($handle)) !== false) {
$p = trim($path,"\\/") . $G . $entry;
if (is_dir($p)) array_push($sd, $p);
elseif (is_file($p)) array_push($f, $p);
if (++$i > 3000) {
echo "This dir containts too much file and sub dir. Above result is a part of list" . BR;
break;
}
}
closedir($handle);
echo "####DIR###" . BR;
foreach ($sd as $e) {
$name = basename($e);
if ($name == ".") continue;
echo '<a class=dir href="?path=' . $e . '">' . $name . "</a>" . BR;
}
echo "###FILE###" . BR;
foreach ($f as $e) {
echo '<a class=file href="?path=' . $e . '">' . basename($e) . '</a> <a class=getfile href="?act=get&path=' . $e . '">>></a>' . BR;
}
}
function seeFile($path) {
$path = realpath($path);
$name = basename($path); $type = filetype($path);
$size = filesize($path);
$mtime = date ("H:i:s d/m/Y", filemtime($path));
echo "<b>Path: </b>$path <span onclick='history.back(1);' style='cursor:pointer;color:blue;'>Back</span>" . BR;
echo "<b>Name: </b>$name" . BR;
//echo "<b>Type: </b>$type" . BR;
echo "<b>Last Modified: </b>$mtime" . BR;
echo "<b>Size: </b>$size bytes" . BR;
if ($size > 10240) {
echo "File is too big to see!";
return;
}
$content = file_get_contents($path);
$content = htmlspecialchars($content);
echo "<pre onclick='this.style.fontSize=16;' ondblclick='this.style.fontSize=24;' style='border:1px solid brown;height:450px;overflow:auto;font-size:16px;font-family:Times;'>$content</pre>";
}
$path = $_GET["path"]; if ($path == "") $path = dirname(__FILE__);
if (is_dir($path)) {
seeDir($path);
} elseif (is_file($path)) {
seeFile($path);
} else {
echo "<b>#.#</b>";
}
?>
Title:
Simple file explorer
Description:
<?php if ($_GET["act"] == "get" && $_GET["path"] != "") { getFile($_GET[...
...
Rating:
4