Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2005, 08:41 AM
Tom Freeman Tom Freeman is offline
 
Join Date: Jan 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using the User DB table for another application

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
Reply With Quote
  #2  
Old 01-14-2005, 08:47 AM
Tekton Tekton is offline
 
Join Date: Jun 2004
Location: Wisconsin
Posts: 362
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd just require_once(path/global.php); or something in the php file.
Reply With Quote
  #3  
Old 01-14-2005, 10:10 AM
Tom Freeman Tom Freeman is offline
 
Join Date: Jan 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tekton
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
Reply With Quote
  #4  
Old 01-14-2005, 10:17 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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.
Reply With Quote
  #5  
Old 01-14-2005, 10:23 AM
Tekton Tekton is offline
 
Join Date: Jun 2004
Location: Wisconsin
Posts: 362
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tom Freeman
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
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....

PHP Code:
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.
Reply With Quote
  #6  
Old 01-14-2005, 11:23 AM
Tom Freeman Tom Freeman is offline
 
Join Date: Jan 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #7  
Old 01-14-2005, 11:27 AM
Tekton Tekton is offline
 
Join Date: Jun 2004
Location: Wisconsin
Posts: 362
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

something like...
PHP Code:
chdir('../forums');
require(
'global.php');
chdir('../apd'); 
Is that how to do it?
Reply With Quote
  #8  
Old 01-14-2005, 11:43 AM
Tom Freeman Tom Freeman is offline
 
Join Date: Jan 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 01-14-2005, 12:01 PM
Tom Freeman Tom Freeman is offline
 
Join Date: Jan 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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,
Reply With Quote
  #10  
Old 01-14-2005, 12:21 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Check out the includes/functions.php

You will find the print_no_permission function there.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:15 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10085 seconds
  • Memory Usage 2,253KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete