[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 fileList.php

Zen Cart 源代码 fileList.php




下载文件

文件名: fileList.php
文件类型: PHP文件
文件大小: 9.68 KiB
MD5: 8ba916c063a309776642adefb0c4714b

fileList.php - 关闭高亮
  1. <?php
  2. /*
  3. Directory Listing Script - Version 2
  4. ====================================
  5. Script Author: Ash Young <ash@evoluted.net>. www.evoluted.net
  6. Layout: Manny <manny@tenka.co.uk>. www.tenka.co.uk
  7.  
  8. REQUIREMENTS
  9. ============
  10. This script requires PHP and GD2 if you wish to use the
  11. thumbnail functionality.
  12.  
  13. INSTRUCTIONS
  14. ============
  15. 1) Unzip all files
  16. 2) Edit this file, making sure everything is setup as required.
  17. 3) Upload to server
  18. 4) ??????
  19. 5) Profit!
  20.  
  21. CONFIGURATION
  22. =============
  23. Edit the variables in this section to make the script work as
  24. you require.
  25.  
  26. Start Directory - To list the files contained within the current
  27. directory enter '.', otherwise enter the path to the directory
  28. you wish to list. The path must be relative to the current
  29. directory.
  30. */
  31. $startdir = DIR_FS_CATALOG . $tempdir;
  32.  
  33. /*
  34. Show Thumbnails? - Set to true if you wish to use the
  35. scripts auto-thumbnail generation capabilities.
  36. This requires that GD2 is installed.
  37. */
  38. $showthumbnails = true;
  39.  
  40. /*
  41. Show Directories - Do you want to make subdirectories available?
  42. If not set this to false
  43. */
  44. $showdirs = true;
  45.  
  46. /*
  47. Force downloads - Do you want to force people to download the files
  48. rather than viewing them in their browser?
  49. */
  50. $forcedownloads = false;
  51.  
  52. /*
  53. Hide Files - If you wish to hide certain files or directories
  54. then enter their details here. The values entered are matched
  55. against the file/directory names. If any part of the name
  56. matches what is entered below then it is now shown.
  57. */
  58. $hide = array(
  59.                 'dlf',
  60.                 'index.php',
  61.                 'Thumbs',
  62.                 '.htaccess',
  63.                 '.htpasswd',
  64.                 'fileList.php'
  65.             );
  66.              
  67. /*
  68. Show index files - if an index file is found in a directory
  69. to you want to display that rather than the listing output
  70. from this script?
  71. */         
  72. $displayindex = false;
  73.  
  74. /*
  75. Allow uploads? - If enabled users will be able to upload
  76. files to any viewable directory. You should really only enable
  77. this if the area this script is in is already password protected.
  78. */
  79. $allowuploads = false;
  80.  
  81. /*
  82. Overwrite files - If a user uploads a file with the same
  83. name as an existing file do you want the existing file
  84. to be overwritten?
  85. */
  86. $overwrite = false;
  87.  
  88. /*
  89. Index files - The follow array contains all the index files
  90. that will be used if $displayindex (above) is set to true.
  91. Feel free to add, delete or alter these
  92. */
  93.  
  94. $indexfiles = array (
  95.                 'index.html',
  96.                 'index.htm',
  97.                 'default.htm',
  98.                 'default.html'
  99.             );
  100.            
  101. /*
  102. File Icons - If you want to add your own special file icons use
  103. this section below. Each entry relates to the extension of the
  104. given file, in the form <extension> => <filename>.
  105. These files must be located within the dlf directory.
  106. */
  107. $filetypes = array (
  108.                 'png' => 'jpg.gif',
  109.                 'jpeg' => 'jpg.gif',
  110.                 'bmp' => 'jpg.gif',
  111.                 'jpg' => 'jpg.gif',
  112.                 'gif' => 'gif.gif',
  113.                 'zip' => 'archive.png',
  114.                 'rar' => 'archive.png',
  115.                 'exe' => 'exe.gif',
  116.                 'setup' => 'setup.gif',
  117.                 'txt' => 'text.png',
  118.                 'htm' => 'html.gif',
  119.                 'html' => 'html.gif',
  120.                 'fla' => 'fla.gif',
  121.                 'swf' => 'swf.gif',
  122.                 'xls' => 'xls.gif',
  123.                 'doc' => 'doc.gif',
  124.                 'sig' => 'sig.gif',
  125.                 'fh10' => 'fh10.gif',
  126.                 'pdf' => 'pdf.gif',
  127.                 'psd' => 'psd.gif',
  128.                 'rm' => 'real.gif',
  129.                 'mpg' => 'video.gif',
  130.                 'mpeg' => 'video.gif',
  131.                 'mov' => 'video2.gif',
  132.                 'avi' => 'video.gif',
  133.                 'eps' => 'eps.gif',
  134.                 'gz' => 'archive.png',
  135.                 'asc' => 'sig.gif',
  136.             );
  137.            
  138. /*
  139. That's it! You are now ready to upload this script to the server.
  140.  
  141. Only edit what is below this line if you are sure that you know what you
  142. are doing!
  143. */
  144. if(!function_exists('imagecreatetruecolor')) $showthumbnails = false;
  145. $leadon = $startdir;
  146. if($leadon=='.') $leadon = '';
  147. if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
  148. $startdir = $leadon;
  149.  
  150. if($_GET['dir']) {
  151.     //check this is okay.
  152.    
  153.     if(substr($_GET['dir'], -1, 1)!='/') {
  154.         $_GET['dir'] = $_GET['dir'] . '/';
  155.     }
  156.    
  157.     $dirok = true;
  158.     $dirnames = split('/', $_GET['dir']);
  159.     for($di=0; $di<sizeof($dirnames); $di++) {
  160.        
  161.         if($di<(sizeof($dirnames)-2)) {
  162.             $dotdotdir = $dotdotdir . $dirnames[$di] . '/';
  163.         }
  164.        
  165.         if($dirnames[$di] == '..') {
  166.             $dirok = false;
  167.         }
  168.     }
  169.    
  170.     if(substr($_GET['dir'], 0, 1)=='/') {
  171.         $dirok = false;
  172.     }
  173.    
  174.     if($dirok) {
  175.          $leadon = $leadon . $_GET['dir'];
  176.     }
  177. }
  178.  
  179. if($_GET['download'] && $forcedownloads) {
  180.     $file = str_replace('/', '', $_GET['download']);
  181.     $file = str_replace('..', '', $file);
  182.  
  183.     if(file_exists($leadon . $file)) {
  184.         header("Content-type: application/x-download");
  185.         header("Content-Length: ".filesize($leadon . $file));
  186.         header('Content-Disposition: attachment; filename="'.$file.'"');
  187.         readfile($leadon . $file);
  188.         die();
  189.     }
  190. }
  191.  
  192.  
  193.  
  194. $opendir = $leadon;
  195. if(!$leadon) $opendir = '.';
  196. if(!file_exists($opendir)) {
  197.     $opendir = '.';
  198.     $leadon = $startdir;
  199. }
  200.  
  201. if ($handle = opendir($opendir)) {
  202.     while (false !== ($file = readdir($handle))) {
  203.         //first see if this file is required in the listing
  204.         if ($file == "." || $file == "..")  continue;
  205.         $discard = false;
  206.         for($hi=0;$hi<sizeof($hide);$hi++) {
  207.             if(strpos($file, $hide[$hi])!==false) {
  208.                 $discard = true;
  209.             }
  210.         }
  211.        
  212.         if($discard) continue;
  213.         if (@filetype($leadon.$file) == "dir") {
  214.             if(!$showdirs) continue;
  215.        
  216.             $n++;
  217.             if($_GET['sort']=="date") {
  218.                 $key = @filemtime($leadon.$file) . ".$n";
  219.             }
  220.             else {
  221.                 $key = $n;
  222.             }
  223.             $dirs[$key] = $file . "/";
  224.         }
  225.         else {
  226.             $n++;
  227.             if($_GET['sort']=="date") {
  228.                 $key = @filemtime($leadon.$file) . ".$n";
  229.             }
  230.             elseif($_GET['sort']=="size") {
  231.                 $key = @filesize($leadon.$file) . ".$n";
  232.             }
  233.             else {
  234.                 $key = $n;
  235.             }
  236.             $files[$key] = $file;
  237.            
  238.             if($displayindex) {
  239.                 if(in_array(strtolower($file), $indexfiles)) {
  240.                     header("Location: $file");
  241.                     die();
  242.                 }
  243.             }
  244.         }
  245.     }
  246.     closedir($handle);
  247. }
  248.  
  249. //sort our files
  250. if($_GET['sort']=="date") {
  251.     @ksort($dirs, SORT_NUMERIC);
  252.     @ksort($files, SORT_NUMERIC);
  253. }
  254. elseif($_GET['sort']=="size") {
  255.     @natcasesort($dirs);
  256.     @ksort($files, SORT_NUMERIC);
  257. }
  258. else {
  259.     @natcasesort($dirs);
  260.     @natcasesort($files);
  261. }
  262.  
  263. //order correctly
  264. if($_GET['order']=="desc" && $_GET['sort']!="size") {$dirs = @array_reverse($dirs);}
  265. if($_GET['order']=="desc") {$files = @array_reverse($files);}
  266. $dirs = @array_values($dirs); $files = @array_values($files);
  267.  
  268.  
  269. ?>
  270. <link rel="stylesheet" type="text/css" href="../<?php echo $tempdir; ?>dlf/styles.css" />
  271. <?php
  272. if($showthumbnails) {
  273. ?>
  274. <script language="javascript" type="text/javascript">
  275. <!--
  276. function o(n, i) {
  277.     document.images['thumb'+n].src = '../<?php echo $tempdir; ?>dlf/i.php?f='+i;
  278.  
  279. }
  280.  
  281. function f(n) {
  282.     document.images['thumb'+n].src = '../<?php echo $tempdir; ?>dlf/trans.gif';
  283. }
  284. //-->
  285. </script>
  286. <?php
  287. }
  288. ?>
  289. <div id="dlf_container">
  290.   <?php
  291.  
  292.     $baseurl = $_SERVER['PHP_SELF'] . '?dir='.$_GET['dir'] . '&amp;';
  293.     $fileurl = 'sort=name&amp;order=asc';
  294.     $sizeurl = 'sort=size&amp;order=asc';
  295.     $dateurl = 'sort=date&amp;order=asc';
  296.    
  297.     switch ($_GET['sort']) {
  298.         case 'name':
  299.             if($_GET['order']=='asc') $fileurl = 'sort=name&amp;order=desc';
  300.             break;
  301.         case 'size':
  302.             if($_GET['order']=='asc') $sizeurl = 'sort=size&amp;order=desc';
  303.             break;
  304.            
  305.         case 'date':
  306.             if($_GET['order']=='asc') $dateurl = 'sort=date&amp;order=desc';
  307.             break;  
  308.         default:
  309.             $fileurl = 'sort=name&amp;order=desc';
  310.             break;
  311.     }
  312.   ?>
  313.     <form enctype="multipart/form-data" action="easypopulate.php" method="post">
  314.         <input type='hidden' name='localfile' value=''>
  315.     <div id="listingcontainer">
  316.         <div id="listingheader">
  317.         <div id="headerfile"><a href="<?php echo $baseurl . $fileurl; ?>">File</a></div>
  318.         <div id="headersize"><a href="<?php echo $baseurl . $sizeurl; ?>">Size</a></div>
  319.         <div id="headermodified"><a href="<?php echo $baseurl . $dateurl; ?>">Last Modified</a></div>
  320.         </div>
  321.         <div id="listing">
  322.         <?php
  323.         $class = 'b';
  324.  
  325.         $arsize = sizeof($files);
  326.         for($i=0;$i<$arsize;$i++) {
  327.             $icon = 'unknown.png';
  328.             $ext = strtolower(substr($files[$i], strrpos($files[$i], '.')+1));
  329.             $supportedimages = array('gif', 'png', 'jpeg', 'jpg');
  330.             $thumb = '';
  331.  
  332.             if($showthumbnails && in_array($ext, $supportedimages)) {
  333.                 $thumb = '<span><img src="../'.$tempdir.'dlf/trans.gif" alt="'.$files[$i].'" name="thumb'.$i.'" /></span>';
  334.                 $thumb2 = ' onmouseover="o('.$i.', \''.urlencode($leadon . $files[$i]).'\');" onmouseout="f('.$i.');"';
  335.                
  336.             }
  337.  
  338.             if($filetypes[$ext]) {
  339.                 $icon = $filetypes[$ext];
  340.             }
  341.  
  342.             $filename = $files[$i];
  343.             if(strlen($filename)>43) {
  344.                 $filename = substr($files[$i], 0, 40) . '...';
  345.             }
  346.  
  347.             $fileurl = $leadon . $files[$i];
  348.             if(!$forcedownloads) {
  349.                 $fileurl = $_SESSION['PHP_SELF'] . '?dir=' . urlencode($leadon) . '&download=' . urlencode($files[$i]);
  350.             }
  351.             $fileurl = "../".$tempdir.$files[$i];
  352.  
  353.             ?>
  354.             <div>
  355.                 <input type="submit" value="Import" onClick="this.form.localfile.value='<?php echo $files[$i]; ?>';" style="float:left; width:50px;">
  356.                 <a href="<?php echo $fileurl; ?>" class="<?php echo $class; ?>"<?php echo $thumb2; ?> >
  357.                     <img src="../<?php echo $tempdir; ?>dlf/<?php echo $icon; ?>" alt="<?php echo $files[$i]; ?>" />
  358.                     <strong><?php echo $filename; ?></strong> <em><?php echo round(filesize($leadon.$files[$i])/1024); ?>KB</em>
  359.                     <?php echo str_replace(" ","&nbsp;",date("M d Y h:i:s A", filemtime($leadon.$files[$i]))); ?><?php echo $thumb; ?>
  360.                 </a>
  361.             </div>
  362.             <?php
  363.             if($class=='b') $class='w';
  364.             else $class = 'b'; 
  365.         }  
  366.         ?></div>
  367.  
  368.         </div>
  369.     </div>
  370.     </form>
  371. <!-- div id="copy">Directory Listing Script &copy;2008 Evoluted, <a href="http://www.evoluted.net/">Web Design Sheffield</a>.</div -->
  372.  


cron