View Single Post
  #3  
Old 06-08-2010, 05:04 AM
30et 30et is offline
 
Join Date: Mar 2009
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for that. I got it working. Here is the code in case it can help others -
PHP Code:
// connect to db
include $_SERVER['DOCUMENT_ROOT'] . '/forums/includes/config.php';
$DB_SERVER = $config['MasterServer']['servername']; ///mysql server
$DB_LOGIN =  $config['MasterServer']['username']; /// Database Login - You have to give login name for DB
$DB_PASSWORD = $config['MasterServer']['password']; /// Database Password
$DB_DATABASE = $config['Database']['dbname']; ////Database name
$DB_PREFIX = $config['Database']['tableprefix'];
$vip_con=mysql_connect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD) or die ('Cannot connect to the database.');
mysql_select_db ($DB_DATABASE);

// get if logged in from db
$vip_sql = "SELECT s.loggedin, u.username, u.userid, u.salt FROM " . $DB_PREFIX .  "session s INNER JOIN " . $DB_PREFIX .  "user u ON s.userid = u.userid WHERE sessionhash = '" . $_COOKIE['bb_sessionhash'] . "'"  ;
$vip_result = mysql_query($vip_sql) or die ('query not working'.mysql_error());
$row = mysql_fetch_array( $vip_result );
$vip_loggedin = $row['loggedin'];
$vip_username = $row['username'];
$TIMENOW = time();
$vip_cookie_salt = 'Cc26QdsovANkeY3pRPt36wERQP'; // this is copied from forums/includes/functions.php
 
// create logouthash 
$vip_securitytoken_raw = sha1($row['userid'] . sha1($row['salt']) . sha1($vip_cookie_salt));
$vip_securitytoken = $TIMENOW . '-' . sha1($TIMENOW . $vip_securitytoken_raw);

$vip_logouthash =& $vip_securitytoken;

// close db connection
mysql_close($vip_con);



if ($vip_loggedin!=0) {
?>
<p>You're logged in as <b><?php  echo $vip_username?></b></p>
<a class="more_info" href="/forums/login.php?<?php echo $session[sessionurl]; ?>do=logout&amp;logouthash=<?php echo $vip_logouthash?>">Log Out</a>
--------------- Added [DATE]1275978418[/DATE] at [TIME]1275978418[/TIME] ---------------

Oh yeah I should mention if you've got other db connections open you might need to do this to seperate the vb db connection.
Change
PHP Code:
$vip_con=mysql_connect ($DB_SERVER$DB_LOGIN$DB_PASSWORD) or die ('Cannot connect to the database.');
mysql_select_db ($DB_DATABASE); 
to
PHP Code:
$vip_con=mysql_connect ($DB_SERVER$DB_LOGIN$DB_PASSWORDtrue) or die ('Cannot connect to the database.');
mysql_select_db ($DB_DATABASE$vip_con); 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01479 seconds
  • Memory Usage 1,779KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete