Файл: editionforum.php
Строк: 207
<?
include_once("mysql.php");
Error_Reporting(E_ALL & ~E_NOTICE);
$rand=rand(100,1000000);
$_title = 'Linewap2';
include 'include/antixak.php';
include 'include/ini.php';
/////////////////////////////////////////////////////
$text = @file("MySql/base123/reg/$log.dat");
if ($text!=""){
$udata = explode(":||:",$text[0]);
$login=trim($udata[0]);
$password=trim($udata[1]);}
////////////////////////////////////////////////////////
include 'include/sesi.php';
include 'include/header.php';
if (isset($user)) {
include("include/who.php");
switch($go) {
default:
$u = explode(".",$login);
if(@file("MySql/base123/mod/$log.dat") || @file("MySql/base123/moders/$log.dat")){
echo"<small><a href="forum.php?$sd&go=addforum">Добавить форум</a></small><br/>";
$text = @file("MySql/base123/forum/count.dat");
$udata = explode("||",$text[0]);
$count=trim($udata[0]);
for($i=0; $i<$count; $i++){
$text = @file("MySql/base123/forum/$i/name.dat");
$udata = explode("||",$text[0]);
$name=trim($udata[0]);
$tem=trim($udata[1]);
$msg=trim($udata[2]);
echo"<small><br/><a href="editionforum.php?$sd&go=forum&id=$i">$name</a> [$tem/$msg]</small>";
}}else{echo"<small>Вам сюда доступ закрыт</small>";}
break;
case 'addforum':
$u = explode(".",$login);
if(@file("MySql/base123/mod/$log.dat")){
echo "<small>Название форума:</small><br/>";
echo "<form action="editionforum.php?$sd&go=saveforum" method="post">";
echo "<input type="text" name="nameforum" maxlength="14"/>";
echo "<input class="ibutton" type="submit" value="Далее"/>".$divK."</form><br/>";
}else{echo"<small>Вам сюда доступ запрещен!</small>";}
break;
case 'saveforum':
$u = explode(".",$login);
if(@file("MySql/base123/mod/$log.dat")){
$text = @file("MySql/base123/forum/count.dat");
$udata = explode("||",$text[0]);
$count=trim($udata[0]);
$newdir=mkdir("MySql/base123/forum/$count",0777);
if($newdir){echo"<small>Создание форума - OK.</small>";}else{
echo"<small>Создание форум - ERROR.</small>";}
$fp=fopen("MySql/base123/forum/$count/name.dat","w");
flock($fp,LOCK_EX);
ftruncate($fp,0);
fputs($fp,"$nameforum||0||0||");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
chmod ("MySql/base123/forum/$count/name.dat", 0666);
$count=$count+1;
$fp=fopen("MySql/base123/forum/count.dat","w");
flock($fp,LOCK_EX);
ftruncate($fp,0);
fputs($fp,"$count||");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
chmod ("MySql/base123/forum/count.dat", 0666);
}else{echo"<small>Вам суда доступ запрещен!</small>";}
break;
case 'forum':
$id = htmlspecialchars(stripslashes(addslashes($id)));
if(!@file("MySql/base123/forum/$id/name.dat")){echo"<small>Такой подфорум несуществует!</small>";include_once"include/down.php";exit;}
$text = @file("MySql/base123/forum/$id/name.dat");
$udata = explode("||",$text[0]);
$name=trim($udata[0]);
$tem=trim($udata[1]);
$msg=trim($udata[2]);
echo"<small><a href="editionforum.php?$sd&go=addtem&id=$id">Новая тема</a><br/>- - -</small><br/>";
if($tem=="0"){echo"<small>Форум пуст.</small>"; include_once"include/down.php"; exit;}
for($i=0; $i<$tem; $i++){
$text = @file("MySql/base123/forum/$id/$i.dat");
$count=count($text);
$count=$count-1;
$udata = explode("||",$text[0]);
$udata2 = explode("||",$text[1]);
$kol[]=$count;
$date[]=$udata2[2];
$nick[]=$udata2[0];
$topic[]=$udata[0];
$sort[]=$udata2[3];
$nomer[]=$i;
arsort($sort);
}
foreach($sort as $k=>$v)
{$name=$nick[$k]; $tema=$topic[$k];
$datet=$date[$k]; $i=$nomer[$k];
$num=$kol[$k];
$u = explode(".",$login);
$data[]="<small><a href="editionforum.php?$sd&go=deltem&id=$id&tema=$i">[DEL]</a><a href="search.php?$sd&go=go&nick=$name">$name</a> $datet<br/><a href="forum.php?$sd&go=tema&id=$id&tema=$i">$tema</a> ($num)<br/></small>";
}
if ($start=="") {$start = 0;}
if ($tem < $start + 10){ $end = $tem; }
else {$end = $start + 10; }
for ($i = $start; $i < $end; $i++){
echo $data[$i];
}
if ($start != 0) {echo '<small><a href="editionforum.php?start='.($start - 10).'&'.$sd.'&id='.$id.'&go=forum">--></a></small> ';}else{echo'<small>- - - -</small><br/>';}
if ($tem > $start + 10) {echo ' <small><a href="editionforum.php?start='.($start + 10).'&'.$sd.'&id='.$id.'&go=forum"><--</a></small>';}
break;
case 'addtem':
$id = htmlspecialchars(stripslashes(addslashes($id)));
if($udata[36]=="on"){echo"<small>Вы забанены!</small></p></card></wml>"; exit;}
echo "<small>Название темы:</small><br/>";
echo "<form action="editionforum.php?$sd&go=savetem&id=$id" method="post">";
echo "<input type="text" name="name" maxlength="14"/><br/>";
echo "<small>Сообщение:</small><br/>";
echo "<input type="text" name="msg" maxlength="100"/><br/>";
echo "<br/>";
echo "<input class="ibutton" type="submit" value="Далее"/>".$divK."</form><br/>";
break;
case 'savetem':
if(empty($name)){echo"<small>Вы не ввели название темы!</small>"; include_once"include/down.php"; exit;}
if(empty($msg)){echo"<small>Вы не ввели сообщение!</small>"; include_once"include/down.php"; exit;}
if ($name=="" || strlen($name) > 14 || strlen($name) < 5) { echo"<small>Тема длинная или короткая!</small>"; include_once"include/down.php"; exit;}
if ($msg=="" || strlen($msg) > 300 || strlen($msg) < 5) { echo"<small>Сообщение длинное или короткое!</small>"; include_once"include/down.php"; exit;}
$id = htmlspecialchars(stripslashes(addslashes($id)));
$text = @file("MySql/base123/forum/$id/name.dat");
$udata = explode("||",$text[0]);
$forum=trim($udata[0]);
$tem=trim($udata[1]);
$msgg=trim($udata[2]);
$date=date("d.m.y");
$time=date("H:i");
$sort=time();
$msg = htmlspecialchars(stripslashes(addslashes($msg)));
$fp=fopen("MySql/base123/forum/$id/$tem.dat","w");
flock($fp,LOCK_EX);
fputs($fp,"$name||rn$log||$msg||[$time/$date]||$sort||rn");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
chmod ("MySql/base123/forum/$id/$tem.dat", 0666);
$tem=$tem+1;
$msgg=$msgg+1;
$fp=fopen("MySql/base123/forum/$id/name.dat","w");
flock($fp,LOCK_EX);
fputs($fp,"$forum||$tem||$msgg||rn");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
chmod ("MySql/base123/forum/$id/name.dat", 0666);
echo"<small>Тема успешно создана.</small><br/>";
echo"<small><a href="editionforum.php?$sd&go=forum&id=$id">Продолжить</a></small>";
break;
case 'tema':
$id = htmlspecialchars(stripslashes(addslashes($id)));
$tema = htmlspecialchars(stripslashes(addslashes($tema)));
if(!@file("MySql/base123/forum/$id/$tema.dat")){echo"<small>Такой темы не существует!</small>"; include_once"include/down.php";exit;}
$text = file("MySql/base123/forum/$id/$tema.dat");
$count=count($text);
if (empty($_GET['start'])) $start = 1;
else $start = $_GET['start'];
if ($count < $start + 10){ $end = $count; }
else {$end = $start + 10; }
for($i=$start; $i<$end; $i++){
$text = file("MySql/base123/forum/$id/$tema.dat");
$udata = explode("||",$text[$i]);
$udata[1]=eregi_replace("((https?|ftp|http)://[[:alnum:]_=/-]+(\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&._=/%]*(\?[[:alnum:]?+&_=/%]*)?)?).(ru|org|net|info|com)", "Реклама запрещена", $udata[1]);
$udata[1]=eregi_replace("([[:alnum:]_=/-]+(\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&._=/%]*(\?[[:alnum:]?+&_=/%]*)?)?).(ru|org|net|info|com)", "Реклама запрещена", $udata[1]);
echo"<small><a href="search.php?$sd&go=go&nick=$udata[0]">$udata[0]</a> $udata[2]<br/>$udata[1]</small><br/>";
}
if ($start != 1) {echo '<small><a href="editionforum.php?start='.($start - 10).'&'.$sd.'&id='.$id.'&tema='.$tema.'&go=tema"><--</a></small> ';}else{echo'<small>- - - -</small><br/>';}
if ($count > $start + 10) {echo ' <small><a href="editionforum.php?start='.($start + 10).'&'.$sd.'&id='.$id.'&tema='.$tema.'&go=tema">--></a></small>';}
echo"<br/><small><a href="forum.php?$sd&go=msg&id=$id&tema=$tema">Ответить</a><br/>- - - -<br/><a href="editionforum.php?$sd=$pas&go=deltem&id=$id&tema=$tema">Удалить</a></small>";
break;
case 'msg':
$id = htmlspecialchars(stripslashes(addslashes($id)));
$tema = htmlspecialchars(stripslashes(addslashes($tema)));
if(!@file("MySql/base123/forum/$id/$tema.dat")){echo"<small>Такой темы не существует!</small>";include_once"include/down.php";exit;}
echo "<small>Сообщение:</small><br/>";
echo "<form action="editionforum.php?$sd&go=addmsg&id=$id&tema=$tema" method="post">";
echo "<input type="text" name="msg" maxlength="300"/><br/>";
echo "<input class="ibutton" type="submit" value="Далее"/>".$divK."</form><br/>";
break;
case 'addmsg':
$id = htmlspecialchars(stripslashes(addslashes($id)));
$tema = htmlspecialchars(stripslashes(addslashes($tema)));
if(!@file("MySql/base123/forum/$id/$tema.dat")){echo"<small>Такой темы не существует!</small>";include_once"include/down.php";exit;}
$msg = htmlspecialchars(stripslashes(addslashes($msg)));
if ($msg=="" || strlen($msg) > 300 || strlen($msg) < 5) { echo"<small>Сообщение длинное или короткое!</small>"; include_once"include/down.php"; exit;}
$date=date("d.m.y");
$time=date("H:i");
$sort=time();
$msg=str_replace("|","",$msg);
$fp=fopen("MySql/base123/forum/$id/$tema.dat","a+");
flock($fp,LOCK_EX);
fputs($fp,"$log||$msg||[$time/$date]||$sort||rn");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
$text = @file("MySql/base123/forum/$id/name.dat");
$udata = explode("||",$text[0]);
$forum=trim($udata[0]);
$tem=trim($udata[1]);
$msgg=trim($udata[2]);
$msgg=$msgg+1;
$fp=fopen("MySql/base123/forum/$id/name.dat","w");
flock($fp,LOCK_EX);
fputs($fp,"$forum||$tem||$msgg||rn");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
chmod ("MySql/base123/forum/$id/name.dat", 0666);
echo"<small>Сообщение добавлено.</small><br/>";
echo"<small><a href="editionforum.php?$sd&go=forum&id=$id">Продолжить</a></small>";
break;
case 'deltem':
$u = explode(".",$login);
if(@file("MySql/base123/mod/$log.dat")){
$flag=stripslashes($flag);
$flag=htmlspecialchars($flag);
$flag=str_replace("\","",$flag);
$flag=str_replace("/","",$flag);
$flag=str_replace("|","",$flag);
$flag=str_replace("$","",$flag);
$flag=str_replace("&","",$flag);
$flag=str_replace("<","",$flag);
$flag=str_replace(">","",$flag);
$flag = @unlink ("NySql/base123/forum/$id/$num.dat");
//////////////////////////////////
if($flag)
{
echo"<small>Тема успешно удалена.</small>";
}else{ print"<small>Тема удалена из базы.</small>"; }
$text = @file("MySql/base123/forum/$id/name.dat");
$udata = explode("||",$text[0]);
$forum=trim($udata[0]);
$tem=trim($udata[1]);
$msgg=trim($udata[2]);
$msgg=$msgg-1;
$tem=$tem-1;
$fp=fopen("MySql/base123/forum/$id/name.dat","w");
flock($fp,LOCK_EX);
fputs($fp,"$forum||$tem||$msgg||rn");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
chmod ("MySql/base123/forum/$id/name.dat", 0666);
}else{echo"Доступ запрещен!";}
break;
}
include 'include/down.php';
}else{echo"<small>Пароль или логин неверен!</small>";}
echo "</p></card></wml>";
?>