Part of the EllisLab Network
x
 
Create New Page
 View Previous Changes    ( Last updated by musikanter )

RA Auth

An authenication library from systemsos (Version 1.0) working.

Originally introduced here: http://codeigniter.com/forums/viewthread/71537/

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * @package    Rapidauth
 * @author        Darren Nolan -  Rapid Hosting - Based on Erkana: CodeIgniter Authorization Library
 * @copyright    Copyright (c) 2008, Rapid Hosting
  * @link        http://www.rapidhosting.com.au
 * @since        Version 1.0
 * @filesource
 */
 
class RA_Auth
{
    
var $CI;
    
    function 
RA_Auth()
    
{
        $this
->CI =& get_instance();
        
log_message('debug''RapidAuth class loaded');
        
        
$this->CI->load->database();
    
}
    
    
function check_login ($condition = array(), $table 'users'$select 'id')
    
{
        $this
->CI->db->select($select);
        
$query $this->CI->db->getwhere($table$condition10);
        if (
$query->num_rows != 1{
            
return FALSE;
        
else {
            $row 
$query->row();
            
$this->CI->ra_session->set_userdata(array('user_id' => $row->$select'authenticated' => 'TRUE'));
            return 
TRUE;
        
}
    }
    
    
function check_session ()
    
{
        
if ($this->CI->ra_session->userdata('user_id') AND $this->CI->ra_session->userdata('authenticated')=='TRUE'{
            
return TRUE;
        
else {
            
return FALSE;
        
}
    }
    
    
function logout ()
    
{
        $this
->CI->ra_session->unset_userdata('user_id');
        
$this->CI->ra_session->unset_userdata('authenticated');
        
$this->CI->ra_session->sess_destroy();
    
}
}
?> 

Category:Libraries -> Authentication