check_captcha($_POST['captcha'], $_POST['captcha_hash'])) $error[]="The security code was wrong!";
// prüfung username
$ergebnis = safe_query("SELECT * FROM ".PREFIX."user WHERE username = '$username' ");
$num = mysql_num_rows($ergebnis);
if($num) $error[]="username already in use!";
// prüfung mail
$ergebnis = safe_query("SELECT * FROM ".PREFIX."user WHERE email = '$mail' ");
$num = mysql_num_rows($ergebnis);
if($num) $error[]="mailadress already in use!";
// prüfung nickname
$ergebnis = safe_query("SELECT * FROM ".PREFIX."user WHERE nickname = '$nickname' ");
$num = mysql_num_rows($ergebnis);
if($num) $error[]="nickname already in use!";
if(!(strlen(trim($username)))) $error[]="you have to enter a username!";
elseif( strlen(trim($username)) > 30 ) $error[]="your username is too long! (max 30 chars)";
// prüfung passwort
if($pwd1 == $pwd2) {
if(!(strlen(trim($pwd1)))) $error[]="you have to enter a password!";
}
else $error[]="your repeated password is not valid!";
// prüfung e-mail
$sem = '^[a-z0-9_\.-]+@[a-z0-9_-]+\.[a-z0-9_\.-]+$';
if(!(eregi($sem, $mail))) $error[]="your e-mail is not valid!";
// prüfung nickname
if(!(strlen(trim($nickname)))) $error[]="you have to enter your nickname!";
if(is_array($error)) {
echo'There has been errors!
';
foreach($error as $err) {
echo'
'.$err.'
';
}
echo'
';
}
else {
// insert in db
$md5pwd = md5($pwd1);
$registerdate=time();
$activationkey = createkey(20);
safe_query("INSERT INTO `".PREFIX."user` (`registerdate`, `lastlogin`, `username`, `password`, `nickname`, `email`, `newsletter`, `activated`) VALUES ('$registerdate', '$registerdate', '$username', '$md5pwd', '$nickname', '$mail', '1', '".$activationkey."')");
$insertid = mysql_insert_id();
// insert in user_groups
safe_query("INSERT INTO ".PREFIX."user_groups ( userID ) values('$insertid' )");
// mail an user
$ToEmail = $mail;
$ToName = $username;
$header = "Account Information: ".PAGETITLE;
$Message = 'Hello '.$username.'!
Your registration was successful.
Your Username: '.$username.'
Your Passwort: '.$pwd1.'
To complete your registration please click on the following link:
http://'.$hp_url.'/index.php?site=register&key='.$activationkey.'
Thank you for registration
'.PAGETITLE.' - '.$hp_url;
if(mail($ToEmail,$header, $Message, "From:".$admin_email."\r\nX-Mailer: PHP/" . phpversion())) echo'Your registration has been successful, you will get an information-mail in seconds. You have to activate your account still by activation link from E-Mail. After that you can log in.';
else 'There was a problem while sending mail. Please contact the webmaster.';
}
}
elseif($_GET['key']) {
safe_query("UPDATE `".PREFIX."user` SET activated='1' WHERE activated='".$_GET['key']."'");
if(mysql_affected_rows()) redirect('index.php?site=login','Your account has been activated successfully. You are now able to login.');
else redirect('index.php?site=login','Your activation key ist wrong!');
}
else {
$bg1=BG_1;
$bg2=BG_2;
$bg3=BG_3;
$bg4=BG_4;
$CAPCLASS = new Captcha;
$captcha = $CAPCLASS->create_captcha();
$hash = $CAPCLASS->get_hash();
$CAPCLASS->clear_oldcaptcha();
eval ("\$register = \"".gettemplate("register")."\";");
echo $register;
}
?>