diff --git a/webui/agent-control-panel/include/.htaccess b/webui/agent-control-panel/include/.htaccess
new file mode 100644
index 0000000000000000000000000000000000000000..d2ca18f15fec0d7c62a85c1c592587442c279e7f
--- /dev/null
+++ b/webui/agent-control-panel/include/.htaccess
@@ -0,0 +1,4 @@
+<Files *>
+	Order Deny,Allow
+	Deny from all
+</Files>
diff --git a/webui/agent-control-panel/include/config.php b/webui/agent-control-panel/include/config.php
new file mode 100644
index 0000000000000000000000000000000000000000..77202c48ea46bab4721d082261c16120aaef1d29
--- /dev/null
+++ b/webui/agent-control-panel/include/config.php
@@ -0,0 +1,17 @@
+<?php
+
+# mysql:host=xx;dbname=yyy
+#
+# pgsql:host=xx;dbname=yyy
+#
+# sqlite:////full/unix/path/to/file.db?mode=0666
+#
+#$DB_DSN="sqlite:////tmp/cluebringer.sqlite";
+$DB_DSN="mysql:host=localhost;dbname=smradius";
+$DB_USER="root";
+$DB_PASS="root";
+$DB_TABLE_PREFIX="";
+
+
+
+?>
diff --git a/webui/agent-control-panel/include/db.php b/webui/agent-control-panel/include/db.php
new file mode 100644
index 0000000000000000000000000000000000000000..8f6abf9d51c3cfab03cdc6ba8b5d37a7a66ec16b
--- /dev/null
+++ b/webui/agent-control-panel/include/db.php
@@ -0,0 +1,51 @@
+<?php
+
+require_once('include/config.php');
+
+
+# Connect to DB
+function connect_db()
+{
+	global $DB_DSN;
+	global $DB_USER;
+	global $DB_PASS;
+
+	try {
+		$dbh = new PDO($DB_DSN, $DB_USER, $DB_PASS, array(
+			PDO::ATTR_PERSISTENT => false
+		));
+
+		$dbh->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
+
+	} catch (PDOException $e) {
+		die("Error connecting to Policyd v2 DB: " . $e->getMessage());
+	}
+
+	return $dbh;
+}
+
+
+# Connect to postfix DB
+function connect_postfix_db()
+{
+	global $DB_POSTFIX_DSN;
+	global $DB_POSTFIX_USER;
+	global $DB_POSTFIX_PASS;
+
+	try {
+		$dbh = new PDO($DB_POSTFIX_DSN, $DB_POSTFIX_USER, $DB_POSTFIX_PASS, array(
+			PDO::ATTR_PERSISTENT => false
+		));
+
+		$dbh->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
+
+	} catch (PDOException $e) {
+		die("Error connecting to Postfix DB: " . $e->getMessage());
+	}
+
+	return $dbh;
+}
+
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/include/footer.php b/webui/agent-control-panel/include/footer.php
new file mode 100644
index 0000000000000000000000000000000000000000..158156d2183252aa431af2f41f4270e25f309db3
--- /dev/null
+++ b/webui/agent-control-panel/include/footer.php
@@ -0,0 +1,32 @@
+<?php
+# Footer of page
+#
+# Copyright (c) 2005-2008, 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.
+
+
+?>
+		<div class="copyright">Copyright (c) 2005-2008, <a href="http://www.allworldit.com">AllWorldIT</a></div>
+		<p />
+		<div class="text-center">
+			<img src="../static/valid-xhtml10.png" alt="Valid XHTML 1.0 Logo" />
+			<img src="../static/valid-css2.png" alt="Valid CSS 2 Logo" />
+		</div>
+	</body>
+</html>
+<?php
+	ob_flush();
+?>
diff --git a/webui/agent-control-panel/include/header.php b/webui/agent-control-panel/include/header.php
new file mode 100644
index 0000000000000000000000000000000000000000..997440217daa520f5fcb69cea5a4c7c4374dabff
--- /dev/null
+++ b/webui/agent-control-panel/include/header.php
@@ -0,0 +1,46 @@
+<?php
+# Header of page
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+# Grab version
+require_once("include/version.php");
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+	<head>
+		<title>SOAP Backend Interface</title> 
+		<link rel="stylesheet" href="../static/styles.css" type="text/css" />
+		<link rel="stylesheet" href="../static/menu.css" type="text/css" />
+	</head>
+
+	<body>
+		<div class="pagetitle">Agent Control Panel</div>	
+<?php
+	if ($auth->loggedIn) {
+?>
+		<div class="smallinfo">Logged in as <?php echo $auth->username ?> (<a href="./?logout=1">Logout</a>).</div>
+<?php
+	} else {
+?>
+		<div class="smallinfo">v<?php echo $VERSION ?></div>
+<?php
+	}
+?>
diff --git a/webui/agent-control-panel/include/pre.php b/webui/agent-control-panel/include/pre.php
new file mode 100644
index 0000000000000000000000000000000000000000..7635329698abcf62b097f96366381088fd2610e5
--- /dev/null
+++ b/webui/agent-control-panel/include/pre.php
@@ -0,0 +1,70 @@
+<?php
+# This file takes care of authentication for us and gets the soap object
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+ob_start();
+
+require_once("../shared-php/auth.php");
+
+require_once("../shared-php/miscfuncs.php");
+
+
+
+
+# Main authentication object
+$auth = new Auth('Agent');
+
+# Check if we logged in and set SOAP object
+$soap = NULL;
+
+
+
+# First of all check if we in maintenance mode
+if (file_exists("../maintmode")) {
+	include("header.php");
+	displayError("System unavailable due to maintenance, sorry for the inconvenience. Please try again in 5 minutes");
+	include("footer.php");
+	exit;
+}
+
+# Check if we logged in
+if (!$auth->loggedIn) {
+	$username = isset($_POST['username']) ? $_POST['username'] : NULL;
+	$password = isset($_POST['password']) ? $_POST['password'] : NULL;
+
+	# If not, check credentials
+	if ($auth->checkLogin($username,$password) != 0) {
+		include("header.php");
+		$auth->displayLogin();
+		include("footer.php");
+		exit;
+	}
+} else {
+	# Log client out
+	if (!empty($_REQUEST['logout']) && $_REQUEST['logout'] != "") {
+		$auth->logout("You have been logged out.");
+		require_once('HTTP.php');
+		HTTP::Redirect('.');
+		exit;
+	}
+}
+
+?>
diff --git a/webui/agent-control-panel/include/version.php b/webui/agent-control-panel/include/version.php
new file mode 100644
index 0000000000000000000000000000000000000000..c15bb63a5599ec19e4a5cf1a850f7df033ce02b5
--- /dev/null
+++ b/webui/agent-control-panel/include/version.php
@@ -0,0 +1,25 @@
+<?php
+# Versioning for this interface
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+$VERSION = "0.4.0b2";
+
+?>
diff --git a/webui/agent-control-panel/index.php b/webui/agent-control-panel/index.php
new file mode 100644
index 0000000000000000000000000000000000000000..7be6a09b9324f5ddc97e537483511ff68b3b082d
--- /dev/null
+++ b/webui/agent-control-panel/index.php
@@ -0,0 +1,41 @@
+<?php
+# Index of agent control panel section
+#
+# Copyright (c) 2005-2008, 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.
+
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+
+
+include("../shared-php/menu-header.php");
+
+
+$agentDetails = $soap->getAgentDetails();
+printf("Agent: %s<br>\n",$agentDetails->Name);
+
+?>
+
+
+<?php
+include("../shared-php/menu-footer.php");
+
+# Footer
+include("include/footer.php");
+?>
diff --git a/webui/agent-control-panel/mailTransports.php b/webui/agent-control-panel/mailTransports.php
new file mode 100644
index 0000000000000000000000000000000000000000..358495c6a07055812e9acb5138060c5099a70e1f
--- /dev/null
+++ b/webui/agent-control-panel/mailTransports.php
@@ -0,0 +1,336 @@
+<?php
+# Mail transport stuff
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+
+# Soap functions
+require_once("php/soapfuncs.php");
+
+
+?>
+<a href=".">Home</a><br><br>
+<?php
+
+
+# Actual form action to update mailbox
+function actionUpdate() {
+	global $soap;
+	global $transportID;
+
+
+	# Create update hash
+	$update = NULL;
+
+	if ($_POST["policyID"] != "nochange") {
+		$update["PolicyID"] = $_POST["policyID"];
+	}		
+
+	if ($_POST["agentDisabled"] != "") {
+		$update["AgentDisabled"] = $_POST["agentDisabled"];
+	}		
+
+	if ($_POST["agentRef"] != "") {
+		$update["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	# If there are still updates to be done, do them
+	if ($update != NULL) {
+		$update["ID"] = $transportID;
+		
+		$res = $soap->updateMailTransport($update);
+		if ($res == 0) {
+			echo "Updated transport<br>\n";
+		} else {
+			echo "Error updating transport($res): ".strSoapError($res);
+		}
+	# Or report no updates to be made
+	} else {
+		echo "No updates to be made!\n";
+	}
+}
+
+
+
+
+# Display edit screen
+function screenEdit() {
+	global $soap;
+	global $transportID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+		
+	$mailPolicies = $soap->getMailPolicies();
+	if (!is_array($mailPolicies)) {
+		echo "getMailPolicies: ".strSoapError($mailPolicies);
+		return;
+	}
+
+?>
+	<form action="mailTransports.php?transportID=<?php echo $transportID; ?>" method="POST">
+	<table border="1">
+		<tr>
+			<td colspan="3" align="center">
+				Transport: <?php printf("%s => %s",$transportInfo->DomainName,
+						$transportInfo->Transport."/".$transportInfo->Detail); ?>
+			</td>
+		</tr>
+		<tr>
+			<td>Attribute</td>
+			<td>Value</td>
+			<td>New Value</td>
+		</tr>
+<?php
+
+		$policyName = "";
+		foreach ($mailPolicies as $policy) {
+			if ($transportInfo->PolicyID == $policy->ID) {
+				$policyName = $policy->PolicyName;
+			}
+		}
+?>
+		<tr>
+			<td>Policy</td>
+			<td><?php echo $policyName ? $policyName : "default"; ?></td>
+			<td>
+				<select name="policyID">
+					<option value="nochange"></option>
+					<option value="">Default</option>
+<?php
+					foreach ($mailPolicies as $policy) {
+						printf("<option value=\"%s\">%s</option>",$policy->ID,$policy->PolicyName);
+					}
+?>
+				</select>
+			</td>
+		</tr>
+
+		<tr>
+			<td>AgentRef</td>
+			<td><?php echo $transportInfo->AgentRef; ?></td>
+			<td><input type="text" name="agentRef"></td>
+		</tr>
+
+		<tr>
+			<td>Disabled</td>
+			<td><?php echo $transportInfo->AgentDisabled ? "yes" : "no"; ?></td>
+			<td>
+				<select name="agentDisabled">
+					<option value="0" <?php if (!$transportInfo->AgentDisabled) { echo "selected"; } ?>>no</option>
+					<option value="1" <?php if ($transportInfo->AgentDisabled) { echo "selected"; } ?>>yes</option>
+				</select>
+			</td>
+			<td></td>
+		</tr>
+	</table>
+
+	<input type="hidden" name="action" value="update">
+	<input type="submit" value="Update">
+	</form>		
+<?php
+}
+
+
+
+
+# List mailboxes
+function transportList($searchOptions) {
+	global $soap;
+
+
+	$mailTransports = $soap->getMailTransports($searchOptions);
+	if (is_array($mailTransports)) {
+?>
+		<a href="mailTransports.php">Back to mail transport search</a><br><br>
+
+		<table class="mtlisttable">
+			<tr class="mtlisttabletitle">
+				<td colspan="6">Search Results for Mail Transports</td>
+			</tr>
+			<tr class="mtlisttablehead">
+				<td rowspan="2">Domain</td>
+				<td rowspan="2">Transport</td>
+				<td rowspan="2">AgentRef</td>
+				<td colspan="2">Disabled</td>
+			</tr>
+			<tr class="mtlisttablehead">
+				<td>Agent</td>
+				<td>Delivery</td>
+			</tr>
+<?php
+			$i = 0;
+			foreach ($mailTransports as $transport) {
+				# Check if number is odd or even
+				if ($i % 2 == 0) {
+					$j = "1";
+				} else {
+					$j = "2";
+				}
+
+?>
+				<tr class="mtlisttabledata<?php echo $j ?>">
+					<td><?php 
+						echo "<a href=\"mailTransports.php?transportID=".$transport->ID."&screen=edit\"?>";
+						echo $transport->DomainName; 
+						echo "</a>";
+					?></td>
+					<td><?php echo $transport->Transport . "/" . $transport->Detail; ?></td>
+					<td><?php echo $transport->AgentRef; ?></td>
+					<td><?php echo $transport->AgentDisabled ? "yes" : "no"; ?></td>
+					<td><?php echo $transport->DisableDelivery ? "yes" : "no"; ?></td>
+					<td>
+<?php
+						if ($transport->Transport == "virtual") {
+?>
+							<a href="mailboxes.php?transportID=<?php echo $transport->ID ?>">Mailboxes</a> | 
+							<a href="mailboxAliases.php?transportID=<?php echo $transport->ID ?>">Aliases</a>
+<?php
+						}
+?>
+					</td>
+				</tr>
+<?php
+				$i++;
+			}
+?>
+		</table>
+		<br>
+		<a href="mailTransports.php">Back to mail transport search</a><br><br>
+<?php
+	} else {
+		echo "getMailTransports: ".strSoapError($mailTransports);
+	}
+}
+
+
+
+
+# Function to display search box
+function searchBox() {
+?>
+	<form action="mailTransports.php" method="GET">
+	<input type="hidden" name="search" value="1">
+	<table class="mtsearchtable">
+		<tr class="mtsearchtabletitle">
+			<td colspan="3">Search Mail Transports</td>
+		</tr>
+		<tr>
+			<td colspan="2" class="mtsearchtableblank"></td>
+			<td>Order by</td>
+		</tr>
+		<tr>
+			<td class="mtsearchtablehead">Domain Name</td>
+			<td class="mtsearchtabledata">
+				<input type="text" name="searchDomainName" value="<?php
+						echo $_SESSION['transport_searchDomainName'] 
+				?>">
+			</td>
+			<td class="mtsearchtableorder">
+				<input type="radio" name="searchOrderBy" value="DomainName" <?php
+					if ($_SESSION['transport_searchOrderBy'] == "" 
+							|| $_SESSION['transport_searchOrderBy'] == "DomainName") {
+						echo "checked";
+					}
+				?>>
+			</td>
+		</tr>
+		<tr>
+			<td class="mtsearchtablehead">Agent Ref</td>
+			<td class="mtsearchtabledata">
+				<input type="text" name="searchAgentRef" value="<?php
+						 echo $_SESSION['transport_searchAgentRef']
+				?>">
+			</td>
+			<td class="mtsearchtableorder">
+				<input type="radio" name="searchOrderBy" value="AgentRef" <?php
+					if ($_SESSION['transport_searchOrderBy'] == "AgentRef") {
+						echo "checked";
+					}
+				?>>
+			</td>
+		</tr>
+		<tr class="mtsearchtablesubmit">
+			<td colspan="3"><input type="submit"></td>
+		</tr>
+	</table>
+	</form>
+
+Note On Searching:
+<li>Wildcards can be specified with *'s. For example: *.com  
+<li>Blank search criteria matches everything
+<?php
+}
+
+# Check if we have a transport
+if ($_REQUEST['transportID'] > 0) {
+	$transportID = $_REQUEST['transportID'];
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+
+
+	echo("<a href=\"mailTransports.php?search=1\">Back to mail transports</a><br><br>");
+
+	# Check if we have a special action to perform
+	if ($_POST["action"] == "update") {
+		actionUpdate();
+	# Edit screen
+	} elseif ($_REQUEST["screen"] == "edit")  {
+		screenEdit();
+	}
+
+# We came from our search box
+} elseif ($_REQUEST['search'] == 1) {
+	# Process search options
+	if (isset($_REQUEST['searchDomainName'])) {
+		$_SESSION['transport_searchDomainName'] = $_REQUEST['searchDomainName'];
+	}
+	if (isset($_REQUEST['searchAgentRef'])) {
+		$_SESSION['transport_searchAgentRef'] = $_REQUEST['searchAgentRef'];
+	}
+	if (isset($_REQUEST['searchOrderBy'])) {
+		$_SESSION['transport_searchOrderBy'] = $_REQUEST['searchOrderBy'];
+	}
+
+	# Setup search
+	$searchOptions->searchDomainName = $_SESSION['transport_searchDomainName'];
+	$searchOptions->searchAgentRef = $_SESSION['transport_searchAgentRef'];
+	$searchOptions->searchOrderBy = $_SESSION['transport_searchOrderBy'];
+
+
+
+	transportList($searchOptions);
+
+# Anything else
+} else {
+	searchBox();
+}
+
+
+# Footer
+include("include/footer.php");
+?>
diff --git a/webui/agent-control-panel/mailboxAliases.php b/webui/agent-control-panel/mailboxAliases.php
new file mode 100644
index 0000000000000000000000000000000000000000..dc0eeed91025cd805b87716b379fd1c522f210d6
--- /dev/null
+++ b/webui/agent-control-panel/mailboxAliases.php
@@ -0,0 +1,495 @@
+<?php
+# Mailbox stuff
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+
+# Soap functions
+require_once("php/soapfuncs.php");
+
+?>
+<a href=".">Home</a><br><br>
+<a href="mailTransports.php">Back to mail transport search</a><br><br>
+<a href="mailTransports.php?search=1">Back to mail transports</a><br><br>
+<?php
+
+
+# Actual form action to add mailbox
+function actionAdd() {
+	global $soap;	
+	global $transportID;
+
+	
+	$mailboxAliasInfo = NULL;
+
+	$mailboxAliasInfo["Address"] = $_POST["address"];
+
+	if ($_POST["goto"] != "") {
+		$mailboxAliasInfo["Goto"] = $_POST["goto"];
+	} else {
+		echo "Forward to must be specified!<br>";
+		return;
+	}
+
+	# Check optional data
+	if ($_POST["agentDisabled"] != "") {
+		$mailboxAliasInfo["AgentDisabled"] = $_POST["agentDisabled"];
+	}		
+
+	if ($_POST["agentRef"] != "") {
+		$mailboxAliasInfo["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	# Create mailbox and check for error
+	$res = $soap->createMailboxAlias($transportID,$mailboxAliasInfo);
+	if ($res > 0) {
+		echo "Added mailbox alias\n";
+	} else {
+		echo "Error creating mailbox alias: ".strSoapError($res);
+	}
+
+}
+
+
+
+# Actual form action to update mailbox
+function actionUpdate() {
+	global $soap;
+	global $mailboxAliasID;
+
+
+	# Create update hash
+	$update = NULL;
+
+	if ($_POST["goto"] != "") {
+		$update["Goto"] = $_POST["goto"];
+	}		
+
+	if ($_POST["agentDisabled"] != "") {
+		$update["AgentDisabled"] = $_POST["agentDisabled"];
+	}		
+
+	if ($_POST["agentRef"] != "") {
+		$update["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	# If there are still updates to be done, do them
+	if ($update != NULL) {
+		$update["ID"] = $mailboxAliasID;
+		
+		$res = $soap->updateMailboxAlias($update);
+		if ($res == 0) {
+			echo "Updated mailbox alias\n";
+		} else {
+			echo "Error updating mailbox alias: ".strSoapError($res);
+		}
+	# Or report no updates to be made
+	} else {
+		echo "No updates to be made!\n";
+	}
+}
+
+
+
+# Actual form action to remove a mailbox
+function actionRemove() {
+	global $soap;
+	global $mailboxAliasID;
+
+
+	$res = $soap->removeMailboxAlias($mailboxAliasID);
+	if ($res == 0) {
+		echo "Removed mailbox alias\n";
+	} else {
+		echo "Error removing mailbox alias: ".strSoapError($res);
+	}
+
+}
+
+
+# Display edit screen
+function screenEdit() {
+	global $soap;
+	global $transportID;
+	global $mailboxAliasID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+		
+	$aliasInfo = $soap->getMailboxAliasInfo($mailboxAliasID);
+	if (!is_object($aliasInfo)) {
+		echo "getMailboxAliasInfo: ".strSoapError($aliasInfo);
+		return;
+	}
+
+?>
+	<form action="mailboxAliases.php?transportID=<?php echo $transportID; ?>&mailboxAliasID=<?php echo $mailboxAliasID; ?>" method="POST">
+	<table border="1">
+		<tr>
+			<td colspan="3" align="center">
+				Alias: <?php printf("%s@%s",$aliasInfo->Address,$transportInfo->DomainName); ?>
+			</td>
+		</tr>
+		<tr>
+			<td>Attribute</td>
+			<td>Value</td>
+			<td>New Value</td>
+		</tr>
+		<tr>
+			<td>Foward to</td>
+			<td><?php echo $aliasInfo->Goto; ?></td>
+			<td><input type="text" name="goto"></td>
+		</tr>
+
+		<tr>
+			<td>AgentRef</td>
+			<td><?php echo $aliasInfo->AgentRef; ?></td>
+			<td><input type="text" name="agentRef"></td>
+		</tr>
+		<tr>
+			<td>Disabled</td>
+			<td><?php echo $aliasInfo->AgentDisabled ? "yes" : "no"; ?></td>
+			<td>
+				<select name="agentDisabled">
+					<option value="0" <?php if (!$aliasInfo->AgentDisabled) { echo "selected"; } ?>>no</option>
+					<option value="1" <?php if ($aliasInfo->AgentDisabled) { echo "selected"; } ?>>yes</option>
+				</select>
+			</td>
+		</tr>
+	</table>
+
+	<input type="hidden" name="action" value="update">
+	<input type="submit" value="Update">
+</form>		
+<?php
+}
+
+
+
+# Remove screen
+function screenRemove() {
+	global $soap;
+	global $transportID;
+	global $mailboxAliasID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+		
+	$mailboxAliasInfo = $soap->getMailboxAliasInfo($mailboxAliasID);
+	if (!is_object($mailboxAliasInfo)) {
+		echo "getMailboxAliasInfo: ".strSoapError($mailboxAliasInfo);
+		return;
+	}
+?>
+	<form action="mailboxAliases.php?transportID=<?php echo $transportID ?>&mailboxAliasID=<?php echo $mailboxAliasID ?>" method="POST">
+	<input type="hidden" name="action" value="remove">
+	Are you very sure you wish to remove alias <?php printf("%s@%s",$mailboxAliasInfo->Address,$transportInfo->DomainName) ?>?<br>
+	<input type="submit" value="Yes">
+	<br>	
+<?php
+}
+
+
+# Add screen
+function screenAdd() {
+	global $soap;
+	global $transportID;
+	global $mailboxAliasesID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+		
+?>
+	<form action="mailboxAliases.php?transportID=<?php echo $transportID ?>&action=add" method="POST">
+	<input type="hidden" name="action" value="add">
+	<table border="1">
+		<tr>
+			<td>Attribute</td>
+			<td>Value</td>
+		</tr>
+		<tr>
+			<td>Address (@<?php echo $transportInfo->DomainName ?>)</td>
+			<td><input type="text" name="address"></td>
+		</tr>
+		<tr>
+			<td>Forward to</td>
+			<td><input type="text" name="goto"></td>
+		</tr>
+		<tr>
+			<td>AgentRef</td>
+			<td><input type="text" name="agentRef"></td>
+		</tr>
+		<tr>
+			<td>Disabled</td>
+			<td>
+				<select name="agentDisabled">
+					<option value="0" selected>no</option>
+					<option value="1">yes</option>
+				</select>
+			</td>
+		</tr>
+		<tr>
+			<td align="center" colspan="2">
+				<input type="submit" value="Add">
+			</td>
+		</tr>
+	</table>
+	</form>
+	<br>
+<?php
+
+}
+
+
+
+# List mailbox aliases
+function mailboxAliasList($searchOptions) {
+	global $soap;
+	global $transportID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+
+?>
+
+	<table border="1">
+		<tr>
+			<td colspan="6" align="center">Aliases for <?php echo $transportInfo->DomainName; ?></td>
+		</tr>
+		<tr>
+			<td align="center" rowspan="2">Alias</td>
+			<td align="center" rowspan="2">Foward to</td>
+			<td align="center" rowspan="2">AgentRef</td>
+			<td align="center" colspan="2">Disable</td>
+			<td></td>
+		</tr>
+		<tr>
+			<td align="center">Agent</td>
+			<td align="center">Delivery</td>
+			<td></td>
+		</tr>
+<?php
+	$mailboxAliases = $soap->getMailboxAliases($transportID,$searchOptions);
+	if (is_array($mailboxAliases)) {
+		if (count($mailboxAliases)) {
+?>
+			<tr>
+				<td colspan="6" align="center">
+					<a href="mailboxAliases.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox Alias</a>
+				</td>
+			</tr>
+<?php
+		}
+		foreach ($mailboxAliases as $item) {
+?>
+			<tr>
+				<td><?php echo $item->Address != "" ? $item->Address : "[catchall]"; ?></td>	
+				<td><?php echo $item->Goto; ?></td>	
+				<td><?php echo $item->AgentRef; ?></td>	
+				<td align="center"><?php echo $item->AgentDisabled ? "yes" : "no"; ?></td>	
+				<td align="center"><?php echo $item->DisableDelivery ? "yes" : "no"; ?></td>	
+				<td>
+					<a href="mailboxAliases.php?transportID=<?php echo $transportID; ?>&mailboxAliasID=<?php echo $item->ID; ?>&screen=edit">Edit</a>
+					 | <a href="mailboxAliases.php?transportID=<?php echo $transportID; ?>&mailboxAliasID=<?php echo $item->ID; ?>&screen=remove">Remove</a>
+				</td>
+			</tr>
+<?php		
+		}
+?>
+		<tr>
+			<td colspan="6" align="center">
+				<a href="mailboxAliases.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox Alias</a>
+			</td>
+		</tr>
+<?php
+			
+	} else {
+?>
+		<tr>
+			<td colspan="6">
+<?php
+				echo "getMailboxAliases: ".strSoapError($mailboxAliases);
+?>
+			</td>
+		</tr>
+<?php
+	}
+?>				
+	</table>
+
+<?php
+}
+
+
+
+
+# Display search box
+function searchBox()
+{
+	global $transportID;
+
+?>
+<form action="mailboxAliases.php" method="GET">
+<input type="hidden" name="transportID" value="<?php echo $transportID ?>">
+<input type="hidden" name="search" value="1">
+<table border="1">
+	<tr>
+		<td colspan="3" align="center">Search Mailbox Aliases</td>
+	</tr>
+	<tr>
+		<td colspan="2"></td>
+		<td align="center">Order by</td>
+	</tr>
+	<tr>
+		<td>Address</td>
+		<td>
+			<input type="text" name="searchAddress" value="<?php
+					echo $_SESSION['mailboxAlias_searchAddress'] 
+			?>">
+		</td>
+		<td align="center">
+			<input type="radio" name="searchOrderBy" value="Address" <?php
+				if ($_SESSION['mailboxAlias_searchOrderBy'] == "" 
+						|| $_SESSION['mailboxAlias_searchOrderBy'] == "Address") {
+					echo "checked";
+				}
+			?>>
+		</td>
+	</tr>
+	<tr>
+		<td>Agent Ref</td>
+		<td>
+			<input type="text" name="searchAgentRef" value="<?php
+					 echo $_SESSION['mailboxAlias_searchAgentRef']
+			?>">
+		</td>
+		<td align="center"><input type="radio" name="searchOrderBy" value="AgentRef" <?php
+				if ($_SESSION['mailboxAlias_searchOrderBy'] == "AgentRef") {
+					echo "checked";
+				}
+			?>>
+		</td>
+	</tr>
+	<tr>	
+		<td colspan="3" align="center"><input type="submit"></td>
+	</tr>
+</table>
+</form>
+
+Note On Searching:
+<li>Wildcards can be specified with *'s. For example: *.com  
+<li>Blank search criteria matches everything
+<?php
+}
+
+
+
+
+# Check if we have a transport
+if ($_REQUEST['transportID'] > 0) {
+	$transportID = $_REQUEST['transportID'];
+
+
+	# Check if we have a mailbox ID, pull in the relevant stuff
+	if ($_REQUEST['mailboxAliasID'] > 0) {
+		$mailboxAliasID = $_REQUEST['mailboxAliasID'];
+
+
+		printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
+		printf("<a href=\"mailboxAliases.php?transportID=%s&search=1\">Back to mailbox aliases</a><br><br>",$transportID);
+
+		# Check if we have a special action to perform
+		if ($_POST["action"] == "update") {
+			actionUpdate();
+		# Actual remove action
+		} elseif ($_POST["action"] == "remove")  {
+			actionRemove();
+		# Edit screen
+		} elseif ($_REQUEST["screen"] == "edit")  {
+			screenEdit();
+		# Remove screen
+		} elseif ($_REQUEST["screen"] == "remove")  {
+			screenRemove();
+		}
+
+
+	} else {
+		# Check if we have a special action to perform
+		if ($_REQUEST["screen"] == "add") {
+			printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
+			printf("<a href=\"mailboxAliases.php?transportID=%s&search=1\">Back to mailbox aliases</a><br><br>",$transportID);
+			screenAdd();
+		} elseif ($_POST["action"] == "add") {
+			printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
+			printf("<a href=\"mailboxAliases.php?transportID=%s&search=1\">Back to mailbox aliases</a><br><br>",$transportID);
+			actionAdd();
+		# We came from search screen
+		} elseif ($_REQUEST['search'] == 1) {
+			printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
+			# Process search options
+			if (isset($_REQUEST['searchAddress'])) {
+				$_SESSION['mailboxAlias_searchAddress'] = $_REQUEST['searchAddress'];
+			}
+			if (isset($_REQUEST['searchAgentRef'])) {
+				$_SESSION['mailboxAlias_searchAgentRef'] = $_REQUEST['searchAgentRef'];
+			}
+			if (isset($_REQUEST['searchOrderBy'])) {
+				$_SESSION['mailboxAlias_searchOrderBy'] = $_REQUEST['searchOrderBy'];
+			}
+
+			# Setup search
+			$searchOptions->searchAddress = $_SESSION['mailboxAlias_searchAddress'];
+			$searchOptions->searchAgentRef = $_SESSION['mailboxAlias_searchAgentRef'];
+			$searchOptions->searchOrderBy = $_SESSION['mailboxAlias_searchOrderBy'];
+
+			mailboxAliasList($searchOptions);
+		# We need to search
+		} else {
+			searchBox();
+		}
+	}
+} else {
+	echo "You cannot call this module directly.";
+}
+
+
+# Footer
+include("include/footer.php");
+?>
diff --git a/webui/agent-control-panel/mailboxes.php b/webui/agent-control-panel/mailboxes.php
new file mode 100644
index 0000000000000000000000000000000000000000..51887a16cc933af0e12e644e3293bbc37f53ba65
--- /dev/null
+++ b/webui/agent-control-panel/mailboxes.php
@@ -0,0 +1,672 @@
+<?php
+# Mailbox stuff
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+
+# Soap functions
+require_once("php/soapfuncs.php");
+
+
+# Javascript stuff
+include("js.getRandomPass");
+
+?>
+<a href=".">Home</a><br><br>
+<a href="mailTransports.php">Back to mail transport search</a><br><br>
+<a href="mailTransports.php?search=1">Back to mail transports</a><br><br>
+<?php
+
+
+
+# Actual form action to add mailbox
+function actionAdd() {
+	global $soap;	
+	global $transportID;
+
+	
+	$mailboxInfo = NULL;
+
+	# Verify data
+	if ($_POST["address"] != "") {
+		$mailboxInfo["Address"] = $_POST["address"];
+	} else {
+		echo "Address must be specified!<br>";
+		return;
+	}
+
+	if ($_POST["password"] != "") {
+		$mailboxInfo["Password"] = $_POST["password"];
+	} else {
+		echo "Password must be specified!<br>";
+		return;
+	}
+
+	# Check optional data
+	if ($_POST["quota"] != "") {
+		$mailboxInfo["Quota"] = $_POST["quota"];
+	} else {
+		echo "Quota must be defined!, you probably want to choose 5 for a 5Mb mailbox.<br>";
+		return;
+	}
+
+	if ($_POST["policyID"] != "") {
+		$mailboxInfo["PolicyID"] = $_POST["policyID"];
+	}		
+
+	if ($_POST["name"] != "") {
+		$mailboxInfo["Name"] = $_POST["name"];
+	}		
+
+	if ($_POST["agentRef"] != "") {
+		$mailboxInfo["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	if ($_POST["premiumSMTP"] != "") {
+		$mailboxInfo["PremiumSMTP"] = $_POST["premiumSMTP"];
+	}		
+
+	if ($_POST["premiumPolicy"] != "") {
+		$mailboxInfo["PremiumPolicy"] = $_POST["premiumPolicy"];
+	}		
+
+	if ($_POST["agentDisabled"] != "") {
+		$mailboxInfo["AgentDisabled"] = $_POST["agentDisabled"];
+	}		
+
+	# Create mailbox and check for error
+	$res = $soap->createMailbox($transportID,$mailboxInfo);
+	if ($res > 0) {
+		echo "Added mailbox<br>\n";
+	} else {
+		echo "Error creating mailbox: ".strSoapError($res);
+	}
+
+}
+
+
+
+
+# Actual form action to update mailbox
+function actionUpdate() {
+	global $soap;
+	global $mailboxID;
+
+
+	# Create update hash
+	$update = NULL;
+
+	if ($_POST["password"] != "") {
+		$update["Password"] = $_POST["password"];
+	}		
+
+	if ($_POST["quota"] != "") {
+		$update["Quota"] = $_POST["quota"];
+	}		
+
+	if ($_POST["policyID"] != "nochange") {
+		$update["PolicyID"] = $_POST["policyID"];
+	}		
+
+	if ($_POST["name"] != "") {
+		$update["Name"] = $_POST["name"];
+	}		
+
+	if ($_POST["agentRef"] != "") {
+		$update["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	if ($_POST["premiumSMTP"] != "") {
+		$update["PremiumSMTP"] = $_POST["premiumSMTP"];
+	}		
+
+	if ($_POST["premiumPolicy"] != "") {
+		$update["PremiumPolicy"] = $_POST["premiumPolicy"];
+	}		
+
+	if ($_POST["agentDisabled"] != "") {
+		$update["AgentDisabled"] = $_POST["agentDisabled"];
+	}		
+
+	# If there are still updates to be done, do them
+	if ($update != NULL) {
+		$update["ID"] = $mailboxID;
+		
+		$res = $soap->updateMailbox($update);
+		if ($res == 0) {
+			echo "Updated mailbox<br>\n";
+		} else {
+			echo "Error updating mailbox: ".strSoapError($res);
+		}
+	# Or report no updates to be made
+	} else {
+		echo "No updates to be made!\n";
+	}
+}
+
+
+
+
+# Actual form action to remove a mailbox
+function actionRemove() {
+	global $soap;
+	global $mailboxID;
+
+
+	$res = $soap->removeMailbox($mailboxID);
+	if ($res == 0) {
+		echo "Removed mailbox\n";
+	} else {
+		echo "Error removing mailbox: ".strSoapError($res);
+	}
+
+}
+
+
+
+
+# Display edit screen
+function screenEdit() {
+	global $soap;
+	global $transportID;
+	global $mailboxID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+		
+	$mailboxInfo = $soap->getMailboxInfo($mailboxID);
+	if (!is_object($mailboxInfo)) {
+		echo "getMailboxInfo: ".strSoapError($mailboxInfo);
+		return;
+	}
+
+	$mailPolicies = $soap->getMailPolicies();
+	if (!is_array($mailPolicies)) {
+		echo "getMailPolicies: ".strSoapError($mailPolicies);
+		return;
+	}
+
+?>
+	<form action="mailboxes.php?transportID=<?php echo $transportID; ?>&mailboxID=<?php echo $mailboxID; ?>" method="POST">
+	<input type="hidden" name="action" value="update">
+	<table border="1">
+		<tr>
+			<td colspan="3" align="center">
+				Mailbox: <?php printf("%s@%s",$mailboxInfo->Address,$transportInfo->DomainName); ?>
+			</td>
+		</tr>
+		<tr>
+			<td>Attribute</td>
+			<td>Value</td>
+			<td>New Value</td>
+		</tr>
+		<tr>
+			<td>Quota (in Mbyte)</td>
+			<td><?php echo $mailboxInfo->Quota; ?></td>
+			<td><input type="text" name="quota"></td>
+		</tr>
+		<tr>
+			<td>Password</td>
+			<td>*encrypted*</td>
+			<td>
+				<input type="text" name="password">
+				<input type="button" value="generate" onClick="this.form.password.value=getRandomPass(8)">
+			</td>
+		</tr>
+<?php
+
+		$policyName = "";
+		foreach ($mailPolicies as $policy) {
+			if ($mailboxInfo->PolicyID == $policy->ID) {
+				$policyName = $policy->PolicyName;
+			}
+		}
+?>
+		<tr>
+			<td>Policy</td>
+			<td><?php echo $policyName ? $policyName : "default"; ?></td>
+			<td>
+				<select name="policyID">
+					<option value="nochange"></option>
+					<option value="">Default</option>
+<?php
+					foreach ($mailPolicies as $policy) {
+						printf("<option value=\"%s\">%s</option>",$policy->ID,$policy->PolicyName);
+					}
+?>
+				</select>
+			</td>
+		</tr>
+
+		<tr>
+			<td>Name</td>
+			<td><?php echo $mailboxInfo->Name; ?></td>
+			<td><input type="text" name="name"></td>
+		</tr>
+
+		<tr>
+			<td>AgentRef</td>
+			<td><?php echo $mailboxInfo->AgentRef; ?></td>
+			<td><input type="text" name="agentRef"></td>
+		</tr>
+
+		<tr>
+			<td>Premium SMTP</td>
+			<td><?php echo $mailboxInfo->PremiumSMTP ? "yes" : "no"; ?></td>
+			<td>
+				<select name="premiumSMTP">
+					<option value="0" <?php if (!$mailboxInfo->PremiumSMTP) { echo "selected"; } ?>>no</option>
+					<option value="1" <?php if ($mailboxInfo->PremiumSMTP) { echo "selected"; } ?>>yes</option>
+				</select>
+			</td>
+		</tr>
+
+		<tr>
+			<td>Premium Policy</td>
+			<td><?php echo $mailboxInfo->PremiumPolicy ? "yes" : "no"; ?></td>
+			<td>
+				<select name="premiumPolicy">
+					<option value="0" <?php if (!$mailboxInfo->PremiumPolicy) { echo "selected"; } ?>>no</option>
+					<option value="1" <?php if ($mailboxInfo->PremiumPolicy) { echo "selected"; } ?>>yes</option>
+				</select>
+			</td>
+		</tr>
+
+		<tr>
+			<td>Disabled</td>
+			<td><?php echo $mailboxInfo->AgentDisabled ? "yes" : "no"; ?></td>
+			<td>
+				<select name="agentDisabled">
+					<option value="0" <?php if (!$mailboxInfo->AgentDisabled) { echo "selected"; } ?>>no</option>
+					<option value="1" <?php if ($mailboxInfo->AgentDisabled) { echo "selected"; } ?>>yes</option>
+				</select>
+			</td>
+		</tr>
+		<tr>
+			<td align="center" colspan="3">
+				<input type="submit" value="Update">
+			</td>
+		</tr>
+	</table>
+
+	</form>
+	<br>
+
+	<font size="-1">
+		Note:
+		<li>To enable clients to log in an change their anti-virus/spam settings, set [Policy] to "Client - Premium Service" and [Premium Policy] to "yes"
+	</font>
+<?php
+}
+
+
+
+
+# Remove screen
+function screenRemove() {
+	global $soap;
+	global $transportID;
+	global $mailboxID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+		
+	$mailboxInfo = $soap->getMailboxInfo($mailboxID);
+	if (!is_object($mailboxInfo)) {
+		echo "getMailboxInfo: ".strSoapError($mailboxInfo);
+		return;
+	}
+
+?>
+	<form action="mailboxes.php?transportID=<?php echo $transportID ?>&mailboxID=<?php echo $mailboxID ?>" method="POST">
+		<input type="hidden" name="action" value="remove">
+		Are you very sure you wish to remove mailbox <?php printf("%s@%s",$mailboxInfo->Address,$transportInfo->DomainName) ?>?
+		<br>
+		<input type="submit" value="Yes">
+	</form>
+	<br
+<?php
+}
+
+
+
+
+# Add screen
+function screenAdd() {
+	global $soap;
+	global $transportID;
+	global $mailboxID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+		
+
+?>
+	<form action="mailboxes.php?transportID=<?php echo $transportID ?>&action=add" method="POST">
+	<input type="hidden" name="action" value="add">
+	<table border="1">
+		<tr>
+			<td>Attribute</td>
+			<td>Value</td>
+		</tr>
+		<tr>
+			<td>Address (@<?php echo $transportInfo->DomainName ?>)</td>
+			<td><input type="text" name="address"></td>
+		</tr>
+		<tr>
+			<td>Password</td>
+			<td>
+				<input type="text" name="password">
+				<input type="button" value="generate" onClick="this.form.password.value=getRandomPass(8)">
+			</td>
+		</tr>
+		<tr>
+			<td>Quota (in Mbyte)</td>
+			<td><input type="text" name="quota"></td>
+		</tr>
+		<tr>
+			<td>Name</td>
+			<td><input type="text" name="name"></td>
+		</tr>
+		<tr>
+			<td>AgentRef</td>
+			<td><input type="text" name="agentRef"></td>
+		</tr>
+		<tr>
+			<td>Premium SMTP</td>
+			<td>
+				<select name="premiumSMTP">
+					<option value="0" selected>no</option>
+					<option value="1">yes</option>
+				</select>
+			</td>
+		</tr>
+		<tr>
+			<td>Premium Policy</td>
+			<td>
+				<select name="premiumPolicy">
+					<option value="0" selected>no</option>
+					<option value="1">yes</option>
+				</select>
+			</td>
+		</tr>
+		<tr>
+			<td>Disabled</td>
+			<td>
+				<select name="agentDisabled">
+					<option value="0" selected>no</option>
+					<option value="1">yes</option>
+				</select>
+			</td>
+		</tr>
+		<tr>
+			<td align="center" colspan="2">
+				<input type="submit" value="Add">
+			</td>
+		</tr>
+	</table>
+	</form>
+	<br>
+<?php
+}
+
+
+
+
+# List mailboxes
+function mailboxList($searchOptions) {
+	global $soap;
+	global $transportID;
+
+
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+
+	if (!is_object($transportInfo)) {
+		echo "getMailTransportInfo: ".strSoapError($transportInfo);
+		return;
+	}
+
+?>
+	<table border="1">
+		<tr>
+			<td colspan="7" align="center">Search Results for Mailboxes on <?php echo $transportInfo->DomainName; ?></td>
+		</tr>
+		<tr>
+			<td rowspan="2" align="center">Mailbox</td>
+			<td rowspan="2" align="center">Quota</td>
+			<td rowspan="2" align="center">AgentRef</td>
+			<td colspan="3" align="center">Disable</td>
+			<td rowspan="2"></td>
+		</tr>
+		<tr>
+			<td>Agent</td>
+			<td>Login</td>
+			<td>Delivery</td>
+		</tr>
+<?php
+	$mailboxes = $soap->getMailboxes($transportID,$searchOptions);
+	if (is_array($mailboxes)) {
+		if (count($mailboxes)) {
+?>
+			<tr>
+				<td colspan="7" align="center">
+					<a href="mailboxes.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox</a>
+				</td>
+			</tr>
+<?php
+		}
+
+		foreach ($mailboxes as $item) {
+?>
+			<tr>
+				<td><?php echo $item->Address; ?></td>	
+				<td><?php echo $item->Quota; ?>Mb</td>	
+				<td><?php echo $item->AgentRef; ?></td>	
+				<td align="center"><?php echo $item->AgentDisabled ? "yes" : "no"; ?></td>	
+				<td align="center"><?php echo $item->DisableLogin ? "yes" : "no"; ?></td>	
+				<td align="center"><?php echo $item->DisableDelivery ? "yes" : "no"; ?></td>	
+				<td>
+					<a href="mailboxes.php?transportID=<?php echo $transportID; ?>&mailboxID=<?php echo $item->ID; ?>&screen=edit">Edit</a>	
+					 | <a href="mailboxes.php?transportID=<?php echo $transportID; ?>&mailboxID=<?php echo $item->ID; ?>&screen=remove">Remove</a>
+				</td>
+			</tr>
+<?php		
+		}
+?>
+		<tr>
+			<td colspan="7" align="center">
+				<a href="mailboxes.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox</a>
+			</td>
+		</tr>
+<?php
+			
+	} else {
+?>
+		<tr>
+			<td colspan="5">
+<?php
+				echo "getMailboxes: ".strSoapError($mailboxes);
+?>
+			</td>
+		</tr>
+<?php
+	}
+?>				
+	</table>
+
+<?php
+}
+
+
+
+
+# Display search box
+function searchBox()
+{
+	global $transportID;
+
+?>
+
+<form action="mailboxes.php" method="GET">
+<input type="hidden" name="transportID" value="<?php echo $transportID ?>">
+<input type="hidden" name="search" value="1">
+<table border="1">
+	<tr>
+		<td colspan="3" align="center">Search Mailboxes</td>
+	</tr>
+	<tr>
+		<td colspan="2"></td>
+		<td align="center">Order by</td>
+	</tr>
+	<tr>
+		<td>Address</td>
+		<td>
+			<input type="text" name="searchAddress" value="<?php
+					echo $_SESSION['mailbox_searchAddress'] 
+			?>">
+		</td>
+		<td align="center">
+			<input type="radio" name="searchOrderBy" value="Address" <?php
+				if ($_SESSION['mailbox_searchOrderBy'] == "" 
+						|| $_SESSION['mailbox_searchOrderBy'] == "Address") {
+					echo "checked";
+				}
+			?>>
+		</td>
+	</tr>
+	<tr>
+		<td>Agent Ref</td>
+		<td>
+			<input type="text" name="searchAgentRef" value="<?php
+					 echo $_SESSION['mailbox_searchAgentRef']
+			?>">
+		</td>
+		<td align="center"><input type="radio" name="searchOrderBy" value="AgentRef" <?php
+				if ($_SESSION['mailbox_searchOrderBy'] == "AgentRef") {
+					echo "checked";
+				}
+			?>>
+		</td>
+	</tr>
+	<tr>	
+		<td colspan="2" align="center"><input type="submit"></td>
+	</tr>
+</table>
+</form>
+
+Note On Searching:
+<li>Wildcards can be specified with *'s. For example: *.com  
+<li>Blank search criteria matches everything
+
+<?php
+}
+
+
+
+
+# Check if we have a transport
+if ($_REQUEST['transportID'] > 0) {
+	$transportID = $_REQUEST['transportID'];
+	$transportInfo = $soap->getMailTransportInfo($transportID);
+
+
+	# Check if we have a mailbox ID, pull in the relevant stuff
+	if ($_REQUEST['mailboxID'] > 0) {
+		$mailboxID = $_REQUEST['mailboxID'];
+
+
+		printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
+		printf("<a href=\"mailboxes.php?transportID=%s&search=1\">Back to mailboxes</a><br><br>",$transportID);
+
+		# Check if we have a special action to perform
+		if ($_POST["action"] == "update") {
+			actionUpdate();
+		# Actual remove action
+		} elseif ($_POST["action"] == "remove")  {
+			actionRemove();
+		# Edit screen
+		} elseif ($_REQUEST["screen"] == "edit")  {
+			screenEdit();
+		# Remove screen
+		} elseif ($_REQUEST["screen"] == "remove")  {
+			screenRemove();
+		}
+
+	} else {
+
+		# Check if we have a special action to perform
+		if ($_REQUEST["screen"] == "add") {
+			printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
+			printf("<a href=\"mailboxes.php?transportID=%s&search=1\">Back to mailboxes</a><br><br>",$transportID);
+			screenAdd();
+		} elseif ($_POST["action"] == "add") {
+			printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
+			printf("<a href=\"mailboxes.php?transportID=%s&search=1\">Back to mailboxes</a><br><br>",$transportID);
+			actionAdd();
+		# We came from search screen
+		} elseif ($_REQUEST['search'] == 1) {
+			printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
+
+			# Process search options
+			if (isset($_REQUEST['searchAddress'])) {
+				$_SESSION['mailbox_searchAddress'] = $_REQUEST['searchAddress'];
+			}
+			if (isset($_REQUEST['searchAgentRef'])) {
+				$_SESSION['mailbox_searchAgentRef'] = $_REQUEST['searchAgentRef'];
+			}
+			if (isset($_REQUEST['searchOrderBy'])) {
+				$_SESSION['mailbox_searchOrderBy'] = $_REQUEST['searchOrderBy'];
+			}
+
+			# Setup search
+			$searchOptions->searchAddress = $_SESSION['mailbox_searchAddress'];
+			$searchOptions->searchAgentRef = $_SESSION['mailbox_searchAgentRef'];
+			$searchOptions->searchOrderBy = $_SESSION['mailbox_searchOrderBy'];
+
+			mailboxList($searchOptions);
+		# We need to search
+		} else {
+			searchBox();
+		}
+	}
+} else {
+	echo "You cannot call this module directly.";
+}
+
+
+# Footer
+include("include/footer.php");
+?>
diff --git a/webui/agent-control-panel/radius-user-add.php b/webui/agent-control-panel/radius-user-add.php
new file mode 100644
index 0000000000000000000000000000000000000000..a633807cdd0f535d29e42e7197e1c584789b95ec
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-add.php
@@ -0,0 +1,195 @@
+<?php
+# Radius user add
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+function displayAdd()
+{
+	global $soap;
+
+
+	$radiusClasses = $soap->getRadiusClasses();
+	if (!is_array($radiusClasses)) {
+		displayError("getRadiusClasses: ".strSoapError($radiusClasses));
+		return;
+	}
+			
+?>
+	<script src="static/js.getRandomPass" type="text/javascript"></script>
+	
+	<div class="sectiontitle">Add Radius User</div>
+	<p />
+
+	<form action="radius-user-add.php" method="post">
+		<div>
+			<input type="hidden" name="frmaction" value="add_final">
+		</div>
+		<table class="entrytable">
+			<tr>
+				<td class="title">Username</td>
+				<td class="entry"><input type="text" name="username" /></td>
+			</tr>
+			<tr>
+				<td class="title">Password</td>
+				<td class="entry">
+					<input type="text" name="password" />
+					<input type="button" value="generate" onClick="this.form.password.value=getRandomPass(8)" />
+				</td>
+			</tr>
+			<tr>
+				<td class="title">Class</td>
+				<td class="entry">
+					<select name="classID">
+<?php
+						foreach ($radiusClasses as $class) {
+							printf("<option value=\"%s\">%s</option>",$class->ID,$class->Service);
+						}
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="title">Usage Cap</td>
+				<td class="entry"><input type="text" name="usageCap" /></td>
+			</tr>
+			<tr>
+				<td class="title">Notify Email</td>
+				<td class="entry"><input type="text" name="notifyMethodEmail" /></td>
+			</tr>
+			<tr>
+				<td class="title">Notify Cell #</td>
+				<td class="entry"><input type="text" name="notifyMethodCell" /></td>
+			</tr>
+			<tr>
+				<td class="title">AgentRef</td>
+				<td class="entry"><input type="text" name="agentRef" /></td>
+			</tr>
+			<tr>
+				<td class="title">Disabled</td>
+				<td class="entry">
+					<select name="agentDisabled">
+						<option value="0" selected>no</option>
+						<option value="1">yes</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td align="center" colspan="2">
+					<input type="submit" value="Add" />
+				</td>
+			</tr>
+		</table>
+	</form>
+<?php
+}
+
+
+function doAdd()
+{
+	global $soap;	
+
+	
+	$userInfo = NULL;
+
+	# Verify data
+	if ($_POST["username"] != "") {
+		$userInfo["Username"] = $_POST["username"];
+	} else {
+		displayError("Username must be specified!");
+		return;
+	}
+
+	if ($_POST["password"] != "") {
+		$userInfo["Password"] = $_POST["password"];
+	} else {
+		displayError("Password must be specified!");
+		return;
+	}
+
+	if ($_POST["username"] == $_POST["password"]) {
+		displayError("Password must be specified!");
+		return;
+	}
+
+	if ($_POST["classID"] != "") {
+		$userInfo["ClassID"] = $_POST["classID"];
+	} else {
+		displayError("Class must be specified!");
+		return;
+	}
+
+	# Check optional data
+	if ($_POST["usageCap"] != "") {
+		$userInfo["UsageCap"] = $_POST["usageCap"];
+	}		
+
+	if ($_POST["notifyMethodCell"] != "") {
+		$userInfo["NotifyMethodCell"] = $_POST["notifyMethodCell"];
+	}		
+	if ($_POST["notifyMethodEmail"] != "") {
+		$userInfo["NotifyMethodEmail"] = $_POST["notifyMethodEmail"];
+	}		
+
+	if ($_POST["agentRef"] != "") {
+		$userInfo["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	if ($_POST["agentDisabled"] != "") {
+		$userInfo["AgentDisabled"] = $_POST["agentDisabled"];
+	}		
+
+	# Create radius user and check for error
+	$res = $soap->createRadiusUser($userInfo);
+	if ($res > 0) {
+		displaySuccess("Added radius user");
+	} else {
+		displayError("Error creating radius user: ".strSoapError($res));
+	}
+
+}
+
+
+# Check if we have an action
+if (!isset($_POST['frmaction'])) {
+	displayAdd();
+
+} elseif ($_POST['frmaction'] == "add_main") {
+	displayAdd();
+
+} elseif ($_POST['frmaction'] == "add_final") {
+	doAdd();
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-change.php b/webui/agent-control-panel/radius-user-change.php
new file mode 100644
index 0000000000000000000000000000000000000000..07521651923cb8a6df2fa81f50067e59fab2b4d7
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-change.php
@@ -0,0 +1,196 @@
+<?php
+# Radius user change
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+function displayChange($userID)
+{
+	global $soap;
+
+
+	# Grab user info
+	$userInfo = $soap->getRadiusUser($userID);
+	if (!is_object($userInfo)) {
+		displayError("getRadiusUser: ".strSoapError($userInfo));
+		return;
+	}
+		
+	# check if we dialup or not
+	$isDialup = preg_match('/dialup/i',$userInfo->Service);
+
+
+?>
+	<script src="static/js.getRandomPass" type="text/javascript"></script>
+
+	
+	<div class="sectiontitle">Change Radius User</div>
+	<p />
+
+	<form action="radius-user-change.php" method="post">
+		<div>
+			<input type="hidden" name="user_id" value="<?php echo $userID; ?>" />
+			<input type="hidden" name="frmaction" value="change_final" />
+		</div>
+		<table class="entrytable">
+			<tr>
+				<td class="title">Attribute</td>
+				<td class="title">Value</td>
+				<td class="title">New Value</td>
+			</tr>
+
+			<tr>
+				<td class="title2">Service</td>
+				<td class="oldvalue"><?php echo $userInfo->Service; ?></td>
+				<td></td>
+			</tr>
+
+			<tr>
+				<td class="title2">UsageCap</td>
+				<td class="oldvalue"><?php echo $userInfo->UsageCap; ?></td>
+				<td class="entry"><input type="text" name="usageCap" /></td>
+			</tr>
+
+			<tr>
+				<td class="title2">Password</td>
+				<td class="oldvalue">*encrypted*</td>
+				<td class="entry">
+					<input type="text" name="password" />
+					<input type="button" value="generate" onclick="this.form.password.value=getRandomPass(8)" />
+				</td>
+			</tr>
+<?php
+			# DSL USER ONLY 
+			if (!$isDialup) {
+?>
+				<tr>
+					<td class="title2">Notify Email</td>
+					<td class="oldvalue"><?php echo $userInfo->NotifyMethodEmail ?></td>
+					<td class="entry"><input type="text" name="notifyMethodEmail" /></td>
+				</tr>
+				<tr>
+					<td class="title2">Notify Cell #</td>
+					<td class="oldvalue"><?php echo $userInfo->NotifyMethodCell ?></td>
+					<td class="entry"><input type="text" name="notifyMethodCell" /></td>
+				</tr>
+<?php
+			}
+?>
+			<tr>
+				<td class="title2">AgentRef</td>
+				<td class="oldvalue"><?php echo $userInfo->AgentRef; ?></td>
+				<td class="entry"><input type="text" name="agentRef" /></td>
+			</tr>
+			<tr>
+				<td class="title2">Disabled</td>
+				<td class="oldvalue"><?php echo $userInfo->AgentDisabled ? "yes" : "no"; ?></td>
+				<td class="entry">
+					<select name="agentDisabled">
+						<option value="">-</option>
+						<option value="0">no</option>
+						<option value="1">yes</option>
+					</select>
+				</td>
+				<td></td>
+			</tr>
+		</table>
+		<div class="text-center">
+			<input type="submit" value="Update" />
+		</div>
+	</form>		
+<?php
+}
+
+
+# Actual form action to update radius user
+function doUpdate($userID) {
+	global $soap;
+
+	# Create update hash
+	$update = NULL;
+
+	if ($_POST["password"] != "") {
+		$update["Password"] = $_POST["password"];
+	}		
+
+	if ($_POST["usageCap"] != "") {
+		$update["UsageCap"] = $_POST["usageCap"];
+	}		
+
+	if ($_POST["notifyMethodCell"] != "") {
+		$update["NotifyMethodCell"] = $_POST["notifyMethodCell"];
+	}		
+	if ($_POST["notifyMethodEmail"] != "") {
+		$update["NotifyMethodEmail"] = $_POST["notifyMethodEmail"];
+	}		
+
+	if ($_POST["agentRef"] != "") {
+		$update["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	if ($_POST["agentDisabled"] != "") {
+		$update["AgentDisabled"] = $_POST["agentDisabled"];
+	}		
+
+	# If there are still updates to be done, do them
+	if ($update != NULL) {
+		$update["ID"] = $userID;
+		
+		$res = $soap->updateRadiusUser($update);
+		if ($res == 0) {
+			displaySuccess("Radius user updated");
+		} else {
+			displayError("Error updating radius user($res): ".strSoapError($res));
+		}
+	# Or report no updates to be made
+	} else {
+		displaySuccess("No updates to be made!");
+	}
+}
+
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "change_main") {
+	displayChange($_REQUEST['user_id']);
+
+} elseif ($_REQUEST['frmaction'] == "change_final") {
+	doUpdate($_REQUEST['user_id']);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-delete.php b/webui/agent-control-panel/radius-user-delete.php
new file mode 100644
index 0000000000000000000000000000000000000000..dcef0e90bebde6ab2eb506c50937648102756f48
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-delete.php
@@ -0,0 +1,103 @@
+<?php
+# Radius user delete
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+
+# Remove screen
+function displayDelete($userID) {
+	global $soap;
+
+
+	$userInfo = $soap->getRadiusUser($userID);
+	if (!is_object($userInfo)) {
+		displayError("getRadiusUser: ".strSoapError($userInfo));
+		return;
+	}
+		
+?>
+	<div class="sectiontitle">Radius User Search Results</div>
+	<p />
+
+	<div class="text-center">
+		<form action="radius-user-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete_final" />
+				<input type="hidden" name="user_id" value="<?php echo $userID ?>" />
+				Are you very sure you wish to remove radius user <?php echo $userInfo->Username; ?>?<p />
+				<input type="submit" name="delete_confirm" value="Yes" />
+				<input type="submit" name="delete_confirm" value="No" />
+			</div>
+		</form>
+	</div>
+<?php
+}
+
+
+
+# Actual form action to remove a mailbox
+function doDelete($userID) {
+	global $soap;
+
+
+	$res = $soap->removeRadiusUser($userID);
+	if ($res == 0) {
+		displaySuccess("Removed radius user");
+	} else {
+		displayError("Error removing radius user: ".strSoapError($res));
+	}
+}
+
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "delete_main") {
+	# Else no confirmation, display confirm dialog
+	displayDelete($_REQUEST['user_id']);
+
+} elseif ($_REQUEST['frmaction'] == "delete_final") {
+	# If confirmed delete
+	if ($_REQUEST['delete_confirm'] == "Yes") {
+		doDelete($_REQUEST['user_id']);
+	} else {
+		# FIXME - redirect to main
+	}
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-info.php b/webui/agent-control-panel/radius-user-info.php
new file mode 100644
index 0000000000000000000000000000000000000000..4befd0d29d21e5a3bd5e051d9487f4c2bae893a8
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-info.php
@@ -0,0 +1,94 @@
+<?php
+# Radius user info
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("soapfuncs.php");
+
+
+
+function display($userID)
+{
+	global $soap;
+
+
+	$userInfo = $soap->getRadiusUser($userID);
+	if (!is_object($userInfo)) {
+		echo "getRadiusUser: ".strSoapError($userInfo);
+		return;
+	}
+
+	$isDialup = preg_match('/dialup/i',$userInfo->Service);
+
+	# DSL USER ONLY INFO
+	if (!$isDialup) {
+		$topups = $soap->getRadiusUserCurrentTopups($userID);
+		$currentUsage = $soap->getRadiusUserCurrentUsage($userID);
+?>
+		<div class="sectiontitle">User Information</div>
+		<p />
+
+		<table class="entrytable">
+			<tr>
+				<td class="title text-right">Usage cap</td>
+				<td class="value text-right" style="width: 50px;"><?php echo $userInfo->UsageCap ?></td>
+			</tr>
+			<tr>
+				<td class="title text-right">+ Current topups</td>
+				<td class="value text-right"><?php echo $topups ?></td>
+			</tr>
+			<tr>
+				<td class="title text-right">Total usage allowed</td>
+				<td class="value text-right" style="border-top: 2px solid black;"><?php echo $userInfo->UsageCap + $topups ?></td>
+			</tr>
+			<tr>
+				<td class="title text-right">Current usage</td>
+				<td class="value text-right" style="border-top: 2px solid black;"><?php echo $currentUsage ?></td>
+			</tr>
+		</table>
+		<p />
+<?php
+	}
+}
+
+
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME - redirect to main page
+
+} elseif ($_REQUEST['frmaction'] == "info_main") { 
+	display($_REQUEST['user_id']);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-logs.php b/webui/agent-control-panel/radius-user-logs.php
new file mode 100644
index 0000000000000000000000000000000000000000..16bbedc4ca47cac3395b17d36164bb45fd9dba58
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-logs.php
@@ -0,0 +1,243 @@
+<?php
+# Radius user logs
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+function displaySearch($userID)
+{
+
+?>
+	<div class="sectiontitle">Search Radious Logs</div>
+	<p />
+
+	<form action="radius-user-logs.php" method="post">
+		<div>
+			<input type="hidden" name="user_id" value="<?php echo $userID ?>" />
+			<input type="hidden" name="frmaction" value="logs_final" />
+		</div>
+
+		<table class="entrytable">
+			<tr>
+				<td class="title">From</td>
+				<td class="entry">
+					<input type="text" name="searchLogsFrom" value="<?php
+							if (isset($_SESSION['radiusUserLogs_searchFrom'])) {
+								echo $_SESSION['radiusUserLogs_searchFrom'];
+							}
+					?>" />
+				</td>
+			</tr>
+			<tr>
+				<td class="title">To</td>
+				<td class="entry">
+					<input type="text" name="searchLogsTo" value="<?php
+							if (isset($_SESSION['radiusUserLogs_searchTo'])) {
+								echo $_SESSION['radiusUserLogs_searchTo'];
+							}
+					?>" />
+				</td>
+			</tr>
+			<tr>
+				<td class="title">Order By</td>
+				<td class="entry" colspan="2">
+					<input type="radio" name="searchLogsOrderBy" value="date" checked="checked" /> Date
+				</td>
+			</tr>
+		</table>
+		<div class="text-center">
+			<input type="submit" />
+		</div>
+	</form>
+
+Note On Searching:
+<ul>
+	<li>Dates are in the format of YYYY-MM-DD</li>
+	<li>Blank search criteria matches last 50 logs</li>
+</ul>
+<?php
+}
+
+
+# Display radius user logs
+function displayLogs($userID,$searchOptions) {
+	global $soap;
+
+	# Radius functions
+	require_once("radiuscodes.php");
+
+	$userInfo = $soap->getRadiusUser($userID);
+
+	$isDialup = preg_match('/dialup/i',$userInfo->Service);
+
+	$userLogs = $soap->getRadiusUserLogs($userID,$searchOptions);
+	if (is_array($userLogs)) {
+?>
+		<div class="sectiontitle">Radius User Logs</div>
+		<br />
+
+		<table class="resulttable">
+			<tr>
+				<td class="title">Timestamp</td>
+				<td class="title">Session ID</td>
+				<td class="title">Session Time</td>
+<?php
+				# Calling/Called station only for dialups
+				if ($isDialup) {
+?>
+					<td class="title">Station</td>
+<?php
+				} else {
+?>
+					<td class="title">NAS Port</td>
+<?php
+				}
+?>
+				<td class="title">Port Rate</td>
+				<td class="title">IP Address</td>
+				<td class="title">Uploaded Mb</td>
+				<td class="title">Downloaded Mb</td>
+				<td class="title">Last Update</td>
+				<td class="title">Status</td>
+				<td class="title">Term Reason</td>
+			</tr>
+<?php
+			$totalIn = 0;
+			$totalOut = 0;
+			$totalTime = 0;
+			foreach ($userLogs as $entry) {
+				$inputMBytes = $entry->AcctInputOctets > 0 ? $entry->AcctInputOctets / 1024 / 1024 : 0;
+				$outputMBytes = $entry->AcctOutputOctets > 0 ? $entry->AcctOutputOctets / 1024 / 1024 : 0;
+				$inputMBytes += $entry->AcctInputGigawords * 4096;
+				$outputMBytes += $entry->AcctOutputGigawords * 4096;
+?>
+				<tr>
+					<td><?php echo $entry->Timestamp; ?></td>
+					<td><?php echo $entry->AcctSessionID; ?></td>
+					<td class="text-right"><?php echo $entry->AcctSessionTime; ?></td>
+<?php
+					# Calling/Called station only for dialups
+					if ($isDialup) {
+?>
+						<td><?php echo $entry->CallingStationID."/".$entry->CalledStationID; ?></td>
+<?php
+					} else {
+?>
+						<td><?php echo $entry->NASPort; ?></td>
+<?php
+					}
+?>
+
+					<td><?php echo $entry->NASTransmitRate ."/". $entry->NASReceiveRate; ?></td>
+					<td><?php echo $entry->FramedIPAddress; ?></td>
+					<td><?php echo sprintf('%.2f',$inputMBytes); ?></td>
+					<td><?php echo sprintf('%.2f',$outputMBytes); ?></td>
+					<td><?php echo $entry->LastAcctUpdate; ?></td>
+					<td><?php echo $entry->Status; ?></td>
+					<td><?php echo strRadiusTermCode($entry->ConnectTermReason); ?></td>
+				</tr>
+<?php
+				$totalIn += $inputMBytes;
+				$totalOut += $outputMBytes;
+				$totalTime += $entry->AcctSessionTime;
+			}
+?>
+				<tr>
+					<td class="title text-center" colspan="12">Totals</td>
+				</tr>
+				<tr>
+					<td></td>
+					<td></td>
+					<td class="title2 text-right"><?php echo $totalTime; ?></td>
+					<td></td>
+					<td></td>
+					<td></td>
+					<td class="title2 text-right"><?php echo sprintf('%.2f',$totalIn); ?></td>
+					<td class="title2 text-right"><?php echo sprintf('%.2f',$totalOut); ?></td>
+					<td></td>
+					<td></td>
+					<td></td>
+				</tr>
+				<tr>
+					<td></td>
+					<td></td>
+					<td></td>
+					<td></td>
+					<td></td>
+					<td></td>
+					<td class="title2 text-center" colspan="2"><?php echo sprintf('%.2f',$totalIn + $totalOut); ?></td>
+					<td></td>
+					<td></td>
+					<td></td>
+				</tr>
+		</table>
+		<br />
+<?php
+	} else {
+		echo "getRadiusUserLogs: ".strSoapError($userLogs);
+	}
+}
+
+
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "logs_main") {
+	displaySearch($_REQUEST['user_id']);
+
+} elseif ($_REQUEST['frmaction'] == "logs_final") {
+	# Process search options
+	if (isset($_REQUEST['searchLogsFrom'])) {
+		$_SESSION['radiusUserLogs_searchFrom'] = $_REQUEST['searchLogsFrom'];
+	}
+	if (isset($_REQUEST['searchLogsTo'])) {
+		$_SESSION['radiusUserLogs_searchTo'] = $_REQUEST['searchLogsTo'];
+	}
+	if (isset($_REQUEST['searchLogsOrderBy'])) {
+		$_SESSION['radiusUserLogs_searchOrderBy'] = $_REQUEST['searchLogsOrderBy'];
+	}
+
+	# Setup search
+	$searchOptions->searchFrom = isset($_SESSION['radiusUserLogs_searchFrom']) ? $_SESSION['radiusUserLogs_searchFrom'] : NULL;
+	$searchOptions->searchTo = isset($_SESSION['radiusUserLogs_searchTo']) ? $_SESSION['radiusUserLogs_searchTo']  : NULL;
+	$searchOptions->searchOrderBy = isset($_SESSION['radiusUserLogs_searchOrderBy']) ? $_SESSION['radiusUserLogs_searchOrderBy']  : NULL;
+
+	displayLogs($_REQUEST['user_id'],$searchOptions);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-main.php b/webui/agent-control-panel/radius-user-main.php
new file mode 100644
index 0000000000000000000000000000000000000000..2a70c8f893c7a013ddf0961b21b937c1a8e5539d
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-main.php
@@ -0,0 +1,239 @@
+<?php
+# Radius user search
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+# Include databae functionality
+include_once("include/db.php");
+
+
+
+$db = connect_db();
+
+
+
+# Function to display search box
+function displaySearch() {
+?>
+	<div class="sectiontitle">Search Radius Users</div>
+	<p />
+
+	<form action="radius-user-main.php" method="post">
+		<div>
+			<input type="hidden" name="frmaction" value="search_main" />
+		</div>
+		<table class="entrytable">
+			<tr>
+				<td colspan="2"></td>
+				<td class="textcenter">Order by</td>
+			</tr>
+			<tr>
+				<td class="title">Username</td>
+				<td class="entry">
+					<input type="text" name="searchUsername" class="entry" value="<?php
+						if (isset($_SESSION['radiusUser_searchUsername'])) {
+							echo $_SESSION['radiusUser_searchUsername'];
+						}
+					?>" />
+				</td>
+				<td align="center">
+					<input type="radio" name="searchOrderBy" value="Username" <?php
+						if (
+								isset($_SESSION['radiusUser_searchOrderBy']) && (
+									$_SESSION['radiusUser_searchOrderBy'] == "" || 
+									$_SESSION['radiusUser_searchOrderBy'] == "Username"
+								)
+						) {
+							echo "checked";
+						}
+					?> />
+				</td>
+			</tr>
+			<tr>
+				<td class="title">Service</td>
+				<td class="entry"></td>
+				<td align="center"><input type="radio" name="searchOrderBy" value="Service" <?php
+						if (isset($_SESSION['radiusUser_searchOrderBy']) && $_SESSION['radiusUser_searchOrderBy'] == "Service") {
+							echo "checked";
+						}
+					?> />
+				</td>
+			</tr>
+			<tr>
+				<td class="title">Agent Ref</td>
+				<td class="entry">
+					<input type="text" name="searchAgentRef" value="<?php
+						if (isset($_SESSION['radiusUser_searchAgentRef'])) {
+							echo $_SESSION['radiusUser_searchAgentRef'];
+						}
+					?>" />
+				</td>
+				<td align="center"><input type="radio" name="searchOrderBy" value="AgentRef" <?php
+						if (isset($_SESSION['radiusUser_searchOrderBy']) && $_SESSION['radiusUser_searchOrderBy'] == "AgentRef") {
+							echo "checked";
+						}
+					?> />
+				</td>
+			</tr>
+		</table>
+		<div class="text-center">
+			<input type="submit" />
+		</div>
+	</form>
+
+Note On Searching:
+<ul>
+	<li>Wildcards can be specified with *'s. For example: *@realm</li>
+	<li>Blank search criteria matches everything</li>
+	<li>Results limited to 100</li>
+</ul>
+<?php
+}
+
+
+
+
+
+function displaySearchResults($searchOptions)
+{
+	global $soap;
+	global $userID;
+
+?>
+		<div class="sectiontitle">Radius User Search Results</div>
+		<p />
+
+		<form id="main_form" action="radius-user-main.php" method="post">
+			<div class="text-center">
+				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 = 'radius-user-change.php';
+							} else if (myobj.selectedIndex == 3) {
+								myform.action = 'radius-user-delete.php';
+							} else if (myobj.selectedIndex == 4) {
+								myform.action = 'radius-user-info.php';
+							} else if (myobj.selectedIndex == 5) {
+								myform.action = 'radius-user-logs.php';
+							} else if (myobj.selectedIndex == 6) {
+								myform.action = 'radius-user-topup-add.php';
+							} else if (myobj.selectedIndex == 7) {
+								myform.action = 'radius-user-topup-main.php';
+							} else if (myobj.selectedIndex == 8) {
+								myform.action = 'radius-user-portlock-main.php';
+							} else if (myobj.selectedIndex == 10) {
+								myform.action = 'radius-user-add.php';
+							}
+
+							myform.submit();
+				">
+					<option selected="selected">select action</option>
+					<option disabled="disabled"> - T H I S - U S E R - </option>
+					<option value="change_main">Change</option>
+					<option value="delete_main">Delete</option>
+					<option value="info_main">Info</option>
+					<option value="logs_main">Logs</option>
+					<option value="topups_add_main">Topups: Add</option>
+					<option value="topups_main">Topups: Search</option>
+					<option value="portlocks_main">Port Locking</option>
+					<option disabled="disabled"> - - - - - - - - - - - </option>
+					<option value="add_main">Add User</option>
+				</select>
+			</div>
+
+			<table class="resulttable">
+				<tr>
+					<td></td>
+					<td class="title">Username</td>
+					<td class="title">Service Class</td>
+					<td class="title">UsageCap</td>
+					<td class="title">AgentRef</td>
+					<td class="title">Disabled</td>
+				</tr>
+<?php
+				foreach ($userList as $user) {
+			
+?>
+					<tr>
+						<td><input type="radio" name="user_id" value="<?php echo $user->ID ?>" /></td>
+						<td><?php echo $user->Username;  ?></td>
+						<td><?php echo $user->Service; ?></td>
+						<td class="text-right"><?php echo $usageCap; ?></td>
+						<td><?php echo $user->AgentRef; ?></td>
+						<td align="center"><?php echo $user->AgentDisabled ? "yes" : "no"; ?></td>
+					</tr>
+<?php
+				}
+?>
+			</table>
+		</form>
+<?php
+	} else {
+		displayError("getRadiusUsers: ".strSoapError($userList));
+	}
+}
+
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	displaySearch();
+
+
+} elseif ($_REQUEST['frmaction'] == "search_main") {
+	# Process search options
+	if (isset($_REQUEST['searchUsername'])) {
+		$_SESSION['radiusUser_searchUsername'] = $_REQUEST['searchUsername'];
+	}
+	if (isset($_REQUEST['searchAgentRef'])) {
+		$_SESSION['radiusUser_searchAgentRef'] = $_REQUEST['searchAgentRef'];
+	}
+	if (isset($_REQUEST['searchOrderBy'])) {
+		$_SESSION['radiusUser_searchOrderBy'] = $_REQUEST['searchOrderBy'];
+	}
+
+	# Setup search
+	$searchOptions->searchUsername = isset($_SESSION['radiusUser_searchUsername']) ? $_SESSION['radiusUser_searchUsername'] : NULL;
+	$searchOptions->searchAgentRef = isset($_SESSION['radiusUser_searchAgentRef']) ? $_SESSION['radiusUser_searchAgentRef'] : NULL;
+	$searchOptions->searchOrderBy = isset($_SESSION['radiusUser_searchOrderBy']) ? $_SESSION['radiusUser_searchOrderBy'] : NULL;
+
+
+	displaySearchResults($searchOptions);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-portlock-add.php b/webui/agent-control-panel/radius-user-portlock-add.php
new file mode 100644
index 0000000000000000000000000000000000000000..35dc466b001b049db2dd58a98f6f0abf8559ca2a
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-portlock-add.php
@@ -0,0 +1,105 @@
+<?php
+# Radius user, add port locking
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+function displayForm($userID)
+{
+	global $soap;
+?>
+	<form action="radius-user-portlock-add.php" method="post">
+		<div>
+			<input type="hidden" name="user_id" value="<?php echo $userID; ?>" />
+			<input type="hidden" name="frmaction" value="portlocks_add_final" />
+		</div>
+		<table class="entrytable">
+			<tr>
+				<td class="title">Port</td>
+				<td class="entry"><input type="text" name="portlock_port" /></td>
+			</tr>
+		</table>
+		<div class="text-center">
+			<input type="submit" value="Add" />
+		</div>
+	</form>
+	<p />
+
+Note On Searching:
+<ul>
+	<li>Dates are in the format of YYYY-MM-DD</li>
+	<li>ValidTo is ALWAYS the first day of the next month</li>
+</ul>
+<?php
+}
+
+
+function doAdd($userID)
+{
+	global $soap;	
+
+	
+	$lockInfo = NULL;
+	$lockInfo["UserID"] = $userID;
+
+	# Verify data
+	if (isset($_REQUEST["portlock_port"])) {
+		$lockInfo["Port"] = $_REQUEST["portlock_port"];
+	} else {
+		displayError("Port must be specified!");
+		return;
+	}
+
+	# Create radius user and check for error
+	$res = $soap->createRadiusUserPortLock($lockInfo);
+	if ($res > 0) {
+		displaySuccess("Added port lock to user");
+	} else {
+		displayError("Error creating port lock: ".strSoapError($res));
+	}
+}
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "portlocks_add_main") {
+	displayForm($_REQUEST['user_id']);
+
+} elseif ($_REQUEST['frmaction'] == "portlocks_add_final") {
+	doAdd($_REQUEST['user_id']);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-portlock-main.php b/webui/agent-control-panel/radius-user-portlock-main.php
new file mode 100644
index 0000000000000000000000000000000000000000..a3a826c8ab021a89bea70f6475b12f5897cd0451
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-portlock-main.php
@@ -0,0 +1,128 @@
+<?php
+# Radius user port locking
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+function displayList($userID)
+{
+	global $soap;
+
+	$userInfo = $soap->getRadiusUser($userID);
+	if (!is_object($userInfo)) {
+		displayError("getRadiusUser: ".strSoapError($userInfo));
+		return;
+	}
+
+	$portlocks = $soap->getRadiusUserPortLocks($userID);
+	if (!is_array($portlocks)) {
+		displayError("getRadiusUserLocks: ".strSoapError($portlocks));
+		return;
+	}
+
+?>
+	<div class="sectiontitle">Radius User Port Locks</div>
+	<p />
+
+	<form id="main_form" action="radius-user-portlock-main.php" method="post">
+		<div>
+			<input type="hidden" name="user_id" value="<?php echo $userID; ?>" />
+		</div>
+		<div class="text-center">
+			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 = 'radius-user-portlock-add.php';
+						} else if (myobj.selectedIndex == 3) {
+							myform.action = 'radius-user-portlock-remove.php';
+						}
+
+						myform.submit();
+			">
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="portlocks_add_main">Add</option>
+				<option value="portlocks_remove_main">Remove</option>
+			</select>
+		</div>
+
+		<table class="resulttable">
+			<tr>
+				<td></td>
+				<td class="title" style="width: 150px;">Port</td>
+				<td class="title">Disabled</td>
+				<td class="title">AgentRef</td>
+			</tr>
+<?php
+			# If below one lock, display no locks
+			if (count($portlocks) < 1) {
+?>
+			<tr>
+				<td colspan="4" align="center">No locking active</td>
+			</tr>
+<?php
+			} else {
+				foreach ($portlocks as $portlock) {
+?>
+					<tr>
+						<td><input type="radio" name="portlock_id" value="<?php echo $portlock->ID ?>" /></td>
+						<td><?php echo $portlock->Port; ?></td>
+						<td class="text-center"><?php echo $portlock->AgentDisabled ? "yes" : "no"; ?></td>
+						<td><?php echo $portlock->AgentRef; ?></td>
+					</tr>
+<?php
+				}
+			}
+?>
+		</table>
+	</form>
+<?php
+}
+
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "portlocks_main") {
+	displayList($_REQUEST['user_id']);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-portlock-remove.php b/webui/agent-control-panel/radius-user-portlock-remove.php
new file mode 100644
index 0000000000000000000000000000000000000000..b17711615f415897e2642e732b5bbb0fe8bbf0dc
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-portlock-remove.php
@@ -0,0 +1,66 @@
+<?php
+# Radius user, add port locking
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+function doRemove($portlockID) {
+	global $soap;	
+
+	
+	# Create radius user and check for error
+	$res = $soap->removeRadiusUserPortLock($portlockID);
+	if ($res == 0) {
+		displaySuccess("Port lock removed");
+	} else {
+		displayError("Error removing port lock: ".strSoapError($res));
+	}
+}
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "portlocks_remove_main") {
+	# Verify data
+	if (isset($_REQUEST["portlock_id"])) {
+		doRemove($_REQUEST['portlock_id']);
+	} else {
+		displayError("PortLockID not found!");
+	}
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-topup-add.php b/webui/agent-control-panel/radius-user-topup-add.php
new file mode 100644
index 0000000000000000000000000000000000000000..74f522e88a5660d8782dc5c506c56524f4db6376
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-topup-add.php
@@ -0,0 +1,152 @@
+<?php
+# Radius user, add topups
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+
+# Add topup
+function displayForm($userID) {
+	global $soap;
+
+?>
+	<div class="sectiontitle">Add Topup</div>
+	<p />
+
+	<form action="radius-user-topup-add.php" method="post">
+		<div>
+			<input type="hidden" name="user_id" value="<?php echo $userID; ?>" />
+			<input type="hidden" name="frmaction" value="topups_add_final" />
+		</div>
+		<table class="entrytable">
+			<tr>
+				<td class="title">Bandwidth (Mbyte)</td>
+				<td class="entry"><input type="text" name="bandwidth" /></td>
+			</tr>
+			<tr>
+				<td class="title">Valid From</td>
+				<td class="entry"><input type="text" name="validFrom" /></td>
+			</tr>
+			<tr>
+				<td class="title">Valid To</td>
+				<td class="entry"><input type="text" name="validTo" /></td>
+			</tr>
+			<tr>
+				<td class="title">AgentRef</td>
+				<td class="entry"><input type="text" name="agentRef" /></td>
+			</tr>
+		</table>
+		<div class="text-center">
+			<input type="submit" value="Add" />
+		</div>
+	</form>
+	<p />
+
+Note On Searching:
+<ul>
+	<li>Dates are in the format of YYYY-MM-DD</li>
+	<li>ValidTo is ALWAYS the first day of the next month</li>
+</ul>
+<?php
+}
+
+
+
+
+
+
+function doAdd($userID)
+{
+	global $soap;	
+
+	$info = NULL;
+
+	# Verify data
+	if ($_REQUEST["user_id"] != "") {
+		$info["UserID"] = $_REQUEST["user_id"];
+	} else {
+		displayError("UserID must be specified");
+		return;
+	}
+
+	if ($_REQUEST["bandwidth"] != "") {
+		$info["Bandwidth"] = $_REQUEST["bandwidth"];
+	} else {
+		displayError("Bandwidth must be specified");
+		return;
+	}
+
+	if ($_REQUEST["validFrom"] != "") {
+		$info["ValidFrom"] = $_REQUEST["validFrom"];
+	} else {
+		displayError("ValidFrom must be specified");
+		return;
+	}
+
+	if ($_REQUEST["validTo"] != "") {
+		$info["ValidTo"] = $_REQUEST["validTo"];
+	} else {
+		displayError("ValidTo must be specified");
+		return;
+	}
+
+	# Check optional data
+	if ($_POST["agentRef"] != "") {
+		$userInfo["AgentRef"] = $_POST["agentRef"];
+	}		
+
+	# Create radius user and check for error
+	$res = $soap->createRadiusUserTopup($info);
+	if ($res > 0) {
+		displaySuccess("Added radius topup");
+	} else {
+		displayError("Error creating radius topup: ".strSoapError($res));
+	}
+
+	
+}
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "topups_add_main") {
+	displayForm($_REQUEST['user_id']);
+
+} elseif ($_REQUEST['frmaction'] == "topups_add_final") {
+	doAdd($_REQUEST['user_id']);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radius-user-topup-main.php b/webui/agent-control-panel/radius-user-topup-main.php
new file mode 100644
index 0000000000000000000000000000000000000000..f6b41beac4cc9a73c2ed0be1ea6d4a1c2fd08998
--- /dev/null
+++ b/webui/agent-control-panel/radius-user-topup-main.php
@@ -0,0 +1,171 @@
+<?php
+# Radius user topups
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+# Menu header
+include("../shared-php/menu-header.php");
+# Functions we need
+require_once("../shared-php/miscfuncs.php");
+
+
+
+# Display radius user topups
+function displayTopups($userID,$searchOptions) {
+	global $soap;
+
+
+	$userInfo = $soap->getRadiusUser($userID);
+	if (!is_object($userInfo)) {
+		displayError("getRadiusUser: ".strSoapError($userInfo));
+		return;
+	}
+
+	$userTopups = $soap->getRadiusUserTopups($userID,$searchOptions);
+	if (!is_array($userTopups)) {
+		displayError("getRadiusUserTopups: ".strSoapError($userTopups));
+		return;
+	}
+?>
+	
+	<div class="sectiontitle">Topup Search Results</div>
+	<p />
+
+	<table class="resulttable">
+		<tr>
+			<td class="title">Bandwidth</td>
+			<td class="title">Timestamp</td>
+			<td class="title">Valid From</td>
+			<td class="title">Valid To</td>
+			<td class="title">Agent Ref</td>
+		</tr>
+<?php
+		foreach ($userTopups as $entry) {
+?>
+			<tr>
+				<td class="text-right"><?php echo $entry->Bandwidth; ?></td>
+				<td><?php echo $entry->Timestamp; ?></td>
+				<td><?php echo $entry->ValidFrom; ?></td>
+				<td><?php echo $entry->ValidTo; ?></td>
+				<td><?php echo $entry->AgentRef; ?></td>
+			</tr>
+<?php
+		}
+?>
+	</table>
+<?php
+}
+
+
+
+
+
+
+# Function to display topup search box
+function displaySearchBox($userID) {
+?>
+	<div class="sectiontitle">Topup Search</div>
+	<p />
+
+	<form action="radius-user-topup-main.php" method="post">
+		<div>
+			<input type="hidden" name="user_id" value="<?php echo $userID ?>" />
+			<input type="hidden" name="frmaction" value="topups_final" />
+		</div>
+		<table class="entrytable">
+			<tr>
+				<td class="title">From</td>
+				<td class="entry">
+					<input type="text" name="searchTopupsFrom" value="<?php
+							if (isset($_SESSION['radiusUserTopups_searchFrom'])) {
+								echo $_SESSION['radiusUserTopups_searchFrom'];
+							}
+					?>" />
+				</td>
+			</tr>
+			<tr>
+				<td class="title">To</td>
+				<td class="entry">
+					<input type="text" name="searchTopupsTo" value="<?php
+							if (isset($_SESSION['radiusUserTopups_searchTo'])) {
+								echo $_SESSION['radiusUserTopups_searchTo'];
+							}
+					?>" />
+				</td>
+			</tr>
+			<tr>
+				<td class="title">Order By</td>
+				<td class="entry" colspan="2">
+					<input type="radio" name="searchTopupsOrderBy" value="date" checked="checked" /> Date
+				</td>
+			</tr>
+		</table>
+		<div class="text-center">
+			<input type="submit" />
+		</div>
+	</form>
+
+Note On Searching:
+<ul>
+	<li>Dates are in the format of YYYY-MM-DD</li>
+	<li>Blank search criteria matches last 50 topups</li>
+</ul>
+<?php
+}
+
+
+
+
+
+# Check if we have an action
+if (!isset($_REQUEST['frmaction'])) {
+	# FIXME : redirect
+
+} elseif ($_REQUEST['frmaction'] == "topups_main") {
+	displaySearchBox($_REQUEST['user_id']);
+
+} elseif ($_REQUEST['frmaction'] == "topups_final") {
+	# Process search options
+	if (isset($_REQUEST['searchTopupsFrom'])) {
+		$_SESSION['radiusUserTopups_searchFrom'] = $_REQUEST['searchTopupsFrom'];
+	}
+	if (isset($_REQUEST['searchTopupsTo'])) {
+		$_SESSION['radiusUserTopups_searchTo'] = $_REQUEST['searchTopupsTo'];
+	}
+	if (isset($_REQUEST['searchTopupsOrderBy'])) {
+		$_SESSION['radiusUserTopups_searchOrderBy'] = $_REQUEST['searchTopupsOrderBy'];
+	}
+
+	# Setup search
+	$searchOptions->searchFrom = $_SESSION['radiusUserTopups_searchFrom'];
+	$searchOptions->searchTo = $_SESSION['radiusUserTopups_searchTo'];
+	$searchOptions->searchOrderBy = $_SESSION['radiusUserTopups_searchOrderBy'];
+	displayTopups($_REQUEST['user_id'],$searchOptions);
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+# Footer
+include("include/footer.php");
+
+# vim: ts=4
+?>
diff --git a/webui/agent-control-panel/radiusUsers.php b/webui/agent-control-panel/radiusUsers.php
new file mode 100644
index 0000000000000000000000000000000000000000..b3c2571a859f2202f8f92ba896f18b8cc1f45b12
--- /dev/null
+++ b/webui/agent-control-panel/radiusUsers.php
@@ -0,0 +1,175 @@
+<?php
+# Radius user stuff
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+
+# Menu header
+include("../shared-php/menu-header.php");
+
+# Soap functions
+require_once("soapfuncs.php");
+
+?>
+<a href=".">Home</a><br><br>
+<?php
+
+
+
+
+
+
+
+
+
+
+# Quicklink functions...
+if (!empty($_REQUEST['quicklink']) && $_REQUEST['quicklink'] == "logs") {
+	$username = $_REQUEST['username'];
+	$userInfo = $soap->getRadiusUserByUsername($username);
+
+	if (!$userInfo) {
+?>
+		User info query returned no result.<br><br>
+<?php
+		searchBox();
+		exit;
+	}
+	
+	$_SESSION['radiusUser_searchUsername'] = $userInfo->Username;
+	$userID = $userInfo->ID;
+
+	searchLogsBox();
+
+# Check if we have a user
+} elseif ($_REQUEST['userID'] > 0) {
+	$userID = $_REQUEST['userID'];
+	$userInfo = $soap->getRadiusUser($userID);
+
+?>
+	<a href="radiusUsers.php">Back to radius user search</a><br><br>
+<?php
+	# Check if we have a special action to perform
+	if ($_POST["action"] == "update") {
+		actionUpdate();
+	# Actual remove action
+	} elseif ($_POST["action"] == "remove")  {
+		actionRemove();
+	
+	# Edit screen
+	} elseif ($_REQUEST["screen"] == "edit")  {
+		screenEdit();
+	# Remove screen
+	} elseif ($_REQUEST["screen"] == "remove")  {
+		screenRemove();
+
+
+	# Logs screen
+	} elseif ($_REQUEST["screen"] == "logs")  {
+		# If we have searchLogs set, means we come from the searchLogs screen
+		if ($_REQUEST['searchLogs'] == 1) {
+		} else {
+
+			searchLogsBox();
+		}
+	
+	# Add port lock
+	} elseif ($_REQUEST["screen"] == "addTopup")  {
+		screenAddTopup();
+
+	} elseif ($_POST["action"] == "addTopup")  {
+		actionAddTopup();
+
+
+	# Topups screen
+	} elseif ($_REQUEST["screen"] == "topups")  {
+		# If we have searchTopups set, means we come from the searchTopups screen
+		if ($_REQUEST['searchTopups'] == 1) {
+
+			displayTopups($searchOptions);
+		} else {
+
+			searchTopupsBox();
+		}
+	
+	# Add port lock
+	} elseif ($_POST["action"] == "addLock")  {
+		actionAddPortLock();
+	# Remove port lock
+	} elseif ($_REQUEST["action"] == "removeLock")  {
+		actionRemovePortLock();
+	
+	# Port locks screen
+	} elseif ($_REQUEST["screen"] == "portlocks")  {
+		displayPortLocks();
+	}
+
+
+
+
+
+# We came from our search box
+} elseif ($_REQUEST['search'] == 1) {
+	# Process search options
+	if (isset($_REQUEST['searchUsername'])) {
+		$_SESSION['radiusUser_searchUsername'] = $_REQUEST['searchUsername'];
+	}
+	if (isset($_REQUEST['searchAgentRef'])) {
+		$_SESSION['radiusUser_searchAgentRef'] = $_REQUEST['searchAgentRef'];
+	}
+	if (isset($_REQUEST['searchOrderBy'])) {
+		$_SESSION['radiusUser_searchOrderBy'] = $_REQUEST['searchOrderBy'];
+	}
+
+	# Setup search
+	$searchOptions->searchUsername = $_SESSION['radiusUser_searchUsername'];
+	$searchOptions->searchAgentRef = $_SESSION['radiusUser_searchAgentRef'];
+	$searchOptions->searchOrderBy = $_SESSION['radiusUser_searchOrderBy'];
+
+
+
+	userList($searchOptions);
+
+# Add user screen
+} elseif ($_REQUEST["screen"] == "add") {
+	echo("<a href=\"radiusUsers.php\">Back to radius user search</a><br><br>");
+
+	screenAdd();
+	
+# Add the user
+} elseif ($_POST["action"] == "add") {
+	actionAdd();
+
+# Anything else
+} else {
+	searchBox();
+}
+
+
+# Menu footer
+include("../shared-php/menu-footer.php");
+
+# Footer
+include("include/footer.php");
+?>
diff --git a/webui/radius-control-panel/config.php b/webui/radius-control-panel/config.php
new file mode 100644
index 0000000000000000000000000000000000000000..32d3f35f36857cd6c3fc79795f8325373c8cc019
--- /dev/null
+++ b/webui/radius-control-panel/config.php
@@ -0,0 +1,24 @@
+<?php
+# Config
+#
+# Copyright (c) 2005-2008, 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.
+
+
+# Location of soap server
+$soap_location = "http://localhost:1080";
+
+?>
diff --git a/webui/radius-control-panel/include/.htaccess b/webui/radius-control-panel/include/.htaccess
new file mode 100644
index 0000000000000000000000000000000000000000..d2ca18f15fec0d7c62a85c1c592587442c279e7f
--- /dev/null
+++ b/webui/radius-control-panel/include/.htaccess
@@ -0,0 +1,4 @@
+<Files *>
+	Order Deny,Allow
+	Deny from all
+</Files>
diff --git a/webui/radius-control-panel/include/footer.php b/webui/radius-control-panel/include/footer.php
new file mode 100644
index 0000000000000000000000000000000000000000..1b6c3da27edda3abe3b1eb29555b8639df48757f
--- /dev/null
+++ b/webui/radius-control-panel/include/footer.php
@@ -0,0 +1,29 @@
+<?php
+# Footer of page
+#
+# Copyright (c) 2005-2008, 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.
+
+
+?>
+	<div class="copyright">Copyright (c) 2005-2008, <a href="http://www.allworldit.com" ?>AllWorldIT</a></div>
+	<br />
+
+	</body>
+</html>
+<?php
+	ob_flush();
+?>
diff --git a/webui/radius-control-panel/include/header.php b/webui/radius-control-panel/include/header.php
new file mode 100644
index 0000000000000000000000000000000000000000..e6021aae3b31733fff39518eac481f8b3bfc6697
--- /dev/null
+++ b/webui/radius-control-panel/include/header.php
@@ -0,0 +1,44 @@
+<?php
+# Top part of radius control panel
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+# Grab version
+require_once("include/version.php");
+
+?>
+<html>
+	<title>User Control Panel</title> 
+	<link rel="stylesheet" href="styles.css" type="text/css">
+
+	<body>
+		<div class="pagetitle">User Control Panel</div>	
+<?php
+	if ($auth->loggedIn) {
+?>
+		<div class="smallinfo">Logged in as <?php echo $auth->username ?> (<a href="./?logout=1">Logout</a>).</div>
+<?php
+	} else {
+?>
+		<div class="smallinfo">v<?php echo $VERSION ?></div>
+<?php
+	}
+?>
+		<br>
diff --git a/webui/radius-control-panel/include/pre.php b/webui/radius-control-panel/include/pre.php
new file mode 100644
index 0000000000000000000000000000000000000000..82ac37e87afbb4d494979b496a2f4005b19f994d
--- /dev/null
+++ b/webui/radius-control-panel/include/pre.php
@@ -0,0 +1,61 @@
+<?php
+# Author: Nigel Kukard  <nkukard@lbsd.net>
+# Date: 2007-06-21
+# Desc: This file takes care of authentication for us and gets the soap object
+# License: GPL
+
+
+ob_start();
+
+require_once("auth.php");
+require_once("miscfuncs.php");
+
+# Main authentication object
+$auth = new Auth('Radius');
+
+# Check if we logged in and set SOAP object
+$soap = NULL;
+
+# First of all check if we in maintenance mode
+if (file_exists("../maintmode")) {
+	include("header.php");
+?>
+	<center>System unavailable due to maintenance, sorry for the inconvenience. Please try again in 5 minutes.</center>
+<?php
+	include("include/footer.php");
+	exit;
+}
+
+# If not ... carry on
+$auth->setLoginBoxUsername('Username');
+
+# Check if we logged in
+if (!$auth->loggedIn) {
+	$username = isset($_POST['username']) ? $_POST['username'] : '';
+	$password = isset($_POST['password']) ? $_POST['password'] : '';
+	# If not, check credentials
+	if ($auth->checkLogin($username,$password) != 0) {
+		include("header.php");
+		$auth->displayLogin();
+		include("include/footer.php");
+		exit;
+	}
+} else {
+	# Log client out
+	if (isset($_REQUEST['logout']) && $_REQUEST['logout'] == 1) {
+		$auth->logout("You have been logged out.");
+		require_once('HTTP.php');
+		HTTP::Redirect('.');
+		exit;
+	}
+}
+
+# This can log us out, if so set message
+if (!($soap = $auth->connect())) {
+	$auth->logout("Session not active, please login.");
+	require_once('HTTP.php');
+	HTTP::Redirect('.');
+	exit;
+}
+
+?>
diff --git a/webui/radius-control-panel/include/version.php b/webui/radius-control-panel/include/version.php
new file mode 100644
index 0000000000000000000000000000000000000000..1e1b5a9aeede0ab08503507de2af804066b8c788
--- /dev/null
+++ b/webui/radius-control-panel/include/version.php
@@ -0,0 +1,25 @@
+<?php
+# Versioning for this interface
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+$VERSION = "0.4.0b1";
+
+?>
diff --git a/webui/radius-control-panel/index.php b/webui/radius-control-panel/index.php
new file mode 100644
index 0000000000000000000000000000000000000000..f6139ad12a4d53f47abbe7522d8e96cd1427c896
--- /dev/null
+++ b/webui/radius-control-panel/index.php
@@ -0,0 +1,143 @@
+<?php
+# Main control panel page
+#
+# Copyright (c) 2005-2008, 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.
+
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+
+# NB: We will only end up here if we authenticated!
+
+
+# Display details
+function displayDetails() { 
+	global $soap;
+
+
+	$userDetails = $soap->getRadiusUserDetails();
+	
+	$isDialup = preg_match('/dialup/i',$userDetails->Service);
+	if (!$isDialup) {
+		$topups = $soap->getRadiusUserCurrentTopups();
+		$usage = $soap->getRadiusUserCurrentUsage();
+	}
+
+?>
+	<table class="blockcenter">
+		<tr>
+			<td colspan="2" class="section">Account Information</td>
+		</tr>
+		<tr>
+			<td class="title">Username</td>
+			<td class="value"><?php echo $userDetails->Username ?></td>
+		</tr>
+		<tr>
+			<td class="title">Service</td>
+			<td class="value"><?php echo $userDetails->Service ?></td>
+		</tr>
+<?php
+		# Only display cap for DSL users
+		if (!$isDialup) {
+?>
+			<tr>
+				<td colspan="2" class="section">Usage Info &amp; Topups</td>
+			</tr>
+			<tr>
+				<td class="title">Bandwidth Cap</td>
+				<td class="value"><?php echo $userDetails->UsageCap ?>MB</td>
+			</tr>
+			<tr>
+				<td class="title">Topups</td>
+				<td class="value"><?php echo $topups; ?>MB</td>
+			</tr>
+			<tr>
+				<td class="title">Used This Month</td>
+				<td class="value"><?php echo ($usage >= 0) ? "${usage}MB" : "[data unavailable]"; ?></td>
+			</tr>
+			<tr>
+				<td colspan="2" class="section">Notifications</td>
+			</tr>
+			<form method="post">
+			<tr>
+				<td class="title">Email Address</td>
+				<td class="value">
+					<input type="text" name="notifyMethodEmail" value="<?php echo $userDetails->NotifyMethodEmail ?>"></input>
+					<input type="submit" name="notifyUpdate" value="update">
+				</td>
+			</tr>
+			<tr>
+				<td class="title">Cell Number</td>
+				<td class="value">
+					<input type="text" name="notifyMethodCell" value="<?php echo $userDetails->NotifyMethodCell ?>"></input>
+					<input type="submit" name="notifyUpdate" value="update">
+				</td>
+			</tr>
+			</form>
+<?php
+		}
+?>
+		<tr>
+			<td></td>
+			<td></td>
+		</tr>
+		<tr>
+			<td colspan="2" align="center">
+				<a href="logs.php">Usage Logs</a>
+<?php
+				# Only display cap for DSL users
+				if (!$isDialup && 0) {
+?>
+					| <a href="portlocks.php">Port Locking</a>
+					| <a href="topups.php">Topups</a>
+<?php
+				}
+?>
+			</td>
+		</tr>
+	</table>
+
+	<br><br>
+
+	<font size="-1">
+		Note:
+		<li>Please contact your ISP if you have any problem using this interface.
+	</font>
+<?php
+}
+
+# If this is a post and we're updating then do it
+if (isset($_POST['notifyUpdate']) && $_POST['notifyUpdate'] == "update") {
+	$i->NotifyMethodEmail = $_POST['notifyMethodEmail'];
+	$i->NotifyMethodCell = $_POST['notifyMethodCell'];
+	$res = $soap->updateRadiusUser($i);
+
+	if ($res == 0) {
+		echo "<center>Notification data updated</center>";
+	} else {
+		echo "<center>Error updating notification data, please contact your ISP. (Err: $res)</center>";
+	}
+}
+
+
+displayDetails();
+
+# Footer
+include("include/footer.php");
+?>
diff --git a/webui/radius-control-panel/logs.php b/webui/radius-control-panel/logs.php
new file mode 100644
index 0000000000000000000000000000000000000000..1e8c03707022851701c984c0566c31a71aca3b31
--- /dev/null
+++ b/webui/radius-control-panel/logs.php
@@ -0,0 +1,184 @@
+<?php
+# Radius user logs
+#
+# Copyright (c) 2005-2008, 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.
+
+# pre takes care of authentication and creates soap object we need
+include("include/pre.php");
+# Page header
+include("include/header.php");
+
+# Soap functions
+require_once("soapfuncs.php");
+
+# Radius functions
+require_once("radiuscodes.php");
+
+
+
+# NB: We will only end up here if we authenticated!
+
+
+# Display settings
+function displayLogs() {
+	global $soap;
+
+
+	# Check if we should search
+	if (isset($_POST['searchFrom']) || isset($_POST['searchFrom'])) {
+
+		if (isset($_POST['searchFrom'])) {
+			$search['searchFrom'] = isset($_POST['searchFrom']) ? $_POST['searchFrom'] : '';
+			$_SESSION['radiusLogs_searchFrom'] = $search['searchFrom'];
+		}
+		if (isset($_POST['searchTo'])) {
+			$search['searchTo'] = isset($_POST['searchTo']) ? $_POST['searchTo'] : '';
+			$_SESSION['radiusLogs_searchTo'] = $search['searchTo'];
+		}
+
+		$results = $soap->getRadiusUserLogs($search);
+	}
+	
+	$userDetails = $soap->getRadiusUserDetails();
+	$isDialup = preg_match('/dialup/i',$userDetails->Service);
+?>
+
+	<table class="blockcenter" width="750">
+		<tr>
+			<td colspan="4" class="title">
+				<form method="POST">
+					<p class="middle center">
+					Display logs between
+					<input type="text" name="searchFrom" value="<?php 
+							if (isset($_SESSION['radiusLogs_searchFrom'])) {
+								echo $_SESSION['radiusLogs_searchFrom'];
+							}
+					?>" size="11"> 
+					and 
+					<input type="text" name="searchTo" value="<?php 
+							if (isset($_SESSION['radiusLogs_searchTo'])) {
+								echo $_SESSION['radiusLogs_searchTo'];
+							}
+					?>" size="11">
+
+					<input type="submit" value="search">
+					</p>
+				</form>
+			</td>
+			<td colspan="2" class="section">Connect Speed</td>
+			<td colspan="2" class="section">Traffic Usage<br> (Mbyte)</td>
+		</tr>
+		<tr>
+			<td class="section">Timestamp</td>
+			<td class="section">Duration</td>
+<?php
+			if (!$isDialup) {
+?>
+				<td class="section">Port</td>
+<?php
+			} else {
+?>
+				<td class="section">Caller ID</td>
+<?php
+			}
+?>
+			<td class="section">Term Reason</td>
+			<td class="section">Receive</td>
+			<td class="section">Transmit</td>
+			<td class="section">Upload</td>
+			<td class="section">Download</td>
+		</tr>
+<?php
+		if (isset($results) && is_array($results)) {
+			$total = 0;
+			$totalUpload = 0;
+			$totalDownload = 0;
+
+			# Loop with log entries
+			foreach ($results as $item) {
+				$inputMBytes = $item->AcctInputOctets > 0 ? $item->AcctInputOctets / 1024 / 1024 : 0;
+				$outputMBytes = $item->AcctOutputOctets > 0 ? $item->AcctOutputOctets / 1024 / 1024 : 0;
+				$inputMBytes += $item->AcctInputGigawords * 4096;
+				$outputMBytes += $item->AcctOutputGigawords * 4096;
+?>
+				<tr>
+					<td class="desc"><?php echo $item->Timestamp; ?>
+					<td class="desc"><?php echo $item->AcctSessionTime; ?></td>
+<?php
+					if (!$isDialup) {
+?>
+						<td class="desc"><?php echo $item->NASPort; ?></td>
+<?php
+					} else {
+?>
+						<td class="desc"><?php echo $item->CallingStationID; ?></td>
+<?php
+					}
+?>
+					<td class="center desc"><?php echo strRadiusTermCode($item->ConnectTermReason); ?></td>
+					<td class="center desc"><?php echo $item->NASTransmitRate; ?></td>
+					<td class="center desc"><?php echo $item->NASReceiveRate; ?></td>
+					<td class="right desc"><?php echo sprintf('%.2f',$inputMBytes); ?></td>
+					<td class="right desc"><?php echo sprintf('%.2f',$outputMBytes); ?></td>
+				</tr>
+<?php
+				$totalUpload += $inputMBytes;
+				$totalDownload += $outputMBytes;
+			}
+
+			$total = $totalUpload + $totalDownload;
+?>
+		<tr>
+			<td colspan="6" class="right">Sub Total:</td>
+			<td class="right desc"><?php echo sprintf('%.2f',$totalUpload); ?></td>
+			<td class="right desc"><?php echo sprintf('%.2f',$totalDownload); ?></td>
+		</tr>
+		<tr>
+			<td colspan="6" class="right">Total:</td>
+			<td colspan="2" class="center desc"><?php echo sprintf('%.2f',$total); ?></td>
+		</tr>
+<?php
+		} else {
+?>
+		<tr>
+			<td colspan="8" class="info">Please specify dates above in YYYY-MM-DD format and click "search".</td>
+		</tr>
+<?php
+		}
+?>
+	</table>
+<?php
+
+}
+
+
+
+?>
+	<a href=".">Back</a><br>
+<?php
+
+
+displayLogs();
+
+?>
+	<a href=".">Back</a><br><br>
+<?php
+
+
+# Footer
+include("include/footer.php");
+?>
diff --git a/webui/radius-control-panel/styles.css b/webui/radius-control-panel/styles.css
new file mode 100644
index 0000000000000000000000000000000000000000..8356b1f8bbc0f482a47f088553d3fbf8792b75d2
--- /dev/null
+++ b/webui/radius-control-panel/styles.css
@@ -0,0 +1,179 @@
+td.section {
+	border-style: solid;
+	border-width: 2px;
+
+	color: #ffffff;
+
+	background-color: #000066;
+ 
+	text-align: center;
+}
+
+
+td.top {
+	vertical-align: top;
+}
+
+
+td.middle {
+	vertical-align: middle;
+}
+
+
+td.right {
+	text-align: right;
+}
+
+
+td.title,div.title {
+	border-style: solid;
+	border-width: 1px;
+
+	background-color: #ffffdd; 
+}
+
+
+div.pagetitle {
+	border-style: solid;
+	border-width: 1px; 
+	border-color: #000000; 
+
+	font-size: larger;
+
+	text-align: center;
+}
+
+
+div.smallinfo {
+	font-size: 10px;
+
+	text-align: center;
+}
+
+
+div.copyright {
+	border-style: solid;
+	border-width: 1px;
+
+	font-size: 10px;
+
+	text-align: center;
+}
+
+
+td.pinfo {
+	border-style: dotted;
+	border-width: 1px;
+
+	font-size: smaller;
+}
+
+
+td.info {
+	border-style: dotted;
+	border-width: 1px;
+
+	font-size: smaller;
+
+	text-align: center;
+}
+
+
+td.value,div.value {
+}
+
+
+td.desc,div.desc {
+	background-color: #eeeeee; 
+}
+
+
+.blockcenter {
+	margin-left: auto;
+	margin-right: auto;
+}
+
+
+.center {
+	text-align: center;
+}
+
+.important {
+	font-style: italic;
+}
+
+body { font-family: verdana; text-align: center; }
+
+a, a:visited {
+	text-decoration: none;
+	color: #004D91;
+}
+
+a:hover {
+	text-decoration: underline;
+}
+
+
+.loginform table {
+	width: 400;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+.loginformt td {
+	text-align: center;
+}
+
+.loginforms {
+	text-align: center;
+}
+
+.loginformud, .loginformpd {
+	text-align: right;
+}
+
+.mtlisttable {
+	border: 1px solid #000000;
+	font-size: 12px;
+	margin-left: auto; margin-right: auto;
+}
+
+.mtlisttabletitle {
+	text-align: center;
+	font-size: 12px;
+	font-weight: bold;
+}
+
+.mtlisttablehead {
+	
+}
+
+.mtlisttabledata {
+	
+}
+
+mtsearchtable {
+	border: 1px solid #000;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+mtsearchtabletitle {
+	font-weight: bold;
+}
+
+mtsearchtablehead {
+
+}
+
+mtsearchtabledata {
+
+}
+
+mtsearchtableorder {
+
+}
+
+mtsearchtablesubmit {
+	font-weight: bold;
+}
\ No newline at end of file
diff --git a/webui/shared-php/auth.php b/webui/shared-php/auth.php
new file mode 100644
index 0000000000000000000000000000000000000000..b2f041247dad3af3a9bb63176ff0663c4f365548
--- /dev/null
+++ b/webui/shared-php/auth.php
@@ -0,0 +1,171 @@
+<?php
+# Authentication class
+#
+# Copyright (c) 2005-2008, 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.
+
+
+$soap_location = "http://localhost:1080";
+
+
+# Authentication class
+class Auth {
+	var $loggedIn = false;
+	var $username = "";
+	var $key = "";
+	var $section = "";
+
+	var $loginBoxUsername = "Username";
+	var $loginBoxMsg = "";
+
+
+	# Clean session
+	function _unsetSession() {
+		$this->loggedIn = $_SESSION['loggedIn'] = false;
+		$this->username = $_SESSION['username'] = "";
+		$this->key = $_SESSION['key'] = "";
+		$this->section = $_SESSION['section'] = "";
+	}
+
+
+	# Populate session
+	function _setSession($username,$key) {
+		$this->loggedIn = $_SESSION['loggedIn'] = true;
+		$this->username = $_SESSION['username'] = $username;
+		$this->key = $_SESSION['key'] = $key;
+		$this->section = $_SESSION['section'] = $this->section;
+	}
+
+
+	# Load object data from session
+	function _loadSession() {
+		$this->loggedIn = $_SESSION['loggedIn'];
+		$this->username = $_SESSION['username'];
+		$this->key = $_SESSION['key'];
+		$this->section = $_SESSION['section'];
+	} 
+
+
+	# Create object
+	# Args: <section to authenticate to>
+	function Auth($section) {
+		# Make sure sessions are active
+		session_start();
+
+		# Check if we logged in, if we are pull in data
+		if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {
+			$this->_loadSession();
+			if ($this->section != $section) {
+				$this->logout("Login section mismatch!");
+			}
+		} else {
+			# Set section
+			$this->section = $section;
+		}
+	}
+
+
+	# Set login box username
+	function setLoginBoxUsername($msg) {
+		$this->loginBoxUsername = $msg;
+	}
+
+
+	# Login
+	function _login($username,$password) {
+		global $soap_location;
+
+		$this->_setSession("joesoap","mykey");
+
+		return 0;
+
+	}
+
+
+	# Logout
+	function logout($msg) {
+		if ($msg != "") {
+			$_SESSION['logoutMsg'] = $msg;
+		}
+		$this->_unsetSession();
+	}
+
+
+	# Display login screen
+	function displayLogin() {
+?>
+		<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
+<?php
+			displayError($this->loginBoxMsg);
+?>
+			<table class="block-center">
+				<tr>
+					<td><?php echo $this->loginBoxUsername ?></td>
+					<td><input type="text" name="username" /></td>
+				</tr>
+				<tr>
+					<td>Password</td>
+					<td><input type="password" name="password" /></td>
+				</tr>
+			</table>
+			<div class="text-center">
+				<input type="submit" value="Login" />
+			</div>
+		</form>
+		<p />
+<?php
+	}
+
+
+	# Function to check login details
+	function checkLogin($username,$password) {
+		$res = -1;
+
+		# Set res to 0 if we logged in
+		if ($username != "" && $password != "" && !$this->loggedIn) {
+			switch ($this->_login($username,$password)) {
+				case 0:
+					$res = 0;
+					break;
+				case -1:
+				case -3:
+					$this->loginBoxMsg = $this->loginBoxUsername. " or Password invalid.";
+					break;
+				case -2:
+					$this->loginBoxMsg = "Cannot connect to SOAP server, please contact your ISP.";
+					break;
+				case -4:
+				default:
+					$this->loginBoxMsg = "Unknown error contacting SOAP server, please contact your ISP.";
+					break;
+			}
+		} else {
+			# Check if we have a logout message
+			if (isset($_SESSION['logoutMsg'])) {
+				$this->loginBoxMsg = $_SESSION['logoutMsg'];
+				unset($_SESSION['logoutMsg']);
+			} else {
+				$this->loginBoxMsg = "Unauthorized Access Prohibited";
+			}
+		}
+
+		return $res;
+	}
+
+}
+
+
+?>
diff --git a/webui/shared-php/menu-footer.php b/webui/shared-php/menu-footer.php
new file mode 100644
index 0000000000000000000000000000000000000000..c0c2a8dd12a0dc6aaee8fb8243752edf88ee525a
--- /dev/null
+++ b/webui/shared-php/menu-footer.php
@@ -0,0 +1,23 @@
+<?php
+# Menu footer
+#
+# Copyright (c) 2005-2008, 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.
+
+?>
+		</td>
+	</tr>
+</table>
diff --git a/webui/shared-php/menu-header.php b/webui/shared-php/menu-header.php
new file mode 100644
index 0000000000000000000000000000000000000000..37327efeda915fc923af8700d9fcc85f4420b65b
--- /dev/null
+++ b/webui/shared-php/menu-header.php
@@ -0,0 +1,43 @@
+<?php
+# Menu header
+#
+# Copyright (c) 2005-2008, 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.
+
+
+?>
+
+<table class="maintable">
+	<tr>
+		<td class="menubar">
+			<table class="menu"><tr><td>
+				<ul>
+					<li class="menutitle">Home</li>
+					<li class="menuitem"><a href=".">Summary</a></li>
+				</ul>
+			</td></tr></table>
+			<table class="menu"><tr><td>
+				<ul>
+					<li class="menutitle">Radius</li>
+					<li class="menuitem"><a href="radius-user-add.php">Add User</a></li>
+					<li class="menuitem"><a href="radius-user-main.php">Search User</a></li>
+				</ul>
+			</td></tr></table>
+			<br />
+		</td>
+		<td class="content">
+			<br />
+
diff --git a/webui/shared-php/miscfuncs.php b/webui/shared-php/miscfuncs.php
new file mode 100644
index 0000000000000000000000000000000000000000..f61ae57334fdfd660b2124ff8b7b812e5461364b
--- /dev/null
+++ b/webui/shared-php/miscfuncs.php
@@ -0,0 +1,41 @@
+<?php
+# Misc functions we can use
+#
+# Copyright (c) 2005-2008, 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.
+
+
+# Display error banner
+function displayError($msg)
+{
+?>
+	<div class="error"><?php echo $msg; ?></div>
+<?php
+}
+
+
+# Display success banner
+function displaySuccess($msg)
+{
+?>
+	<div class="success"><?php echo $msg; ?></div>
+<?php
+}
+
+
+
+
+?>
diff --git a/webui/shared-php/radiuscodes.php b/webui/shared-php/radiuscodes.php
new file mode 100644
index 0000000000000000000000000000000000000000..a9b852745c169050e8216019cf7f11726f8e5e2b
--- /dev/null
+++ b/webui/shared-php/radiuscodes.php
@@ -0,0 +1,64 @@
+<?php
+# Radius term code mappings
+#
+# Copyright (c) 2005-2008, 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.
+
+
+
+
+# Return string for radius term code
+function strRadiusTermCode($errCode) {
+
+	if (is_numeric($errCode)) {
+
+		switch ($errCode) {
+			case 0:
+				return "Still logged in";
+			case 45: # Unknown
+			case 46: # Unknown
+			case 63: # Unknown
+			case 1:
+				return "User request";
+			case 2:
+			case 816: # TCP connection reset? unknown
+				return "Carrier loss";
+			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";
+			default:
+				return "Unkown";
+		}
+
+	} else {
+		return "Unknown";
+	}
+
+}
+
+
+?> 
diff --git a/webui/shared-php/soapfuncs.php b/webui/shared-php/soapfuncs.php
new file mode 100644
index 0000000000000000000000000000000000000000..6728f50c19242c14b7603b6b723b2cd4b246febf
--- /dev/null
+++ b/webui/shared-php/soapfuncs.php
@@ -0,0 +1,67 @@
+<?php
+# Misc funcs we use for SOAP stuff
+#
+# Copyright (c) 2005-2008, 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.
+
+
+# Function to return a stringified soap error
+function strSoapError($errCode) {
+
+	if (is_numeric($errCode)) {
+
+		if ($errCode == -1) {
+			return "Backend returned unknown error!";
+
+		} elseif ($errCode == -2) {
+			return "Backend database error!";
+
+		} elseif ($errCode == -3) {
+			return "Record already exists!";
+
+		} elseif ($errCode == -4) {
+			return "Parameter(s) invalid!";
+
+		} elseif ($errCode == -5) {
+			return "Not allowed!";
+
+		} elseif ($errCode == -6) {
+			return "Backend system error!";
+
+		} elseif ($errCode == -101) {
+			return "Incorrect use of SOAP function!";
+
+		} elseif ($errCode == -102) {
+			return "Not authorized to access specified record!";
+
+		} elseif ($errCode == -103) {
+			return "Not authorized to access SOAP function!";
+
+		} elseif ($errCode == -104) {
+			return "SOAP API error!";
+
+		} else {
+			return "Unknown error code $errCode, please contact your ISP.";
+		}
+
+	} else {
+		return "Unknown return value!";
+	}
+
+}
+
+
+?> 
diff --git a/webui/static/js.getRandomPass b/webui/static/js.getRandomPass
new file mode 100644
index 0000000000000000000000000000000000000000..7209e84876cfe84c5c713d8247d070fff0d35f27
--- /dev/null
+++ b/webui/static/js.getRandomPass
@@ -0,0 +1,11 @@
+/* Generate a random password */
+function getRandomPass(len) {
+	var keylist="abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
+	var ret=''
+
+
+	for (i = 0; i < len; i++)
+		ret += keylist.charAt( Math.floor(Math.random() * keylist.length) )
+
+	return ret
+}
diff --git a/webui/static/menu.css b/webui/static/menu.css
new file mode 100644
index 0000000000000000000000000000000000000000..4f6636734a9e3debc9eb035e83e7022fac96e394
--- /dev/null
+++ b/webui/static/menu.css
@@ -0,0 +1,61 @@
+/*
+ * Header of page
+ *
+ * Copyright (c) 2005-2008, 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.
+ */
+
+.menubar {
+	width: 100px;
+	vertical-align: top;
+}
+
+
+.menu {
+	width: 100%;
+	border: 1px solid black;
+	margin-top: 5px;
+}
+
+
+.menu ul {
+	padding: 0px;
+	margin: 0px;
+	list-style-type: none;
+}
+
+.menu li {
+	text-align: center;
+}
+
+.menutitle {
+	background-color: #004D91;
+	color: #ffffff;
+	font-weight: bolder;
+	text-align: center;
+}
+	
+.menu a {
+	background-color: #ffffdd; 
+	display: block;
+	text-decoration: none;
+}
+
+.menu a:hover {
+	background-color: #eeeeee; 
+}
+
+
diff --git a/webui/static/styles.css b/webui/static/styles.css
new file mode 100644
index 0000000000000000000000000000000000000000..6e20544a6f4f9b5138cadb07b41e026ec333663d
--- /dev/null
+++ b/webui/static/styles.css
@@ -0,0 +1,178 @@
+
+/* new */
+
+/* Main page title */
+div.pagetitle {
+	border-style: solid;
+	border-width: 1px; 
+	border-color: #000000; 
+
+	font-size: larger;
+	font-weight: bolder;
+
+	color: #ffffff;
+	background-color: #004d91;
+
+	text-align: center;
+}
+
+/* Main page table, splits off the menu and content */
+.maintable {
+	width: 100%;
+}
+
+
+/* Content block */
+.content {
+	padding-left: 10px;
+	padding-right: 10px;
+	vertical-align: top;
+}
+
+/* Content block title */
+.sectiontitle {
+	width: 50%;
+	border: 1px solid black;
+	text-align: center;
+	background-color: #eeeeee;
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+/* Generic result table */
+.resulttable {
+	margin-left: auto;
+	margin-right: auto;
+}
+/* result table item title */
+.resulttable td.title {
+	border: 1px solid black;
+	padding-left: 5px;
+	padding-right: 5px;
+	background-color: #004d91;
+	color: #ffffff;
+	text-align: center;
+}
+/* result table item title2 */
+.resulttable td.title2 {
+	border: 1px solid black;
+	padding-left: 5px;
+	padding-right: 5px;
+	background-color: #eeeeee;
+}
+
+
+/* Generic entry table */
+.entrytable {
+	margin-left: auto;
+	margin-right: auto;
+}
+/* entry table item title */
+.entrytable td.title {
+	border: 1px solid black;
+	padding-left: 5px;
+	padding-right: 5px;
+	background-color: #004d91;
+	color: #ffffff;
+}
+/* entry table item title2 */
+.entrytable td.title2 {
+	border: 1px solid black;
+	padding-left: 5px;
+	padding-right: 5px;
+}
+/* entry table old item */
+.entrytable td.value {
+	padding-left: 5px;
+	padding-right: 5px;
+	background-color: #ffffdd; 
+}
+/* entry table old item */
+.entrytable td.oldvalue {
+	padding-left: 5px;
+	padding-right: 5px;
+	background-color: #eeeeee;
+}
+
+
+/* Error message */
+.error {
+	width: 50%;
+	border: 1px solid black;
+	text-align: center;
+	background-color: #aa0000;
+	color: #ffffff;
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+
+/* Success message */
+.success {
+	width: 50%;
+	border: 1px solid black;
+	text-align: center;
+	background-color: #009900;
+	color: #ffffff;
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+/* Text alignment */
+.text-center {
+	text-align: center;
+}
+
+.text-right {
+	text-align: right;
+}
+
+.text-left {
+	text-align: left;
+}
+
+/* Block alignment */
+.block-center {
+	margin-left: auto;
+	margin-right: auto;
+}
+
+
+
+
+
+
+
+
+
+/* Old */
+
+div.smallinfo {
+	font-size: 10px;
+
+	text-align: center;
+}
+
+
+div.copyright {
+	border-style: solid;
+	border-width: 1px;
+
+	font-size: 10px;
+
+	text-align: center;
+}
+
+
+a, a:visited {
+	text-decoration: none;
+	color: black;
+}
+
+a:hover {
+	text-decoration: underline;
+}
+
diff --git a/webui/static/valid-css2.png b/webui/static/valid-css2.png
new file mode 100644
index 0000000000000000000000000000000000000000..c04dbab5769fcc634b40de5422b11bbdb9121de1
Binary files /dev/null and b/webui/static/valid-css2.png differ
diff --git a/webui/static/valid-xhtml10.png b/webui/static/valid-xhtml10.png
new file mode 100644
index 0000000000000000000000000000000000000000..b81de9160bbaa1aaff62924d217b523edbb6f53d
Binary files /dev/null and b/webui/static/valid-xhtml10.png differ