Deprecated: Assigning the return value of new by reference is deprecated in /home/thomastr/codeIgniter/system/codeigniter/Common.php on line 85

Deprecated: Assigning the return value of new by reference is deprecated in /home/thomastr/codeIgniter/system/codeigniter/Common.php on line 91

A PHP Error was encountered

Severity: 8192

Message: Function set_magic_quotes_runtime() is deprecated

Filename: codeigniter/CodeIgniter.php

Line Number: 46


Notice: Use of undefined constant APPPATH - assumed 'APPPATH' in /home/thomastr/codeIgniter/system/database/DB.php on line 81

Notice: Use of undefined constant EXT - assumed 'EXT' in /home/thomastr/codeIgniter/system/database/DB.php on line 81

Warning: include(APPPATHerrors/error_phpEXT) [function.include]: failed to open stream: No such file or directory in /home/thomastr/codeIgniter/system/database/DB.php on line 81

Warning: include(APPPATHerrors/error_phpEXT) [function.include]: failed to open stream: No such file or directory in /home/thomastr/codeIgniter/system/database/DB.php on line 81

Warning: include() [function.include]: Failed opening 'APPPATHerrors/error_phpEXT' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/thomastr/codeIgniter/system/database/DB.php on line 81

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/thomastr/codeIgniter/system/codeigniter/Common.php:85)

Filename: libraries/Session.php

Line Number: 282

Introduction - Welcome - My Erkana implementation

Private

Contact

tomcode.com

0.0843 sec

Google tracked

Welcome

Introduction

This is my first implementation of Michael Wales Erkanaauth library, see

For this implementation I adapted it to my likes:

  1. The library is now a model
  2. I rearranged the if clauses inside the methodes.
  3. I do not use the helper
  4. The returns of try_login() and getUser() are now the same.

You can log in using admin / admin or test / test.

There is also a page in case cookies are disabled.

This application

A base application with static pages and user administration allows me to fast demo my client's projects.

It will become my replacement for UserAuth Mini-App of George Peccavio, which I am using until now.

My version of Michael Wales library

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
 
class 
Erkanaauth extends Model{
 
    var 
$db_table 'users';
    var 
$db_userid 'id';
    
    function 
Erkanaauth()
    {
    
        
parent::Model();
        
log_message('debug',
            
'Authorization class initialized (model Erkanaauth).');
    }
    
    
/**
     * Attempt to login using the given condition
     *
     * Accepts an associative array as input, containing login conditions
     * Example: 
     *     $conditions = array
     *     (
     *          'email'=>$email,
     *          'password'=>dohash($password)
     *     );
     *     $this->erkanaauth->try_login($conditions));
     *
     * @access public
     * @param  array login conditions
     * @return mixed boolean:false or object with user record
     */
    
function try_login($condition = array())
    {
        
$query $this->db->getwhere($this->db_table$condition10);
        
        if (
$query->num_rows != 1) return FALSE;
        
        
$row $query->row();
        
$this->session->set_userdata(array('user_id'=>$row->id));
        
        return 
$row;
    }

    
/** 
     * Multipurpose: Check logged state and have the current user info
     *
     * Copied from http://codeigniter.com/forums/viewthread/63423/P30/:
     * getUser() now returns a user's record and can be
     * used to determine login status as well as retrieving
     * user information. Right now it doesn’t support roles
     * (so if you use that system, add in a JOIN to the method below)
     * but it will when I actually release this version    
     *
     * @access public
     * @param  int the user id, defaults to session user_id
     * @return mixed boolean:false or object with user record
     */
    
function getUser($id FALSE)
    {
        if (
$id == FALSE$id $this->session->userdata('user_id');
        
        if (
$id == FALSE) return FALSE;
        
        
$condition = array(($this->db_table .'.' .$this->db_userid) =>$id);
        
        
$query $this->db->getwhere($this->db_table$condition10);
        
        
$row = ($query->num_rows() == 1) ? $query->row() : FALSE;
        
        return 
$row;
        }
    
    
/**
     * Logs a user out
     *
     * Example: $this->erkanaauth->logout()
     *
     * @access    public
     * @return    void
     */
     
function logout()
    {
        
$this->session->set_userdata(array('user_id'=>FALSE));
    }
 }
 
 
?>