vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Use "global.php" without updating lasactivity and lastvisit (https://vborg.vbsupport.ru/showthread.php?t=130928)

belinea 11-06-2006 06:48 PM

Use "global.php" without updating lasactivity and lastvisit
 
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
PHP Code:

 // 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:

Code:

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 :

Code:

        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:

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:

PHP Code:

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:

PHP Code:

define('SESSION_BYPASS'1); 



All times are GMT. The time now is 11:15 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01188 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete