<?
include_once("mysql.php");
include_once("include/antixak.php");
include_once("include/zag.php");
include_once("include/ini.php");
include 'include/sesi.php';
if (isset($user)) {
switch($go) {
default:
echo"<b>Коментарии</b><br/>";
if(@file("local/koment/$num.dat")){
$file = @file("local/koment/$num.dat");
$total = count($file);
if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + 5){ $end = $total; }
else {$end = $start + 5; }
for ($i = $start; $i < $end; $i++){
$file = @file("local/koment/$num.dat");
$file = array_reverse($file);
$data = explode("|",$file[$i]);
$i2=round($i+1);
$id=$total-$i-1;
$data[1]=trim($data[1]);
$data[2]=trim($data[2]);
$elita=mysql_query("SELECT * FROM `table_admin` WHERE `nick`='$data[1]' LIMIT 1");
if(mysql_num_rows($elita)==1){
echo"<a href=\"search.php?$sd&nick=$data[1]&go=go\"><font color=lime>$data[1]</font></a>[A]($data[3]) - $data[2]<br/>";}else{
$elita=mysql_query("SELECT * FROM `table_moder` WHERE `nick`='$data[1]' LIMIT 1");
if(mysql_num_rows($elita)==1){
echo"<a href=\"search.php?$sd&nick=$data[1]&go=go\"><font color=#00FFFF>$data[1]</font></a>[M]($data[3]) - $data[2]<br/>";}else{
if(@file("MySql/base123/rating/olimpiads/$data[1].dat")){
echo"<a href=\"search.php?$sd&nick=$data[1]&go=go\"><font color=#C71585>$data[1]</font></a>($data[3]) - $data[2]<br/>";}else{
echo"<a href=\"search.php?$sd&nick=$data[1]&go=go\">$data[1]</a>($data[3]) - $data[2]<br/>";}}}
}
if($total=="0"){echo"Коментариев нет.</small>";}
}else{echo"Коментариев нет.</small>";}
if ($start != 0) {echo '<a href="koment.php?start='.($start - 5).'&'.$sd.'&go=list&num='.$num.'">Назад</a> ';}
if ($total > $start + 5) {echo ' <a href="koment.php?start='.($start + 5).'&'.$sd.'&go=list&num='.$num.'">Далее</a>';}
echo"<br/><a href=\"koment.php?$sd&go=add&num=$num\">Написать</a>";
break;
case 'komentadd':
if(empty($msg)){echo"<b>Не введено сообщение.</b><br/><a href=\"koment.php?$sd&num=$num\">Назад</a>"; include 'include/down.php'; exit;}
$elita=mysql_query("SELECT * FROM `table_admin` WHERE `nick`='$log' LIMIT 1");
if(mysql_num_rows($elita)==1){
$msg="<font color=red>$msg</font>";}
$text='|'.$log.'|'.$msg.'|'.date("H:i:s").'';
$fp=fopen("local/koment/$num.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
flock ($fp,LOCK_UN);
fclose($fp);
echo"Сообщение отправлено!
<br/><a href=\"koment.php?$sd&num=$num\">Назад</a>";
break;
case 'add':
echo"Добавить сообщение<br/>";
echo'<form method="post" action="koment.php?'.$sd.'&go=komentadd&num='.$num.'">';
echo "<input name=\"msg\" maxlength=\"200\" title=\"name\"/><br/>";
echo '<input class="button" type="submit" value="Добавить"/></form>';
break;
}}else{echo"<small>Пароль или логин неверен!</small>";}
include 'include/down.php';
?>

