View Full Version : getting VB vars to work in a misc php file in the forum directory?
Gutspiller
03-04-2002, 03:49 PM
How would I do this? It's a php news file ( http://www.theforumz.com/forumz/frontpage.php ), but I want to use some fo the variables in VB to call numbers and features, like getting the number of people that are online. (I have FireFly's lil' hack) or getting a PM box on the page, etc. I try it and instead of grabbing the variable, it just shows the variable text instead of getting it. Do I need to require certain VB files inorder to get this to work?
If somebody can help me, I would greatly appreciate it.
Thanks!
Admin
03-04-2002, 03:53 PM
<?php
error_reporting(7);
require('./global.php');
/* rest of your code here */
?>
That's the 'template' you should use for all vBulletin files. Requiring global.php actually gives you access to all the variables and database.
Gutspiller
03-04-2002, 04:05 PM
What's the error reporting part suppose to be? It looks like it made it a link? :confused:
EDIT: I just checked my file and I am requiring the global.php file. :confused:
Admin
03-04-2002, 04:13 PM
The link is just part of a hack, and error_reporting is a function to set the error reporting level. vBulletin uses 7 (E_ERROR | E_WARNING | E_PARSE) in all its scripts. You don't have to use it but you should.
Gutspiller
03-04-2002, 04:41 PM
Firefly I have included the global.php file in the frontpage.php file and it just shows the var instead of executing it and getting the "code" that is attached to the variable. Anything else?
About the "error_reporting(7);" So I just actually write out
"error_reporting(7);"
It just seemed a little weird since it was so plain. (I thought the php code tag might of changed it.) :confused:
What other files can I include to get this to work?
Admin
03-04-2002, 04:44 PM
How are you using these variables?
Gutspiller
03-04-2002, 05:02 PM
<a href="http://www.theforumz.com/forumz/test.php" target="_blank">http://www.theforumz.com/forumz/test.php</a>
Upper left. Do I need to add more... stuff?
Admin
03-04-2002, 06:03 PM
How? :) i.e what code...
Gutspiller
03-04-2002, 06:18 PM
View source... duh. :)
<a href="http://www.theforumz.com/forumz/online.php"><b> $headeronline </b></a> Currently Online Users
Admin
03-04-2002, 06:20 PM
What PHP code?
Gutspiller
03-04-2002, 06:53 PM
Maybe I don't understand the quesiton?
If you want to know what code the $headeronline var calls here are the instructions written by you. :)
************************************************
** Number of online users in header / footer! **
************************************************
1. Add the following code to your phpinclude template (PHP-Parsed code):
************************************************** **********
// start - get online users (hack by firefly)
$datecut=time()-$cookietimeout;
$headerguests=$DB_site->query_first("SELECT COUNT(*) AS count FROM session WHERE userid=0 AND lastactivity>$datecut");
$headerusers=$DB_site->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM session WHERE session.userid>0 AND session.lastactivity>$datecut");
$headerguests=$headerguests[count];
$headerusers=$headerusers[count];
$headeronline=$headerguests+$headerusers;
// end - get online users (hack by firefly)
************************************************** **********
2. Save the template changes.
3. Place $headeronline wherever you want in either your header or footer templates to show number of online users. In addition, you can also use $headerguests to show number of online guests, or $headerusers to show number of online members.
Enjoy the hack. :-)
Is that what you wanted? :confused:
Admin
03-05-2002, 02:01 PM
*bangs head against nearest wall*
HOW are you using $headeronline?! In a template, file, echoing it, what?
Gutspiller
03-05-2002, 02:23 PM
Duh.... me likes VB.. :?:
:D
OK, well since I am still a complete noob and I have no idea what "echoing" even means, it's hard to answer your questions.
If you want to know how I am using it in my forum in my
forumdisplay_threadslist
file I added this line: <a href="http://www.theforumz.com/forumz/online.php"><b> $headeronline </b></a> Currently Online Users
Other than that I have given you everything I have done. The way I put it in the misc. php file that's in my forum directory, the instructions on how I got the users to be in a var from your instructions, the pages themselves, how I put it into forum pages.
If you want more you will have to convert your speaking to newbie terms, because I still don't understand. Is all I want it to do is make is to that my misc php file that I have in my forum directory to act like my forum templates and when I type $headeronline in my misc php file I don't want it to show "$headeronline", I want it to actually go get the number of people that were online.
Can you please help me to understand what you are saying and what I need to do?
(Sorry for being such a noob) :(
Thanks.
M.Smith
03-06-2002, 01:07 PM
err.... FireFly, how would i be able to call in templates like headinclude, header and footer?
Gutspiller
03-06-2002, 02:12 PM
Originally posted by Sn2
err.... FireFly, how would i be able to call in templates like headinclude, header and footer?
If you are looking to include the users online in your header, follow the instructions I posted of FireFly's in post 11 of this thread. ( https://vborg.vbsupport.ru/showthread.php?postid=225814#post225814 )
M.Smith
03-06-2002, 04:27 PM
no, i mean actually call a template into a misc php file that has global.php included.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.