I've a hotspot and I've created a PHP file to read data from "Export User Accounts" task.
Features :
Show in HTML the Export User Accounts file
Translation is possible
Version 1.1
+ Add N/A is cell is blank - Thanks to logan
Version 1.2
+ Data show now KB, MB or GB
+ Time online show now min or hours
+ Balance show device (USD, EUR, ...)
Thanks to logan who help me to add these functions
- Code: Select all
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<?php
/* BEGIN SCRIPT CONFIGURATION */
//Location of exported accounts file
$exported_accounts = "accounts.txt";
//Translation of column headers
$translation[0] = "Timestamp"; //Timestamp
$translation[1] = "Account"; //Username
$translation[2] = "Full Name"; //Real Name
$translation[3] = "Downloaded"; //Client Send (b)
$translation[4] = "Uploaded"; //Client Recv (b)
$translation[5] = "Uploaded For"; //Server Send (b)
$translation[6] = "Downloaded For"; //Server Recv (b)
$translation[7] = "Time Online"; //Time (s)
$translation[8] = "Opening Balance"; //Opening
$translation[9] = "Closing Balance"; //Closing
// Other Translation
$hours = "hours"; // hours
$minutes = "min"; // minutes
$GB = "GB"; // Gigabytes
$MB = "MB"; // Megabytes
$KB = "KB"; // Kilobytes
$Bytes = "Bytes"; // Bytes
$device = "USD";
/* END SCRIPT CONFIGURATION */
$header = array("Timestamp", "Username", "Real Name", "Client Send (b)", "Client Recv (b)", "Server Send (b)", "Server Recv (b)", "Time (s)", "Opening", "Closing");
$handle = fopen($exported_accounts, "r");
$row = 0;
while (($data = fgetcsv($handle, 1000, " ")) !== FALSE) {
$num = count($data);
$data = str_replace($header, $translation, $data);
$row++;
echo "<tr>";
for ($c=0; $c < $num; $c++) {
If ($data[$c] == "" or $data[$c] == "<system>")
echo "<td> </td>";
else {
If ($c == 7 and $row > 1)
// Time Function
If ($data[$c] < 3600)
{$data[$c] = round($data[$c] / 60, 2)." ".$minutes;}
else
{$data[$c] = round($data[$c] / 3600, 2)." ".$hours;}
// Datas Transfered Function
If ($c > 2 and $c < 7 and $row > 1)
if ($data[$c] > 1073741824)
{$data[$c] = round($data[$c] / 1073741824, 2)." ".$GB;}
else If ($data[$c] > 1048576)
{$data[$c] = round($data[$c] / 1048576, 2)." ".$MB;}
else If ($data[$c] > 1024)
{$data[$c] = round($data[$c] / 1024, 2)." ".$KB;}
else If ($data[$c] < 1024)
{$data[$c] = round($data[$c], 2)." ".$Bytes;}
// Balance Function
If ($c > 7 and $c < 10 and $row > 1) $data[$c] = round($data[$c], 2)." ".$device;
echo "<td>".$data[$c]."</td>";
}
}
echo "</tr>";
}
fclose($handle);
?>
</table>
Let me know your feedback ;)