diff --git a/webui/group-add.php b/webui/group-add.php index 3858a206757b6e00da5d92db0c5a898bb4c8ffc2..afc37d023ae94e52cbd57bf68fc750d2602e788f 100644 --- a/webui/group-add.php +++ b/webui/group-add.php @@ -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 + } diff --git a/webui/group-attribute-add.php b/webui/group-attribute-add.php index cdd9cdf63a9b4878e364ac997b0355b6ec171520..33a331b1bb39e785cbc0706bc45e33cf3c6fb0a3 100644 --- a/webui/group-attribute-add.php +++ b/webui/group-attribute-add.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=">">></option> - <option value="<"><</option> - <option value=">=">>=</option> - <option value="<="><=</option> + <option value=">">></option> + <option value="<"><</option> + <option value=">=">>=</option> + <option value="<="><=</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(); diff --git a/webui/group-attribute-change.php b/webui/group-attribute-change.php index c29cdef07d1568907934eadba7f7287db61013d9..359927f53bd3545d61e1edd989e54578065dfb84 100644 --- a/webui/group-attribute-change.php +++ b/webui/group-attribute-change.php @@ -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=">">></option> - <option value="<"><</option> - <option value=">=">>=</option> - <option value="<="><=</option> + <option value=">">></option> + <option value="<"><</option> + <option value=">=">>=</option> + <option value="<="><=</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 + } diff --git a/webui/group-attribute-delete.php b/webui/group-attribute-delete.php index 6a6eab674259f05a3306c0cefc08aca73ce7ac4b..a4bedf25f73b4ff72e30912fde2e8b6e6fc8a48c 100644 --- a/webui/group-attribute-delete.php +++ b/webui/group-attribute-delete.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 diff --git a/webui/group-attributes.php b/webui/group-attributes.php index 84c8725a84cbb64b2472b5adc59eeeb020ad2173..f4daa02d0c97ebbbafa88edf3ad28ed5fbc617bd 100644 --- a/webui/group-attributes.php +++ b/webui/group-attributes.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"> diff --git a/webui/user-logs.php b/webui/user-logs.php index 32aa0d9b6a5aa8b431357c186ca3db8fc6228ebd..32f72fc9aac034c50474e81ab7c661953cd1ad96 100644 --- a/webui/user-logs.php +++ b/webui/user-logs.php @@ -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; ?> diff --git a/webui/user-main.php b/webui/user-main.php index 9d09608656a54965043c3cddcb5e64f1858bc8b3..066302c4c82df9b24f0db06373361bd3ba836227 100644 --- a/webui/user-main.php +++ b/webui/user-main.php @@ -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> diff --git a/webui/wisp-multiuser-add.php b/webui/wisp-multiuser-add.php index b98e93686b0275e11e996c988565abb6b872252e..00b74a79675c833f9c17dedc2ba29722b6d97bbd 100644 --- a/webui/wisp-multiuser-add.php +++ b/webui/wisp-multiuser-add.php @@ -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; } diff --git a/webui/wisp-user-add.php b/webui/wisp-user-add.php index b874f89679f38466f0ee0b1ffec1cba860090dc9..e79667bfc498e593fb2f8867ebdcc85da5c57139 100644 --- a/webui/wisp-user-add.php +++ b/webui/wisp-user-add.php @@ -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> diff --git a/webui/wisp-user-delete.php b/webui/wisp-user-delete.php index 297df45b26f0a7a2c31efcd71d2c5bc575d62190..75ac1b4cf34670548f93f892853ebb605594e826 100644 --- a/webui/wisp-user-delete.php +++ b/webui/wisp-user-delete.php @@ -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 { diff --git a/webui/wisp-user-edit.php b/webui/wisp-user-edit.php index 3f8b297d426ef049582d607b14f71062caff734d..b2447176970821ddab0ca5885ac74e7f8bcc2c3f 100644 --- a/webui/wisp-user-edit.php +++ b/webui/wisp-user-edit.php @@ -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") { ?> diff --git a/webui/wisp-user-list.php b/webui/wisp-user-list.php index 07f638c9992d8be0f8085cf0b78f736a25cdc547..10d1f7924b340f6c19cce41b203e31475d0e2a53 100644 --- a/webui/wisp-user-list.php +++ b/webui/wisp-user-list.php @@ -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(); ?> diff --git a/webui/wisp-user-logs.php b/webui/wisp-user-logs.php index 1b349773ebee0f8899ef25815e6cc55c26ddff17..39e9b75b523805384a136d6b1731f6509e620e1f 100644 --- a/webui/wisp-user-logs.php +++ b/webui/wisp-user-logs.php @@ -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