Просмотр файла list.php

Размер файла: 7.56Kb
<?php

$show=$_GET['show'];
if(!@$_GET['tr']) $tr=''; else $tr=$_GET['tr'];
function gettime()
{
$part_time = explode(' ', microtime());
$real_time = $part_time[1].substr($part_time[0], 1);
return $real_time;
}
$type= array('zip.mid');
$index_flag = false;
$existion_flag = false;
$size_flag = false;
$start1 = gettime();
if (!@$show) {$curren_dir = getcwd ().'/';// $show ,     
}else{
$curren_dir=''.getcwd ().'/'.$show.'/';
}
$curren_dir=str_replace('//','/', $curren_dir);
$curren_dir=str_replace("..","",$curren_dir);
if (!(@$tr)) {
if (file_exists($curren_dir.'translit.dat')) {$tr='true';} else {$tr='false';}
;};
if (!(@$trh)) {
if (file_exists($curren_dir.'translithere.dat')) {$trh='true';} else {$trh='false';}
;};
$addon='';
if ($tr=='true') 
$addon=$addon.'&amp;tr=true';
$dirr=@$show;
$lenghth = strlen ($curren_dir);
for ( $i = $lenghth-1; $i>0; $i--) {  
if ( $curren_dir [$i] === "/" or $curren_dir [$i] === "\\" ) 
{ $curren_dir_title = substr ( $curren_dir, $i+1, $lenghth);  break; }
}
$header ='<html><head><title>Библиотека</title>
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="content-type" content="text/html; charset=utf-8"></head>
<body bgcolor="#ffffff" link="#201BF1" vlink="#15D206" alink="#FB2F11">
<font face="Arial" size="2">
<img src="librar.gif" alt="librar" border=0><br/>';

$footer ='<br/><img src="line.gif" alt="---" border=0><br/>
<a href="index.php">Начало</a><br/>
<a href="'.$main_url.'">WAPrus.Org</a><br/></font></body>
</html>';
$body = "";
$body_line = "";
$i = 1;
$show = opendir ($curren_dir);
$biglet= array(
"а"=>"А","б"=>"Б","в"=>"В","г"=>"Г","д"=>"Д","е"=>"Е","ё"=>"Ё","ж"=>"Ж","з"=>"З","и"=>"И",
"й"=>"Й","к"=>"К","л"=>"Л","м"=>"М","н"=>"Н","о"=>"О","п"=>"П","р"=>"Р","с"=>"С",
"т"=>"Т","у"=>"У","ф"=>"Ф","х"=>"Х","ц"=>"Ц","ч"=>"Ч","ш"=>"Ш","щ"=>"Щ","ъ"=>"Ъ",
"ы"=>"Ы","ь"=>"Ь","э"=>"Э","ю"=>"Ю","я"=>"Я"
);
function bigletter($str) {
global $biglet;
$str=strtr($str,$biglet);
return $str;
}
$tran = array(
"A"=>"А","a"=>"а","B"=>"Б","b"=>"б","V"=>"В",
"v"=>"в","G"=>"Г","g"=>"г","D"=>"Д","d"=>"д",
"E"=>"Е","e"=>"е","Zh"=>"Ж","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"=>"Ш",
"sh"=>"ш","Sch"=>"Щ","SCH"=>"Щ","sch"=>"щ","''"=>"ъ",
"Y"=>"Ы","y"=>"ы","'"=>"ь","Ye"=>"Э", "YE"=>"Э",
"ye"=>"э","Yu"=>"Ю","yu"=>"ю","Ya"=>"Я","ya"=>"я",
"YU"=>"Ю","YA"=>"Я","Yo"=>"ё","YO"=>"Ё",
"W"=>"Ш","w"=>"ш", 'q'=>'ь'
);
$tran1= array(
'нэ '=>'ные ', 'нэ'=>'ные'
);
function latrus($str) {
global $tran;
global $tran1;
$str=strtr($str,$tran);
return strtr($str,$tran1);
}
function allowed_type ($d)
{
$lenghth = strlen ($d);
$d=@substr($d, strrpos($d,'/')+1);
$p=strpos($d, '.');
global $name;
$name=substr($d,0,$p);
global $existion;
$existion=trim(substr($d, $p+1));
global $allowed_file;
global $type;
for ($i=0; $i<count($type); $i++)
{
$type[$i]=trim($type[$i]);
}
return in_array(trim($existion), $type);
}
while ( ($d = readdir ($show)) !== false)
{
if ( is_dir ($curren_dir.'/'.$d) and !($d==".") and !($d== "..")){
if (($tr=='true')or($trh=='true')) {$dname=latrus($d);} else {$dname=$d;}
$dname=str_replace('_', ' ', $dname);
$links[]='<br/><img src="book.gif" border=0><a href="'.$_SERVER['PHP_SELF'].'?show='.$dirr.'/'.$d.$addon.'">'.$dname.'</a><br/>';
$poslinks[count($links)-1]=$dname;
}
};
if (@count(@$links)>0) {
global $dddd;
$dddd=654;
} else {
$show = opendir ($curren_dir);
while ( ($d = readdir ($show)) !== false)
{
if ( is_dir ( $d ) and !($d == ".") and !($d == ".."))
{
$body_line ='';
$body = $body.$body_line;
}
$dd=$curren_dir.'/'.$d;
$dd=str_replace('//','/', $dd);
$dd=str_replace('//','/', $dd);
$flag_allowed = true;
if (allowed_type($dd))
{
$LIST_FILE = @stat ($dd);
$file_size = $LIST_FILE [7];		    
$file_change_time = $LIST_FILE [9];
if ($file_size < 1024) $file_size = $file_size."b";
if ($file_size >= 1024) $file_size = round (($file_size/1024), 1)."Kb";
if ($file_size >= 1024) $file_size = round (($file_size/1024), 1)."Mb";
if ($index_flag) $index = $i;
else $index = "";
if ($existion_flag) $filename = $d;
else $filename = $name;
if (!$size_flag) $file_size = "";
global $links;
global $poslinks;
if (($tr=='true')or($trh=='true')) {$namefile=latrus($filename);} else {$namefile=$filename;}
$namefile=str_replace('_', ' ', $namefile);
$links[]=''.$index.'<br/><img src="book.gif" border=0><a href="zip_read.php?book_id='.substr($dirr,1)."/".$filename.'">'.$namefile.'</a> '.$file_size.@$st1.'<br/>';
$poslinks[count($links)-1]=$namefile;
$i++;
}
}
}
header ("Content-type:text/html; charset=utf-8");
print $header;
function checkGetVar($var)
{
if (array_key_exists($var,$_GET))
return $_GET[$var];
else
return -1;
}
$part=checkGetVar("part");
if (@$goo==1) $part=$part-1;
if ($part==-1) { $part=0; };
$limstr=checkGetVar("limit");
if ($limstr==-1) {$limstr=10;};
if ($part==0) {$begin=1;} else {$begin=0;};
$addon='';
print '&#1057;&#1090;&#1088;&#1072;&#1085;&#1080;&#1094;&#1072; '.($part+1).' &#1080;&#1079; '.((int)(count(@$links) / $limstr)+1).'<br/><img src="line.gif" alt="---" border=0><br/>';
$papka=substr($dirr, strrpos($dirr, '/')+1);
if (($tr=='true')or($trh=='true')) {$papka=latrus($papka);} else {$papka=$papka;}
$papka=str_replace('_', ' ', $papka);
if (($tr=='true')||($trh=='true')) {
$st1=substr($papka,0,2);
$st1=bigletter($st1);
$papka=$st1.(substr($papka,2));
} else{
$papka=(ucfirst($papka));
}
print '<br/>['.$papka.']';
$poslinks=@array_flip($poslinks);
$poslinks = @array_splice($poslinks, $part*$limstr, $limstr);
if(@count(@$links)==0){echo "<u>Папка пока пуста!<br/>Зайдите позже</u><br/>";
}else{
foreach ($poslinks as $name=>$pos)
{
print $links[$pos]."\n";
}
}
print "<br/>";
if (@$end==0) {$razd=" |";} else {$razd="";};
if ($part*$limstr+$limstr-1>=count(@$links)-1) { $endstr=count(@$links)-1; $end=1;} else {$endstr=$part*$limstr+$limstr-1; $end=0;};
if ($begin==0){
$res[]=('<a href="'.$PHP_SELF.'?show='.$dirr.'&amp;limit='.$limstr.'&amp;part='.($part-1).$addon.'&amp;tr='.$tr.'&amp;trh='.$trh.'">'.''.("Назад")."</a>".$razd."\n".'');
}else{
$res[]=("Назад | ");
};
if ($end==0){
$res[]='<a href="'.$PHP_SELF.'?show='.$dirr.'&amp;limit='.$limstr.'&amp;part='.($part+1).$addon.'&amp;tr='.$tr.'&amp;trh='.$trh.'">'.''.("Далее")."</a>"."\n";
}else{
$res[]=("Далее");
};
if (count(@$res)==2) {$result=@$res[0].@$res[1];} else {$result=@$res[0];};
print @$result;
print '<br/>';
print '<img src="line.gif" alt="---" border=0><br/>';
if (@$dddd!==654) print 'Файлы: '; else print 'Папок: ';
print '[<b>'.count(@$links).'</b>]'.'<br/>';
print 'Стр.: [<b>'.((int)(count(@$links) / $limstr)+1).'</b>]<br/>';
if (count(@$links) / $limstr>2) print 'Перейти к:<br/></small><input name="page" title="GO" emptyok="true" value="1" format="*N" size="3"/> <a href ="?limit='.$limstr.'&amp;'.$addon.'&amp;tr='.$tr.'&amp;trh='.$trh.'&amp;show='.$dirr.'&amp;part=$(page)&amp;goo=1">Стр.</a><br/><small>';
print 'Online: [<b>';
include "useronline.php";
print '</b>]';
$end1 = gettime();
print '<br/>['.round(($end1 - $start1), 5).']';
print $footer;
?>