include('site_vars.inc.php');
$session_force=false;
$is_home=false;
$is_index=false;
$title="Sign Up";
include($db_location);
session_start();
include($header_location);
/*
https://www.google.com/recaptcha/admin/site/351153485/setup
linkreef.com recaptcha
site key - 6LdNLe4UAAAAAF7gbHT4_VdxtUpAlGJpMS9qw1C-
secret key - 6LdNLe4UAAAAAIV4ri-js6wV6JooDPvL2V_GrglK
backend - https://developers.google.com/recaptcha/docs/verify
frontend - https://developers.google.com/recaptcha/docs/v3
*/
?>
$error_count = -1;
$username = trim($username);
$email = trim($email);
if ($addnew == "yes") {
$error_count = 0;
function reCaptcha_isValid()
{
try
{
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array('secret' => '6LdNLe4UAAAAAIV4ri-js6wV6JooDPvL2V_GrglK', 'response' => $_POST['g-recaptcha-response'], 'remoteip' => $_SERVER['REMOTE_ADDR']);
$options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data) ) );
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return json_decode($result)->success;
}
catch (Exception $e) {
return null;
}
}
if (reCaptcha_isValid()) {
//continue on!
} else {
//$main->error("Wrong verification code! Try Again...");
print "
Error: Wrong verification code! Try Again...";
$error_count = 1;
}
if ($error_count == 0) {
$result = mysql_query ("SELECT id FROM users WHERE email = '".addslashes($email)."' ");
$row = mysql_fetch_array($result);
if ($row["id"] != "") {
print "
Error: E-mail address already registered";
$error_count = 1;
}
$result = mysql_query ("SELECT id FROM users WHERE username = '".addslashes($username)."' ");
$row = mysql_fetch_array($result);
if ($row["id"] != "") {
print "
Error: User Name already registered";
$error_count = 1;
}
}
if ($error_count == 0) {
if (!(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))) {
print "
Error: Invalid E-mail Address";
} elseif (strlen($username) < 3) {
print "
Error: Your user name must be at least 3 characters";
} else {
$userpass = trim($userpass);//createpass() is for setting it for them and making them verify email and change pass when they come back
$cryptpass = cryptpass($userpass);
//email user
$phpmailto = $email;
$phpmailfrom = "noreturn@".$site_domain;
$phpmailfromname = $site_name;
$phpmailsubject = $site_name." Confirmation";
$phpmailbody = "Thank you for registering for ".$site_domain.".\n\nYour login is your username: $username\nYour password is: $userpass\n\nClick to login: http://www.".$site_domain."/\n\n-".$site_domain." Staff";//login-done.php?username=$username&userpass=$userpass not when change isnt forced
$phpmailsend = "
$site_name Registration SuccessfulYou may
start now.";
$phpmailerror = "Error: There was an error sending the e-mail message to $phpmailto , account not created";
if (mail($phpmailto, $phpmailsubject, $phpmailbody, "From: \"$phpmailfromname\" <$phpmailfrom>")) {
print $phpmailsend;
} else {
print $phpmailerror;
exit;
}
//add user - putting lastlogin in here to bypass forced password change in login-done.php page
mysql_query("INSERT INTO users (username, email, cryptpass, acctstatus, createDate, lastlogin) VALUES ('".addslashes($username)."','".addslashes($email)."','".addslashes($cryptpass)."','emailed', '". date("Y-m-d H:i:s") ."', '". date("Y-m-d H:i:s") ."')");
$id = mysql_insert_id();
// SET SESSION VARIABLES TOO
$_SESSION["userlogin"] = $email;
$_SESSION["usercrypt"] = $cryptpass;
$_SESSION["name"] = $username;
$_SESSION["password"] = $email;
$_SESSION["id"] = $id;
if ($remember == "yes") {
setcookie("userinfo1",$userlogin,time()+31536000);
setcookie("userinfo2",$usercrypt,time()+31536000);
setcookie("name",$name,time()+31536000);
setcookie("password",$password,time()+31536000);
setcookie("id",$id,time()+31536000);
}
//die;// TAKE THIS OUT, ENABLE THE FOOTER TO SHOW
}
}//end err = 0
} // end add new
if ($error_count != 0) {
?>
}
function createpass() {
$min=8; // minimum length of password
$max=12; // maximum length of password
$userpass=""; // to store generated password
for($i=0;$i