<?
include 'mysql.php';
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);
include_once("include/zag.php");
include 'include/ini.php';
include 'include/sesi.php';
if (isset($user)) {
switch($go) {

default:
$self = $_SERVER['SCRIPT_NAME'];
$ref=rand(100,100000);
include_once"include/tradextochat.php";
echo"<br/>- - -<br/>[<a href=\"tradechat.php?$sd&ref=$ref\">Обновить</a> / <a href=\"tradechat.php?$sd&go=add&ref=$ref\">Написать</a>] / [<a href=\"wwkod.php?$sd\">ВВ-коды</a>]<br/>- - -<br/>";


$file = file("MySql/base123/trade.dat");
$file = array_reverse($file);
$total = count($file);


for ($i = 0; $i < $total; $i++){
$data = explode("#",$file[$i]);
if($data[1]!=="CooL" && $data[1]!=="BaFFer"){
$data_0[]=$data[0];
$data_1[]=$data[1];
$data_4[]=$data[4];
}
}

if(empty($data_0)){echo"Сообщений нет."; include_once"include/down.php"; exit;}

foreach($data_0 as $k=>$v)
{
if($data_4[$k]==$log){
$elita=mysql_query("SELECT * FROM `table_admin` WHERE `nick`='$data_1[$k]' LIMIT 1");
if(mysql_num_rows($elita)==1){
$dat_screen[]="<a

href=\"search.php?$sd&nick=$data_1[$k]&go=go\"><font color=lime>$data_1[$k]</font></a><b></b>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">[ответить]</a><u>$data_0[$k]</u></u><hr>";}else{
$elita=mysql_query("SELECT * FROM `table_moder` WHERE `nick`='$data_1[$k]' LIMIT 1");
if(mysql_num_rows($elita)==1){
$dat_screen[]="<a

href=\"search.php?$sd&nick=$data_1[$k]&go=go\"><font color=#blue>$data_1[$k]</font></a><b></b>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">[ответить]</a><u>$data_0[$k]</u><hr>";}else{
if(@file("MySql/base123/rating/olimpiads/$data_1[$k].dat")){
$dat_screen[]="<a

href=\"search.php?$sd&nick=$data_1[$k]&go=go\"><font color=#C71585>$data_1[$k]</font></a><b></b>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">[ответить]</a>$data_0[$k]<hr>";}else{
$dat_screen[]="<a href=\"search.php?$sd&go=go&nick=$data_1[$k]\">$data_1[$k]</a>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">say</a><u>$data_0[$k]</u><hr>";
}}}}else{


$elita=mysql_query("SELECT * FROM `table_admin` WHERE `nick`='$data_1[$k]' LIMIT 1");
if(mysql_num_rows($elita)==1){
$dat_screen[]="<a

href=\"search.php?$sd&nick=$data_1[$k]&go=go\"><font color=lime>$data_1[$k]</font></a><b></b>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">[ответить]</a>$data_0[$k]<hr>";}else{
$elita=mysql_query("SELECT * FROM `table_moder` WHERE `nick`='$data_1[$k]' LIMIT 1");
if(mysql_num_rows($elita)==1){
$dat_screen[]="<a

href=\"search.php?$sd&nick=$data_1[$k]&go=go\"><font color=blue>$data_1[$k]</font></a><b></b>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">[ответить]</a>$data_0[$k]<hr>";}else{
if(@file("MySql/base123/rating/olimpiads/$data_1[$k].dat")){
$dat_screen[]="<a

href=\"search.php?$sd&nick=$data_1[$k]&go=go\"><font color=#C71585>$data_1[$k]</font></a><b></b>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">[ответить]</a>$data_0[$k]<hr>";}else{
$dat_screen[]="<a href=\"search.php?$sd&go=go&nick=$data_1[$k]\">$data_1[$k]</a>|<a href=\"tradesay.php?$sd&nick=$data_1[$k]\">[ответить]</a>$data_0[$k]<hr>";
}}}}

}
$total = count($dat_screen);
if(empty($udata[35])){$udata[35]="5";}
if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + $udata[35]){ $end = $total; }
else {$end = $start + $udata[35]; }
for ($i = $start; $i < $end; $i++){

echo"$dat_screen[$i]";

}

if($total>0){

$ba=ceil($total/5);
$ba2=$ba*5-5;

$asd=$start-(5*3);
$asd2=$start+(5*4);

if($asd<$total && $asd>0){echo ' <a href="tradechat.php?start=0&'.$sd.'">1</a> ... ';}

for($i=$asd; $i<$asd2;){

if($i<$total && $i>=0){
$ii=floor(1+$i/5);

if ($start==$i) {
echo ' <b>('.$ii.')</b>';
}else{
echo ' <a href="tradechat.php?start='.$i.'&'.$sd.'">'.$ii.'</a>';
}}
$i=$i+5;}
if($asd2<$total){echo ' ... <a href="tradechat.php?start='.$ba2.'&'.$sd.'">'.$ba.'</a>';}
}
echo"<br/>[<a href=\"tradechat.php?$sd&ref=$ref\">Обновить</a> / <a href=\"tradechat.php?$sd&go=add&ref=$ref\">Написать</a>]";
echo"<br/>[<a href=\"faq.php?$sd&id=10\">Смайлы</a>]";
$elita=mysql_query("SELECT * FROM `table_moder` WHERE `nick`='$log' LIMIT 1");
if(mysql_num_rows($elita)==1){
echo"<br/>[<a href=\"moder.php?$sd&go=tradechat\">Управление</a>]<br/>[<a href=\"XmodersX/block.php?log=$log&pas=$pas\">Блокировать</a>]";
}
$elita=mysql_query("SELECT * FROM `table_admin` WHERE `nick`='$log' LIMIT 1");
if(mysql_num_rows($elita)==1){
echo"<br/>[<a href=\"admin.php?$sd&go=tradechat\">Управление</a>]<br/>[<a href=\"admin.php?$sd&go=block\">Блокировать</a>]";
}
break;
case 'add':
echo "<form action=\"add2.php?$sd\" method=\"post\">";
echo "<input name=\"msg\" maxlength=\"500\" title=\"msg\"/><br/><input type=\"hidden\" name=\"self\" value=\"$self\" />";
echo "<br/><input type=\"submit\" value=\"Написать\"/></form><br/>";
break;
}
}else{echo"<small>Пароль или логин неверен!</small>";}
include 'include/down.php';
?>
