<?
$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.'&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 ='<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.3//EN" "http://www.phone.com/dtd/wml13.dtd">
<wml>
<card id="Menu" title="Wap-библиотека">';
$footer ='<p><small>
_______<br/>
<a href="index.php">Начало</a><br/>
<a href="'.$main_url.'">На главную</a></small><br/>
</p>
</card>
</wml>';
$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[]='<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.'<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/vnd.wap.wml; 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 '<p><small>';
print 'Страница '.($part+1).' из '.((int)(count(@$links) / $limstr)+1).'<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.']</small></p>';
print '<p mode="nowrap" align="left"><small>';
$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 '</small></p>';
print "<p><small><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.'&limit='.$limstr.'&part='.($part-1).$addon.'&tr='.$tr.'&trh='.$trh.'">'.''.("<<Назад")."</a>".$razd."\n".'');
}else{
$res[]=("<<Назад | ");
};
if ($end==0){
$res[]='<a href="'.$PHP_SELF.'?show='.$dirr.'&limit='.$limstr.'&part='.($part+1).$addon.'&tr='.$tr.'&trh='.$trh.'">'.''.("Далее>>")."</a>"."\n";
}else{
$res[]=("Далее>>");
};
if (count(@$res)==2) {$result=@$res[0].@$res[1];} else {$result=@$res[0];};
print @$result;
print '<br/>';
print '_______<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.'&'.$addon.'&tr='.$tr.'&trh='.$trh.'&show='.$dirr.'&part=$(page)&goo=1">стр.</a><br/><small>';
print 'Online: [<b>';
include "useronline.php";
print '</b>]';
print '</small>';
print "</p>";
print $footer;
?>