? admin/inc/backup ? admin/templates/default/backup Index: admin/inc/class.boaccess_history.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/admin/inc/class.boaccess_history.inc.php,v retrieving revision 1.3.4.2 diff -a -b -u -r1.3.4.2 class.boaccess_history.inc.php --- admin/inc/class.boaccess_history.inc.php 30 Sep 2005 09:53:43 -0000 1.3.4.2 +++ admin/inc/class.boaccess_history.inc.php 10 Feb 2006 22:03:34 -0000 @@ -77,9 +77,49 @@ { return $this->so->total($account_id); } + function btotal($account_id) + { + return $this->so->btotal($account_id); + } + + function return_logged_out($account_id) + { + return $this->so->return_logged_out($account_id); + } - function return_logged_out() + function list_banned($account_id,$bstart,$border,$bsort) + { + $results = $this->so->list_banned($account_id,$bstart,$border,$bsort); + while (is_array($results) && list(,$record) = each($results)) + { + if ($record['bli']) + { + $record['bli'] = $GLOBALS['phpgw']->common->show_date($record['bli']); + } + if ($account_id) + { + $record['burl'] = $record['bloginid']; + $record['unbantype'] = 'bannedid'; + } + else + { + $record['burl'] = $record['bip']; + $record['unbantype'] = 'bannedip'; + } + $brecords[] = array( + 'bloginid' => $record['bloginid'], + 'bip' => $record['bip'], + 'bli' => $record['bli'], + 'bsessionid' => $record['bsessionid'], + 'burl' => $record['burl'], + 'unbantype' => $record['unbantype'] + ); + } + echo $record['burl']; + return $brecords; + } + function unban($banned_id,$banned_ip,$account_id) { - return $this->so->return_logged_out(); + $this->so->unban($banned_id,$banned_ip,$account_id); } } Index: admin/inc/class.soaccess_history.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/admin/inc/class.soaccess_history.inc.php,v retrieving revision 1.3.4.4 diff -a -b -u -r1.3.4.4 class.soaccess_history.inc.php --- admin/inc/class.soaccess_history.inc.php 30 Sep 2005 09:53:43 -0000 1.3.4.4 +++ admin/inc/class.soaccess_history.inc.php 10 Feb 2006 22:03:34 -0000 @@ -56,12 +56,70 @@ return $this->db->f(0); } + function btotal($account_id) + { + ($account_id) ? ($lid = ($GLOBALS['phpgw']->accounts->id2name($account_id))) : ''; + ($lid) ? ($who = "WHERE loginid = '$lid' AND ") : ($who = "WHERE "); + $this->db->query("SELECT COUNT(*) from phpgw_access_log $who account_id='0'" , __LINE__, __FILE__); + $this->db->next_record(); + + return $this->db->f(0); + } - function return_logged_out() + function return_logged_out($account_id) { - $this->db->query("SELECT COUNT(*) FROM phpgw_access_log WHERE lo !=0", __LINE__, __FILE__); + ($account_id) ? ($who = "WHERE account_id = '$account_id' AND ") : ($who = "WHERE "); + $this->db->query("SELECT COUNT(*) FROM phpgw_access_log $who lo !=0", __LINE__, __FILE__); $this->db->next_record(); return $this->db->f(0); } + + //added the following sections for banned IP removal listing and removal - burnt-toast + function list_banned($account_id,$bstart,$border,$bsort) + { + ($account_id) ? ($lid = ($GLOBALS['phpgw']->accounts->id2name($account_id))) : ''; + ($lid) ? ($who = "WHERE loginid = '$lid' AND ") : ($who = "WHERE "); + $this->db->limit_query("SELECT loginid,ip,li,sessionid FROM phpgw_access_log $who account_id ='0' ORDER BY li desc",$bstart, __LINE__, __FILE__); + + while ($this->db->next_record()) + { + $results[] = array( + 'bloginid' => $this->db->f('loginid'), + 'bip' => $this->db->f('ip'), + 'bli' => $this->db->f('li'), + 'bsessionid' => $this->db->f('sessionid') + ); + } + return $results; + } + function unban($banned_id,$banned_ip,$account_id) + { + // We will need at least a who or where for this to work since we do not want to unban all banned items. + + if (($banned_id) || ($banned_ip)) + + { ($banned_id) ? ($who = "AND loginid='$banned_id '") : ($who = null); + ($banned_ip) ? ($where = "AND ip='$banned_ip'") : ($where = null); + ($banned_id) ? ($that = "account_id='$account_id'") : ($that = "account_id = '2147483647'"); + ($banned_id) ? ($note = ", sessionid='Cleared Failed User Login'") : ($note = ", sessionid='Cleared Failed IP Login'"); + /* + An account_id of 0 is apparently used to signify a bad login attempt or block. + I don't want to delete the incorrect login attempts, that way someone can't cover up their tracks directly + if they manage to hack one of the scripts or try to send bad form data to this function. + I want to just unban the user / ip, so I set a number that should be higher than ANY phpgw user id, + (If I receive an IP address othewise I set the users ID if I'm clearing a user) + but still fit in the INT column type in the table. Maybe I am wrong though... + Please check as I use MySQl and dont want to break any databases or authentication systems that I dont use... + */ + $this->db->query("UPDATE phpgw_access_log SET $that $note WHERE account_id='0' $who $where"); + $changed = $this->db->num_rows(); + } + else + { + $changed = null; + } + return $changed; +//none of the $changed returns are working and im not sure why. i removed the higer level code to minimize confusion.- burnt-toast + } } Index: admin/inc/class.uiaccess_history.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/admin/inc/class.uiaccess_history.inc.php,v retrieving revision 1.6.2.2.2.6 diff -a -b -u -r1.6.2.2.2.6 class.uiaccess_history.inc.php --- admin/inc/class.uiaccess_history.inc.php 30 Sep 2005 09:53:44 -0000 1.6.2.2.2.6 +++ admin/inc/class.uiaccess_history.inc.php 10 Feb 2006 22:03:34 -0000 @@ -36,6 +36,9 @@ $this->template->set_block('accesslog','list'); $this->template->set_block('accesslog','row'); $this->template->set_block('accesslog','row_empty'); + $this->template->set_block('accesslog','brow'); + $this->template->set_block('accesslog','brow_empty'); + } function list_history() @@ -44,38 +47,76 @@ $start = get_var('start',array('POST'),0); $sort = get_var('sort',array('POST'),0); $order = get_var('order',array('POST'),0); - + $bstart = get_var('bstart', array('POST'),0); + $bsort = get_var('bsort' ,array('POST'),0); + $border = get_var('border',array('POST'),0); + $banned_id = get_var('bannedid',array('POST')); + $banned_ip = get_var('bannedip',array('POST')); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('View access log'); $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); + //Added by Burnt-toast + // This was added so navigation left and right does not exceed the total matches for bans. + // Bans list will display the same search result range as the regular list until it is too high. + if ((($bstart) < ($start)) || (($bstart) > ($start))) + { + if (($bstart + $bstart) < $btotal_records) + { + $bstart = $start; + } + elseif ($bstart > $start) + { + $bstart = $start; + } + } + // This checks to see if a user or IP to unblock has been submitted to the form. If so it runs the unblock. + if ($banned_id || $banned_ip) + { + $changed = $this->bo->unban($banned_id,$banned_ip,$account_id); + echo "Records Modification Attempted Check Your Database"; + } + // I had to move the record totals here in case a user was removed from the list to fix an issue with normal list total being off. $total_records = $this->bo->total($account_id); - + $btotal_records = $this->bo->btotal($account_id); + //These two items have not been updated in the database and so only display in English for now. + ($account_id) ? ($ubantype = lang('Unban User')) : ($ubantype = lang('Unban IP')); $var = Array( 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], - 'nextmatchs_left' => $this->nextmatchs->left('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id), - 'nextmatchs_right' => $this->nextmatchs->right('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id), + 'nextmatchs_left' => $this->nextmatchs->left('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id . '&bstart=' . $bstart), + 'nextmatchs_right' => $this->nextmatchs->right('/index.php',$start,$total_records,'&menuaction=admin.uiaccess_history.list_history&account_id=' . $account_id . '&bstart=' . $bstart), 'showing' => $this->nextmatchs->show_hits($total_records,$start), + 'bshowing' => $this->nextmatchs->show_hits($btotal_records,$bstart), 'lang_loginid' => lang('LoginID'), 'lang_ip' => lang('IP'), 'lang_login' => lang('Login'), 'lang_logout' => lang('Logout'), - 'lang_total' => lang('Total') + 'lang_total' => lang('Total'), + 'lang_login_attempt' => lang('Login Attempt'), + 'lang_note' => lang('Note'), + 'lang_ubantype' => $ubantype, + 'lang_unban_ip' => lang('Unban IP'), + 'lang_unban_user' => lang('Unban User'), + 'lang_submit' => lang('Submit') ); - + //Ironically this was in the original file but the link was missing from the template... so I added it there - Burnt-toast + //There was also another error here which kept the single user total from being tallied differently from the entire list. + //I fixed that as well. if ($account_id) { $var['link_return_to_view_account'] = '' . lang('Return to view account') . ''; $var['lang_last_x_logins'] = lang('Last %1 logins for %2',$total_records,$GLOBALS['phpgw']->common->grab_owner_name($account_id)); + $var['lang_last_x_failed_logins'] = lang('Last %1 failed logins for %2',$btotal_records,$GLOBALS['phpgw']->common->grab_owner_name($account_id)); } else { $var['lang_last_x_logins'] = lang('Last %1 logins',$total_records); + $var['lang_last_x_failed_logins'] = lang('Last %1 failed logins', $btotal_records); } $this->template->set_var($var); @@ -103,20 +144,55 @@ $this->template->fp('rows_access','row_empty',True); } - $loggedout = $this->bo->return_logged_out(); + $loggedout = $this->bo->return_logged_out($account_id); if ($total_records) { - $percent = round(($loggedout / $total_records) * 100); + $percent = round((($loggedout) / ($total_records)) * 100); } else { $percent = '0'; } + //This is Where I started adding stuff to make a ban list, navigation, removal functions etc. + $brecords = $this->bo->list_banned($account_id,$bstart,$border,$bsort); + $acturl = (!($account_id) + ? $GLOBALS['phpgw']->link('/index.php', + Array( + 'menuaction' => 'admin.uiaccess_history.list_history' + )) + : $GLOBALS['phpgw']->link('/index.php', + Array( + 'menuaction' => 'admin.uiaccess_history.list_history', + 'account_id' => $account_id + ))); + while (is_array($brecords) && list(,$brecord) = each($brecords)) + { + $this->nextmatchs->template_alternate_row_color($this->template); + + $var = array( + 'brow_loginid' => $brecord['bloginid'], + 'brow_ip' => $brecord['bip'], + 'brow_li' => $brecord['bli'], + 'brow_sessionid' => $brecord['bsessionid'], + 'brow_unban' => $brecord['burl'], + 'brow_unbantype' => $brecord['unbantype'], + 'brow_unbanurl' => $acturl + ); + $this->template->set_var($var); + $this->template->fp('brows_access','brow',True); + } + if (! $btotal_records && $account_id) + { + $this->nextmatchs->template_alternate_row_color($this->template); + $this->template->set_var('brow_message',lang('No Ban history exists for this user')); + $this->template->fp('brows_access','brow_empty',True); + } $var = Array( 'bg_color' => $GLOBALS['phpgw_info']['themes']['bg_color'], - 'footer_total' => lang('Total records') . ': ' . $total_records + 'footer_total' => lang('Total records') . ': ' . $total_records, + 'bfooter_total' => lang('Total records') . ': ' . $btotal_records ); if ($account_id) { @@ -130,7 +206,6 @@ // create the menu on the left, if needed $menuClass = CreateObject('admin.uimenuclass'); $var['rows'] = $menuClass->createHTMLCode('view_account'); - $this->template->set_var($var); $this->template->pfp('out','list'); } Index: admin/templates/default/accesslog.tpl =================================================================== RCS file: /cvsroot/phpgroupware/admin/templates/default/accesslog.tpl,v retrieving revision 1.9.4.1 diff -a -b -u -r1.9.4.1 accesslog.tpl --- admin/templates/default/accesslog.tpl 17 May 2003 20:46:13 -0000 1.9.4.1 +++ admin/templates/default/accesslog.tpl 10 Feb 2006 22:03:34 -0000 @@ -4,6 +4,7 @@
+ {link_return_to_view_account} {rows} + + + + + + + + + + + + + {brows_access} + + + + +
@@ -37,6 +38,32 @@
{lang_percent}
+ {lang_last_x_failed_logins} + + {bshowing} + + +

+
+
{lang_loginid}{lang_ip}{lang_login_attempt}{lang_note}{lang_ubantype}
{bfooter_total}{baffected}
@@ -60,3 +87,19 @@ {row_message} + + + + {brow_loginid} + {brow_ip} + {brow_li} + {brow_sessionid}  +
+ + + + + + {row_message} + +