Файл: DarkAge/moder/chat.php
Строк: 80
<?
Error_Reporting(E_ALL & ~E_NOTICE);
$ref=rand(100,10000000);
include_once ("../files/zag.php");
echo "<p align="left">";
$log = htmlspecialchars(stripslashes($log));
$pas = htmlspecialchars(stripslashes($pas));
/////////////////////////////////////////////////////
$text = @file("../data/reg/$log.dat");
if ($text!=""){
$udata = explode(":||:",$text[0]);
$login=trim($udata[0]);
$password=trim($udata[1]);}
////////////////////////////////////////////////////////
if (md5($pas)==$password && $log==$login && $log!=="" && md5($pas)!=="") {
$file=@file("../data/moders.dat");
$total=count($file);
for($i=0; $i<$total; $i++){
$data=explode("|",$file[$i]);
if($data[0]==$log){
switch($go) {
default:
function img($image) {return eregi_replace("pic/","../pic/", $image);} ob_start("img");
if(empty($udata[35])){$udata[35]="5";}
$file = @file("../data/chat.dat");
$total = count($file);
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++){
$file = @file("../data/chat.dat");
$file = array_reverse($file);
$data = explode("#",$file[$i]);
$i2=round($i+1);
$data[6]=str_replace("rn", "", $data[6]);
if(!empty($data[1])){
echo"<small><small><b><a href="chat.php?log=$log&pas=$pas&go=del&id=$i">[DEL]</a><a href="chat.php?log=$log&pas=$pas&go=ignor&name=$data[1]">[IGNOR]</a></b><a href="../search.php?log=$log&pas=$pas&go=go&nick=$data[1]">$data[1]</a></small> - <small>$data[0]<br/>[$data[2]/$data[3]]</small></small><br/>";}
}
echo"<br/><small>- - -</small>";
echo"<form mathod="post" action="chat.php?log=$log&pas=$pas&go=add">";
echo "<br/><input name="msg" maxlength="999" title="msg"/><br/>";
echo "<small><input class="button" type="submit" value="Написать">";
echo "<postfield name="msg" value="$(msg)"/>";
echo "<postfield name="self" value="$self"/>";
echo "</form></small>";
if ($start != 0) {echo '<small><a href="chat.php?start='.($start - $udata[35]).'&log='.$log.'&pas='.$pas.'">Назад</a></small> ';}else{echo'<small>- - -</small>';}
if ($total > $start + $udata[35]) {echo ' <small><a href="chat.php?start='.($start + $udata[35]).'&log='.$log.'&pas='.$pas.'">Далее</a></small>';}
echo"<br/><small><a href="chat.php?log=$log&pas=$pas&ref=$ref">Обновить</a></small><br/>";
break;
case 'add':
if(getenv("HTTP_X_FORWARDED_FOR")){ $ip = getenv("HTTP_X_FORWARDED_FOR"); }else{
if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");}
$ip=htmlspecialchars(stripslashes($ip));
$brow=htmlspecialchars(stripslashes(getenv('HTTP_USER_AGENT')));
$brow=strtok($brow,'/');
$brow=str_replace("#","",$brow);
$ip=str_replace("#","",$ip);
$msg=htmlspecialchars(stripslashes($msg));
$msg=str_replace("#","",$msg);
$date=date("d.m.y");
$time=date("H:i");
$text="$msg#$log#$brow#$ip#";
$text=str_replace("rn", "", $text);
$fp=fopen("../data/chat.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$textrn");
flock ($fp,LOCK_UN);
fclose($fp);
$file=file("../data/chat.dat"); $i = count($file);
if ($i>=1000) {
$fp=fopen("../data/chat.dat","w");
flock ($fp,LOCK_EX);
unset($file[0]);
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
}
echo"<small><a href="chat.php?log=$log&pas=$pas">Сообщение добавлено!</a></small>";
break;
case 'del':
$file = @file("../data/chat.dat");
$total = count($file);
if($id=="0"){$id=$total-1;}else{$id=$total-$id-1;}
$file=file("../data/chat.dat");
$fp=fopen("../data/chat.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$id) {unset($file[$i]);} }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
echo"<small><a href="chat.php?log=$log&pas=$pas">Удалено.</a></small>";
break;
case 'ignor':
$name=htmlspecialchars(stripslashes($name));
echo "<small>Причина:</small><br/>";
echo "<form method="post" action="chat.php?log=$log&pas=$pas&go=ban&name=$name">";
echo "<input name="prichina" maxlength="999"/><br/>";
echo "<small><input class="button" type="submit" value="Банить">";
echo "<postfield name="prichina" value="$(prichina)"/>";
echo "</form></small><br/>";
break;
case 'ban':
$name=htmlspecialchars(stripslashes($name));
$file=@file("../data/chat.dat");
$file = array_reverse($file);
$total=count($file);
for($i=0; $i<$total; $i++){
$data = explode("#",$file[$i]);
if($name==$data[1]){
$ip=explode(".",$data[3]);
$ipn="$ip[0].$ip[1].$ip[2]";
$time=time();
$prichina=htmlspecialchars(stripslashes($prichina));
$prichina=str_replace("|","",$prichina);
$name=str_replace("|","",$name);
$text="$ipn||$time||$name||$prichina||$data[0]||";
$fp=fopen("../data/ban.dat","a+");
flock($fp,LOCK_EX);
fputs($fp,"$textrn");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
echo"<small><a href="chat.php?log=$log&pas=$pas">$name забанен на 24 часа.</a></small><br/>";
echo"<small>- - -<br/>» <a href="../main.php?log=$log&pas=$pas">Моё меню</a></small></p></body></html>";
exit;}
}
break;
}}
}
}else{echo"<small>Пароль или логин неверен!</small><br/>";}
echo"<small>- - -<br/>» <a href="../main.php?log=$log&pas=$pas">Моё меню</a></small><br/>";
echo "</p></body></html>";
?>