Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2006, 06:48 PM
belinea belinea is offline
 
Join Date: Jun 2002
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 01-09-2007, 11:01 AM
netwind netwind is offline
 
Join Date: Feb 2005
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 ?
Reply With Quote
  #3  
Old 04-02-2007, 10:12 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 04-02-2007, 12:00 PM
MarkPW MarkPW is offline
 
Join Date: Apr 2006
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 04-02-2007, 01:34 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 04-02-2007, 01:44 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That define was added in vB 3.5
Reply With Quote
  #7  
Old 04-02-2007, 04:13 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 04-02-2007, 05:05 PM
MarkPW MarkPW is offline
 
Join Date: Apr 2006
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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); 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:34 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05922 seconds
  • Memory Usage 2,235KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete