]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
Add a failed logins page, to show the most recent failed logins.
authorkkalev <kkalev>
Tue, 10 Sep 2002 07:35:56 +0000 (07:35 +0000)
committerkkalev <kkalev>
Tue, 10 Sep 2002 07:35:56 +0000 (07:35 +0000)
Changelog
conf/admin.conf
htdocs/failed_logins.php3 [new file with mode: 0644]

index 11b05e14b34609e25c01a5c22151c933bdbee230..a047b05988395f43ad19a9e7a0013ff0bb095593 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -51,6 +51,7 @@ Ver 1.59:
   connect to that one instead of the ldap_server. That way we can read from the fast read-only replicas and
   write to a slower master.
 * Fix a few more bugs
+* Add a failed logins page, to show the most recent failed logins.
 Ver 1.55:
 * Update the FAQ about missing attributes from the user/group edit pages and add a few comments
   in the configuration files
index 700b5cb2e2124c5513477744a46faf50364ef984..1d4c566f221362a225632f49da5970036f7dfb53 100644 (file)
@@ -17,6 +17,11 @@ general_domain: company.com
 # the admin.conf
 # This feature is considered experimantal for the moment
 general_use_session: no
+#
+# This is used by the failed logins page. It states the default back time
+# in minutes.
+#
+general_most_recent_fl: 30
 
 #
 general_ldap_attrmap: %{general_radiusd_base_dir}/etc/raddb/ldap.attrmap
diff --git a/htdocs/failed_logins.php3 b/htdocs/failed_logins.php3
new file mode 100644 (file)
index 0000000..34ce661
--- /dev/null
@@ -0,0 +1,167 @@
+<?php
+require('../conf/config.php3');
+?>
+<html>
+<?php
+
+if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
+       include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
+else{
+       echo <<<EOM
+<title>Failed logins</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<center>
+<b>Could not include SQL library functions. Aborting</b>
+</body>
+</html>
+EOM;
+       exit();
+}
+
+$now = time();
+if ($last == 0)
+       $last = ($config[general_most_recent_fl]) ? $config[general_most_recent_fl] : 5;
+$start = $now - ($last*60);
+$now_str = date($config[sql_full_date_format],$now);
+$prev_str = date($config[sql_full_date_format],$start);
+$pagesize = ($pagesize) ? $pagesize : 10;
+$limit = ($pagesize == 'all') ? '' : "LIMIT $pagesize";
+$selected[$pagesize] = 'selected';
+$order = ($order) ? $order : $config[general_accounting_info_order];
+if ($order != 'desc' && $order != 'asc')
+       $order = 'desc';
+$selected[$order] = 'selected';
+if ($callerid != '')
+       $callerid_str = "AND CallingStationId = '$callerid'";
+
+?>
+
+<head>
+<title>Failed Logins</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<center>
+<table border=0 width=550 cellpadding=0 cellspacing=0>
+<tr valign=top>
+<td align=center><img src="images/title2.gif"></td>
+</tr>
+</table>
+<table border=0 width=400 cellpadding=0 cellspacing=2>
+</table>
+<br>
+<table border=0 width=840 cellpadding=1 cellspacing=1>
+<tr valign=top>
+<td width=65%></td>
+<td bgcolor="black" width=35%>
+       <table border=0 width=100% cellpadding=2 cellspacing=0>
+       <tr bgcolor="#907030" align=right valign=top><th>
+       <font color="white">Failed Logins</font>&nbsp;
+       </th></tr>
+       </table>
+</td></tr>
+<tr bgcolor="black" valign=top><td colspan=2>
+       <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
+       <tr><td>
+<?php
+echo <<<EOM
+<b>$prev_str</b> up to <b>$now_str</b>
+EOM;
+?>
+
+<p>
+       <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
+       <tr bgcolor="#d0ddb0">
+       <th>#</th><th>login</th><th>time</th><th>server</th><th>terminate cause</th><th>callerid</th>
+       </tr>
+
+<?php
+$link = @da_sql_pconnect($config);
+if ($link){
+       $search = @da_sql_query($link,$config,
+       "SELECT AcctStartTime,UserName,NASIPAddress,NASPortId,AcctTerminateCause,CallingStationId
+       FROM $config[sql_accounting_table]
+       WHERE AcctStartTime <= '$now_str' AND AcctStartTime >= '$prev_str'
+       AND AcctTerminateCause LIKE 'Login-Incorrect%' OR
+       AcctTerminateCause LIKE 'Invalid-User%' OR
+       AcctTerminateCause LIKE 'Multiple-Logins%' $callerid_str
+       ORDER BY AcctStartTime $order $limit;");
+       if ($search){
+               while( $row = @da_sql_fetch_array($search,$config) ){
+                       $num++;
+                       $acct_login = $row[UserName];
+                       if ($acct_login == '')
+                               $acct_login = '-';
+                       else
+                               $acct_login = "<a href=\"user_admin.php3?login=$acct_login\" title=\"Edit user $acct_login\">$acct_login</a>";
+                       $acct_time = $row[AcctStartTime];
+                       $acct_server = $da_name_cache[$row[NASIPAddress]];
+                       if (!isset($acct_server)){
+                               $acct_server = gethostbyaddr($row[NASIPAddress]);
+                               if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
+                                       $da_name_cache[$row[NASIPAddress]] = $acct_server;
+                                       session_register('da_name_cache');
+                               }
+                               else
+                                       $da_name_cache[$row[NASIPAddress]] = $acct_server;
+                       }
+                       $acct_server = "$acct_server:$row[NASPortId]";
+                       $acct_terminate_cause = "$row[AcctTerminateCause]";
+                       if ($acct_terminate_cause == '')
+                               $acct_terminate_cause = '-';
+                       $acct_callerid = "$row[CallingStationId]";
+                       if ($acct_callerid == '')
+                               $acct_callerid = '-';
+                       echo <<<EOM
+                       <tr align=center bgcolor="white">
+                               <td>$num</td>
+                               <td>$acct_login</td>
+                               <td>$acct_time</td>
+                               <td>$acct_server</td>
+                               <td>$acct_terminate_cause</td>
+                               <td>$acct_callerid</td>
+                       </tr>
+EOM;
+               }
+       }
+}
+echo <<<EOM
+       </table>
+<tr><td>
+<hr>
+<tr><td align="left">
+       <form action="failed_logins.php3" method="get" name="master">
+       <table border=0>
+               <tr valign="bottom">
+                       <td><small><b>time back (mins)</td><td><small><b>pagesize</td><td><small><b>caller id</td><td><b>order</td>
+       <tr valign="middle"><td>
+<input type="text" name="last" size="11" value="$last"></td>
+<td><select name="pagesize">
+<option $selected[5] value="5" >05
+<option $selected[10] value="10">10
+<option $selected[15] value="15">15
+<option $selected[20] value="20">20
+<option $selected[40] value="40">40
+<option $selected[80] value="80">80
+<option $selected[all] value="all">all
+</select>
+</td>
+<td>
+<input type="text" name="callerid" size="11" value="$callerid"></td>
+<td><select name="order">
+<option $selected[asc] value="asc">older first
+<option $selected[desc] value="desc">recent first
+</select>
+</td>
+EOM;
+?>
+
+<td><input type="submit" class=button value="show"></td></tr>
+</table></td></tr></form>
+</table>
+</tr>
+</table>
+</body>
+</html>