thieumao

maoview.php

May 23rd, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.57 KB | None | 0 0
  1. <?
  2.  
  3. $host = $_SERVER['HTTP_HOST'];
  4. setlocale(LC_TIME, "vn_VN");
  5. date_default_timezone_set('Asia/Ho_Chi_Minh');
  6.  
  7.  
  8. $startdir = '.';
  9. $showthumbnails = false;
  10. $showdirs = true;
  11. $forcedownloads = false;
  12. $hide = array(
  13.                 'dlf',
  14.                 'public_html',             
  15.                 'index.php',
  16.                 'Thumbs',
  17.                 '.htaccess',
  18.                 '.htpasswd'
  19.             );
  20. $displayindex = false;
  21. $allowuploads = false;
  22. $overwrite = false;
  23.  
  24. $indexfiles = array (
  25.                 'index.html',
  26.                 'index.htm',
  27.                 'default.htm',
  28.                 'default.html'
  29.             );
  30.            
  31. $filetypes = array (
  32.                 'png' => 'jpg.gif',
  33.                 'jpeg' => 'jpg.gif',
  34.                 'bmp' => 'jpg.gif',
  35.                 'jpg' => 'jpg.gif',
  36.                 'gif' => 'gif.gif',
  37.                 'zip' => 'archive.png',
  38.                 'rar' => 'archive.png',
  39.                 'exe' => 'exe.gif',
  40.                 'setup' => 'setup.gif',
  41.                 'txt' => 'text.png',
  42.                 'htm' => 'html.gif',
  43.                 'html' => 'html.gif',
  44.                 'php' => 'php.gif',            
  45.                 'fla' => 'fla.gif',
  46.                 'swf' => 'swf.gif',
  47.                 'xls' => 'xls.gif',
  48.                 'doc' => 'doc.gif',
  49.                 'sig' => 'sig.gif',
  50.                 'fh10' => 'fh10.gif',
  51.                 'pdf' => 'pdf.gif',
  52.                 'psd' => 'psd.gif',
  53.                 'rm' => 'real.gif',
  54.                 'mpg' => 'video.gif',
  55.                 'mpeg' => 'video.gif',
  56.                 'mov' => 'video2.gif',
  57.                 'avi' => 'video.gif',
  58.                 'eps' => 'eps.gif',
  59.                 'gz' => 'archive.png',
  60.                 'asc' => 'sig.gif',
  61.             );
  62.            
  63. error_reporting(0);
  64. if(!function_exists('imagecreatetruecolor')) $showthumbnails = false;
  65. $leadon = $startdir;
  66. if($leadon=='.') $leadon = '';
  67. if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
  68. $startdir = $leadon;
  69.  
  70. if($_GET['dir']) {
  71.     // check this is okay.
  72.    
  73.     if(substr($_GET['dir'], -1, 1)!='/') {
  74.         $_GET['dir'] = $_GET['dir'] . '/';
  75.     }
  76.    
  77.     $dirok = true;
  78.     $dirnames = split('/', $_GET['dir']);
  79.     for($di=0; $di<sizeof($dirnames); $di++) {
  80.        
  81.         if($di<(sizeof($dirnames)-2)) {
  82.             $dotdotdir = $dotdotdir . $dirnames[$di] . '/';
  83.         }
  84.        
  85.         if($dirnames[$di] == '..') {
  86.             $dirok = false;
  87.         }
  88.     }
  89.    
  90.     if(substr($_GET['dir'], 0, 1)=='/') {
  91.         $dirok = false;
  92.     }
  93.    
  94.     if($dirok) {
  95.          $leadon = $leadon . $_GET['dir'];
  96.     }
  97. }
  98.  
  99.  
  100.  
  101. $opendir = $leadon;
  102. if(!$leadon) $opendir = '.';
  103. if(!file_exists($opendir)) {
  104.     $opendir = '.';
  105.     $leadon = $startdir;
  106. }
  107.  
  108. clearstatcache();
  109. if ($handle = opendir($opendir)) {
  110.     while (false !== ($file = readdir($handle))) {
  111.         // first see if this file is required in the listing
  112.         if ($file == "." || $file == "..")  continue;
  113.         $discard = false;
  114.         for($hi=0;$hi<sizeof($hide);$hi++) {
  115.             if(strpos($file, $hide[$hi])!==false) {
  116.                 $discard = true;
  117.             }
  118.         }
  119.        
  120.         if($discard) continue;
  121.         if (@filetype($leadon.$file) == "dir") {
  122.             if(!$showdirs) continue;
  123.        
  124.             $n++;
  125.             if($_GET['sort']=="date") {
  126.                 $key = @filemtime($leadon.$file) . ".$n";
  127.             }
  128.             else {
  129.                 $key = $n;
  130.             }
  131.             $dirs[$key] = $file . "/";
  132.         }
  133.         else {
  134.             $n++;
  135.             if($_GET['sort']=="date") {
  136.                 $key = @filemtime($leadon.$file) . ".$n";
  137.             }
  138.             elseif($_GET['sort']=="size") {
  139.                 $key = @filesize($leadon.$file) . ".$n";
  140.             }
  141.             else {
  142.                 $key = $n;
  143.             }
  144.             $files[$key] = $file;
  145.            
  146.             if($displayindex) {
  147.                 if(in_array(strtolower($file), $indexfiles)) {
  148.                     header("Location: $file");
  149.                     die();
  150.                 }
  151.             }
  152.         }
  153.     }
  154.     closedir($handle);
  155. }
  156.  
  157. // sort our files
  158. if($_GET['sort']=="date") {
  159.     @ksort($dirs, SORT_NUMERIC);
  160.     @ksort($files, SORT_NUMERIC);
  161. }
  162. elseif($_GET['sort']=="size") {
  163.     @natcasesort($dirs);
  164.     @ksort($files, SORT_NUMERIC);
  165. }
  166. else {
  167.     @natcasesort($dirs);
  168.     @natcasesort($files);
  169. }
  170.  
  171. // order correctly
  172. if($_GET['order']=="desc" && $_GET['sort']!="size") {$dirs = @array_reverse($dirs);}
  173. if($_GET['order']=="desc") {$files = @array_reverse($files);}
  174. $dirs = @array_values($dirs); $files = @array_values($files);
  175.  
  176. ?>
  177.  
  178. <html>
  179.     <head>
  180.         <title><? print $host; ?> - Thieu Mao </title>
  181.        
  182.     </head>
  183.     <body>
  184.         <div id="main">
  185.             <div id="content">
  186.  
  187.                 <div class="content">
  188.  
  189.                     <div id="files">
  190.                         <div class="top"></div>
  191.                         <div class="cont">
  192.  
  193.                             <div id="listingcontainer">
  194.                                 <div id="listing">
  195.                                 <?
  196.                                 $class = 'b';
  197.                                 if($dirok) {
  198.                                 ?>
  199.                                   <div><a href="<?=$dotdotdir;?>" class="<?=$class;?>"><img src="http://www.main-hosting.com/hostinger/welcome/index/dirup.png" alt="Folder" /><strong>..</strong> <em>-</em><? $mtime = filemtime($dotdotdir); $mtime = date("m/d/Y H:i:s", $mtime); $mtime = strftime("%B %e, %G %T", strtotime($mtime)); print ucfirst($mtime); ?></a></div>
  200.                                 <?
  201.                                     if($class=='b') $class='w';
  202.                                     else $class = 'b';
  203.                                 }
  204.                                 $arsize = sizeof($dirs);
  205.                                 for($i=0;$i<$arsize;$i++) {
  206.                                 ?>
  207.                                   <div><a href="<?=$leadon.$dirs[$i];?>" class="<?=$class;?>"><img src="http://www.main-hosting.com/hostinger/welcome/index/folder.png" alt="<?=$dirs[$i];?>" /><strong><?=$dirs[$i];?></strong> <em>-</em><? $mtime = filemtime($leadon.$dirs[$i]); $mtime = date("m/d/Y H:i:s", $mtime); $mtime = strftime("%B %e, %G %T", strtotime($mtime)); print ucfirst($mtime); ?></a></div>
  208.                                 <?
  209.                                     if($class=='b') $class='w';
  210.                                     else $class = 'b'; 
  211.                                 }
  212.                                
  213.                                 $arsize = sizeof($files);
  214.                                 for($i=0;$i<$arsize;$i++) {
  215.                                     $icon = 'unknown.png';
  216.                                     $ext = strtolower(substr($files[$i], strrpos($files[$i], '.')+1));
  217.                                     $supportedimages = array('gif', 'png', 'jpeg', 'jpg');
  218.                                     $thumb = '';
  219.                                            
  220.                                     if($filetypes[$ext]) {
  221.                                         $icon = $filetypes[$ext];
  222.                                     }
  223.                                    
  224.                                     $filename = $files[$i];
  225.                                     if(strlen($filename)>43) {
  226.                                         $filename = substr($files[$i], 0, 40) . '...';
  227.                                     }
  228.                                    
  229.                                     $fileurl = $leadon . $files[$i];
  230.                                 ?>
  231.                                   <div><a href="<?=$fileurl;?>" class="<?=$class;?>"<?=$thumb2;?>><img src="http://cpanel.main-hosting.com/images/index/<?=$icon;?>" alt="<?=$files[$i];?>" /><strong><?=$filename;?></strong><em><?=round(filesize($leadon.$files[$i])/1024);?> KB</em><? $mtime = filemtime($leadon.$files[$i]); $mtime = date("m/d/Y H:i:s", $mtime); $mtime = strftime("%B %e, %G %T", strtotime($mtime)); print ucfirst($mtime); ?><?=$thumb;?></a></div>
  232.                                 <?
  233.                                     if($class=='b') $class='w';
  234.                                     else $class = 'b'; 
  235.                                 }  
  236.                                 ?>
  237.                                 </div>
  238.                             </div>
  239.  
  240.                         </div>
  241.  
  242.                     </div>
  243.  
  244.                 </div>
  245.  
  246.             </div>
  247.  
  248.             </div>
  249.         </div>
  250.     </body>
  251. </html>
Advertisement
Add Comment
Please, Sign In to add comment