-
Notifications
You must be signed in to change notification settings - Fork 0
Vb auth
Authentication library for CodeIgnited vBulletin extensions
Inspired by Pat Andrew's vBuser_-_vBulletin_based_Auth_Library package
Author: [url=http://codeigniter.com/forums/member/155463/]MiklosK[/url]
[h3]Introduction[/h3]
Vb_auth library is useful to create, maintain or utilize user sessions authenticated against pre-installed vBulletin installations in the same domain.
It can be used in situations like this:
http://example.com/ // domain root or your CodeIgniter Project
http://example.com/myci // optional place for your CodeIgniter project root
http://example.com/forums // your vBulletin installation[h3]Features[/h3] [h4]Session cookie authorization[/h4] Recognizes valid vBulletin session cookies and picks up their corresponding user data from vBulletin's user table. [h4]Permanent cookie authorization[/h4] Recognizes valid vBulletin permanent cookies ('remember me') and creates a valid session for the corresponding user. [h4]Session info push[/h4] In case of a logged in user, vb_auth sends user activity messages to vBulletin's session table, allowing it to be visible in vB admin panel
[h3]Download source:[/h3]
[url=http://github.com/MiklosK/Vb_auth]Vb_auth on github[/url]
[h3]Installation:[/h3]
[h4]Step 1.[/h4] Drop the project files to their respective folders in your CI project
[h4]Step 2.[/h4] Edit your config/vb_auth.php by adding the proper vBulletin license info and the location of your installed vBulletin forum:
$config['vb_auth']['vblicense'] = 'YOUR VB LINCESE KEY';
$config['vb_auth']['forum_url'] = 'http://example.com/forums/';[h4]Step 3.[/h4] Edit your config/database.php by adding a secondary database definition like this:
$db['vbulletin']['hostname'] = "localhost";
$db['vbulletin']['username'] = "username";
$db['vbulletin']['password'] = "password";
$db['vbulletin']['database'] = "database";
$db['vbulletin']['dbdriver'] = "mysql";
$db['vbulletin']['dbprefix'] = "vb_";
$db['vbulletin']['pconnect'] = FALSE; // don't use persistent db connections
$db['vbulletin']['db_debug'] = TRUE;
$db['vbulletin']['cache_on'] = FALSE;
$db['vbulletin']['cachedir'] = "";
$db['vbulletin']['char_set'] = "utf8";
$db['vbulletin']['dbcollat'] = "utf8_general_ci";[b]Important![/b] Make sure that you reconfigure your default database [b]not to use persistent database connection[/b] otherwise CI will not be able to handle this dual DB solution.
[h4]Step 4.[/h4] Optional, but recommended to autoload vb_auth in your config/autoload.php like this:
$autoload['libraries'] = array('database','vb_auth');[h3]How to use[/h3] Once you installed and properly configured vb_auth, you can simply use it anywhere in your application.
vb_auth->is_logged_in() returns true if a valid vB session is detected vb_auth->info contains the data of the current user vb_auth->is_admin() returns true if the current user is a vB admin
[h3]Examples[/h3] [h4]In a controller[/h4]
if( $this->vb_auth->is_logged_in()){
$data['user']$this->vb_auth->username;
$this->load->view('logged_in_as',$data);
} else {
$this->load->view('not_logged_in');
} [h4]In a view[/h4]
<?php
$CI =& get_instance();
if ( ! $CI->vb_auth->is_logged_in()) {
$this->load->view('blocks/vb_login_box');
} else {
$data['username'] = $CI->vb_auth->info['username'];
$this->load->view('blocks/vb_logout_box',$data);
}
?>- Original author: Derek Jones
- How to extend helpers: See User Guide
- Modified by: Thomas Stapleton (id, classes, selected country option and all option)
- Modified by: Bradley De-Lar (construct, setLayout example)