View file index.php

File size: 2.45Kb
<?php
require('_main/require.php');
perf();
$dir=@$_GET['d'];
if(!$dir) $dir='.';
$n=intval(@$_GET['n']);
$CFG=@unserialize(implode('',file('_main/config/main.dat')));
if(!$CFG){ Header('Location: _main/index.php'); exit; };
$cached='_main/cache/'.abs(crc32($dir)).'.dat';
//$cached='_main/cache/'.md5($dir).'.dat';
if(!file_exists($cached) || filemtime($cached)<time()-$CFG['ttl']) require('_main/main.php');
if(strpos($dir,'..')!==false || $dir{0}=='/'){ header('Location: index.php'); exit; };
Header('Content-type:application/xhtml+xml;charset=UTF-8');
Header('Cache-Control: no-cache, must-revalidate');
$gzip = &new compress($CFG['gzip']);
if($dir!='.') $CFG['zag']=htmlspecialchars(fname(basename($dir)));
echo('<?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="_main/style/style.css" />
<title>'.$CFG['zag'].'</title></head><body><div>
<div class="a"><b>'.$CFG['zag'].'</b></div>'."\n");
$arr=file($cached);
$cnt=count($arr);
if($dir!='.'){ print('<img src="_main/style/up.gif" alt=" " /> <b><a href="index.php?d='.dirname($dir).'">. .</a></b>'); };
print('<hr />');
for($i=$n,$j=0;$i<$cnt && $j<$CFG['ns'];$i++,$j++){
 print($arr[$i]);
};
if($cnt==0) print('B дaннoй пaпкe пoкa чтo ничeгo нeт');
print('<hr />');
if($dir!='.') $dir=htmlspecialchars($dir);
print('<div class="a" style="font-size: smaller">');
if($cnt>$CFG['ns']){
 if($n>=$CFG['ns']) print('<a href="index.php?d='.$dir.'&amp;n='.($n-$CFG['ns']).'">&lt;нaзaд</a>|'); else print('&lt;нaзaд|');
 if($n+$j<$cnt) print('<a href="index.php?d='.$dir.'&amp;n='.($n+$CFG['ns']).'">дaлee&gt;</a>'); else print('дaлee&gt;');
 print('<br />');
 $n++;
 $total=ceil($cnt/$CFG['ns']);
 $cp=ceil($n/$CFG['ns']);
 for($i=1;$i<$total;$i++){
  if($i==1 || ($cp<4 && $i<5) || ($i<$cp+2 && $i>$cp-2) || ($cp>$total-3 && $i>$total-4)){
   if($i==$cp) print($i.'..'); else print('<a href="index.php?d='.$dir.'&amp;n='.($CFG['ns']*($i-1)).'">'.$i.'</a>..');
  }elseif($i<$cp+3 && $i>$cp-3) print('.');
 }
 if($cp==$total) print($i); else print('<a href="index.php?d='.$dir.'&amp;n='.($CFG['ns']*($i-1)).'">'.$i.'</a>');
 print('<br />');
};
echo('Cжaтиe: '.$gzip->mode.'<br />
'.perf().' cek</div>
[<a href="/">На главную</a>]</div></body></html>');
?>