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

Syntax fixes, improved formatting

parent d5f1537f
No related branches found
No related tags found
No related merge requests found
......@@ -35,50 +35,51 @@ printHeader(array(
if ($_POST['frmaction'] == "add") {
?>
<p class="pageheader">Add Group</p>
<?php
?>
<form method="post" action="group-add.php">
<div>
<input type="hidden" name="frmaction" value="add2" />
</div>
<table class="entry">
<tr>
<td class="entrytitle">Name</td>
<td><input type="text" name="group_name" /></td>
</tr>
<tr>
<td class="entrytitle">Priority</td>
<td><input type="text" name="group_priority" /></td>
</tr>
<tr>
<td class="entrytitle">Disabled</td>
<td>
<select name="group_disabled">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
<tr>
<td class="entrytitle texttop">Comment</td>
<td><textarea name="group_comment" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" />
</td>
</tr>
</table>
</form>
<?php
<p class="pageheader">Add Group</p>
<form method="post" action="group-add.php">
<div>
<input type="hidden" name="frmaction" value="add2" />
</div>
<table class="entry">
<tr>
<td class="entrytitle">Name</td>
<td><input type="text" name="group_name" /></td>
</tr>
<tr>
<td class="entrytitle">Priority</td>
<td><input type="text" name="group_priority" /></td>
</tr>
<tr>
<td class="entrytitle">Disabled</td>
<td>
<select name="group_disabled">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
<tr>
<td class="entrytitle texttop">Comment</td>
<td><textarea name="group_comment" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" />
</td>
</tr>
</table>
</form>
<?php
# Check we have all params
} elseif ($_POST['frmaction'] == "add2") {
?>
<p class="pageheader">Group Add Results</p>
<?php
......@@ -92,22 +93,31 @@ if ($_POST['frmaction'] == "add") {
$_POST['group_comment'],
));
if ($res) {
?>
<div class="notice">Group created</div>
<?php
} else {
?>
<div class="warning">Failed to create group</div>
<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
<?php
}
<?php
}
} else {
?>
<div class="warning">Invalid invocation</div>
<?php
}
......
......@@ -24,11 +24,9 @@ include_once("includes/db.php");
include_once("includes/tooltips.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "group-main.php"
......@@ -36,8 +34,7 @@ printHeader(array(
));
if ($_POST['frmaction'] == "add") {
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "add") {
?>
<p class="pageheader">Add attribute</p>
......@@ -59,10 +56,10 @@ if ($_POST['frmaction'] == "add") {
<option value=":=">:=</option>
<option value="+=">+=</option>
<option value="!=">!=</option>
<option value=">">&gt</option>
<option value="<">&lt</option>
<option value=">=">&gt=</option>
<option value="<=">&lt=</option>
<option value=">">&gt;</option>
<option value="<">&lt;</option>
<option value=">=">&gt;=</option>
<option value="<=">&lt;=</option>
<option value="=~">=~</option>
<option value="!~">!~</option>
<option value="=*">=*</option>
......@@ -87,15 +84,22 @@ if ($_POST['frmaction'] == "add") {
# Check we have all params
} elseif ($_POST['frmaction'] == "add2") {
?>
<p class="pageheader">Attribute Add Results</p>
<?php
# Check for empty values
if (empty($_POST['attr_name']) || empty($_POST['attr_operator']) || empty($_POST['attr_value'])) {
?>
<div class="warning">Submission cannot have empty value</div>
<?php
} else {
$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}group_attributes (GroupID,Name,Operator,Value) VALUES (?,?,?,?)");
# Which user am I working with?
......@@ -108,22 +112,33 @@ if ($_POST['frmaction'] == "add") {
$_POST['attr_value'],
));
if ($res) {
?>
<div class="notice">Attribute added</div>
<?php
session_destroy();
session_destroy();
} else {
?>
<div class="warning">Failed to add attribute</div>
<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
<?php
}
}
} else {
?>
<div class="warning">Invalid invocation</div>
<?php
}
printFooter();
......
......@@ -35,17 +35,18 @@ printHeader(array(
),
));
# Display change screen
if ($_POST['frmaction'] == "change") {
if (isset($_POST['frmaction'] && $_POST['frmaction'] == "change") {
# Check an attribute was selected
if (isset($_POST['attr_id'])) {
# Prepare statement
$temp = $_POST['attr_id'];
$sql = "SELECT ID, Name, Operator, Value, Disabled FROM ${DB_TABLE_PREFIX}group_attributes WHERE ID = $temp";
$sql = "SELECT ID, Name, Operator, Value, Disabled FROM ${DB_TABLE_PREFIX}group_attributes WHERE ID = '$temp'";
$res = $db->query($sql);
$row = $res->fetchObject();
?>
<p class="pageheader">Update Group Attribute</p>
<form action="group-attribute-change.php" method="post">
......@@ -63,14 +64,14 @@ if ($_POST['frmaction'] == "change") {
<td class="entrytitle texttop">
Name
</td>
<td class="oldval texttop"><?php echo $row->name ?></td>
<td class="oldval texttop"><?php echo $row->name; ?></td>
<td><textarea name="group_attributes_name" cols="40" rows="1"></textarea></td>
</tr>
<tr>
<td class="entrytitle texttop">
Operator
</td>
<td class="oldval texttop"><?php echo $row->operator ?></td>
<td class="oldval texttop"><?php echo $row->operator; ?></td>
<td>
<select name="group_attributes_operator">
<option value="=">=</option>
......@@ -78,10 +79,10 @@ if ($_POST['frmaction'] == "change") {
<option value=":=">:=</option>
<option value="+=">+=</option>
<option value="!=">!=</option>
<option value=">">&gt</option>
<option value="<">&lt</option>
<option value=">=">&gt=</option>
<option value="<=">&lt=</option>
<option value=">">&gt;</option>
<option value="<">&lt;</option>
<option value=">=">&gt;=</option>
<option value="<=">&lt;=</option>
<option value="=~">=~</option>
<option value="!~">!~</option>
<option value="=*">=*</option>
......@@ -93,12 +94,12 @@ if ($_POST['frmaction'] == "change") {
</tr>
<tr>
<td class="entrytitle texttop">Value</td>
<td class="oldval texttop"><?php echo $row->value ?></td>
<td class="oldval texttop"><?php echo $row->value; ?></td>
<td><textarea name="group_attributes_value" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td class="entrytitle">Disabled</td>
<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no'; ?></td>
<td>
<select name="group_attributes_disabled" />
<option value="">--</option>
......@@ -115,21 +116,28 @@ if ($_POST['frmaction'] == "change") {
<input type="submit" />
</div>
</form>
<?php
$res->closeCursor();
$res->closeCursor();
} else {
?>
<div class="warning">No attribute selected</div>
<?php
}
<div class="warning">No attribute selected</div>
<?php
}
# SQL Updates
} elseif ($_POST['frmaction'] == "change2") {
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "change2") {
?>
<p class="pageheader">Attribute Update Results</p>
<?php
# Check an attribute was selected
if (isset($_POST['attr_id'])) {
......@@ -154,35 +162,51 @@ if ($_POST['frmaction'] == "change") {
$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}group_attributes SET $updateStr WHERE ID = ".$db->quote($_POST['attr_id']));
if ($res) {
?>
<div class="notice">Attribute updated</div>
<?php
} else {
?>
<div class="warning">Error updating attribute</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
}
}
# Warn
} else {
?>
<div class="warning">No attribute updates</div>
<?php
}
}
# Warn
} else {
?>
<div class="error">No attribute data available</div>
<?php
}
<?php
}
} else {
?>
<div class="warning">Invalid invocation</div>
<?php
}
......
......@@ -37,7 +37,7 @@ printHeader(array(
# Display delete confirm screen
if ($_POST['frmaction'] == "delete") {
if (isset($_POST['frmaction'] && $_POST['frmaction'] == "delete") {
# Check a user was selected
if (isset($_POST['attr_id'])) {
?>
......@@ -63,7 +63,7 @@ if ($_POST['frmaction'] == "delete") {
# SQL Updates
} elseif ($_POST['frmaction'] == "delete2") {
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete2") {
?>
<p class="pageheader">Attribute Delete Results</p>
<?php
......
......@@ -81,13 +81,7 @@ printHeader(array(
$sql = "SELECT ID, Name, Operator, Value, Disabled FROM ${DB_TABLE_PREFIX}group_attributes WHERE GroupID = $temp ORDER BY ID";
$res = $db->query($sql);
$rownums = 0;
while ($row = $res->fetchObject()) {
if ($row->id != NULL) {
$rownums = $rownums + 1;
} else {
$rownums = $rownums - 1;
}
?>
<tr class="resultsitem">
<td><input type="radio" name="attr_id" value="<?php echo $row->id ?>"/><?php echo $row->id ?></td>
......@@ -99,7 +93,7 @@ printHeader(array(
<?php
}
$res->closeCursor();
if ($rownums <= 0) {
if ($res->rowCount() == 0) {
?>
<p />
<tr>
......@@ -107,7 +101,6 @@ printHeader(array(
</tr>
<?php
}
unset($rownums);
} else {
?>
<tr class="resultitem">
......
......@@ -33,7 +33,6 @@ printHeader(array(
));
?>
<p class="pageheader">User Log</p>
......@@ -165,51 +164,41 @@ if (isset($_POST['user_id'])) {
$totalInputData = 0;
$totalOutputData = 0;
$totalSessionTime = 0;
$rownums = 0;
while ($row = $res->fetchObject()) {
# Data usage
# ==========
# Input
$inputDataItem = 0;
if (!empty($row->acctinputoctets) && $row->acctinputoctets > 0) {
$inputDataItem = ($row->acctinputoctets / 1024 / 1024);
$inputDataItem += ($row->acctinputoctets / 1024) / 1024;
}
if (!empty($row->acctinputgigawords) && $row->inputgigawords > 0) {
$inputDataItem = ($row->acctinputgigawords * 4096);
}
if ($inputDataItem != 0) {
} else {
$inputDataItemDisplay = 0;
$inputDataItem += ($row->acctinputgigawords * 4096);
}
$totalInputData = $totalInputData + $inputDataItem;
$totalInputData += $inputDataItem;
# Output
$outputDataItem = 0;
if (!empty($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
$outputDataItem = ($row->acctoutputoctets / 1024 / 1024);
$outputDataItem += ($row->acctoutputoctets / 1024) / 1024;
}
if (!empty($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$outputDataItem = ($row->acctoutputgigawords * 4096);
}
if ($outputDataItem != 0) {
} else {
$outputDataItem = 0;
$outputDataItem += ($row->acctoutputgigawords * 4096);
}
$totalOutputData = $totalOutputData + $outputDataItem;
# Add up time
$sessionTimeItem = 0;
if (!empty($row->acctsessiontime) && $row->acctsessiontime > 0) {
$sessionTimeItem = $row->acctsessiontime / 60;
$sessionTimeItem += $row->acctsessiontime / 60;
}
$totalSessionTime = $totalSessionTime + $sessionTimeItem;
$totalSessionTime += $sessionTimeItem;
?>
......
......@@ -77,24 +77,17 @@ if (!isset($_POST['frmaction']))
$sql = "SELECT ID, Username, Disabled FROM ${DB_TABLE_PREFIX}users ORDER BY ID ASC";
$res = $db->query($sql);
$rownums = 0;
# List users
while ($row = $res->fetchObject()) {
if ($row->id != NULL) {
$rownums = $rownums + 1;
} else {
$rownums = $rownums - 1;
}
?>
<tr class="resultsitem">
<td><input type="radio" name="user_id" value="<?php echo $row->id ?>"/><?php echo $row->id ?></td>
<td><?php echo $row->username ?></td>
<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
<td><input type="radio" name="user_id" value="<?php echo $row->id; ?>"/><?php echo $row->id; ?></td>
<td><?php echo $row->username; ?></td>
<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no'; ?></td>
</tr>
<?php
}
$res->closeCursor();
if ($rownums <= 0) {
if ($res->rowCount() == 0) {
?>
<p />
<tr>
......@@ -102,7 +95,7 @@ if (!isset($_POST['frmaction']))
</tr>
<?php
}
unset($rownums);
$res->closeCursor();
?>
</table>
</form>
......
......@@ -188,13 +188,13 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "insert") {
$userPasswordResult = $userPasswordStatement->execute(array($userPassword));
# Insert data limit into user_attributes table
$userDataStatement = $db->prepare(" INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
($userID,'SMRadius-Capping-Traffic-Limit',':=',?)
");
$userDataLimitStatement = $db->prepare("INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
($userID,'SMRadius-Capping-Traffic-Limit',':=',?)
");
$userDataResult = $userDataStatement->execute(array($dataLimit,));
$userDataLimitResult = $userDataLimitStatement->execute(array($dataLimit,));
# Insert time limit into user_attributes table
$userTimeStatement = $db->prepare(" INSERT INTO
......@@ -214,10 +214,15 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "insert") {
$userTimeOutResult = $userTimeOutStatement->execute(array($sessionTimeout,));
if ($userTimeOutResult && $userTimeResult && $userDataResult && $userPasswordResult && $userDataLimitResult) {
$failed = 0;
} else {
$failed = 1;
}
# If one was not successful, rollback
} else {
$db->rollback;
print_r($db->errorInfo());
$db->rollback;
$failed = 1;
break;
}
......
......@@ -92,14 +92,6 @@ if (!isset($_POST['frmaction'])) {
<td class="entrytitle">IP Address</td>
<td><input type="text" name="user_ip_address" /></td>
</tr>
<!--<tr>
<td class="entrytitle">Pool Name</td>
<td><input type="text" name="pool_name" /></td>
</tr>
<tr>
<td class="entrytitle">Group Name</td>
<td><input type="text" name="group_name" /></td>
</tr>-->
<tr>
<td class="entrytitle">Data Usage Limit (MB)</td>
<td><input type="text" name="user_data_limit" /></td>
......
......@@ -35,9 +35,8 @@ printHeader(array(
));
# Display delete confirm screen
if ($_POST['frmaction'] == "delete") {
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") {
# Check a user was selected
if (isset($_POST['user_id'])) {
......@@ -69,7 +68,7 @@ if ($_POST['frmaction'] == "delete") {
}
# SQL Updates
} elseif ($_POST['frmaction'] == "delete2") {
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete2") {
?>
......@@ -79,47 +78,22 @@ if ($_POST['frmaction'] == "delete") {
if (isset($_POST['user_id'])) {
if ($_POST['confirm'] == "yes") {
$failTotDeleteAll = 0;
$db->beginTransaction();
# Delete user data
$userDataDeleteResult = $db->exec("DELETE FROM userdata WHERE UserID = ".$_POST['user_id']);
if ($userDataDeleteresult !== FALSE) {
# Delete user attributes
$attrDeleteResult = $db->exec("DELETE FROM user_attributes WHERE UserID = ".$_POST['user_id']);
if ($attrDeleteResult !== FALSE) {
# Delete from users
$userDeleteResult = $db->exec("DELETE FROM users WHERE ID = ".$_POST['user_id']);
if ($userDeleteResult !== FALSE) {
?>
<div class="notice">User with ID: <?php print_r($_POST['user_id']);?> deleted</div>
<?php
$db->commit();
} else {
# Delete user attributes
$attrDeleteResult = $db->exec("DELETE FROM user_attributes WHERE UserID = ".$_POST['user_id']);
# Delete from users
$userDeleteResult = $db->exec("DELETE FROM users WHERE ID = ".$_POST['user_id']);
if ($userDataDeleteResult && $attrDeleteResult && $userDeleteResult) {
?>
<div class="warning">Error deleting user</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<div class="notice">User with ID: <?php print_r($_POST['user_id']);?> deleted</div>
<?php
$failToDeleteAll = 1;
}
} else {
?>
<div class="warning">Error deleting user</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
$failToDeleteAll = 1;
}
$db->commit();
} else {
?>
......@@ -129,10 +103,6 @@ if ($_POST['frmaction'] == "delete") {
<?php
$failToDeleteAll = 1;
}
# If we failed at all, rollback
if ($failToDeleteAll == 1) {
$db->rollback();
}
} else {
......
......@@ -31,7 +31,7 @@ printHeader(array(
# Display edit screen
if ($_POST['frmaction'] == "edit") {
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "edit") {
# Check a user was selected
if (isset($_POST['user_id'])) {
......@@ -46,7 +46,7 @@ if ($_POST['frmaction'] == "edit") {
FROM
userdata
WHERE
UserID = $userID
UserID = '$userID'
";
$userDataResult = $db->query($sql);
......@@ -57,7 +57,7 @@ if ($_POST['frmaction'] == "edit") {
FROM
user_attributes
WHERE
UserID = $userID
UserID = '$userID'
AND
Name = 'Framed-IP-Address'
";
......@@ -70,7 +70,7 @@ if ($_POST['frmaction'] == "edit") {
FROM
user_attributes
WHERE
UserID = $userID
UserID = '$userID'
AND
Name = 'Calling-Station-Id'
";
......@@ -84,7 +84,7 @@ if ($_POST['frmaction'] == "edit") {
FROM
user_attributes
WHERE
UserID = $userID
UserID = '$userID'
AND
Name = 'User-Password'
";
......@@ -98,7 +98,7 @@ if ($_POST['frmaction'] == "edit") {
FROM
user_attributes
WHERE
UserID = $userID
UserID = '$userID'
AND
Name = 'SMRadius-Capping-Traffic-Limit'
";
......@@ -112,7 +112,7 @@ if ($_POST['frmaction'] == "edit") {
FROM
user_attributes
WHERE
UserID = $userID
UserID = '$userID'
AND
Name = 'SMRadius-Capping-Time-Limit'
";
......@@ -139,27 +139,27 @@ if ($_POST['frmaction'] == "edit") {
</tr>
<tr>
<td class="entrytitle texttop">Password</td>
<td class="oldval texttop"><?php echo $userPasswordRow->value ?></td>
<td class="oldval texttop"><?php echo $userPasswordRow->value; ?></td>
<td><input type="password" name="new_password" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Data Limit</td>
<td class="oldval texttop"><?php echo $dataLimit ?> MB</td>
<td class="oldval texttop"><?php echo $dataLimit; ?> MB</td>
<td><input type="text" name="new_data_limit" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Time Limit</td>
<td class="oldval texttop"><?php echo $timeLimit ?> Min</td>
<td class="oldval texttop"><?php echo $timeLimit; ?> Min</td>
<td><input type="text" name="new_time_limit" /></td>
</tr>
<tr>
<td class="entrytitle texttop">MAC Address</td>
<td class="oldval texttop"><?php echo $callingStationRow->value ?></td>
<td class="oldval texttop"><?php echo $callingStationRow->value; ?></td>
<td><input type="text" name="new_mac_address" /></td>
</tr>
<tr>
<td class="entrytitle texttop">IP Address</td>
<td class="oldval texttop"><?php echo $framedIPRow->value ?></td>
<td class="oldval texttop"><?php echo $framedIPRow->value; ?></td>
<td><input type="text" name="new_ip_address" /></td>
</tr>
<tr>
......@@ -172,27 +172,27 @@ if ($_POST['frmaction'] == "edit") {
</tr>
<tr>
<td class="entrytitle texttop">First Name</td>
<td class="oldval texttop"><?php echo $userDataRow->firstname ?></td>
<td class="oldval texttop"><?php echo $userDataRow->firstname; ?></td>
<td><input type="text" name="new_firstname" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Last Name</td>
<td class="oldval texttop"><?php echo $userDataRow->lastname ?></td>
<td class="oldval texttop"><?php echo $userDataRow->lastname; ?></td>
<td><input type="text" name="new_lastname" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Location</td>
<td class="oldval texttop"><?php echo $userDataRow->location ?></td>
<td class="oldval texttop"><?php echo $userDataRow->location; ?></td>
<td><input type="text" name="new_location" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Email</td>
<td class="oldval texttop"><?php echo $userDataRow->email ?></td>
<td class="oldval texttop"><?php echo $userDataRow->email; ?></td>
<td><input type="text" name="new_email" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Phone</td>
<td class="oldval texttop"><?php echo $userDataRow->phone ?></td>
<td class="oldval texttop"><?php echo $userDataRow->phone; ?></td>
<td><input type="text" name="new_phone" /></td>
</tr>
</table>
......@@ -223,7 +223,7 @@ if ($_POST['frmaction'] == "edit") {
$callingStationResult->closeCursor();
# SQL Updates
} elseif ($_POST['frmaction'] == "edit2") {
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "edit2") {
?>
......
......@@ -196,16 +196,7 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "dofilter") {
$res->execute($extraSQLVals);
# List users
$rownums = 0;
while ($row = $res->fetchObject()) {
# If there was nothing returned we want to know about it
if ($row->id != NULL) {
$rownums = $rownums + 1;
} else {
$rownums = $rownums - 1;
}
# Second dirty query to get user's attributes
$tempUserID = $row->id;
......@@ -257,10 +248,8 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "dofilter") {
<?php
}
$res->closeCursor();
# If there were no rows, complain
if ($rownums <= 0) {
if ($res->rowCount() == 0) {
?>
......@@ -272,6 +261,7 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "dofilter") {
<?php
}
$res->closeCursor();
?>
......
......@@ -165,61 +165,41 @@ if (isset($_POST['user_id'])) {
$totalInputData = 0;
$totalOutputData = 0;
$totalSessionTime = 0;
$rownums = 0;
while ($row = $res->fetchObject()) {
if ($row->eventtimestamp != NULL) {
$rownums = $rownums + 1;
} else {
$rownums = $rownums - 1;
}
# Data usage
# ==========
# Input
$inputDataItem = 0;
if (!empty($row->acctinputoctets) && $row->acctinputoctets > 0) {
$inputDataItem = ($row->accinputoctets / 1024 / 1024);
$inputDataItem += ($row->acctinputoctets / 1024) / 1024;
}
if (!empty($row->acctinputgigawords) && $row->inputgigawords > 0) {
$inputDataItem = ($row->acctinputgigawords * 4096);
}
if ($inputDataItem != 0) {
$inputDataItemDisplay = ceil($inputDataItem * 100)/100;
} else {
$inputDataItemDisplay = 0;
$inputDataItem += ($row->acctinputgigawords * 4096);
}
$totalInputData = $totalInputData + $inputDataItem;
$totalInputData += $inputDataItem;
# Output
$outputDataItem = 0;
if (!empty($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
$outputDataItem = ($row->acctoutputoctets / 1024 / 1024);
$outputDataItem += ($row->acctoutputoctets / 1024) / 1024;
}
if (!empty($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$outputDataItem = ($row->acctoutputgigawords * 4096);
}
if ($outputDataItem != 0) {
$outputDataItem = ceil($outputDataItem * 100)/100;
} else {
$outputDataItem = 0;
$outputDataItem += ($row->acctoutputgigawords * 4096);
}
$totalOutputData = $totalOutputData + $outputDataItem;
$totalOutputData += $outputDataItem;
# Add up time
$sessionTimeItem = 0;
if (!empty($row->acctsessiontime) && $row->acctsessiontime > 0) {
$sessionTimeItem = $row->acctsessiontime / 60;
$sessionTimeItem = ceil($sessionTimeItem * 100)/100;
$sessionTimeItem += $row->acctsessiontime / 60;
}
$totalSessionTime = $totalSessionTime + $sessionTimeItem;
$totalSessionTime = ceil($totalSessionTime * 100)/100;
$totalSessionTime += $sessionTimeItem;
?>
......@@ -238,9 +218,9 @@ if (isset($_POST['user_id'])) {
<td class="textcenter"><?php echo $row->nasidentifier; ?></td>
<td class="textcenter"><?php echo $row->nasipaddress; ?></td>
<td class="textcenter"><?php echo $row->acctdelaytime; ?></td>
<td class="textcenter"><?php echo $sessionTimeItem; ?> Min</td>
<td class="textcenter"><?php echo $inputDataItem; ?> MB</td>
<td class="textcenter"><?php echo $outputDataItem; ?> MB</td>
<td class="textcenter"><?php printf('%.2f',$sessionTimeItem); ?> Min</td>
<td class="textcenter"><?php printf('%.2f',$inputDataItem); ?> MB</td>
<td class="textcenter"><?php printf('%.2f',$outputDataItem); ?> MB</td>
<td class="textcenter"><?php echo $row->acctstatustype; ?></td>
<td class="textcenter"><?php echo strRadiusTermCode($row->acctterminatecause); ?></td>
</tr>
......@@ -248,9 +228,7 @@ if (isset($_POST['user_id'])) {
<?php
}
$res->closeCursor();
if ($rownums <= 0) {
if ($res->rowCount() == 0) {
?>
......@@ -279,9 +257,9 @@ if (isset($_POST['user_id'])) {
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter" style="font-weight: bold;"><? echo $totalSessionTime ?> Min</td>
<td class="textcenter" style="font-weight: bold;"><? echo $totalInputData ?> MB</td>
<td class="textcenter" style="font-weight: bold;"><? echo $totalOutputData ?> MB</td>
<td class="textcenter" style="font-weight: bold;"><? printf('%.2f',$totalSessionTime); ?> Min</td>
<td class="textcenter" style="font-weight: bold;"><? printf('%.2f',$totalInputData); ?> MB</td>
<td class="textcenter" style="font-weight: bold;"><? printf('%.2f',$totalOutputData); ?> MB</td>
<td class="textcenter"></td>
<td class="textcenter"></td>
</tr>
......@@ -289,6 +267,7 @@ if (isset($_POST['user_id'])) {
<?php
}
$res->closeCursor();
?>
</table>
<?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