⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lister.php

📁 以前做的一个j2ee的项目
💻 PHP
📖 第 1 页 / 共 2 页
字号:
         $error = "File \'" . $HTTP_POST_FILES["image"]["name"] . "\' is not a supported type ($type)";
   }

   // ... otherwise, report the error
   else
      $error = "Invalid upload environment";
}

/*
** Emits the appropriate HTML for the specified File.
**
** Params:  $value - File name
**          $key - Array key (undefined)
**          $depth - Indent depth
*/
function fileTag($value, $key, $depth) {

   // initialize context
   $file = basePath($value);
   $size = @getImageSize(IMAGE_DIR . $file);

   // if Image size and type are available ...
   if($size) {

      // ... 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=\"";
      switch($size[2]) {
      case 1:
         echo scriptURL("gif.gif");
         break;
      case 2:
         echo scriptURL("jpg.gif");
         break;
      case 3:
         echo scriptURL("png.gif");
         break;
      }
      echo "\" alt=\"" . $value . "\">";
      echo "<a href=\"" . scriptURL("viewer.php?DPI=" . AGENT_DPI . "&file=" . urlencode($file)) . "\" target=\"" . VIEWER_NAME . "\">";
      echo $value;
      echo "</a>\n";
      echo "</td><td class=\"delete\" align=\"right\" valign=\"bottom\">\n";
      if(SUPPORT_DELETE) {
         echo "<a href=\"javascript:deletePath('" . $file . "')\">" . TEXT_DELETE . "</a>";
      }
      echo "</td></tr>\n";
   }
}

/*
** Emits the appropriate HTML for an Indent.
**
** Params:  $depth - Indent depth
*/
function indentTag($depth) {

   // if Indent is desired ...
   if($depth > 0) {
      $size = @getImageSize(SCRIPT_DIR . ICON_INDENT);

      // ... emit the HTML
      echo "<img src=\"" . scriptURL(ICON_INDENT) . "\" width=\"" . ($size[0] * $depth) . "\" height=\"" . $size[1] . "\">";
   }
}

/*
** Returns the empty status of the specified Directory.
**
** Params:  $path    - Path to check
**
** Return:  TRUE if Directory is empty; FALSE otherwise
*/
function isEmpty($path) {

   // initialize context
   $empty = TRUE;

   // if the Directory opens ...
   if(($dir = @opendir(IMAGE_DIR . $path))) {

      // ... while Files remain ...
      while($empty && FALSE !== ($file = readdir($dir))) {

         // ... if NOT hierarchy entries ...
         if($file != "." && $file != "..")

            // ... indicate NOT empty
            $empty = FALSE;
      }

      // close the Directory
      closedir($dir);
   }

   // return the status
   return $empty;
}

/*
** Returns an array of the Directories within the specified path.
**
** Return:  Array of Directory names
*/
function listDirs() {
   global $base;
   $result = array();

   // if the Directory opens ...
   if(($dir = @opendir(IMAGE_DIR . $base))) {

      // ... while Files remain ...
      while(FALSE !== ($file = readdir($dir))) {

         // ... if NOT hierarchy entries ...
         if($file != "." && $file != "..") {

            // ... if File is a Directory ...
            if(is_dir(IMAGE_DIR . basePath($file)))

               // ... return the Directory
               $result[] = $file;
         }
      }

      // close the Directory
      closedir($dir);
   }

   // return the Directories
   return $result;
}

/*
** Returns an array of the Files within the specified path.
**
** Params:  $filter - Extension filter(s)
**
** Return:  Array of File names
*/
function listFiles($filter = Array()) {
   global $base;
   $result = Array();

   // if the Directory opens ...
   if(($dir = @opendir(IMAGE_DIR . $base))) {
      $filters = count($filter);

      // ... while Files remain ...
      while(FALSE !== ($file = readdir($dir))) {

         // ... if File is NOT a Directory ...
         if(!(is_dir(IMAGE_DIR . basePath($file)))) {

            // ... if Filters were specified ...
            if($filters > 0) {
               $compare = (isWindows() ? "strcasecmp" : "strcmp");

               // ... isolate the Extension
               $parts = pathinfo(IMAGE_DIR . basePath($file));
               $ext = $parts["extension"];

               // for ALL specified Filters ...
               for($index = 0; $index < $filters; $index++) {

                  // ... if this a Filtered extension ...
                  if(!($compare($ext, $filter[$index])))

                     // ... get out now!
                     break;
               }

               // if File is NOT to be included ...
               if($index >= $filters)

                  // ... continue listing Files
                  continue;
            }

            // return the File
            $result[] = $file;
         }
      }

      // close the Directory
      closedir($dir);
   }

   // return the Files
   return $result;
}

// process GET/POST parameters
$action = "";
if(isset($HTTP_GET_VARS["action"]))
   $action = urldecode($HTTP_GET_VARS["action"]);
else if(isset($HTTP_POST_VARS["action"]))
   $action = urldecode($HTTP_POST_VARS["action"]);
$file = "";
if(SUPPORT_DELETE) {
   if(isset($HTTP_GET_VARS["file"]))
      $file = urldecode($HTTP_GET_VARS["file"]);
   else if(isset($HTTP_POST_VARS["file"]))
      $file = urldecode($HTTP_POST_VARS["file"]);
}
$folder = "";
if(SUPPORT_CREATE) {
   if(isset($HTTP_POST_VARS["folder"]))
      $folder = $HTTP_POST_VARS["folder"];
}
$name = "";
if(SUPPORT_UPLOAD) {
   if(isset($HTTP_POST_VARS["name"]))
      $name = $HTTP_POST_VARS["name"];
}
$path = "";
if(isset($HTTP_GET_VARS["path"]))
   $path = urldecode($HTTP_GET_VARS["path"]);
else if(isset($HTTP_POST_VARS["path"]))
   $path = urldecode($HTTP_POST_VARS["path"]);

// parse and clean the Path
cleanPath($path);

?>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php
// if CREATE is supported AND this is CREATE ...
if(SUPPORT_CREATE && !(strcasecmp($action, "create")))

   // ... create the Folder
   doCreate($folder);

// ... otherwise, if DELETE is supported AND this is DELETE ...
else if(SUPPORT_DELETE && !(strcasecmp($action, "delete")))

   // ... delete the Folder/File
   doDelete($file);

// ... otherwise, if UPLOAD is supported AND this is UPLOAD ...
else if(SUPPORT_UPLOAD && !(strcasecmp($action, "upload")))

   // ... upload the Image
   doUpload(basename($name));

// list the Path
doList();

// emit the HTML
echo "<script language=\"javascript\">\n";

// if DELETE is supported ...
if(SUPPORT_DELETE) {

   // ... emit the HTML
   echo "function deletePath(path) {\n";
   echo "   var lister = findAncestor(window.frameElement, '" . LISTER_NAME . "', '" . LISTER_TAG . "');\n\n";
   echo "   if(lister && confirm(\"Delete '\" + path + \"'?\"))\n";
   echo "      lister.contentWindow.navigate('" . scriptURL("lister.php?DPI=") . AGENT_DPI . "&action=delete&path=" . $base . "&file=" . "' + escape(path));\n";
   echo "}\n\n";
}
?>
actionComplete("<?php echo $action; ?>", "<?php echo $path; ?>", "<?php echo $error; ?>", "<?php echo $info; ?>");
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -