Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • smradius/smradius
  • centiva-shail/smradius
  • nkukard/smradius
3 results
Show changes
Showing
with 49 additions and 1791 deletions
webui/tooltips/bt.gif

1.55 KiB

<?php
# Radius User Add
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
include_once("includes/tooltips.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php"
),
));
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "add") {
?>
<p class="pageheader">Add user</p>
<form method="post" action="user-add.php">
<div>
<input type="hidden" name="frmaction" value="add2" />
</div>
<table class="entry">
<tr>
<td class="entrytitle">Username</td>
<td><input type="text" name="user_name" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" />
</td>
</tr>
</table>
</form>
<?php
# Check we have all params
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "add2") {
?>
<p class="pageheader">User Add Results</p>
<?php
# Check name
if (empty($_POST['user_name'])) {
?>
<div class="warning">Username cannot be empty</div>
<?php
}
else if (!preg_match('/^[a-z0-9]+$/i', $_POST['user_name'])) {
?>
<div class="warning">Username invalid: must be alphanumeric</div>
<?php
# Add to database
} else {
$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}users (Username) VALUES (?)");
$res = $stmt->execute(array(
$_POST['user_name'],
));
# Was it successful?
if ($res) {
?>
<div class="notice">User added</div>
<?php
} else {
?>
<div class="warning">Failed to add user</div>
<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
<?php
}
}
} else {
?>
<div class="warning">Invalid invocation</div>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User Attribute Add
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
session_start();
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
include_once("includes/tooltips.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php"
),
));
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "add") {
?>
<p class="pageheader">Add attribute</p>
<form method="post" action="user-attribute-add.php">
<div>
<input type="hidden" name="frmaction" value="add2" />
</div>
<table class="entry">
<tr>
<td class="entrytitle">Attribute Name</td>
<td><input type="text" name="attr_name" /></td>
</tr>
<tr>
<td class="entrytitle">Operator</td>
<td>
<select name="attr_operator">
<option value="=">=</option>
<option value="==">==</option>
<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="=~">=~</option>
<option value="!~">!~</option>
<option value="=*">=*</option>
<option value="!*">!*</option>
<option value="||=">||=</option>
<option value="||==">||==</option>
</select>
</td>
</tr>
<tr>
<td class="entrytitle">Value</td>
<td><input type="text" name="attr_value" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" />
</td>
</tr>
</table>
</form>
<?php
# Check we have all params
} elseif (isset($_POST['frmaction']) && $_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}user_attributes (UserID,Name,Operator,Value) VALUES (?,?,?,?)");
# Which user am I working with?
$attr_user_id = $_SESSION['attr_user_id'];
$res = $stmt->execute(array(
$attr_user_id,
$_POST['attr_name'],
$_POST['attr_operator'],
$_POST['attr_value'],
));
if ($res) {
?>
<div class="notice">Attribute added</div>
<?php
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();
# vim: ts=4
?>
<?php
# Radius User Attribute Change
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
include_once("includes/tooltips.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php",
),
));
# Display change screen
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "change") {
# Check an attribute was selected
if (isset($_POST['attr_id'])) {
# Prepare statement
$sql = "SELECT ID, Name, Operator, Value, Disabled FROM ${DB_TABLE_PREFIX}user_attributes WHERE ID = ".$db->quote($_POST['attr_id']);
$res = $db->query($sql);
$row = $res->fetchObject();
?>
<p class="pageheader">Update User</p>
<form action="user-attribute-change.php" method="post">
<div>
<input type="hidden" name="frmaction" value="change2" />
<input type="hidden" name="attr_id" value="<?php echo $_POST['attr_id']; ?>" />
</div>
<table class="entry" style="width: 75%;">
<tr>
<td></td>
<td class="entrytitle textcenter">Old Value</td>
<td class="entrytitle textcenter">New Value</td>
</tr>
<tr>
<td class="entrytitle texttop">
Name
<?php tooltip('user_attributes_name'); ?>
</td>
<td class="oldval texttop"><?php echo $row->name; ?></td>
<td><textarea name="user_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>
<select name="user_attributes_operator">
<option value="=">=</option>
<option value="==">==</option>
<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="=~">=~</option>
<option value="!~">!~</option>
<option value="=*">=*</option>
<option value="!*">!*</option>
<option value="||=">||=</option>
<option value="||==">||==</option>
</select>
</td>
</tr>
<tr>
<td class="entrytitle texttop">Value</td>
<td class="oldval texttop"><?php echo $row->value; ?></td>
<td><textarea name="user_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>
<select name="user_attributes_disabled">
<option value="">--</option>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
</table>
<p />
<div class="textcenter">
<input type="submit" />
</div>
</form>
<?php
$res->closeCursor();
} else {
?>
<div class="warning">No attribute selected</div>
<?php
}
# SQL Updates
} 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'])) {
$updates = array();
if (!empty($_POST['user_attributes_name'])) {
array_push($updates,"Name = ".$db->quote($_POST['user_attributes_name']));
}
if (isset($_POST['user_attributes_operator']) && $_POST['user_attributes_operator'] != "") {
array_push($updates,"Operator = ".$db->quote($_POST['user_attributes_operator']));
}
if (!empty($_POST['user_attributes_value'])) {
array_push($updates,"Value = ".$db->quote($_POST['user_attributes_value']));
}
if (isset($_POST['user_attributes_disabled']) && $_POST['user_attributes_disabled'] != "") {
array_push($updates ,"Disabled = ".$db->quote($_POST['user_attributes_disabled']));
}
# Check if we have updates
if (sizeof($updates) > 0) {
$updateStr = implode(', ',$updates);
$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}user_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
}
} else {
?>
<div class="warning">Invalid invocation</div>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User Attribute Delete
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php",
),
));
# Display delete confirm screen
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") {
# Check a user was selected
if (isset($_POST['attr_id'])) {
?>
<p class="pageheader">Delete Attribute</p>
<form action="attribute-delete.php" method="post">
<div>
<input type="hidden" name="frmaction" value="delete2" />
<input type="hidden" name="attr_id" value="<?php echo $_POST['attr_id']; ?>" />
</div>
<div class="textcenter">
Are you very sure? <br />
<input type="submit" name="confirm" value="yes" />
<input type="submit" name="confirm" value="no" />
</div>
</form>
<?php
} else {
?>
<div class="warning">No attribute selected</div>
<?php
}
# SQL Updates
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete2") {
?>
<p class="pageheader">Attribute Delete Results</p>
<?php
if (isset($_POST['attr_id'])) {
if (isset($_POST['confirm']) && $_POST['confirm'] == "yes") {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}user_attributes WHERE ID = ".$db->quote($_POST['attr_id']));
if ($res !== FALSE) {
?>
<div class="notice">Attribute with ID: <?php echo $_POST['attr_id']; ?> deleted</div>
<?php
} else {
?>
<div class="warning">Error deleting attribute</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
}
# Warn
} else {
?>
<div class="warning">Delete attribute aborted</div>
<?php
}
} else {
?>
<div class="warning">Invocation error, no attribute ID selected</div>
<?php
}
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User Attributes
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
session_start();
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php"
),
));
?>
<p class="pageheader">Attribute List</p>
<form id="main_form" action="user-attributes.php" method="post">
<div class="textcenter">
Action
<select id="main_form_action" name="frmaction"
onchange="
var myform = document.getElementById('main_form');
var myobj = document.getElementById('main_form_action');
if (myobj.selectedIndex == 2) {
myform.action = 'user-attribute-add.php';
} else if (myobj.selectedIndex == 5) {
myform.action = 'user-attribute-change.php';
} else if (myobj.selectedIndex == 3) {
myform.action = 'user-attribute-delete.php';
}
myform.submit();
">
<option selected="selected">select action</option>
<option disabled="disabled"> - - - - - - - - - - - </option>
<option value="add">Add Attribute</option>
<option value="delete">Delete Attribute</option>
<option disabled="disabled"> - - - - - - - - - - - </option>
<option value="change">Change Attribute</option>
</select>
</div>
<p />
<table class="results" style="width: 75%;">
<tr class="resultstitle">
<td class="textcenter">ID</td>
<td class="textcenter">Name</td>
<td class="textcenter">Operator</td>
<td class="textcenter">Value</td>
<td class="textcenter">Disabled</td>
</tr>
<?php
if (isset($_POST['user_id'])) {
# Set to session for later use
$_SESSION['attr_user_id'] = $_POST['user_id'];
# Get old attributes
$sql = "SELECT
ID, Name, Operator, Value, Disabled
FROM
${DB_TABLE_PREFIX}user_attributes
WHERE
UserID = ".$db->quote($_POST['user_id'])."
ORDER BY
ID
";
$res = $db->query($sql);
while ($row = $res->fetchObject()) {
?>
<tr class="resultsitem">
<td><input type="radio" name="attr_id" value="<?php echo $row->id; ?>"/><?php echo $row->id; ?></td>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->operator; ?></td>
<td><?php echo $row->value; ?></td>
<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no'; ?></td>
</tr>
<?php
}
if ($res->rowCount() == 0) {
?>
<p />
<tr>
<td colspan="5" class="textcenter">Attribute list is empty</td>
</tr>
<?php
}
$res->closeCursor();
} else {
?>
<tr class="resultitem">
<td colspan="5" class="textcenter">No User ID selected</td>
</tr>
<?php
}
?>
</table>
</form>
<?php
printFooter();
# vim: ts=4
?>
<?php
# Radius User Delete
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php",
),
));
# Display delete confirm screen
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") {
# Check a user was selected
if (isset($_POST['user_id'])) {
?>
<p class="pageheader">Delete User</p>
<form action="user-delete.php" method="post">
<input type="hidden" name="frmaction" value="delete2" />
<input type="hidden" name="user_id" value="<?php echo $_POST['user_id']; ?>" />
<div class="textcenter">
Are you very sure? <br />
<input type="submit" name="confirm" value="yes" />
<input type="submit" name="confirm" value="no" />
</div>
</form>
<?php
} else {
?>
<div class="warning">No user selected</div>
<?php
}
# SQL Updates
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete2") {
?>
<p class="pageheader">User Delete Results</p>
<?php
if (isset($_POST['user_id'])) {
if (isset($_POST['confirm']) && $_POST['confirm'] == "yes") {
$db->beginTransaction();
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}users_to_groups WHERE UserID = ".$db->quote($_POST['user_id']));
if ($res !== FALSE) {
?>
<div class="notice">User groups deleted</div>
<?php
} else {
?>
<div class="warning">Error deleting user</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<?php
$db->rollback();
}
if ($res !== FALSE) {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}wisp_userdata WHERE UserID = ".$db->quote($_POST['user_id']));
if ($res !== FALSE) {
?>
<div class="notice">Userdata deleted</div>
<?php
} else {
?>
<div class="warning">Error deleting user</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<?php
$db->rollback();
}
}
if ($res !== FALSE) {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}user_attributes WHERE UserID = ".$db->quote($_POST['user_id']));
if ($res !== FALSE) {
?>
<div class="notice">User attributes deleted</div>
<?php
} else {
?>
<div class="warning">Error deleting user</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<?php
$db->rollback();
}
}
if ($res !== FALSE) {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}users WHERE ID = ".$db->quote($_POST['user_id']));
if ($res !== FALSE) {
?>
<div class="notice">User deleted</div>
<?php
} else {
?>
<div class="warning">Error deleting user</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<?php
$db->rollback();
}
}
if ($res) {
?>
<div class="notice">User with ID: <?php echo $_POST['user_id']; ?> deleted</div>
<?php
$db->commit();
}
} else {
?>
<div class="warning">Delete user aborted</div>
<?php
}
} else {
?>
<div class="warning">Invocation error, no user ID selected</div>
<?php
}
} else {
?>
<div class="warning">Invocation error</div>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User Group Add
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
session_start();
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
));
if (isset($_SESSION['groups_user_id'])) {
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "add") {
?>
<p class="pageheader">Available Groups</p>
<form id="main_form" action="user-groups-add.php" method="post">
<div class="textcenter">
<input type="hidden" name="frmaction" value="add2" />
<table class="entry">
<tr>
<td class="entrytitle">Comment</td>
<td class="entrytitle">Disabled</td>
</tr>
<tr>
<td><input type="text" name="users_to_groups_comment" /></td>
<td>
<select name="users_group_disabled">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</div>
<p />
<table class="results" style="width: 75%;">
<tr class="resultstitle">
<td class="textcenter">ID</td>
<td class="textcenter">Name</td>
<td class="textcenter">Priority</td>
<td class="textcenter">Disabled</td>
<td class="textcenter">Comment</td>
</tr>
<?php
# List current available groups
$sql = "SELECT ID, Name, Priority, Disabled, Comment FROM ${DB_TABLE_PREFIX}groups ORDER BY ID";
$res = $db->query($sql);
while ($row = $res->fetchObject()) {
?>
<tr class="resultsitem">
<td><input type="radio" name="group_id" value="<?php echo $row->id; ?>" /></td>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->priority; ?></td>
<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no'; ?></td>
<td><?php echo $row->comment; ?></td>
</tr>
<?php
}
$res->closeCursor();
?>
</table>
</form>
<?php
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "add2") {
?>
<p class="pageheader">Group assignment results</p>
<?php
if (isset($_POST['group_id']) && !empty($_POST['users_to_groups_comment'])) {
$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}users_to_groups (UserID,GroupID,Comment,Disabled) VALUES (?,?,?,?)");
$res = $stmt->execute(array(
$_SESSION['groups_user_id'],
$_POST['group_id'],
$_POST['users_group_comment'],
$_POST['users_group_disabled'],
));
if ($res) {
?>
<div class="notice">Group assignment successful</div>
<?php
} else {
?>
<div class="warning">Failed to assign group to user</div>
<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
<?php
}
} else {
?>
<div class="warning">One or more values not set</div>
<?php
}
}
} else {
?>
<div class="warning">No user id received</div>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User Group Delete
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
session_start();
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php",
),
));
# Display delete confirm screen
if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") {
# Check a user was selected
if (isset($_POST['group_id'])) {
?>
<p class="pageheader">Remove Group Assignment</p>
<form action="user-groups-delete.php" method="post">
<div>
<input type="hidden" name="frmaction" value="delete2" />
<input type="hidden" name="group_id" value="<?php echo $_POST['group_id']; ?>" />
</div>
<div class="textcenter">
Are you very sure? <br />
<input type="submit" name="confirm" value="yes" />
<input type="submit" name="confirm" value="no" />
</div>
</form>
<?php
} else {
?>
<div class="warning">No group assignment selected</div>
<?php
}
# SQL Updates
} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete2") {
?>
<p class="pageheader">Group Assignment Removal Results</p>
<?php
if (isset($_POST['group_id']) && isset($_SESSION['groups_user_id'])) {
if (isset($_POST['confirm']) && $_POST['confirm'] == "yes") {
$res = $db->exec("
DELETE FROM
${DB_TABLE_PREFIX}users_to_groups
WHERE
UserID = ".$db->quote($_SESSION['groups_user_id'])."
AND
GroupID = ".$db->quote($_POST['group_id'])
);
if ($res !== FALSE) {
?>
<div class="notice">Group with ID: <?php print_r($_POST['group_id']);?> deleted from user with ID: <?php print_r($_SESSION['groups_user_id']);?></div>
<?php
session_destroy();
} else {
?>
<div class="warning">Error removing group assignment</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<?php
}
# Warn
} else {
?>
<div class="warning">Remove Group Assignment aborted</div>
<?php
}
} else {
?>
<div class="warning">Invocation error, no group ID selected</div>
<?php
}
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User Group List
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
session_start();
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php"
),
));
?>
<p class="pageheader">Groups List</p>
<form id="main_form" action="user-groups.php" method="post">
<div class="textcenter">
Action
<select id="main_form_action" name="frmaction"
onchange="
var myform = document.getElementById('main_form');
var myobj = document.getElementById('main_form_action');
if (myobj.selectedIndex == 2) {
myform.action = 'user-groups-add.php';
} else if (myobj.selectedIndex == 3) {
myform.action = 'user-groups-delete.php';
}
myform.submit();
">
<option selected="selected">select action</option>
<option disabled="disabled"> - - - - - - - - - - - </option>
<option value="add">Assign Group</option>
<option value="delete">Remove Group Assignment</option>
</select>
</div>
<p />
<table class="results" style="width: 75%;">
<tr class="resultstitle">
<td class="textcenter">ID</td>
<td class="textcenter">Name</td>
<td class="textcenter">Priority</td>
<td class="textcenter">Disabled</td>
<td class="textcenter">Comment</td>
</tr>
<?php
if (isset($_POST['user_id'])) {
# Store user_id for later use
$_SESSION['groups_user_id'] = $_POST['user_id'];
$sql = "SELECT GroupID FROM ${DB_TABLE_PREFIX}users_to_groups WHERE UserID = ".$db->quote($_POST['user_id']);
$res = $db->query($sql);
while ($row = $res->fetchObject()) {
$sql = "SELECT ID, Name, Priority, Disabled, Comment FROM ${DB_TABLE_PREFIX}groups WHERE ID = ".$db->quote($row->groupid);
$result = $db->query($sql);
while ($row = $result->fetchObject()) {
?>
<tr class="resultsitem">
<td><input type="radio" name="group_id" value="<?php echo $row->id; ?>"/></td>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->priority; ?></td>
<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no'; ?></td>
<td><?php echo $row->comment; ?></td>
</tr>
<?php
}
$result->closeCursor();
}
if ($res->rowCount() == 0) {
?>
<tr>
<td>User does not belong to any groups</td>
</tr>
<?php
}
$res->closeCursor();
} else {
?>
<tr>
<td>Invocation error, no user ID selected</td>
</tr>
<?php
}
?>
</table>
</form>
<?php
printFooter();
# vim: ts=4
?>
<?php
# Radius User Logs
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
include("includes/radiuscodes.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "user-main.php"
),
));
?>
<p class="pageheader">User Log</p>
<?php
if (isset($_POST['user_id'])) {
# Which user in the accounting table should we look for?
$stmt = $db->prepare("SELECT Username FROM ${DB_TABLE_PREFIX}users WHERE ID = ?");
$stmt->execute(array($_POST['user_id']));
$row = $stmt->fetchObject();
$stmt->closeCursor();
$getuser = $row->username;
?>
<form id="main_form" action="user-logs.php" method="post">
<!-- User input from and to dates -->
<div>
<table>
<tr>
<td>From (yyyy-mm-dd)</td>
</tr>
<tr>
<td><input type="text" name="date_from" /></td>
</tr>
<tr>
<td>To (yyyy-mm-dd)</td>
</tr>
<tr>
<td><input type="text" name="date_to" /></td>
</tr>
<tr>
<input type="hidden" name="user_id" value=<?php echo $_POST['user_id']; ?> />
<td><input type="submit" value="Get results" /></td>
</tr>
</table>
</div>
</form>
<p />
<!-- Tables headings -->
<table class="results" style="width: 75%;">
<tr class="resultstitle">
<td class="textcenter">EventTimestamp</td>
<td class="textcenter">ServiceType</td>
<td class="textcenter">FramedProtocol</td>
<td class="textcenter">NASPort</td>
<td class="textcenter">NASPortType</td>
<td class="textcenter">CallingSationID</td>
<td class="textcenter">CalledStationID</td>
<td class="textcenter">NASPortID</td>
<td class="textcenter">AcctSessionID</td>
<td class="textcenter">FramedIPAddress</td>
<td class="textcenter">AcctAuthentic</td>
<td class="textcenter">NASIdentifier</td>
<td class="textcenter">NASIPAddress</td>
<td class="textcenter">AcctDelayTime</td>
<td class="textcenter">AcctSessionTime</td>
<td class="textcenter">Data-Input</td>
<td class="textcenter">Data-Output</td>
<td class="textcenter">AcctStatusType</td>
<td class="textcenter">AcctTerminateCause</td>
</tr>
<?php
# Extra SQL
$extraSQL = "";
$extraSQLVals = array();
$limitSQL = "";
# Do we have a from date?, if so add it to our query
if (isset($_POST['date_from'])) {
$extraSQL .= " AND EventTimestamp >= ?";
array_push($extraSQLVals,$_POST['date_from']);
}
# Do we have a from date?, if so add it to our query
if (isset($_POST['date_to'])) {
$extraSQL .= " AND EventTimestamp <= ?";
array_push($extraSQLVals,$_POST['date_to']);
}
# Modify if we had a partial search or no search
if (count($extraSQLVals) < 2) {
$limitSQL = "LIMIT 50";
}
# Query to get all default data
$sql = "
SELECT
EventTimestamp,
ServiceType,
FramedProtocol,
NASPort,
NASPortType,
CallingStationID,
CalledStationID,
NASPortID,
AcctSessionID,
FramedIPAddress,
AcctAuthentic,
NASIdentifier,
NASIPAddress,
AcctDelayTime,
AcctSessionTime,
AcctInputOctets,
AcctInputGigawords,
AcctOutputOctets,
AcctOutputGigawords,
AcctStatusType,
AcctTerminateCause
FROM
${DB_TABLE_PREFIX}accounting
WHERE
Username = ".$db->quote($getuser)."
$extraSQL
ORDER BY
EventTimestamp
DESC
$limitSQL
";
$res = $db->prepare($sql);
$res->execute($extraSQLVals);
$totalInputData = 0;
$totalOutputData = 0;
$totalSessionTime = 0;
while ($row = $res->fetchObject()) {
# Input
$inputDataItem = 0;
if (!empty($row->acctinputoctets) && $row->acctinputoctets > 0) {
$inputDataItem += ($row->acctinputoctets / 1024) / 1024;
}
if (!empty($row->acctinputgigawords) && $row->inputgigawords > 0) {
$inputDataItem += ($row->acctinputgigawords * 4096);
}
$totalInputData += $inputDataItem;
# Output
$outputDataItem = 0;
if (!empty($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
$outputDataItem += ($row->acctoutputoctets / 1024) / 1024;
}
if (!empty($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
$outputDataItem += ($row->acctoutputgigawords * 4096);
}
$totalOutputData = $totalOutputData + $outputDataItem;
# Add up time
$sessionTimeItem = 0;
if (!empty($row->acctsessiontime) && $row->acctsessiontime > 0) {
$sessionTimeItem += ($row->acctsessiontime - ($row->acctsessiontime % 60)) / 60;
}
$totalSessionTime += $sessionTimeItem;
?>
<tr class="resultsitem">
<td class="textcenter"><?php echo $row->eventtimestamp; ?></td>
<td class="textcenter"><?php echo $row->servicetype; ?></td>
<td class="textcenter"><?php echo $row->framedprotocol; ?></td>
<td class="textcenter"><?php echo $row->nasport; ?></td>
<td class="textcenter"><?php echo $row->nasporttype; ?></td>
<td class="textcenter"><?php echo $row->callingstationid; ?></td>
<td class="textcenter"><?php echo $row->calledstationid; ?></td>
<td class="textcenter"><?php echo $row->nasportid; ?></td>
<td class="textcenter"><?php echo $row->acctsessionid; ?></td>
<td class="textcenter"><?php echo $row->framedipaddress; ?></td>
<td class="textcenter"><?php echo $row->acctauthentic; ?></td>
<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 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>
<?php
}
if ($res->rowCount() == 0) {
?>
<tr>
<td colspan="23" class="textcenter">No logs found for user: <?php echo $getuser ?></td>
</tr>
<?php
} else {
?>
<tr class="resultsitem">
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<td class="textcenter"></td>
<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;"><? 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>
<?php
}
$res->closeCursor();
?>
</table>
<?php
} else {
?>
<div class="warning">No user selected</div>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User List
# Copyright (C) 2007-2009, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
));
# If we have no action, display list
if (!isset($_POST['frmaction']))
{
?>
<p class="pageheader">User List</p>
<form id="main_form" action="user-main.php" method="post">
<div class="textcenter">
Action
<select id="main_form_action" name="frmaction"
onchange="
var myform = document.getElementById('main_form');
var myobj = document.getElementById('main_form_action');
if (myobj.selectedIndex == 2) {
myform.action = 'user-add.php';
} else if (myobj.selectedIndex == 3) {
myform.action = 'user-delete.php';
} else if (myobj.selectedIndex == 5) {
myform.action = 'user-attributes.php';
} else if (myobj.selectedIndex == 6) {
myform.action = 'user-groups.php';
} else if (myobj.selectedIndex == 7) {
myform.action = 'user-logs.php';
}
myform.submit();
">
<option selected="selected">select action</option>
<option disabled="disabled"> - - - - - - - - - - - </option>
<option value="add">Add User</option>
<option value="delete">Delete User</option>
<option disabled="disabled"> - - - - - - - - - - - </option>
<option value="useratts">Attributes</option>
<option value="usergroups">Groups</option>
<option value="defaultlist">LogS</option>
</select>
</div>
<p />
<table class="results" style="width: 75%;">
<tr class="resultstitle">
<td class="textcenter">ID</td>
<td class="textcenter">Username</td>
<td class="textcenter">Disabled</td>
</tr>
<?php
$sql = "SELECT ID, Username, Disabled FROM ${DB_TABLE_PREFIX}users ORDER BY ID ASC";
$res = $db->query($sql);
# List users
while ($row = $res->fetchObject()) {
?>
<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>
</tr>
<?php
}
if ($res->rowCount() == 0) {
?>
<p />
<tr>
<td colspan="3" class="textcenter">User list is empty</td>
</tr>
<?php
}
$res->closeCursor();
?>
</table>
</form>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Authentication class
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
<?php
# User Control Panel UI Config
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
<?php
# Database Interface
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
<?php
# Footer of page
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -18,7 +18,7 @@
?>
<div class="copyright">SMRadius - Copyright &copy; 2007-2009, <a href="http://www.allworldit.com" ?>AllWorldIT</a></div>
<div class="copyright">SMRadius - Copyright &copy; 2007-2011, <a href="http://www.allworldit.com" ?>AllWorldIT</a></div>
<br />
</body>
......
<?php
# Top part of radius control panel
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
<?php
# Misc functions we can use
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
<?php
# Web User UI PRE
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
<?php
# Radius term code mappings
# Copyright (C) 2007-2009, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -23,38 +23,54 @@
function strRadiusTermCode($errCode) {
if (is_numeric($errCode)) {
# Terminate codes RFC 2866
switch ($errCode) {
case 0:
return "Still logged in";
case 45: # Unknown
case 46: # Unknown
case 63: # Unknown
case 1:
return "User request";
return "User Request";
case 2:
case 816: # TCP connection reset? unknown
return "Carrier loss";
return "Lost Carrier";
case 3:
return "Lost Service";
case 4:
return "Idle Timeout";
case 5:
return "Session timeout";
case 6: # Admin reset
case 10: # NAS request
case 11: # NAS reboot
case 831: # NAS request? unknown
case 841: # NAS request? unknown
return "Router reset/reboot";
case 8: # Port error
return "Port error";
case 180: # Unknown
return "Local hangup";
case 827: # Unknown
return "Service unavailable";
return "Session Timeout";
case 6:
return "Admin Reset";
case 7:
return "Admin Reboot";
case 8:
return "Port Error";
case 9:
return "NAS Error";
case 10:
return "NAS Request";
case 11:
return "NAS Reboot";
case 12:
return "Port Unneeded";
case 13:
return "Port Preempted";
case 14:
return "Port Suspended";
case 15:
return "Service Unavailable";
case 16:
return "Callback";
case 17:
return "User Error";
case 18:
return "Host Request";
default:
return "Unkown";
}
} else {
return "Unknown";
switch ($errCode) {
case NULL:
return "Still logged in";
default:
return "Unkown";
}
}
}
......