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 03-16-2001, 10:47 PM
BabyU BabyU is offline
 
Join Date: Nov 2001
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had a #online users hack that was working great in 1.x, but returns an error in 2.0

There is a file called online.php that consists of:

------------------------------------------------------------------------
<?php
chdir($DOCUMENT_ROOT . "/forums");
require($DOCUMENT_ROOT . "/forums/global.php");

$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid=0");
$guests=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid<>0");
$members=$loggedins[sessions];

echo "There are currently $members forum members and
$guests guests online. <a href=/forums/index.php>Join us!</a>";

?>

------------------------------------------------------------------------

It is called to a non-php homepage via an include statement:

<!--#include virtual="/forums/online.php"-->

The error I am now receiving since upgrading to 2.0 is:

----------------------------------------------------------------------
There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.
----------------------------------------------------------------------

Any suggestions to fix this? Thanks!
Reply With Quote
  #2  
Old 03-16-2001, 10:48 PM
Guest
 
Posts: n/a
Default

<a href="http://vbulletin.com/forum/showthread.php?s=&goto=lastpost&threadid=10471" target="_blank">http://vbulletin.com/forum/showthrea...threadid=10471</a>
Reply With Quote
  #3  
Old 03-16-2001, 10:52 PM
Guest
 
Posts: n/a
Default

This isn't the same hack that I was referring to in that post. This only showed the number of registered members & guests currently online (shown on a non-vb page).

Is it still affected by the last active location?
Reply With Quote
  #4  
Old 03-16-2001, 10:56 PM
Guest
 
Posts: n/a
Default

Sorry, didn't read it properly...

When you see such a message as this:

There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.


Look in the html-source; It contains more information about what kind of error etc..
Reply With Quote
  #5  
Old 03-16-2001, 11:56 PM
Guest
 
Posts: n/a
Default

I viewed the source code and used the additional information to correct that problem. The user session info is not in global.php anymore, but rather /admin/sessions.php . Easy enough.

Fixed that. It also appears that there is no longer a variable called 'sessionid' . It looks like it is now 'sessionhash' . So I changed that in the hack code.

Now I get the following error:

Fatal error: Call to a member function on a non-object in /home/sites/site14/web/boards/admin/sessions.php on line 70

The online.php file now looks like this:
-----------------------------------------------------------------------<?php
chdir($DOCUMENT_ROOT . "/boards");
require($DOCUMENT_ROOT . "/boards/admin/sessions.php");

$loggedins=$DB_site->query_first("SELECT COUNT(sessionhash) AS sessions FROM session WHERE userid=0");
$guests=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionhash) AS sessions FROM session WHERE userid<>0");
$members=$loggedins[sessions];

echo "There are currently $members forum members and
$guests guests online. <a href=/boards/index.php>Join us!</a>";

?>
-----------------------------------------------------------------------

So close ... yet so far away! I feel like I'm missing one tiny detail. Can anyone else see what it is?
Reply With Quote
  #6  
Old 03-17-2001, 12:10 AM
Guest
 
Posts: n/a
Default

Just look at what index.php does!
Reply With Quote
  #7  
Old 03-17-2001, 12:34 AM
Guest
 
Posts: n/a
Default

Sometimes the obvious is easily overlooked. Thank you Freddie -- working like a charm
Reply With Quote
  #8  
Old 03-17-2001, 05:42 AM
Guest
 
Posts: n/a
Default

Can you post the code here? I would love to use this!
Reply With Quote
  #9  
Old 03-17-2001, 10:43 AM
Guest
 
Posts: n/a
Default

Save the following as online.php and upload to the forums directory.

-----------------------------------------------------------------------
<?php
chdir($DOCUMENT_ROOT . "/forums");
require($DOCUMENT_ROOT . "/forums/global.php");

if ($displayloggedin) {
$datecut=time()-$cookietimeout;

//$loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE lastactivity>$datecut");
//$totalonline=$loggedins['sessions'];
$loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE userid=0 AND lastactivity>$datecut");
$numberguest=$loggedins['sessions'];
//$numberregistered=$totalonline-$numberguest;

$numbervisible=0;
$numberregistered=0;
//$loggedins=$DB_site->query("SELECT DISTINCT user.userid,username FROM user,session WHERE session.userid=user.userid AND session.userid<>0 AND invisible=0 AND session.lastactivity>$datecut ORDER BY username");
$loggedins=$DB_site->query("SELECT DISTINCT session.userid,username,invisible
FROM session
LEFT JOIN user ON (user.userid=session.userid)
WHERE session.userid<>0 AND session.lastactivity>$datecut
ORDER BY invisible ASC, username ASC");
if ($loggedin=$DB_site->fetch_array($loggedins)) {
$numberregistered++;
if ($loggedin['invisible']==0 or $bbuserinfo['usergroupid']==6) {
$numbervisible++;
$userid=$loggedin['userid'];
if ($loggedin['invisible']==1) { // Invisible User but show to Admin
$username=$loggedin['username'];
$invisibleuser = '*';
} else {
$username=$loggedin['username'];
$invisibleuser = '';
}
$location=$loggedin['location'];
eval("\$activeusers = \"".gettemplate('forumhome_loggedinuser')."\";" );
}

while ($loggedin=$DB_site->fetch_array($loggedins)) {
$numberregistered++;
$invisibleuser = '';
if ($loggedin['invisible']==1 and $bbuserinfo['usergroupid']!=6) {
continue;
}
$numbervisible++;
$userid=$loggedin['userid'];
if ($loggedin['invisible']==1) { // Invisible User but show to Admin
$username=$loggedin['username'];
$invisibleuser = '*';
} else {
$username=$loggedin['username'];
}
$location=$loggedin['location'];
eval("\$activeusers .= \", ".gettemplate('forumhome_loggedinuser')."\";") ;
}
}
$DB_site->free_result($loggedins);

$totalonline=$numberregistered+$numberguest;

$numberinvisible=$numberregistered-$numbervisible;

}

echo "There are currently $numberregistered member(s) and $numberguest guest(s) on the boards. <a href=/boards/index.php>Join us!</a>";

?>
-----------------------------------------------------------------------

Call it into your non-vb page via

<!--#include virtual="/forums/online.php"-->

Thank you Freddie & Mas*Mind!
Reply With Quote
  #10  
Old 03-17-2001, 03:40 PM
Guest
 
Posts: n/a
Default

One thing about this code you need to be aware of!

This ONLY works if the visitor has visited your forums before. If they visit this page BEFORE they visit your forums this code will return an error message.

I have been working on a fix for a while now, but have not figured it out as of yet.
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 04:03 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.05185 seconds
  • Memory Usage 2,234KB
  • 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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete