<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/siti_conf.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";
if(!empty($start2)){$start=round(($start2-1)*$config_maxpostbook);}
echo '<div class=a><font color="gold"><b>Рейтинг фирм</b></font>';
if(!isset($action)) {
$dir = opendir(BASEDIR."local/navigator/firma/");
while ($file = readdir ($dir)) 
{if (( $file != ".") && ($file != "..") && ($file != ".htaccess") && ($file != "index.php"))
{$a[]=$file;}}
closedir ($dir);
$total = count($a);
for ($i = 0; $i < $total; $i++){
$sopli = count($a[$i]);
$tex = @file(BASEDIR."local/navigator/firma/$a[$i]");
$data = explode("|",$tex[0]);
if (!$data[6]=="" && !$data[7]==""){
$dat_log[]=$data[0];
$dat_naz[]=$data[8];
$dat_opis[]=$data[7]; 
$dat_tim[]=$data[6];
$dat_bal[]=$data[5];
}}
arsort($dat_bal);
$total = count($dat_naz);
if($total==0){echo'<br><b>Пока нет фирм!!!</b></div>';}else{
echo'<br><b>Всего фирм: <font color="red">'.$total.'</font></b></div>';}
foreach($dat_bal as $k=>$v)
{$dat_bal[$k]; $config_maxpostbook=$v;
$dat_tuning2[]='<div class=b><b><font color="gold">'.$dat_naz[$k].'</b></font></div>
Владелец:<font color="gold"><a href="../pages/anketa.php?uz='.$dat_log[$k].'&amp;'.SID.'"><b> '.$dat_log[$k].'</b></a></font><br>
Описание:<font color="green"> '.$dat_opis[$k].'</font><br>
Капитал: <b><font color="red"> '.$dat_bal[$k].'$</font></b><br>
Дата рег-ции: <b>'.$dat_tim[$k].'</b><br>';
$dat_tuning1[]='[<a href="firm.php?action=del&amp;name='.$dat_log[$k].'&amp;'.SID.'">Удалить</a>]<br>';}
if($total<0){echo '<hr><b>Фирм нет!</b><hr>';}
if ($start=="") {$start = 0;}
if ($total < $start + $config_bookpost){ $end = $total;}
else {$end = $start + $config_bookpost; }
for ($i = $start; $i < $end; $i++){echo $dat_tuning2[$i];
if ($log==$config_nikname){echo $dat_tuning1[$i];}}
if($total>0){
$ba=ceil($total/$config_bookpost);
$ba2=$ba*$config_bookpost-$config_bookpost;
echo '<hr>Стр:';
$asd=$start-($config_bookpost*3);
$asd2=$start+($config_bookpost*4);
if($asd<$total && $asd>0){echo ' <a href="firm.php?start=0&amp;'.SID.'">1</a> ... ';}
for($i=$asd; $i<$asd2;){
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_bookpost);
if ($start==$i) {
echo ' <b>('.$ii.')</b>';
}else {echo ' <a href="firm.php?start='.$i.'&amp;'.SID.'">'.$ii.'</a>';}}
$i=$i+$config_bookpost;}
if($asd2<$total){echo ' ... <a href="firm.php?start='.$ba2.'&amp;'.SID.'">'.$ba.'</a>';}}}
if ($log==$config_nikname){
if ($action=="del"){
unlink(BASEDIR."local/navigator/firma/$name.firm");
unlink("../local/birga/$name.dat");
header ("Location: firm.php?".SID);}}
echo'<hr>&#187; <a href="index.php?'.SID.'">В город</a><br>';
echo'&#187; <a href="../index.php?'.SID.'">На главную</a>';
include_once"../themes/$config_themes/foot.php";
?>