this is what i thought. I am quite new at this post nuke stuff, but i thought i would give 'er the ol college try.
I wanted to hack NewUser/user.php so that it would check the subscriber DB table (nuke_nl_sub) for a matching email address with the current new subscriber. if a match existed, then update the column (nuke_nl_sub.sub_uid) with the value of the user id (nuke_users.pn_uid) for the new user.
Hopefully i haven't confused anyone. but this was my attempt at the function newuser_user_finishnewuser() within newuser/user.php. I know it is coded in a very elementary way but that is currently the only way i know how. here is the function in whole...my "hack" is close tho the bottom.
Code
function newuser_user_finishnewuser($var)
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
list($name,
$agreetoterms,
$email,
$femail,
$vemail,
$url,
$pass,
$vpass,
$bio,
$uname,
$user_avatar,
$user_icq,
$user_occ,
$user_from,
$user_intrest,
$user_sig,
$user_aim,
$user_yim,
$user_msnm,
$user_viewemail,
$timezoneoffset,
$dynadata) = pnVarCleanFromInput('name',
'agreetoterms',
'email',
'femail',
'vemail',
'url',
'pass',
'vpass',
'bio',
'uname',
'user_avatar',
'user_icq',
'user_occ',
'user_from',
'user_intrest',
'user_sig',
'user_aim',
'user_yim',
'user_msnm',
'user_viewemail',
'timezoneoffset',
'dynadata');
$system = pnConfigGetVar('system');
$adminmail = pnConfigGetVar('adminmail');
$sitename = pnConfigGetVar('sitename');
$siteurl = pnGetBaseURL();
$Default_Theme = pnConfigGetVar('Default_Theme');
$commentlimit = pnConfigGetVar('commentlimit');
$storynum = pnConfigGetVar('storyhome');
if (!pnConfigGetVar('reg_optitems')) {
// if we don't show optional items
// we should set the timezone based on site settings
$timezoneoffset = pnConfigGetVar('timezone_offset');
}
$minpass = pnConfigGetVar('minpass'); //by class007
include 'header.php';
$stop = userCheck($uname, $email, $agreetoterms);
// add vpass and vemail check. by class007
// TODO: remove it to userCheck() [class007]
if ((isset($pass)) && ("$pass" != "$vpass")) {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _PASSDIFFERENT . "</div></span><br /><br /><br /><br />";
} elseif (($pass != "") && (strlen($pass) < $minpass)) {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _YOURPASSMUSTBE . " $minpass " . _CHARLONG . "</div></span><br /><br /><br /><br />";
} elseif (empty($pass) && !pnConfigGetVar('reg_verifyemail')) {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _PASSWDNEEDED . "</div></span><br /><br /><br /><br />";
} elseif ("$email" != "$vemail") {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _EMAILSDIFF . "</div></span><br /><br /><br /><br />";
}
$user_regdate = time();
if (empty($user_avatar)) $user_avatar = 'blank.gif';
if (empty($stop)) {
if (pnConfigGetVar('reg_verifyemail')) {
$makepass = makepass();
$cryptpass = md5($makepass);
} else {
$makepass = $pass; // for welcome email. [class007]
$cryptpass = md5($pass);
}
// some additional checks
if (!empty($femail)) {
$femail = preg_replace('/[^a-zA-Z0-9_@.-]/', '', $femail);
}
if (!empty($url)) {
if (!eregi("^http://[\-\.0-9a-z]+", $url)) {
$url = "http://" . $url;
}
$url = preg_replace('/[^a-zA-Z0-9_@.&#?;:\/-]/', '', $url);
}
// end of additional checks
$uid = $dbconn->GenId($pntable['users']);
$column = &$pntable['users_column'];
$result =& $dbconn->Execute("INSERT INTO $pntable[users] ($column[name], $column[uname], $column[email],
$column[femail], $column[url], $column[user_avatar], $column[user_regdate], $column[user_icq],
$column[user_occ], $column[user_from], $column[user_intrest], $column[user_sig],
$column[user_viewemail], $column[user_theme], $column[user_aim], $column[user_yim],
$column[user_msnm], $column[pass], $column[storynum], $column[umode], $column[uorder],
$column[thold], $column[noscore], $column[bio], $column[ublockon], $column[ublock],
$column[theme], $column[commentmax], $column[counter], $column[timezone_offset])
VALUES ('" . pnVarPrepForStore($name) . "','" . pnVarPrepForStore($uname) . "',
'" . pnVarPrepForStore($email) . "','" . pnVarPrepForStore($femail) . "',
'" . pnVarPrepForStore($url) . "','" . pnVarPrepForStore($user_avatar) . "',
'" . pnVarPrepForStore($user_regdate) . "','" . pnVarPrepForStore($user_icq) . "',
'" . pnVarPrepForStore($user_occ) . "','" . pnVarPrepForStore($user_from) . "',
'" . pnVarPrepForStore($user_intrest) . "','" . pnVarPrepForStore($user_sig) . "',
'" . pnVarPrepForStore($user_viewemail) . "','',
'" . pnVarPrepForStore($user_aim) . "','" . pnVarPrepForStore($user_yim) . "',
'" . pnVarPrepForStore($user_msnm) . "','" . pnVarPrepForStore($cryptpass) . "',
'" . pnVarPrepForStore($storynum) . "','',0,0,0,'" . pnVarPrepForStore($bio) . "',0,'','',
'" . pnVarPrepForStore($commentlimit) . "', '0', '" . pnVarPrepForStore($timezoneoffset) . "')");
// insert dynadata [class007]
if (!empty($dynadata) && is_array($dynadata)) {
while (list($key, $val) = each($dynadata)) {
pnUserSetVar($key, $val);
}
}
if ($dbconn->ErrorNo() <> 0) {
echo $dbconn->ErrorNo() . ": " . $dbconn->ErrorMsg() . "<br />";
error_log ($dbconn->ErrorNo() . ": " . $dbconn->ErrorMsg() . "<br />");
} else {
// get the generated id
$uid = $dbconn->PO_Insert_ID($pntable['users'], $column['uid']);
// Let any hooks know that we have created a new item
pnModCallHooks('item', 'create', $uid, 'uid');
// Add user to group
$column = &$pntable['groups_column'];
$result =& $dbconn->Execute("SELECT $column[gid]
FROM $pntable[groups]
WHERE $column[name]='" . pnConfigGetVar('defaultgroup') . "'");
if ($dbconn->ErrorNo() <> 0) {
echo $dbconn->ErrorNo() . _GETGROUP . $dbconn->ErrorMsg() . "<br />";
error_log ($dbconn->ErrorNo() . _GETGROUP . $dbconn->ErrorMsg() . "<br />");
} else {
if (!$result->EOF) {
list($gid) = $result->fields;
$result->Close();
$column = &$pntable['group_membership_column'];
$result =& $dbconn->Execute("INSERT INTO $pntable[group_membership] ($column[gid], $column[uid])
VALUES (" . pnVarPrepForStore($gid) . ", " . pnVarPrepForStore($uid) . ")");
if ($dbconn->ErrorNo() <> 0) {
echo $dbconn->ErrorNo() . _CREATEGROUP . $dbconn->ErrorMsg() . "<br />";
error_log ($dbconn->ErrorNo() . _CREATEGROUP . $dbconn->ErrorMsg() . "<br />");
}
}
$message = "" . _WELCOMETO . " $sitename ($siteurl)!\n\n" . _YOUUSEDEMAIL . " ($email) " . _TOREGISTER . " $sitename. " . _FOLLOWINGMEM . "\n\n" . _UNICKNAME . " $uname\n" . _UPASSWORD . " $makepass";
$subject = "" . _USERPASS4 . " $uname" . _USERPASS42 . "";
$from = "$adminmail";
/**
* if ($system == 1) {
* echo "<table align=\"center\"><tr><td><span class=\"pn-normal\">"._YOURPASSIS." <strong>$makepass</strong></span><br />";
* echo "<a class=\"pn-normal\" href=\"user.php?module=NS-User&op=login&uname=$uname&pass=$makepass&url=user.php\">"._LOGIN."</a><span class=\"pn-normal\"> "._2CHANGEINFO."</span></td></tr></table>";
* } else {
*/
// 11-09-01 eugeniobaldi not compliant with PHP < 4.0.5
// pnMail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion(), "-f$from");
// if (pnConfigGetVar('reg_verifyemail')) {
pnMail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion(), 0);
// }
if (pnConfigGetVar('reg_notifyemail') != "") {
$email2 = pnConfigGetVar('reg_notifyemail');
$subject2 = _NOTIFYEMAILSUB;
$message2 = _NOTIFYEMAILCONT1 . "$uname" . _NOTIFYEMAILCONT2;
pnMail($email2, $subject2, $message2, "From: $from\nX-Mailer: PHP/" . phpversion(), 0);
}
OpenTable();
//------------this is my attempt---------------------------------------------->
//check for subscription hack
$resultHACK =& $dbconn->Execute("SELECT * FROM nuke_nl_subscribers WHERE sub_email='".pnVarPrepForStore($email)."'");
if (mysql_num_rows($resultHACK)>=1) {
$rowa=@mysql_fetch_assoc($resultHACK);
echo("got this far");
}
else {}
//end Hack
//-------------------end my attempt-----------------------
echo "<span class=\"pn-normal\">" . _YOUAREREGISTERED . "</span>";
CloseTable();
}
}
} else {
echo "$stop";
}
include 'footer.php';
}
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
list($name,
$agreetoterms,
$email,
$femail,
$vemail,
$url,
$pass,
$vpass,
$bio,
$uname,
$user_avatar,
$user_icq,
$user_occ,
$user_from,
$user_intrest,
$user_sig,
$user_aim,
$user_yim,
$user_msnm,
$user_viewemail,
$timezoneoffset,
$dynadata) = pnVarCleanFromInput('name',
'agreetoterms',
'email',
'femail',
'vemail',
'url',
'pass',
'vpass',
'bio',
'uname',
'user_avatar',
'user_icq',
'user_occ',
'user_from',
'user_intrest',
'user_sig',
'user_aim',
'user_yim',
'user_msnm',
'user_viewemail',
'timezoneoffset',
'dynadata');
$system = pnConfigGetVar('system');
$adminmail = pnConfigGetVar('adminmail');
$sitename = pnConfigGetVar('sitename');
$siteurl = pnGetBaseURL();
$Default_Theme = pnConfigGetVar('Default_Theme');
$commentlimit = pnConfigGetVar('commentlimit');
$storynum = pnConfigGetVar('storyhome');
if (!pnConfigGetVar('reg_optitems')) {
// if we don't show optional items
// we should set the timezone based on site settings
$timezoneoffset = pnConfigGetVar('timezone_offset');
}
$minpass = pnConfigGetVar('minpass'); //by class007
include 'header.php';
$stop = userCheck($uname, $email, $agreetoterms);
// add vpass and vemail check. by class007
// TODO: remove it to userCheck() [class007]
if ((isset($pass)) && ("$pass" != "$vpass")) {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _PASSDIFFERENT . "</div></span><br /><br /><br /><br />";
} elseif (($pass != "") && (strlen($pass) < $minpass)) {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _YOURPASSMUSTBE . " $minpass " . _CHARLONG . "</div></span><br /><br /><br /><br />";
} elseif (empty($pass) && !pnConfigGetVar('reg_verifyemail')) {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _PASSWDNEEDED . "</div></span><br /><br /><br /><br />";
} elseif ("$email" != "$vemail") {
$stop = "<div style=\"text-align:center\"><span class=\"pn-title\">" . _EMAILSDIFF . "</div></span><br /><br /><br /><br />";
}
$user_regdate = time();
if (empty($user_avatar)) $user_avatar = 'blank.gif';
if (empty($stop)) {
if (pnConfigGetVar('reg_verifyemail')) {
$makepass = makepass();
$cryptpass = md5($makepass);
} else {
$makepass = $pass; // for welcome email. [class007]
$cryptpass = md5($pass);
}
// some additional checks
if (!empty($femail)) {
$femail = preg_replace('/[^a-zA-Z0-9_@.-]/', '', $femail);
}
if (!empty($url)) {
if (!eregi("^http://[\-\.0-9a-z]+", $url)) {
$url = "http://" . $url;
}
$url = preg_replace('/[^a-zA-Z0-9_@.&#?;:\/-]/', '', $url);
}
// end of additional checks
$uid = $dbconn->GenId($pntable['users']);
$column = &$pntable['users_column'];
$result =& $dbconn->Execute("INSERT INTO $pntable[users] ($column[name], $column[uname], $column[email],
$column[femail], $column[url], $column[user_avatar], $column[user_regdate], $column[user_icq],
$column[user_occ], $column[user_from], $column[user_intrest], $column[user_sig],
$column[user_viewemail], $column[user_theme], $column[user_aim], $column[user_yim],
$column[user_msnm], $column[pass], $column[storynum], $column[umode], $column[uorder],
$column[thold], $column[noscore], $column[bio], $column[ublockon], $column[ublock],
$column[theme], $column[commentmax], $column[counter], $column[timezone_offset])
VALUES ('" . pnVarPrepForStore($name) . "','" . pnVarPrepForStore($uname) . "',
'" . pnVarPrepForStore($email) . "','" . pnVarPrepForStore($femail) . "',
'" . pnVarPrepForStore($url) . "','" . pnVarPrepForStore($user_avatar) . "',
'" . pnVarPrepForStore($user_regdate) . "','" . pnVarPrepForStore($user_icq) . "',
'" . pnVarPrepForStore($user_occ) . "','" . pnVarPrepForStore($user_from) . "',
'" . pnVarPrepForStore($user_intrest) . "','" . pnVarPrepForStore($user_sig) . "',
'" . pnVarPrepForStore($user_viewemail) . "','',
'" . pnVarPrepForStore($user_aim) . "','" . pnVarPrepForStore($user_yim) . "',
'" . pnVarPrepForStore($user_msnm) . "','" . pnVarPrepForStore($cryptpass) . "',
'" . pnVarPrepForStore($storynum) . "','',0,0,0,'" . pnVarPrepForStore($bio) . "',0,'','',
'" . pnVarPrepForStore($commentlimit) . "', '0', '" . pnVarPrepForStore($timezoneoffset) . "')");
// insert dynadata [class007]
if (!empty($dynadata) && is_array($dynadata)) {
while (list($key, $val) = each($dynadata)) {
pnUserSetVar($key, $val);
}
}
if ($dbconn->ErrorNo() <> 0) {
echo $dbconn->ErrorNo() . ": " . $dbconn->ErrorMsg() . "<br />";
error_log ($dbconn->ErrorNo() . ": " . $dbconn->ErrorMsg() . "<br />");
} else {
// get the generated id
$uid = $dbconn->PO_Insert_ID($pntable['users'], $column['uid']);
// Let any hooks know that we have created a new item
pnModCallHooks('item', 'create', $uid, 'uid');
// Add user to group
$column = &$pntable['groups_column'];
$result =& $dbconn->Execute("SELECT $column[gid]
FROM $pntable[groups]
WHERE $column[name]='" . pnConfigGetVar('defaultgroup') . "'");
if ($dbconn->ErrorNo() <> 0) {
echo $dbconn->ErrorNo() . _GETGROUP . $dbconn->ErrorMsg() . "<br />";
error_log ($dbconn->ErrorNo() . _GETGROUP . $dbconn->ErrorMsg() . "<br />");
} else {
if (!$result->EOF) {
list($gid) = $result->fields;
$result->Close();
$column = &$pntable['group_membership_column'];
$result =& $dbconn->Execute("INSERT INTO $pntable[group_membership] ($column[gid], $column[uid])
VALUES (" . pnVarPrepForStore($gid) . ", " . pnVarPrepForStore($uid) . ")");
if ($dbconn->ErrorNo() <> 0) {
echo $dbconn->ErrorNo() . _CREATEGROUP . $dbconn->ErrorMsg() . "<br />";
error_log ($dbconn->ErrorNo() . _CREATEGROUP . $dbconn->ErrorMsg() . "<br />");
}
}
$message = "" . _WELCOMETO . " $sitename ($siteurl)!\n\n" . _YOUUSEDEMAIL . " ($email) " . _TOREGISTER . " $sitename. " . _FOLLOWINGMEM . "\n\n" . _UNICKNAME . " $uname\n" . _UPASSWORD . " $makepass";
$subject = "" . _USERPASS4 . " $uname" . _USERPASS42 . "";
$from = "$adminmail";
/**
* if ($system == 1) {
* echo "<table align=\"center\"><tr><td><span class=\"pn-normal\">"._YOURPASSIS." <strong>$makepass</strong></span><br />";
* echo "<a class=\"pn-normal\" href=\"user.php?module=NS-User&op=login&uname=$uname&pass=$makepass&url=user.php\">"._LOGIN."</a><span class=\"pn-normal\"> "._2CHANGEINFO."</span></td></tr></table>";
* } else {
*/
// 11-09-01 eugeniobaldi not compliant with PHP < 4.0.5
// pnMail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion(), "-f$from");
// if (pnConfigGetVar('reg_verifyemail')) {
pnMail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion(), 0);
// }
if (pnConfigGetVar('reg_notifyemail') != "") {
$email2 = pnConfigGetVar('reg_notifyemail');
$subject2 = _NOTIFYEMAILSUB;
$message2 = _NOTIFYEMAILCONT1 . "$uname" . _NOTIFYEMAILCONT2;
pnMail($email2, $subject2, $message2, "From: $from\nX-Mailer: PHP/" . phpversion(), 0);
}
OpenTable();
//------------this is my attempt---------------------------------------------->
//check for subscription hack
$resultHACK =& $dbconn->Execute("SELECT * FROM nuke_nl_subscribers WHERE sub_email='".pnVarPrepForStore($email)."'");
if (mysql_num_rows($resultHACK)>=1) {
$rowa=@mysql_fetch_assoc($resultHACK);
echo("got this far");
}
else {}
//end Hack
//-------------------end my attempt-----------------------
echo "<span class=\"pn-normal\">" . _YOUAREREGISTERED . "</span>";
CloseTable();
}
}
} else {
echo "$stop";
}
include 'footer.php';
}
as you notice, i haven't even begun to code the UPDATE portion of it. I only have echo'd "got this far" so that i might at least feel good about myself for getting one step instead of trying to accomplish it all in one giant leap.
anyway....this is not working.....can somone tell me why?
