View Full Version : Building a hack
pgowder
11-16-2001, 06:10 PM
I'm starting an application for my site which will use some of the vB tables like users.
When I write my php code, what do I need to include to track user sessions, use the colors and styles of my vb, etc?
thanks
Admin
11-16-2001, 06:22 PM
<?php
require('global.php');
?>
That PHP code is 100% powered by vBulletin.
That's all there is to it really. :)
Just make sure it's in the same folder as the rest of vBulletin's files.
Otherwise, you'll need to add a chdir() command before requiring global.php, for example:
chdir("/full/path/to/you/forum");
pgowder
11-16-2001, 06:47 PM
Great, thanks!
couldnt you just do this:
<?php
require('/full/path/to/you/forum/global.php');
?>
heh. just wondering.
Palmer ofShinra
11-17-2001, 10:44 PM
No, because Global.php references several other files on a relative path from the current directory, not the directory global.php is in.
If you were in www/ and specified the path /board/global.php
It looks for ./admin/functions.php
In this case, it would expect to find it at www/admin/functions.php
I found this out the hard way.
Admin
11-18-2001, 05:05 AM
Exactly.
You can only include files like that if they are independent.
pgowder
11-28-2001, 04:39 PM
I'm a little further in my design now.
I'm building an event calendar. I want to allow users to rate the event. And of coure limit it to only members and once per users.
What do I need to do to check to see if a person is logged in?
And if not, so them a log in screen?
thanks
Admin
11-28-2001, 04:41 PM
if ($bbuserinfo[userid]==0) {
// show_nopermission();
} else {
// ok
}
pgowder
11-28-2001, 05:12 PM
Ok, just tried that.
I placed the code below on a page.
<?
chdir("/home/sites/home/web/gathering");
require('global.php');
if ($bbuserinfo[userid]==0) {
// show_nopermission();
} else {
// ok
}
chdir("/home/sites/home/web/gathering/pw_calendar");
?>
When I am logged in, no problems.
When I am not logged in, I get the following error:
Warning: Cannot add header information - headers already sent by (output started at /home/sites/home/web/gathering/pw_calendar/pw_event_rate.php:9) in /home/sites/home/web/gathering/admin/functions.php on line 1459
pgowder
11-28-2001, 05:14 PM
Just upgraded to 2.2.1
Still having the error.
thanks
pgowder
11-28-2001, 06:34 PM
It now gives the error whether I'm logged in or not.
tubedogg
11-29-2001, 05:00 AM
Remove the // in front of show_nopermission() for starters. Then remove any white space before the <? or after the ?> in your file.
pgowder
11-29-2001, 11:35 AM
Ok, here is what I have now:
<?
chdir("/home/sites/home/web/gathering");
require('global.php');
if ($bbuserinfo[userid]==0) {
show_nopermission();
} else {
print ('It worked'."\n");
}
?>
Still getting the same error??
Thanks
pgowder
01-04-2002, 06:34 PM
I'm trying to do the following, where am I going wrong:
<?
require('global.php');
if ($bbuserinfo[userid]==0) {
show_nopermission();
} else {
$q= "SELECT * FROM user";
$r= mysql_query($q) or die(mysql_error());
$row=mysql_fetch_object($r);
print (' '.$row->userid.' ');
}?>
pgowder
01-04-2002, 06:37 PM
Nevermind, it works.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.