I use an auto registration module on one of my Nuke sites because AOL keeps blocking emails intermittently thus people can not click the confirmation link to register. The problem is that some people are using bad email addresses.
I want to modify the code below so it sends a welcome email with the username and password when using the auto registration option. This way I can see if the message bounces back, and why, to decide if the person gave a bad email or if the email was just blocked.
I tried including part of the code that is used for the normal registration after the auto registration to produce an email (see the code at the bottom) but gave up as I could not get it to work.
Here is the code if anyone can help. Send a PM or post if you need to see the rest of the code, I just included the part I thought it involved.
Thanks
Code:
function confirmNewUser($username, $user_email, $user_password, $user_password2, $random_num, $gfx_check) {
global $stop, $EditedMessage, $sitename, $module_name, $minpass, $autoActivate;
include("header.php");
include("config.php");
filter_text($username);
$u]sername = $EditedMessage;
$user_viewemail = "0";
userCheck($username, $user_email);
if (!$stop) {
$datekey = date("F j");
$rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $sitekey . $_POST[random_num] . $datekey));
$code = substr($rcode, 2, 6);
if (extension_loaded("gd") AND $code != $gfx_check AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7)) {
title(""._NEWUSERERROR."");
OpenTable();
echo "<center>"._SECCODEINCOR."
"
.""._GOBACK."</center>";
CloseTable();
include("footer.php");
die();
}
if ($user_password == "" AND $user_password2 == "") {
$user_password = makepass();
} elseif ($user_password != $user_password2) {
title(""._NEWUSERERROR."");
OpenTable();
echo "<center>"._PASSDIFFERENT."
"._GOBACK."</center>";
CloseTable();
include("footer.php");
die();
} elseif ($user_password == $user_password2 AND strlen($user_password) < $minpass) {
title(""._NEWUSERERROR."");
OpenTable();
echo "<center>"._YOUPASSMUSTBE." $minpass "._CHARLONG."
"._GOBACK."</center>";
CloseTable();
include("footer.php");
die();
}
title("$sitename: "._USERREGLOGIN."");
OpenTable();
echo "<center>"._USERFINALSTEP."
$username, "._USERCHECKDATA."
"
."<table align='center' border='0'>"
."<tr><td>"._UUSERNAME.": $username
</td></tr>"
."<tr><td>"._EMAIL.": $user_email</td></tr></table>
";
if (!$autoActivate) echo "<center>"._NOTE." "._YOUWILLRECEIVE."";
echo "<form action=\"modules.php?name=$module_name\" method=\"post\">"
."<input type=\"hidden\" name=\"random_num\" value=\"$random_num\">"
."<input type=\"hidden\" name=\"gfx_check\" value=\"$gfx_check\">"
."<input type=\"hidden\" name=\"username\" value=\"$username\">"
."<input type=\"hidden\" name=\"user_email\" value=\"$user_email\">"
."<input type=\"hidden\" name=\"user_password\" value=\"$user_password\">"
."<input type=\"hidden\" name=\"op\" value=\"finish\">
"
."<input type=\"submit\" value=\""._FINISH."\"> "._GOBACK."</form></center>";
CloseTable();
} else {
OpenTable();
echo "<center><font class=\"title\">Registration Error!</font>
";
echo "<font class=\"content\">$stop
"._GOBACK."</font></center>";
CloseTable();
}
include("footer.php");
}
function finishNewUser($username, $user_email, $user_password, $random_num, $gfx_check) {
global $stop, $EditedMessage, $adminmail, $sitename, $Default_Theme, $user_prefix, $db, $storyhome, $module_name, $nukeurl, $autoActivate;
include("header.php");
include("config.php");
userCheck($username, $user_email);
$user_regdate = date("M d, Y");
if (!isset($stop)) {
$datekey = date("F j");
$rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $sitekey . $random_num . $datekey));
$code = substr($rcode, 2, 6);
if (extension_loaded("gd") AND $code != $gfx_check AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7)) {
Header("Location: modules.php?name=$module_name");
die();
}
mt_srand ((double)microtime()*1000000);
$maxran = 1000000;
$check_num = mt_rand(0, $maxran);
$check_num = md5($check_num);
$time = time();
$finishlink = "$nukeurl/modules.php?name=$module_name&op=activate&username=$username&check_num=$check_num";
$new_password = md5($user_password);
$username = check_html($username, nohtml);
$user_email = check_html($user_email, nohtml);
$result = $db->sql_query("INSERT INTO ".$user_prefix."_users_temp (user_id, username, user_email, user_password, user_regdate, check_num, time) VALUES (NULL, '$username', '$user_email', '$new_password', '$user_regdate', '$check_num', '$time')");
if(!$result) {
echo ""._ERROR."
";
} elseif ($autoActivate) { activate($username, $check_num, $autoActivate);
} else {
$message = ""._WELCOMETO." $sitename!\n\n"._YOUUSEDEMAIL." ($user_email) "._TOREGISTER." $sitename.\n\n "._TOFINISHUSER."\n\n $finishlink\n\n "._FOLLOWINGMEM."\n\n"._UNICKNAME." $username\n"._UPASSWORD." $user_password";
$subject = ""._ACTIVATIONSUB."";
$from = "$adminmail";
mail($user_email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());
title("$sitename: "._USERREGLOGIN."");
OpenTable();
echo "<center>"._ACCOUNTCREATED."
";
echo ""._YOUAREREGISTERED.""
."
"
.""._FINISHUSERCONF."
"
.""._THANKSUSER." $sitename!</center>";
CloseTable();
}
} else {
echo "$stop";
}
include("footer.php");
}
function activate($username, $check_num, $autoActivate=FALSE) {
global $db, $user_prefix, $module_name, $language, $stop, $EditedMessage, $adminmail, $sitename, $Default_Theme, $db, $storyhome, $nukeurl, $autoActivate;
$past = time()-86400;
$db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE time < '$past'");
$sql = "SELECT * FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'";
$result = $db->sql_query($sql);
if ($db->sql_numrows($result) == 1) {
$row = $db->sql_fetchrow($result);
if ($check_num == $row[check_num]) {
$db->sql_query("INSERT INTO ".$user_prefix."_users (user_id, username, user_email, user_password, user_avatar, user_regdate, user_lang) VALUES (NULL, '$row[username]', '$row[user_email]', '$row[user_password]', 'gallery/blank.gif', '$row[user_regdate]', '$language')");
$db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'");
if (!$autoActivate) include("header.php");
include("config.php");
title(""._ACTIVATIONYES."");
OpenTable();
echo "<center>$row[username]: "._ACTMSG."</center>";
CloseTable();
include("footer.php");
die();
} else {
if (!$autoActivate) include("header.php");
title(""._ACTIVATIONERROR."");
OpenTable();
echo "<center>"._ACTERROR1."</center>";
CloseTable();
include("footer.php");
die();
}
} else {
if (!$autoActivate) include("header.php");
title(""._ACTIVATIONERROR."");
OpenTable();
echo "<center>"._ACTERROR2."</center>";
CloseTable();
include("footer.php");
die();
}
}
I tried adding the globals to the auto activation if statement and this code but it did not work so what am I doing wrong?:
Code:
$message = ""._WELCOMETO." $sitename!\n\n"._YOUUSEDEMAIL." ($user_email) "._TOREGISTER." $sitename.\n\n "._TOFINISHUSER."\n\n $finishlink\n\n "._FOLLOWINGMEM."\n\n"._UNICKNAME." $username\n"._UPASSWORD." $user_password";
$subject = ""._ACTIVATIONSUB."";
$from = "$adminmail";
mail($user_email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());