View Full Version : Use "global.php" without updating lasactivity and lastvisit
belinea
11-06-2006, 06:48 PM
I want to use some vBulletin functions in my own PHP Script. So i have included the global.php in my script. But when my script become executed Vbulletin refreshes the user.lastactivity and user.lastvisit informations in the databse. Is there a way to prevent this? I want to use vBulletin functions but vBulletin shouldn´t regocnizes me as an visitor in the forum.
Many many thanks for some hints.
netwind
01-09-2007, 11:01 AM
I found notes in includes/session.php
// if this line is removed (say to be replaced by a cron job, you will need to change all of the
'online'
// status indicators as they use $userinfo['lastactivity'] to determine if a user is online which
relies
// on this to be updated in real time.
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "user
SET lastactivity = " . TIMENOW . "
WHERE userid = $bbuserinfo[userid]
", 'lastvisit');
Maybe cron job code already exists, but where it is ?
sv1cec
04-02-2007, 10:12 AM
I am not sure I am 100% correct, but I did this for a script I have and which I didn't want to update the lastactivity or the lastvisit:
In sessions.php find:
if (!SESSION_BYPASS)
{
if (TIMENOW - $bbuserinfo['lastactivity'] > $vboptions['cookietimeout'])
{ // see if session has 'expired' and if new post indicators need resetting
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "user
SET lastvisit = lastactivity,
lastactivity = " . TIMENOW . "
WHERE userid = $bbuserinfo[userid]
", 'lastvisit');
$bbuserinfo['lastvisit'] = $bbuserinfo['lastactivity'];
}
else
{
Replace this with :
if (!SESSION_BYPASS)
{
if (TIMENOW - $bbuserinfo['lastactivity'] > $vboptions['cookietimeout'])
{ // see if session has 'expired' and if new post indicators need resetting
if (THIS_SCRIPT != 'yourscriptname')
{
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "user
SET lastvisit = lastactivity,
lastactivity = " . TIMENOW . "
WHERE userid = $bbuserinfo[userid]
", 'lastvisit');
$bbuserinfo['lastvisit'] = $bbuserinfo['lastactivity'];
}
}
else
{
Notice this line in the replacing code:
if (THIS_SCRIPT != 'yourscriptname')
This is where you enter the name of your php script. Also make sure that at the top of your script, there is a line like:
[code]define('THIS_SCRIPT', 'yourscriptname');
Mind you I am using vB 3.0.xx so the code may be different if you are using a later version.
MarkPW
04-02-2007, 12:00 PM
No need to edit vb's files. Add the following before calling global.php:
define('SKIP_SESSIONCREATE', 1);
define('NOCOOKIES', 1);
define('DIE_QUIETLY', 1);
Edit: But then, this thread is pretty old.
sv1cec
04-02-2007, 01:34 PM
Sorry for reviving an old thread, I admit I didn't check the date.
Can you please let me know if the above are for vB 3.0.xx or later? I can't find the NOCOOKIES parameter nowhere, so I have to assume that it is for later vB releases?
Marco van Herwaarden
04-02-2007, 01:44 PM
That define was added in vB 3.5
sv1cec
04-02-2007, 04:13 PM
Well, if you use those parameters, then the external program doesn't get any $bbuserinfo. With my clumsy solution it does, the only thing that doesn't happen is to update the lastvisit and lastactivity parameters, which is what the original question was about.
MarkPW
04-02-2007, 05:05 PM
I was assuming that belinea didn't want to be seen as a visitor to the forum (full stop, meaning no sessions either). However, it appears (although I haven't tested this) you can bypass the user (member) activity update using:
define('SESSION_BYPASS', 1);
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.