",'>',$text);
$text=str_replace("<",'<',$text);
$text=str_replace("\"",'"',$text);
$text=preg_replace("/\n\n/",'',$text);
$text=preg_replace("/\n/",'
',$text);
$text=preg_replace("/\\\$/",'$',$text);
$text=preg_replace("/\r/",'',$text);
$text=preg_replace("/\\\/",'\',$text);
// ���� magic_quotes �������� - ������ ����� ����� � ���� �������: ��������� (') � ������� ������� ("), �������� ���� (\)
if (get_magic_quotes_gpc()) { $text=str_replace("\"",'"',$text); $text=str_replace("\'",'\'',$text); $text=str_replace("\\",'\',$text); }
$text=str_replace("\r\n","
",$text);
$text=str_replace("\n\n",'
',$text);
$text=str_replace("\n",'
',$text);
$text=str_replace("\t",'',$text);
$text=str_replace("\r",'',$text);
$text=str_replace(' ',' ',$text);
return $text; }
function unreplacer ($text) { // ������� ������ ������������ ����� ������ �� �������
$text=str_replace("<br>","
",$text);
$text=str_replace("|","|",$text);
return $text;}
function nospam() { global $max_key,$rand_key; // ������� ��������
if (array_key_exists("image", $_REQUEST)) { $num=replacer($_REQUEST["image"]);
for ($i=0; $i<10; $i++) {if (md5("$i+$rand_key")==$num) {imgwr($st,$i); die();}} }
$xkey=""; mt_srand(time()+(double)microtime()*1000000);
$dopkod=mktime(0,0,0,date("m"),date("d"),date("Y")); // ���.���: �������� ������ 24 ����
$stime=md5("$dopkod+$rand_key");// ���.���
echo'�������� ���: ';
for ($i=0; $i<$max_key; $i++) {
$snum[$i]=mt_rand(0,9); $psnum=md5($snum[$i]+$rand_key+$dopkod);
echo "
\n";
$xkey=$xkey.$snum[$i];}
$xkey=md5("$xkey+$rand_key+$dopkod"); //����� + ���� �� config.php + ��� ���������� ����� 24 ����
print"
";
return; }
// ������ ����� - ������� ����
if(isset($_GET['event'])) { if ($_GET['event']=="clearcooke") { setcookie("wrforumm","",time()-3600); Header("Location: index.php"); exit; } }
if (isset($_COOKIE['wrforumm'])) { // ������� ���/������ �� ���� � �������� � ������ �����
$text=$_COOKIE['wrforumm'];
$text=trim($text); // �������� ���������� �������
if (strlen($text)>60) exit("������� ������ - ����� ���������� ���� ������ �������!");
$text=replacer($text);
$exd=explode("|",$text); $name1=$exd[0]; $pass1=$exd[1];
if (($name1!=$adminname and $name1!=$modername) or ($pass1!=$adminpass and $name1!=$moderpass)) {sleep(1); setcookie("wrforumm", "0", time()-3600); Header("Location: admin.php"); exit;}
} else { // ���� ���� ���� ����
if (isset($_POST['name']) & isset($_POST['pass'])) { // ���� ���� ���������� �� ����� ����� ������
$name=str_replace("|","I",$_POST['name']); $pass=str_replace("|","I",$_POST['pass']);
$text="$name|$pass|";
$text=trim($text); // �������� ���������� �������
if (strlen($text)<4) exit("$back �� �� ����� ��� ��� ������!");
$text=replacer($text);
$exd=explode("|",$text); $name=$exd[0]; $pass=$exd[1];
//$qq=md5("$pass+$skey"); exit("$qq"); // ������������� ��� ��������� MD5 ������ ������!
//--�-�-�-�-�-�-�-�--�������� ����--
if ($antispam==TRUE) {
if (!isset($_POST['usernum']) or !isset($_POST['xkey']) or !isset($_POST['stime']) ) exit("������ �� ����� �� ���������!");
$usernum=replacer($_POST['usernum']); $xkey=replacer($_POST['xkey']); $stime=replacer($_POST['stime']);
$dopkod=mktime(0,0,0,date("m"),date("d"),date("Y")); // ���.���. �������� ������ 24 ����
$usertime=md5("$dopkod+$rand_key");// ���.���
$userkey=md5("$usernum+$rand_key+$dopkod");
if (($usertime!=$stime) or ($userkey!=$xkey)) exit("����� ��������� ���!");}
// ������� �������� ���/������ � �������� � ������ �����
$tektime=time();
// ������������� ���� ��������������
if ($name==$adminname & md5("$pass+$skey")==$adminpass) {$wrforumm="$adminname|$adminpass|$tektime|"; setcookie("wrforumm", $wrforumm, time()+18000); Header("Location: admin.php"); exit;}
// ������������� ���� ����������
if ($name==$modername & md5("$pass+$skey")==$moderpass) {$wrforumm="$modername|$moderpass|$tektime|"; setcookie("wrforumm", $wrforumm, time()+18000); Header("Location: admin.php"); exit;}
exit("���� ������ ��������!");
} else { // ���� ���� ������, �� ������� ����� ����� ������
echo '
Powered by WR-Forum Professional © 1.9
";
exit;}
} // ����������� ��������!
$gbc=$_COOKIE['wrforumm']; $gbc=explode("|", $gbc); $gbname=$gbc[0];$gbpass=$gbc[1];$gbtime=$gbc[2];
if ($gbname==$adminname) $ktotut="1"; else $ktotut="2"; // ��� �����: ����� ��� �����?
// �������� ��������� ���������� ������
if(isset($_GET['event'])) { if ($_GET['event']=="rassilochka") {
$name=replacer($_POST['name']);
$email=replacer($_POST['email']);
$userdata=replacer($_POST['userdata']); if (strlen($userdata)<5) exit("�� �� ������� ��������� ������, �������� ���������� ���������!");
$dt=explode("|", $userdata); $username=$dt[1]; $useremail=$dt[2];
$msg=$_POST['msg'];
// ��� ������ ����� - ��������������� � � �������������� ������� ��������� //
$bdcolor="#79BBEF"; $fcolor="#00293E"; // �������������
//$bdcolor="#FF9A00"; $fcolor="#833C07"; // ���������
//$bdcolor="#FFE51A"; $fcolor="#FF8000"; // Ƹ���-���������
//$bdcolor="#00E900"; $fcolor="#005300"; // ������-�������
//$bdcolor="#FB5037"; $fcolor="#620000"; // �������
//$bdcolor="#800080"; $fcolor="#350035"; // �������������
//$bdcolor="#007800"; $fcolor="#000000"; // ����� �������
//$bdcolor="#D2A500"; $fcolor="#4A3406"; // �������
//$bdcolor="#BCC0C0"; $fcolor="#646464"; // �����
//$bdcolor="#FFA8FF"; $fcolor="#800080"; // �������
// ������� ������ ������ ����� !!!
$shapka="
";
$host=$_SERVER["HTTP_HOST"]; $self=$_SERVER["PHP_SELF"]; $furl="http://$host$self";
$furl=str_replace("admin.php", "", $furl);
// ��������� ��� �������� �����
$headers=null;
$headers.="From: $name <$email>\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="Content-Type: text/html; charset=windows-1251";
$msg=str_replace("\r\n", "
",$msg);
$msg=str_replace("%name", "$username",$msg);
$msg=str_replace("%fname", "$fname",$msg);
$msg=str_replace("%furllogin", "".$furl."tools.php?event=login",$msg);
$msg=str_replace("%furl", "$furl",$msg);
// �������� ��� ���������� � ���� ������
$allmsg="$shapka
��������� c ����� \" $furl\" |
��� | $name |
E-mail | $email |
���� ��������: | $date �. � $time |
��������� | $msg |
";
$printmsg="$allmsg
C�������� ������� ����������
";
$allmsg.="
* ��� ��������� ���������� � ������.";
// ���������� ������ ������� �� �������� ;-)
mail("$useremail", "��������� � �����: $fname", $allmsg, $headers);
print "$printmsg"; exit;
}}
// ����� ������ ������ �����
if (isset($_GET['newuserpass'])) {
if (isset($_POST['newpass'])) {$newpass=replacer($_POST['newpass']); $email=replacer($_GET['email']);
$newpass=md5("$newpass"); // ������� ������ ������������ � ��5
// ���� ����� � ����� �������. ���� ���� - ������
$email=strtolower($email); unset($fnomer); unset($ok); $oldpass="";
$lines=file("$datadir/usersdat.php"); $ui=count($lines); $i=$ui;
do {$i--; $rdt=explode("|",$lines[$i]);
$rdt[3]=strtolower($rdt[3]);
if ($rdt[3]===$email) {$oldpass=$rdt[1]; $fnomer=$i; $name=$rdt[0];}
} while($i > 1);
if (isset($fnomer)) { // ���������� ������ ����� � ��
$i=$ui; $dt=explode("|", $lines[$fnomer]);
$txtdat=$lines[$fnomer];
$txtdat=str_replace("$name|$oldpass","$name|$newpass",$txtdat);
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=(sizeof($lines)-1);$i++) {if ($i==$fnomer) fputs($fp,"$txtdat"); else fputs($fp,$lines[$i]);}
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp); }
Header("Location: admin.php?event=userwho"); exit; }}
// ���� �������� ���� ���������������� ����������
if(isset($_GET['delalluser'])) { $records="\r\n";
$file=file("$datadir/usersdat.php"); $maxi=count($file)-1; $i=0;
$fp=fopen("$datadir/usersdat.php","w"); // ������� ������ � �� ��������������� �������� ����������
flock ($fp,LOCK_EX);
do { $i++; $dt=explode("|",$file[$i]);
if (strlen($dt[13])=="6" and ctype_digit($dt[13])) $records=$records; else $records.=$file[$i]; } while($i<$maxi);
ftruncate ($fp,0);
fputs($fp, $records);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho"); exit; }
// ���������� IP-����� � ���
if (isset($_GET['badip'])) {
if (isset($_POST['ip'])) {$ip=$_POST['ip']; $badtext=$_POST['text'];}
if (isset($_GET['ip_get'])) {$ip=$_GET['ip_get']; $badtext="�� ���������� ������������� ��������� �� �����! �� ����!!!";}
if (strlen($ip)<8) exit("������� IP �� ������� X.X.X.X, ��� � - ����� �� 1 �� 255! ������ ������ ���� ��� IP �� ������!");
$text="$ip|$badtext|"; $text=stripslashes($text); $text=htmlspecialchars($text); $text=str_replace("\r\n", "
", $text);
$fp=fopen("$datadir/bad_ip.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=blockip"); exit; }
// �������� ����� �� ����
if (isset($_GET['delip'])) { $xd=$_GET['delip'];
$file=file("$datadir/bad_ip.dat"); $dt=explode("|",$file[$xd]);
$fp=fopen("$datadir/bad_ip.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$xd) unset($file[$i]); }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=blockip"); exit; }
// ��������� ������������
if(isset($_GET['event'])) { if ($_GET['event']=="activate") {
$key=$_GET['key']; $email=$_GET['email']; $page=$_GET['page'];
// ������ �� ������ �� ����� � ������
if (strlen($key)<6 or strlen($key)>6 or !ctype_digit($key)) exit("$back. �� �������� ��� ����� �����. ���� ����� ��������� ������ 6 ����.");
$email=stripslashes($email); $email=htmlspecialchars($email);
$email=str_replace("|","I",$email); $email=str_replace("\r\n","
",$email);
if (strlen($key)>30) exit("������ ��� ����� ������");
// ���� ����� � ����� ������� � ������. ���� ���� - ������ ������ �� ������ ����
$email=strtolower($email); unset($fnomer); unset($ok);
$lines=file("$datadir/usersdat.php"); $ui=count($lines); $i=$ui;
do {$i--; $rdt=explode("|",$lines[$i]);
$rdt[3]=strtolower($rdt[3]);
if ($rdt[3]===$email and $rdt[13]===$key) {$name=$rdt[0]; $pass=$rdt[1]; $fnomer=$i;}
if ($rdt[3]===$email and $rdt[13]==="") $ok="1";
} while($i > 1);
if (isset($fnomer)) {
// ���������� ������ ����� � ��
$i=$ui; $dt=explode("|", $lines[$fnomer]);
$txtdat="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$dt[4]|$dt[5]|$dt[6]|$dt[7]|$dt[8]|$dt[9]|$dt[10]|$dt[11]|$dt[12]||";
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=(sizeof($lines)-1);$i++) {if ($i==$fnomer) fputs($fp,"$txtdat\r\n"); else fputs($fp,$lines[$i]);}
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
}
if (!isset($fnomer) and !isset($ok)) exit("$back. �� �������� � ���� �������������� ����� ��� ������.");
if (isset($ok)) $add="������ ������������ �����"; else $add="$name, ������������ ������� ���������������.";
print"
�������, $add.
����� ��������� ������ �� ������ ������������� ���������� �� �������� � ����������� ������.
������ >>> |
|
";
exit;
}
}
// ���� �����ר�� ���-�� ��� � ���������
if(isset($_GET['event'])) { if ($_GET['event'] =="revolushion") {
$lines=file("$datadir/mainforum.dat"); $countmf=count($lines)-1; $i="-1";$u=$countmf-1;$k="0";
do {$i++; $dt=explode("|", $lines[$i]);
if (!isset($dt[12])) {$dt[12]=""; $dt[11]="";}
if ($dt[1]!="razdel") { $fid=$dt[0];
if ((is_file("$datadir/topic$fid.dat")) && (sizeof("$datadir/topic$fid.dat")>0)) {
$fl=file("$datadir/topic$fid.dat"); $kolvotem=count($fl); $kolvomsg="0";
for ($itf=0; $itf<$kolvotem; $itf++) {
$forumdt=explode("|",$fl[$itf]);
$id=$forumdt[7]; $tema=$forumdt[3];
if ((!ctype_digit($id)) or (strlen($id)!=7)) print"- � ���� � ��������� '$tema': index.php?id=$fid ' ���� ������: ������� �������������, �� ���� �������� ����
";
else {
if (is_file("$datadir/$id.dat")) {
$msgfile=file("$datadir/$id.dat"); $countmsg=count($msgfile); $kolvomsg=$kolvomsg+$countmsg;
} else print"- �������� � ����� � ��������� '$tema': index.php?id=$id - ����������� ���� � ����� (������ ���� ������� �����������)!
";
}
} // for
if ($kolvotem=="0") $dt[8]="";
$lines[$i]="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$kolvotem|$kolvomsg|$dt[6]|$dt[7]|$dt[8]|$dt[9]|$dt[10]|$dt[11]|$dt[12]|\r\n";
}
else {$kolvotem="0"; $kolvomsg="0"; $lines[$i]="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$kolvotem|$kolvomsg|$dt[6]|$dt[7]|$dt[8]||$dt[10]|$dt[11]|$dt[12]|\r\n";}
}
else $lines[$i]="$dt[0]|$dt[1]|$dt[2]|\r\n";
} while($i < $countmf);
// ��������� ���������� ������ � ���-�� ��� � ��������� � �����
$file=file("$datadir/mainforum.dat");
$fp=fopen("$datadir/mainforum.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) fputs($fp,$lines[$i]);
flock ($fp,LOCK_UN);
fclose($fp);
print "
�� ������� �����������.";
exit; }}
// ���� �������� ��������� ������
if (isset($_GET['usersdelete'])) { $usersdelete=$_GET['usersdelete'];
$first=$_POST['first']; $last=$_POST['last']; $page=$_GET['page']; $delnum=null; $i=0;
// ���������� ���-�� ����� � ����� ������ � �� ����������
if (count(file("$datadir/usersdat.php")) != count(file("$datadir/userstat.dat"))) exit("���������� ���������� ����������! ��������� ����: '����������� ���������� ����������',
� ����� ��� ����� ����� ������� ����������!");
do {$dd="del$first"; if (isset($_POST["$dd"])) { $delnum[$i]=$first; $i++;} $first++; } while ($first<=$last);
$itogodel=count($delnum); $newi=0;
if ($delnum=="") exit("�������� ����� ������ ������ ���������!");
$file=file("$datadir/usersdat.php"); $itogo=sizeof($file); $lines=null; $delyes="0";
for ($i=0; $i<$itogo; $i++) { // ���� �� ����� � �������
for ($p=0; $p<$itogodel; $p++) {if ($i==$delnum[$p]) $delyes=1;} // ���� �� ������� ��� ��������
// ���� ��� ����� �� �������� ������ - ��������� ����� ������ �������, ����� - ���
if ($delyes!=1) {$lines[$newi]=$file[$i]; $newi++;} else $delyes="0"; }
// ����� ����� ������ � ����
$newitogo=count($lines);
$fp=fopen("$datadir/usersdat.php","w");
flock ($fp,LOCK_EX);
// ���� ���� ������ �������, ����� ������ ���� ������� :-))
if (isset($lines[0])) { for ($i=0; $i<$newitogo; $i++) fputs($fp,$lines[$i]); } else fputs($fp,"");
flock ($fp,LOCK_UN);
fclose($fp);
// ������� ���� � ����� �� ����� ���������� - ���������� ����!!!!
// ������ ����� ������ ������� �� ������, ������� ������������� ������
// �� � ������ ����� ��������� ��� ���������� � �������� ����
// ������ - ����� ��������� ����� ������
$file=file("$datadir/userstat.dat"); $itogo=sizeof($file); $lines=null; $delyes="0"; $newi=0;
for ($i=0; $i<$itogo; $i++) { // ���� �� ����� � �������
for ($p=0; $p<$itogodel; $p++) {if ($i==$delnum[$p]) $delyes=1;} // ���� �� ������� ��� ��������
// ���� ��� ����� �� �������� ������ - ��������� ����� ������ �������, ����� - ���
if ($delyes!=1) {$lines[$newi]=$file[$i]; $newi++;} else $delyes="0"; }
// ����� ����� ������ � ����
$newitogo=count($lines);
$fp=fopen("$datadir/userstat.dat","w");
flock ($fp,LOCK_EX);
// ���� ���������� ���� ������ �������, ����� ������ ���� ������� :-))
if (isset($lines[0])) {for ($i=0; $i<$newitogo; $i++) fputs($fp,$lines[$i]);} else fputs($fp,"");
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho&page=$page"); exit; }
// ���� �����ר�� ���������� ����������
if(isset($_GET['newstatistik'])) {
$lines=null; $ok=null;
// 1. ��������� � ��������� � ������ ���� � �������
$ulines=file("$datadir/usersdat.php"); $ui=count($ulines);
// 2. ��������� ���� ����������
$slines=file("$datadir/userstat.dat"); $si=count($slines)-1;
// ���� �� ���-�� ������ � ����
for ($i=1;$i<$ui;$i++) {
$udt=explode("|", $ulines[$i]);
if ($i<=$si) $sdt=explode("|",$slines[$i]); else $sdt[0]="";
if ($udt[0]==$sdt[0]) {$udt[0]=str_replace("\r\n","",$udt[0]); $ok=1; if (isset($sdt[1]) and isset($sdt[2]) and isset($sdt[3]) and isset($sdt[4])) {$lines[$i]="$slines[$i]";} else {$lines[$i]="$udt[0]|0|0|0|0|||||\r\n";}} // ���� ���=��� - ������ ������ �����
// ���� � ����� ���������� - ����� ������ �������� �����
if ($ok!="1") {
for ($j=1;$j<$si;$j++) {
$sdt=explode("|", $slines[$j]);
if ($udt[0]==$sdt[0]) {$ok=1; $lines[$i]=$slines[$j]; }// ���� ���=��� - ������ ������ �����
}
if ($ok!="1") $lines[$i]="$udt[0]|0|0|0|0|||||\r\n"; // ������ ����� � ������� �����������
}
$ok=null; $ii=count($lines);}
$fp=fopen("$datadir/userstat.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
fputs($fp,"���_�����|���|���������|���������|�������������� �/5|����� ��������� ��� ������ ������� � UNIX �������|||\r\n");
for ($i=1;$i<=$ii;$i++) fputs($fp,"$lines[$i]");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho"); exit; }
// ���� ��������� ������� ���������
if(isset($_GET['newstatus'])) { if ($_GET['newstatus'] !="") { $newstatus=$_GET['newstatus']-1; $status=$_POST['status'];
if (isset($_GET['page'])) $page=$_GET['page']; else $page=1;
if (strlen($status)<3) exit("����� ������ ��������� < 3 �������� - ��� �� ��������!");
$status=htmlspecialchars($status); $status=stripslashes($status);
$status=str_replace("|"," ",$status); $status=str_replace("\r\n","
",$status);
$lines=file("$datadir/usersdat.php"); $i=count($lines);
$dt=explode("|", $lines[$newstatus]);
$record="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$dt[4]|$dt[5]|$dt[6]|$dt[7]|$dt[8]|$dt[9]|$dt[10]|$dt[11]|$dt[12]|$status|";
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=(sizeof($lines)-1);$i++) { if ($i==$newstatus) fputs($fp,"$record\r\n"); else fputs($fp,$lines[$i]); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho&page=$page"); exit; } }
// ���� ��������� �������� ���������
if(isset($_GET['newreiting'])) { if ($_GET['newreiting'] !="") { $newreiting=$_GET['newreiting']-1; $reiting=$_POST['reiting'];
if (isset($_GET['page'])) $page=$_GET['page']; else $page=1;
$reiting=htmlspecialchars($reiting); $reiting=stripslashes($reiting);
$reiting=str_replace("|"," ",$reiting); $reiting=str_replace("\r\n","
",$reiting);
$lines=file("$datadir/usersdat.php"); $i=count($lines);
$dt=explode("|", $lines[$newreiting]);
$txtdat="$dt[0]|$dt[1]|$reiting|$dt[3]|$dt[4]|$dt[5]|$dt[6]|$dt[7]|$dt[8]|$dt[9]|$dt[10]|$dt[11]|$dt[12]|$dt[13]|";
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=(sizeof($lines)-1);$i++) { if ($i==$newreiting) fputs($fp,"$txtdat\r\n"); else fputs($fp,$lines[$i]); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho&page=$page"); exit; } }
// �������� ��������� �����
if(isset($_GET['newrepa'])) {
if (isset($_GET['page'])) $page=$_GET['page']; else $page=1;
$text=$_POST['repa']; $usernum=$_POST['usernum']-1;
$text=htmlspecialchars($text); $text=stripslashes($text);
$text=str_replace("|"," ",$text); $repa=str_replace("\r\n","
",$text);
$lines=file("$datadir/userstat.dat");
$dt=explode("|", $lines[$usernum]);
$txtdat="$dt[0]|$dt[1]|$dt[2]|$repa|$dt[4]|$dt[5]|$dt[6]|$dt[7]|||";
$fp=fopen("$datadir/userstat.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=(sizeof($lines)-1);$i++) { if ($i==$usernum) fputs($fp,"$txtdat\r\n"); else fputs($fp,$lines[$i]); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho&page=$page"); exit; }
// ���� �������� �����, ������������� � ���������
if(isset($_GET['deletefoto'])) { $deletefoto=replacer($_GET['deletefoto']);
$fid=replacer($_GET['fid']); $id=replacer($_GET['id']);
if (is_file("$filedir/$deletefoto")) unlink ("$filedir/$deletefoto"); // ������� ����
Header("Location: admin.php?fid=$fid&id=$id"); exit;}
// ���������/������� ������ �����
if(isset($_GET['userstatus'])) {
if (isset($_GET['page'])) $page=$_GET['page']; else $page=1;
$text=$_POST['submit']; $status=$_POST['status']; $usernum=$_POST['usernum']-1;
$text=htmlspecialchars($text); $text=stripslashes($text);
$text=str_replace("|"," ",$text); $submit=str_replace("\r\n","
",$text);
if (!ctype_digit($status)) $status=0;
$status=$status+$submit; // ������������ ������ (+1 ��� -1)
// 0 <= ������ <= 5 (������ ���� ����� ����, �� ������ ���� ����� ����)
if($status<0 or $status>5) exit("$back ������ ������������ ������ ���� ����� ����, �� ������ ���� ����� ����!");
$lines=file("$datadir/userstat.dat");
if (!isset($lines[$usernum])) exit("������! ��� ������ ������������ � ����� ����������!"); // ���� ��� ����� ������ � ����� ����������
$dt=explode("|", $lines[$usernum]);
// � ������ 1.8.2 ��� ���� 5 ����� � ������ ����� userstat.dat.
// ���������� �� ������ - ������ ������ ����
if (!isset($dt[6])) $dt[6]="";
if (!isset($dt[7])) $dt[7]="";
$dt[6]=str_replace("\r\n","",$dt[6]); $dt[7]=str_replace("\r\n","",$dt[7]);
$txtdat="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$status|$dt[5]|$dt[6]|$dt[7]|||";
$fp=fopen("$datadir/userstat.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=(sizeof($lines)-1);$i++) { if ($i==$usernum) fputs($fp,"$txtdat\r\n"); else fputs($fp,$lines[$i]); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho&page=$page"); exit; }
// ���������� ������ �����������
if (isset($_GET['event'])) { if ($_GET['event']=="voteadd") {
$id=replacer($_GET['id']); $toper=replacer($_POST['toper']); // �������� ������ �� �����
$i=1; $itgo=0; $text="$toper||\r\n";
do {
$otv=replacer($_POST["otv$i"]); $otv=str_replace("|","I",$otv); $otv=str_replace("\r\n","
",$otv);
$kolvo=replacer($_POST["kolvo$i"]); $kolvo=str_replace("|","I",$kolvo); $kolvo=str_replace("\r\n","
",$kolvo);
if (strlen($otv)>0) {$itgo++; $text.="$otv|$kolvo|\r\n";}
$i++;
} while ($i<10);
if ($itgo<1) exit("������ ���� ������ ���� ������� ������!");
// ������ ���� � ������������
$fp=fopen("$datadir/$id-vote.dat","w");
flock ($fp,LOCK_EX);
fputs($fp,"$text");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
@chmod("$datadir/$id-vote.dat", 0644);
// ������ ���� ��� ������ IP������ ������������
$fp=fopen("$datadir/$id-ip.dat","w");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
@chmod("$datadir/$id-ip.dat", 0644);
Header("Location: admin.php?id=$id"); exit; }} // ����� ���������� ������ �����������
// ���� ����������/��������������/�������� �����������
// � �������� ��������� - ��������!!!!
if(isset($_GET['vote'])) { $vote=$_GET['vote'];
$fid=$_GET['fid']; $id=$_GET['id'];
if ($vote=="delete") { // ������� - ��������
if (is_file("$datadir/$id-vote.dat")) {unlink ("$datadir/$id-vote.dat"); unlink ("$datadir/$id-ip.dat");}} // ������� ����� � ������������
if ($vote=="change") { } // ������� - ��������������
if ($vote=="add") {
if (is_file("$datadir/$id-vote.dat")) exit("$back. ����������� ��� ��������� � ����. ����� ������ ����������� ��������� ������!");
} // ������� - ����������
if ($vote=="addsave") { } // ���������� ����� ����� ���������� ��� ��������������
Header("Location: admin.php?fid=$fid&id=$id"); exit;}
// ���� ����������� �����/���� ������� ��� ������
if(isset($_GET['movetopic'])) { if ($_GET['movetopic'] !="") {
$move1=$_GET['movetopic']; $where=$_GET['where'];
if ($where=="0") $where="-1";
$move2=$move1-$where;
$file=file("$datadir/mainforum.dat"); $imax=sizeof($file);
if (($move2>=$imax) or ($move2<"0")) exit(" ���� ���� �������!");
$data1=$file[$move1]; $data2=$file[$move2];
$fp=fopen("$datadir/mainforum.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
// ������ ������� ��� �������� �������
for ($i=0; $i<$imax; $i++) {if ($move1==$i) fputs($fp,$data2); else {if ($move2==$i) fputs($fp,$data1); else fputs($fp,$file[$i]);}}
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php"); exit; }}
// ���� �������� ���������� ������� ��� ������ +++
if(isset($_GET['fxd'])) {
$id=replacer($_GET['fxd']); if ($id=="" or strlen($id)>3) exit("������, �������� ������� ��� ��������, ���� ������ �������!");
// ��������� ��� ����� � ����� data ���������, ������ ��, ������� ���������� �� $id,
// (����� � ������, ������������ -vote, IP-������� ����������� -ip, topic$id - � ������)
if ($handle=opendir($datadir)) {
while (($file = readdir($handle)) !== false)
if (!is_dir($file)) {
$tema=substr($file,0,3);
if($tema==$id) unlink ("$datadir/$file");
if($file=="topic$id.dat") unlink ("$datadir/topic$id.dat");
} closedir($handle); } else echo'������!';
// ������� ������, ��������������� ���� � ����� �� ����� ������
$file=file("$datadir/mainforum.dat");
$fp=fopen("$datadir/mainforum.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) {$dt=explode("|",$file[$i]); if ($dt[0]==$id) unset($file[$i]);}
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php"); exit; }
// ���� �������� ���������� ���������� ��������� +++
if(isset($_GET['lxd'])) {
$id=replacer($_GET['lxd']); if ($id=="" or strlen($id)!=7) exit("������, �������� ��������� ��� ��������, ���� ������ �������!");
// ��������� ���� news.dat � ������� ������, ��������������� ��������� � �����
$file=file("$datadir/news.dat");
$fp=fopen("$datadir/news.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) {$dt=explode("|",$file[$i]); if ($dt[1]==$id) unset($file[$i]);}
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php"); exit; }
// ���� ������������� ���� +--
if (isset($_GET['rename'])) { if ($_GET['rename'] !="") {
$fid=$_GET['id']; $id_old=$_GET['rename']; $page=$_GET['page'];
// ID ���� �������� � ����� ����, � �������, � 10-�� ���������, �� ������� � ��������� ����
// ����� ����� ���������!!! �����!
// 1. ��������� ����������, ���������� ����� ID ����
// ���� ���������� ��������� �� ������� ����� ����, ������� �������� � 1000
// ��������� ���� ���� � ������ � ������
$id=1000; $id="$fid$id";
$allid=null; $records=file("$datadir/topic$fid.dat"); $imax=count($records); $i=$imax;
if ($i > 0) { do {$i--; $rd=explode("|",$records[$i]); $allid[$i]=$rd[7]; } while($i>0);
//natcasesort($allid); // ��������� �� �����������
do $id++; while(in_array($id,$allid) or is_file("$datadir/$id.dat"));
} else $id=$fid."1000";
// ��������� ���������� ������� � ������ ������ |ID ������| �� ����� �� ����� �����
$rec=file_get_contents("$datadir/topic$fid.dat");
$rec=str_replace("|$id_old|","|$id|",$rec); // ������ ������ |ID ������| �� ����� �� ����� �����
$fp=fopen("$datadir/topic$fid.dat","w+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
fputs($fp,"$rec");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
rename("$datadir/$id_old.dat", "$datadir/$id.dat"); // ��������������� ����
$rec=file_get_contents("$datadir/$id.dat"); // ��������� ����������
$rec=str_replace("|$id_old|","|$id|",$rec); // ������ ������ |ID ������| �� ����� �� ����� �����
$fp=fopen("$datadir/$id.dat","w+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
fputs($fp,"$rec");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
// 4. ��������� ���������� ������� � ������ ������ |ID ������| �� ����� �� ����� �����
$rec=file_get_contents("$datadir/mainforum.dat"); // ��������� ����������
$rec=str_replace("|$id_old|","|$id|",$rec); // �������� |ID ������| �� ����� �� ����� �����
$fp=fopen("$datadir/mainforum.dat","w+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
fputs($fp,"$rec");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
// 5. ��������� ���������� ��������� 20 ��� � ������ ������ |ID ������| �� ����� �� ����� �����
$rec=file_get_contents("$datadir/news.dat"); // ��������� ����������
$rec=str_replace("|$id_old|","|$id|",$rec); // �������� |ID ������| �� ����� �� ����� �����
$fp=fopen("$datadir/news.dat","w+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
fputs($fp,"$rec");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
// ������ � ����� �������! � ������ ���� �� 1 �� 4-�, ����� �� ������� ��� ������ ��������
// ������
Header("Location: admin.php?id=$fid&page=$page"); exit; } }
// ���� �������� ��������� ����
if (isset($_GET['xd'])) { if ($_GET['xd'] !="") {
if (isset($_GET['page'])) $page=$_GET['page']; else $page="0";
$xd=$_GET['xd']; $id=$_GET['id']; $fid=substr($id,0,3);
$file=file("$datadir/topic$fid.dat");
$minmsg=1; $delf=null; if (isset($file[$xd])) {
$dt=explode("|", $file[$xd]);
$delf = str_replace("\r\n", "", $dt[7]);
$mlines=file("$datadir/$delf.dat"); $minmsg=count($mlines);
unlink ("$datadir/$delf.dat");} // ������� ���� � �����
if (is_file("$datadir/$delf-vote.dat")) unlink("$datadir/$delf-vote.dat"); // ������� ���� � ������������
if (is_file("$datadir/$delf-ip.dat")) unlink("$datadir/$delf-ip.dat"); // ������� ���� � ������������� IP
// ������� ������, ��������������� ���� � ����� � �������� ������
$fp=fopen("$datadir/topic$fid.dat","w");
$kolvotem=sizeof($file)-1; // ���-�� ��� ��� ��������� �� �������
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) {if ($i==$xd) unset($file[$i]);}
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
// ���� �������� 1-�� �� ���-�� ��� � �������� ���-�� ���������
$lines=file("$datadir/mainforum.dat"); $i=count($lines);
// ������� �� fid ����� ������
for ($ii=0;$ii< sizeof($lines);$ii++) {$kdt=explode("|",$lines[$ii]);
if ($kdt[0]==$fid) $mnumer=$ii;}
$dt=explode("|",$lines[$mnumer]);
$dt[5]=$dt[5]-$minmsg;
if ($kolvotem=="0") $dt[5]="0";
if ($dt[5]<0) $dt[5]="0";
if ($dt[4]<0) $dt[4]="0";
// ���� ��������� ���� ����� �� ������� ��� ���������, �� ������� � � �������
if ($dt[3]==$delf or $dt[5]==0) {$dt[6]="";$dt[7]="";$dt[8]="";$dt[9]="";$dt[10]="";}
$text="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$kolvotem|$dt[5]|$dt[6]|$dt[7]|$dt[8]|$dt[9]|$dt[10]|$dt[11]|$dt[12]||";
$file=file("$datadir/mainforum.dat");
$fp=fopen("$datadir/mainforum.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
for ($ii=0;$ii< sizeof($file);$ii++) { if ($mnumer!=$ii) fputs($fp,$file[$ii]); else fputs($fp,"$text\r\n"); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
// ������� ���������� �� 10-�� ���������
$file=file("$datadir/news.dat");
$fp=fopen("$datadir/news.dat","w");
flock ($fp,LOCK_EX);
for ($i=0; $i< sizeof($file); $i++) { $dt=explode("|",$file[$i]); if ($dt[1]==$id) unset($file[$i]); }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?id=$fid&page=$page"); exit; } }
// ���� �������� ���������� ���������
if (isset($_GET['topicxd'])) { if ($_GET['topicxd'] !="") {
$id=$_GET['id']; $fid=substr($id,0,3); $topicxd=$_GET['topicxd']-1;
if (isset($_GET['page'])) $page=$_GET['page']; else $page="1";
$file=file("$datadir/$id.dat");
if (count($file)==1) exit("� ���� ������ �������� ������ ���� ���������!");
$fp=fopen("$datadir/$id.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$topicxd) unset($file[$i]); }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
$topicxd--;
$file=file("$datadir/$id.dat");
//������������ ������ ���������� ��������� � ����
$dt=explode("|",$file[count($file)-1]); $avtor=$dt[0]; $data=$dt[5]; $time=$dt[6];
// ���� �������� 1-�� �� ���-�� ��������� �� �������
$lines = file("$datadir/mainforum.dat"); $i=count($lines);
// ������� �� fid ����� ������
for ($ii=0;$ii< sizeof($lines);$ii++) { $kdt=explode("|",$lines[$ii]); if ($kdt[0]==$fid) $mnumer=$ii; }
$dt=explode("|",$lines[$mnumer]);
$dt[5]--; if ($dt[5]<0) $dt[5]="0";
$text="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$dt[4]|$dt[5]|$avtor|$data|$time|$dt[9]|$dt[10]|$dt[11]||$dt[12]||";
$file=file("$datadir/mainforum.dat");
$fp=fopen("$datadir/mainforum.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
for ($ii=0;$ii< sizeof($file);$ii++) { if ($mnumer!=$ii) fputs($fp,$file[$ii]); else fputs($fp,"$text\r\n"); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?id=$id&page=$page#m$topicxd"); exit; } }
// ���������� ������ / ������� +++
if(isset($_GET['event'])) { if ($_GET['event'] =="addmainforum") {
$ftype=$_POST['ftype']; $zag=$_POST['zag']; $msg=$_POST['msg']; $id="101";
if ($zag=="") exit("$back � ������� ���������!");
// ��������� �� ����� � �������� ��������/������� - ���� ���������� � ��������� +1
if (is_file("$datadir/mainforum.dat")) { $lines=file("$datadir/mainforum.dat");
$imax=count($lines); $i=0;
do {$dt=explode("|", $lines[$i]); if ($id<$dt[0]) {$id=$dt[0];} $i++; } while($i<$imax);
$id++; }
if ($id<101) $id=101; if ($id>999) exit("����� �� ����� ���� ����� 999");
$zag=str_replace("|","I",$zag); $msg=str_replace("|","I",$msg);
if ($ftype=="") $record="$id|$zag|$msg||0|0||$date|$time||||||"; else $record="$id|$ftype|$zag|";
$record=replacer($record);
// ������ ������ ���� � ���������
if ($ftype=="") { $fp=fopen("$datadir/topic$id.dat","a+");
flock ($fp,LOCK_EX); fputs($fp,""); fflush ($fp); flock ($fp,LOCK_UN); fclose($fp); }
// ������ ������ �� ������� ��������
$fp=fopen("$datadir/mainforum.dat","a+");
flock ($fp,LOCK_EX); fputs($fp,"$record\r\n"); fflush ($fp); flock ($fp,LOCK_UN); fclose($fp);
Header("Location: admin.php"); exit; }
// ���� ���������� ����������
if(isset($_GET['event'])) { if ($_GET['event'] =="sortusers") { $kaksort=$_POST['kaksort']; $lines="";
// ��������� ��� ����� � ������
$dat="$datadir/usersdat.php"; $dlines=file("$dat"); $di=count($dlines);
$stat="$datadir/userstat.dat"; $slines=file("$stat"); $si=count($slines);
$msguser=1000; // ����� ���-�� ����������� ��������� - ���� �������!!!!
if ($di!=$si) exit("$back - ���������� ����������� ���������� ����������!!! ���� �������� ��������!!!");
for ($i=1;$i<$di;$i++) {
$dt=explode("|",$dlines[$i]);
$st=explode("|",$slines[$i]);
if ($dt[0]!=$st[0]) exit("$back ���������� ����������� ���������� ����������!!! ���� �������� ��������!!!");
/* kaksort
1 - ����� $dt[0]
2 - ���-�� ��������� $st[2]
3 - ���-�� ���� dt[2]
4 - ��������� $st[3]
5 - ���� ����������� $dt[4]
6 - ���������� $dt[4]/$st[2] */
// ��� ���������� �� ������ ����� ������ ������ ��������
if ($kaksort==1) {$name=strtolower($dt[0]); $lines[$i]="$name|";}
if ($kaksort==2) {$msg="0".+9999-$st[2]; $lines[$i]="$msg|";}
if ($kaksort==3) {$msg="0".+99-$dt[2]; $lines[$i]="$msg|";}
if ($kaksort==4) {$msg="0".+9000-$st[3]; $lines[$i]="$msg|";}
if ($kaksort>4) {
$akt=explode(".",$dt[4]); $tekdt=mktime();
$datereg=mktime(0,0,0,$akt[1],$akt[0],$akt[2]);
$aktiv=round(($tekdt-$datereg)/86400);
$aktiv=round(100*$msguser/$aktiv)/100;
if ($kaksort==5) $lines[$i]="$datereg|";
if ($kaksort==6) $lines[$i]="$aktiv|"; }
// ��������� ��� ����� � ���� ����������
$lines[$i].="$dt[0]|$dt[1]|$dt[2]|$dt[3]|$dt[4]|$dt[5]|$dt[6]|$dt[7]|$dt[8]|$dt[9]|$dt[10]|$dt[11]|$dt[12]|$dt[13]|$st[1]|$st[2]|$st[3]|$st[4]|$st[5]|||\r\n";
} // ����� FOR
// ��������� ������
setlocale(LC_ALL,'ru_RU.CP1251'); // ! ��������� ������ �������, ���������� � ���������� � � �������� �������
function prcmp ($a, $b) {if ($a==$b) return 0; if ($a<$b) return -1; return 1;} // ������� ����������
usort($lines,"prcmp"); // ��������� ��� �� �����������
// ��������� �� ��� ������� � �� ������� �� ���������
$dlines=null; $dlines="\r\n"; $slines=null; $slines="���_�����|���|���������|���������|�������������� �/5|����� ��������� ��� ������ ������� � UNIX �������|||\r\n";
for ($i=0;$i<$di-1;$i++) {
$nt=explode("|",$lines[$i]);
$dlines.="$nt[1]|$nt[2]|$nt[3]|$nt[4]|$nt[5]|$nt[6]|$nt[7]|$nt[8]|$nt[9]|$nt[10]|$nt[11]|$nt[12]|$nt[13]|$nt[14]|||\r\n";
$slines.="$nt[1]|$nt[15]|$nt[16]|$nt[17]|$nt[18]|$nt[19]|||\r\n";
}
// ������ ������
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
fputs($fp,"$dlines");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
$fp=fopen("$datadir/userstat.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
fputs($fp,"$slines");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=userwho"); exit; }}
// �������������� ������ / �������
if ($_GET['event'] =="frdmainforum") {
$nextnum=$_POST['nextnum'];
$frd=$_POST['frd'];
$ftype=$_POST['ftype'];
$zag=$_POST['zag'];
if ($zag=="") exit("$back � ������� ���������!");
$zag=str_replace("|","I",$zag);
if ($ftype == "") { $addmax=$_POST['addmax']; $zvezdmax=$_POST['zvezdmax'];
$msg=$_POST['msg'];$idtemka=$_POST['idtemka'];$kt=$_POST['kt'];$km=$_POST['km'];$namem=$_POST['namem'];$datem=$_POST['datem'];$timem=$_POST['timem'];$temka=$_POST['temka'];$timetk=$_POST['timetk'];
$msg=str_replace("|","I",$msg); $msg=str_replace("\r\n", "
", $msg);
$txtmf="$nextnum|$zag|$msg|$idtemka|$kt|$km|$namem|$datem|$timem|$timetk|$temka|$addmax|$zvezdmax||";}
else $txtmf="$nextnum|$ftype|$zag|";
$txtmf=htmlspecialchars($txtmf); $txtmf=stripslashes($txtmf); $txtmf=str_replace("\r\n","
",$txtmf);
$file=file("$datadir/mainforum.dat");
$fp=fopen("$datadir/mainforum.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i< sizeof($file);$i++) { if ($frd!=$i) fputs($fp,$file[$i]); else fputs($fp,"$txtmf\r\n"); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php"); exit; }
if ($_GET['event']=="rdtema") { // ������� �������������� ����
$rd=replacer($_POST['rd']); $id=$rd;// - ���������� ����� ����, ������� ���������� ��������
$changefid=$_POST['changefid'];
if (isset($_GET['page'])) $page=$_GET['page']; else $page="0";
$oldzag=replacer($_POST['oldzag']); // ������ �������� ���� (�� ��������������)
$name=$_POST['name']; $who=$_POST['who']; $email=$_POST['email'];
$zag=$_POST['zag']; $msg=$_POST['msg']; $datem=$_POST['datem'];
$timem=$_POST['timem']; $fid=substr($rd,0,3);
$timetk=$_POST['timetk']; $status=$_POST['status']; $goto=$_POST['goto'];
if ($goto==1) $goto="admin.php?id=$changefid"; else $goto="admin.php?id=$fid&page=$page";
if ($zag=="") exit("$back � ������� ����, ��� ������!");
$text="$name|$who|$email|$zag|$msg|$datem|$timem|$rd|$status|$timetk|||||";
$text=replacer($text); $text=str_replace("<br>","
",$text);
// ���� ����������� ���
// I. � topic$temaplus.dat ����� ������� ������ � ���� �����
$temaplus=replacer($_POST['temaplus']); $temakuda=replacer($_POST['temakuda']);
if (strlen($temaplus)>1 and is_file("$datadir/$temaplus.dat")) {
$file=file("$datadir/topic$fid.dat");
$fp=fopen("$datadir/topic$fid.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i2) exit("$back. ������� ������. ������� ����� �� �����.");
// ������ �� ������ fid
if (!ctype_digit($fid) or strlen($fid)>3) exit("$back. ������� ������. ������� ����� �� �����.");
// �������� �� ���� �������� � ������� - ���� �������������
// �� ��� ������, ���� mainforum.dat - ����, ���������� ��������� �����
$realbase="1"; if (is_file("$datadir/mainforum.dat")) $mainlines=file("$datadir/mainforum.dat");
if (!isset($mainlines)) $datasize=0; else $datasize=sizeof($mainlines);
if ($datasize<=0) {if (is_file("$datadir/copy.dat")) {$realbase="0"; $mainlines=file("$datadir/copy.dat"); $datasize=sizeof($mainlines);}}
if ($datasize<=0) exit("$back. �������� � ����� ������ - ���������� � ��������������");
$i=count($mainlines);
$realfid=null;
do {$i--; $dt=explode("|", $mainlines[$i]);
if ($dt[0]==$fid) {$realfid=$i; if ($dt[1]=="razdel") exit("$back. ������� ������.");} // ����������� $realfid - � �/� ������
} while($i>0);
if (!isset($realfid)) exit("$back. ������ � ������� �������. ��� �� ���������� � ����.");
$dt=explode("|",$mainlines[$realfid]);
if (is_file("$datadir/topic$fid.dat")) {$tlines=file("$datadir/topic$fid.dat"); $tc=count($tlines)-2; $i=$tc+2; $ok=null;
// ����� ����������� �� ������, ����� ����. ���� ���� - �������, ���� - ������ ���������� ��������� ���������!
if ($_GET['event']=="addanswer") {
do {$i--; $tdt=explode("|",$tlines[$i]);
//print"$tdt[7]==$id
";
if ($tdt[7]=="$id") {$ok=1; if ($tdt[8]=="closed") exit("$back ���� ������� � ���������� ��������� ���������!"); }
} while($i>0);
if ($ok!=1) exit("$back ���� ������� � ���������� ��������� ���������!"); }
} else $tc="2";
if ($dt[11]>0 and $tc>=$dt[11]) exit("$back. ��������� ����������� �� ���-�� ���������� ��� � ������ �������! �� ����� $dt[11] ���!");
// �������� ������/������ �����. ����� �� �����, ����� ����� ���
// ���� 1
if (isset($_COOKIE['wrfcookies'])) {
$wrfc=$_COOKIE['wrfcookies']; $wrfc=htmlspecialchars($wrfc); $wrfc=stripslashes($wrfc);
$wrfc=explode("|", $wrfc); $wrfname=$wrfc[0]; $wrfpass=$wrfc[1];
} else {unset($wrfname); unset($wrfpass);}
// ���� 2
if ($who=="��") {
if (isset($wrfname) & isset($wrfpass)) {
$lines=file("$datadir/usersdat.php"); $i=count($lines);
do {$i--; $rdt=explode("|", $lines[$i]);
if (isset($rdt[1])) { $realname=strtolower($rdt[0]);
if (strtolower($wrfname)===$realname & $wrfpass===$rdt[1]) $ok="$i"; }
} while($i > "1");
if (!isset($ok)) {setcookie("wrfcookies","",time()); exit("������ ��� ������ � ����! �� �� ������� �������� ���������, ���������� ������ ��� ��� �����. ��� ����� � ������ �� ������� � ���� ������, ���������� ����� �� ����� �����. ���� ������ ����������� - ���������� � �������������� ������.");}
}}
if (!isset($name) || strlen($name) > $maxname || strlen($name) <1) exit("$back ���� ��� ������, ��� ��������� $maxname ��������!");
if (strlen(ltrim($zag))<3 || strlen($zag) > 200) exit("$back ������� �������� �������� ���� ��� �������� ��������� $maxzag ��������!");
if (strlen(ltrim($msg))<2 || strlen($msg) > 10000) exit("$back ���� ��������� �������� ��� ��������� $maxmsg ��������.");
if (!preg_match('/^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$/si',$email) and strlen($email)>30 and $email!="") exit("$back � ������� ���������� E-mail �����!");
// ���������� ��� ����� � �����
if ($_GET['event'] =="addtopic") {$add=null; $z=null; do {$id=mt_rand(1000,9999); if ($fid<10) $add="0"; if (!is_file("$datadir/$add$fid$id.dat") and strlen($id)==4) {$z++;} } while ($z<1); $id="$add$fid$id";}
if ((!ctype_digit($id)) or (strlen($id)>15)) exit("$back. ������� ������. $id ������ ���� ������. ������� ����� �� �����.");
if (strlen(ltrim($zag))<3) exit("$back ! ������ � ����� ������ ���������!");
$tektime=time();
$name=wordwrap($name,30,' ',1); // ��������� ������� ������
$zag==wordwrap($zag,30,' ',1);
$msg=wordwrap($msg,110,' ',1);
$name=str_replace("|","I",$name);
$who=str_replace("|","|",$who);
$email=str_replace("|","|",$email);
$zag=str_replace("|","|",$zag);
$msg=str_replace("|","|",$msg);
$smname=$name; if (strlen($name)>18) {$smname=substr($name,0,18); $smname.="..";}
$smzag=$zag; if (strlen($zag)>24) {$smzag=substr($zag,0,24); $smzag.="..";}
$ip=$_SERVER['REMOTE_ADDR']; // ���������� IP �����
$text="$name|$who|$email|$zag|$msg|$date|$time|$id||$tektime|$smname|$smzag|||||$ip||||";
$text=replacer($text);
$exd=explode("|",$text);
$name=$exd[0]; $zag=$exd[3]; $smname=$exd[10]; $smzag=$exd[11]; $smmsg=$exd[4];
if(isset($_GET['topicrd'])) { // ������� �������������� ���������
$topicrd=replacer($_GET['topicrd']); // ����� ������, ������� ���������� ��������
$oldmsg=replacer($_POST['oldmsg']);
$oldmsg=str_replace("\r\n","
",$oldmsg);
$oldmsg=str_replace("|","|",$oldmsg);
$oldmsg=str_replace(":kovichka:", "'",$oldmsg); // �������������� ������ '
$fdate=replacer($_POST['fdate']); $ftime=replacer($_POST['ftime']);
$msg=replacer($msg);
$file=file("$datadir/$id.dat");
$fs=count($file)-1; $i="-1";
$timetek=time(); $timefile=filemtime("$datadir/$id.dat");
$timer=$timetek-$timefile; // ������ ������� ������ ������� (� ��������)
$records=file_get_contents("$datadir/$id.dat");
$records=str_replace("|$oldmsg|$fdate|$ftime|","|$msg|$fdate|$ftime|",$records); // ������ ������ |������ ���������|����|�����| �� �����
//print"$oldmsg\r\r\n
$msg\r\r\n
$records"; exit; // ���������������� ���� ��������� �� �������������!
$fp=fopen("$datadir/$id.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
fputs($fp,$records);
//do {$i++; if ($i==$topicrd) fputs($fp,"$text\r\n"); else fputs($fp,$file[$i]); } while($i < $fs);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
if ($timer<0) {$viptime=strtotime("+2 year"); touch("$datadir/$fid$id.dat",$viptime);}
Header("Location: admin.php?id=$id&page=$page"); exit; }
print"";
// ���� ������� ������� ��, �� ������ ���� �������� ����� � ���� ����� ������ �����
if ($_GET['event'] =="addanswer") { // ��� ������ � ����
if (is_file("$datadir/$id.dat")) {$linesn=file("$datadir/$id.dat"); $in=count($linesn)-1;}
// ���������, ����� �� �������������� ����
$timetek=time(); $timefile=filemtime("$datadir/$id.dat");
$timer=$timetek-$timefile; // ������ ������� ������ ������� (� ��������)
// $timer<10 - 10 ������ ������ �� ���������
if ($smmsg=="��!") {
if ($timer<10 and $timer>0) exit("$back ���� ���� ������� ����� $timer ������ �����.");
touch("$datadir/$id.dat");
print "
�������, $name, ���� ��������������.
����� ��������� ������ �� ������ ������������� ���������� � ������� ���� $zag.
������ >>> |
|
";
exit; }
if ($timer<10 and $timer>0) exit("$back ���� ���� ������� ����� $timer ������ �����.");
}
$razdelname="";
if ($realbase=="1" and $maxzd<1) { // ���� ���������� ������� ����, � �� �����
$lines=file("$datadir/mainforum.dat");
$dt=explode("|", $lines[$realfid]); $dt[5]++;
if ($_GET['event']=="addtopic") $dt[4]++;
// �� ������ 4-� ������ ����� ��� �������� ��� � �����!
if (!isset($dt[11])) $dt[11]="100"; $dt[11]=str_replace("
", "
", $dt[11]);
if (!isset($dt[12])) $dt[12]=""; $dt[12]=str_replace("
", "
", $dt[12]);
$txtdat="$dt[0]|$dt[1]|$dt[2]|$id|$dt[4]|$dt[5]|$smname|$date|$time|$tektime|$smzag|$dt[11]|$dt[12]||";
$razdelname=$dt[1];
// ������ ������ �� ������� ��������
$fp=fopen("$datadir/mainforum.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=(sizeof($lines)-1);$i++) { if ($i==$realfid) fputs($fp,"$txtdat\r\n"); else fputs($fp,$lines[$i]); }
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
} // if ($realbase==1)
if ($newmess=="1" and $maxzd<1) { // ������ � ��������� ���� ������ ���������
if (is_file("$datadir/topic$fid.dat")) $nlines=count(file("$datadir/topic$fid.dat")); else $nlines=1;
if (is_file("$datadir/$id.dat")) $nlines2=count(file("$datadir/$id.dat"))+1; else $nlines2=1;
$newmessfile="$datadir/news.dat";
$newlines=file("$newmessfile"); $ni=count($newlines)-1; $i2=0; $newlineexit="";
$nmsg=substr($msg,0,150); // �������� ��������� �� 150 ��������
$ntext="$fid|$id|$date|$time|$smname|$zag|$nmsg...|$nlines|$nlines2|$razdelname|$who||||";
$ntext=str_replace("
", "
", $ntext);
// ���� ���������, ���� �� ��� ����� ��������� � ���� ����. ���� ���� - ���������. �� ������ - ������ ��� ���� ������.
for ($i=0;$i<=$ni;$i++)
{ $ndt=explode("|",$newlines[$i]);
if (isset($ndt[1])) {if ($id!=$ndt[1]) {$newlineexit.="$newlines[$i]"; $i2++;}}
}
// ���������� ������ ��������� � ������ � ����� ��������� ��� � ����
if ($maxzd<1) { // ���� ���� �������� ��� ���� - ��� ����������� �� ������
if ($i2>0) { // ���� ���� ����� ����, �� ����� ���� ������, ����� ���� ������
$newlineexit.=$ntext;
$fp=fopen("$newmessfile","w");
flock ($fp,LOCK_EX);
fputs($fp,"$newlineexit\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
} else {
$fp=fopen("$newmessfile","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$ntext\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp); }
$file=file($newmessfile);$i=count($file);
if ($i>="15") {
$fp=fopen($newmessfile,"w");
flock ($fp,LOCK_EX);
unset($file[0]);
fputs($fp, implode("",$file));
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
}
}
}
} // if ($newmess==1)
// ���� ��������� +1 � ���� � +1 � ��������� ��� +1 � ���-�� ���, ��������� ������
if (isset($_COOKIE['wrfcookies']) and (isset($ok))) {
$ufile="$datadir/userstat.dat"; $ulines=file("$ufile"); $ui=count($ulines)-1; $ulinenew="";
// ���� ����� �� ����� � ����� userstat.dat
for ($i=0;$i<=$ui;$i++) {$udt=explode("|",$ulines[$i]);
if ($udt[0]==$wrfname) {
$udt[3]++; $udt[2]++; if ($_GET['event']=="addtopic") $udt[1]++;
$ulines[$i]="$udt[0]|$udt[1]|$udt[2]|$udt[3]|$udt[4]|$udt[5]||||\r\n";}
$ulinenew.="$ulines[$i]";}
// ����� ������ � ����
$fp=fopen("$ufile","w");
flock ($fp,LOCK_EX);
fputs($fp,"$ulinenew");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
} // if isset($ok)
if ($_GET['event'] =="addtopic") { // ���������� ���� - ������ ������
// ����� � �����
$fp=fopen("$datadir/topic$fid.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
// ����� � ����
$fp=fopen("$datadir/$fid$id.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
print "
�������, $name, �� ���������� ����!
����� ��������� ������ �� ������ ������������� ���������� � ��������� ����.
������ >>> |
|
";
exit;
}
if ($_GET['event'] =="addanswer") { //����� � ���� - ������ ������
$timetek=time(); $timefile=filemtime("$datadir/$id.dat");
$timer=$timetek-$timefile; // ������ ������� ������ ������� (� ��������)
$fp=fopen("$datadir/$id.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
if ($timer<0) {$viptime=strtotime("+2 year"); touch("$datadir/$id.dat",$viptime);}
$in=$in+2; $page=ceil($in/$qq); // ����������� ������ �������� � ����� ���������
print "
�������, $name, ��� ����� ������� ��������.
����� ��������� ������ �� ������ ������������� ���������� � ������� ���� $zag.
������ >>> |
|
";
exit;
}
// ������� ����� ��
if ($_GET['event']=="makecopy") {
if (is_file("$datadir/mainforum.dat")) $lines=file("$datadir/mainforum.dat");
if (!isset($lines)) $datasize=0; else $datasize=sizeof($lines);
if ($datasize<=0) exit("�������� � ����� ������ - ���� ����������. ������ = 0!");
if (copy("$datadir/mainforum.dat", "$datadir/copy.dat")) exit("
����� ���� ������ �������.
$back
"); else exit("������ �������� ����� ���� ������. ���������� ������� ������� ���� copy.dat � ����� $datadir � ��������� ��� ����� �� ������ - 666 ��� ������ ����� 777 � ��������� �������� �������� �����!"); }
// ������������ �� ����� ��
if ($_GET['event']=="restore") {
if (is_file("$datadir/copy.dat")) $lines=file("$datadir/copy.dat");
if (!isset($lines)) $datasize=0; else $datasize=sizeof($lines);
if ($datasize<=0) exit("�������� � ������ ���� ������ - ��� ����������. �������������� ����������!");
if (copy("$datadir/copy.dat", "$datadir/mainforum.dat")) exit("
�� ������������� �� �����.
$back
"); else exit("������ �������������� �� ����� ���� ������. ���������� ������� ������ copy.dat � mainforum.dat � ����� $datadir ��������� ����� �� ������ - 666 ��� ������ ����� 777 � ��������� �������� ��������������!"); }
// ���������������� ������, ��� 2: ���������� ������
if ($_GET['event']=="config") {
// ��������� ����� ������ ������/����������
if (strlen($_POST['newpassword'])<1 or strlen($_POST['newmoderpass'])<1) exit("$back ����������� ����� ������ ������� 1 ������!");
if ($_POST['newpassword']!="�����") {$pass=trim($_POST['newpassword']); $_POST['password']=md5("$pass+$skey");}
if ($_POST['newmoderpass']!="�����") {$pass=trim($_POST['newmoderpass']); $_POST['moderpass']=md5("$pass+$skey");}
// ������ �� ������. ��������, ��� � ������� ������ ���������� �������...
$fd=stripslashes($_POST['fdesription']); $fd=str_replace("\\","/",$fd); $fd=str_replace("?>","? >",$fd); $fd=str_replace("\"","'",$fd); $fdesription=str_replace("\r\n","
",$fd);
mt_srand(time()+(double)microtime()*1000000); $rand_key=mt_rand(1000,9999); // ���������� ��������� ����� ��� �����������
$gmttime=($_POST['deltahour'] * 60 * 60); // ������� ��������
$newsmiles=$_POST['newsmiles'];
$i=count($newsmiles); $smiles="array(";
for($k=0; $k<$i; $k=$k+2) {
$j=$k+1; $s1=replacer($newsmiles[$k]); $s2=replacer($newsmiles[$j]);
$smiles.="\"$s1\", \"$s2\""; if ($k!=($i-2)) $smiles.=",";
} $smiles.=");";
$_POST['fname']=replacer($_POST['fname']);
$configdata="��������� �����\"; // ������� ������\r\n".
"$"."smiles=".$smiles."// �������� (��� �����, ������ ��� �������, -//-)\r\n".
"$"."date=date(\"d.m.Y\", time()+$gmttime); // �����.�����.���\r\n".
"$"."deltahour=\"".$_POST['deltahour']."\"; // ��������� ���-�� ����� �� ��������� ������������ �������� �� �������: �� * 3600\r\n".
"$"."time=date(\"H:i:s\",time()+$gmttime); // ����:������:�������\r\n?>";
$file=file("config.php");
$fp=fopen("config.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
fputs($fp,$configdata);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
Header("Location: admin.php?event=configure"); exit;}
} // ����� if isset($event)
// ����� ��� ���� ������� ������
if (isset($_COOKIE['wrfcookies'])) {
$wrfc=$_COOKIE['wrfcookies']; $wrfc = explode("|", $wrfc);
$wrfname=$wrfc[0];$wrfpass=$wrfc[1];$wrftime1=$wrfc[2];$wrftime2=$wrfc[3];
if (time()>($wrftime1+50)) { $tektime=time();
$wrfcookies="$wrfc[0]|$wrfc[1]|$tektime|$wrftime1|";
setcookie("wrfcookies", $wrfcookies, time()+1728000);
$wrfc=$_COOKIE['wrfcookies']; $wrfc = explode("|", $wrfc);
$wrfname=$wrfc[0];$wrfpass=$wrfc[1];$wrftime1=$wrfc[2];$wrftime2=$wrfc[3]; }}
if (is_file("$datadir/mainforum.dat")) $mainlines=file("$datadir/mainforum.dat");
if (!isset($mainlines)) $datasize=0; else $datasize=sizeof($mainlines);
if ($datasize<=0) {if (is_file("$datadir/copy.dat")) {$mainlines=file("$datadir/copy.dat"); $datasize=sizeof($mainlines);}}
if ($datasize<=0) exit("���� ������ ������������! �������� �������!
");
// ���� ���������� ����� �������� ����� ��� �����������
if (is_file("$datadir/mainforum.dat")) $mainlines=file("$datadir/mainforum.dat"); $imax=count($mainlines); $i=$imax;
if (!isset($mainlines)) $datasize=0; else $datasize=sizeof($mainlines);
if ($datasize<=0) {if (is_file("$datadir/copy.dat")) {$mainlines=file("$datadir/copy.dat"); $datasize=sizeof($mainlines);}}
if ($datasize<=0) exit("���� ������ ������������! ������� � ������� � �������� �������!");
$error=FALSE; $frname=null; $frtname=""; $rfid="";
// ��� ������ ���� razdel=
if (isset($_GET['razdel'])) {
do {$i--; $dt=explode("|", $mainlines[$i]);
if ($dt[0]==$_GET['razdel']) {$rfid=$i; $frname="$dt[2] ->";}
} while($i >0);
$i=$imax;}
if (isset($_GET['id'])) { // ���� ������� � ��������� ������: ���� -> ������ -> �����
$id=$_GET['id'];
if (strlen($id)<=3 and !is_file("$datadir/topic$id.dat")) $error="�� ���� ������";
if (strlen($id)> 3 and !is_file("$datadir/$id.dat")) $error="�� ���� ����";
if (!ctype_digit($id)) $error="�� ���� ���� ��� ������";
if (isset($_GET['quotemsg'])) $error=TRUE;
if(strlen($id)>3) {$fid=substr($id,0,3); $id=substr($id,3,4);} else $fid=$id;
// �������� �� ���� �������� � ������� - ���� �������������
do {$i--; $dt=explode("|", $mainlines[$i]);
if ($dt[0]==$fid) { $frname="$dt[1] ->";
if (isset($dt[11])) { if($dt[11]>0) $maxtem=$dt[11]; else $maxtem="999";}}
} while($i >0);
//$frtname="1"; $frname="2"; $fname="3";
// ���� ��������� �������� ���� ��� ����������� � ����� ������
if (strlen($id)>3 and is_file("$datadir/topic$fid.dat")) {
$lines=file("$datadir/topic$fid.dat"); $imax=count($lines); $i=$imax;
do {$i--; $dt=explode("|",$lines[$i]);
if($dt[7]=="$fid$id") $frtname="$dt[3] ->";
} while ($i>0); }
if ($error==TRUE) { // ��������� ���������� ������� � ������������ / ���˨���� ������� / ����!
$topurl="$fskin/top.html";
ob_start(); include $topurl; $topurl=ob_get_contents(); ob_end_clean();
$topurl=str_replace("",'',$topurl);
print"$topurl";
if (strlen($error)>1) exit("��������, �� �����������$error �����������.
���������� ������� �� ������� �������� ������ ��
���� ������,
� ����� ������������ ��� ����.
"); }
// ����� ��������� ���������� �� ��������, �� ������� ������ ����
if (strlen($id)==3) { $lines=file("$datadir/topic$id.dat"); $imax=count($lines);
if (isset($_GET['page'])) $page=$_GET['page']; else $page=1;
$maxikpage=ceil($imax/$qqmain); }
} // if (isset($_GET['id']))
// �������� �������� ������ ���� ���� ����
?>
������� :: <?print"$frtname $frname $fname";?>
">
">
';
// ���������� ���: ����� ��� ���������
if ($dt[1]=="razdel") print "";
else {
if (is_file("$datadir/$dt[3].dat")) { $msgsize=sizeof(file("$datadir/$dt[3].dat")); // ������� ���-�� ������� � �����
if ($msgsize>$qq) $page=ceil($msgsize/$qq); else $page=1; } else {$msgsize=""; $page=1;}
if ($dt[7]==$date) $dt[7]="�������";
$maxzvezd=null; if (isset($dt[12])) { if ($dt[12]>0) {$maxzvezd="*�������� ����������, ������� $dt[12] �����";
$dt[4]=""; $dt[5]="";
if ($dt[12]==1) $maxzvezd.="�";
if ($dt[12]==2 or $dt[12]==3 or $dt[12]==4) $maxzvezd.="�"; $maxzvezd.=" �������";}}
print "
";
$itogotem=$itogotem+$dt[4]; $itogomsg=$itogomsg+$dt[5]; }
} while($a1 < $u);
echo'
$add";
// ������� ������� �������� ������
if (!isset($_GET['event'])) {
if (!isset($_GET['id'])) {
echo'
';
// ������� qq ��������� �� ������� ��������
$addform="
������ |
���/����. |
������� |
���������� |
---|
";
if (!is_file("$datadir/mainforum.dat")) exit("������������ �� �� �����. ���� mainforum.dat ������������ ��� �������� �����/������.$addform");
$lines = file("$datadir/mainforum.dat"); $datasize = sizeof($lines);
if ($datasize==0) exit("���� mainforum.dat ���� - �������� ����� ��� ������.$addform");
$i=count($lines);
$n="0"; $a1="-1"; $u=$i-1;
$fid="0"; $itogotem="0"; $itogomsg="0";
do {$a1++; $dt = explode("|", $lines[$a1]);
$fid=$dt[0];
echo' |
';
if ($ktotut==1) { // ������ ����� ����� ��������� ���������
print""; }
echo' | $dt[2] | |
$dt[1] $maxzvezd $dt[2] |
$dt[4] / $dt[11] |
$dt[5] |
����: $dt[10]
�����: $dt[6]
����: $dt[7] - $dt[8] |
';
// ������� �������������� ������
if (isset($_GET['frd'])) { if ($_GET['frd'] !="") { $frd=$_GET['frd'];
$lines = file("$datadir/mainforum.dat");
$dt = explode("|", $lines[$frd]);
if (isset($dt[11])) { if ($dt[11]>0) $addmax=$dt[11]; else $addmax="100"; }
if (isset($dt[12])) {if ($dt[12]<=0) $dt[12]="0";}
$dt[2]=str_replace("
","\r\n",$dt[2]);
print "
";
} } // ����� �������������� ������
else { if ($ktotut==1) print "$addform"; }
if ($statistika==TRUE) {
print"���������� |
 |
���������: $itogomsg ���: $itogotem ����� ���������������� ����������: $ui ��������� �����������������: $tdt[0] |
";
// ���������� -= ��������� ��������� � ������ =-
if (is_file("$datadir/news.dat")) { $newmessfile="$datadir/news.dat";
$lines=file($newmessfile); $i=count($lines); //if ($i>10) $i=10; (������������� - ��� ��� ����!!! ;-))
if ($i>1) {
echo('
');
$a1=$i-1;$u="-1"; // ������� ������ �� ����������� ��� ��������
do {$dt=explode("|", $lines[$a1]); $a1--;
if (isset($dt[1])) { // ���� ������� ���������� � ������� (������ ������) - �� ������ � �� �������
$dt[6]=htmlspecialchars($dt[6]);
$dt[6]=str_replace("[b] "," ",$dt[6]);
$dt[6]=str_replace("[/b]"," ",$dt[6]);
$dt[6]=str_replace("[RB] "," ",$dt[6]);
$dt[6]=str_replace("[/RB]"," ",$dt[6]);
$dt[6]=str_replace("[Code] "," ",$dt[6]);
$dt[6]=str_replace("[/Code]"," ",$dt[6]);
$dt[6]=str_replace("[Quote] "," ",$dt[6]);
$dt[6]=str_replace("[/Quote]"," ",$dt[6]);
$dt[6]=str_replace("
","\r\n", $dt[6]);
$dt[6]=str_replace("'","`", $dt[6]);
$dt[2]=str_replace(".201",".1", $dt[2]);
$dt[2]=substr($dt[2],0,8);
$dt[3]=substr($dt[3],0,5);
if ($dt[8]>$qq) $page=ceil($dt[8]/$qq); else $page=1; // ������� ��������
if ($dt[10]=="��") {$codename=urlencode($dt[4]); $name="$dt[4]";} else $name="����� $dt[4]";
print"
";
} // ���� ������� ����������
$a11=$u; $u11=$a1;
} while($a11 < $u11);
echo'��������� ��������� |
 | |
$dt[2] - $dt[3]: $dt[9] -> $dt[5] - $name. |
';}
} // ����� ����� ��������� ���������
}
} // ����� ������� ��������
// ����� ����������!
if (isset($_GET['id'])) {
if (strlen($_GET['id'])==3) { $fid=replacer($_GET['id']); $id=replacer($_GET['id']); }
else $id=replacer($_GET['id']);
if (strlen($id)==3) { // ������� �������� � ������ ��������� �������
$maxzd=null; // �������� ������ �� ���-�� �¨�� � ����
$imax=count($mainlines);
do {$imax--; $ddt=explode("|", $mainlines[$imax]); if ($ddt[0]==$fid) $maxzd=$ddt[12]; } while($imax>"0");
if (!ctype_digit($maxzd)) $maxzd=0;
print "
";
$addbutton="
X/P |
���� |
C�������� |
����� |
���������� |
";
// ���������� ���� �� ���������� � ����� � �������
if (is_file("$datadir/topic$fid.dat"))
{
$msglines=file("$datadir/topic$fid.dat");
if (count($msglines)>0) {
if (count($msglines)>$maxtem-1) $addbutton="";
} //if (is_file)
} while($lm < $fm);
// ��������� ���������� $pageinfo - �� ������� �������
$pageinfo=""; $addpage=""; $maxpage=ceil(($maxi+1)/$qq); if ($page>$maxpage) $page=$maxpage;
$pageinfo.="��������: ";
if ($page>3 and $maxpage>5) $pageinfo.="
1 ... ";
$f1=$page+2; $f2=abs($page-2); if ($f2=="0") $f2=1; if ($page>=$maxpage-1) $f1=$maxpage;
if ($maxpage<=5) {$f1=$maxpage; $f2=1;}
for($i=$f2; $i<=$f1; $i++) { if ($page==$i) $pageinfo.="
$i ";
else {if ($i!=1) $addpage="&page=$i"; $pageinfo.="
$i ";} }
if ($page<=$maxpage-3 and $maxpage>5) $pageinfo.="...
$maxpage";
$pageinfo.='
';
print "���������� ���������� ��� � ������� ���������.";
// ������� qqmain ��������� �� ������� ��������
$lines=file("$datadir/topic$fid.dat");
$i=count($lines); $maxi=count($lines)-1; $n="0";
// ���� ����������: ��������� ������ ������ (�� ������� �������� ����� � �����)!
do {$i--; $dt=explode("|",$lines[$i]);
$filename="$dt[7].dat"; if (is_file("$datadir/$filename")) $ftime=filemtime("$datadir/$filename"); else $ftime="";
$newlines[$i]="$ftime|$dt[7]|$i|";
} while($i > 0);
usort($newlines,"prcmp");
// $newlines - ������ � �������: ���� | ���_�����_�_����� | � �/� |
// $lines - ������ �� ����� ������ ��������� �������
$i=$maxi;
do {$i--; $dtn=explode("|", $newlines[$i]);
$numtp="$dtn[2]"; $lines[$i]="$lines[$numtp]";
} while($i > 0);
// ����� ����� ����������
// ��������� ������ ������ �������������� ��������
if (!isset($_GET['page'])) $page=1; else { $page=$_GET['page']; if (!ctype_digit($page)) $page=1; if ($page<1) $page=1; }
// ���������� QQ ���
$fm=$maxi-$qq*($page-1); if ($fm<"0") $fm=$qq;
$lm=$fm-$qq; if ($lm<"0") $lm="-1";
$timetek=time();
do {$dt=explode("|", $lines[$fm]);
// ����� ��� ����������� ���� �� VIP-������
if (is_file("$datadir/$dt[7].dat")) $ftime=filemtime("$datadir/$dt[7].dat"); else $ftime="";
$timer=$timetek-$ftime; // ������ ������� ������ ������� (� ��������)
$fm--; $num=$fm+2; $numid=$fm+1;
$filename=$dt[7]; if (is_file("$datadir/$filename.dat")) { // ���� ���� � ����� ���������� - �� �������� ����
$msgsize=sizeof(file("$datadir/$filename.dat"));
// --------- �������� ����� ���������
$linetmp=file("$datadir/$filename.dat"); if (sizeof($linetmp)!=0) {
$pos=$msgsize-1; $dtt=explode("|", $linetmp[$pos]);
$foldicon="folder.gif";
// ���� ��������� ��������� � ������ ��������� ������ ��������� - ������ ������ ������ - �����
if (isset($wrfname)) {if (isset($dtt[9])) {if ($dtt[9]>$wrftime2) $foldicon="foldernew.gif";}}
if (strlen($dt[8])>1 and $dt[8]=="closed") {if ($msgsize<"20") $foldicon="close.gif"; else $foldicon="closed.gif"; }} else $foldicon="foldernew.gif";
// --------- �����
print " |
|
 |
";
if ($timer<0) echo'VIP ';
print"$dt[3]";
if ($msgsize>$qq) { // ������� ������ ��������� ������� ����
$maxpaget=ceil($msgsize/$qq); $addpage="";
echo' ��������: ';
if ($maxpaget<=5) $f1=$maxpaget; else $f1=5;
for($i=1; $i<=$f1; $i++) {if ($i!=1) $addpage="&page=$i"; print" $i ";}
if ($maxpaget>5) print "... $maxpaget"; }
print" | $msgsize | ";
$codename=urlencode($dt[0]);
if ($dt[1]=="��") print "$dt[0] $users"; else print"$dt[0] $guest";
if ($msgsize>=2) {$linesdat=file("$datadir/$filename.dat"); $dtdat=explode("|", $linesdat[$msgsize-1]);
if (strlen($linesdat[$msgsize-1])>10) {$dt[0]=$dtdat[0]; $dt[1]=$dtdat[1]; $dt[2]=$dtdat[2]; $dt[5]=$dtdat[5]; $dt[6]=$dtdat[6];}} // ������ if (strlen...) ������ ���� ���� ���� � ����� ������ ������ - �������
$dt[6]=substr($dt[6],0,-3);
if ($dt[5]===$date) $dt[5]="�������";
print " |
�����: $dt[0]
����: $dt[5]
�����: $dt[6]
|
$pageinfo";
}}
// ------------ ������� �������������� ����
if (isset($_GET['rd'])) { if ($_GET['rd'] !="") { $rd=replacer($_GET['rd']); $i="-1";
// ����� �� ������� ��� � ���� �� ����, ������� ������� �� ��������������
do {$i++; $dt=explode("|",$lines[$i]);
if ($dt[7]===$rd) $i=$maxi; // ���� ����� ����, ������ ��������� ���� � ������ �������� �� �������
} while($i < $maxi);
$moddate=filemtime("$datadir/$dt[7].dat"); $tektime=mktime();
if ($moddate<$tektime) {$vt1="checked"; $vt2="";} else {$vt2="checked"; $vt1="";}
if ($dt[8]=="closed") {$ct2="checked"; $ct1="";} else {$ct1="checked"; $ct2="";}
print "";
}
} else {
echo '
";
}
// --------------
}
if (strlen($id)==7) { // ������� ��������� � ������� ����
// ���������� ���� �� ���������� � ����� � �������
if (!is_file("$datadir/$id.dat")) exit("
$back. ��������, �� ����� ���� �� ������ �� ����������.
������ ����� � ������ �������������.");
$lines=file("$datadir/$id.dat"); $mitogo=count($lines); $i=$mitogo; $maxi=$i-1;
if ($mitogo>0) { $tblstyle="row1"; $printvote=null;
// ��������� ���������� ���� ����������
if (is_file("$datadir/userstat.dat")) {$ufile="$datadir/userstat.dat"; $ulines=file("$ufile"); $ui=count($ulines)-1;}
// ���� ���� � topic��.dat - ��������� �� ������� �� ����?
$msglines=file("$datadir/topic$fid.dat"); $mg=count($msglines); $closed="no";
do {$mg--; $mt=explode("|",$msglines[$mg]);
if ($mt[7]==$id and $mt[8]=="closed") $closed="yes";
} while($mg > "0");
$maxzd=null; // �������� ������ �� ���-�� �¨�� � ����
$imax=count($mainlines);
do {$imax--; $ddt=explode("|", $mainlines[$imax]); if ($ddt[0]==$fid) $maxzd=$ddt[12]; } while($imax>"0");
if (!ctype_digit($maxzd)) $maxzd=0;
// ��������� ������ ������ �������������� ��������
if (!isset($_GET['page'])) $page=1; else {$page=$_GET['page']; if (!ctype_digit($page)) $page=1; if ($page<1) $page=1;}
// ��������� ���������� $pageinfo - �� ������� �������
$pageinfo=""; $addpage=""; $maxpage=ceil(($maxi+1)/$qq); if ($page>$maxpage) $page=$maxpage;
$pageinfo.="��������: ";
if ($page>3 and $maxpage>5) $pageinfo.="
1 ... ";
$f1=$page+2; $f2=abs($page-2); if ($f2=="0") $f2=1; if ($page>=$maxpage-1) $f1=$maxpage;
if ($maxpage<=5) {$f1=$maxpage; $f2=1;}
for($i=$f2; $i<=$f1; $i++) { if ($page==$i) $pageinfo.="
$i ";
else {if ($i!=1) $addpage="&page=$i"; $pageinfo.="
$i ";} }
if ($page<=$maxpage-3 and $maxpage>5) $pageinfo.="...
$maxpage";
$pageinfo.='
';
print"$pageinfo";
$fm=$qq*($page-1); if ($fm>$maxi) $fm=$maxi-$qq;
$lm=$fm+$qq; if ($lm>$maxi) $lm=$maxi+1;
do {$dt=explode("|", $lines[$fm]);
$fm++; $num=$maxi-$fm+2; $status=""; unset($youwr);
if (strlen($lines[$fm-1])>5) { // ���� ������� ���������� � ������� (������ ������) - �� ������ � �� �������
$msg=str_replace("[b]","", $dt[4]);
$msg=str_replace("[/b]","",$msg);
$msg=str_replace("[RB]","",$msg);
$msg=str_replace("[/RB]","",$msg);
$msg=preg_replace("#\[Quote\]\s*(.*?)\s*\[/Quote\]#is","
������:",$msg);
$msg=preg_replace("#\[Code\]\s*(.*?)\s*\[/Code\]#is","
PHP ���:",$msg);
if ($smile==TRUE) {$i=count($smiles)-1; // �������� ��������� �������� �� ����������� ���� ���������
for($k=0; $k<$i; $k=$k+2) {$j=$k+1; $msg=str_replace("$smiles[$j]","
",$msg);}}
$msg=str_replace("<br>","
",$msg);
$msg=preg_replace('#\[img(.*?)\](.+?)\[/img\]#','
',$msg);
// ���� ��������� ���������� �����
if ($liteurl==TRUE) $msg = preg_replace ("/([\s>\]]+)(http|https|ftp|goper):\/\/([a-zA-Z0-9\.\?&=\;\-\/_]+)([\W\s<\[]+)/", "\\1\\2://\\3\\4", $msg);
// ��������� � ������ ������ �� ������������
if ($dt[1]=="��") {
$userlines=file("$datadir/usersdat.php"); $usercount=count($userlines); $ui=$usercount-1;
$iu=$usercount;
do {$iu--; $du=explode("|", $userlines[$iu]); if ($du[0]==$dt[0])
{ if (isset($du[12])) {$status=$du[13]; $reiting=$du[2]; $youavatar=$du[12]; $email=$du[3]; $icq=$du[7]; $site=$du[8]; $userpn=$iu;} $youwr=preg_replace("#(\[url=([^\]]+)\](.*?)\[/url\])|(http://(www.)?[0-9a-z\.-]+\.[a-z]{2,6}[0-9a-z/\?=&\._-]*)#","$4 ",$du[11]);}
} while($iu > "0");
}
if ($tblstyle=="row1") $tblstyle="row2"; else $tblstyle="row1";
if (!isset($m1)) {
print "";
echo''; $m1="1"; }
print"";
} // ���� ������� ����������
} while($fm < $lm);
print"
����� |
��������� |
";
// ���������: ��� �����?
if (!isset($youwr)) {if (strlen($dt[2])>5) print "$dt[0] "; else print"$dt[0] ";
$kuda=$fm-1; print" ".chr(149)."
$guest";}
else {
$codename=urlencode($dt[0]);
print "$dt[0] ".chr(149)."
";
if (strlen($status)>2 & $dt[1]=="��" & isset($youwr)) print "$status"; else print"$users";
if (isset($reiting)) {if ($reiting>0) {echo' '; if (is_file("$fskin/star.gif")) {for ($ri=0;$ri<$reiting;$ri++) {print" ";} } }}
if (isset($youavatar)) { if (is_file("avatars/$youavatar")) $avpr="$youavatar"; else $avpr="noavatar.gif";
print "
 ";}
} // isset($youwr)
if (isset($youwr) and is_file("$datadir/userstat.dat")) { // ������ ��������� ����� ��� ���������! ;-)
if (isset($ulines[$userpn])) {
if (strlen($ulines[$userpn])>5) {
$ddu=explode("|",$ulines[$userpn]);
print"
��� �������: $ddu[1]
���������: $ddu[2]
���������: $ddu[3] -+
��������������: $ddu[4] "; }}}
if (!isset($dt[16])) $dt[16]=""; // ��������, ��� ������������� � ������� ��������
print "
IP: $dt[16] ��� �� IP
| $msg";
// ���� ����������� - ���� ���� �� ������� !!!
if ($fm==1 and is_file("$datadir/$id-vote.dat")) { // ���� �������� ���� ���
$vlines=file("$datadir/$id-vote.dat");
if (sizeof($vlines)>0) {$vitogo=count($vlines); $vi=1; $vdt=explode("|",$vlines[0]);
print" | ';
// ���� �������˨� ���� � ��������� - �� ���������� ������ � ������ �� ���� ��� ��������
if (isset($dt[12])) { if ($dt[12]!="" and is_file("$filedir/$dt[13]")) {
$fsize=round($dt[14]/10.24)/100; print""; }}
// �������� ������� ���������
if (isset($youwr)) {if (strlen($youwr)>3) {print " | -------------------------------------------------- $youwr";}}
print" |
|
��������� # $fm. |
����������: $dt[5] - $dt[6] |
 |
$pageinfo ";
// ������� ����� .P. - �������������� ���������
if (isset($_GET['topicrd'])) { // ������� ��������� � �����
$topicrd=$_GET['topicrd']-1;
$lines=file("$datadir/$id.dat");
$dt=explode("|", $lines[$topicrd]);
$dt[4]=str_replace("
", "\r\n", $dt[4]);
$oldmsg=str_replace("'", ":kovichka:",$dt[4]); // ������� ������ '
print "