<HTML>
<HEAD>
<TITLE>Calls</TITLE>
</HEAD>
<BODY bgcolor=white>
CallerID
<BR>
<TABLE>
<TR><TH>Number</TH><TH>Login</TH><TH>Exchange</TH></TR>
<?
include "./mysql.inc.php";
#print $CustomerID;
function cli($callerid){
$esql="SELECT ExchangeName
FROM Exchanges, Prefix
WHERE '$callerid' LIKE concat(Prefix,'%')
AND Exchanges.ExchangeID=Prefix.ExchangeID";
#print $esql;
$eres=mysql_query($esql);
print mysql_error();
if (mysql_num_rows($eres))
$ret=mysql_result($eres,0);
else
$ret='';
return $ret;
}
if (!$start)
$start="0";
if (!$num)
$num="40";
if ($number)
$sql = "SELECT DISTINCTROW UserName, CallingStationId FROM radacct WHERE CallingStationId = '$number'";
else{
$saql="SELECT Login FROM SubAccounts WHERE CustomerID=$CustomerID";
$sares=mysql_query($saql);
$sql="SELECT Distinct row CallingStationId, UserName FROM radacct WHERE (";
#mysql_data_seek($sares,0);
while ($asrow=mysql_fetch_row($sares)){
$sql=$sql." UserName='$asrow[0]' OR";
}
$sql=substr($sql,0,strlen($sql)-2);
$sql .=")";
}
$startres=mysql_query($sql);
if (mysql_error()){
print $sql;
print mysql_error();
}
while ($row = mysql_fetch_row($startres)){
if ($number){
print "<TR><TD>$row[0]</TD><TD><A HREF=\"jump.php?username=$row[1]\">$row[1]</A></TD><TD>";
$c = cli($row[0]);
if ($c)
print $c;
else
print ' ';
print "</TD></TR>";
}else{
print "<TR><TD><A HREF=\"cli.php?number=$row[0]\">$row[0]</A></TD><TD>";
#print "<A HREF=\"jump.php?username=$row[1]\">$row[1]</A></TD><TD>";
print "$row[1]</TD><TD>";
$c = cli($row[0]);
if ($c)
print $c;
else
print ' ';
print "</TD></TR>";
}
}
?></TABLE>
</BODY>
</HTML>