can't call myself a 'developer' (but I do aspire
) so please bear with my n00blishness what I'm trying to accomplish:
login to PostNuke and automatically login (setting cookies,too) to an external portion of my website,sparing users from logging in twice.
(something like the pnphpbb module)
particulars:
I'm running a, uhm.. tracker using:
XBTT as the tracker, and using
BTIT as a front end for the tracker.
I would like users to access PostNuke, see the news articles,and click attached link to see more details/download torrent from the tracker (these are functions of BTIT.)
However, I do not want most users to access the main tracker itself.
so what I have done so far is:
Modified New Accounts,Recover Lost Password,Change Info.
i.e user registers with PN,is registered with BTIT. same with recover password (on recover it updates BTIT DB). same with change info.
These modifications are really simply copying code from BTIT into the appropriate PN *.php code.
In order not to clutter this post I am posting those working changes outside this board.
NS-NewUser\user.php
NS-LostPassword\user.php
NS-Your_Account\user…ules\changeinfo.php
now to the problem:
here is the BTIT code for logging in/out
first BTIT's include.php has the following functions
Code
(I cannot use it as an include in PN as some other BTIT functions clash with PN,so I have to copy/paste those two functions into wherever the PN login/out functions are)
code login
Code
// *** btit begin edit ***
$res = mysql_query("SELECT * FROM users WHERE username ='$uname' AND password ='" . md5($pass) . "'") or die(mysql_error());
$row = mysql_fetch_array($res);
logincookie($row["id"],$row["password"]);
// *** btit end edit ***
$res = mysql_query("SELECT * FROM users WHERE username ='$uname' AND password ='" . md5($pass) . "'") or die(mysql_error());
$row = mysql_fetch_array($res);
logincookie($row["id"],$row["password"]);
// *** btit end edit ***
and logout
Code
// *** btit begin edit ***
logoutcookie();
// *** btit end edit ***
logoutcookie();
// *** btit end edit ***
now where to put these?
n00bly I put them in to 'www\includes\pnUser.php' :wince:
well it worked..sort of.
it logins to to PN and BTIT (cookies created) and logs out ok..but...
If,while logged in I change my account info,it will let me do so ONCE.
When attempting to change info again, I get:
'Sorry! You did not enter the same password in each password field. Please enter the same password twice'
eww!
Its not a 'changeinfo.php' or the other modification issue as I played around changing back my changes and narrowing it down to the 'pnUser.php' change.
here is the code of change:
Code
// Original Author of file: Jim McDonald
// Purpose of file: User functions
// ----------------------------------------------------------------------
// *** btit begin edit ***
function logincookie($id, $passhash, $expires = 0x7fffffff)
{
setcookie("uid", $id, $expires, "/");
setcookie("pass", $passhash, $expires, "/");
}
function logoutcookie() {
setcookie("uid", "", 0x7fffffff, "/");
setcookie("pass", "", 0x7fffffff, "/");
}
// *** btit end edit ***
/**
* @package PostNuke_Core
.
.
.
.
// Set session variables
pnSessionSetVar('uid', (int)$uid);
if (!empty($rememberme)) {
pnSessionSetVar('rememberme', 1);
}
}
// *** btit begin edit ***
$res = mysql_query("SELECT * FROM users WHERE username ='$uname' AND password ='" . md5($pass) . "'") or die(mysql_error());
$row = mysql_fetch_array($res);
logincookie($row["id"],$row["password"]);
// *** btit end edit ***
return true;
}
/**
* Compare Passwords
.
.
.
function pnUserLogOut()
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
if (pnUserLoggedIn()) {
// Reset user session information (new table)
$sessioninfocolumn = &$pntable['session_info_column'];
$sessioninfotable = $pntable['session_info'];
$query = "UPDATE $sessioninfotable
SET $sessioninfocolumn[uid] = 0
WHERE $sessioninfocolumn[sessid] = '" . pnVarPrepForStore(session_id()) . "'";
$dbconn->Execute($query);
pnSessionDelVar('rememberme');
pnSessionDelVar('uid');
pnSessionDestroy(session_id());
// *** btit begin edit ***
logoutcookie();
// *** btit end edit ***
}
}
/**
// Purpose of file: User functions
// ----------------------------------------------------------------------
// *** btit begin edit ***
function logincookie($id, $passhash, $expires = 0x7fffffff)
{
setcookie("uid", $id, $expires, "/");
setcookie("pass", $passhash, $expires, "/");
}
function logoutcookie() {
setcookie("uid", "", 0x7fffffff, "/");
setcookie("pass", "", 0x7fffffff, "/");
}
// *** btit end edit ***
/**
* @package PostNuke_Core
.
.
.
.
// Set session variables
pnSessionSetVar('uid', (int)$uid);
if (!empty($rememberme)) {
pnSessionSetVar('rememberme', 1);
}
}
// *** btit begin edit ***
$res = mysql_query("SELECT * FROM users WHERE username ='$uname' AND password ='" . md5($pass) . "'") or die(mysql_error());
$row = mysql_fetch_array($res);
logincookie($row["id"],$row["password"]);
// *** btit end edit ***
return true;
}
/**
* Compare Passwords
.
.
.
function pnUserLogOut()
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
if (pnUserLoggedIn()) {
// Reset user session information (new table)
$sessioninfocolumn = &$pntable['session_info_column'];
$sessioninfotable = $pntable['session_info'];
$query = "UPDATE $sessioninfotable
SET $sessioninfocolumn[uid] = 0
WHERE $sessioninfocolumn[sessid] = '" . pnVarPrepForStore(session_id()) . "'";
$dbconn->Execute($query);
pnSessionDelVar('rememberme');
pnSessionDelVar('uid');
pnSessionDestroy(session_id());
// *** btit begin edit ***
logoutcookie();
// *** btit end edit ***
}
}
/**
I assume PN does something like set a session cookie checking perms when making changes and after altering the user DB info the first time when attempting to change info a 2nd time,perms dont match,or something deep like that. :)
I know modding the pnUser.php (or any of core) is a big no-no :( ,especially by n00bs but I cant figure any place else to put it :scratches head:
What I've attempted is a pretty coarse/unelegant mod ((besides not working :/ ) just remember my utter n00bness,please forgive
:)
any suggestions as to what,where to hack/insert these BTIT login/out functions/code would be highly appreciated
thanks,
AuntieSocial (The DEV!
