vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Integration with vBulletin - user session authication (https://vborg.vbsupport.ru/showthread.php?t=148154)

mic2100 05-25-2007 10:00 PM

user session authication
 
hi,

I was trying to build a member area for my site and wanted to use the vbulliten login system for all the areas on my site, so I have written this code:

PHP Code:


//this is the connection string to the database where the vbulliten table are.
require_once('../Connections/conn_nadea.php');

//this code will allow viewing of a page if a user is currently logged into the 
//vbulletin forum and is not a guest user. if it detects that no user is logged
//in it will automatically send you to the forum home page where you can login
//or register as a new user.

$colname_rs_userid "-1";
if (isset(
$_COOKIE['bbsessionhash'])) {
  
$sessionid = (get_magic_quotes_gpc()) ? $_COOKIE['bbsessionhash'] : addslashes($_COOKIE['bbsessionhash']);
}
mysql_select_db($database_conn_nadea$conn_nadea);
$sql sprintf("SELECT userid FROM session WHERE sessionhash = '%s'"$sessionid);
$rs_userid mysql_query($sql$conn_nadea);
$row mysql_fetch_assoc($rs_userid);
$totalRows mysql_num_rows($rs_userid);

if(
$totalRows == and $row['userid'] == 0)
{

    
//this navigates to the forum login page
    
header('Location: ../forum/login.php');
    
    
mysql_free_result($rs_userid);

}
else
{

    
//this is where you page content should go.
    
echo "Page Content!!!";
    
    
mysql_free_result($rs_userid);
    


This will authicate any user that trys to access any page that you want protecting, if they are not currently logged into the forum then it will re-direct them to the forum. All you need to do is use this code at the top of the protected pages.

Hopfully this may be useful for somebody.

Robru 05-26-2007 06:58 AM

Thanks for this solution :)

amnesia623 05-26-2007 07:00 AM

uhh...yah it will be useful!!!

thanks!

Milad 05-26-2007 02:39 PM

This can be done better by including gloabal.php in your file. I think.


All times are GMT. The time now is 03:03 AM.

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.01701 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete