}else { $tmp=pathinfo($f); switch(@strtolower($tmp['extension'])) { case 'jpeg': case 'jpe': case 'jpg': case 'gif': case 'png': @$sz=getimagesize($f); light_message('<h3>Preview of '.show_file($f).'</h3> <a href="system/download.php?file='.rawurlencode($f).'&'.session_name().'='.session_id().'"><img src="system/preview.php?file='.rawurlencode($f).'&size=normal" border="0" alt="Download the full image" title="Download the full image ('.($sz ? $sz[0].'x'.$sz[1].', ' : '').show_size($f).')"></a>'); break; default: if(d_filesize($f)>102400) { header('location: system/download.php?file='.rawurlencode($f).'&'.session_name().'='.session_id()); break; } $wr = setwritable($f,true); light_message('<h3>Edit '.show_file($f).' <small>(<a href="?act=properties&files[]='.rawurlencode($f).'&back='.rawurlencode('?act=edit&file='.rawurlencode($f)).'">info</a>)</small></h3> <form action="index.php?act=edit&apply=true&file='.rawurlencode($f).'" method="POST"> <textarea name="content" id="content" rows=10 cols=40>'.htmlspecialchars(d_file_get_contents($f)).'</textarea> <script><!-- /* for stupid IE <= 6 */ var checkf = function() {
{ $f=clean($_GET['file']); } // some people reported about problems with file compression, so it is turned off always $compress=false /*d_filesize($f)<100*1024*/; //compress the stream or not? if(!empty($_GET['text'])) $text=str_replace(array("\r\n","\r","\n","\t"),array("\n","\n","\r\n"," "),d_file_get_contents($f)); if($compress) ob_start('ob_gzhandler'); header("Content-Type: application/force-download; charset=".CHARSET); header("Content-Transfer-Encoding: binary"); header('Content-Description: File Transfer'); if(!$compress) header("Content-Length: ".(isset($text) ? strlen($text) : d_filesize($f))); header("Content-Disposition: attachment; filename=\"".addslashes(basename($f))."\""); if(empty($_GET['text'])) { if(file_exists($f)) { readfile($f); }else { echo d_file_get_contents($f); } } else echo $text; die(); ?>
/** * Shows size of $f file or folder like "1023.53 Kb". If $format=false, it returns just filesize in bytes, and fills $GLOBALS['show_size_files'] and $GLOBALS['show_size_dirs'] with values. If $size is not false, the function will just format $size value, but not count the size of directory again. * * @param string $f * @param bool $format * @return string/int */ function show_size($f,$format=true,$size=false) { if($format || $size!==false) { if($size===false) $size=show_size($f,false); if(!empty($GLOBALS['TIMED_OUT'])) $p = '>'; else $p = ''; if($size == 1) return $p.'1 byte'; else if($size<=1024) return $p.$size.' bytes'; else if($size<=1048576) return $p.round($size/1024,2).' Kb'; else if($size<=1073741824) return $p.round($size/1048576,2).' Mb'; else if($size<=1099511627776) return $p.round($size/1073741824,2).' Gb'; else if($size<=1125899906842624) return $p.round($size/1099511627776,2).' Tb'; else return $p.round($size/1125899906842624,2).' Pb'; }else { if(d_is_file($f)) { $GLOBALS['show_size_files'] = 1; $GLOBALS['show_size_dirs'] = 0; return d_filesize($f); } if(!d_file_exists($f)) { return 0; } $size=0; setreadable($f,true); $dh=opendir($f); $fs=$ds=0; if($dh) { while(($file=readdir($dh))!==false) { if($file=='.' || $file=='..') continue; // delete the next lines if you don't want any limits if(!defined('NOLIMIT') && array_sum(explode(' ',microtime()))-START_TIME>DIRSIZE_LIMIT) { $GLOBALS['TIMED_OUT'] = true; break; } if(d_is_file($f.'/'.$file)) { $size+=d_filesize($f.'/'.$file); $fs++; }else { $size+=show_size($f.'/'.$file,false,false); $ds+=$GLOBALS['show_size_dirs']; $fs+=$GLOBALS['show_size_files']; } } closedir($dh); } $GLOBALS['show_size_files'] = $fs; $GLOBALS['show_size_dirs'] = 1+$ds; return $size+d_filesize($f); // +d_filesize($f) for *nix directories } }
function get_info($f) { global $descr; if(!isset($_REQUEST['type'])) $_REQUEST['type'] = determine_type($f); if(isset($_REQUEST['file'])) $f = clean($_REQUEST['file'], true); if($f == lang('My computer')) { $_RESULT = array( 'name' => 'details', 'filename' => htmlspecialchars($f), 'dir' => false, 'type' => lang('System folder'), ); }else if(in_array($_REQUEST['type'],array(tDIR,tFILE))) { if(!@lstat($f)) return null; $ext=pathinfo($f); @$ext=strtolower($ext['extension']); $imgext = array('jpeg','jpe','gif','png','jpg'); if(preg_match('/Darwin/is', PHP_OS)) $imgext = array_merge($imgext, explode(' ','pdf doc docx ppt pptx xls xlsx tiff tif bmp mov avi mpg mp4 tga psd svg eps key pages html')); $img=in_array($ext,$imgext); //echo $f; $real_link = $link_raw = @is_link($f) && function_exists('readlink') ? readlink($f) : false; if($link_raw !== false && $link_raw[0] != '/') // not absolute link { $link_raw = abs_path( dirname($f).'/'.$link_raw ); } $_RESULT=array( 'name' => 'details', 'filename' => htmlspecialchars(basename($f)), 'filename_encoded' => rawurlencode($f), 'fullpath' => $f, 'link' => $link_raw !== false ? htmlspecialchars($real_link) : false, 'link_raw' => $link_raw, 'md5(filename)' => md5($f), 'dir' => d_is_dir($f), 'type' => (d_is_dir($f) ? false : get_type($f)), 'changed' => ((@$t=filemtime($f)) ? date('d F Y, H:i',$t) : false), 'size' => ( (d_is_dir($f) && !SHOW_DIRSIZE) ? (/*no subdirectories*/!empty($GLOBALS['files']) && sizeof($GLOBALS['dirs'])==0 && !empty($GLOBALS['sz']) ? show_size(true,true,$GLOBALS['sz']) : false) : show_size($f)), 'size_bytes' => d_filesize($f), 'thumb' => ($img ? '<div style="padding-bottom: 10px;" align="center"><img src="system/preview.php?file='.rawurlencode($f).'&size=small" align="center"></div>' : false), 'id3' => (($img && d_filesize($f) < 15*1024*1024 && @$sz=getimagesize($f)) ? 'Dimensions: '.$sz[0].'x'.$sz[1] : ''), 'owner' => get_owner($f), 'group' => get_group($f), 'rights' => d_get_rights($f, false), ); }else if($_REQUEST['type']==tDRIVE) { $_RESULT=array( 'name' => 'details', 'filename' => !empty($_REQUEST['name']) ? $_REQUEST['name'] : $_SESSION['DIR'], 'type' => $descr[$_REQUEST['icon']], 'dir' => false, ); if(!empty($_REQUEST['fs'])) $_RESULT['fs'] = $_REQUEST['fs']; if($s = disk_free_space($f)) $_RESULT['free']=show_size(true,true,$s); if($s = disk_total_space($f)) $_RESULT['total']=show_size(true,true,$s); } return $_RESULT; }