�������: $date - $time";
return true;}
function replacer ($text) { // ������� ������� ����
$text=str_replace(" ",' ',$text);
$text=str_replace(">",'>',$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 nospam() { global $max_key,$rand_key; // ������� �������� 2011 !
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'';
$nummax=0; for ($i=0; $i<=$max_key; $i++) {
$snum[$i]=mt_rand(0,9); $psnum=md5($snum[$i]+$rand_key+$dopkod);
$secret=mt_rand(0,1); $styles='bgcolor=#EEEEEE';
if ($nummax<3) { if ($secret==1 or $i==0) {$styles='bgcolor=#FFFF00'; $xkey=$xkey.$snum[$i]; $nummax++;}}
echo "\r\n";}
$xkey=md5("$xkey+$rand_key+$dopkod"); //����� + ���� �� config.php + ��� ���������� ����� 24 ����
print"
";
return; }
// ������� ������������ ��� ����������� ��������
function get_dir($path = './', $mask = '*.php', $mode = GLOB_NOSORT) {
if ( version_compare( phpversion(), '4.3.0', '>=' ) ) {if ( chdir($path) ) {$temp = glob($mask,$mode); return $temp;}}
return false;}
// �Ѩ, ��� �������� ��� ������� ���������� $_GET['event']
if(isset($_GET['event'])) {
if ($_GET['event']=="login") { // ���� �� ����� ����������
$frname="���� �� ����� .:. "; $frtname="";
include("$fskin/top.html"); addtop(); // ���������� ����� ������
echo '
'; exit;}
// ��������� - ���� ������: ��� 1
if ($_GET['event']=="repa") {
if (!isset($_GET['name'])) exit("��� ������ ���������� name.");
if (!isset($_GET['who'])) exit("��� ������ ���������� who.");
$name=replacer($_GET['name']); $userpn=replacer($_GET['who']);
if (!ctype_digit($userpn) or strlen($userpn)>4) exit("$back. ������� ������. ������� ����� �� �����!");
// ���� ����� ��� - �����, ���� ���� ���� � ����� ����� ����� - �����.
if (!isset($_COOKIE['wrfcookies'])) exit("��������� ��������� ��������� ��������� ����� ����������� ������ �������� ������!");
else { $wrfc=$_COOKIE['wrfcookies']; $wrfc=htmlspecialchars($wrfc); $wrfc=stripslashes($wrfc); $wrfc=explode("|", $wrfc); $wrfname=$wrfc[0];
if ($wrfname===$name) print"$back. �� �������� ������ ��������� ��������� ���� ���������! ";
else { print "��������� ��������� ���������: $name
";}
if (is_file("$datadir/repa.dat")) { // ���� � ����� repa.dat ���� �� ���� ����� � �������, ���� ����
$file="$datadir/repa.dat"; $lines=file("$file"); $i=count($lines);
echo' ';
do {$i--; $dt=explode("|",$lines[$i]);
if ($dt[2]==$name) {$dt[0]=date("d.m.y � H:i",$dt[0]); print"";}
} while($i>0);
echo'������ ���������
����� ��� ���� ������� $dt[0] $dt[3] $dt[1] $dt[4]
'; } // ���� ���� ���� repa.dat
exit; }}
// ��������� - ����������: ��� 2
if ($_GET['event']=="repasave") {
if (isset($_COOKIE['wrfcookies'])) {$wrfc=$_COOKIE['wrfcookies']; $wrfc=htmlspecialchars($wrfc); $wrfc=stripslashes($wrfc); $wrfc=explode("|", $wrfc); $wrfname=$wrfc[0];} else exit('������ ��������� ������ ����� �������� ���������!');
if (isset($_POST['userpn'])) $userpn=$_POST['userpn']; else exit("��� ������ ���������� userpn");
if (isset($_POST['repa'])) $repa=$_POST['repa']; else exit("��� ������ ���������� repa");
if (isset($_POST['pochemu'])) $pochemu=$_POST['pochemu']; else exit("������� ������� ����� ���������");
if (!ctype_digit($userpn) or strlen($userpn)>4) exit("$back. ������� ������. ������� ����� �� �����!");
if (!is_numeric($repa)) exit("$back. ������� ������. �� ��������, ����!");
if ($repa>5 or $repa<-5) exit("$back. ������� ������. ���� ����� ������ ������ �� +-5 �������. �� ��������, ����!");
if (strlen($pochemu)<1 or strlen($pochemu)>150) exit("$back. ����� ������� ������ ���� ������! � ���� �� ����� 150 ��������!");
$today=mktime();
// ���� ��������� + � ��������� �����
//���_�����|���|���������|���������|�������������� �/5|����� ��������� ��� ������ ������� � UNIX �������|||
$ufile="$datadir/userstat.dat"; $ulines=file("$ufile"); $ui=count($ulines)-1; $ulinenew=""; $username="";
// ���� ����� �� ����� � ����� userstat.dat, ���� ������� ���������� �� ����, ���������
for ($i=0;$i<=$ui;$i++) {$udt=explode("|",$ulines[$i]);
if ($i==$userpn) {$udt[3]=$udt[3]+$repa; if (strlen($udt[5])>5) {$next=$today-$udt[5]; sleep(1); if ($next<60) {$last=60-$next; exit("$back. ������� ����� ��������� ��� ��� ������� ������ ���. �������� $last ������. ");}}
$ulines[$i]="$udt[0]|$udt[1]|$udt[2]|$udt[3]|$udt[4]|$today||||\r\n"; $username="$udt[0]";}
$ulinenew.="$ulines[$i]";}
// ���������� ������ � ����
$fp=fopen("$ufile","w");
flock ($fp,LOCK_EX);
fputs($fp,"$ulinenew");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
// ���������� ������ � ���� REPA.DAT
//���� � UNIX-�������|������� ������|���_����_������|���_�����|�������||||
$fp=fopen("$datadir/repa.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$today|$repa|$username|$wrfname|$pochemu||||\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
exit("");
}
// �������� ��������� �����
if ($_GET['event']=="mailto") {
if ($sendmail!=TRUE) exit("$back. ��������, �� ������� �������� ����� ������������� ���������������!������� ���� ");
if (!isset($_POST['email'])) exit("��� ������ ���������� email.");
if (!isset($_POST['name'])) exit("��� ������ ���������� name.");
$uemail=replacer($_POST['email']); $uname=replacer($_POST['name']);
$id=""; $fid=""; if (isset($_POST['id'])) {$id=replacer($_POST['id']); if (strlen($id)>0) $fid=substr($id,0,3);}
print "
����������� ��������� ������ ����������
';
exit; }
// ��� 2 �������� ��������� ������������
if ($_GET['event']=="mailtogo") {
$name=replacer($_POST['name']);
$email=replacer($_POST['email']);
$msg=replacer($_POST['msg']);
if (isset($_POST['fid'])) $fid=replacer($_POST['fid']);
if (isset($_POST['id'])) $id=replacer($_POST['id']);
$uname=replacer($_POST['uname']);
$uemail=replacer($_POST['uemail']);
//--�-�-�-�-�-�-�-�--�������� ����--
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("����� ��������� ���!");}
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 (!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',$uemail) and strlen($uemail)>30 and $uemail!="") exit("$back � ������������ ����� �������������� �����! ");
if ($name=="") exit("$back �� �� ����� ��� ���! ");
if ($msg=="") exit("$back �� �� ����� ���������! ");
$text="$name|$msg|$uname|$email|";
$text=str_replace("\r\n"," ",$text);
$exd=explode("|",$text); $name=$exd[0]; $msg=$exd[1]; $uname=$exd[2]; $email=$exd[3];
$headers=null; // ��������� ��� �������� �����
$headers.="From: $name $email\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="Content-Type: text/html; charset=windows-1251";
// �������� ��� ���������� � ���� ������
$allmsg="
$uname, ��� ��������� ���������� ��� �� ���������� ������ $fname
��� $name
E-mail: $email
���������: $msg
���� �������� ���������: $time - $date �.
������� �� ������� ��������: $furl
* ������ ������ ������������� � ���������� �������, �������� �� ���� �� �����.
";
mail("$uemail", "��������� �� ���������� ������ ($fname) �� $name ", $allmsg, $headers);
exit(''); }
// �������� �����/������ � ���� �� �����
if ($_GET['event']=="regenter") {
if (!isset($_POST['name']) & !isset($_POST['pass'])) exit("$back ������� ��� � ������!");
$name=str_replace("|","I",$_POST['name']); $pass=replacer($_POST['pass']);
$name=replacer($name); $name=strtolower($name);
if (strlen($name)<1 or strlen($pass)<1) exit("$back �� �� ����� ��� ��� ������!");
// �������� �� ���� ������������� � ������� ������
$lines=file("$datadir/usersdat.php"); $i=count($lines); $regenter=FALSE;
$pass=md5("$pass");
do {$i--; $rdt=explode("|",$lines[$i]);
if (isset($rdt[1])) { // ���� ������� �� �����
if ($name===strtolower($rdt[0]) & $pass===$rdt[1]) {
if (strlen($rdt[13])>1 and ctype_digit($rdt[13])) exit("$back. ���� ������� ������ �� ������������ . ��� ��������� ��� ���������� ������� �� ������, ������� ������ ������ ��� �� �����.");
$regenter=TRUE;
$tektime=time();
$wrfcookies="$rdt[0]|$rdt[1]|$tektime|$tektime|";
setcookie("wrfcookies", $wrfcookies, time()+1728000);
}} // if-�
} while($i > "1");
if ($regenter==FALSE) exit("$back ��� ������ �� ����� !");
Header("Location: index.php");
}
// ����������� ����� ��� 2!! �������� �� ��� ������������� � ���������� � ��
if ($_GET['event']=="regnext") {
if (!isset($_POST['name']) & !isset($_POST['pass'])) exit("$back ������� ��� � ������!");
$name=str_replace("|","I",$_POST['name']); $pass=str_replace("|","I",$_POST['pass']); $dayreg=$date;
$name=trim($name); // �������� ���������� �������
if (isset($_POST['email'])) $email=$_POST['email']; else $email="";
$email=strtolower($email);
//--�-�-�-�-�-�-�-�--�������� ����--
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("����� ��������� ���!");}
if (preg_match("/[^(\\w)|(\\x7F-\\xFF)|(\\-)]/",$name)) exit("$back ���� ��� �������� ����������� �������. ��������� ������� � ���������� �����, ����� � �������������!!.");
if ($name=="" or strlen($name)>$maxname) exit("$back ���� ��� ������, ��� ��������� $maxname ��������!");
if ($pass=="" or strlen($pass)<1 or strlen($pass)>$maxname) exit("$back �� �� ����� ������. ������ �� ������ ���� ������.");
if(!preg_match("/^[a-z0-9\.\-_]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is", $email) or $email=="" or strlen($email)>40) exit("$back � ������� ���������� E-mail �����!");
if(substr( $email, -2, 2)=="pl"||substr( $email, -3, 3)=="com"||substr( $email, -6, 6)=="qip.ru") exit("����, �������, ����� ��������! $back � ������� ���������� E-mail �����!");
if (isset($_POST['pol'])) $pol=$_POST['pol']; else $pol=""; if ($pol!="�������") $pol="�������";
$email=str_replace("|","I",$email);
$key=mt_rand(100000,999999); if ($useactkey!="1") $key=""; // ������� ��������� ��� ���������? ���� �� ��������� - ��������
$pass=replacer($pass); $ps=md5("$pass");
$text="$name|$ps|0|$email|$dayreg||$pol||||||noavatar.gif|$key|";
$text=replacer($text);
$exd=explode("|",$text); $name=$exd[0]; $email=$exd[3];
if ($name===$pass) exit("$back. � ����� ����� ������������, ��������� ��������� ����� � ������! ");
// ���� ����� � ����� ������� ��� �������
$loginsm=strtolower($name);
$lines=file("$datadir/usersdat.php"); $i=count($lines);
if ($i>"1") { do {$i--; $rdt=explode("|",$lines[$i]);
$rdt[0]=strtolower($rdt[0]);
if ($rdt[0]===$loginsm) {$bad="1"; $er="�������";}
if ($rdt[3]===$email) {$bad="1"; $er="�������";}
} while($i > 1);
if (isset($bad)) exit("$back. �������� � ����� $er ��� ��������������� �� ������ !"); }
// �������� ������������ ���� ���������
$headers=null; // ��������� ��� �������� �����
$headers.="From: $name <$email>\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="Content-type: text/plain; charset=windows-1251";
// �������� ��� ���������� � ���� ������
if ($useactkey==TRUE) {
$allmsg=$fname.' (������������� �����������)'.chr(13).chr(10).
'����������� ������������ �� ������, ��� ����� ��������� �� ������: '.$furl.'tools.php?event=reg3&email='.$email.'&key='.$key.chr(13).chr(10).
'���� ���: '.$name.chr(13).chr(10).
'��� ������: '.$pass.chr(13).chr(10).
'��� E-mail: '.$email.chr(13).chr(10).
'������������� ����: '.$key.chr(13).chr(10).chr(13).chr(10).
'��������� ������ � ������� ��� ��������� ���.'.chr(13).chr(10).
'������ �� ������ �������� � ������������� ����, ������� ������ ����������.'.chr(13).chr(10).
'��� �������������� ������� � ������ ��� ������� ��������������� �������� �������������� ������.'.chr(13).chr(10);
} else { $allmsg=$fname.' (������ �����������)'.chr(13).chr(10). '�� ������� ���������������� �� ������: '.$furl.chr(13).chr(10). '���� ���: '.$name.chr(13).chr(10). '��� ������: '.$pass.chr(13).chr(10). '��� E-mail: '.$email.chr(13).chr(10); }
// ���������� ������ ������� �� �������� ;-)
mail("$email", "=?windows-1251?B?" . base64_encode("$fname (������������� �����������)") . "?=", $allmsg, $headers);
if ($sendadmin==TRUE) {mail("$adminemail", "=?windows-1251?B?" . base64_encode("$fname (����� ��������)") . "?=", $allmsg, $headers);}
$file=file("$datadir/usersdat.php");
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
fflush ($fp);//�������� ��������� ������
flock ($fp,LOCK_UN);
fclose($fp);
// ���������� ������� � ������ � ���� �� �����������
$file=file("$datadir/userstat.dat");
$fp=fopen("$datadir/userstat.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$name|0|0|0|0|||\r\n");
fflush ($fp);//�������� ��������� ������
flock ($fp,LOCK_UN);
fclose($fp);
if ($useactkey!=TRUE) { $tektime=time(); $wrfcookies="$name|$pass|$tektime|0|"; setcookie("wrfcookies", $wrfcookies, time()+1728000);
print"
$name, �� ������� ���������������� . ����� ��������� ������ �� ������ ������������� ���������� �� ������� �������� ������.
������ >>>
"; exit;}
print"
$name, �� ��������� ���� ����� ��� ������ ��� �������������.
��� ���� ����� ������������������ - ������� ��� �� ��������, ���� ��������� �� ������ - ��������� � ������ . ����� ��������� ������ �� ������ ������������� ���������� �� �������� ������������� �����������.
������ >>>
";
exit;
}
// ����������� ��� 3 - ���� ����� ���� ������������� �� ������
if ($_GET['event']=="reg3") {
if (isset($_GET['email']) and isset($_GET['key'])) {$key=$_GET['key']; $email=$_GET['email'];} else {
$frname=""; $frtname=""; include("$fskin/top.html"); addtop(); // ���������� ����� ������
exit('������������� �����������*
');}
// ������ �� ������ �� ����� � ������
if (strlen($key)<6 or strlen($key)>6 or !ctype_digit($key)) exit("$back. �� �������� ��� ����� �����. ���� ����� ��������� ������ 6 ����.");
$email=replacer($email); $email=str_replace("|","I",$email); $email=str_replace("\r\n"," ",$email);
if (strlen($key)>30) exit("������ ��� ����� ������");
// ���� ����� � ����� ������� � ������. ���� ���� - ������ ������ �� ������ ����.
$fnomer=null; $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);
// ������������� ����
$tektime=time(); $wrfcookies="$name|$pass|$tektime|0|";
setcookie("wrfcookies", $wrfcookies, time()+1728000);
}
if (!isset($fnomer) and !isset($ok)) exit("$back. �� �������� � ���� �������������� ����� ��� ������. ");
if (isset($ok)) $add="���� ������ ��� ������������"; else $add="$name, �� ������� ����������������";
print"
�������, $add . ����� ��������� ������ �� ������ ������������� ���������� �� ������� �������� ������.
������ >>>
";
exit; }
// ��������� ������ ����������� - ���������� ������
if ($_GET['event']=="reregist") { // if ($event =="reregist")
if (!isset($_POST['name'])) exit("$back ������� ���� ���!");
$name=str_replace("|","I",$_POST['name']);
if ($name=="" or strlen($name)>$maxname) exit("$back ���� ��� ������, ��� ��������� $maxname ��������!");
$name=trim($name); // �������� ���������� �������
if (preg_match("/[^(\\w)|(\\x7F-\\xFF)|(\\-)]/",$name)) exit("$back ���� ��� �������� ����������� �������. ��������� ������� � ���������� �����, ����� � �������������!!.");
if (!isset($_POST['pass'])) exit("$back �� �� ����� ������!");
$oldpass=$_POST['oldpass']; // ������ ������
$pass=trim($_POST['pass']);
if (strlen($_POST['newpassword'])<1 ) exit("$back ����������� ����� ������ ������� 1 ������!");
if ($_POST['newpassword']!="�����") {$pass=trim($_POST['newpassword']);
if (strlen($pass)<1 or strlen($pass)>20) exit("$back �� �� ����� ������. ������ ������ ���� ������ �� 1 �� 20 ��������!");
$pass=md5("$pass");}
$pass=replacer($pass); $pass=str_replace("|","I",$pass);
if (isset($_POST['email'])) $email=$_POST['email']; else $email=""; $email=strtolower($email);
if(!preg_match("/^[a-z0-9\.\-_]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is", $email) or $email=="" or strlen($email)>40) exit("$back � ������� ���������� E-mail �����!");
if (isset($_POST['dayx'])) $dayx=replacer($_POST['dayx']); else $dayx="";
if (isset($_POST['pol'])) $pol=replacer($_POST['pol']); else $pol=""; if ($pol!="�������") $pol="�������";
if (isset($_POST['icq'])) $icq=replacer($_POST['icq']); else $icq="";
if (isset($_POST['www'])) $www=replacer($_POST['www']); else $www="";
if (isset($_POST['about'])) $about=replacer($_POST['about']); else $about="";
if (isset($_POST['work'])) $work=replacer($_POST['work']); else $work="";
if (isset($_POST['write'])) $write=replacer($_POST['write']); else $write="";
if (isset($_POST['avatar'])) $avatar=replacer($_POST['avatar']); else $avatar="";
if ($_FILES['file']['name']!="") { // ��������� ��� � ������ ������������� �����
$fotoname=replacer($_FILES['file']['name']); $fotosize=$_FILES['file']['size']; // ��� � ������ �����
} else {$fotoname=$avatar; $fotosize="";}
$notgood="$back ������� ������� �������� ���������� ";
if (strlen($dayx)>20) {$notgood.="���� ��������!"; exit("$notgood");}
if (strlen($icq)>10) {$notgood.="ICQ!"; exit("$notgood");}
if (strlen($www)>75) {$notgood.="URL �����!"; exit("$notgood");}
if (strlen($about)>75) {$notgood.="������!"; exit("$notgood");}
if (strlen($work)>75) {$notgood.="��������!"; exit("$notgood");}
if (strlen($write)>75) {$notgood.="�������!"; exit("$notgood");}
$email=str_replace("|","I",$email);
$dayx=str_replace("|","I",$dayx);
$icq=str_replace("|","I",$icq);
$www=str_replace("|","I",$www);
$about=str_replace("|","I",$about);
$work=str_replace("|","I",$work);
$write=str_replace("|","I",$write);
$avatar=str_replace("|","I",$avatar);
// �������� ������/������� ������
$ok=null; $lines=file("$datadir/usersdat.php"); $i=count($lines); unset($ok);
do {$i--; $rdt=explode("|", $lines[$i]);
if (strtolower($name)===strtolower($rdt[0]) & $oldpass===$rdt[1]) $ok="$i"; // ���� ����� �����/������
else { if ($email===$rdt[3]) $bademail="1"; } // ����� � ������ ��� ���� ����� �����?
} while($i > "1");
if (isset($bademail)) exit("$back. �������� � ������� $email ��� ��������������� �� ������!");
if (!isset($ok)) {setcookie("wrfcookies","",time());
exit("$back ��� ����� ����� /������ / ����� �� ��������� �� � ����� �� ��.
����� ������������ ������ ���������
������ ������� ��� ������� ������ - ���������� � ��������������! ");}
$udt=explode("|",$lines[$ok]); $dayreg=$udt[4]; $kolvomsg=$udt[2]; $status=$udt[13];
$text="$name|$pass|$kolvomsg|$email|$dayreg|$dayx|$pol|$icq|$www|$about|$work|$write|$fotoname|$status|";
$text=replacer($text);
$exd=explode("|",$text); $name=$exd[0]; $pass=$exd[1]; $email=$exd[3];
// ������ ���� �����
//$tektime=time(); $wrfcookies="$name|$pass|$tektime|$tektime|";
//setcookie("wrfcookies", $wrfcookies, time()+1728000);
if ($fotoname!=$avatar and $fotoname!="") { // ���� �������� �������
// ������ �� ������
// 1. ��������� ����������
$ext = strtolower(substr($fotoname, 1 + strrpos($fotoname, ".")));
if (!in_array($ext, $valid_types)) {echo "���� �� ��������. ��������� �������:
- ��������� �������� ������ ������ � ������ ������������: ";
$patern=""; foreach($valid_types as $v) print"$v, ";
print"
- �� ��������� ��������� ���� � ������� �����������;
- ������� ����� ����� ��� ������ ����������� ����; "; exit;}
// 1. ������� ���-�� ����� � ��������� - ���� ������� ����� - ��������!
$findtchka=substr_count($fotoname, "."); if ($findtchka>1) exit("����� ����������� � ����� ����� $findtchka ���(�). ��� ���������! \r\n");
// 2. ���� � ����� ���� .php, .html, .htm - ��������!
$bag="��������, �� � ����� ����� ��������� ������������ .php, .html, .htm";
if (preg_match("/\.php/i",$fotoname)) exit("��������� .php �������. $bag");
if (preg_match("/\.html/i",$fotoname)) exit("��������� .html �������. $bag");
if (preg_match("/\.htm/i",$fotoname)) exit("��������� .htm �������. $bag");
// 3. �������� �� ������� ���� � ����� ����� � �������� ���������� �����
$patern=""; foreach($valid_types as $v) $patern.="$v|";
if (!preg_match("/^[a-z0-9\.\-_]+\.(".$patern.")+$/is",$fotoname)) exit("$fotoname - ��������� ������������ ������� ����� � ����� �����, � ����� ��������� ��������� ����� � ����������� �������� �� ��������!!");
// 4. ���������, ����� ���� ���� � ����� ������ ��� ���� �� �������
if (file_exists("$filedir/$fotoname")) exit(" $back. ���� � ����� ������ ��� ���������� �� �������! ���� �������� ��� �� ������, ���� �������� �������� - �������� �� ��������� �������� ��������� � ���� ��������!!");
// 5. ������ � ��. < �����������
$fotoksize=round($fotosize/10.24)/100; // ������ ������������ ���� � ��.
$fotomax=round($max_file_size/10.24)/100; // ������������ ������ ���� � ��.
if ($fotoksize>$fotomax) exit("�� ��������� ���������� ������ ����! ����������� ���������� ������ ����: $fotomax ��. �� ��������� ��������� �����������: $fotoksize ��!");
// 6. "��������" ������� > 150 � 150 - �� ��������! :-)
$size=getimagesize($_FILES['file']['tmp_name']);
if ($size[0]>150 or $size[1]>150) exit("�� ���������� �������� �������. ��������� ���� 150 � 150 px!");
if ($fotosize>"0" and $fotosize<$max_file_size) {
copy($_FILES['file']['tmp_name'], $avatardir."/".$fotoname);
print " ���� ������� ���������: $fotoname (������: $fotosize ����)";}
else exit("���� �� �������� - ������ �������!
���� �� ������ ��������� - [function.getimagesize]: Filename cannot be empty, ������ � ��� ���������� GD �����������, ���� ������ ������
�����, ������ �� ����� ��� �������� ��������� ��������, ��� �� �������� �������� �������� ������ ����� http ��� ���������!
���������� � ��������������!");
} // ����� ����� �������� �������
$file=file("$datadir/usersdat.php");
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i< sizeof($file);$i++) { if ($ok!=$i) fputs($fp,$file[$i]); else fputs($fp,"$text\r\n"); }
fflush ($fp);//�������� ��������� ������
flock ($fp,LOCK_UN);
fclose($fp);
print"
�������, $name, ���� ������ ������� �������� . ����� ��������� ������ �� ������ ������������� ���������� �� ������� �������� ������.
������ >>>
";
exit; }
if ($_GET['event'] =="givmepassword") { // �������� �������� ������ �� ����
// ������ �� ��������� ������
if (!isset($_POST['myemail']) or !isset($_POST['myname'])) exit("�� ����� �� ��������� ������!");
$myemail=strtolower($_POST['myemail']); $myemail=replacer($myemail);
$myname =strtolower($_POST['myname']); $myname =replacer($myname);
if (strlen($myemail)>40 or strlen($myname)>40) exit("����� ����� ��� ����� ������ ���� ����� 40 ��������!");
// ���������� ����� ������ �����
$len=8; // ���������� �������� � ����� ������
$base='ABCDEFGHKLMNPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';
$max=strlen($base)-1; $pass=''; mt_srand((double)microtime()*1000000);
while (strlen($pass)<$len) $pass.=$base{mt_rand(0,$max)};
$lines=file("$datadir/usersdat.php"); $record="\r\n"; $itogo=count($lines); $i=1; $regenter=FALSE;
do {$rdt=explode("|", $lines[$i]); // �������� �� ���� ������������� � ������� ������
if (isset($rdt[1])) { // ���� ������� ���������� � ������� (������ ������) - �� ������ � �� �������
$rdt[3]=strtolower($rdt[3]); $rdt[0]=strtolower($rdt[0]);
if ($myemail===$rdt[3] or $myname===$rdt[0]) {$regenter=TRUE; $myemail=$rdt[3]; $myname=$rdt[0]; $passmd5=md5("$pass"); $lines[$i]=str_replace("$rdt[1]","$passmd5",$lines[$i]);}
} //if isset
$record.=$lines[$i];
$i++; } while($i < $itogo);
// ����� IP-�������������� ������
$ip=""; $ip=(isset($_SERVER['REMOTE_ADDR']))?$_SERVER['REMOTE_ADDR']:0;
// ������������ ���� ���������� - ��������� ���� ����� ������
$fp=fopen("$datadir/usersdat.php","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
fputs($fp,"$record");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
// �������� ������������ ��� ����� � ������ �� ����
if ($regenter==TRUE) {
$headers=null; // ��������� ��� �������� �����
$headers.="From: ������������� <$adminemail>\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="Content-Type: text/plain; charset=windows-1251";
// �������� ��� ���������� � ���� ������
$allmsg=$fname.' (������ ��� �������������� ������� � ������)'.chr(13).chr(10).
'��, ���� ���-�� ������ � IP-������ '.$ip.' ��������� ������ ��� �������������� ������� � ������ �� ������: '.$furl.chr(13).chr(10).chr(13).chr(10).
'���� ���: '.$myname.chr(13).chr(10).
'��� ����� ������: '.$pass.chr(13).chr(10).chr(13).chr(10).
'��� ����� �� ����� ��������� �� ������ � ������� ����� � ����� ������: '.$furl.'?event=login'.chr(13).chr(10).chr(13).chr(10).
'�������� ��� ������ (������ ����� ���� ��� ������) ������ ����� �� ��������: '.$furl.'?event=profile&pname='.$myname.chr(13).chr(10).chr(13).chr(10).
'* ��� ������ ������������� �������, �������� �� ���� �� �����.'.chr(13).chr(10);
// ���������� ������ ������� �� �������� ;-)
mail("$myemail", "=?windows-1251?B?" . base64_encode("$fname (������ ��� �������������� ������� � ������)") . "?=", $allmsg, $headers);
// ���� ���� �������� � �������� �������
$msgtoopr="$myname , �� ��� ����������� ����� ������� ��������� � ������ � ������� ������� � ������.";
}
// ���� ��� ������ ������ � ��
else $msgtoopr="��������� � ����� ������� ��� ������� �� ������ �� ����������������! ";
print "
$msgtoopr ����� ��������� ������ �� ������ ������������� ���������� �� ������� ��������.
���� ����� �� ����������, ������� ����� .
";
exit; }
if ($_GET['event']=="moresmiles") { // ���������� ���� ������� �� ���������� SMILE
$lines=null; unset($lines); if (!is_dir("smile/")) exit("����� smile �� ����������.");
$i=0; if ($handle = opendir("smile/")) {
while (($file = readdir($handle)) !== false)
if (!is_dir($file)) {$lines[$i]=$file; $i++;}
closedir($handle);
}
if (!isset($lines)) exit("� ����� smile ��� �������! ���������� � ������ - ����� ������.");
$itogo=count($lines); $k=0; $text=null;
print"
�������������� ������ ";
do {
$rdt=explode(".",$lines[$k]);
if ($rdt[1]=="jpg" or $rdt[1]=="gif") {print" ";}
$k++;
} while ($k<$itogo);
exit("������� ���� P.S. �������������! ����� ����� ��������� ����� ������ - ������ ������� ����� ������ � ����� $forurl/smile/ ");}
// ----- ����� ��� ���� ������� ������
if (isset($_COOKIE['wrfcookies'])) {
$wrfc=$_COOKIE['wrfcookies']; $wrfc=htmlspecialchars($wrfc); $wrfc=stripslashes($wrfc);
$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);}}
else {unset($wrfname); unset($wrfpass);}
// -----
$frname=""; $frtname=""; include("$fskin/top.html"); addtop(); // ���������� ����� ������
if ($_GET['event'] =="deletemsg") { // �������� ������ ���������
if (!isset($_GET['username']) or !isset($_GET['id'])) exit("� ������ ������ ������ ID ���� � ��� ���������! ������� ������.");
$username=urldecode($_GET['username']); // ����������� ��� ������������, ��������� �� GET-�������.
$id=$_GET['id']; // �������� ������������� ����
$lines=file("$datadir/usersdat.php"); $i=count($lines); $mlines="0";
// ������� ��� � ������ � ����� � ������ � ������� � usersdat.php
do {$i--; $rdt=explode("|", $lines[$i]);
if (isset($rdt[1])) { // ���� ������� ���������� � ������� (������ ������) - �� ������ � �� �������
if ($username===$rdt[0]) {
if (isset($wrfname) & isset($wrfpass)) { $wrfname=replacer($wrfname); $wrfpass=replacer($wrfpass);
if ($wrfname===$rdt[0] & $wrfpass===$rdt[1]) {
$mlines=file("$datadir/$id.dat"); $maxi=count($mlines)-1;
$dt=explode("|",$mlines[$maxi]);
// ���� ��������� ��������� � ���� ������� ��� ���������� ����, �� ������� ��������� ���������
// ����� �������� ������ � ������ �� ������ �����
if ($dt[0]==$username and $dt[1]=="��" and $maxi>0) { unset($mlines[$maxi]); $maxi--;} else $mlines="0";
$i=1;
} } } }
} while($i > "1");
if ($mlines!="0") {
$fp=fopen("$datadir/$id.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);//������� ���������� �����
for ($i=0;$i<=$maxi;$i++) fputs($fp,$mlines[$i]);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
$rezult="���� ������� �������.";} else $rezult="�� ���� �������, ��� ��� ��� ������������ � ����! ";
print "
��������, $username , ���� ��������� $rezult ����� ��������� ������ �� ������ ������������� ���������� � ������� ����.
������ >>>
";
exit; }
if ($_GET['event']=="who") { // �������� ����������
// ���� ��������� - �� �������
if (!isset($_COOKIE['wrfcookies'])) exit("������ ��������� ��� ��������� ������ ������������� ���������� ������������������. $back
");
$t1="row1";
$alllines=file("$datadir/usersdat.php");
$allmaxi=count($alllines)-1; $i=1; $j=0; $flag=0;
if (isset($_GET['pol'])) $pol=replacer($_GET['pol']); else $pol="";
if (isset($_GET['interes'])) $interes=replacer($_GET['interes']); else $interes="";
if (isset($_GET['url'])) $url=replacer($_GET['url']); else $url="";
if (isset($_GET['from'])) $from=replacer($_GET['from']); else $from="";
if($pol!="" or $interes!="" or $url!="" or $from!="") {
do {$dt=explode("|", $alllines[$i]);
// ���� ���� ���������� � ������ - ����������� ����� �������� 1
if ($dt[6]!="" and $pol!="") {if (stristr($dt[6],$pol)) $flag=1;} // ���� ������ �� �����
if ($dt[10]!="" and $interes!="") {if (stristr($dt[10],$interes)) $flag=1;}
if ($dt[8]!="" and $url!="") {if (stristr($dt[8],$url)) $flag=1;}
if ($dt[9]!="" and $from!="") {if (stristr($dt[9],$from)) $flag=1;}
// ���� ���� ���� ���� ����������, �������� ��������� � ������ ����������
if ($flag==1) {$lines[$j]=$alllines[$i]; $flag=0; $j++;}
$i++;
} while($i<$allmaxi);
$fadd="&pol=$pol&interes=$interes&url=$url&from=$from";
} else {$fadd=""; $lines=$alllines;} // ���� ����� �� �����, ����� ����������� ������
if (!isset($lines)) $maxi=0; else $maxi=count($lines)-1;
print"
";
echo'';
if ($allmaxi=="0") {print"";
} else {
// ��������� ������ ������ �������������� ��������
if (!isset($_GET['page'])) $page=1; else { $page=$_GET['page']; if (!ctype_digit($page)) $page=1; if ($page<1) $page=1; }
$maxpage=ceil(($maxi+1)/$uq); if ($page>$maxpage) $page=$maxpage;
$fm=$uq*($page-1); if ($fm>$maxi) $fm=$maxi-$uq;
$lm=$fm+$uq; if ($lm>$maxi) $lm=$maxi+1;
if (isset($lines)) {
do {$dt=explode("|", $lines[$fm]);
$fm++; $num=$fm-1;
if (isset($dt[1])) { // ���� ������� �����, �� ������ � �� �������
$codename=urlencode($dt[0]); // �������� ��� � ����������, ��� ��������� ���������� �������� ����� ����� GET-������.
if (isset($wrfname)) {$wfn="$dt[0] ";
$mls=" ";} else {$wfn="$dt[0]"; $mls="�������������";}
if (strlen($dt[13])=="6" and ctype_digit($dt[13])) $dt[13]="�������� ��������� ";
if (strlen($dt[13])<2) $dt[13]=$users;
if ($dt[6]=="�������") $add="polm.gif"; else $add="polg.gif";
print"";
if ($t1=="row1") $t1="row2"; else $t1="row1";
} // ���� ������� ����������
} while($fm < $lm);
} // if isset($lines)
} // ����� ���� ���� userdat.php ����
echo'
�
���
������
�� �� �-����
�����������
���� ��������
��������
����
������
���������� �� ����������������
$num
$wfn
$dt[13]
$mls
$dt[4]
$dt[5]
$dt[10]
$dt[8]
$dt[9]
';
// ��������� ���������� $pageinfo - �� ������� �������
$pageinfo=""; $addpage=""; $maxpage=ceil(($maxi+1)/$uq); 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
����� ���������������� ���������� - $allmaxi
";}
if ($_GET['event'] =="profile") { // �������������� �������
if (!isset($_GET['pname'])) exit("������� ������.");
$pname=urldecode($_GET['pname']); // ����������� ��� ������������, ��������� �� GET-�������.
$lines=file("$datadir/usersdat.php"); $i = count($lines); $use="0"; $userpn="0";
do {$i--; $rdt=explode("|", $lines[$i]);
if (isset($rdt[1])) { // ���� ������� ���������� � ������� (������ ������) - �� ������ � �� �������
if (strlen($rdt[13])=="6" and ctype_digit($rdt[13])) $rdt[13]="�������� ��������� ";
if ($pname===$rdt[0]) { $userpn=$i;
// ��������� ���������� ���������/���� �����
$jfile="$datadir/userstat.dat"; $jlines=file("$jfile"); $uj=count($jlines)-1; $msjitogo=0;
for ($j=0;$j<=$uj;$j++) {$udt=explode("|",$jlines[$j]); $msjitogo=$msjitogo+$udt[2]; if ($udt[0]==$rdt[0]) {$msguser=$udt[2]; $temaded=$udt[1]; $repa=$udt[3];}}
$msgaktiv=round(10000*$msguser/$msjitogo)/100;
$akt=explode(".",$rdt[4]);
$aktiv=mktime(0,0,0,$akt[1],$akt[0],$akt[2]);
$tekdt=mktime(); $aktiv=round(($tekdt-$aktiv)/86400);
$aktiv=round(100*$msguser/$aktiv)/100;
if (isset($wrfname) & isset($wrfpass)) { $wrfname=replacer($wrfname); $wrfpass=replacer($wrfpass);
if ($wrfname===$rdt[0] & $wrfpass===$rdt[1]) {
print "��������������� ������
"; $use="1"; }
if ($use!="1") {
if (strlen($rdt[13])<2) $rdt[13]=$users;
if (is_file("avatars/$rdt[12]")) $avpr="$rdt[12]"; else $avpr="noavatar.gif";
print "������� ���������
��������������� ����������
��� ���������: $rdt[0]
���������: $repa [������� ± ]
����������: ��� �������: $temaded , ����� ���������: $msguser [$msgaktiv% �� ������ ����� / $aktiv ��������� � �����]
��������� ������ ��������� �� e-mail:
�������� ������������ ��������� (���� �� �����):
���� �����������: $rdt[4]
������: $rdt[13]
���: $rdt[6]
���� �������: $rdt[5]
����� � ICQ: $rdt[7]
�������� ���������: $rdt[8]
������ (����� ����������, �����, ������.): $rdt[9]
��������: $rdt[10]
�������: $rdt[11]
������:
"; $use="1";}
}
}
} // if
} while($i > "1");
if (!isset($wrfname)) exit("������ ������������������ ��������� ������ ����� ������������� ������ �������!");
if ($use!="1") { // � �� ������ ����� ��� - ��� ����� ������
print"
������������ �� ���������������
��������� ����������!
��������, �� �������� � ����� - ������� �� ������ �� ���������������.
������ �����, ��� ������ ������������� .
���������� ������ ���������� ����� ����� .
������� �� ������� �������� ������ ����� �� ���� ������
"; }
}
if ($_GET['event']=="reg") { // ���� ����������� ������������
if (!isset($_POST['okrules'])) {
echo'
������� � ������� �����������
';
} else {
print"����������� �� ������
';
}
}
if ($_GET['event']=="find") { // �����
$minfindme="3"; //����������� ���-�� �������� � ����� ��� ������
echo'