Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/display/FailedLogins.php
<?

if  (isset($_GET['lsid'])) 
{
	$loc=getLocationID($_GET['lsid']);
	$LocName=$_GET['lsid'];
}
else
	$LocName = $_SESSION['LocName'];

$LocName = $_SESSION['LocName'];

if (isset($_GET['lsid']) AND ($_GET['lsid']=="All"))
		$locstr="";
	 else
	 {
		$locstr=" AND userinfo.LocationID='$loc'";
		$locstrwa=" WHERE LocationID='$loc'";
	}


if(!isset($buttonID)) {
	$msg= "$msg <p class=\"error\">No button ID was sent</p>"; // this shouldn't happen
}

if(!isset($msg)){  // no errors? ...  hit it.  Need to reset button id
	
$y=date('Y');
$m=date('m');
$now=time();
if (isset($_POST['start'])) $start=$_POST['start'];
if (isset($_POST['stop'])) $stop=$_POST['stop'];
if (isset($_POST['order'])) $order=$_POST['order'];
if (isset($_POST['sortby'])) $sortby=$_POST['sortby'];
if (isset($_POST['server'])) $server=$_POST['server'];
if (isset($_POST['callerid'])) $callerid=$_POST['callerid'];
if (isset($_POST['last'])) $last=$_POST['last'];

if (isset($_POST['pagesize'])) $pagesize=$_POST['pagesize'];


if (!isset($last))
	        $last = ($general_most_recent_fl) ? $general_most_recent_fl : 5;
if (!is_numeric($last))
	$last = 5;

$start = $now - ($last*60);
$startd=date($dateFormat,$start);
$stopd=date($dateFormat,$now);
$now_str = date($sql_date_format,$now);
$prev_str = date($sql_date_format,$start);

$now_str = $oreon->database->database->escape_string($now_str);
$prev_str = $oreon->database->database->escape_string($prev_str);


$pagesize = ($pagesize) ? $pagesize : 10;
if (!is_numeric($pagesize) && $pagesize != 'all')
	        $pagesize = 10;
$limit = ($pagesize == 'all') ? '' : "LIMIT $pagesize";
$selected[$pagesize] = 'selected';
$order = ($order) ? $order : 'desc';
if ($order != 'desc' && $order != 'asc')
	        $order = 'desc';
if ($sortby != '')
	        $order_attr = ($sortby == 'num') ? 'connnum' : 'conntotduration';
else
	        $order_attr = 'connnum';
if ($server != '' && $server != 'all'){
	        $server = $oreon->database->database->escape_string($server);
		        $server_str = "AND nasipaddress = '$server'";
}
$login_str = ($login) ? "AND username = '$login' " : '';

$selected[$order] = 'selected';
$selected[$sortby] = 'selected';


if ($callerid != ''){
	$callerid =  $oreon->database->database->escape_string($callerid);
	$callerid_str = "AND callingstationid = '$callerid'";
}
if ($server != '' && $server != 'all'){
	$server =  $oreon->database->database->escape_string($server);
	$server_str = "AND nasipaddress = '$server'";
}

unset($da_name_cache);
if (isset($_SESSION['da_name_cache']))
	$da_name_cache = $_SESSION['da_name_cache'];

?>

<center>
<table border=0 width=400 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=800 cellpadding=1 cellspacing=1>
<tr valign=top>
<td width=65%></td>
<td bgcolor="888888" width=35%>
	<table border=0 width=100% cellpadding=2 cellspacing=0>
	<tr bgcolor="#aaaaaa" 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
print "<b>$startd</b> up to <b>$stopd</b>";
?>

<p>
 <table border=0 bordercolordark=#e6e6e6 bordercolorlight=#000000 width=600px cellpadding=2 cellspacing=0 bgcolor="#e6e6e6" valign=top>
        <tr bgcolor="#e6e6e6">

	<th>#</th><th>login</th>
<?php
echo "<th>Logged in</th>\n";
echo "<th>Server</th>\n";
echo "<th>Terminate cause</th>\n";
echo "<th>Caller id</th>\n";
?>
	</tr>

<?php
$search = $oreon->database->database->query("SELECT acctstoptime,radacct.username,nasipaddress,nasportid,acctterminatecause,callingstationid
	FROM radacct,userinfo
	WHERE radacct.username=userinfo.username and acctstoptime <= '$now_str' AND acctstoptime >= '$prev_str'
	AND (acctterminatecause LIKE 'Login-Incorrect%' OR
	acctterminatecause LIKE 'Invalid-User%' OR
	acctterminatecause LIKE 'Multiple-Logins%') $locstr $callerid_str $server_str $sql_extra_query ".
	" ORDER BY acctstoptime $order " . $limit . " ;");
	if ($search){
		while( $row = $oreon->database->database->fetch_array($search) ){
			$num++;
			$acct_login = $row[username];
			if ($acct_login == '')
				$acct_login = '-';
			else {
			     $acct_login='<input type="button" class="smallButton" name="UserSelected" value="'.$acct_login.'" onClick="window.open(\'include/divers/sexyTabs.php?phpmyprepaid='.session_id.'&usr='.$acct_login.'\',\'User informations\',\'width=800,height=600,status=yes,resizable=yes,menubar=yes,scrollbars=yes\');" >';
			}
			$acct_time = $row['acctstoptime'];
			$acct_server = $row['nasipaddress'];
			if ($acct_server != ''){
				if (!isset($acct_server)){
					$acct_server = $row['nasipaddress'];
					$acct_server = gethostbyaddr($acct_server);
				}
			}
			else
				$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 = '-';
			print "<tr align=center bgcolor=\"white\">
				<td>$num</td>
				<td>$acct_login</td>";
				echo "<td>$acct_time</td>\n";
				echo "<td>$acct_server</td>\n";
				echo "<td>$acct_terminate_cause</td>\n";
				echo "<td>$acct_callerid</td>\n";
				echo "</tr>\n";
		}
	}
print '	</table>
	<tr><td>';
}	
echo '<hr>
<tr><td align="left">
	<form action="phpmyprepaid.php" method="post" 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>';

print "<input type=\"text\" name=\"last\" size=\"11\" value=\"$last\"></td>
	<td><select name=\"pagesize\">";
echo "
<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>";

echo '<td><input type="submit" class=smallButton value="show"></td></tr>
<tr><td>
<b>On Access Server:</b>
</td></tr><tr><td>
<select name="server">';

$nas_list=get_naslist($_SESSION['locID']);
foreach ($nas_list as $nas){
       $name = $nas[name];
       $servers[$name] = $nas[ip];
}
ksort($servers);
foreach ($servers as $name => $ip){
        if ($server == $ip)
               echo "<option selected value=\"$ip\">$name\n";
        else
               echo "<option value=\"$ip\">$name\n";
}
if ($server == '' || $server == 'all')
       echo "<option selected value=\"all\">all\n";
else
       echo "<option value=\"all\">all\n";
print "</select>


</td></tr>
</table></td></tr></form>
</table>
</tr>
</table>";
?>
Return current item: phpMyPrepaid