CL Auth [BETA] v0.2.5 - El Forum - 10-10-2008
[eluser]Tony Nash[/eluser]
Sorry.. Since FAL was seems dead for many weeks I thought migrating to CL Auth. But my complain about CL_Auth is lack of documentation. Most of the doc pages say "Not finished yet...". Even the heart of the CL Auth (URI Auth?) has no complete documentation :-( (except the what you have on this forum) is that all about?
How soon we can expect any joy on this regard.
CL Auth [BETA] v0.2.5 - El Forum - 10-13-2008
[eluser]Unknown[/eluser]
I have a problem when reading cl_auth config file. I'm using diffrent folder for application it looks like that:
CI
./main/
./admin/
./system/
in ./main/ dir I have CL_auth core library and config file. When I load CL_AUTH it throw datebase error and Says that my CL_AUTH is turned off i tried to debug it seems that cl_auth config file isn't loaded.... I tried to load it manualy but nothing happens... Any ideas?
CL Auth [BETA] v0.2.5 - El Forum - 10-13-2008
[eluser]Unknown[/eluser]
[quote author="FlashUK" date="1222192536"]Also, if anyone is using CL Auth on their website, I would like to know! I want to create a list of links in the documentation to websites who have implemented this library. Please just post a link to your website here and I will add it [/quote]
First of all - thanks for providing such a great system! It made developing my project so much easier and faster. 
I am using CL Auth on my movie quotes site - http://www.KazeQuotes.com
Keep up the good work.
CL Auth [BETA] v0.2.5 - El Forum - 10-24-2008
[eluser]Jelmer[/eluser]
Hey FlashUK,
With CI 1.7 just out I'd like to upgrade but I remembered you made changes to the Session.php, how hard is it to make the new Session.php compatible with CL Auth?
UDPATE: I made an overview of the diffences between the CI 1.6.3 Session.php and the CL_Auth Session.php - if I get round to updating to CI 1.7 and trying to get everything to work with the new Session.php, I'll let you know how it turns out
Code: ==========================================================================
function CI_Session()
==========================================================================
--------------------------------------------------------------------------
ADD AFTER "$this->CI =& get_instance();"
--------------------------------------------------------------------------
// CL_Auth config settings
$this->track_activity = $this->CI->config->item('track_activity');
$this->regen = $this->CI->config->item('regen')
==========================================================================
function sess_run()
==========================================================================
--------------------------------------------------------------------------
ADD AFTER introduction comments
--------------------------------------------------------------------------
if (is_numeric($this->CI->config->item('sess_time_to_update')))
{
$this->time_to_update = $this->CI->config->item('sess_time_to_update');
}
--------------------------------------------------------------------------
CHANGE ELSE STATEMENT AFTER if ( ! $this->sess_read()) { $this->sess_create(); }
--------------------------------------------------------------------------
// Activity Function for CL_Auth
if ( $this->userdata['session_user_id'] != 0 AND $this->CI->config->item('CL_Auth') === TRUE AND
$this->track_activity === TRUE )
{
$this->CI->load->model('cl_auth/users', 'users');
$active = $this->now - $this->userdata['last_activity'];
$this->CI->users->update_activity($this->userdata['session_user_id'], $active);
$this->sess_update();
}
// We only update the session every five minutes
elseif (($this->userdata['last_activity'] + $this->time_to_update) < $this->now)
{
$this->sess_update();
}
==========================================================================
function sess_read()
==========================================================================
--------------------------------------------------------------------------
MANY DIFFERENCES, ONLY THING IMPORTANT TO CL_AUTH WAS THE FOLLOWING I THINK
ADD BEFORE THE CHECK "$query->num_rows() == 0"
--------------------------------------------------------------------------
// This section of code is new
if ( $this->CI->config->item('CL_Auth') === TRUE )
{
$users_table = $this->CI->config->item('CL_table_prefix').$this->CI->config->item
('CL_users_table');
$this->CI->db->from($this->session_table);
$this->CI->db->join($users_table, $users_table.'.id = '.$this-
>session_table.'.session_user_id', 'left');
$query = $this->CI->db->get();
}
else
{
// Normal session query
$query = $this->CI->db->get($this->session_table);
}
==========================================================================
function sess_create()
==========================================================================
--------------------------------------------------------------------------
SOME DIFFERENCE, NOT IMPORTANT TO CL_AUTH I THINK?
--------------------------------------------------------------------------
==========================================================================
function sess_update()
==========================================================================
--------------------------------------------------------------------------
REPLACE THE STATEMENT if ($this->use_database === TRUE) { [...] }
--------------------------------------------------------------------------
// format query array to update database
$ud = $this->userdata;
$sql_ary = array(
'session_id' => $new_sessid,
'session_user_id' => $ud['session_user_id'],
'last_page' => $this->CI->uri->uri_string(), // Grab current page they are on
'last_activity' => $ud['last_activity']);
unset($ud['session_id'], $ud['session_user_id'], $ud['last_page'], $ud['last_activity'], $ud
['user_agent'], $ud['ip_address']);
$sql_ary['session_data'] = serialize($ud);
$this->CI->db->query($this->CI->db->update_string($this->session_table, $sql_ary, array
('session_id' => $old_sessid)));
==========================================================================
function set_userdata()
==========================================================================
--------------------------------------------------------------------------
ORIGINAL USES sess_write() AT THE END, BUT THE CL_AUTH USES sess_update()?
--------------------------------------------------------------------------
==========================================================================
function unset_userdata()
==========================================================================
--------------------------------------------------------------------------
SAME DIFFERENCE AS set_userdata()
--------------------------------------------------------------------------
==========================================================================
function _flashdata_sweep()
==========================================================================
--------------------------------------------------------------------------
CHANGED TO
--------------------------------------------------------------------------
function _flashdata_sweep()
{
$i=0;
$userdata = $this->all_userdata();
foreach ($userdata as $key => $value)
{
if (strpos($key, ':old:'))
{
unset($this->userdata[$key]);
$i++;
}
}
if ($i > 0)
CL Auth [BETA] v0.2.5 - El Forum - 10-24-2008
[eluser]blewis[/eluser]
I just started with CI about a week ago and just upgraded to 1.7 today since my app is pretty basic at this point. I was looking at CL Auth, but clearly it will need an update for CI 1.7. Hopefully that can happen soon! CL looks very nice though.
Thanks,
Bryan
CL Auth [BETA] v0.2.5 - El Forum - 10-25-2008
[eluser]dexcell[/eluser]
[quote author="Jelmer" date="1224864954"]Hey FlashUK,
With CI 1.7 just out I'd like to upgrade but I remembered you made changes to the Session.php, how hard is it to make the new Session.php compatible with CL Auth?
UDPATE: I made an overview of the diffences between the CI 1.6.3 Session.php and the CL_Auth Session.php - if I get round to updating to CI 1.7 and trying to get everything to work with the new Session.php, I'll let you know how it turns out
[/quote]
I'm looking forward to it since i also think this is a good library after tried it.
And I hope maybe you can release unofficial CLAuth which do not need to hack CI core sessions.php
CL Auth [BETA] v0.2.5 - El Forum - 10-25-2008
[eluser]bigdaddysheikh[/eluser]
I am loving the CL auth updates man. Keep up the good work.
Just a question, I know this works with get vanilla forum, Anyone try this for other forum apps i.e. phpbb Vbulletin?
CL Auth [BETA] v0.2.5 - El Forum - 10-28-2008
[eluser]FlashUK[/eluser]
Hi everyone. I realise that there is a problem with CL Auth and the new version of CI 1.7. I shall have a look into the code problems and possibly update some of the functions.
The sessions class is different because it stores more information about the user in the DB.
If someone wants to release an unofficial version then please go ahead, I will not be offended by it (would actually welcome it). Finding it hard to make time to update this library.
[quote author="bigdaddysheikh" date="1224981538"]I am loving the CL auth updates man. Keep up the good work.
Just a question, I know this works with get vanilla forum, Anyone try this for other forum apps i.e. phpbb Vbulletin?[/quote]
Getting any library to work with phpBB, vBulletin punBB, IPB etc. is a nightmare. I am afraid nobody has tried to integrate these forums with this library (yet).
CL Auth [BETA] v0.2.5 - El Forum - 10-28-2008
[eluser]Jelmer[/eluser]
I'm actually thinking about doing a full rewrite pretty seriously, won't have the time to take a pass at it for another 2/3 weeks though. One of the more important things in my eyes is to remove the need for an altered Sessions.php, and make it use only AR functions and no custom queries. Also I'd like to add support for directories, which would probably mean that the group_uri would either use the real url (instead of the controler name) or try to determine the controler's directory.
FlashUK would you be open to questions about the choices you made by email? Also I'm interpreting your post as permission to do this, since I'll probably copy-paste most of the code. (And you'll get the main credit if that's the way it turns out)
On actually doing this: I'm promissing nothing except that I'll make my rewrite public if I make one.
CL Auth [BETA] v0.2.5 - El Forum - 11-03-2008
[eluser]Paul Apostol[/eluser]
So, what can I say. I made some changes to CL lib to use 1.7.0 CI Session lib. This is the code:
Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
*/
require_once BASEPATH.'libraries/Session.php';
class CL_Session extends CI_Session{
var $sess_table_fields = array('session_user_id', 'session_id', 'ip_address',
'user_agent', 'last_page', 'last_activity');
var $sess_user_data = 'session_data';
function cookie_create($sessid){
return array(
'session_id' => $sessid,
'last_activity' => $this->now
);
}
function sess_load_data($session, $row)
{
$ses_ary = array(
'session_user_id' => $row->session_user_id,
'ip_address' => $row->ip_address,
'user_agent' => $row->user_agent,
'last_page' => $row->last_page,
'last_activity' => $row->last_activity,
// Overwrite important session_data vars with the DB record
'user_id' => $row->session_user_id,
'username' => $row->username,
'group_id' => $row->group_id
// Add your additional fields here...
);
return array_merge( $session, $ses_ary);
}
function sess_create_fields($sessid)
{
$this->userdata = array(
'session_id' => md5(uniqid($sessid, TRUE)),
'session_user_id' => 0,
'ip_address' => $this->CI->input->ip_address(),
'user_agent' => substr($this->CI->input->user_agent(), 0, 149),
'last_page' => $this->CI->uri->uri_string(),
'last_activity' => $this->now
);
return $this->userdata;
}
function sess_update_fields($sessid, $ud)
{
$sql_ary = array(
'session_id' => $sessid,
'session_user_id' => $ud['session_user_id'],
'last_page' => $this->CI->uri->uri_string(),
'last_activity' => $ud['last_activity']);
foreach($this->sess_table_fields as $v)
unset($ud[$v]);
$sql_ary[$this->sess_user_data] = serialize($ud);
return $sql_ary;
}
function CL_Session()
{
log_message('debug', "Session Class Initialized");
// Set the super object to a local variable for use throughout the class
$this->CI =& get_instance();
// CL_Auth config settings
$this->track_activity = $this->CI->config->item('track_activity');
$this->regen = $this->CI->config->item('regen');
// Set all the session preferences, which can either be set
// manually via the $params array above or via the config file
foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name',
'sess_expiration', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name',
'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix',
'encryption_key') as $key)
{
$this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
}
// Load the string helper so we can use the strip_slashes() function
$this->CI->load->helper('string');
// Do we need encryption? If so, load the encryption class
if ($this->sess_encrypt_cookie == TRUE)
{
$this->CI->load->library('encrypt');
}
// Are we using a database? If so, load it
if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
{
$this->CI->load->database();
}
// Set the "now" time. Can either be GMT or server time, based on the
// config prefs. We use this to set the "last activity" time
$this->now = $this->_get_time();
// Set the session length. If the session expiration is
// set to zero we'll set the expiration two years from now.
if ($this->sess_expiration == 0)
{
$this->sess_expiration = (60*60*24*365*2);
}
// Set the cookie name
$this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name;
// Run the Session routine. If a session doesn't exist we'll
// create a new one. If it does, we'll update it.
if ( ! $this->sess_read())
{
$this->sess_create();
}
else
{
// Activity Function for CL_Auth
if ( $this->userdata['session_user_id'] != 0 AND
$this->CI->config->item('CL_Auth') === TRUE AND $this->track_activity === TRUE )
{
$this->CI->load->model('cl_auth/users', 'users');
$active = $this->now - $this->userdata['last_activity'];
$this->CI->users->update_activity($this->userdata['session_user_id'], $active);
$this->sess_update();
}
else {
//end CL_Auth
$this->sess_update();
/////////////////CL_Auth start
}
//end CL_Auth
}
// Delete 'old' flashdata (from last request)
$this->_flashdata_sweep();
// Mark all new flashdata as old (data will be deleted before next request)
$this->_flashdata_mark();
// Delete expired sessions if necessary
$this->_sess_gc();
log_message('debug', "Session routines successfully run");
}
will be contiuned in the next post
|