Файл: reg.php
Строк: 407
<?php
//error_reporting(2047|2048);
error_reporting(0);
ini_set('session.auto_start', 'Off');
ini_set('session.use_cookies', 'Off');
ini_set('session.gc_maxlifetime', '600');
ini_set('session.use_trans_sid', '0');
ini_set('url_rewriter.tags', '0');
include 'config.php';
class_exists('config') or die('Error load config class');
if(isset($_GET['i'])){
$sid = trim($_GET['i']);
session_id($sid);
session_start();
if(!isset($_SESSION['code'])){
session_destroy();
$code = 'error';
}
else $code = $_SESSION['code'];
$img = imagecreate(48, 20);
$black = imagecolorallocate($img, 0, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
imagefilledrectangle($img, 1, 1, 46, 18, $white);
imagestring($img, 5, 2, 2, $code, $black);
new config(0, 0, 1);
header('Content-type: image/gif');
imagegif($img);
imagedestroy($img);
exit();
}
$config = new config(1, 1, 1);
$lang = $config->parse_lang() or die('Error parse lang file');
$config->start('reg', $lang['1004']);
if(isset($_GET['ref'])) $ref = intval($_GET['ref']);
else if(isset($_POST['ref'])) $ref = intval($_POST['ref']);
else $ref = 0;
if($ref < 0 || $ref > 999999999) $ref = 0;
if($config->conf['ref'] != 'on') $ref = 0;
if(@$_GET['r'] != 'yes' && @$_POST['r'] != 'yes'){
if($config->vers == 'wml') echo '<small>';
echo $lang['1030'].
'<a href="reg.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'&r=yes">'.$lang['1028'].'</a><br/>'.
'<a href="index.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'">'.$lang['1027'].'</a>';
if($config->vers == 'wml') echo '</small>';
$config->finish(true);
}
if($config->conf['reg'] !== 'on'){
if($config->vers == 'wml'){
print '<b>'.$lang['1035'].'</b><br/>';
}
else
if($config->vers == 'html'){
print '<font color="'.$config->color['error'].'">'.$lang['1035'].'</font><br/>';
}
print '<a href="index.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'">'.$lang['1003'].'</a>';
mysql_close($mysql); $config->finish(true);
}
if(!isset($_POST['s'])){
session_start();
$sid = session_id();
$code = mt_rand(10000, 99999);
$rand = mt_rand(10000, 99999);
$_SESSION['time'] = time();
$_SESSION['code'] = $code;
$_SESSION['rand'] = $rand;
if($config->vers == 'wml')
echo '<small>'.$lang['1036'].':</small><br/>'.
'<input type="text" name="site'.$rand.'" value="http://" maxlength="150"/><br/>'.
'<small>'.$lang['1033'].':</small><br/>'.
'<input type="text" name="mail'.$rand.'" value="" maxlength="150"/><br/>'.
'<small>'.$lang['1249'].':</small><br/>'.
'<input type="text" name="wmr'.$rand.'" value="" maxlength="150"/><br/>'.
'<small>'.$lang['1021'].':</small><br/>'.
'<input type="password" name="pass'.$rand.'" value="" maxlength="150"/><br/>'.
'<small>'.$lang['1034'].':</small><br/>'.
'<img src="reg.php?i='.$sid.'" alt=""/>'.
'<input type="text" name="code'.$rand.'" value="" maxlength="5" format="*N" size="5"/><br/><br/>'.
'<small><anchor>'.$lang['1028'].'<go href="reg.php" method="post">'.
'<postfield name="l" value="'.$config->lang.'"/>'.
'<postfield name="v" value="wml"/>'.
'<postfield name="ref" value="'.$ref.'"/>'.
'<postfield name="r" value="yes"/>'.
'<postfield name="s" value="'.$sid.'"/>'.
'<postfield name="site'.$rand.'" value="$(site'.$rand.')"/>'.
'<postfield name="wmr'.$rand.'" value="$(mail'.$rand.')"/>'.
'<postfield name="mail'.$rand.'" value="$(wmr'.$rand.')"/>'.
'<postfield name="pass'.$rand.'" value="$(pass'.$rand.')"/>'.
'<postfield name="code'.$rand.'" value="$(code'.$rand.')"/>'.
'</go></anchor><br/>'.
'<a href="index.php?l='.$config->lang.'&v=wml&ref='.$ref.'">'.$lang['1027'].'</a></small>';
else
if($config->vers == 'html')
echo '
<form action="reg.php" method="post">'.
'<input type="hidden" name="l" value="'.$config->lang.'"/>'.
'<input type="hidden" name="v" value="html"/>'.
'<input type="hidden" name="r" value="yes"/>'.
'<input type="hidden" name="ref" value="'.$ref.'"/>'.
'<input type="hidden" name="s" value="'.$sid.'"/>'.
$lang['2w'].'<br/>'.
'<font collor="red">* </font>'.
$lang['1036'].':<br/>'.
'<input type="text" name="site'.$rand.'" value="http://" maxlength="150"/><br/><font collor="red">* </font>'.
$lang['1033'].':<br/>'.
'<input type="text" name="mail'.$rand.'" value="" maxlength="150"/><br/><font collor="red">* </font>'.
$lang['1249'].':<br/>'.
'<input type="text" name="wmr'.$rand.'" value="R" maxlength="150"/><br/><font collor="red">* </font>'.
$lang['1021'].':<br/>'.
'<input type="password" name="pass'.$rand.'" value="" maxlength="150"/><br/>'.
'<img src="reg.php?i='.$sid.'" alt=""/><br/><font collor="red">* </font>'.
$lang['1034'].':<br/>'.
'<input type="text" name="code'.$rand.'" value="" maxlength="5" size="5"/><br/><br/>'.
'<input type="submit" value="'.$lang['1028'].'"/><br/>'.
'<a href="index.php?l='.$config->lang.'&v=html&ref='.$ref.'">'.$lang['1027'].'</a>'.
'</form>';
$config->finish(true);
}
$sid = trim($_POST['s']);
session_id($sid);
session_start();
session_destroy();
$error = false;
$rand = @$_SESSION['rand'];
if(!isset($_SESSION['rand'])) $error = $lang['1031'];
else if($_SESSION['time'] == time()) $error = $lang['1032'];
else if(!$_POST['site'.$rand]) $error = $lang['1039'];
else if(!$_POST['wmr'.$rand]) $error = $lang['1050'];
else if(!$_POST['mail'.$rand]) $error = $lang['1041'];
else if(!$_POST['pass'.$rand]) $error = $lang['1043'];
else if(!$_POST['code'.$rand]) $error = $lang['1037'];
else if($_POST['code'.$rand] != $_SESSION['code']) $error = $lang['1038'];
else{
if(!$mysql = mysql_connect($config->mysql['host'], $config->mysql['user'], $config->mysql['pass'])){
if($config->vers == 'wml'){
print '<b>'.$lang['1014'].'! '.$lang['1010'].'</b><br/>';
}
else
if($config->vers == 'html'){
print '<font color="'.$config->color['error'].'">'.$lang['1014'].'! '.$lang['1010'].'</font><br/>';
}
print $lang['1015'].' MySQL: <u>'.mysql_error().'</u><br/>';
print '<a href="index.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'">'.$lang['1003'].'</a>';
$config->finish(true);
}
if(!mysql_select_db($config->mysql['db'], $mysql)){
if($config->vers == 'wml'){
print '<b>'.$lang['1014'].'! '.$lang['1011'].'</b><br/>';
}
else
if($config->vers == 'html'){
print '<font color="'.$config->color['error'].'">'.$lang['1014'].'! '.$lang['1011'].'</font><br/>';
}
print $lang['1015'].' MySQL: <u>'.mysql_error().'</u><br/>';
print '<a href="index.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'">'.$lang['1003'].'</a>';
mysql_close($mysql); $config->finish(true);
}
$site = trim($_POST['site'.$rand]);
$mail = trim($_POST['mail'.$rand]);
$wmr = trim($_POST['wmr'.$rand]);
$pass = trim($_POST['pass'.$rand]);
if($site == 'http://') $error = $lang['1040'];
else if(strlen($site) > 150) $error = $lang['1040'];
else if(strlen($mail) > 150) $error = $lang['1050'];
else if(strlen($wmr) > 150) $error = $lang['1042'];
else if(strlen($pass) > 150) $error = $lang['1044'];
else if(!preg_match('/^(?:http://)?((?:[-a-z0-9_]+.)*(?:info|mobi|name|biz|com|net|org|ae|au|az|be|br|by|bz|ca|cc|ch|cn|cz|de|dk|do|ee|eo|es|eu|fi|fr|hu|il|in|iz|jp|kg|kr|kz|lt|lv|mn|mx|nl|no|nz|pl|ro|ru|si|sk|su|tv|tw|ua|uk|us|uz|ws|yu|za)).?(?::d+)?(?:(?:/|?)(?:.*?))?$/i', $site, $site)) $error = $lang['1040'];
else if(!preg_match('/^([-a-z0-9_.]+)@((?:[-a-z0-9_]+.)*(?:info|mobi|name|biz|com|net|org|ae|au|az|be|br|by|bz|ca|cc|ch|cn|cz|de|dk|do|ee|eo|es|eu|fi|fr|hu|il|in|iz|jp|kg|kr|kz|lt|lv|mn|mx|nl|no|nz|pl|ro|ru|si|sk|su|tv|tw|ua|uk|us|uz|ws|yu|za)).?$/i', $mail, $mail)) $error = $lang['1042'];
else if(!preg_match('/^([-a-z0-9_.]+)$/i', $pass)) $error = $lang['1044'];
else{
$site = strtolower($site['1']);
$mail = strtolower($mail['1'].'@'.$mail['2']);
$q = mysql_query("SELECT `id` FROM `users` WHERE `site` = '$site';", $mysql);
$n = mysql_num_rows($q);
if($n > 0){
$error = $lang['1045'];
if($n == 1){
$q = mysql_fetch_array($q);
$error .= ' [id:'.$q['id'].']';
}
}
}
}
if($error){
if($config->vers == 'wml')
echo '<b>'.$lang['1014'].'!</b> '.$error.'<br/><br/>';
else
if($config->vers == 'html')
echo '<font color="'.$config->color['error'].'">'.$lang['1014'].'!</font> '.$error.'<br/><br/>';
echo '<a href="reg.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'&r=yes">'.$lang['1029'].'</a><br/>'.
'<a href="index.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'">'.$lang['1003'].'</a>';
mysql_close($mysql); $config->finish(true);
}
if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
if(!isset($_SERVER['HTTP_USER_AGENT'])) $_SERVER['HTTP_USER_AGENT'] = 'Unknown';
$ip = addslashes($_SERVER['REMOTE_ADDR']);
$ua = addslashes($_SERVER['HTTP_USER_AGENT']);
if(strlen($ip) > 15) $ip = substr($ip, 0, 15);
if(strlen($ua) > 200) $ua = substr($ua, 0, 200);
if($config->conf['mod_user'] == 'off'){ $status = 3; }else{ $status = 1; }
$q = mysql_query("INSERT INTO `users` VALUES('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '$ref', '', '$site', '$mail', '$pass', '$ip|$ua', '".time()."', '0', '0', '0', '0', '0', '0', '1', '1', '1', '$status', '$wmr');", $mysql);
$id = mysql_insert_id($mysql);
if(!$id){
if($config->vers == 'wml')
echo '<b>'.$lang['1014'].'!</b><br/>';
else
if($config->vers == 'html')
echo '<font color="'.$config->color['error'].'">'.$lang['1014'].'!</font><br/>';
echo $lang['1015'].' MySQL: <u>'.mysql_error().'</u><br/><br/>'.
'<a href="index.php?l='.$config->lang.'&v='.$config->vers.'&ref='.$ref.'">'.$lang['1003'].'</a>';
mysql_close($mysql); $config->finish(true);
}
$subj = $lang['1047'].' '.$config->site;
$subj = convert_cyr_string($subj, 'w', 'k');
$subj = base64_encode($subj);
$subj = '=?koi8-r?B?'.$subj.'?=';
$head = 'From: '.$config->site.' <'.$config->mail.'>'."n".
'Reply-To: <wap@wml.su>'."n".
'Content-Type: text/plain; charset=windows-1251'."n".
'MIME-Version: 1.0';
$mess = $lang['1048'].' '.$config->site."rn".
$lang['1020'].': '.$id."rn".
$lang['1021'].': '.$pass."rn".
$lang['1249'].': '.$wmr."rn".
$lang['1049'].': http://'.$config->site.'/panel.php?id='.$id.'&ps='.$pass."rnrn".
$lang['1050'].' '.$site."rn".
$lang['1051'].': <a href="http://'.$config->site.'/c.php?'.$id.'"><img src="http://'.$config->site.'/b.php?'.$id.'" alt="'.$config->site.'"/></a>'."rn".
$lang['1052'].': <a href="http://'.$config->site.'/t.php?'.$id.'">'.$lang['1055'].'</a>';
mail($mail, $subj, $mess, $head);
if($config->vers == 'wml') print '<small>';
echo '<u>'.$lang['1046'].'</u><br/>'.
$lang['1020'].': <u>'.$id.'</u><br/>'.
$lang['1021'].': <u>'.$pass.'</u><br/>'.
$lang['1249'].': <u>'.$wmr.'</u><br/>'.
$lang['1053'].' <u>'.$mail.'</u><br/><br/>'.
'<a href="panel.php?l='.$config->lang.'&v='.$config->vers.'&id='.$id.'&ps='.$pass.'">'.$lang['1009'].'</a><br/>'.
'<a href="index.php?l='.$config->lang.'&v='.$config->vers.'">'.$lang['1003'].'</a><br/>';
if($config->vers == 'wml') print '</small>';
mysql_close($mysql); $config->finish();
?>