Просмотр файла down/index.php

Размер файла: 1.62Kb
<?php
@$folder=$_GET['dir'];
@$n=$_GET['n'];
if($n=='') $n=0;
if($folder) $zag=strtr($folder,'_',' '); else $zag='Загрузки!';
include_once '../style/head.php';
$tsize=0;
$cnt=0;
$ns=0;
if($folder){
if(strstr($folder,'..')) die('Доступ запрещён!</small></body></html>');
$dir=opendir($folder);
}else $dir=opendir('.');
while($file=readdir($dir))
{
if($file!='.' and $file!='..' and $file!='.htaccess' and $file!='index.php' and $file!='img'){
if($cnt<$n){$cnt++; continue;}
if($ns<10){
if($folder and strpos($file,'-')) $fname=strstr($file,'-'); else $fname=$file;
$fname=strtr($fname,array('_'=>' ','-'=>' '));
if($folder){
$str=filesize($folder.'/'.$file);
$file=$folder.'/'.$file;
}else $str=filesize($file);
$size=round($str/1024,1);
if(strpos($file,'.')){
$fname=strtok($fname,'.');
print '<img src="img/file.png" alt=""/><a href="'.$file.'">'.$fname.'</a>('.$size.'kB)<br />';
$ns++;
$tsize=$tsize+$str;
}else{
print '<img src="img/dir.png" alt=""/><a href="?dir='.$file.'">'.$fname.'</a><br />';
$ns++;
}
}
$cnt++;}
}
closedir($dir);
if(!$ns<10 and $ns+$n!=$cnt) print '&nbsp;<a href="index.php?dir='.$folder.'&amp;n='.($ns+$n).'">След.&#187;</a><br />';
if($n!=0) print '&nbsp;<a href="index.php?dir='.$folder.'&amp;n='.($n-10).'">&#171;Пред.</a>';
$tsize=round($tsize/1024,1);
$stran=round($cnt/10);
if(($cnt-$stran*10)>0) $stran++;
echo '<hr /><font color="#7D0000">Cтpaницa '.(($n+10)/10).' из '.$stran.'<br /></font><hr/>';
if($folder) print '<a href="index.php">Начало</a>'; else print '<a href="..">Начало</a>';
include_once '../style/foot.php';
?>