Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2004, 07:30 PM
pgowder's Avatar
pgowder pgowder is offline
 
Join Date: Nov 2001
Location: West Columbia, SC
Posts: 537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Calling vb username in another app

I know that I can require global.php and then call variables like $bbuserid and $bbusername. I've done that on pages I've built before.

What I need now is to pre-populate the form of another app. It's a recipe sharing script.

Here:

www.powwows.com/gathering/cookbook

I want to have the name and email prepopulated on the add recipe page.

I've trying adding require global.php and putting it in the main vb directory, but that apparently messes up it's internal mysql statements.

Is there another way I can call the information from the cookies? Or some other way??

Thanks
Reply With Quote
  #2  
Old 02-26-2004, 07:42 PM
vbmechanic vbmechanic is offline
 
Join Date: Jan 2004
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try leaving it in it's original directory and changing directories to vB before calling global.

chdir ('../forum');
require_once ('./global.php');

etc. where the first line contains the relative path to the forums.
Reply With Quote
  #3  
Old 02-26-2004, 07:48 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, you can avoid using global.php.

The important cookies are bbuserid and bbpassword.

If you have these cookies you can verify if the combination is valid and retrieve the username from table user.

For vB3
PHP Code:
$userid intval($_COOKIE[bbuserid]);
$password addslashes($_COOKIE[bbpassword]);
$result mysql_query("SELECT username, userid FROM user WHERE userid=$userid AND MD5(CONCAT(password, 'LicenseNo')) = '$password'");
$user mysql_fetch_array($result);
if (
$user[userid])
  
// valid
else
  
// invalid 
Please note that LicenseNo must be replaced with you vB license number.
You must also make sure that you have selected the correct database before executing this query, if your other tables are in another database.
Reply With Quote
  #4  
Old 02-26-2004, 09:59 PM
pgowder's Avatar
pgowder pgowder is offline
 
Join Date: Nov 2001
Location: West Columbia, SC
Posts: 537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vbmechanic
Try leaving it in it's original directory and changing directories to vB before calling global.

chdir ('../forum');
require_once ('./global.php');

etc. where the first line contains the relative path to the forums.
Will I need to change it back to the orignal directory after I call global?
Reply With Quote
  #5  
Old 02-26-2004, 10:00 PM
pgowder's Avatar
pgowder pgowder is offline
 
Join Date: Nov 2001
Location: West Columbia, SC
Posts: 537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
Yes, you can avoid using global.php.

The important cookies are bbuserid and bbpassword.

If you have these cookies you can verify if the combination is valid and retrieve the username from table user.

For vB3
PHP Code:
$userid intval($_COOKIE[bbuserid]);
$password addslashes($_COOKIE[bbpassword]);
$result mysql_query("SELECT username, userid FROM user WHERE userid=$userid AND MD5(CONCAT(password, 'LicenseNo')) = '$password'");
$user mysql_fetch_array($result);
if (
$user[userid])
  
// valid
else
  
// invalid 
Please note that LicenseNo must be replaced with you vB license number.
You must also make sure that you have selected the correct database before executing this query, if your other tables are in another database.
Will this work in vB 2.x??
Reply With Quote
  #6  
Old 02-26-2004, 10:45 PM
vbmechanic vbmechanic is offline
 
Join Date: Jan 2004
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

>>Will I need to change it back to the orignal directory after I call global?

Always a good idea, I meant to add that in my original reply.
Reply With Quote
  #7  
Old 02-26-2004, 11:14 PM
pgowder's Avatar
pgowder pgowder is offline
 
Join Date: Nov 2001
Location: West Columbia, SC
Posts: 537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
Yes, you can avoid using global.php.

The important cookies are bbuserid and bbpassword.

If you have these cookies you can verify if the combination is valid and retrieve the username from table user.

For vB3
PHP Code:
$userid intval($_COOKIE[bbuserid]);
$password addslashes($_COOKIE[bbpassword]);
$result mysql_query("SELECT username, userid FROM user WHERE userid=$userid AND MD5(CONCAT(password, 'LicenseNo')) = '$password'");
$user mysql_fetch_array($result);
if (
$user[userid])
  
// valid
else
  
// invalid 
Please note that LicenseNo must be replaced with you vB license number.
You must also make sure that you have selected the correct database before executing this query, if your other tables are in another database.
I ended up using this and it worked great!!

Anyway to force the nopermission function with this?

Thanks!
Reply With Quote
  #8  
Old 02-27-2004, 05:42 PM
pgowder's Avatar
pgowder pgowder is offline
 
Join Date: Nov 2001
Location: West Columbia, SC
Posts: 537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok that didn't work exactly how I needed. The two apps are in different databases. So I'm using this code

PHP Code:
//connect to database
$hostname "localhost";
$username "username";
$password "password";
$dbName "vBulletin";
$conn MYSQL_CONNECT($hostname,$username,$password) or die(mysql_error());
@
mysql_select_db("$dbName") or die("Unable to select database");

$userid intval($_COOKIE[bbuserid]);
$password addslashes($_COOKIE[bbpassword]);
$result mysql_query("SELECT username, userid FROM user WHERE userid=$userid AND MD5(CONCAT(password, 'licensenumber')) = '$password'");
$user mysql_fetch_array($result); 
Whenc I call $userid I get the right user id of the person logged in. But if I call $username I get the username used to log into MySQL not the vBulletin user???
Reply With Quote
  #9  
Old 02-27-2004, 06:07 PM
pgowder's Avatar
pgowder pgowder is offline
 
Join Date: Nov 2001
Location: West Columbia, SC
Posts: 537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Shouldn't this work?? I get userid, but no username??


PHP Code:
<?

//bbusername

//connect to database
$hostname = "localhost";
$dbusername = "username";
$password = "password";
$dbName = "vBulletin";
$conn = MYSQL_CONNECT($hostname,$dbusername,$password) or die(mysql_error());
@mysql_select_db("$dbName") or die("Unable to select database");

$userid = intval($_COOKIE[bbuserid]);
$password = addslashes($_COOKIE[bbpassword]);
$result = mysql_query("SELECT username, userid FROM user WHERE userid=$userid AND MD5(CONCAT(password, 'licensenumber')) = '$password'");
$user = mysql_fetch_array($result);

echo $userid;
echo $username;
echo $user["username"]
?>
Reply With Quote
  #10  
Old 02-27-2004, 06:12 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This should work.
Did you check that both cookies are set?
Did you put in the correct license number (you can verify this on top of each PHP file)?
Is $user[userid] set ($userid doesn't mean anything, as this will always be the value from the cookie if set)?

You should add $conn as a second parameter to mysql_query()
Reply With Quote
Reply

Thread Tools
Display Modes

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 06:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06727 seconds
  • Memory Usage 2,273KB
  • 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
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete