'.gif .jpg .jpeg .png .svg', 'php.png' => '.php .inc .class', 'htm.png' => '.html .htm .tpl', 'pdf.png' => '.pdf', 'odt.png' => '.odt', 'txt.png' => '.txt README .htaccess', ); $iconSpecial = array( 'up' => 'back.png', 'dir' => 'folder.png', 'other' => 'bin.png', 'empty' => 'empty.png', ); $typeByExt = array( 'image/gif' => '.gif', 'image/jpeg' => '.jpg .jpeg', 'image/png' => '.png', 'text/html' => '.html .htm', 'text/svg+xml' => '.svg', 'application/pdf' => '.pdf', 'text/plain' => '.txt README', ); $viewable = ':IMG .gif .png .jpg .jpeg :COLOR .html .htm .tpl .php .phps .inc .class .css .js .sql :NONE .txt README .htaccess CHANGELOG HEADER INSTALL VERSION'; $dirSize = '4 kB'; /* END OF CONFIGURATION */ setlocale(LC_ALL, 'pl_PL.UTF8'); function processConfig() { global $iconByExt, $typeByExt, $viewable; $temp = array(); foreach($iconByExt as $img => $ext) { $ext = explode(' ', $ext); foreach($ext as $ex) { if(!$ex) continue; $temp[$ex] = $img; } } $iconByExt = $temp; $temp = array(); foreach($typeByExt as $type => $ext) { $ext = explode(' ', $ext); foreach($ext as $ex) { if(!$ex) continue; $temp[$ex] = $type; } } $typeByExt = $temp; $temp = array(); $temp2 = ''; $viewable = explode(' ', $viewable); foreach($viewable as $element) { if(substr($element, 0, 1)==':') { $temp2 = substr($element, 1); } else { $temp[$element] = $temp2; } } $viewable = $temp; } function unit($bytes) { $jedn = array('B', 'kB', 'MB', 'GB', 'TB', 'PB'); $i=0; while(($byte = bcdiv($bytes, 1024, 1))>1) { $bytes = $byte; $i++; } return str_replace('.', ',', $bytes).' '.$jedn[$i]; } function explodeDir($dir) { $ret = ''; $begin = PHP_SELF.'/'; echo ' / '; if($dir == '') return ''; $dir = explode('/', $dir); foreach($dir as $element) { $d = is_dir('./'.substr($begin, strlen(PHP_SELF)).$element); $begin = $begin.$element.($d ? '/' : ''); echo ''.$element.($d ? ' /' : '').' '; } } function formatTime($time) { return strftime('%x %X %Z', $time); } function findFileType($file, &$array) { $file = basename($file); if(isset($array[$file])) { return $array[$file]; } elseif(($pos=strrpos($file, '.'))!==FALSE AND isset($array[substr($file, $pos)])) { return $array[substr($file, $pos)]; } else { return FALSE; } } function fileIcon($file) { global $iconByExt, $iconSpecial, $iconDir; if($file == '/') { $icon = $iconSpecial['dir']; } elseif($file == '..') { $icon = $iconSpecial['up']; } else { $icon = findFileType($file, $iconByExt); } if(!$icon) { $icon = $iconSpecial['other']; } return PHP_SELF.'/'.$iconDir.'/'.$icon; } function isViewable($file) { global $viewable; return (bool)findFileType($file, $viewable); } function makelink($element) { global $dirSize; $belement = basename($element); if(is_dir($element)) { echo '
Katalog: '; explodeDir($SDIR); echo '
'."\n\n"; /* BEGIN - DIRECTORY */ processConfig(); ?>Nazwa pliku | Rozmiar | Data modyfikacji | Opcje |
---|---|---|---|
../ |
'; break; case 'COLOR': case 'NONE': echo '
'; if($type=='COLOR') { highlight_file($RDIR); } else { ob_start(create_function('$string', 'return htmlspecialchars($string);')); readfile($RDIR); ob_end_flush(); } echo ''; break; default: echo '
Pliku nie można podejrzeć!
'; break; } /* END - VIEW */ } ?>Browse Code © 2010 by Jacek Kowalski