$act_key = trim($act_key); if (!preg_match('/^[a-z|A-Z|0-9]{32}$/', "{$act_key}")) { header("Location: no_such_key.html"); die; } #------------------------------------------------------------------------------------------------------------------------- #Open MySQL-DB $link = open_db(); #Has someone this activation key? $result = mysql_query("SELECT * FROM Yane WHERE activation_key = '{$act_key}'") or die(mysql_error()); #If no, show error if (mysql_num_rows($result) == 0) { mysql_close($link); header("Location: no_such_key.html"); die; } else { #Get mailaddress $result = mysql_query("SELECT email_address FROM Yane WHERE activation_key = '{$act_key}';") or die(mysql_error()); $row = mysql_fetch_assoc($result); #If yes, set activation-key to NULL mysql_query("UPDATE Yane SET activation_key = NULL WHERE CONVERT( activation_key USING utf8 ) = '{$act_key}'") or die(mysql_error()); mysql_close($link); # Log the correct login log_correct_login($row['email_address'], $_SERVER['REMOTE_ADDR']); # Set account modification-time log_change($row['email_address']); #------------------------------------------------------------------------------------------------------------------------- #Send mail #send_mail($row['email_address'], "activated", "http://newsletters.yacy-forum.de/activate"); header("Location: success.html"); }
} #------------------------------------------------------------------------------------------------------------------------- #If user doesn't exist: #Add new user #------------------------------------------------------------------------------------------------------------------------- add_user($mailaddress); #------------------------------------------------------------------------------------------------------------------------- #Set password #------------------------------------------------------------------------------------------------------------------------- update_PW($mailaddress, $plain_pw1); #------------------------------------------------------------------------------------------------------------------------- #Log time of last modification on dataset #------------------------------------------------------------------------------------------------------------------------- log_change($mailaddress); #------------------------------------------------------------------------------------------------------------------------- #Initialize the login values #------------------------------------------------------------------------------------------------------------------------- #Get the user's IP $ip = $_SERVER['REMOTE_ADDR']; log_correct_login($mailaddress, $ip); #------------------------------------------------------------------------------------------------------------------------- #Generate and save activation key #------------------------------------------------------------------------------------------------------------------------- $token = generate_activation_key($mailaddress); #------------------------------------------------------------------------------------------------------------------------- #If we didn't die() up to now, everything was successful #Send confirmation mail to user #send_mail($mailadresse, "register", "http://newsletters.yacy-forum.de/activate", $mailaddress, $ip, $token); #------------------------------------------------------------------------------------------------------------------------- #Show success header("Location: success.html");