<html>
<head>
<title>SAPPCDR v1.0</title>
<style>
th {
font-size: x-small;
white-space:nowrap;
overflow: hidden;
height: 10px;
margin: 1px;
border: 1px solid;
background: #cccccc;
}
td {
font-size: x-small;
white-space: nowrap;
margin: 1px;
border: 1px solid;
padding-left: 5px;
padding-right: 5px;
}
a:link , a:visited {
color:#000000;
}
.row1 {
background: #CCCC99;
}
.row2 {
background: #eeeeee;
}
</style>
</head>
<body>
<?
$contextvar = "ivr";
$filename="/var/log/asterisk/cdr-csv/Master.csv";
//there isnt a need to edit anything below this line, unless you would like to.
$color1 = "row1";
$color2 = "row2";
$row_count = 0;
echo("<table border=\"1\">\n");
echo("<tr>");
echo("<th>Date & Time</th>");
echo("<th colspan=\"2\">Caller ID</th>");
echo("<th>Context</th>");
echo("<th>Call Status</th>");
echo("<th>Seconds</th>");
echo("</tr>\r\n");
if (!file_exists($filename)) {
echo("<tr><th colspan=\"6\">Sorry, the cdr file specified doesnt exist");
}
if (file_exists($filename)) {
$id = fopen($filename, "r"); //open the file
while ($data = fgetcsv($id, filesize($filename))) //start a loop
$table[] = $data; //put each line into its own entry in the $table array
fclose($id); //close file
foreach(array_reverse($table) as $row)
{
$row_color = ($row_count % 2) ? $color1 : $color2;
$callerid = explode("\"", $row[4]);
$calleridname = ucwords(strtolower($callerid[1]));
$calleridnumb = ereg_replace('\>', '', ereg_replace('\<', '', $callerid[2]));
$npa = "".$calleridnumb['1']."".$calleridnumb['2']."".$calleridnumb['3']."";
$nxx = "".$calleridnumb['4']."".$calleridnumb['5']."".$calleridnumb['6']."";
$xxx = "".$calleridnumb['7']."".$calleridnumb['8']."".$calleridnumb['9']."".$calleridnumb['10']."";
$date=$row[11];
$context=$row[3];
$time=$row[12];
$status=$row[14];
if ($context=="$contextvar") {
echo "<tr class=\"".$row_color."\">";
echo "<td>".$date."</td>";
echo "<td>
<a target=\"_blank\" href=\"http://www.telephreak.org/npa/lookup.php?npa=".$npa."&nxx=".$nxx."\">
".$npa."-".$nxx."-".$xxx."</a>
</td><td>
".$calleridname."
</td>";
echo "<td>".$context."</td>";
echo "<td>".$status."</td>";
echo "<td>".$time."</td>";
echo "</tr>\n";
$row_count++;
}
}
}
echo "<tr><td colspan=\"6\" bgcolor=\"#CCCC99\">
<center><font size=\"1\">Created by <a href=\"mailto:gid@telephreak.org\">
<font color=\"#000000\">gid</font></a> - <a target=\"_blank\"
href=\"http://www.telephreak.org\"><font color=\"#000000\">for
Telephreak</font></a>. <br /> This is do whatever the hell you want with
software.</font></center></td></tr>";
echo "</table>\n";
?>
</body>
</html>