if(!defined("IN_BC")){
header("Location: index.php?page=register");
}
switch($_REQUEST["function"]){
default;
startpage("Register");
?>
endpage();
break;
case "register";
if ($_POST["submitted"] == "yes"){
$fname = addslashes($_POST['fname']);
$lname = addslashes($_POST['lname']);
$uname = addslashes($_POST['uname']);
$pword = addslashes($_POST['pword']);
$cpword = addslashes($_POST['cpword']);
$emaill = addslashes($_POST['email']);
$squestion = addslashes($_POST['question']);
$sanswer = md5(strtolower($_POST['answer']));
if(!eregi("^[A-Za-z0-9]",$uname)){
Error("Incorrect information", "Improper username
Back");
} else {
if($pword != $cpword){
Error("Incorrect information", "Passwords do not match
Back");
} else {
$ip = getenv(REMOTE_ADDR);
$query = "SELECT * from users where username= '$uname'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if($num!=0){
Error("Incorrect information", "User with that name already exists!");
} else {
$md5pass = md5($pword);
$checksum = base64_encode("$uname|$time");
$sql = "INSERT INTO users VALUES('0', '$uname', '$fname', '$lname', '$emaill', '$md5pass', '-2','$ip','$time','$time','100','0','$squestion','$sanswer')";
$result = mysql_query($sql) or die(mysql_error());
mail($emaill,"Beyond Cooling - Register", "Hello $fname,\nWelcome to Beyond Cooling. Your details are as follows.\nUsername: $uname\nPassword: $pword\nPlease click this link to activate your account.\nhttp://beyond-cooling.com/?page=register&function=activate&checksum=$checksum\n\nKingsley.\nBeyond Cooling Owner - http://beyond-cooling.com","From: Beyond Cooling Accounts Manager ");
startpage("Register");
print "$uname, Your account has been created,
But is inactive, please follow the directions in the e-mail to activate your account.
If you're using hotmail, it is known that these e-mails are automaticly stored in junk. Please check your junk folder.";
endpage();
}
}
}
}
break;
case "activate";
$checksum = base64_decode($_REQUEST["checksum"]);
$check = explode("|",$checksum);
$user = addslashes($check[0]);
$time1 = addslashes($check[1]);
$checkaccount = mysql_num_rows(mysql_query("SELECT * from `users` where username='$user' and date_reg='$time1' and level='-2'"));
if($checkaccount==0){
Error("Invalid information", "There was an error activating your account. Please contact accounts@beyond-cooling.com");
} elseif($checkaccount==1){
mysql_query("UPDATE `users` set level='0' where username='$user'");
startpage("Activate account");
print "Your account has been activated $user! Feel free to login.";
endpage();
}
break;
case "resend";
print "Yet to add";
break;
}
?>