Skip to content
Snippets Groups Projects
Commit 6ad7d78c authored by Robert Anderson's avatar Robert Anderson
Browse files

* Calculate totals based on byte values of all log lines, then round up to nearest Mbyte

 webgui/ajax.php                                 |    8 +-
 webgui/include/ajax/functions/AdminUserLogs.php |   80 ++++++++----------------
 webgui/include/ajax/functions/WiSPUserLogs.php  |   80 ++++++++----------------
 webgui/js/app/windows/AdminUserLogs.js          |   11 ++-
 webgui/js/app/windows/WiSPUserLogs.js           |   11 ++-
 webui/user/index.php                            |   68 ++++++++++----------
 webui/user/logs.php                             |   48 ++++++--------
 7 files changed, 131 insertions(+), 175 deletions(-)

parent be25085f
No related branches found
No related tags found
No related merge requests found
...@@ -610,8 +610,8 @@ ...@@ -610,8 +610,8 @@
$res->addField('CalledStationID','string'); $res->addField('CalledStationID','string');
$res->addField('AcctSessionID','string'); $res->addField('AcctSessionID','string');
$res->addField('FramedIPAddress','string'); $res->addField('FramedIPAddress','string');
$res->addField('AcctInputMbyte','int'); $res->addField('AcctInput','float');
$res->addField('AcctOutputMbyte','int'); $res->addField('AcctOutput','float');
$res->addField('AcctSessionTime','int'); $res->addField('AcctSessionTime','int');
$res->addField('ConnectTermReason','string'); $res->addField('ConnectTermReason','string');
$res->parseArray($rawData); $res->parseArray($rawData);
...@@ -984,8 +984,8 @@ ...@@ -984,8 +984,8 @@
$res->addField('CalledStationID','string'); $res->addField('CalledStationID','string');
$res->addField('AcctSessionID','string'); $res->addField('AcctSessionID','string');
$res->addField('FramedIPAddress','string'); $res->addField('FramedIPAddress','string');
$res->addField('AcctInputMbyte','int'); $res->addField('AcctInput','float');
$res->addField('AcctOutputMbyte','int'); $res->addField('AcctOutput','float');
$res->addField('AcctSessionTime','int'); $res->addField('AcctSessionTime','int');
$res->addField('ConnectTermReason','string'); $res->addField('ConnectTermReason','string');
$res->parseArray($rawData); $res->parseArray($rawData);
......
...@@ -144,11 +144,11 @@ function getAdminUserLogsSummary($params) { ...@@ -144,11 +144,11 @@ function getAdminUserLogsSummary($params) {
$res = DBSelect(" $res = DBSelect("
SELECT SELECT
@TP@accounting.AcctSessionTime, SUM(@TP@accounting.AcctSessionTime) / 60 AS TotalSessionTime,
@TP@accounting.AcctInputOctets, SUM(@TP@accounting.AcctInputOctets) / 1024 / 1024 +
@TP@accounting.AcctInputGigawords, SUM(@TP@accounting.AcctInputGigawords) * 4096 +
@TP@accounting.AcctOutputOctets, SUM(@TP@accounting.AcctOutputOctets) / 1024 / 1024 +
@TP@accounting.AcctOutputGigawords SUM(@TP@accounting.AcctOutputGigawords) * 4096 AS TotalTraffic
FROM FROM
@TP@accounting, @TP@users @TP@accounting, @TP@users
WHERE WHERE
...@@ -163,35 +163,17 @@ function getAdminUserLogsSummary($params) { ...@@ -163,35 +163,17 @@ function getAdminUserLogsSummary($params) {
} }
# Set total traffic and uptime used # Set total traffic and uptime used
$totalTraffic = 0; $row = $res->fetchObject();
$totalUptime = 0;
while ($row = $res->fetchObject()) {
# Traffic in
if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
$totalTraffic += ceil($row->acctinputoctets / 1024 / 1024);
}
if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
$totalTraffic += ceil($row->acctinputgigawords * 4096);
}
# Traffic out
if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
$totalTraffic += ceil($row->acctoutputoctets / 1024 / 1024);
}
if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$totalTraffic += ceil($row->acctoutputgigawords * 4096);
}
# Uptime
$sessionTimeItem = 0;
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$totalUptime += ceil($row->acctsessiontime / 60);
}
}
# Add usage to our return array # Add usage to our return array
$resultArray['trafficUsage'] = (int)$totalTraffic; $resultArray['trafficUsage'] = 0;
$resultArray['uptimeUsage'] = (int)$totalUptime; $resultArray['uptimeUsage'] = 0;
if (isset($row->totaltraffic) && $row->totaltraffic > 0) {
$resultArray['trafficUsage'] += $row->totaltraffic;
}
if (isset($row->totalsessiontime) && $row->totalsessiontime > 0) {
$resultArray['uptimeUsage'] += $row->totalsessiontime;
}
# Loop through topups and add to return array # Loop through topups and add to return array
$resultArray['trafficTopups'] = 0; $resultArray['trafficTopups'] = 0;
...@@ -241,12 +223,12 @@ function getAdminUserLogs($params) { ...@@ -241,12 +223,12 @@ function getAdminUserLogs($params) {
@TP@accounting.CalledStationID, @TP@accounting.CalledStationID,
@TP@accounting.AcctSessionID, @TP@accounting.AcctSessionID,
@TP@accounting.FramedIPAddress, @TP@accounting.FramedIPAddress,
@TP@accounting.AcctInputOctets, @TP@accounting.AcctInputOctets / 1024 / 1024 +
@TP@accounting.AcctInputGigawords, @TP@accounting.AcctInputGigawords * 4096 AS AcctInput,
@TP@accounting.AcctOutputOctets, @TP@accounting.AcctOutputOctets / 1024 / 1024 +
@TP@accounting.AcctOutputGigawords, @TP@accounting.AcctOutputGigawords * 4096 AS AcctOutput,
@TP@accounting.AcctTerminateCause, @TP@accounting.AcctTerminateCause,
@TP@accounting.AcctSessionTime @TP@accounting.AcctSessionTime / 60 AS AcctSessionTime
FROM FROM
@TP@accounting, @TP@users @TP@accounting, @TP@users
WHERE WHERE
...@@ -266,26 +248,20 @@ function getAdminUserLogs($params) { ...@@ -266,26 +248,20 @@ function getAdminUserLogs($params) {
while ($row = $sth->fetchObject()) { while ($row = $sth->fetchObject()) {
# Input # Input
$acctInputMbyte = 0; $acctInput = 0;
if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) { if (isset($row->acctinput) && $row->acctinput > 0) {
$acctInputMbyte += ceil($row->acctinputoctets / 1024 / 1024); $acctInput += $row->acctinput;
}
if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
$acctInputMbyte += ceil($row->acctinputgigawords * 4096);
} }
# Output # Output
$acctOutputMbyte = 0; $acctOutput = 0;
if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) { if (isset($row->acctoutput) && $row->acctoutput > 0) {
$acctOutputMbyte += ceil($row->acctoutputoctets / 1024 / 1024); $acctOutput += $row->acctoutput;
}
if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$acctOutputMbyte += ceil($row->acctoutputgigawords * 4096);
} }
# Uptime # Uptime
$acctSessionTime = 0; $acctSessionTime = 0;
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) { if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$acctSessionTime += ceil($row->acctsessiontime / 60); $acctSessionTime += $row->acctsessiontime;
} }
# Build array for this row # Build array for this row
...@@ -305,8 +281,8 @@ function getAdminUserLogs($params) { ...@@ -305,8 +281,8 @@ function getAdminUserLogs($params) {
$item['CalledStationID'] = $row->calledstationid; $item['CalledStationID'] = $row->calledstationid;
$item['AcctSessionID'] = $row->acctsessionid; $item['AcctSessionID'] = $row->acctsessionid;
$item['FramedIPAddress'] = $row->framedipaddress; $item['FramedIPAddress'] = $row->framedipaddress;
$item['AcctInputMbyte'] = (int)$acctInputMbyte; $item['AcctInput'] = $acctInput;
$item['AcctOutputMbyte'] = (int)$acctOutputMbyte; $item['AcctOutput'] = $acctOutput;
$item['AcctSessionTime'] = (int)$acctSessionTime; $item['AcctSessionTime'] = (int)$acctSessionTime;
$item['ConnectTermReason'] = strRadiusTermCode($row->acctterminatecause); $item['ConnectTermReason'] = strRadiusTermCode($row->acctterminatecause);
......
...@@ -144,11 +144,11 @@ function getWiSPUserLogsSummary($params) { ...@@ -144,11 +144,11 @@ function getWiSPUserLogsSummary($params) {
$res = DBSelect(" $res = DBSelect("
SELECT SELECT
@TP@accounting.AcctSessionTime, SUM(@TP@accounting.AcctSessionTime) / 60 AS TotalSessionTime,
@TP@accounting.AcctInputOctets, SUM(@TP@accounting.AcctInputOctets) / 1024 / 1024 +
@TP@accounting.AcctInputGigawords, SUM(@TP@accounting.AcctInputGigawords) * 4096 +
@TP@accounting.AcctOutputOctets, SUM(@TP@accounting.AcctOutputOctets) / 1024 / 1024 +
@TP@accounting.AcctOutputGigawords SUM(@TP@accounting.AcctOutputGigawords) * 4096 AS TotalTraffic
FROM FROM
@TP@accounting, @TP@users @TP@accounting, @TP@users
WHERE WHERE
...@@ -163,35 +163,17 @@ function getWiSPUserLogsSummary($params) { ...@@ -163,35 +163,17 @@ function getWiSPUserLogsSummary($params) {
} }
# Set total traffic and uptime used # Set total traffic and uptime used
$totalTraffic = 0; $row = $res->fetchObject();
$totalUptime = 0;
while ($row = $res->fetchObject()) {
# Traffic in
if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
$totalTraffic += ceil($row->acctinputoctets / 1024 / 1024);
}
if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
$totalTraffic += ceil($row->acctinputgigawords * 4096);
}
# Traffic out
if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
$totalTraffic += ceil($row->acctoutputoctets / 1024 / 1024);
}
if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$totalTraffic += ceil($row->acctoutputgigawords * 4096);
}
# Uptime
$sessionTimeItem = 0;
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$totalUptime += ceil($row->acctsessiontime / 60);
}
}
# Add usage to our return array # Add usage to our return array
$resultArray['trafficUsage'] = (int)$totalTraffic; $resultArray['trafficUsage'] = 0;
$resultArray['uptimeUsage'] = (int)$totalUptime; $resultArray['uptimeUsage'] = 0;
if (isset($row->totaltraffic) && $row->totaltraffic > 0) {
$resultArray['trafficUsage'] += $row->totaltraffic;
}
if (isset($row->totalsessiontime) && $row->totalsessiontime > 0) {
$resultArray['uptimeUsage'] += $row->totalsessiontime;
}
# Loop through topups and add to return array # Loop through topups and add to return array
$resultArray['trafficTopups'] = 0; $resultArray['trafficTopups'] = 0;
...@@ -241,12 +223,12 @@ function getWiSPUserLogs($params) { ...@@ -241,12 +223,12 @@ function getWiSPUserLogs($params) {
@TP@accounting.CalledStationID, @TP@accounting.CalledStationID,
@TP@accounting.AcctSessionID, @TP@accounting.AcctSessionID,
@TP@accounting.FramedIPAddress, @TP@accounting.FramedIPAddress,
@TP@accounting.AcctInputOctets, @TP@accounting.AcctInputOctets / 1024 / 1024 +
@TP@accounting.AcctInputGigawords, @TP@accounting.AcctInputGigawords * 4096 AS AcctInput,
@TP@accounting.AcctOutputOctets, @TP@accounting.AcctOutputOctets / 1024 / 1024 +
@TP@accounting.AcctOutputGigawords, @TP@accounting.AcctOutputGigawords * 4096 AS AcctOutput,
@TP@accounting.AcctTerminateCause, @TP@accounting.AcctTerminateCause,
@TP@accounting.AcctSessionTime @TP@accounting.AcctSessionTime / 60 AS AcctSessionTime
FROM FROM
@TP@accounting, @TP@users @TP@accounting, @TP@users
WHERE WHERE
...@@ -266,26 +248,20 @@ function getWiSPUserLogs($params) { ...@@ -266,26 +248,20 @@ function getWiSPUserLogs($params) {
while ($row = $sth->fetchObject()) { while ($row = $sth->fetchObject()) {
# Input # Input
$acctInputMbyte = 0; $acctInput = 0;
if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) { if (isset($row->acctinput) && $row->acctinput > 0) {
$acctInputMbyte += ceil($row->acctinputoctets / 1024 / 1024); $acctInput += $row->acctinput;
}
if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
$acctInputMbyte += ceil($row->acctinputgigawords * 4096);
} }
# Output # Output
$acctOutputMbyte = 0; $acctOutput = 0;
if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) { if (isset($row->acctoutput) && $row->acctoutput > 0) {
$acctOutputMbyte += ceil($row->acctoutputoctets / 1024 / 1024); $acctOutput += $row->acctoutput;
}
if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$acctOutputMbyte += ceil($row->acctoutputgigawords * 4096);
} }
# Uptime # Uptime
$acctSessionTime = 0; $acctSessionTime = 0;
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) { if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$acctSessionTime += ceil($row->acctsessiontime / 60); $acctSessionTime += $row->acctsessiontime;
} }
# Build array for this row # Build array for this row
...@@ -305,8 +281,8 @@ function getWiSPUserLogs($params) { ...@@ -305,8 +281,8 @@ function getWiSPUserLogs($params) {
$item['CalledStationID'] = $row->calledstationid; $item['CalledStationID'] = $row->calledstationid;
$item['AcctSessionID'] = $row->acctsessionid; $item['AcctSessionID'] = $row->acctsessionid;
$item['FramedIPAddress'] = $row->framedipaddress; $item['FramedIPAddress'] = $row->framedipaddress;
$item['AcctInputMbyte'] = (int)$acctInputMbyte; $item['AcctInput'] = $acctInput;
$item['AcctOutputMbyte'] = (int)$acctOutputMbyte; $item['AcctOutput'] = $acctOutput;
$item['AcctSessionTime'] = (int)$acctSessionTime; $item['AcctSessionTime'] = (int)$acctSessionTime;
$item['ConnectTermReason'] = strRadiusTermCode($row->acctterminatecause); $item['ConnectTermReason'] = strRadiusTermCode($row->acctterminatecause);
......
...@@ -193,11 +193,13 @@ function showAdminUserLogsWindow(id) { ...@@ -193,11 +193,13 @@ function showAdminUserLogsWindow(id) {
}, },
{ {
header: "Input Mbyte", header: "Input Mbyte",
dataIndex: 'AcctInputMbyte' dataIndex: 'AcctInput',
renderer: renderUsageFloat
}, },
{ {
header: "Output Mbyte", header: "Output Mbyte",
dataIndex: 'AcctOutputMbyte' dataIndex: 'AcctOutput',
renderer: renderUsageFloat
}, },
{ {
header: "Session Uptime", header: "Session Uptime",
...@@ -243,8 +245,8 @@ function showAdminUserLogsWindow(id) { ...@@ -243,8 +245,8 @@ function showAdminUserLogsWindow(id) {
{type: 'string', dataIndex: 'CalledStationID'}, {type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'AcctSessionID'}, {type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'FramedIPAddress'}, {type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInputMbyte'}, {type: 'numeric', dataIndex: 'AcctInput'},
{type: 'numeric', dataIndex: 'AcctOutputMbyte'}, {type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'}, {type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'} {type: 'string', dataIndex: 'ConnectTermReason'}
] ]
...@@ -344,4 +346,5 @@ function showAdminUserLogsWindow(id) { ...@@ -344,4 +346,5 @@ function showAdminUserLogsWindow(id) {
adminUserLogsWindow.show(); adminUserLogsWindow.show();
} }
// vim: ts=4 // vim: ts=4
...@@ -193,11 +193,13 @@ function showWiSPUserLogsWindow(id) { ...@@ -193,11 +193,13 @@ function showWiSPUserLogsWindow(id) {
}, },
{ {
header: "Input Mbyte", header: "Input Mbyte",
dataIndex: 'AcctInputMbyte' dataIndex: 'AcctInput',
renderer: renderUsageFloat
}, },
{ {
header: "Output Mbyte", header: "Output Mbyte",
dataIndex: 'AcctOutputMbyte' dataIndex: 'AcctOutput',
renderer: renderUsageFloat
}, },
{ {
header: "Session Uptime", header: "Session Uptime",
...@@ -243,8 +245,8 @@ function showWiSPUserLogsWindow(id) { ...@@ -243,8 +245,8 @@ function showWiSPUserLogsWindow(id) {
{type: 'string', dataIndex: 'CalledStationID'}, {type: 'string', dataIndex: 'CalledStationID'},
{type: 'string', dataIndex: 'AcctSessionID'}, {type: 'string', dataIndex: 'AcctSessionID'},
{type: 'string', dataIndex: 'FramedIPAddress'}, {type: 'string', dataIndex: 'FramedIPAddress'},
{type: 'numeric', dataIndex: 'AcctInputMbyte'}, {type: 'numeric', dataIndex: 'AcctInput'},
{type: 'numeric', dataIndex: 'AcctOutputMbyte'}, {type: 'numeric', dataIndex: 'AcctOutput'},
{type: 'numeric', dataIndex: 'AcctSessionTime'}, {type: 'numeric', dataIndex: 'AcctSessionTime'},
{type: 'string', dataIndex: 'ConnectTermReason'} {type: 'string', dataIndex: 'ConnectTermReason'}
] ]
...@@ -344,4 +346,5 @@ function showWiSPUserLogsWindow(id) { ...@@ -344,4 +346,5 @@ function showWiSPUserLogsWindow(id) {
wispUserLogsWindow.show(); wispUserLogsWindow.show();
} }
// vim: ts=4 // vim: ts=4
...@@ -50,11 +50,11 @@ function displayDetails() { ...@@ -50,11 +50,11 @@ function displayDetails() {
$sql = " $sql = "
SELECT SELECT
AcctSessionTime, SUM(AcctSessionTime) / 60 AS AcctSessionTime,
AcctInputOctets, SUM(AcctInputOctets) / 1024 / 1024 +
AcctInputGigawords, SUM(AcctInputGigawords) * 4096 AS AcctInputTraffic,
AcctOutputOctets, SUM(AcctOutputOctets) / 1024 / 1024 +
AcctOutputGigawords SUM(AcctOutputGigawords) * 4096 AS AcctOutputTraffic
FROM FROM
${DB_TABLE_PREFIX}accounting ${DB_TABLE_PREFIX}accounting
WHERE WHERE
...@@ -67,26 +67,22 @@ function displayDetails() { ...@@ -67,26 +67,22 @@ function displayDetails() {
# Set total traffic and uptime used # Set total traffic and uptime used
$totalTraffic = 0; $totalTraffic = 0;
$totalUptime = 0; $totalUptime = 0;
while ($row = $res->fetchObject()) {
# Traffic in
if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
$totalTraffic += ceil($row->acctinputoctets / 1024 / 1024);
}
if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
$totalTraffic += ceil($row->acctinputgigawords * 4096);
}
# Traffic out
if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
$totalTraffic += ceil($row->acctoutputoctets / 1024 / 1024);
}
if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$totalTraffic += ceil($row->acctoutputgigawords * 4096);
}
# Uptime # Pull in row
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) { $row = $res->fetchObject();
$totalUptime += ceil($row->acctsessiontime / 60);
} # Traffic in
if (isset($row->acctinputtraffic) && $row->acctinputtraffic > 0) {
$totalTraffic += $row->acctinputtraffic;
}
# Traffic out
if (isset($row->acctoutputtraffic) && $row->acctoutputtraffic > 0) {
$totalTraffic += $row->acctoutputtraffic;
}
# Uptime
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$totalUptime += $row->acctsessiontime;
} }
# Fetch user uptime and traffic cap # Fetch user uptime and traffic cap
...@@ -350,13 +346,17 @@ function displayDetails() { ...@@ -350,13 +346,17 @@ function displayDetails() {
<?php <?php
} else { } else {
?> ?>
<td class="value"><?php echo $topupTrafficRemaining; ?> MB</td> <td class="value"><?php printf("%.2f",$topupTrafficRemaining); ?> MB</td>
<?php <?php
} }
if (isset($currentTrafficTopup['Used']) && isset($currentTrafficTopup['Cap'])) { if (isset($currentTrafficTopup['Used']) && isset($currentTrafficTopup['Cap'])) {
?> ?>
<td class="value"><?php echo $currentTrafficTopup['Used']; <td class="value">
print("/".$currentTrafficTopup['Cap']); ?> MB</td> <?php
printf("%.2f",$currentTrafficTopup['Used']);
print("/").$currentTrafficTopup['Cap'];
?> MB
</td>
<?php <?php
} else { } else {
?> ?>
...@@ -364,7 +364,7 @@ function displayDetails() { ...@@ -364,7 +364,7 @@ function displayDetails() {
<?php <?php
} }
?> ?>
<td class="value"><?php echo $totalTraffic; ?> MB</td> <td class="value"><?php printf("%.2f",$totalTraffic); ?> MB</td>
</tr> </tr>
<tr> <tr>
<td colspan="4" class="section">Uptime Usage</td> <td colspan="4" class="section">Uptime Usage</td>
...@@ -396,13 +396,17 @@ function displayDetails() { ...@@ -396,13 +396,17 @@ function displayDetails() {
<?php <?php
} else { } else {
?> ?>
<td class="value"><?php echo $topupUptimeRemaining; ?> Min</td> <td class="value"><?php printf("%.2f",$topupUptimeRemaining); ?> Min</td>
<?php <?php
} }
if (isset($currentUptimeTopup['Used']) && isset($currentUptimeTopup['Cap'])) { if (isset($currentUptimeTopup['Used']) && isset($currentUptimeTopup['Cap'])) {
?> ?>
<td class="value"><?php echo $currentUptimeTopup['Used']; <td class="value">
print("/".$currentUptimeTopup['Cap']); ?> Min</td> <?php
printf("%.2f",$currentUptimeTopup['Used']);
print("/").$currentUptimeTopup['Cap'];
?> Min
</td>
<?php <?php
} else { } else {
?> ?>
...@@ -410,7 +414,7 @@ function displayDetails() { ...@@ -410,7 +414,7 @@ function displayDetails() {
<?php <?php
} }
?> ?>
<td class="value"><?php echo $totalUptime; ?> Min</td> <td class="value"><?php printf("%.2f",$totalUptime); ?> Min</td>
</tr> </tr>
<!-- <!--
<tr> <tr>
......
...@@ -118,17 +118,17 @@ function displayLogs() { ...@@ -118,17 +118,17 @@ function displayLogs() {
# Accounting query FIXME nas receive and transmit rates # Accounting query FIXME nas receive and transmit rates
$sql = " $sql = "
SELECT SELECT
EventTimestamp, EventTimestamp,
CallingStationID, CallingStationID,
AcctSessionTime, AcctSessionTime / 60 AS AcctSessionTime,
AcctInputOctets, AcctInputOctets / 1024 / 1024 +
AcctInputGigawords, AcctInputGigawords * 4096 AS AcctInputMbyte,
AcctOutputOctets, AcctOutputOctets / 1024 / 1024 +
AcctOutputGigawords, AcctOutputGigawords * 4096 AS AcctOutputMbyte,
AcctTerminateCause AcctTerminateCause
FROM FROM
${DB_TABLE_PREFIX}accounting ${DB_TABLE_PREFIX}accounting
WHERE WHERE
Username = ".$db->quote($_SESSION['username'])." Username = ".$db->quote($_SESSION['username'])."
$extraSQL $extraSQL
ORDER BY ORDER BY
...@@ -147,34 +147,28 @@ function displayLogs() { ...@@ -147,34 +147,28 @@ function displayLogs() {
# Input data calculation # Input data calculation
$inputData = 0; $inputData = 0;
if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) { if (isset($row->acctinputmbyte) && $row->acctinputmbyte > 0) {
$inputData += ceil($row->acctinputoctets / 1024 / 1024); $inputData += $row->acctinputmbyte;
}
if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
$inputData += ceil($row->acctinputgigawords * 4096);
} }
$totalInput += $inputData; $totalInput += $inputData;
# Output data calculation # Output data calculation
$outputData = 0; $outputData = 0;
if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) { if (isset($row->acctoutputmbyte) && $row->acctoutputmbyte > 0) {
$outputData += ceil($row->acctoutputoctets / 1024 / 1024); $outputData += $row->acctoutputmbyte;
}
if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$outputData += ceil($row->acctoutputgigawords * 4096);
} }
$totalOutput += $outputData; $totalOutput += $outputData;
# Uptime calculation # Uptime calculation
$sessionTime = 0; $sessionTime = 0;
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) { if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$sessionTime += ceil($row->acctsessiontime / 60); $sessionTime += $row->acctsessiontime;
} }
$totalTime += $sessionTime; $totalTime += $sessionTime;
?> ?>
<tr> <tr>
<td class="desc"><?php echo $row->eventtimestamp; ?></td> <td class="desc"><?php echo $row->eventtimestamp; ?></td>
<td class="desc"><?php echo $sessionTime; ?></td> <td class="desc"><?php printf("%.2f",$sessionTime); ?></td>
<td class="desc"><?php echo $row->callingstationid; ?></td> <td class="desc"><?php echo $row->callingstationid; ?></td>
<td class="center desc"><?php echo strRadiusTermCode($row->acctterminatecause); ?></td> <td class="center desc"><?php echo strRadiusTermCode($row->acctterminatecause); ?></td>
<td class="center desc"> <td class="center desc">
...@@ -191,8 +185,8 @@ function displayLogs() { ...@@ -191,8 +185,8 @@ function displayLogs() {
} }
?> ?>
</td> </td>
<td class="right desc"><?php echo $inputData; ?></td> <td class="right desc"><?php printf("%.2f",$inputData); ?></td>
<td class="right desc"><?php echo $outputData; ?></td> <td class="right desc"><?php printf("%.2f",$outputData); ?></td>
</tr> </tr>
<?php <?php
} }
...@@ -207,12 +201,12 @@ function displayLogs() { ...@@ -207,12 +201,12 @@ function displayLogs() {
?> ?>
<tr> <tr>
<td colspan="6" class="right">Sub Total:</td> <td colspan="6" class="right">Sub Total:</td>
<td class="right desc"><?php echo $totalInput; ?></td> <td class="right desc"><?php printf("%.2f",$totalInput); ?></td>
<td class="right desc"><?php echo $totalOutput; ?></td> <td class="right desc"><?php printf("%.2f",$totalOutput); ?></td>
</tr> </tr>
<tr> <tr>
<td colspan="6" class="right">Total:</td> <td colspan="6" class="right">Total:</td>
<td colspan="2" class="center desc"><?php echo $totalTraffic; ?></td> <td colspan="2" class="center desc"><?php printf("%.2f",$totalTraffic); ?></td>
</tr> </tr>
<?php <?php
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment