PDA

View Full Version : how to include active user info in non-vb page ?


08-25-2000, 07:50 PM
how do i include active user info on this page http://www.animeboards.net

something like

Currently xx members and xx guests viewing this forum

and to have the words member and guest hyperlinked to forums/index.php#active

[Edited by eva2000 on 08-25-2000 at 05:12 PM]

08-26-2000, 10:34 AM
pretty please.... :D

08-26-2000, 12:53 PM
I'll help you - contact me via ICQ:73902680 or AIM: phpBulletin

08-26-2000, 01:15 PM
thanks i sent you an email cause my ICQ doesn't connect properly anymore :(

08-26-2000, 05:38 PM
well i still need a bit of help... thanks to shri who sent me this code which works at
http://animeboards.net/activeusers.shri.php3

<?
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
chdir("/home/usr1/www.animeboards.net/htdocs/forums");
require("/home/usr1/www.animeboards.net/htdocs/forums/global.php");

if ($displayloggedin==1) {
$datecut=time()-$cookietimeout;
$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session");
$totalonline=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid=0");
$numberguest=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid<>0");
$numberregistered=$loggedins[sessions];

$numbervisible=0;
$loggedins=$DB_site->query("SELECT DISTINCT user.userid,username,location FROM user,session WHERE session.userid=user.userid AND session.userid<>0 AND invisible=0 AND usergroupid<>3 ORDER BY username");
if ($loggedin=$DB_site->fetch_array($loggedins)) {
$numbervisible++;
$userid=$loggedin[userid];
$username=$loggedin[username];
$location=$loggedin[location];

eval("\$activeusers .= \"".gettemplate("loggedinuser")."\";");

while ($loggedin=$DB_site->fetch_array($loggedins)) {
$numbervisible++;
$userid=$loggedin[userid];
$username=$loggedin[username];
$location=$loggedin[location];
eval("\$activeusers .= \", ".gettemplate("loggedinuser")."\";");
}
}
$numberinvisible=$numberregistered-$numbervisible;
eval("\$loggedinusers = \"".gettemplate("loggedinusers")."\";");
}

echo $loggedinusers;
?>

i hazardly guessed and modified the echo part leaving intact the rest since i haven't a clue what it is
(don't know php just comparing other code from other stuff) and it works like how i want to at http://animeboards.net/activeusers.root.php3

<?
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
chdir("/home/usr1/www.animeboards.net/htdocs/forums");
require("/home/usr1/www.animeboards.net/htdocs/forums/global.php");

if ($displayloggedin==1) {
$datecut=time()-$cookietimeout;
$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session");
$totalonline=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid=0");
$numberguest=$loggedins[sessions];
$loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid<>0");
$numberregistered=$loggedins[sessions];

$numbervisible=0;
$loggedins=$DB_site->query("SELECT DISTINCT user.userid,username,location FROM user,session WHERE session.userid=user.userid AND session.userid<>0 AND invisible=0 AND usergroupid<>3 ORDER BY username");
if ($loggedin=$DB_site->fetch_array($loggedins)) {
$numbervisible++;
$userid=$loggedin[userid];
$username=$loggedin[username];
$location=$loggedin[location];

eval("\$activeusers .= \"".gettemplate("loggedinuser")."\";");

while ($loggedin=$DB_site->fetch_array($loggedins)) {
$numbervisible++;
$userid=$loggedin[userid];
$username=$loggedin[username];
$location=$loggedin[location];
eval("\$activeusers .= \", ".gettemplate("loggedinuser")."\";");
}
}
$numberinvisible=$numberregistered-$numbervisible;
eval("\$loggedinusers = \"".gettemplate("loggedinusers")."\";");
}

echo "<FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"1\">Currently $numberregistered <A HREF=\"http://animeboards.net/forums/index.php#active\">member(s)</A> and $numberguest <A HREF=\"http://animeboards.net/forums/index.php#active\">guest(s)</A> are on the forums.</font>";
?>

Problem is when i try to include it doesn't work and gives me 2 errors on http://animeboards.net/index4a.php3
(i removed the include for now)

i get this displayed

Fatal error: DB_Sql_vb is already a function or class in admin/db_mysql.php on line 6

and this sent to me via email

Database error in vBulletin: Invalid SQL: SELECT COUNT(sessionid) AS sessions FROM session WHERE userid=0
mysql error: Unknown column 'userid' in 'where clause'
mysql error number: 1054
Date: Saturday 26th of August 2000 01:21:46 PM
Script: /index4a.php3
Referer

08-27-2000, 07:20 AM
anyone ?

08-27-2000, 09:16 AM
This is just off the top of my head but it could be that you're including global.php in twice. Since DB_Sql_vb is already defined (possibly through config.php) including it again will bring up that error.

If you delete that file see what happens... or if it's not that, try to look for a file that is referenced twice by require -- that's probably you're answer :)

I do not know if the mysql error is related to the first one, but could be!

--red

08-27-2000, 09:54 AM
thanks.. this is what i have in the index4a.php3 before the html tags


<?
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
require("/home/usr1/www.animeboards.net/htdocs/phpads/config.inc.php3");
require("/home/usr1/www.animeboards.net/htdocs/phpads/view.inc.php3");
require("/home/usr1/www.animeboards.net/htdocs/phpads/acl.inc.php3");
chdir("/home/usr1/www.animeboards.net/htdocs/forums");
require("/home/usr1/www.animeboards.net/htdocs/forums/global.php");
?>

and this is what i have in the activeusers.root.php3 file
chdir("/home/usr1/www.animeboards.net/htdocs/forums");
require("/home/usr1/www.animeboards.net/htdocs/forums/global.php");
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");

08-27-2000, 01:30 PM
change index4a.php's requires to this:
<?
require("/home/usr1/www.animeboards.net/htdocs/phpads/config.inc.php3");
require("/home/usr1/www.animeboards.net/htdocs/phpads/view.inc.php3");
require("/home/usr1/www.animeboards.net/htdocs/phpads/acl.inc.php3");
chdir("/home/usr1/www.animeboards.net/htdocs/forums");
require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
require("/home/usr1/www.animeboards.net/htdocs/forums/global.php");
?>

And drop all the requires from activeusers.root.php3

08-27-2000, 04:01 PM
thanks i did that i it came up with this error

Fatal error: DB_Sql_vb is already a function or class in admin/db_mysql.php on line 6

i did an exact copy of index4a.php3 named index4b.php3 except, removed all other php includes and the activeusers.root.php3 works

at http://www.animeboards.net/index4b.php3

but when i add back all the php includes to index4b.php3 i get the say error

Fatal error: DB_Sql_vb is already a function or class in admin/db_mysql.php on line 6

08-30-2000, 02:41 AM
eva:

Well,

Global.php has an explicit REQUIRE for /admin/config.php, so turn this:


require("/home/usr1/www.animeboards.net/htdocs/forums/admin/config.php");
require("/home/usr1/www.animeboards.net/htdocs/forums/global.php");


into this:


require("/home/usr1/www.animeboards.net/htdocs/forums/global.php");

I'm not sure why you have that first require( config.php ) deal in there, but global.php does it for you. That's why you're getting the redefinition error.

09-09-2000, 04:45 PM
Eva this works for me - see at http://www.hedgehogwheels.com/online.php

My forums are in /forums but I don't have an anchor = active so when you click it just goes to the page.


<?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 <a href=\"forums/index.php#active\">$members</a> members and
<a href=\"forums/index.php#active\">$guests</a> guests viewing this forum";

?>


Putting $DOCUMENT_ROOT in all requires is a smart thing to do and makes this all easier. If all the PHP files in vBulletin had $DOCUMENT_ROOT then we wouldn't need to chdir.

[Edited by rangersfan on 09-09-2000 at 01:48 PM]

09-09-2000, 04:50 PM
thanks mrogish and rangersfan... i had almost given up on this thread :D ...

i shall be giving this a try in the morning :)

man, is the code here messing with the newreply page... the text box is in the middle of my brower and had to scroll horizontally :(

09-12-2000, 03:10 AM
I tried Rangerfans code but got this error:

Fatal error: Call to a member function on a non-object in /home/php/pbcity/vb/etc/online.php on line 5

09-12-2000, 03:27 AM
What I posted works, you can verify it by clicking the link in the same post.

09-12-2000, 03:35 AM
Right,

Not for me though.

I tried putting both the absolute path and the url to the paths you specified in the chdir and the require statements.

Any ideas?

09-12-2000, 03:14 PM
Chris Schreiber tried this yesterday as well Rangersfan and it did not work for him.

Any ideas?

09-12-2000, 03:31 PM
I'm sorry but as it is, it works on my server.


Fatal error: Call to a member function on a non-object in /home/php/pbcity/vb/etc/online.php on line 5


Line 5 is the first reference to "$DB_site->query_first"

My script is in /
My forums are in /forums

Is your directory structure the same? If the script is in the same directory as the forum then no chdirs are needed.

09-12-2000, 04:36 PM
The script is running at:
http://forums.paintballcity.com/etc/online.php
the full path to that is:
/home/php/pbcity/vb/etc

The forums are at:
http://forums.paintballcity.com
The full path to that is:
/home/php/pbcity/vb

What would be the right config?

09-12-2000, 04:42 PM
By the paths you list than the etc directory is a sub-directory in the directory that contains your forums?

09-12-2000, 04:53 PM
try:

chdir($DOCUMENT_ROOT . "/vb");
require($DOCUMENT_ROOT . "/vb/global.php");

(I am assuming /home/php/pbcity == your web root directory)

09-12-2000, 05:14 PM
I used:

chdir($DOCUMENT_ROOT . "");
require($DOCUMENT_ROOT . "global.php");

and it worked. Thanks for your patience. I feel like such a dummy. :)

09-12-2000, 06:41 PM
OK so /vb is your web root directory.

This is cleaner:

chdir($DOCUMENT_ROOT);
require($DOCUMENT_ROOT . "global.php");

09-12-2000, 06:56 PM
Ok Thanks.