Размер файла: 1.15Kb
<?php
if(basename($_SERVER['PHP_SELF'])=='main.php') exit;
$arr=array();
$d = dir($dir);
while($f = $d->read()){
if($f{0}!='.' && $f{0}!='_' && $f!='index.php'){
if($CFG['sort']==2) $arr[$f]=filemtime($dir.'/'.$f); else $arr[$f]=filesize($dir.'/'.$f);
};
};
$d->close();
if($CFG['sort']!=0) asort($arr); else ksort($arr);
$data='';
foreach($arr as $path=>$info){
$path=htmlspecialchars($path);
$f=strrpos($path,'.');
// (get extension of a file):
if($f){
$ext=substr($path,$f+1);
$name=substr($path,0,$f);
}else{
$ext='dir';
$name=$path;
};
$name=fname($name);
if($dir!='.') $path=$dir.'/'.$path;
if($ext!='dir' && !in_array($ext,$CFG['ico'])) $ext='file';
if($ext=='dir'){
$d = dir($path);
$about=0;
while($str=$d->read()){
if($str{0}!='.' && $str{0}!='_') $about++;
};
$d->close();
$about='<small>['.$about.']</small>';
}else $about='<small>('.round($info/1024,1).'kB)</small>';
if($ext=='dir') $path='./?d='.$path;
$data.='<img src="_main/style/'.$ext.'.gif" alt="'.$ext.'" /> <a href="'.$path.'">'.$name.'</a> '.$about."<br />\n";
}
$f=fopen($cached,'wb');
fwrite($f,$data);
fclose($f);
?>