The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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! |
#2
|
|||
|
|||
<a href="http://vbulletin.com/forum/showthread.php?s=&goto=lastpost&threadid=10471" target="_blank">http://vbulletin.com/forum/showthrea...threadid=10471</a>
|
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
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.. |
#5
|
|||
|
|||
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? |
#6
|
|||
|
|||
Just look at what index.php does!
|
#7
|
|||
|
|||
Sometimes the obvious is easily overlooked. Thank you Freddie -- working like a charm
|
#8
|
|||
|
|||
Can you post the code here? I would love to use this!
|
#9
|
|||
|
|||
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! |
#10
|
|||
|
|||
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. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|