include 'library.php';
$ME = $_SERVER['PHP_SELF'];
$FOLDER = "folder.gif";
$CELLSIZE = 150;
$TABLEWIDTH = 5;
function startTable() {
global $CELLSIZE;
print("
\n");
}
function addCell($image, $text, $hint, $link, $target) {
global $TABLEWIDTH;
global $CELLSIZE;
static $colCount = 0;
if ($colCount == 0) print("");
print("\n");
print(" $text");
print(" | \n");
$colCount++;
if ($colCount == $TABLEWIDTH) {
$colCount = 0;
print("
");
}
}
function endTable() {
print("
\n");
}
function authBaseDir($dir) {
return (file_exists("$dir/explore.auth") ||
file_exists("$dir/../explore.auth") ||
file_exists("$dir/../../explore.auth") ||
file_exists("$dir/../../../explore.auth") ||
file_exists("$dir/../../../../explore.auth") ||
file_exists("$dir/../../../../../explore.auth"));
}
function lss ($baseDir, $subDir) {
global $FOLDER;
global $ME;
global $THUMB;
//if ($subDir == "") $subDir = ".";
$fullDir = $baseDir;
if ($subDir != "") $fullDir .= "/". $subDir;
print("Navegación: ");
$dirs = explode("/", $subDir);
print("Inicio ");
$addDir = "";
foreach($dirs as $nextDir) {
if ($nextDir == "") continue;
if ($addDir == "") $addDir = myurlencode($nextDir); else $addDir .= "/".myurlencode($nextDir);
print("» $nextDir ");
}
print("
\n");
startTable();
$images = array();
$folders = array();
$d = @ dir($fullDir);
if ($d != FALSE) {
while($entry = $d->read()) {
if (($entry != ".") && ($entry != "..") && ($entry != "php") && ($entry != "php2")) {
if (is_dir("$fullDir/$entry")) {
$folders[] = $entry;
}
else
if (isJPG($entry) && (! isThumb($entry)) ) {
$images[] = $entry;
}
}
}
$d->close();
}
sort($images);
sort($folders);
foreach ($folders as $entry) {
addCell($FOLDER, $entry, "Abrir", "$ME?" . myurlencode($baseDir . "&" . $subDir . "/" . $entry), "");
}
foreach ($images as $entry) {
$noExt = substr($entry, 0, strlen($entry)-4);
$url = "view.php?" . myurlencode("$fullDir/$entry&$noExt");
addCell("$fullDir/$noExt"."$THUMB.jpg", $noExt, "Clic para ampliar", $url, "newwin");
}
endTable();
}
$queryArray = explode('&', $_SERVER['QUERY_STRING']);
$baseDir = $queryArray[0];
$subDir = $queryArray[1];
if (($baseDir == "") || (! authBaseDir($baseDir))) {
startHTML("Acceso restirngidoo");
print("Acceso restingido
");
endHTML();
exit(403);
}
else {
startHTML("Imagenes");
lss(myurldecode($baseDir), myurldecode($subDir));
endHTML();
}
?>