📄 lister.php
字号:
<html>
<head>
<?php
require("config.inc.php");
?>
<style type="text/css">
TD { <?php echo LISTER_STYLE; ?> }
TD.delete { <?php echo LISTER_DELETE; ?> }
</style>
<script language="javascript">
function actionComplete(action, path, error, info) {
var manager = findAncestor(window.frameElement, '<?php echo MANAGER_NAME; ?>', '<?php echo MANAGER_TAG; ?>');
var wrapper = findAncestor(window.frameElement, '<?php echo WRAPPER_NAME; ?>', '<?php echo WRAPPER_TAG; ?>');
if(manager) {
if(error.length < 1) {
manager.all.actions.reset();
<?php
// if UPLOAD is supported ...
if(SUPPORT_UPLOAD) {
// ... emit the JavaScript
echo " if(action == 'upload') {\n";
echo " manager.all.actions.image.value = '';\n";
echo " manager.all.actions.name.value = '';\n";
echo " }\n";
}
// if CREATE is supported ...
if(SUPPORT_CREATE) {
// ... emit the JavaScript
echo " if(action == 'create')\n";
echo " manager.all.actions.folder.value = '';\n";
}
// if DELETE is supported ...
if(SUPPORT_DELETE) {
// ... emit the JavaScript
echo " if(action == 'delete')\n";
echo " manager.all." . MANAGER_SRC . ".value = '';\n";
}
?>
}
manager.all.actions.DPI.value = <?php echo AGENT_DPI; ?>;
manager.all.actions.path.value = path;
}
if(wrapper)
wrapper.all.viewer.contentWindow.navigate('<?php echo scriptURL("viewer.php?DPI=") . AGENT_DPI; ?>');
if(error.length > 0)
alert(error);
else if(info.length > 0)
alert(info);
}
</script>
</head>
<?php
/*
** Emits the appropriate HTML for the specified Directory.
**
** Params: $value - Directory name
** $key - Array key (undefined)
** $depth - Indent depth
** $icon - Icon filename
** $link - TRUE if Directory should be linked; FALSE otherwise
*/
function dirTag($value, $key, $depth, $icon = ICON_CLOSED, $link = TRUE) {
global $HTTP_SERVER_VARS, $base;
// initialize context
$path = basePath($value, ($depth - 1));
// emit the HTML
echo "<tr><td align=\"left\" valign=\"bottom\" width=\"100%\">\n";
// indent as required
indentTag($depth);
// emit the HTML
echo "<img align=\"bottom\" src=\"" . scriptURL($icon) . "\" alt=\"$value\">";
if($link) {
echo "<a href=\"" . scriptURL(basename($HTTP_SERVER_VARS["PHP_SELF"])) . "?DPI=" . AGENT_DPI;
if(strcmp(TEXT_ROOT, $value))
echo "&path=" . urlencode($path);
echo "\">";
}
echo "<b>$value</b>";
echo "</a>";
echo "</td><td class=\"delete\" align=\"right\" valign=\"bottom\">\n";
if(SUPPORT_DELETE) {
if(!(strcmp($icon, ICON_CLOSED)) && isEmpty($path))
echo "<a href=\"javascript:deletePath('" . $path . "')\">" . TEXT_DELETE . "</a>";
}
echo "</td></tr>\n";
}
/*
** Creates a new Folder.
**
** Params: $folder - Folder to create
*/
function doCreate($folder) {
global $error;
// initialize context
$path = basePath($folder);
// if Folder does NOT already exist ...
if(!(file_exists(IMAGE_DIR . $path))) {
// ... if Folder does NOT create ...
if(!(@mkdir(IMAGE_DIR . $path, 0777)))
// ... report the error
$error = "Folder \'" . $path . "\' could not be created";
}
// ... otherwise, report the error
else
$error = "Folder \'" . $path . "\' already exists";
}
/*
** Deletes a Folder/File.
**
** Params: $file - Folder/file to delete
*/
function doDelete($file) {
global $base, $error;
// if Folder/File exists ...
if(file_exists(IMAGE_DIR . $file)) {
// ... if this is a Folder ...
if(is_dir(IMAGE_DIR . $file)) {
// ... if Folder does NOT delete ...
if(!(@rmdir(IMAGE_DIR . $file)))
// ... report the error
$error = "Folder \'" . $file . "\' could not be deleted";
}
// ... otherwise, if File does NOT delete ...
else if(!(@unlink(IMAGE_DIR . $file)))
// ... report the error
$error = "Image \'" . $file . "\' could not be deleted";
}
// ... otherwise, report the error
else
$error = "Folder or file \'" . $file . "\' not found";
}
/*
** Lists a Path.
*/
function doList() {
global $dirs;
// initialize context
$nodes = 0;
$current = (count($dirs) + 1);
// emit the HTML
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
dirTag(TEXT_ROOT, "", $nodes++, ICON_OPENED);
// for ALL Directories in the Path ...
foreach($dirs as $dir) {
// ... if Directory is exists ...
if(strlen($dir) > 0)
// ... emit the HTML
dirTag($dir, "", $nodes++, ICON_OPENED, ($nodes != $current));
}
// list Directories and emit the HTML
$list = listDirs();
array_walk($list, dirTag, $nodes);
// list Image files and emit the HTML
$list = listFiles(array("gif", "jpg", "jpeg", "png"));
array_walk($list, fileTag, $nodes);
// emit the HTML
echo "</table>\n";
}
/*
** Uploads an Image.
**
** Params: $name - Name for uploaded Image
*/
function doUpload($name) {
global $HTTP_POST_FILES, $error, $info;
// initialize context
$temp = $HTTP_POST_FILES["image"]["tmp_name"];
// if File is a legitimate upload ...
if(is_uploaded_file($temp)) {
$type = $HTTP_POST_FILES["image"]["type"];
$types = array("image/gif" => "[.]gif$", "image/jpg" => "[.]jp[e]?g$", "image/jpeg" => "[.]jp[e]?g$", "image/pjpeg" => "[.]jp[e]?g$", "image/png" => "[.]png$", "image/x-png" => "[.]png$");
// ... if File is a valid image ...
if(isset($types[$type])) {
$search = (isWindows() ? "eregi" : "ereg");
$replace = (isWindows() ? "eregi" : "ereg");
// ... if Name was NOT specified ...
if(strlen($name) < 1)
// ... use the same Name
$name = $HTTP_POST_FILES["image"]["name"];
// if File has NO or an improper extension ...
if(!($search($types[$type], $name))) {
$exts = array("image/gif" => ".gif", "image/jpg" => ".jpg", "image/jpeg" => ".jpg", "image/pjpeg" => ".jpg", "image/png" => ".png", "image/x-png" => ".png");
// ... if NO extension exists ...
if(!($search("[.].+$", $name)))
// ... append the proper extension
$name .= $exts[$type];
// ... otherwise, force a proper extension
else
$name = $replace("[.].*$", $exts[$type], $name);
// notify the user
$info = "Proper extension was added to make \'" . $name . "\' valid for this image type";
}
// if File has the proper extension now ...
if($search($types[$type], $name)) {
$path = basePath($name);
// ... if File does NOT already exist ...
if(!(file_exists(IMAGE_DIR . $path))) {
$size = $HTTP_POST_FILES["image"]["size"];
// ... if NO size limit exists OR File is NOT over the limit ...
if(UPLOAD_LIMIT == 0 || $size <= UPLOAD_LIMIT) {
// ... if File CANNOT be copied ...
if(!(@copy($temp, (IMAGE_DIR . $path))))
// ... report the error
$error = "File \'" . $path . "\' could not be created";
}
// ... otherwise, report the error
else
$error = "File \'" . $path . "\' exceeds " . round((UPLOAD_LIMIT / 1024)) . " KByte size limit";
}
// ... otherwise, report the error
else
$error = "File \'" . $path . "\' already exists";
}
// ... otherwise, report the error
else
$error = "Files of type \'" . $type . "\' require a matching extension";
}
// ... otherwise, report the error
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -