[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 源代码 index.php

Zen Cart 源代码 index.php




下载文件

文件名: index.php
文件类型: PHP文件
文件大小: 11.63 KiB
MD5: c4e892d7a8c08a276373409baae1625e

index.php - 关闭高亮
  1. <?
  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 = '.';
  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.             );
  65.              
  66. /*
  67. Show index files - if an index file is found in a directory
  68. to you want to display that rather than the listing output
  69. from this script?
  70. */         
  71. $displayindex = false;
  72.  
  73. /*
  74. Allow uploads? - If enabled users will be able to upload
  75. files to any viewable directory. You should really only enable
  76. this if the area this script is in is already password protected.
  77. */
  78. $allowuploads = false;
  79.  
  80. /*
  81. Overwrite files - If a user uploads a file with the same
  82. name as an existing file do you want the existing file
  83. to be overwritten?
  84. */
  85. $overwrite = false;
  86.  
  87. /*
  88. Index files - The follow array contains all the index files
  89. that will be used if $displayindex (above) is set to true.
  90. Feel free to add, delete or alter these
  91. */
  92.  
  93. $indexfiles = array (
  94.                 'index.html',
  95.                 'index.htm',
  96.                 'default.htm',
  97.                 'default.html'
  98.             );
  99.            
  100. /*
  101. File Icons - If you want to add your own special file icons use
  102. this section below. Each entry relates to the extension of the
  103. given file, in the form <extension> => <filename>.
  104. These files must be located within the dlf directory.
  105. */
  106. $filetypes = array (
  107.                 'png' => 'jpg.gif',
  108.                 'jpeg' => 'jpg.gif',
  109.                 'bmp' => 'jpg.gif',
  110.                 'jpg' => 'jpg.gif',
  111.                 'gif' => 'gif.gif',
  112.                 'zip' => 'archive.png',
  113.                 'rar' => 'archive.png',
  114.                 'exe' => 'exe.gif',
  115.                 'setup' => 'setup.gif',
  116.                 'txt' => 'text.png',
  117.                 'htm' => 'html.gif',
  118.                 'html' => 'html.gif',
  119.                 'fla' => 'fla.gif',
  120.                 'swf' => 'swf.gif',
  121.                 'xls' => 'xls.gif',
  122.                 'doc' => 'doc.gif',
  123.                 'sig' => 'sig.gif',
  124.                 'fh10' => 'fh10.gif',
  125.                 'pdf' => 'pdf.gif',
  126.                 'psd' => 'psd.gif',
  127.                 'rm' => 'real.gif',
  128.                 'mpg' => 'video.gif',
  129.                 'mpeg' => 'video.gif',
  130.                 'mov' => 'video2.gif',
  131.                 'avi' => 'video.gif',
  132.                 'eps' => 'eps.gif',
  133.                 'gz' => 'archive.png',
  134.                 'asc' => 'sig.gif',
  135.             );
  136.            
  137. /*
  138. That's it! You are now ready to upload this script to the server.
  139.  
  140. Only edit what is below this line if you are sure that you know what you
  141. are doing!
  142. */
  143. if(!function_exists('imagecreatetruecolor')) $showthumbnails = false;
  144. $leadon = $startdir;
  145. if($leadon=='.') $leadon = '';
  146. if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
  147. $startdir = $leadon;
  148.  
  149. if($_GET['dir']) {
  150.     //check this is okay.
  151.    
  152.     if(substr($_GET['dir'], -1, 1)!='/') {
  153.         $_GET['dir'] = $_GET['dir'] . '/';
  154.     }
  155.    
  156.     $dirok = true;
  157.     $dirnames = split('/', $_GET['dir']);
  158.     for($di=0; $di<sizeof($dirnames); $di++) {
  159.        
  160.         if($di<(sizeof($dirnames)-2)) {
  161.             $dotdotdir = $dotdotdir . $dirnames[$di] . '/';
  162.         }
  163.        
  164.         if($dirnames[$di] == '..') {
  165.             $dirok = false;
  166.         }
  167.     }
  168.    
  169.     if(substr($_GET['dir'], 0, 1)=='/') {
  170.         $dirok = false;
  171.     }
  172.    
  173.     if($dirok) {
  174.          $leadon = $leadon . $_GET['dir'];
  175.     }
  176. }
  177.  
  178. if($_GET['download'] && $forcedownloads) {
  179.     $file = str_replace('/', '', $_GET['download']);
  180.     $file = str_replace('..', '', $file);
  181.  
  182.     if(file_exists($leadon . $file)) {
  183.         header("Content-type: application/x-download");
  184.         header("Content-Length: ".filesize($leadon . $file));
  185.         header('Content-Disposition: attachment; filename="'.$file.'"');
  186.         readfile($leadon . $file);
  187.         die();
  188.     }
  189. }
  190.  
  191. if($allowuploads && $_FILES['file']) {
  192.     $upload = true;
  193.     if(!$overwrite) {
  194.         if(file_exists($leadon.$_FILES['file']['name'])) {
  195.             $upload = false;
  196.         }
  197.     }
  198.    
  199.     if($upload) {
  200.         move_uploaded_file($_FILES['file']['tmp_name'], $leadon . $_FILES['file']['name']);
  201.     }
  202. }
  203.  
  204. $opendir = $leadon;
  205. if(!$leadon) $opendir = '.';
  206. if(!file_exists($opendir)) {
  207.     $opendir = '.';
  208.     $leadon = $startdir;
  209. }
  210.  
  211. if ($handle = opendir($opendir)) {
  212.     while (false !== ($file = readdir($handle))) {
  213.         //first see if this file is required in the listing
  214.         if ($file == "." || $file == "..")  continue;
  215.         $discard = false;
  216.         for($hi=0;$hi<sizeof($hide);$hi++) {
  217.             if(strpos($file, $hide[$hi])!==false) {
  218.                 $discard = true;
  219.             }
  220.         }
  221.        
  222.         if($discard) continue;
  223.         if (@filetype($leadon.$file) == "dir") {
  224.             if(!$showdirs) continue;
  225.        
  226.             $n++;
  227.             if($_GET['sort']=="date") {
  228.                 $key = @filemtime($leadon.$file) . ".$n";
  229.             }
  230.             else {
  231.                 $key = $n;
  232.             }
  233.             $dirs[$key] = $file . "/";
  234.         }
  235.         else {
  236.             $n++;
  237.             if($_GET['sort']=="date") {
  238.                 $key = @filemtime($leadon.$file) . ".$n";
  239.             }
  240.             elseif($_GET['sort']=="size") {
  241.                 $key = @filesize($leadon.$file) . ".$n";
  242.             }
  243.             else {
  244.                 $key = $n;
  245.             }
  246.             $files[$key] = $file;
  247.            
  248.             if($displayindex) {
  249.                 if(in_array(strtolower($file), $indexfiles)) {
  250.                     header("Location: $file");
  251.                     die();
  252.                 }
  253.             }
  254.         }
  255.     }
  256.     closedir($handle);
  257. }
  258.  
  259. //sort our files
  260. if($_GET['sort']=="date") {
  261.     @ksort($dirs, SORT_NUMERIC);
  262.     @ksort($files, SORT_NUMERIC);
  263. }
  264. elseif($_GET['sort']=="size") {
  265.     @natcasesort($dirs);
  266.     @ksort($files, SORT_NUMERIC);
  267. }
  268. else {
  269.     @natcasesort($dirs);
  270.     @natcasesort($files);
  271. }
  272.  
  273. //order correctly
  274. if($_GET['order']=="desc" && $_GET['sort']!="size") {$dirs = @array_reverse($dirs);}
  275. if($_GET['order']=="desc") {$files = @array_reverse($files);}
  276. $dirs = @array_values($dirs); $files = @array_values($files);
  277.  
  278.  
  279. ?>
  280. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  281. <html xmlns="http://www.w3.org/1999/xhtml">
  282. <head>
  283. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  284. <title>Directory Listing of <?=dirname($_SERVER['PHP_SELF']).'/'.$leadon;?></title>
  285. <link rel="stylesheet" type="text/css" href="dlf/styles.css" />
  286. <?
  287. if($showthumbnails) {
  288. ?>
  289. <script language="javascript" type="text/javascript">
  290. <!--
  291. function o(n, i) {
  292.     document.images['thumb'+n].src = 'dlf/i.php?f='+i;
  293.  
  294. }
  295.  
  296. function f(n) {
  297.     document.images['thumb'+n].src = 'dlf/trans.gif';
  298. }
  299. //-->
  300. </script>
  301. <?
  302. }
  303. ?>
  304. </head>
  305. <body>
  306. <div id="dlf_container">
  307.   <h1>Directory Listing of <?=dirname($_SERVER['PHP_SELF']).'/'.$leadon;?></h1>
  308.   <div id="breadcrumbs"> <a href="<?=$_SERVER['PHP_SELF'];?>">home</a>
  309.   <?
  310.      $breadcrumbs = split('/', $leadon);
  311.     if(($bsize = sizeof($breadcrumbs))>0) {
  312.         $sofar = '';
  313.         for($bi=0;$bi<($bsize-1);$bi++) {
  314.             $sofar = $sofar . $breadcrumbs[$bi] . '/';
  315.             echo ' &gt; <a href="'.$_SERVER['PHP_SELF'].'?dir='.urlencode($sofar).'">'.$breadcrumbs[$bi].'</a>';
  316.         }
  317.     }
  318.  
  319.     $baseurl = $_SERVER['PHP_SELF'] . '?dir='.$_GET['dir'] . '&amp;';
  320.     $fileurl = 'sort=name&amp;order=asc';
  321.     $sizeurl = 'sort=size&amp;order=asc';
  322.     $dateurl = 'sort=date&amp;order=asc';
  323.    
  324.     switch ($_GET['sort']) {
  325.         case 'name':
  326.             if($_GET['order']=='asc') $fileurl = 'sort=name&amp;order=desc';
  327.             break;
  328.         case 'size':
  329.             if($_GET['order']=='asc') $sizeurl = 'sort=size&amp;order=desc';
  330.             break;
  331.            
  332.         case 'date':
  333.             if($_GET['order']=='asc') $dateurl = 'sort=date&amp;order=desc';
  334.             break;  
  335.         default:
  336.             $fileurl = 'sort=name&amp;order=desc';
  337.             break;
  338.     }
  339.   ?>
  340.   </div>
  341.   <div id="listingcontainer">
  342.     <div id="listingheader">
  343.     <div id="headerfile"><a href="<?=$baseurl . $fileurl;?>">File</a></div>
  344.     <div id="headersize"><a href="<?=$baseurl . $sizeurl;?>">Size</a></div>
  345.     <div id="headermodified"><a href="<?=$baseurl . $dateurl;?>">Last Modified</a></div>
  346.     </div>
  347.     <div id="listing">
  348.     <?
  349.     $class = 'b';
  350.     if($dirok) {
  351.     ?>
  352.     <div><a href="<?=$_SERVER['PHP_SELF'].'?dir='.urlencode($dotdotdir);?>" class="<?=$class;?>"><img src="dlf/dirup.png" alt="Folder" /><strong>..</strong> <em>-</em> <?=date ("M d Y h:i:s A", filemtime($dotdotdir));?></a></div>
  353.     <?
  354.         if($class=='b') $class='w';
  355.         else $class = 'b';
  356.     }
  357.     $arsize = sizeof($dirs);
  358.     for($i=0;$i<$arsize;$i++) {
  359.     ?>
  360.     <div><a href="<?=$_SERVER['PHP_SELF'].'?dir='.urlencode($leadon.$dirs[$i]);?>" class="<?=$class;?>"><img src="dlf/folder.png" alt="<?=$dirs[$i];?>" /><strong><?=$dirs[$i];?></strong> <em>-</em> <?=date ("M d Y h:i:s A", filemtime($leadon.$dirs[$i]));?></a></div>
  361.     <?
  362.         if($class=='b') $class='w';
  363.         else $class = 'b'; 
  364.     }
  365.    
  366.     $arsize = sizeof($files);
  367.     for($i=0;$i<$arsize;$i++) {
  368.         $icon = 'unknown.png';
  369.         $ext = strtolower(substr($files[$i], strrpos($files[$i], '.')+1));
  370.         $supportedimages = array('gif', 'png', 'jpeg', 'jpg');
  371.         $thumb = '';
  372.        
  373.         if($showthumbnails && in_array($ext, $supportedimages)) {
  374.             $thumb = '<span><img src="dlf/trans.gif" alt="'.$files[$i].'" name="thumb'.$i.'" /></span>';
  375.             $thumb2 = ' onmouseover="o('.$i.', \''.urlencode($leadon . $files[$i]).'\');" onmouseout="f('.$i.');"';
  376.            
  377.         }
  378.        
  379.         if($filetypes[$ext]) {
  380.             $icon = $filetypes[$ext];
  381.         }
  382.        
  383.         $filename = $files[$i];
  384.         if(strlen($filename)>43) {
  385.             $filename = substr($files[$i], 0, 40) . '...';
  386.         }
  387.        
  388.         $fileurl = $leadon . $files[$i];
  389.         if($forcedownloads) {
  390.             $fileurl = $_SESSION['PHP_SELF'] . '?dir=' . urlencode($leadon) . '&download=' . urlencode($files[$i]);
  391.         }
  392.  
  393.     ?>
  394.     <div><a href="<?=$fileurl;?>" class="<?=$class;?>"<?=$thumb2;?>><img src="dlf/<?=$icon;?>" alt="<?=$files[$i];?>" /><strong><?=$filename;?></strong> <em><?=round(filesize($leadon.$files[$i])/1024);?>KB</em> <?=date ("M d Y h:i:s A", filemtime($leadon.$files[$i]));?><?=$thumb;?></a></div>
  395.     <?
  396.         if($class=='b') $class='w';
  397.         else $class = 'b'; 
  398.     }  
  399.     ?></div>
  400.     <?
  401.     if($allowuploads) {
  402.         $phpallowuploads = (bool) ini_get('file_uploads');     
  403.         $phpmaxsize = ini_get('upload_max_filesize');
  404.         $phpmaxsize = trim($phpmaxsize);
  405.         $last = strtolower($phpmaxsize{strlen($phpmaxsize)-1});
  406.         switch($last) {
  407.             case 'g':
  408.                 $phpmaxsize *= 1024;
  409.             case 'm':
  410.                 $phpmaxsize *= 1024;
  411.         }
  412.    
  413.     ?>
  414.     <div id="upload">
  415.         <div id="uploadtitle"><strong>File Upload</strong> (Max Filesize: <?=$phpmaxsize;?>KB)</div>
  416.         <div id="uploadcontent">
  417.             <?
  418.             if($phpallowuploads) {
  419.             ?>
  420.             <form method="post" action="<?=$_SERVER['PHP_SELF'];?>?dir=<?=urlencode($leadon);?>" enctype="multipart/form-data">
  421.             <input type="file" name="file" /> <input type="submit" value="Upload" />
  422.             </form>
  423.             <?
  424.             }
  425.             else {
  426.             ?>
  427.             File uploads are disabled in your php.ini file. Please enable them.
  428.             <?
  429.             }
  430.             ?>
  431.         </div>
  432.        
  433.     </div>
  434.     <?
  435.     }
  436.     ?>
  437.   </div>
  438. </div>
  439. <div id="copy">Directory Listing Script &copy;2008 Evoluted, <a href="http://www.evoluted.net/">Web Design Sheffield</a>.</div>
  440. </body>
  441. </html>
  442.  


cron