View file load/index.php

File size: 4.29Kb
<?php
Header('Content-type:application/xhtml+xml;charset=UTF-8');
Header('Cache-Control: no-cache, must-revalidate');
@$dir=$_GET['d'];
@$n=$_GET['n'];
$n=intval($n);
@$s=$_GET['s'];
$s=intval($s);
@$ns=$_GET['c'];
$ns=intval($ns);
if($ns<1) $ns=8;
function to_rus($str){
$str=substr($str,1);
$str=strtr($str,array(
'A'=>'А','a'=>'а','B'=>'Б','b'=>'б',
'V'=>'В','v'=>'в','G'=>'Г','g'=>'г',
'D'=>'Д','d'=>'д','E'=>'Е','e'=>'е',
'yo'=>'ё','Yo'=>'Ё','Zh'=>'Ж','zh'=>'ж',
'Z'=>'З','z'=>'з','I'=>'И','i'=>'и',
'J'=>'Й','j'=>'й','K'=>'К','k'=>'к',
'L'=>'Л','l'=>'л','M'=>'М','m'=>'м',
'N'=>'Н','n'=>'н','O'=>'О','o'=>'о',
'P'=>'П','p'=>'п','R'=>'Р','r'=>'р',
'S'=>'С','s'=>'с','T'=>'Т','t'=>'т',
'U'=>'У','u'=>'у','F'=>'Ф','f'=>'ф',
'H'=>'Х','h'=>'х','C'=>'Ц','c'=>'ц',
'Ch'=>'Ч','ch'=>'ч','Sh'=>'Ш','sh'=>'ш',
'Sch'=>'Щ','sch'=>'щ',"''"=>'ъ',"'"=>'ь',
'Y'=>'Ы','y'=>'ы','Ye'=>'Э','ye'=>'э',
'Yu'=>'Ю','yu'=>'ю','Ya'=>'Я','ya'=>'я',
'_'=>' '));
return $str;
}
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>
<link rel="stylesheet" type="text/css" href="_script/style.css" />
<title>';
if(empty($dir)){
$dir='.'; print 'Фaйлы';
}else{
$f=strrpos($dir,'/');
if($f===false) $f=-1;
$str=substr($dir,$f+1);
if($str{0}=='!') $str=to_rus($str); else $str=strtr($str,'_',' ');
print htmlspecialchars($str);
}
print '</title></head><body><div>
';
if(strpos($dir,'..')!==false or strpos($dir,'/.')!==false) die('Дocтуп к тaким пaпкaм зaпpeщён.</div></body></html>');
if($dir!='.'){
print '<img src="_script/up.gif" /> <b><a href="index.php?d=';
$f=strrpos($dir,'/');
if($f!==false) print substr($dir,0,$f);
print '&amp;s='.$s.'&amp;c='.$ns.'">. .</a></b><hr />'; }
$arr=array();
$d=opendir($dir);
while($f=readdir($d)){
if($f!='.' and $f!='..' and $f!='.htaccess' and $f!='_script' and $f!='index.php'){
if($s=='2') $arr[$f]=filemtime($dir.'/'.$f); else $arr[$f]=filesize($dir.'/'.$f);
}} closedir($d);
if($s!=0) asort($arr); else ksort($arr);
function out($name,$info){
$name=htmlspecialchars($name);
$f=strrpos($name,'.');
if($f){ $ext=substr($name,$f); $str=substr($name,0,$f); }else{ $ext='dir'; $str=$name; }
if($name{0}=='!') $str=to_rus($str); else $str=strtr($str,'_',' ');
if($GLOBALS['dir']!='.') $name=$GLOBALS['dir'].'/'.$name;
print '<img src="_script/';
switch($ext){
case 'dir': $ico='dir.gif'; break;
case '.jpg': case '.jpeg': $ico='jpg.gif'; break;
case '.gif': $ico='gif.gif'; break;
case '.mid': $ico='mid.gif'; break;
case '.mp3': $ico='mp3.gif'; break;
case '.wav': case '.amr': $ico='wav.gif'; break;
case '.mmf': $ico='mmf.gif'; break;
case '.jad': $ico='jad.gif'; break;
case '.jar': $ico='jar.gif'; break;
case '.zip': $ico='zip.gif'; break;
case '.txt': $ico='txt.gif'; break;
case '.exe': $ico='exe.gif'; break;
case '.htm': $ico='htm.gif'; break;
case '.php': $ico='php.gif'; break;
default: $ico='file.gif'; break; }
print $ico.'" alt="'.$ext.'" /> <a href="';
if($ext=='dir') print './?d='.$name.'&amp;s='.$GLOBALS['s'].'&amp;c='.$GLOBALS['ns']; else print $name;
print '">'.$str.'</a>';
if($ext!='dir' and $GLOBALS['s']!=2) print ' <small>('.round($info/1024,1).'kB)</small>'; elseif($ext!='dir') print ' <small>('.date('d.m.y h:i',$info).')</small>';
print '<br />
'; }
$cnt=count($arr);
$i=0; $c=0;
foreach($arr as $name=>$info){
if($c<$n){ $c++; continue; }
if($i==$ns) break;
out($name,$info);
$i++; $c++; }
if($cnt==0) print 'Здecь пoкa чтo ничeгo нeт';
print '<hr />
';
if($dir!='.') $dir=htmlspecialchars($dir); else $dir='';
if($c<$cnt or $c>$ns) print '<small>';
if($c<$cnt) print '&gt;<a href="index.php?d='.$dir.'&amp;n='.$c.'&amp;c='.$ns.'&amp;s='.$s.'">Дaлee</a><br />
';
if($c>$ns){ print '&lt;&lt;<a href="index.php?d='.$dir.'&amp;c='.$ns.'&amp;s='.$s.'">B нaчaлo</a><br />
';
}elseif($c<$cnt) print '&gt;&gt;<a href="index.php?d='.$dir.'&amp;n='.($cnt-$ns).'&amp;c='.$ns.'&amp;s='.$s.'">B кoнeц</a><br />
';
if($c<$cnt or $c>$ns) print 'Cтp '.ceil($c/$ns).' из '.ceil($cnt/$ns).'</small><br />
';
print '[<a href="..">На главную</a>]</div></body></html>';
?>