PDA

View Full Version : Using the User DB table for another application


Tom Freeman
01-14-2005, 08:41 AM
Hi,
I need some help. I have the lastest version or the forums (3) running on my server and I have a large database of users. I am now developing a new application but I only want to have ONE login, and basically use the login information and users from the forum. I presume this is possible.

I can see the information in the users table in the database. My question is really how are the sessions done when a user logs in? I'm pretty new to the PHP code for the forum and haven't done any hacks to it yet, so wondered if anyone could point me in the right direction.

Can I just query $_SESSION['username'] or something like that? Would be nice if it was that simple :ninja:

Thanks,
Tom

Tekton
01-14-2005, 08:47 AM
I'd just require_once(path/global.php); or something in the php file.

Tom Freeman
01-14-2005, 10:10 AM
I'd just require_once(path/global.php); or something in the php file.

ok thanks, can you ellaborate a little bit? If I require the global.php file then what? Is there a variable somewhere I can query against to see if the user is logged in? And if so what their username is?

THanks for the help, i'm a bit confused :o

Andreas
01-14-2005, 10:17 AM
$bbuserinfo['userid] and $bbuserinfo['username']

If you want to be independent from vBulletin backend you must (if existant) check the cookies bbuserid and bbpassword against the user table.
Or the username and password entered in your application, if it also does provide login.

Tekton
01-14-2005, 10:23 AM
ok thanks, can you ellaborate a little bit? If I require the global.php file then what? Is there a variable somewhere I can query against to see if the user is logged in? And if so what their username is?

THanks for the help, i'm a bit confused :o
Then you can do anything you could in vBulletin pages basically (unless you needed to require some of the functions).

i.e. after grabbing the file make them login which is something like....

require_once(~path~/global.php);
if($bbuserinfo[userid]==0){print_no_permission();}


I can't remember off hand if that will work, but it might.

Tom Freeman
01-14-2005, 11:23 AM
ok thanks, that makes sense, i'll give it a go.

One more thing though, I have my forum running under /forums/ on my server. My other application is running under /apd/. Do I have to move this to /forums/apd/ because I tried require_once('../forums/global.inc'); and it gave me this error.

Warning: main(./includes/init.php): failed to open stream: No such file or directory in /home/gadseek/public_html/forums/global.php on line 50

Fatal error: main(): Failed opening required './includes/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/gadseek/public_html/forums/global.php on line 50

I guess this is probably because under a different directory right?

Tekton
01-14-2005, 11:27 AM
something like...

chdir('../forums');
require('global.php');
chdir('../apd');


Is that how to do it?

Tom Freeman
01-14-2005, 11:43 AM
cheers that does work, thanks! :)

Although having problems now because the login form it redirects me to tries to run login.php under the /apd/ directory. But I will sort that by hardcoding the form action to be /forums/login.php, rather than just login.php, which should sort it. Will just have to remember I changed that if I ever move the forums.

Next problem though is finding where in the distribution the form HTML code is! :) sure I will find it eventually.

Tom Freeman
01-14-2005, 12:01 PM
ok I give up. Where can I find the HTML code which is generated on call to print_no_permission(); so I can edit the form action='login.php' to be form action='/forums/login.php'

Is it even stored on disk as a file, or in the database?

Cheers,

Marco van Herwaarden
01-14-2005, 12:21 PM
Check out the includes/functions.php

You will find the print_no_permission function there.