Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("dbcon.php");
- function reg($newname,$email,$newpass,$newpassagain){
- if(isset($newname)) {
- $username = isset($newname) && is_string($newname) ? stripslashes($newname) : '';
- $loginname = mysql_real_escape_string($username);
- $signuptime = time();
- $password = (isset($newpass) && is_string($newpass)) ? stripslashes($newpass) : '';
- $password2 = (isset($newpassagain) && is_string($newpassagain)) ? stripslashes($newpassagain) : '';
- if(!isset($email) || !valid_email(stripslashes($email))) {
- echo '<div class="alert alert-danger text-center">Sorry, the email is invalid.<br /></div>';
- }
- $pass = mysql_real_escape_string($password);
- $email = mysql_real_escape_string(stripslashes($email));
- $email2 = mysql_real_escape_string(stripslashes($_POST['email2']));
- if(!isset($_POST['gender']) || ($_POST['gender'] != 'Male' && $_POST['gender'] != 'Female')) {
- echo '<div class="alert alert-danger text-center">Sorry, the gender is invalid.<br /></div>';
- }
- $gender = mysql_real_escape_string(stripslashes($_POST['gender']));
- $activation = md5(uniqid(rand(),true));
- $checkuser = mysql_query("SELECT `id`,`loginame`,`password` FROM `grpgusers` WHERE `loginame` = '{$loginname}'");
- $username_exist = mysql_num_rows($checkuser);
- if($username_exist > 0) {
- $message = "<div>I'm sorry but the username you chose has already been taken. Please pick another one.</div>";
- $newname = "";
- }
- if(!preg_match("/^[a-zA-Z0-9]+$/", $username)) {
- $message = "<div>You can only use letters and numbers for your username.</div>";
- $newname = "";
- }
- if($_POST['tos'] != "agree")
- $message = "<div>You haven't agreed to the Terms of Service.</div>";
- if(strlen($username) < 4 or strlen($username) > 20) {
- $message = "<div>The username you chose has " . strlen($username) . " characters. You need to have between 4 and 20 characters.</div>";
- $newname = "";
- }
- if(strlen($password) < 6 or strlen($username) > 20)
- $message = "<div>The password you chose has " . strlen($password) . " characters. You need to have between 6 and 20 characters.</div>";
- if($password != $password2)
- $message = "<div>Your passwords don't match. Please try again.</div>";
- if($email != $email2) {
- $message = "<div>Your emails don't match. Please try again.</div>";
- $email = "";
- $_POST['email2'] = "";
- }
- $IP = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
- $checkip = mysql_query("SELECT `ip`,`signupip` FROM `grpgusers` WHERE `signupip` = '$IP' OR `ip` = '$IP'");
- $ip_exist = mysql_num_rows($checkip);
- /*if($ip_exist > 0) {
- $message = "You already have an account here on silent-mafia! If you think this may be an error or would like somebody else in the family
- on the same IP as you to play then please <a href='contact.php' />contact</a> an admin.";
- }*/
- $checkemail = mysql_query("SELECT `email` FROM `grpgusers` WHERE `email` = '".$email."'");
- $email_exist = mysql_num_rows($checkemail);
- if($email_exist > 0) {
- $message = "That email is already being used for an account on CrimeCity.";
- $email = "";
- }
- if(!isset($message)) {
- mysql_query("INSERT INTO `grpgusers` (`signupip`,`username`,`password`,`email`,`signuptime`,`loginame`,`gender`,`activate`)
- VALUES ('".$IP."','".$loginname."',md5('$pass'),'".$email."','$signuptime','".$loginname."','".$gender."','$activation')");
- echo Message('Your account has been created successfully!
- Before you can login, you will need to activate your account using the email you signed up with.
- Remember to check your junk/spam folder as it may be been mistaken.');
- mail($email, "{$set['gamename']} RPG Activation","Hello and thank you for registering at {$set['gamename']}.
- You must activate your account by clicking the link or coping the code and paste in browser link:
- {$set['gamelink']}/activate.php?a={$activation}",$headers);
- $from = "noreply@{$set['gamelink']}";
- $to = $email;
- $subject = "{$set['gamename']}: Activate Account";
- $body = "Thank you for registering at {$set['gamename']}.
- Please click on the link below to activate your account. \n\n
- {$set['gamelink']}/activate.php?a=".$activation."\n\n
- Thankyou,\n\nThe {$set['gamename']} Team.";
- $headers = "MIME-Version: 1.0\r\n";
- $headers .= "Content-type:text/html;charset=iso-8859-1\r\n";
- $headers .= 'From: '.$from."\r\n".'Reply-To: '.$from."\r\n".'X-Mailer: PHP/' . phpversion();
- if(!empty($_POST['referer'])) {
- $_POST['referer'] = isset($_POST['referer']) && ctype_digit($_POST['referer']) ? abs(intval($_POST['referer'])) : 0;
- $result12 = mysql_query("SELECT `id` FROM `grpgusers` WHERE `loginame` = '".$loginname."'");
- $worked12 = mysql_fetch_array($result12);
- mysql_query("INSERT INTO `referrals` (`when`, `referrer`, `referred`)
- VALUES ('$signuptime','".$_POST['referer']."', '".$worked12['id']."')");
- }
- }
- }
- if(isset($message))
- echo '<div class="alert alert-danger text-center">'.$message.'</div>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement