View file index.php

File size: 2.29Kb
<?php
Header('Content-type:application/xhtml+xml;charset=UTF-8');
Header('Cache-Control: no-cache, must-revalidate');
@$folder=$_GET['dir'];
@$n=$_GET['n'];
if($n=='') $n=0;
if($folder) $zag=strtr($folder,'_',' '); else $zag='Фaйлы';
print '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head><style type="text/css">
body{background: url(../../bg.gif) #000000;color: #90FF90}
a:link,a:visited{color: #FF0000;text-decoration: none}
a:active,a:hover{color: #FFFF00;text-decoration: none;background-color: transparent}
img{vertical-align: middle}</style><title>'.$zag.'</title></head><body><div>
';
$tsize=0;
$cnt=0;
$ns=0;
if($folder){
if(strstr($folder,'..')) die('Доступ запрещён</div></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.gif" alt=""/> <a href="'.$file.'">'.$fname.'</a>('.$size.'kB)<br />';
$ns++;
$tsize=$tsize+$str;
}else{
print '<img src="img/dir.gif" 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).'">&gt;&gt;&gt;</a><br />';
if($n!=0) print '&nbsp;<a href="index.php?dir='.$folder.'&amp;n='.($n-10).'">&lt;&lt;&lt;</a>';
$tsize=round($tsize/1024,1);
$stran=round($cnt/10);
if(($cnt-$stran*10)>0) $stran++;
echo '<hr /><small style="color: #1E90FF">Cтpaницa '.(($n+10)/10).' из '.$stran.'<br />Paзмep фaйлoв: '.$tsize.' kB</small><br />';
if($folder) print '[<a href="index.php">Назад</a>]'; else print '[<a href="..">Назад</a>]';
print '<br />[<a href="../../main.php">На главную</a>]</div></body></html>';
?>