View file registration.php

File size: 8.89Kb
<?php

require_once"./includes/functions/gzip.php";

list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;

$configs = file("configs.dat");
$reg_status = $configs[0];
$computer = $configs[2];
$img = $configs[3];
$reg_acti = $configs[4];

if(isset($_POST['action']))
{
session_id("".$_POST['sid']."");
session_start();
}
else
{
session_start();
$number = rand(1000, 9999);
$_SESSION['code'] = $number;
}

error_reporting(0);

include("config.php");
include("./includes/constants/registration");
include("./includes/".$ver."/banned");

$nocache = rand(1000, 9999);
$mobile = strtok(getenv('HTTP_USER_AGENT'), "/");
$ip = getenv('REMOTE_ADDR');
$ua = mysql_escape_string(htmlspecialchars(getenv('HTTP_USER_AGENT')));

switch($ver)
{
case 'wml':
///////////////////////////////////////////////////////
//WML VERSION
///////////////////////////////////////////////////////

echo "Removed Bcoz Some Mom Fucking PPl Were Using It";
break;

case 'html':
///////////////////////////////////////////////////////
//HTML VERSION
///////////////////////////////////////////////////////

$my_title = "Register";
if(!isset($_COOKIE['theme'])) $_COOKIE['theme'] = 1;
include_once "themes/".intval($_COOKIE['theme'])."/index.php";

if($reg_status == 0)
{
echo "Registration is temporarily closed.<br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
exit();
}

if($reg_acti == 1)
{
echo "I Hate OverSmart Ppl....Get Lost From Here.U Mom Fucker Otherwise I Have To kick ur ass out.<br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
exit();
}

$q = mysql_query("SELECT `id` FROM `chat_users` WHERE `ip` = '".$ip."';");
$prot = mysql_result($q,0);

if ($prot > 0)
{
echo "There Is Already A ID Registersed With This IP.You Cannot Register New.";
break;
}

if(((strpos($ua, "Opera") !== false) or (strpos($ua, "Mozilla") !== false) or (strpos($ua, "MSIE") !== false)  or (strpos($ua, "Netscape") !== false)) && $computer == 1)
{
echo "Registration with the computer is prohibited.<br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
exit();
}

echo "<!-- Registration -->\n";
if(!isset($_POST['action']))
{
echo "<form action=\"registration.php?ver=html&amp;nocache=$nocache\" method=\"post\">\n";
echo "Desired Nick*:<br/>\n";
echo "<input type=\"text\" name=\"nickname\" maxlength=\"15\"/><br/>\n";
echo "Password*:<br/>\n";
echo "<input type=\"text\" name=\"password\" maxlength=\"20\"/><br/>\n";
echo "Name:<br/>\n";
echo "<input type=\"text\" name=\"name\" maxlength=\"15\"/><br/>\n";
echo "Gender:<br/>\n";
echo "<select name=\"sex\">\n";
echo "<option value=\"0\" selected=\"selected\">Male</option>\n";
echo "<option value=\"1\">Female</option>\n";
echo "<option value=\"2\">Unknown :)</option>\n";
echo "</select><br/>\n";
echo "Date of Birth:<br/>";
echo "<input type=\"text\" name=\"day\" format=\"*N\" maxlength=\"2\" size=\"2\"/>-\n";
echo "<input type=\"text\" name=\"month\" format=\"*N\" maxlength=\"2\" size=\"2\"/>-\n";
echo "<input type=\"text\" name=\"year\" format=\"*N\" maxlength=\"4\" size=\"4\"/><br/>\n";
/*echo "Location:<br/>\n";
echo "<input type=\"text\" name=\"from\" maxlength=\"20\"/><br/>\n";
echo "Mobile:<br/>\n";
echo "<input type=\"text\" name=\"mobile\" maxlength=\"20\" value=\"$mobile\"/><br/>\n";
echo "eMail:<br/>\n";
echo "<input type=\"text\" name=\"email\" maxlength=\"30\"/><br/>\n";
echo "Сайт:<br/>\n";
echo "<input type=\"text\" name=\"site\" maxlength=\"50\" value=\"http://\"/><br/>\n";
echo "About:<br/>\n";
echo "<input type=\"text\" name=\"about\" maxlength=\"250\"/><br/>\n";*/
if($img == 1){
echo "<img src=\"img.php?sid=".session_id()."\" alt=\"kartinka\"/><br/>\n";
echo "Enter Above Words:<br/>\n";
echo "<input type=\"text\" name=\"ref\" maxlength=\"4\" value=\"\"/><br/>\n";
}
echo "<input type=\"hidden\" name=\"number\" value=\"$number\" />\n";
echo "<input type=\"hidden\" name=\"sid\" value=\"".session_id()."\" />\n";
echo "<input type=\"hidden\" name=\"action\" value=\"registration\" />\n";
echo "<input type=\"submit\" value=\"Register\" /></form>\n";
echo "<a href=\"rules.php?ver=html&amp;action=registration&amp;nocache=$nocache\">Rules</a><br/>\n";
echo "<a href=\"index.php?ver=html&amp;nocache=$nocache\">Index</a><br/><br/>\n";
}
else
{
$nickname = trim(htmlspecialchars(mysql_escape_string($_POST['nickname'])));
$nickname = str_replace('$', '$$', $nickname);
$password = trim(htmlspecialchars(mysql_escape_string($_POST['password'])));
$name = trim(htmlspecialchars(mysql_escape_string($_POST['name'])));
$name = str_replace('$', '$$', $name);
$sex = intval($_POST['sex']);
if($sex != 0 && $sex != 1) $sex = 2;
$day = substr(intval($_POST['day']), 0, 2);
$month = substr(intval($_POST['month']), 0, 2);
$year = substr(intval($_POST['year']), 0, 4);
$birthday = "$day-$month-$year";
$from = trim(htmlspecialchars(mysql_escape_string($_POST['from'])));
$from = str_replace('$', '$$', $from);
$mobile = trim(htmlspecialchars(mysql_escape_string($_POST['mobile'])));
$mobile = str_replace('$', '$$', $mobile);
$email = trim(htmlspecialchars(mysql_escape_string($_POST['email'])));
$email = str_replace('$', '$$', $email);
$site = strtolower(trim(htmlspecialchars(mysql_escape_string($_POST['site']))));
$site = str_replace('http://', '', $site);
$site = str_replace('$', '$$', $site);
$about = trim(htmlspecialchars(mysql_escape_string($_POST['about'])));
$about = str_replace('$', '$$', $about);
$number = intval($_POST['number']);

$error = "";
if(($img == 1) && ($_POST['ref'] != $_SESSION['ref'])) $error .= "ne pravilnoe 4islo!<br/>\n";
if($number != $_SESSION['code']) $error .= BAD_SID."<br/>\n";
if(empty($nickname)) $error .= "Do not put nickname!<br/>\n";
if(empty($password)) $error .= "Do not put password!<br/>\n";
if(strlen($nickname) > 25) $error .= "too big nickname!<br/>\n";
if(strlen($password) > 20) $error .= "too big password!<br/>\n";      
if((preg_match("/[^A-Za-z1-9\@\*\(\)\?\!\-\~\_\[\]\=]+/",$nickname))&&(!preg_match("!^[@\\*\\)\\(\\?\\!\\-_\\]\\|\\[=~]+$!i",$bak))) $error .= "Nickname contains illegal characters<br/>\n";

if(preg_match("/[^0-9a-zA-Z_]+/",$password)) $error .= "Password contains illegal characters!<br/>\n";
if(!empty($email))
{
	if (!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $email)) $error .= "not valid email!<br/>\n";
}

	if(!empty($error))
	{
	echo $error;
	echo "<a href=\"registration.php?ver=html&amp;nocache=$nocache\">Register</a><br/><br/>\n";
	include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
	session_destroy();
	exit();
	}

$q = mysql_query("SELECT `id` FROM `chat_users` WHERE `nickname` = '".$nickname."';");

	if(mysql_num_rows($q) != 0)
	{
	echo "<b>".$nickname."</b> already exist.<br/>\n";
	echo "<a href=\"registration.php?ver=html&amp;nocache=$nocache\">Register</a><br/><br/>\n";
	include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
	session_destroy();
	exit();
	}

$q = mysql_query("SELECT * FROM `chat_banned_nicknames` WHERE `nickname` = '".$nickname."';");

	if(mysql_affected_rows() != 0)
	{
	echo "<b>".$nickname."</b> Cnt register!<br/>\n";
	echo "<a href=\"registration.php?ver=html&amp;nocache=$nocache\">Register</a><br/><br/>\n";
	include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
	session_destroy();
	exit();
	}

$registration = mysql_query("INSERT INTO `chat_users` SET `nickname` = '".$nickname."', `password` = '".md5($password)."', `pwd` = '".$password."', `status` = 'Newbie', `name` = '".$name."', `sex` = ".$sex.", `birthday` = '".$birthday."', `from` = '".$from."', `mobile` = '".$mobile."', `email` = '".$email."', `site` = '".$site."', `about` = '".$about."', `ip` = '".$ip."', `ua` = '".$ua."', `time` = ".time().", `key` = '', `regdate` = '".date('d-m-y')."';");

	if($registration)
	{
// mail it 
$message = "Hello,$nickname,Thank You For Signing Up In Chatsoon.Org.
this is your password: $password .
Hope You Like Our Site."; 
$from = "admin@Chatsoon.Org";
$subject = "Thank You For Sign Up";
$headers = "From: Jack || ".$from." "  ;
$check = mail($email,$subject,$message,$headers);
if($check){ 
echo "Login details mailed to $email<br/>";}
	$id = mysql_insert_id();
	mysql_query("INSERT INTO `chat_letters` VALUES(0, '".$id."', '".$id."', 1, '".LETTER_TITLE."', '".LETTER_BODY."', '".date("d-m-Y")."', '".time()."', 0);");
        $id = mysql_insert_id();
	echo REGISTRATION_SUCCESS."<br/>\n";
	echo "Nick: <u>".$nickname."</u><br/>\n";
	echo "Password: <u>".$password."</u><br/>\n";
	echo "<br/><form action=\"menu.php?ver=html&amp;nocache=$nocache\" method=\"post\">\n";
	echo "<input type=\"hidden\" name=\"password\" value=\"$password\" />\n";
	echo "<input type=\"hidden\" name=\"nickname\" value=\"$nickname\" />\n";
	echo "<input type=\"hidden\" name=\"action\" value=\"auth\" />\n";
	echo "<input type=\"submit\" value=\"Continue\" /></form>\n";
	echo "<a href=\"index.php?ver=html&amp;nocache=$nocache\">Index</a><br/><br/>\n";
	}
	else
	{
	echo REGISTRATION_ERROR."<br/>\n";
	echo mysql_error()."<br/>\n";
	}
session_destroy();
}
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
break;
}
?>