diff --git a/webui/wisp-locations-add.php b/webui/wisp-locations-add.php new file mode 100644 index 0000000000000000000000000000000000000000..e52d48cd1dee07d2311afac3622d84196354283f --- /dev/null +++ b/webui/wisp-locations-add.php @@ -0,0 +1,112 @@ +<?php +# Radius Location 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"); + +$db = connect_db(); + +printHeader(array( + "Tabs" => array( + "Back to locations list" => "wisp-locations-manage.php" + ), +)); + +if (isset($_POST['frmaction']) && $_POST['frmaction'] == "add") { + +?> + + <p class="pageheader">Add location</p> + <form method="post" action="wisp-locations-add.php"> + <div> + <input type="hidden" name="frmaction" value="add2" /> + </div> + <table class="entry"> + <tr> + <td class="entrytitle">Location</td> + <td><input type="text" name="location" /></td> + </tr> + <tr> + <td class="textcenter" 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">Location Add Results</p> + +<?php + + # Check name + if (empty($_POST['location'])) { + +?> + + <div class="warning">Location cannot be empty</div> + +<?php + + # Add to database + } else { + $stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}wisp_locations (Location) VALUES (?)"); + $res = $stmt->execute(array( + $_POST['location'], + )); + # Was it successful? + if ($res) { + +?> + + <div class="notice">Location added</div> + +<?php + + } else { + +?> + + <div class="warning">Failed to add location</div> + <div class="warning"><?php print_r($stmt->errorInfo()) ?></div> + +<?php + + } + } +} else { + +?> + + <div class="warning">Invalid invocation</div> + +<?php + +} + +printFooter(); + +# vim: ts=4 +?> diff --git a/webui/wisp-locations-delete.php b/webui/wisp-locations-delete.php new file mode 100644 index 0000000000000000000000000000000000000000..581bbfac2133bc1948ed84b1113a9ddece74f7e7 --- /dev/null +++ b/webui/wisp-locations-delete.php @@ -0,0 +1,138 @@ +<?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 location list" => "wisp-locations-manage.php", + ), +)); + + + +# Display delete confirm screen +if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") { + # Check a user was selected + if (isset($_POST['location_id'])) { + +?> + + <p class="pageheader">Delete Location</p> + + <form action="wisp-locations-delete.php" method="post"> + <input type="hidden" name="frmaction" value="delete2" /> + <input type="hidden" name="location_id" value="<?php echo $_POST['location_id']; ?>" /> + <div class="textcenter"> + Are you very sure you wish to remove this location and unlink all users linked to it? <br /> + <input type="submit" name="confirm" value="yes" /> + <input type="submit" name="confirm" value="no" /> + </div> + </form> + +<?php + + } else { + +?> + + <div class="warning">No location selected</div> + +<?php + + } +# SQL Updates +} elseif (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete2") { + +?> + + <p class="pageheader">Location Delete Results</p> + +<?php + + if (isset($_POST['location_id'])) { + if (isset($_POST['confirm']) && $_POST['confirm'] == "yes") { + $db->beginTransaction(); + + $res = $db->exec("UPDATE ${DB_TABLE_PREFIX}wisp_userdata SET LocationID = NULL WHERE LocationID = ".$db->quote($_POST['location_id'])); + if ($res !== FALSE) { +?> + <div class="notice">Location members unlinked</div> +<?php + } else { +?> + <div class="warning">Error unlinking members from location</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_locations WHERE ID = ".$db->quote($_POST['location_id'])); + if ($res !== FALSE) { +?> + <div class="notice">Location deleted</div> +<?php + } else { +?> + <div class="warning">Error deleting location</div> + <div class="warning"><?php print_r($db->errorInfo()); ?></div> +<?php + $db->rollback(); + } + } + if ($res) { +?> + <div class="notice">Location with ID: <?php echo $_POST['location_id']; ?> deleted</div> +<?php + $db->commit(); + } + } else { +?> + <div class="warning">Delete location aborted</div> +<?php + } + } else { +?> + + <div class="warning">Invocation error, no location ID selected</div> + +<?php + + } +} else { +?> + <div class="warning">Invocation error</div> +<?php +} +printFooter(); + + +# vim: ts=4 +?> + diff --git a/webui/wisp-locations-manage.php b/webui/wisp-locations-manage.php new file mode 100644 index 0000000000000000000000000000000000000000..7d035614067daf6ef91e9486bb3d40bfa1bc8b60 --- /dev/null +++ b/webui/wisp-locations-manage.php @@ -0,0 +1,103 @@ +<?php +# Radius Location 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">Location List</p> + + <form id="main_form" action="wisp-locations-manage.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 = 'wisp-locations-add.php'; + } else if (myobj.selectedIndex == 3) { + myform.action = 'wisp-locations-delete.php'; + } else if (myobj.selectedIndex == 5) { + myform.action = 'wisp-locations-members.php'; + } + + myform.submit(); + "> + <option selected="selected">select action</option> + <option disabled="disabled"> - - - - - - - - - - - </option> + <option value="add">Add Location</option> + <option value="delete">Delete Location</option> + <option disabled="disabled"> - - - - - - - - - - - </option> + <option value="useratts">List Location Members</option> + </select> + </div> + + <p /> + + <table class="results" style="width: 75%;"> + <tr class="resultstitle"> + <td class="textcenter">ID</td> + <td class="textcenter">Location</td> + </tr> + +<?php + + $sql = "SELECT Name FROM ${DB_TABLE_PREFIX}wisp_locations ORDER BY Name ASC"; + $res = $db->query($sql); + + # List users + while ($row = $res->fetchObject()) { + +?> + + <tr class="resultsitem"> + <td><input type="radio" name="location_id" value="<?php echo $row->id; ?>"/></td> + <td><?php echo $row->name; ?></td> + </tr> +<?php + } + if ($res->rowCount() == 0) { +?> + <p /> + <tr> + <td colspan="3" class="textcenter">Location list is empty</td> + </tr> +<?php + } + $res->closeCursor(); +?> + </table> + </form> +<?php +} +printFooter(); + +# vim: ts=4 +?> diff --git a/webui/wisp-locations-members.php b/webui/wisp-locations-members.php new file mode 100644 index 0000000000000000000000000000000000000000..f4c607673f6c8d3fb9837d8f25b45255ac946c1a --- /dev/null +++ b/webui/wisp-locations-members.php @@ -0,0 +1 @@ +Im broken at the moment, please try later