Permalink
Browse files

multiple bug fixes in the xsession library, improves and additional f…

…eatures/pages added to the sessions manager
  • Loading branch information...
xcaww committed Jul 11, 2011
1 parent 0d2f633 commit d50086b7023cf27ea5be3d158432b950d0fe7596
View
3 README
@@ -1,7 +1,7 @@
xSession
CodeIgniter Session Library
Developed by Blake J
-Version: beta
+Version: beta 0.2
Instructions
@@ -15,6 +15,7 @@ install -
user's and their session data. Import this into a database
* In '/application/config/config.php', set these variable:
- $config['base_url']
+ - $config['encryption_key']
- $config['xsession_session_table']
- $config['xsession_users_table']
* In '/applcation/config/database.php', set these variables:
View
@@ -1,3 +1,5 @@
RewriteEngine on
-RewriteCond $1 !^(index\.php|images|robots\.txt|css|js)
-RewriteRule ^(.*)$ /app/index.php/$1 [L]
+RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule ^(.*)$ index.php/$1 [L,QSA]
@@ -14,7 +14,7 @@
| path to your installation.
|
*/
-$config['base_url'] = 'http://localhost/';
+$config['base_url'] = "http://localhost/";
/*
|--------------------------------------------------------------------------
@@ -224,7 +224,7 @@
| MUST set an encryption key. See the user guide for info.
|
*/
-$config['encryption_key'] = '';
+$config['encryption_key'] = 'er#ER8>5;36def#E_DCF"{##F78@!_{as3+';
/*
|--------------------------------------------------------------------------
@@ -244,13 +244,13 @@
| 'sess_time_to_update' = how many seconds between CI refreshing Session Information
|
*/
-$config['sess_cookie_name'] = 'ci_cookie_login';
+$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
-$config['sess_use_database'] = TRUE;
-$config['sess_table_name'] = 'sessions';
-$config['sess_match_ip'] = TRUE;
+$config['sess_use_database'] = FALSE;
+$config['sess_table_name'] = 'ci_sessions';
+$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
@@ -279,7 +279,7 @@
| COOKIE data is encountered
|
*/
-$config['global_xss_filtering'] = FALSE;
+$config['global_xss_filtering'] = TRUE;
/*
|--------------------------------------------------------------------------
@@ -293,9 +293,9 @@
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.
*/
-$config['csrf_protection'] = FALSE;
-$config['csrf_token_name'] = 'csrf_test_name';
-$config['csrf_cookie_name'] = 'csrf_cookie_name';
+$config['csrf_protection'] = TRUE;
+$config['csrf_token_name'] = 'xsession_csrf_token';
+$config['csrf_cookie_name'] = 'xsession_csrf_cookie';
$config['csrf_expire'] = 7200;
/*
@@ -357,6 +357,7 @@
*/
$config['proxy_ips'] = '';
+
/*
|--------------------------------------------------------------------------
| xSession
@@ -372,5 +373,6 @@
$config['xsession_session_table'] = 'sessions';
$config['xsession_users_table'] = 'users';
$config['xsession_session_time'] = 180;
+
/* End of file config.php */
/* Location: ./application/config/config.php */
@@ -41,10 +41,10 @@
$active_group = 'default';
$active_record = TRUE;
-$db['default']['hostname'] = '127.0.0.1';
-$db['default']['username'] = 'user';
-$db['default']['password'] = 'pass';
-$db['default']['database'] = 'database';
+$db['default']['hostname'] = '';
+$db['default']['username'] = '';
+$db['default']['password'] = '';
+$db['default']['database'] = '';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
@@ -41,7 +41,53 @@ public function user(){
// edit/$function
public function edit(){
+ $this->xsession->gather_user_data();
+
+ if($this->uri->segment(3) == true){
+
+ switch($this->uri->segment(3)){
+
+ case 'user':
+ $this->load->model('user_data');
+ $data['user'] = $this->user_data->build_user_data($this->uri->segment(4));
+ $data['page_content'] = 'sessions_edit_user';
+ break;
+ case 'session';
+ //$this->load->model('session_data');
+ //$data['sessions'] = $this->session_data->build_session_data();
+ $data['page_content'] = 'sessions_edit_session';
+ break;
+ default:
+ redirect('sessions');
+ exit();
+ break;
+
+ }
+
+ }
+
+
+ $this->load->view('pagebits/page', $data);
+
}
+
+ // add
+ public function add_user(){
+
+ $this->xsession->gather_user_data();
+ $data['page_content'] = 'sessions_add_user';
+ $this->load->view('pagebits/page', $data);
+
+ }
+
+ // search
+ public function search(){
+
+ $this->xsession->gather_user_data();
+ $data['page_content'] = 'sessions_search';
+ $this->load->view('pagebits/page', $data);
+
+ }
}
@@ -345,7 +345,7 @@ function verify_login(){
$this->is_logging_in = true;
$this->object->db->where('username', $this->object->input->post('username'));
- $this->object->db->where('password', md5($this->object->input->post('password')));
+ $this->object->db->where('password', md5($this->object->input->post('password') . $this->object->config->item('encryption_key')));
$query = $this->object->db->get($this->object->config->item('xsession_users_table'));
if($query->num_rows == 1){
@@ -34,6 +34,7 @@ function build_user_data($user_id){
foreach($query->result_array() as $row_data){
+ $user['sessions'][$i]['user_id'] = $row_data['user_id'];
$user['sessions'][$i]['session_id'] = $row_data['session_id'];
$user['sessions'][$i]['ip_address'] = $row_data['ip_address'];
$user['sessions'][$i]['user_agent'] = $row_data['user_agent'];
@@ -4,7 +4,7 @@
<div id="login_form">
- <h1>Sign In</h1>
+ <h1 style="display: block";>Sign In</h1>
<?php
echo form_open('login/authenticate');
$username_input = array('name' => 'username', 'id' => 'username_field', 'value' => 'username', 'type' => 'text', 'onclick' => "removeText(this.id)");
@@ -1,6 +1,6 @@
<div id="footer">
- <p style="text-align: right; margin-bottom: 15px;"><?php if($this->uri->segment(1) != 'login'){ echo anchor('login/quit', 'logout'); } ?></p>
+ <p style="text-align: right; margin-bottom: 15px;"><?php if($this->uri->segment(1) == 'sessions'){ echo anchor('login/quit', 'logout'); } ?></p>
<p>xSession Library</p>
<p>&copy; 2011 Blake J</p>
<p class="powered_by">Powered by <a href="http://codeigniter.com/">CodeIgniter <img src="<?php echo base_url(); ?>images/ci.png" width="20" height="22" /></a></p>
@@ -0,0 +1 @@
+<div id="page_buttons"> <a href="<?php echo base_url(); ?>sessions/add_user"><div class="add" width="20px" height="20px" alt="add">&nbsp;</div><span>add user</span></a> <a href="<?php echo base_url(); ?>sessions/search"><div class="search" width="20px" height="20px" alt="search">&nbsp;</div><span>search</span></a></div>
@@ -0,0 +1,22 @@
+ <div id="sessions_container">
+
+ <h1>Sessions</h1>
+
+ <?php $this->load->view('pagebits/page_buttons'); ?>
+
+ <div id="sessions_content">
+
+ <h2>Add User</h2>
+ <div id="top_buttons"><?php echo anchor('sessions', 'overview'); ?></div>
+
+ <?php
+
+ $this->object =& get_instance();
+
+
+
+ ?>
+
+ </div>
+
+ </div>
@@ -0,0 +1 @@
+ <div id="sessions_container"> <h1>Sessions</h1> <?php $this->load->view('pagebits/page_buttons'); ?> <div id="sessions_content"> <h2>Add User</h2> <div id="top_buttons"><?php echo anchor('sessions/user/' . $user['sessions'][0]['user_id'], 'user'); ?> - <?php echo anchor('sessions', 'overview'); ?></div> </div></div>
@@ -1 +1 @@
- <div id="sessions_container"> <h1>Sessions</h1> <div id="sessions_content"> <h2>Overview</h2> <?php $this->object =& get_instance(); $tmpl = array ( 'table_open' => '<table class="overview">', 'heading_row_start' => '<tr class="titles">', 'heading_row_end' => '</tr>', 'heading_cell_start' => '<th align="left">', 'heading_cell_end' => '</th>', 'row_start' => '<tr class="overview_data">', 'row_end' => '</tr>', 'cell_start' => '<td>', 'cell_end' => '</td>', 'row_alt_start' => '<tr class="overview_data">', 'row_alt_end' => '</tr>', 'cell_alt_start' => '<td>', 'cell_alt_end' => '</td>', 'table_close' => '</table>' ); $this->object->load->library('table'); $this->object->table->set_template($tmpl); $this->object->table->set_heading(array('&nbsp;', 'Time Created', 'Session ID', 'User ID', 'User Name', 'Last Activity')); $i = 0; foreach($sessions as $session_row){ $this->object->table->add_row(array('<input type="checkbox" class="checkbox_clear" name="session_' . $i . '"/>', date( 'h:ia d/m/y', $session_row['time_created']), $session_row['session_id'], $session_row['user_id'], anchor('/sessions/user/' . $session_row['user_id'], $session_row['username']), date( 'h:ia d/m/y', $session_row['last_activity']))); $i++; } echo $this->object->table->generate(); ?> <table class="overview"> <tr class="options_divider"> <td colspan="7"> &nbsp; </td> <tr> <tr class="options"> <td colspan="7"> <div id="option_buttons"> <span class="all_button">&nbsp;</span> <a href="#">edit</a> <a href="#">delete</a> </div> </td> <tr> </table> </div> </div>
+ <div id="sessions_container"> <h1>Sessions</h1> <?php $this->load->view('pagebits/page_buttons'); ?> <div id="sessions_content"> <h2>Overview</h2> <?php $this->object =& get_instance(); $tmpl = array ( 'table_open' => '<table class="overview">', 'heading_row_start' => '<tr class="titles">', 'heading_row_end' => '</tr>', 'heading_cell_start' => '<th align="left">', 'heading_cell_end' => '</th>', 'row_start' => '<tr class="overview_data">', 'row_end' => '</tr>', 'cell_start' => '<td>', 'cell_end' => '</td>', 'row_alt_start' => '<tr class="overview_data">', 'row_alt_end' => '</tr>', 'cell_alt_start' => '<td>', 'cell_alt_end' => '</td>', 'table_close' => '</table>' ); $this->object->load->library('table'); $this->object->table->set_template($tmpl); $this->object->table->set_heading(array('&nbsp;', 'Time Created', 'Last Activity', 'Session ID', 'User ID', 'User Name')); $i = 0; foreach($sessions as $session_row){ $this->object->table->add_row(array( '<input type="checkbox" class="checkbox_clear" name="session_' . $i . '"/>', date( 'h:ia d/m/y', $session_row['time_created']), date('h:ia d/m/y', $session_row['last_activity']), $session_row['session_id'], $session_row['user_id'], anchor('/sessions/user/' . $session_row['user_id'], $session_row['username']) )); $i++; } echo $this->object->table->generate(); ?> <table class="overview"> <tr class="options_divider"> <td colspan="7"> &nbsp; </td> <tr> <tr class="options"> <td colspan="7"> <div id="option_buttons"> <span class="all_button">&nbsp;</span> <a href="#">edit</a> <a href="#">delete</a> </div> </td> <tr> </table> </div> </div>
@@ -0,0 +1,14 @@
+ <div id="sessions_container">
+
+ <h1>Sessions</h1>
+
+ <?php $this->load->view('pagebits/page_buttons'); ?>
+
+ <div id="sessions_content">
+
+ <h2>Search</h2>
+ <div id="top_buttons"><?php echo anchor('sessions', 'overview'); ?></div>
+
+ </div>
+
+</div>
@@ -1,11 +1,13 @@
<div id="sessions_container">
<h1>Sessions</h1>
+
+ <?php $this->load->view('pagebits/page_buttons'); ?>
<div id="sessions_content">
- <h2>User: <?php echo $user['username']; ?></h2>
- <div id="top_buttons"><?php echo anchor('sessions', 'Back to Sessions'); ?></div>
+ <h2>User</h2>
+ <div id="top_buttons"><?php echo anchor('sessions/edit/user/' . $user['sessions'][0]['user_id'], 'edit user'); ?> - <?php echo anchor('sessions', 'overview'); ?></div>
<?php
@@ -34,11 +36,14 @@
$this->object->load->library('table');
$this->object->table->set_template($tmpl);
+ $this->object->table->add_row(array('<b>ID</b>', $user['sessions'][0]['user_id']));
+ $this->object->table->add_row(array('<b>Username</b>', $user['username']));
$this->object->table->add_row(array('<b>Email</b>', $user['email']));
$this->object->table->add_row(array('<b>IP Address</b>', $user['sessions'][0]['ip_address']));
$this->object->table->add_row(array('<b>Session ID</b>', $user['sessions'][0]['session_id']));
echo $this->object->table->generate();
+ //<HR> spacer to seperate the data from options
?><p><hr/></p><?php
$tmpl = array (
@@ -64,13 +69,18 @@
$this->object->load->library('table');
$this->object->table->set_template($tmpl);
- $this->object->table->set_heading(array('Time Created', 'Session ID', 'IP Address', 'User Agent', 'Last Activity'));
- $i = 0;
+ $this->object->table->set_heading(array('Time Created', 'Last Activity', 'Session ID', 'IP Address', 'User Agent'));
foreach($user['sessions'] as $session_row){
- $this->object->table->add_row(array(date( 'h:ia d/m/y', $session_row['time_created']), $session_row['session_id'], $session_row['ip_address'], $session_row['user_agent'], date( 'h:ia d/m/y', $session_row['last_activity'])));
- $i++;
+ $this->object->table->add_row(array(
+ date( 'h:ia d/m/y', $session_row['time_created']),
+ date( 'h:ia d/m/y', $session_row['last_activity']),
+ $session_row['session_id'],
+ $session_row['ip_address'],
+ $session_row['user_agent']
+ ));
+
}
echo $this->object->table->generate();
Oops, something went wrong.

0 comments on commit d50086b

Please sign in to comment.