From 1c9534385e59c75567eabe940d1456f3f6c870a8 Mon Sep 17 00:00:00 2001
From: Robert Anderson <randerson@lbsd.net>
Date: Tue, 17 Mar 2009 11:07:23 +0000
Subject: [PATCH] * Copied in cluebringer webui

---
 webui/accesscontrol-add.php                |  163 +++
 webui/accesscontrol-change.php             |  221 ++++
 webui/accesscontrol-delete.php             |  114 ++
 webui/accesscontrol-main.php               |  125 ++
 webui/accounting-add.php                   |  238 ++++
 webui/accounting-change.php                |  311 +++++
 webui/accounting-delete.php                |  148 +++
 webui/accounting-main.php                  |  144 +++
 webui/amavis-add.php                       | 1059 +++++++++++++++++
 webui/amavis-change.php                    | 1246 ++++++++++++++++++++
 webui/amavis-delete.php                    |  114 ++
 webui/amavis-main.php                      |  119 ++
 webui/checkhelo-add.php                    |  331 ++++++
 webui/checkhelo-blacklist-add.php          |  112 ++
 webui/checkhelo-blacklist-change.php       |  168 +++
 webui/checkhelo-blacklist-delete.php       |  113 ++
 webui/checkhelo-blacklist-main.php         |  112 ++
 webui/checkhelo-change.php                 |  481 ++++++++
 webui/checkhelo-delete.php                 |  114 ++
 webui/checkhelo-main.php                   |  119 ++
 webui/checkhelo-whitelist-add.php          |  117 ++
 webui/checkhelo-whitelist-change.php       |  173 +++
 webui/checkhelo-whitelist-delete.php       |  114 ++
 webui/checkhelo-whitelist-main.php         |  112 ++
 webui/checkspf-add.php                     |  214 ++++
 webui/checkspf-change.php                  |  306 +++++
 webui/checkspf-delete.php                  |  113 ++
 webui/checkspf-main.php                    |  119 ++
 webui/greylisting-add.php                  |  387 ++++++
 webui/greylisting-change.php               |  632 ++++++++++
 webui/greylisting-delete.php               |  114 ++
 webui/greylisting-main.php                 |  129 ++
 webui/greylisting-whitelist-add.php        |  117 ++
 webui/greylisting-whitelist-change.php     |  174 +++
 webui/greylisting-whitelist-delete.php     |  114 ++
 webui/greylisting-whitelist-main.php       |  110 ++
 webui/images/bg.jpg                        |  Bin 0 -> 437 bytes
 webui/images/bullet.jpg                    |  Bin 0 -> 631 bytes
 webui/images/help.gif                      |  Bin 0 -> 302 bytes
 webui/images/menuleft.gif                  |  Bin 0 -> 640 bytes
 webui/images/menuright.gif                 |  Bin 0 -> 1398 bytes
 webui/images/specs_bottom.jpg              |  Bin 0 -> 871 bytes
 webui/images/strips_onside.jpg             |  Bin 0 -> 392 bytes
 webui/images/top2.jpg                      |  Bin 0 -> 2114 bytes
 webui/images/valid-css2.png                |  Bin 0 -> 1588 bytes
 webui/images/valid-xhtml10.png             |  Bin 0 -> 1882 bytes
 webui/images/wcag1AAA.png                  |  Bin 0 -> 1598 bytes
 webui/includes/config.php                  |   24 +
 webui/includes/db.php                      |   51 +
 webui/includes/footer.php                  |   34 +
 webui/includes/header.php                  |  145 +++
 webui/includes/tooltipdata.php             |   81 ++
 webui/includes/tooltips.php                |   30 +
 webui/index.php                            |  145 +++
 webui/policy-add.php                       |  128 ++
 webui/policy-change.php                    |  166 +++
 webui/policy-delete.php                    |  137 +++
 webui/policy-group-add.php                 |  104 ++
 webui/policy-group-change.php              |  146 +++
 webui/policy-group-delete.php              |  136 +++
 webui/policy-group-main.php                |  101 ++
 webui/policy-group-member-add.php          |  110 ++
 webui/policy-group-member-change.php       |  160 +++
 webui/policy-group-member-delete.php       |  115 ++
 webui/policy-group-member-main.php         |  124 ++
 webui/policy-main.php                      |  111 ++
 webui/policy-member-add.php                |  132 +++
 webui/policy-member-change.php             |  181 +++
 webui/policy-member-delete.php             |  116 ++
 webui/policy-member-main.php               |  126 ++
 webui/postfix-aliases-add.php              |  135 +++
 webui/postfix-aliases-change.php           |  156 +++
 webui/postfix-aliases-delete.php           |  114 ++
 webui/postfix-aliases-main.php             |  100 ++
 webui/postfix-distgroups-add.php           |  131 ++
 webui/postfix-distgroups-change.php        |  151 +++
 webui/postfix-distgroups-delete.php        |  135 +++
 webui/postfix-distgroups-main.php          |  101 ++
 webui/postfix-distgroups-member-add.php    |  102 ++
 webui/postfix-distgroups-member-change.php |  147 +++
 webui/postfix-distgroups-member-delete.php |  116 ++
 webui/postfix-distgroups-member-main.php   |  131 ++
 webui/postfix-mailboxes-add.php            |  165 +++
 webui/postfix-mailboxes-change.php         |  216 ++++
 webui/postfix-mailboxes-delete.php         |  159 +++
 webui/postfix-mailboxes-main.php           |  101 ++
 webui/postfix-transports-add.php           |  141 +++
 webui/postfix-transports-change.php        |  186 +++
 webui/postfix-transports-delete.php        |  114 ++
 webui/postfix-transports-main.php          |  100 ++
 webui/quotas-add.php                       |  220 ++++
 webui/quotas-change.php                    |  279 +++++
 webui/quotas-delete.php                    |  206 ++++
 webui/quotas-limits-add.php                |  130 ++
 webui/quotas-limits-change.php             |  180 +++
 webui/quotas-limits-delete.php             |  116 ++
 webui/quotas-limits-main.php               |  125 ++
 webui/quotas-main.php                      |  134 +++
 webui/stylesheet.css                       |  247 ++++
 webui/tooltips/BubbleTooltips.js           |   95 ++
 webui/tooltips/bt.css                      |   19 +
 webui/tooltips/bt.gif                      |  Bin 0 -> 1586 bytes
 102 files changed, 15652 insertions(+)
 create mode 100644 webui/accesscontrol-add.php
 create mode 100644 webui/accesscontrol-change.php
 create mode 100644 webui/accesscontrol-delete.php
 create mode 100644 webui/accesscontrol-main.php
 create mode 100644 webui/accounting-add.php
 create mode 100644 webui/accounting-change.php
 create mode 100644 webui/accounting-delete.php
 create mode 100644 webui/accounting-main.php
 create mode 100644 webui/amavis-add.php
 create mode 100644 webui/amavis-change.php
 create mode 100644 webui/amavis-delete.php
 create mode 100644 webui/amavis-main.php
 create mode 100644 webui/checkhelo-add.php
 create mode 100644 webui/checkhelo-blacklist-add.php
 create mode 100644 webui/checkhelo-blacklist-change.php
 create mode 100644 webui/checkhelo-blacklist-delete.php
 create mode 100644 webui/checkhelo-blacklist-main.php
 create mode 100644 webui/checkhelo-change.php
 create mode 100644 webui/checkhelo-delete.php
 create mode 100644 webui/checkhelo-main.php
 create mode 100644 webui/checkhelo-whitelist-add.php
 create mode 100644 webui/checkhelo-whitelist-change.php
 create mode 100644 webui/checkhelo-whitelist-delete.php
 create mode 100644 webui/checkhelo-whitelist-main.php
 create mode 100644 webui/checkspf-add.php
 create mode 100644 webui/checkspf-change.php
 create mode 100644 webui/checkspf-delete.php
 create mode 100644 webui/checkspf-main.php
 create mode 100644 webui/greylisting-add.php
 create mode 100644 webui/greylisting-change.php
 create mode 100644 webui/greylisting-delete.php
 create mode 100644 webui/greylisting-main.php
 create mode 100644 webui/greylisting-whitelist-add.php
 create mode 100644 webui/greylisting-whitelist-change.php
 create mode 100644 webui/greylisting-whitelist-delete.php
 create mode 100644 webui/greylisting-whitelist-main.php
 create mode 100644 webui/images/bg.jpg
 create mode 100644 webui/images/bullet.jpg
 create mode 100644 webui/images/help.gif
 create mode 100644 webui/images/menuleft.gif
 create mode 100644 webui/images/menuright.gif
 create mode 100644 webui/images/specs_bottom.jpg
 create mode 100644 webui/images/strips_onside.jpg
 create mode 100644 webui/images/top2.jpg
 create mode 100644 webui/images/valid-css2.png
 create mode 100644 webui/images/valid-xhtml10.png
 create mode 100644 webui/images/wcag1AAA.png
 create mode 100644 webui/includes/config.php
 create mode 100644 webui/includes/db.php
 create mode 100644 webui/includes/footer.php
 create mode 100644 webui/includes/header.php
 create mode 100644 webui/includes/tooltipdata.php
 create mode 100644 webui/includes/tooltips.php
 create mode 100644 webui/index.php
 create mode 100644 webui/policy-add.php
 create mode 100644 webui/policy-change.php
 create mode 100644 webui/policy-delete.php
 create mode 100644 webui/policy-group-add.php
 create mode 100644 webui/policy-group-change.php
 create mode 100644 webui/policy-group-delete.php
 create mode 100644 webui/policy-group-main.php
 create mode 100644 webui/policy-group-member-add.php
 create mode 100644 webui/policy-group-member-change.php
 create mode 100644 webui/policy-group-member-delete.php
 create mode 100644 webui/policy-group-member-main.php
 create mode 100644 webui/policy-main.php
 create mode 100644 webui/policy-member-add.php
 create mode 100644 webui/policy-member-change.php
 create mode 100644 webui/policy-member-delete.php
 create mode 100644 webui/policy-member-main.php
 create mode 100644 webui/postfix-aliases-add.php
 create mode 100644 webui/postfix-aliases-change.php
 create mode 100644 webui/postfix-aliases-delete.php
 create mode 100644 webui/postfix-aliases-main.php
 create mode 100644 webui/postfix-distgroups-add.php
 create mode 100644 webui/postfix-distgroups-change.php
 create mode 100644 webui/postfix-distgroups-delete.php
 create mode 100644 webui/postfix-distgroups-main.php
 create mode 100644 webui/postfix-distgroups-member-add.php
 create mode 100644 webui/postfix-distgroups-member-change.php
 create mode 100644 webui/postfix-distgroups-member-delete.php
 create mode 100644 webui/postfix-distgroups-member-main.php
 create mode 100644 webui/postfix-mailboxes-add.php
 create mode 100644 webui/postfix-mailboxes-change.php
 create mode 100644 webui/postfix-mailboxes-delete.php
 create mode 100644 webui/postfix-mailboxes-main.php
 create mode 100644 webui/postfix-transports-add.php
 create mode 100644 webui/postfix-transports-change.php
 create mode 100644 webui/postfix-transports-delete.php
 create mode 100644 webui/postfix-transports-main.php
 create mode 100644 webui/quotas-add.php
 create mode 100644 webui/quotas-change.php
 create mode 100644 webui/quotas-delete.php
 create mode 100644 webui/quotas-limits-add.php
 create mode 100644 webui/quotas-limits-change.php
 create mode 100644 webui/quotas-limits-delete.php
 create mode 100644 webui/quotas-limits-main.php
 create mode 100644 webui/quotas-main.php
 create mode 100644 webui/stylesheet.css
 create mode 100644 webui/tooltips/BubbleTooltips.js
 create mode 100644 webui/tooltips/bt.css
 create mode 100644 webui/tooltips/bt.gif

diff --git a/webui/accesscontrol-add.php b/webui/accesscontrol-add.php
new file mode 100644
index 00000000..7a0d91e9
--- /dev/null
+++ b/webui/accesscontrol-add.php
@@ -0,0 +1,163 @@
+<?php
+# Module: AccessControl add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to access cntrl" => "accesscontrol-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add Access Control</p>
+
+	<form method="post" action="accesscontrol-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="accesscontrol_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Link to policy</td>
+				<td>
+					<select name="accesscontrol_policyid">
+<?php
+						$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+						while ($row = $res->fetchObject()) {
+?>
+							<option value="<?php echo $row->id ?>"><?php echo $row->name ?></option>
+<?php
+						}
+						$res->closeCursor();
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Verdict
+					<?php tooltip('accesscontrol_verdict'); ?>
+				</td>
+				<td>
+					<select name="accesscontrol_verdict">
+						<option value="HOLD">Hold</option>
+						<option value="REJECT" selected="selected">Reject</option>
+						<option value="DISCARD">Discard (drop)</option>
+						<option value="FILTER">Filter</option>
+						<option value="REDIRECT">Redirect</option>
+						<option value="OK">Ok</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Data
+					<?php tooltip('accesscontrol_data'); ?>
+				</td>
+				<td><input type="text" name="accesscontrol_data" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="accesscontrol_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Access Control Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['accesscontrol_policyid'])) {
+?>
+		<div class="warning">Policy ID cannot be empty</div>
+<?php
+
+	# Check name
+	} elseif (empty($_POST['accesscontrol_name'])) {
+?>
+		<div class="warning">Name cannot be empty</div>
+<?php
+
+	# Check verdict
+	} elseif (empty($_POST['accesscontrol_verdict'])) {
+?>
+		<div class="warning">Verdict cannot be empty</div>
+<?php
+
+	} else {
+		$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}access_control (PolicyID,Name,Verdict,Data,Comment,Disabled) VALUES (?,?,?,?,?,1)");
+		
+		$res = $stmt->execute(array(
+			$_POST['accesscontrol_policyid'],
+			$_POST['accesscontrol_name'],
+			$_POST['accesscontrol_verdict'],
+			$_POST['accesscontrol_data'],
+			$_POST['accesscontrol_comment']
+		));
+		
+		if ($res) {
+?>
+			<div class="notice">Access control created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create access control</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/accesscontrol-change.php b/webui/accesscontrol-change.php
new file mode 100644
index 00000000..bba8491b
--- /dev/null
+++ b/webui/accesscontrol-change.php
@@ -0,0 +1,221 @@
+<?php
+# Module: AccessControl change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to access cntrl" => "accesscontrol-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a access control was selected
+	if (isset($_POST['accesscontrol_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				${DB_TABLE_PREFIX}access_control.ID, ${DB_TABLE_PREFIX}access_control.PolicyID, ${DB_TABLE_PREFIX}access_control.Name, 
+				${DB_TABLE_PREFIX}access_control.Verdict, ${DB_TABLE_PREFIX}access_control.Data, 
+				${DB_TABLE_PREFIX}access_control.Comment, ${DB_TABLE_PREFIX}access_control.Disabled,
+				
+				${DB_TABLE_PREFIX}policies.Name AS PolicyName
+				
+			FROM 
+				${DB_TABLE_PREFIX}access_control, ${DB_TABLE_PREFIX}policies 
+
+			WHERE 
+				${DB_TABLE_PREFIX}access_control.ID = ?
+				AND ${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}access_control.PolicyID
+			");
+?>
+		<p class="pageheader">Update Access Control</p>
+
+		<form action="accesscontrol-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="accesscontrol_id" value="<?php echo $_POST['accesscontrol_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['accesscontrol_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="accesscontrol_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Link to policy</td>
+					<td class="oldval"><?php echo $row->policyname ?></td>
+					<td>
+						<select name="accesscontrol_policyid">
+							<option value="">--</option>
+<?php
+							$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+							while ($row2 = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row2->id ?>" ><?php echo $row2->name ?></option>
+<?php
+							}
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Verdict
+						<?php tooltip('accesscontrol_verdict'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->verdict ?></td>
+					<td>
+						<select name="accesscontrol_verdict">
+							<option value="">--</option>
+							<option value="HOLD">Hold</option>
+							<option value="REJECT">Reject</option>
+							<option value="DISCARD">Discard (drop)</option>
+							<option value="FILTER">Filter</option>
+							<option value="REDIRECT">Redirect</option>
+							<option value="OK">Ok</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Data
+						<?php tooltip('accesscontrol_data'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->data ?></td>
+					<td><input type="text" name="accesscontrol_data" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="accesscontrol_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="accesscontrol_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No access control selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Access Control Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['accesscontrol_policyid'])) {
+		array_push($updates,"PolicyID = ".$db->quote($_POST['accesscontrol_policyid']));
+	}
+	if (!empty($_POST['accesscontrol_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['accesscontrol_name']));
+	}
+	if (!empty($_POST['accesscontrol_verdict'])) {
+		array_push($updates,"Verdict = ".$db->quote($_POST['accesscontrol_verdict']));
+	}
+	if (!empty($_POST['accesscontrol_data'])) {
+		array_push($updates,"Data = ".$db->quote($_POST['accesscontrol_data']));
+	}
+	if (!empty($_POST['accesscontrol_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['accesscontrol_comment']));
+	}
+	if (isset($_POST['accesscontrol_disabled']) && $_POST['accesscontrol_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['accesscontrol_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}access_control SET $updateStr WHERE ID = ".$db->quote($_POST['accesscontrol_id']));
+		if ($res) {
+?>
+			<div class="notice">Access control updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating access control!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to access control</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/accesscontrol-delete.php b/webui/accesscontrol-delete.php
new file mode 100644
index 00000000..ec7f017c
--- /dev/null
+++ b/webui/accesscontrol-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Module: AccessControl delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to access cntrl" => "accesscontrol-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a access control was selected
+	if (isset($_POST['accesscontrol_id'])) {
+?>
+		<p class="pageheader">Delete Access Control</p>
+
+		<form action="accesscontrol-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="accesscontrol_id" value="<?php echo $_POST['accesscontrol_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No access control selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Access Control Delete Results</p>
+<?php
+	if (isset($_POST['accesscontrol_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}access_control WHERE ID = ".$db->quote($_POST['accesscontrol_id']));
+			if ($res) {
+?>
+				<div class="notice">Access control deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting access control!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Access control not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no access control ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/accesscontrol-main.php b/webui/accesscontrol-main.php
new file mode 100644
index 00000000..5f9b2bcf
--- /dev/null
+++ b/webui/accesscontrol-main.php
@@ -0,0 +1,125 @@
+<?php
+# Module: AccessControl
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">Access Control List</p>
+
+	<form id="main_form" action="accesscontrol-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'accesscontrol-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'accesscontrol-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'accesscontrol-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Policy</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Verdict</td>
+				<td class="textcenter">Data</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						${DB_TABLE_PREFIX}access_control.ID, ${DB_TABLE_PREFIX}access_control.Name, 
+						${DB_TABLE_PREFIX}access_control.Verdict, ${DB_TABLE_PREFIX}access_control.Data, 
+						${DB_TABLE_PREFIX}access_control.Disabled,
+						${DB_TABLE_PREFIX}policies.Name AS PolicyName
+
+					FROM 
+						${DB_TABLE_PREFIX}access_control, ${DB_TABLE_PREFIX}policies
+
+					WHERE
+						${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}access_control.PolicyID
+
+					ORDER BY 
+						${DB_TABLE_PREFIX}policies.Name
+			";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="accesscontrol_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->policyname ?></td>
+					<td><?php echo $row->name ?></td>
+					<td><?php echo $row->verdict ?></td>
+					<td><?php echo $row->data ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/accounting-add.php b/webui/accounting-add.php
new file mode 100644
index 00000000..f03264f0
--- /dev/null
+++ b/webui/accounting-add.php
@@ -0,0 +1,238 @@
+<?php
+# Module: Accounting add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to accounting" => "accounting-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add Accounting</p>
+
+	<form method="post" action="accounting-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="accounting_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Link to policy</td>
+				<td>
+					<select name="accounting_policyid">
+<?php
+						$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+						while ($row = $res->fetchObject()) {
+?>
+							<option value="<?php echo $row->id ?>"><?php echo $row->name ?></option>
+<?php
+						}
+						$res->closeCursor();
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Track</td>
+				<td>
+					<select id="accounting_track" name="accounting_track"
+							onchange="
+								var myobj = document.getElementById('accounting_track');
+								var myobj2 = document.getElementById('accounting_trackextra');
+
+								if (myobj.selectedIndex == 0) {
+									myobj2.disabled = false;
+									myobj2.value = '/32';
+								} else if (myobj.selectedIndex != 0) {
+									myobj2.disabled = true;
+									myobj2.value = 'n/a';
+								}
+					">
+						<option value="SenderIP">Sender IP</option>
+						<option value="Sender:user@domain" selected="selected">Sender:user@domain</option>
+						<option value="Sender:@domain">Sender:@domain</option>
+						<option value="Sender:user@">Sender:user@</option>
+						<option value="Recipient:user@domain">Recipient:user@domain</option>
+						<option value="Recipient:@domain">Recipient:@domain</option>
+						<option value="Recipient:user@">Recipient:user@</option>
+						<option value="SASLUsername">SASLUsername:username</option>
+						<option value="Policy">Policy</option>
+					</select>
+					<input type="text" id="accounting_trackextra" name="accounting_trackextra" size="18" value="n/a" disabled="disabled" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Period</td>
+				<td>
+					<select name="accounting_period">
+						<option value="0">Daily</option>
+						<option value="1">Weekly</option>
+						<option value="2">Monthly</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Message Count Limit</td>
+				<td><input type="text" name="accounting_messagecountlimit" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Message Cumulative Size Limit</td>
+				<td><input type="text" name="accounting_messagecumulativesizelimit" />Kbyte</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Verdict
+				</td>
+				<td>
+					<select name="accounting_verdict">
+						<option value="">None</option>
+						<option value="HOLD">Hold</option>
+						<option value="REJECT">Reject</option>
+						<option value="DISCARD">Discard (drop)</option>
+						<option value="FILTER">Filter</option>
+						<option value="REDIRECT">Redirect</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Data
+				</td>
+				<td><input type="text" name="accounting_data" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Stop processing here</td>
+				<td>
+					<select name="accounting_lastaccounting">
+						<option value="0">No</option>
+						<option value="1">Yes</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="accounting_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Accounting Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['accounting_policyid'])) {
+?>
+		<div class="warning">Policy ID cannot be empty</div>
+<?php
+
+	# Check name
+	} elseif (empty($_POST['accounting_name'])) {
+?>
+		<div class="warning">Name cannot be empty</div>
+<?php
+
+	# Check accounting track
+	} elseif (empty($_POST['accounting_track'])) {
+?>
+		<div class="warning">Track cannot be empty</div>
+<?php
+
+	# Check last accounting
+	} elseif (!isset($_POST['accounting_lastaccounting'])) {
+?>
+		<div class="warning">Stop procesing here field cannot be empty</div>
+<?php
+
+	} else {
+		$stmt = $db->prepare("
+			INSERT INTO ${DB_TABLE_PREFIX}accounting 
+				(
+					PolicyID, Name, Track, AccountingPeriod,
+					MessageCountLimit, MessageCumulativeSizeLimit,
+					Verdict, Data,
+					LastAccounting,
+					Comment, Disabled
+				) 
+			VALUES 
+				(?,?,?,?,?,?,?,?,?,?,1)");
+		
+		$res = $stmt->execute(array(
+			$_POST['accounting_policyid'],
+			$_POST['accounting_name'],
+			$_POST['accounting_track'],
+			$_POST['accounting_period'],
+			$_POST['accounting_messagecountlimit'],
+			$_POST['accounting_messagecumulativesize'],
+			$_POST['accounting_verdict'],
+			$_POST['accounting_data'],
+			$_POST['accounting_lastaccounting'],
+			$_POST['accounting_comment']
+		));
+		
+		if ($res) {
+?>
+			<div class="notice">Accounting created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create accounting</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/accounting-change.php b/webui/accounting-change.php
new file mode 100644
index 00000000..62fbc21b
--- /dev/null
+++ b/webui/accounting-change.php
@@ -0,0 +1,311 @@
+<?php
+# Module: Accounting change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to accounting" => "accounting-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a accounting was selected
+	if (isset($_POST['accounting_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				${DB_TABLE_PREFIX}accounting.ID, ${DB_TABLE_PREFIX}accounting.PolicyID, ${DB_TABLE_PREFIX}accounting.Name, 
+				${DB_TABLE_PREFIX}accounting.Track, ${DB_TABLE_PREFIX}accounting.AccountingPeriod, 
+				${DB_TABLE_PREFIX}accounting.MessageCountLimit, ${DB_TABLE_PREFIX}accounting.MessageCumulativeSizeLimit,
+				${DB_TABLE_PREFIX}accounting.Verdict, ${DB_TABLE_PREFIX}accounting.Data, 
+				${DB_TABLE_PREFIX}accounting.LastAccounting, 
+				${DB_TABLE_PREFIX}accounting.Comment, 
+				${DB_TABLE_PREFIX}accounting.Disabled,
+				
+				${DB_TABLE_PREFIX}policies.Name AS PolicyName
+				
+			FROM 
+				${DB_TABLE_PREFIX}accounting, ${DB_TABLE_PREFIX}policies 
+
+			WHERE 
+				${DB_TABLE_PREFIX}accounting.ID = ?
+				AND ${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}accounting.PolicyID
+			");
+?>
+		<p class="pageheader">Update Accounting</p>
+
+		<form action="accounting-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="accounting_id" value="<?php echo $_POST['accounting_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['accounting_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="accounting_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Link to policy</td>
+					<td class="oldval"><?php echo $row->policyname ?></td>
+					<td>
+						<select name="accounting_policyid">
+							<option value="">--</option>
+<?php
+							$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+							while ($row2 = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row2->id ?>" ><?php echo $row2->name ?></option>
+<?php
+							}
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Track</td>
+					<td class="oldval"><?php echo $row->track ?></td>
+					<td>
+						<select id="accounting_track" name="accounting_track"
+								onChange="
+									var myobj = document.getElementById('accounting_track');
+									var myobj2 = document.getElementById('accounting_trackextra');
+
+									if (myobj.selectedIndex == 1) {
+										myobj2.disabled = false;
+										myobj2.value = '0.0.0.0/0';
+									} else if (myobj.selectedIndex != 1) {
+										myobj2.disabled = true;
+										myobj2.value = 'n/a';
+									}
+							">
+							<option value="">--</option>
+							<option value="SenderIP">Sender IP</option>
+							<option value="Sender:user@domain">Sender:user@domain</option>
+							<option value="Sender:@domain">Sender:@domain</option>
+							<option value="Sender:user@">Sender:user@</option>
+							<option value="Recipient:user@domain">Recipient:user@domain</option>
+							<option value="Recipient:@domain">Recipient:@domain</option>
+							<option value="Recipient:user@">Recipient:user@</option>
+							<option value="SASLUsername">SASLUsername:username</option>
+							<option value="Policy">Policy</option>
+						</select>
+						<input type="text" id="accounting_trackextra" name="accounting_trackextra" size="18" value="n/a" disabled="disabled" />
+					</td>
+				</tr>
+				<tr>
+<?php
+					# Get human readable accounting period
+					if ($row->accountingperiod == "0") {
+						$accountingperiod = "Daily";
+					} elseif ($row->accountingperiod == "1") {
+						$accountingperiod = "Weekly";
+					} elseif ($row->accountingperiod == "2") {
+						$accountingperiod = "Monthly";
+					}
+?>
+					<td class="entrytitle">Period</td>
+					<td class="oldval"><?php echo $accountingperiod ?></td>
+					<td>
+						<select id="accounting_period" name="accounting_period">
+							<option value="">--</option>
+							<option value="0">Daily</option>
+							<option value="1">Weekly</option>
+							<option value="2">Monthly</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Message Count Limit</td>
+					<td class="oldval"><?php echo $row->messagecountlimit ? $row->messagecountlimit : '-none-' ?></td>
+					<td><input type="text" name="accounting_messagecountlimit" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Message Cumulative Size Limit</td>
+					<td class="oldval"><?php echo $row->messagecumulativesizelimit ? $row->messagecumulativesizelimit : '-none-' ?></td>
+					<td><input type="text" name="accounting_messagecumulativesizelimit" />Kbyte</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Verdict
+					</td>
+					<td class="oldval"><?php echo $row->verdict ?></td>
+					<td>
+						<select name="accounting_verdict">
+							<option value="">--</option>
+							<option value="HOLD">Hold</option>
+							<option value="REJECT">Reject</option>
+							<option value="DISCARD">Discard (drop)</option>
+							<option value="FILTER">Filter</option>
+							<option value="REDIRECT">Redirect</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Data
+					</td>
+					<td class="oldval"><?php echo $row->data ?></td>
+					<td><input type="text" name="accounting_data" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Stop processing here</td>
+					<td class="oldval"><?php echo $row->lastaccounting ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="accounting_lastaccounting">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="accounting_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="accounting_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No accounting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Accounting Update Results</p>
+<?
+	$updates = array();
+
+	if (!empty($_POST['accounting_policyid'])) {
+		array_push($updates,"PolicyID = ".$db->quote($_POST['accounting_policyid']));
+	}
+	if (!empty($_POST['accounting_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['accounting_name']));
+	}
+	if (!empty($_POST['accounting_track'])) {
+		array_push($updates,"Track = ".$db->quote($_POST['accounting_track']));
+	}
+	if (isset($_POST['accounting_period']) && $_POST['accounting_period'] != "") {
+		array_push($updates,"AccountingPeriod = ".$db->quote($_POST['accounting_period']));
+	}
+	if (!empty($_POST['accounting_messagecountlimit'])) {
+		array_push($updates,"MessageCountLimit = ".$db->quote($_POST['accounting_messagecountlimit']));
+	}
+	if (!empty($_POST['accounting_messagecumulativesizelimit'])) {
+		array_push($updates,"MessageCumulativeSizeLimit = ".$db->quote($_POST['accounting_messagecumulativesizelimit']));
+	}
+	if (!empty($_POST['accounting_verdict'])) {
+		array_push($updates,"Verdict = ".$db->quote($_POST['accounting_verdict']));
+	}
+	if (!empty($_POST['accounting_data'])) {
+		array_push($updates,"Data = ".$db->quote($_POST['accounting_data']));
+	}
+	if (!empty($_POST['accounting_lastaccounting'])) {
+		array_push($updates,"LastAccounting = ".$db->quote($_POST['accounting_lastaccounting']));
+	}
+	if (!empty($_POST['accounting_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['accounting_comment']));
+	}
+	if (isset($_POST['accounting_disabled']) && $_POST['accounting_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['accounting_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}accounting SET $updateStr WHERE ID = ".$db->quote($_POST['accounting_id']));
+		if ($res) {
+?>
+			<div class="notice">Accounting updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating accounting!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to accounting</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/accounting-delete.php b/webui/accounting-delete.php
new file mode 100644
index 00000000..12fa60ee
--- /dev/null
+++ b/webui/accounting-delete.php
@@ -0,0 +1,148 @@
+<?php
+# Module: Accounting delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to accounting" => "accounting-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a accounting was selected
+	if (isset($_POST['accounting_id'])) {
+?>
+		<p class="pageheader">Delete Accounting</p>
+
+		<form action="accounting-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="accounting_id" value="<?php echo $_POST['accounting_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure you want to remove this and its associated records? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No accounting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Accounting Delete Results</p>
+<?
+	if (isset($_POST['accounting_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			
+			# Check last query succeeded, if so continue
+			$db->beginTransaction();
+
+			$stmt = $db->prepare("
+				DELETE FROM 
+					${DB_TABLE_PREFIX}accounting_tracking 
+				WHERE 
+					AccountingID = ?
+			");
+			$res = $stmt->execute(array($_POST['accounting_id']));
+
+			if ($res !== FALSE) {
+?>
+				<div class="notice">Accounting tracking info deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting accounting tracking info!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+				$db->rollBack();
+			}
+
+
+			if ($res !== FALSE) {
+				$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}accounting WHERE ID = ".$db->quote($_POST['accounting_id']));
+				if ($res) {
+?>
+					<div class="notice">Accounting deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting accounting!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+					$db->rollBack();
+				}
+			}
+			
+			# Commit if last transaction succeeded
+			if ($res) {
+				$db->commit();
+			}
+			
+		} else {
+?>
+			<div class="notice">Accounting not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no accounting ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/accounting-main.php b/webui/accounting-main.php
new file mode 100644
index 00000000..8d594d85
--- /dev/null
+++ b/webui/accounting-main.php
@@ -0,0 +1,144 @@
+<?php
+# Module: Accounting
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">Accounting</p>
+
+	<form id="main_form" action="accounting-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'accounting-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'accounting-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'accounting-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Policy</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Track</td>
+				<td class="textcenter">Period</td>
+				<td class="textcenter">Count Limit</td>
+				<td class="textcenter">Cumulative Size Limit</td>
+				<td class="textcenter">Verdict</td>
+				<td class="textcenter">Data</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						${DB_TABLE_PREFIX}accounting.ID, ${DB_TABLE_PREFIX}accounting.Name, 
+						${DB_TABLE_PREFIX}accounting.Track, ${DB_TABLE_PREFIX}accounting.AccountingPeriod, 
+						${DB_TABLE_PREFIX}accounting.MessageCountLimit, 
+						${DB_TABLE_PREFIX}accounting.MessageCumulativeSizeLimit,
+						${DB_TABLE_PREFIX}accounting.Verdict, ${DB_TABLE_PREFIX}accounting.Data, ${DB_TABLE_PREFIX}accounting.Disabled,
+						${DB_TABLE_PREFIX}policies.Name AS PolicyName
+
+					FROM 
+						${DB_TABLE_PREFIX}accounting, ${DB_TABLE_PREFIX}policies
+
+					WHERE
+						${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}accounting.PolicyID
+
+					ORDER BY 
+						${DB_TABLE_PREFIX}policies.Name
+			";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+
+				# Get human readable ${DB_TABLE_PREFIX}accounting period
+				if ($row->accountingperiod == "0") {
+					$accountingperiod = "Daily";
+				} elseif ($row->accountingperiod == "1") {
+					$accountingperiod = "Weekly";
+				} elseif ($row->accountingperiod == "2") {
+					$accountingperiod = "Monthly";
+				}
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="accounting_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->policyname ?></td>
+					<td><?php echo $row->name ?></td>
+					<td><?php echo $row->track ?></td>
+					<td><?php echo $accountingperiod ?></td>
+					<td><?php echo !empty($row->messagecountlimit) ? $row->messagecountlimit : '-' ?></td>
+					<td><?php echo !empty($row->messagecumulativesizelimit) ? $row->messagecumulativesizelimit : '-' ?></td>
+					<td><?php echo $row->verdict ?></td>
+					<td><?php echo $row->data ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/amavis-add.php b/webui/amavis-add.php
new file mode 100644
index 00000000..af6d218e
--- /dev/null
+++ b/webui/amavis-add.php
@@ -0,0 +1,1059 @@
+<?php
+# Module: Amavis add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Amavis" => "amavis-main.php"
+		),
+));
+
+
+# Process an option
+function process_post_option($option) {
+	$results = array();
+
+	# Inherit
+	if ($option == 0) {
+		array_push($results,NULL);
+		array_push($results,0);
+	# Explicit yes
+	} elseif ($option == 1) {
+		array_push($results,1);
+		array_push($results,2);
+	# Explicit no
+	} elseif ($option == 2) {
+		array_push($results,0);
+		array_push($results,2);
+	}
+
+	return $results;
+};
+
+
+# Process a value
+function process_post_value($option,$value) {
+	$results = array();
+
+	# Inherit
+	if ($option == 0) {
+		array_push($results,NULL);
+		array_push($results,0);
+	# Override
+	} elseif ($option == 2) {
+		array_push($results,$value);
+		array_push($results,2);
+	}
+
+	return $results;
+};
+
+
+# Process a list of items
+function process_post_list($option,$value) {
+	$results = array();
+
+	# Inherit
+	if ($option == 0) {
+		array_push($results,NULL);
+		array_push($results,0);
+	# Merge
+	} elseif ($option == 1) {
+		array_push($results,$value);
+		array_push($results,1);
+	# Override
+	} elseif ($option == 2) {
+		array_push($results,$value);
+		array_push($results,2);
+	}
+
+	return $results;
+};
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add Amavis Rule</p>
+
+	<form method="post" action="amavis-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="amavis_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Link to policy</td>
+				<td>
+					<select name="amavis_policyid">
+<?php
+						$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+						while ($row = $res->fetchObject()) {
+?>
+							<option value="<?php echo $row->id ?>"><?php echo $row->name ?></option>
+<?php
+						}
+						$res->closeCursor();
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Bypass Checks</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Virus
+					<?php tooltip('amavis_bypass_virus_checks'); ?>
+				</td>
+				<td>
+					<select name="amavis_bypass_virus_checks">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Banned File
+					<?php tooltip('amavis_bypass_banned_checks'); ?>
+				</td>
+				<td>
+					<select name="amavis_bypass_banned_checks">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Spam
+					<?php tooltip('amavis_bypass_spam_checks'); ?>
+				</td>
+				<td>
+					<select name="amavis_bypass_spam_checks">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Header
+					<?php tooltip('amavis_bypass_header_checks'); ?>
+				</td>
+				<td>
+					<select name="amavis_bypass_header_checks">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Anti-spam Settings</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Tag Level
+					<?php tooltip('amavis_spam_tag_level'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_tag_level_mode" id="amavis_spam_tag_level_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_tag_level_mode');
+							var myobji = document.getElementById('amavis_spam_tag_level');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '0.0';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_tag_level" size="6" id="amavis_spam_tag_level" disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Tag2 Level
+					<?php tooltip('amavis_spam_tag2_level'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_tag2_level_mode" id="amavis_spam_tag2_level_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_tag2_level_mode');
+							var myobji = document.getElementById('amavis_spam_tag2_level');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '5.0';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_tag2_level" size="6" id="amavis_spam_tag2_level" disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Tag3 Level
+					<?php tooltip('amavis_spam_tag3_level'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_tag3_level_mode" id="amavis_spam_tag3_level_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_tag3_level_mode');
+							var myobji = document.getElementById('amavis_spam_tag3_level');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '7.5';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_tag3_level" size="6" id="amavis_spam_tag3_level" disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Kill Level
+					<?php tooltip('amavis_spam_kill_level'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_kill_level_mode" id="amavis_spam_kill_level_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_kill_level_mode');
+							var myobji = document.getElementById('amavis_spam_kill_level');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '7.5';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_kill_level" size="6" id="amavis_spam_kill_level" disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					DSN Cutoff Level
+					<?php tooltip('amavis_spam_dsn_cutoff_level'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_dsn_cutoff_level_mode" id="amavis_spam_dsn_cutoff_level_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_dsn_cutoff_level_mode');
+							var myobji = document.getElementById('amavis_spam_dsn_cutoff_level');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '7.5';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_dsn_cutoff_level" size="6" id="amavis_spam_dsn_cutoff_level" disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Quarantine Cutoff Level
+					<?php tooltip('amavis_spam_quarantine_cutoff_level'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_quarantine_cutoff_level_mode" id="amavis_spam_quarantine_cutoff_level_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_quarantine_cutoff_level_mode');
+							var myobji = document.getElementById('amavis_spam_quarantine_cutoff_level');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '15.0';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_quarantine_cutoff_level" size="6" id="amavis_spam_quarantine_cutoff_level" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Modify Subject
+					<?php tooltip('amavis_spam_modifies_subject'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_modifies_subject">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Tag Subject
+					<?php tooltip('amavis_spam_tag_subject'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_tag_subject_mode" id="amavis_spam_tag_subject_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_tag_subject_mode');
+							var myobji = document.getElementById('amavis_spam_tag_subject');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_tag_subject" id="amavis_spam_tag_subject" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Tag2 Subject
+					<?php tooltip('amavis_spam_tag2_subject'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_tag2_subject_mode" id="amavis_spam_tag2_subject_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_tag2_subject_mode');
+							var myobji = document.getElementById('amavis_spam_tag2_subject');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_tag2_subject" id="amavis_spam_tag2_subject" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Tag3 Subject
+					<?php tooltip('amavis_spam_tag3_subject'); ?>
+				</td>
+				<td>
+					<select name="amavis_spam_tag3_subject_mode" id="amavis_spam_tag3_subject_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_spam_tag3_subject_mode');
+							var myobji = document.getElementById('amavis_spam_tag3_subject');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_spam_tag3_subject" id="amavis_spam_tag3_subject" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">General Checks</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Max Message Size (in Kbyte)
+					<?php tooltip('amavis_max_message_size'); ?>
+				</td>
+				<td>
+					<select name="amavis_max_message_size_mode" id="amavis_max_message_size_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_max_message_size_mode');
+							var myobji = document.getElementById('amavis_max_message_size');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_max_message_size" id="amavis_max_message_size" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle texttop">
+					Banned Files
+					<?php tooltip('amavis_banned_files'); ?>
+				</td>
+				<td class="texttop">
+					<select name="amavis_banned_files_mode" id="amavis_banned_files_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_banned_files_mode');
+							var myobji = document.getElementById('amavis_banned_files');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Merge</option>
+						<option value="2">Override</option>
+					</select>
+					<br />
+					<textarea name="amavis_banned_files" id="amavis_banned_files" disabled="disabled" cols="40" rows="5">n/a</textarea>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Whitelist &amp; Blacklist</td>
+			</tr>
+			<tr>
+				<td class="entrytitle texttop">
+					Sender Whitelist
+					<?php tooltip('amavis_sender_whitelist'); ?>
+				</td>
+				<td class="texttop">
+					<select name="amavis_sender_whitelist_mode" id="amavis_sender_whitelist_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_sender_whitelist_mode');
+							var myobji = document.getElementById('amavis_sender_whitelist');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Merge</option>
+						<option value="2">Override</option>
+					</select>
+					<br />
+					<textarea name="amavis_sender_whitelist" id="amavis_sender_whitelist" disabled="disabled" cols="40" rows="5">n/a</textarea>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle texttop">
+					Sender Blacklist
+					<?php tooltip('amavis_sender_blacklist'); ?>
+				</td>
+				<td class="texttop">
+					<select name="amavis_sender_blacklist_mode" id="amavis_sender_blacklist_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_sender_blacklist_mode');
+							var myobji = document.getElementById('amavis_sender_blacklist');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Merge</option>
+						<option value="2">Override</option>
+					</select>
+					<br />
+					<textarea name="amavis_sender_blacklist" id="amavis_sender_blacklist" disabled="disabled" cols="40" rows="5">n/a</textarea>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Admin Notifications</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					New Virus
+					<?php tooltip('amavis_notify_admin_newvirus'); ?>
+				</td>
+				<td>
+					<select name="amavis_notify_admin_newvirus_mode" id="amavis_notify_admin_newvirus_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_notify_admin_newvirus_mode');
+							var myobji = document.getElementById('amavis_notify_admin_newvirus');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_notify_admin_newvirus" id="amavis_notify_admin_newvirus" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Virus
+					<?php tooltip('amavis_notify_admin_virus'); ?>
+				</td>
+				<td>
+					<select name="amavis_notify_admin_virus_mode" id="amavis_notify_admin_virus_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_notify_admin_virus_mode');
+							var myobji = document.getElementById('amavis_notify_admin_virus');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_notify_admin_virus" id="amavis_notify_admin_virus" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Spam
+					<?php tooltip('amavis_notify_admin_spam'); ?>
+				</td>
+				<td>
+					<select name="amavis_notify_admin_spam_mode" id="amavis_notify_admin_spam_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_notify_admin_spam_mode');
+							var myobji = document.getElementById('amavis_notify_admin_spam');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_notify_admin_spam" id="amavis_notify_admin_spam" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Banned File
+					<?php tooltip('amavis_notify_admin_banned_file'); ?>
+				</td>
+				<td>
+					<select name="amavis_notify_admin_banned_file_mode" id="amavis_notify_admin_banned_file_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_notify_admin_banned_file_mode');
+							var myobji = document.getElementById('amavis_notify_admin_banned_file');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_notify_admin_banned_file" id="amavis_notify_admin_banned_file" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Bad Header
+					<?php tooltip('amavis_notify_admin_bad_header'); ?>
+				</td>
+				<td>
+					<select name="amavis_notify_admin_bad_header_mode" id="amavis_notify_admin_bad_header_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_notify_admin_bad_header_mode');
+							var myobji = document.getElementById('amavis_notify_admin_bad_header');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_notify_admin_bad_header" id="amavis_notify_admin_bad_header" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Quarantine</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Virus
+					<?php tooltip('amavis_quarantine_virus'); ?>
+				</td>
+				<td>
+					<select name="amavis_quarantine_virus_mode" id="amavis_quarantine_virus_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_quarantine_virus_mode');
+							var myobji = document.getElementById('amavis_quarantine_virus');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_quarantine_virus" id="amavis_quarantine_virus" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Spam
+					<?php tooltip('amavis_quarantine_spam'); ?>
+				</td>
+				<td>
+					<select name="amavis_quarantine_spam_mode" id="amavis_quarantine_spam_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_quarantine_spam_mode');
+							var myobji = document.getElementById('amavis_quarantine_spam');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_quarantine_spam" id="amavis_quarantine_spam" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Banned File
+					<?php tooltip('amavis_quarantine_banned_file'); ?>
+				</td>
+				<td>
+					<select name="amavis_quarantine_banned_file_mode" id="amavis_quarantine_banned_file_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_quarantine_banned_file_mode');
+							var myobji = document.getElementById('amavis_quarantine_banned_file');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_quarantine_banned_file" id="amavis_quarantine_banned_file" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Bad Header
+					<?php tooltip('amavis_quarantine_bad_header'); ?>
+				</td>
+				<td>
+					<select name="amavis_quarantine_bad_header_mode" id="amavis_quarantine_bad_header_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_quarantine_bad_header_mode');
+							var myobji = document.getElementById('amavis_quarantine_bad_header');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_quarantine_bad_header" id="amavis_quarantine_bad_header" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Interception</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					BCC To
+					<?php tooltip('amavis_bcc_to'); ?>
+				</td>
+				<td>
+					<select name="amavis_bcc_to_mode" id="amavis_bcc_to_mode"
+						onchange="
+							var myobjs = document.getElementById('amavis_bcc_to_mode');
+							var myobji = document.getElementById('amavis_bcc_to');
+
+							if (myobjs.selectedIndex == 0) {
+								myobji.disabled = true;
+								myobji.value = 'n/a';
+							} else if (myobjs.selectedIndex != 0) {
+								myobji.disabled = false;
+								myobji.value = '';
+							}
+					">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="2">Override</option>
+					</select>
+					<input type="text" name="amavis_bcc_to" id="amavis_bcc_to" 
+							disabled="disabled" value="n/a" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">&nbsp;</td>
+			</tr>
+			<tr>
+				<td class="entrytitle texttop">Comment</td>
+				<td><textarea name="amavis_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Amavis Rule Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['amavis_policyid'])) {
+?>
+		<div class="warning">Policy ID cannot be empty</div>
+<?php
+
+	# Check name
+	} elseif (empty($_POST['amavis_name'])) {
+?>
+		<div class="warning">Name cannot be empty</div>
+<?php
+
+	} else {
+		$dbinfo = array();
+
+		# add stuff we need first...
+		array_push($dbinfo,$_POST['amavis_policyid']);
+		array_push($dbinfo,$_POST['amavis_name']);
+
+		# Bypass options
+		$res = process_post_option($_POST['amavis_bypass_virus_checks']);
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_option($_POST['amavis_bypass_banned_checks']);
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_option($_POST['amavis_bypass_spam_checks']);
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_option($_POST['amavis_bypass_header_checks']);
+		$dbinfo = array_merge($dbinfo,$res);
+
+		# Anti-spam options
+		$res = process_post_value($_POST['amavis_spam_tag_level_mode'],isset($_POST['amavis_spam_tag_level']) ? $_POST['amavis_spam_tag_level'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_tag2_level_mode'],isset($_POST['amavis_spam_tag2_level']) ? $_POST['amavis_spam_tag2_level'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_tag3_level_mode'],isset($_POST['amavis_spam_tag3_level']) ? $_POST['amavis_spam_tag3_level'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_kill_level_mode'],isset($_POST['amavis_spam_kill_level']) ? $_POST['amavis_spam_kill_level'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_dsn_cutoff_level_mode'],
+				isset($_POST['amavis_spam_dsn_cutoff_level']) ? $_POST['amavis_spam_dsn_cutoff_level'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_quarantine_cutoff_level_mode'],
+				isset($_POST['amavis_spam_quarantine_cutoff_level']) ? $_POST['amavis_spam_quarantine_cutoff_level'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+
+		$res = process_post_option($_POST['amavis_spam_modifies_subject']);
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_tag_subject_mode'],isset($_POST['amavis_spam_tag_subject']) ? $_POST['amavis_spam_tag_subject'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_tag2_subject_mode'],isset($_POST['amavis_spam_tag2_subject']) ? $_POST['amavis_spam_tag2_subject'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_spam_tag3_subject_mode'],isset($_POST['amavis_spam_tag3_subject']) ? $_POST['amavis_spam_tag3_subject'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+
+		# General
+		$res = process_post_value($_POST['amavis_max_message_size_mode'],isset($_POST['amavis_max_message_size']) ? $_POST['amavis_max_message_size'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_list($_POST['amavis_banned_files_mode'],isset($_POST['amavis_banned_files']) ? $_POST['amavis_banned_files'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+
+		# Whitelist & blacklist	
+		$res = process_post_list($_POST['amavis_sender_whitelist_mode'],isset($_POST['amavis_sender_whitelist']) ? $_POST['amavis_sender_whitelist'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_list($_POST['amavis_sender_blacklist_mode'],isset($_POST['amavis_sender_blacklist']) ? $_POST['amavis_sender_blacklist'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+
+		# Notifications	
+		$res = process_post_value($_POST['amavis_notify_admin_newvirus_mode'],isset($_POST['amavis_notify_admin_newvirus']) ? 
+				$_POST['amavis_notify_admin_newvirus'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_notify_admin_virus_mode'],isset($_POST['amavis_notify_admin_virus']) ? 
+				$_POST['amavis_notify_admin_virus'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_notify_admin_spam_mode'],isset($_POST['amavis_notify_admin_spam']) ? 
+				$_POST['amavis_notify_admin_spam'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_notify_admin_banned_file_mode'],isset($_POST['amavis_notify_admin_banned_file']) ? 
+				$_POST['amavis_notify_admin_banned_file'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_notify_admin_bad_header_mode'],isset($_POST['amavis_notify_admin_bad_header']) ? 
+				$_POST['amavis_notify_admin_bad_header'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+
+		# Quarantine	
+		$res = process_post_value($_POST['amavis_quarantine_virus_mode'],isset($_POST['amavis_quarantine_virus']) ? 
+				$_POST['amavis_quarantine_virus'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_quarantine_spam_mode'],isset($_POST['amavis_quarantine_spam']) ? 
+				$_POST['amavis_quarantine_spam'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_quarantine_banned_file_mode'],isset($_POST['amavis_quarantine_banned_file']) ? 
+				$_POST['amavis_quarantine_banned_file'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		$res = process_post_value($_POST['amavis_quarantine_bad_header_mode'],isset($_POST['amavis_quarantine_bad_header']) ? 
+				$_POST['amavis_quarantine_bad_header'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		
+		# Interception	
+		$res = process_post_value($_POST['amavis_bcc_to_mode'],isset($_POST['amavis_bcc_to']) ? 
+				$_POST['amavis_bcc_to'] : '');
+		$dbinfo = array_merge($dbinfo,$res);
+		
+		# And stuff we need at end
+		array_push($dbinfo,$_POST['amavis_comment']);
+
+		$stmt = $db->prepare("
+			INSERT INTO ${DB_TABLE_PREFIX}amavis_rules
+				(
+					PolicyID,Name,
+					
+					bypass_virus_checks, bypass_virus_checks_m,
+					bypass_banned_checks, bypass_banned_checks_m,
+					bypass_spam_checks, bypass_spam_checks_m,
+					bypass_header_checks, bypass_header_checks_m,
+
+					spam_tag_level, spam_tag_level_m,
+					spam_tag2_level, spam_tag2_level_m,
+					spam_tag3_level, spam_tag3_level_m,
+					spam_kill_level, spam_kill_level_m,
+					spam_dsn_cutoff_level, spam_dsn_cutoff_level_m,
+					spam_quarantine_cutoff_level, spam_quarantine_cutoff_level_m,
+
+					spam_modifies_subject, spam_modifies_subject_m,
+					spam_tag_subject, spam_tag_subject_m,
+					spam_tag2_subject, spam_tag2_subject_m,
+					spam_tag3_subject, spam_tag3_subject_m,
+
+					max_message_size, max_message_size_m,
+					banned_files, banned_files_m,
+
+					sender_whitelist, sender_whitelist_m,
+					sender_blacklist, sender_blacklist_m,
+
+					notify_admin_newvirus, notify_admin_newvirus_m,
+					notify_admin_virus, notify_admin_virus_m,
+					notify_admin_spam, notify_admin_spam_m,
+					notify_admin_banned_file, notify_admin_banned_file_m,
+					notify_admin_bad_header, notify_admin_bad_header_m,
+
+					quarantine_virus, quarantine_virus_m,
+					quarantine_spam, quarantine_spam_m,
+					quarantine_banned_file, quarantine_banned_file_m,
+					quarantine_bad_header, quarantine_bad_header_m,
+					
+					bcc_to, bcc_to_m,
+
+					Comment,
+
+					Disabled
+				) 
+				VALUES 
+				(
+					?,?,
+					
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+
+					?,?,
+					?,?,
+
+					?,?,
+					?,?,
+
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+
+					?,?,
+					?,?,
+					?,?,
+					?,?,
+					
+					?,?,
+
+					?,
+
+					1
+				)"
+		);
+
+		if (!$stmt) {
+			print_r( $db->errorInfo() );
+		}
+
+		$res = $stmt->execute($dbinfo);
+		if ($res) {
+?>
+			<div class="notice">Amavis rule created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create Amavis rule</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/amavis-change.php b/webui/amavis-change.php
new file mode 100644
index 00000000..db23369a
--- /dev/null
+++ b/webui/amavis-change.php
@@ -0,0 +1,1246 @@
+<?php
+# Module: Amavis change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Amavis" => "amavis-main.php"
+		),
+));
+
+# Process an option
+function process_post_option($name,$option) {
+	global $db;
+
+	$results = array();
+
+	# Inherit
+	if ($option == 0) {
+		array_push($results,"$name = NULL");
+		array_push($results,"${name}_m = ".$db->quote(0));
+	# Explicit yes
+	} elseif ($option == 1) {
+		array_push($results,"$name = ".$db->quote(1));
+		array_push($results,"${name}_m = ".$db->quote(2));
+	# Explicit no
+	} elseif ($option == 2) {
+		array_push($results,"$name = ".$db->quote(0));
+		array_push($results,"${name}_m = ".$db->quote(2));
+	}
+
+	return $results;
+};
+
+
+# Process a value
+function process_post_value($name,$option,$value) {
+	global $db;
+
+	$results = array();
+
+	# Inherit
+	if ($option == 0) {
+		array_push($results,"$name = NULL");
+		array_push($results,"${name}_m = ".$db->quote(0));
+	# Override
+	} elseif ($option == 2) {
+		array_push($results,"$name = ".$db->quote($value));
+		array_push($results,"${name}_m = ".$db->quote(2));
+	}
+
+	return $results;
+};
+
+
+# Process a list of items
+function process_post_list($name,$option,$value) {
+	global $db;
+
+	$results = array();
+
+	# Inherit
+	if ($option == 0) {
+		array_push($results,"$name = NULL");
+		array_push($results,"${name}_m = ".$db->quote(0));
+	# Merge
+	} elseif ($option == 1) {
+		array_push($results,"$name = ".$db->quote($value));
+		array_push($results,"${name}_m = ".$db->quote(1));
+	# Override
+	} elseif ($option == 2) {
+		array_push($results,"$name = ".$db->quote($value));
+		array_push($results,"${name}_m = ".$db->quote(2));
+	}
+
+	return $results;
+};
+
+
+
+
+# Make a pretty db option
+function decode_db_option($option,$value)
+{
+	$ret = "unknown";
+
+	if ($option == "0") {
+		$ret = "Inherit";
+
+	# Overwrite
+	} elseif ($option == "2") {
+
+		# Check value
+		if ($value == "0") {
+			$ret = "No";
+
+		} elseif ($value == "1") {
+			$ret = "Yes";
+		}
+	}
+
+	return $ret;
+}
+
+
+# Make a pretty db value
+function decode_db_value($option,$value)
+{
+	$ret = "unknown";
+
+	if ($option == "0") {
+		$ret = "Inherit";
+
+	# Merge
+	} elseif ($option == "1") {
+		$ret = "Merge: $value";
+
+	# Overwrite
+	} elseif ($option == "2") {
+		$ret = "Overwrite: $value";
+
+	}
+
+	return $ret;
+}
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a amavis rule was selected
+	if (isset($_POST['amavis_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				${DB_TABLE_PREFIX}amavis_rules.ID, ${DB_TABLE_PREFIX}amavis_rules.PolicyID, ${DB_TABLE_PREFIX}amavis_rules.Name, 
+			
+				${DB_TABLE_PREFIX}amavis_rules.bypass_virus_checks, ${DB_TABLE_PREFIX}amavis_rules.bypass_virus_checks_m,
+				${DB_TABLE_PREFIX}amavis_rules.bypass_banned_checks, ${DB_TABLE_PREFIX}amavis_rules.bypass_banned_checks_m,
+				${DB_TABLE_PREFIX}amavis_rules.bypass_spam_checks, ${DB_TABLE_PREFIX}amavis_rules.bypass_spam_checks_m,
+				${DB_TABLE_PREFIX}amavis_rules.bypass_header_checks, ${DB_TABLE_PREFIX}amavis_rules.bypass_header_checks_m,
+
+				${DB_TABLE_PREFIX}amavis_rules.spam_tag_level, ${DB_TABLE_PREFIX}amavis_rules.spam_tag_level_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_tag2_level, ${DB_TABLE_PREFIX}amavis_rules.spam_tag2_level_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_tag3_level, ${DB_TABLE_PREFIX}amavis_rules.spam_tag3_level_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_kill_level, ${DB_TABLE_PREFIX}amavis_rules.spam_kill_level_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_dsn_cutoff_level, ${DB_TABLE_PREFIX}amavis_rules.spam_dsn_cutoff_level_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_quarantine_cutoff_level, ${DB_TABLE_PREFIX}amavis_rules.spam_quarantine_cutoff_level_m,
+
+				${DB_TABLE_PREFIX}amavis_rules.spam_modifies_subject, ${DB_TABLE_PREFIX}amavis_rules.spam_modifies_subject_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_tag_subject, ${DB_TABLE_PREFIX}amavis_rules.spam_tag_subject_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_tag2_subject, ${DB_TABLE_PREFIX}amavis_rules.spam_tag2_subject_m,
+				${DB_TABLE_PREFIX}amavis_rules.spam_tag3_subject, ${DB_TABLE_PREFIX}amavis_rules.spam_tag3_subject_m,
+
+				${DB_TABLE_PREFIX}amavis_rules.max_message_size, ${DB_TABLE_PREFIX}amavis_rules.max_message_size_m,
+				${DB_TABLE_PREFIX}amavis_rules.banned_files, ${DB_TABLE_PREFIX}amavis_rules.banned_files_m,
+
+				${DB_TABLE_PREFIX}amavis_rules.sender_whitelist, ${DB_TABLE_PREFIX}amavis_rules.sender_whitelist_m,
+				${DB_TABLE_PREFIX}amavis_rules.sender_blacklist, ${DB_TABLE_PREFIX}amavis_rules.sender_blacklist_m,
+
+				${DB_TABLE_PREFIX}amavis_rules.notify_admin_newvirus, ${DB_TABLE_PREFIX}amavis_rules.notify_admin_newvirus_m,
+				${DB_TABLE_PREFIX}amavis_rules.notify_admin_virus, ${DB_TABLE_PREFIX}amavis_rules.notify_admin_virus_m,
+				${DB_TABLE_PREFIX}amavis_rules.notify_admin_spam, ${DB_TABLE_PREFIX}amavis_rules.notify_admin_spam_m,
+				${DB_TABLE_PREFIX}amavis_rules.notify_admin_banned_file, ${DB_TABLE_PREFIX}amavis_rules.notify_admin_banned_file_m,
+				${DB_TABLE_PREFIX}amavis_rules.notify_admin_bad_header, ${DB_TABLE_PREFIX}amavis_rules.notify_admin_bad_header_m,
+
+				${DB_TABLE_PREFIX}amavis_rules.quarantine_virus, ${DB_TABLE_PREFIX}amavis_rules.quarantine_virus_m,
+				${DB_TABLE_PREFIX}amavis_rules.quarantine_spam, ${DB_TABLE_PREFIX}amavis_rules.quarantine_spam_m,
+				${DB_TABLE_PREFIX}amavis_rules.quarantine_banned_file, ${DB_TABLE_PREFIX}amavis_rules.quarantine_banned_file_m,
+				${DB_TABLE_PREFIX}amavis_rules.quarantine_bad_header, ${DB_TABLE_PREFIX}amavis_rules.quarantine_bad_header_m,
+				
+				${DB_TABLE_PREFIX}amavis_rules.bcc_to, ${DB_TABLE_PREFIX}amavis_rules.bcc_to_m,
+
+				${DB_TABLE_PREFIX}amavis_rules.Comment, 
+				${DB_TABLE_PREFIX}amavis_rules.Disabled,
+				
+				${DB_TABLE_PREFIX}policies.Name AS PolicyName
+				
+			FROM 
+				${DB_TABLE_PREFIX}amavis_rules, ${DB_TABLE_PREFIX}policies 
+
+			WHERE 
+				${DB_TABLE_PREFIX}amavis_rules.ID = ?
+				AND ${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}amavis_rules.PolicyID
+			");
+?>
+		<p class="pageheader">Update Amavis Rule</p>
+
+		<form action="amavis-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="amavis_id" value="<?php echo $_POST['amavis_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['amavis_id']));
+
+			$row = $stmt->fetchObject();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="amavis_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Link to policy</td>
+					<td class="oldval"><?php echo $row->policyname ?></td>
+					<td>
+						<select name="amavis_policyid">
+							<option value="">--</option>
+<?php
+							$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+							while ($row2 = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row2->id ?>" ><?php echo $row2->name ?></option>
+<?php
+							}
+							$res->closeCursor();
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Bypass Checks</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Virus Checks
+						<?php tooltip('amavis_bypass_virus_checks'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_option($row->bypass_virus_checks_m,$row->bypass_virus_checks) ?></td>
+					<td>
+						<select name="amavis_bypass_virus_checks">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Yes</option>
+							<option value="2">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Banned File Checks
+						<?php tooltip('amavis_bypass_banned_checks'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_option($row->bypass_banned_checks_m,$row->bypass_banned_checks) ?></td>
+					<td>
+						<select name="amavis_bypass_banned_checks">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Yes</option>
+							<option value="2">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Spam Checks
+						<?php tooltip('amavis_bypass_spam_checks'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_option($row->bypass_spam_checks_m,$row->bypass_spam_checks) ?></td>
+					<td>
+						<select name="amavis_bypass_spam_checks">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Yes</option>
+							<option value="2">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Header Checks
+						<?php tooltip('amavis_bypass_header_checks'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_option($row->bypass_header_checks_m,$row->bypass_header_checks) ?></td>
+					<td>
+						<select name="amavis_bypass_header_checks">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Yes</option>
+							<option value="2">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Anti-spam Settings</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Tag Level
+						<?php tooltip('amavis_spam_tag_level'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_tag_level_m,$row->spam_tag_level) ?></td>
+					<td>
+						<select name="amavis_spam_tag_level_mode" id="amavis_spam_tag_level_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_tag_level_mode');
+								var myobji = document.getElementById('amavis_spam_tag_level');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '0.0';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_tag_level" size="6" id="amavis_spam_tag_level" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Tag2 Level
+						<?php tooltip('amavis_spam_tag2_level'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_tag2_level_m,$row->spam_tag2_level) ?></td>
+					<td>
+						<select name="amavis_spam_tag2_level_mode" id="amavis_spam_tag2_level_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_tag2_level_mode');
+								var myobji = document.getElementById('amavis_spam_tag2_level');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '5.0';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_tag2_level" size="6" id="amavis_spam_tag2_level" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Tag3 Level
+						<?php tooltip('amavis_spam_tag3_level'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_tag3_level_m,$row->spam_tag3_level) ?></td>
+					<td>
+						<select name="amavis_spam_tag3_level_mode" id="amavis_spam_tag3_level_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_tag3_level_mode');
+								var myobji = document.getElementById('amavis_spam_tag3_level');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '7.5';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_tag3_level" size="6" id="amavis_spam_tag3_level" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Kill Level
+						<?php tooltip('amavis_spam_kill_level'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_kill_level_m,$row->spam_kill_level) ?></td>
+					<td>
+						<select name="amavis_spam_kill_level_mode" id="amavis_spam_kill_level_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_kill_level_mode');
+								var myobji = document.getElementById('amavis_spam_kill_level');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '7.5';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_kill_level" size="6" id="amavis_spam_kill_level" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						DSN Cutoff Level
+						<?php tooltip('amavis_spam_dsn_cutoff_level'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_dsn_cutoff_level_m,$row->spam_dsn_cutoff_level) ?></td>
+					<td>
+						<select name="amavis_spam_dsn_cutoff_level_mode" id="amavis_spam_dsn_cutoff_level_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_dsn_cutoff_level_mode');
+								var myobji = document.getElementById('amavis_spam_dsn_cutoff_level');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '7.5';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_dsn_cutoff_level" size="6" id="amavis_spam_dsn_cutoff_level" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Quarantine Cutoff Level
+						<?php tooltip('amavis_spam_quarantine_cutoff_level'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_quarantine_cutoff_level_m,$row->spam_quarantine_cutoff_level) ?></td>
+					<td>
+						<select name="amavis_spam_quarantine_cutoff_level_mode" id="amavis_spam_quarantine_cutoff_level_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_quarantine_cutoff_level_mode');
+								var myobji = document.getElementById('amavis_spam_quarantine_cutoff_level');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '15.0';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_quarantine_cutoff_level" size="6" id="amavis_spam_quarantine_cutoff_level" 
+								disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Modify Subject
+						<?php tooltip('amavis_spam_modifies_subject'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_option($row->spam_modifies_subject_m,$row->spam_modifies_subject) ?></td>
+					<td>
+						<select name="amavis_spam_modifies_subject">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Yes</option>
+							<option value="2">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Tag Subject
+						<?php tooltip('amavis_spam_tag_subject'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_tag_subject_m,$row->spam_tag_subject) ?></td>
+					<td>
+						<select name="amavis_spam_tag_subject_mode" id="amavis_spam_tag_subject_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_tag_subject_mode');
+								var myobji = document.getElementById('amavis_spam_tag_subject');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_tag_subject" id="amavis_spam_tag_subject" 
+								disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Tag2 Subject
+						<?php tooltip('amavis_spam_tag2_subject'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_tag2_subject_m,$row->spam_tag2_subject) ?></td>
+					<td>
+						<select name="amavis_spam_tag2_subject_mode" id="amavis_spam_tag2_subject_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_tag2_subject_mode');
+								var myobji = document.getElementById('amavis_spam_tag2_subject');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_tag2_subject" id="amavis_spam_tag2_subject" 
+								disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Tag3 Subject
+						<?php tooltip('amavis_spam_tag3_subject'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->spam_tag3_subject_m,$row->spam_tag3_subject) ?></td>
+					<td>
+						<select name="amavis_spam_tag3_subject_mode" id="amavis_spam_tag3_subject_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_spam_tag3_subject_mode');
+								var myobji = document.getElementById('amavis_spam_tag3_subject');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_spam_tag3_subject" id="amavis_spam_tag3_subject" 
+								disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">General Checks</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Max Message Size (Kbyte)
+						<?php tooltip('amavis_max_message_size'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->max_message_size_m,$row->max_message_size) ?></td>
+					<td>
+						<select name="amavis_max_message_size_mode" id="amavis_max_message_size_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_max_message_size_mode');
+								var myobji = document.getElementById('amavis_max_message_size');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_max_message_size" id="amavis_max_message_size" 
+								disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">
+						Banned Files	
+						<?php tooltip('amavis_banned_files'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->banned_files_m,$row->banned_files) ?></td>
+					<td>
+						<select name="amavis_banned_files_mode" id="amavis_banned_files_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_banned_files_mode');
+								var myobji = document.getElementById('amavis_banned_files');
+
+								if (myobjs.selectedIndex < 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex >= 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Merge</option>
+							<option value="2">Override</option>
+						</select>
+						<br />
+						<textarea name="amavis_banned_files" id="amavis_banned_files" disabled="disabled" cols="40" rows="5">n/a</textarea>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Whitelist &amp; Blacklist</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">
+						Sender Whitelist
+						<?php tooltip('amavis_sender_whitelist'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->sender_whitelist_m,$row->sender_whitelist) ?></td>
+					<td class="texttop">
+						<select name="amavis_sender_whitelist_mode" id="amavis_sender_whitelist_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_sender_whitelist_mode');
+								var myobji = document.getElementById('amavis_sender_whitelist');
+
+								if (myobjs.selectedIndex < 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex >= 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Merge</option>
+							<option value="2">Override</option>
+						</select>
+						<br />
+						<textarea name="amavis_sender_whitelist" id="amavis_sender_whitelist" disabled="disabled" cols="40" rows="5">n/a</textarea>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">
+						Sender Blacklist
+						<?php tooltip('amavis_sender_blacklist'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->sender_blacklist_m,$row->sender_blacklist) ?></td>
+					<td class="texttop">
+						<select name="amavis_sender_blacklist_mode" id="amavis_sender_blacklist_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_sender_blacklist_mode');
+								var myobji = document.getElementById('amavis_sender_blacklist');
+
+								if (myobjs.selectedIndex < 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex >= 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="1">Merge</option>
+							<option value="2">Override</option>
+						</select>
+						<br />
+						<textarea name="amavis_sender_blacklist" id="amavis_sender_blacklist" disabled="disabled" cols="40" rows="5">n/a</textarea>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Admin Notifications</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						New Virus
+						<?php tooltip('amavis_notify_admin_newvirus'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->notify_admin_newvirus_m,$row->notify_admin_newvirus) ?></td>
+					<td>
+						<select name="amavis_notify_admin_newvirus_mode" id="amavis_notify_admin_newvirus_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_notify_admin_newvirus_mode');
+								var myobji = document.getElementById('amavis_notify_admin_newvirus');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_notify_admin_newvirus" id="amavis_notify_admin_newvirus" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Virus
+						<?php tooltip('amavis_notify_admin_virus'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->notify_admin_virus_m,$row->notify_admin_virus) ?></td>
+					<td>
+						<select name="amavis_notify_admin_virus_mode" id="amavis_notify_admin_virus_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_notify_admin_virus_mode');
+								var myobji = document.getElementById('amavis_notify_admin_virus');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_notify_admin_virus" id="amavis_notify_admin_virus" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Spam
+						<?php tooltip('amavis_notify_admin_spam'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->notify_admin_spam_m,$row->notify_admin_spam) ?></td>
+					<td>
+						<select name="amavis_notify_admin_spam_mode" id="amavis_notify_admin_spam_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_notify_admin_spam_mode');
+								var myobji = document.getElementById('amavis_notify_admin_spam');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_notify_admin_spam" id="amavis_notify_admin_spam" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Banned File
+						<?php tooltip('amavis_notify_admin_banned_file'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->notify_admin_banned_file_m,$row->notify_admin_banned_file) ?></td>
+					<td>
+						<select name="amavis_notify_admin_banned_file_mode" id="amavis_notify_admin_banned_file_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_notify_admin_banned_file_mode');
+								var myobji = document.getElementById('amavis_notify_admin_banned_file');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_notify_admin_banned_file" id="amavis_notify_admin_banned_file" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Bad Header
+						<?php tooltip('amavis_notify_admin_bad_header'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->notify_admin_bad_header_m,$row->notify_admin_bad_header) ?></td>
+					<td>
+						<select name="amavis_notify_admin_bad_header_mode" id="amavis_notify_admin_bad_header_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_notify_admin_bad_header_mode');
+								var myobji = document.getElementById('amavis_notify_admin_bad_header');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_notify_admin_bad_header" id="amavis_notify_admin_bad_header" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Quarantine</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Virus
+						<?php tooltip('amavis_quarantine_virus'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->quarantine_virus_m,$row->quarantine_virus) ?></td>
+					<td>
+						<select name="amavis_quarantine_virus_mode" id="amavis_quarantine_virus_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_quarantine_virus_mode');
+								var myobji = document.getElementById('amavis_quarantine_virus');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_quarantine_virus" id="amavis_quarantine_virus" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Spam
+						<?php tooltip('amavis_quarantine_spam'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->quarantine_spam_m,$row->quarantine_spam) ?></td>
+					<td>
+						<select name="amavis_quarantine_spam_mode" id="amavis_quarantine_spam_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_quarantine_spam_mode');
+								var myobji = document.getElementById('amavis_quarantine_spam');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_quarantine_spam" id="amavis_quarantine_spam" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Banned File
+						<?php tooltip('amavis_quarantine_banned_file'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->quarantine_banned_file_m,$row->quarantine_banned_file) ?></td>
+					<td>
+						<select name="amavis_quarantine_banned_file_mode" id="amavis_quarantine_banned_file_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_quarantine_banned_file_mode');
+								var myobji = document.getElementById('amavis_quarantine_banned_file');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_quarantine_banned_file" id="amavis_quarantine_banned_file" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Bad Header
+						<?php tooltip('amavis_quarantine_bad_header'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->quarantine_bad_header_m,$row->quarantine_bad_header) ?></td>
+					<td>
+						<select name="amavis_quarantine_bad_header_mode" id="amavis_quarantine_bad_header_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_quarantine_bad_header_mode');
+								var myobji = document.getElementById('amavis_quarantine_bad_header');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_quarantine_bad_header" id="amavis_quarantine_bad_header" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Interception</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						BCC To
+						<?php tooltip('amavis_bcc_to'); ?>
+					</td>
+					<td class="oldval"><?php echo decode_db_value($row->bcc_to_m,$row->bcc_to) ?></td>
+					<td>
+						<select name="amavis_bcc_to_mode" id="amavis_bcc_to_mode"
+							onchange="
+								var myobjs = document.getElementById('amavis_bcc_to_mode');
+								var myobji = document.getElementById('amavis_bcc_to');
+	
+								if (myobjs.selectedIndex != 2) {
+									myobji.disabled = true;
+									myobji.value = 'n/a';
+								} else if (myobjs.selectedIndex == 2) {
+									myobji.disabled = false;
+									myobji.value = '';
+								}
+						">
+							<option value="">--</option>
+							<option value="0">Inherit</option>
+							<option value="2">Override</option>
+						</select>
+						<input type="text" name="amavis_bcc_to" id="amavis_bcc_to" disabled="disabled" value="n/a" />
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">&nbsp;</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="amavis_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="amavis_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No Amavis rule selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Amavis Rule Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['amavis_policyid'])) {
+		array_push($updates,"PolicyID = ".$db->quote($_POST['amavis_policyid']));
+	}
+	if (!empty($_POST['amavis_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['amavis_name']));
+	}
+
+	# Bypass options
+	if (isset($_POST['amavis_bypass_virus_checks']) && $_POST['amavis_bypass_virus_checks'] != "") {
+		$res = process_post_option('bypass_virus_checks',$_POST['amavis_bypass_virus_checks']);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_bypass_banned_checks']) && $_POST['amavis_bypass_banned_checks'] != "") {
+		$res = process_post_option('bypass_banned_checks',$_POST['amavis_bypass_banned_checks']);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_bypass_spam_checks']) && $_POST['amavis_bypass_spam_checks'] != "") {
+		$res = process_post_option('bypass_spam_checks',$_POST['amavis_bypass_spam_checks']);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_bypass_header_checks']) && $_POST['amavis_bypass_header_checks'] != "") {
+		$res = process_post_option('bypass_header_checks',$_POST['amavis_bypass_header_checks']);
+		$updates = array_merge($updates,$res);
+	}
+
+	# Antispam level
+	if (isset($_POST['amavis_spam_tag_level_mode']) && $_POST['amavis_spam_tag_level_mode'] != "") {
+		$res = process_post_value('spam_tag_level',$_POST['amavis_spam_tag_level_mode'],
+				isset($_POST['amavis_spam_tag_level']) ? $_POST['amavis_spam_tag_level'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_tag2_level_mode']) && $_POST['amavis_spam_tag2_level_mode'] != "") {
+		$res = process_post_value('spam_tag2_level',$_POST['amavis_spam_tag2_level_mode'],
+				isset($_POST['amavis_spam_tag2_level']) ? $_POST['amavis_spam_tag2_level'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_tag3_level_mode']) && $_POST['amavis_spam_tag3_level_mode'] != "") {
+		$res = process_post_value('spam_tag3_level',$_POST['amavis_spam_tag3_level_mode'],
+				isset($_POST['amavis_spam_tag3_level']) ? $_POST['amavis_spam_tag3_level'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_kill_level_mode']) && $_POST['amavis_spam_kill_level_mode'] != "") {
+		$res = process_post_value('spam_kill_level',$_POST['amavis_spam_kill_level_mode'],
+				isset($_POST['amavis_spam_kill_level']) ? $_POST['amavis_spam_kill_level'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_dsn_cutoff_level_mode']) && $_POST['amavis_spam_dsn_cutoff_level_mode'] != "") {
+		$res = process_post_value('spam_dsn_cutoff_level',$_POST['amavis_spam_dsn_cutoff_level_mode'],
+				isset($_POST['amavis_spam_dsn_cutoff_level']) ? $_POST['amavis_spam_dsn_cutoff_level'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_quarantine_cutoff_level_mode']) && $_POST['amavis_spam_quarantine_cutoff_level_mode'] != "") {
+		$res = process_post_value('spam_quarantine_cutoff_level',$_POST['amavis_spam_quarantine_cutoff_level_mode'],
+				isset($_POST['amavis_spam_quarantine_cutoff_level']) ? $_POST['amavis_spam_quarantine_cutoff_level'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+
+	if (isset($_POST['amavis_spam_modifies_subject']) && $_POST['amavis_spam_modifies_subject'] != "") {
+		$res = process_post_option('spam_modifies_subject',$_POST['amavis_spam_modifies_subject']);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_tag_subject_mode']) && $_POST['amavis_spam_tag_subject_mode'] != "") {
+		$res = process_post_value('spam_tag_subject',$_POST['amavis_spam_tag_subject_mode'],
+				isset($_POST['amavis_spam_tag_subject']) ? $_POST['amavis_spam_tag_subject'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_tag2_subject_mode']) && $_POST['amavis_spam_tag2_subject_mode'] != "") {
+		$res = process_post_value('spam_tag2_subject',$_POST['amavis_spam_tag2_subject_mode'],
+				isset($_POST['amavis_spam_tag2_subject']) ? $_POST['amavis_spam_tag2_subject'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_spam_tag3_subject_mode']) && $_POST['amavis_spam_tag3_subject_mode'] != "") {
+		$res = process_post_value('spam_tag3_subject',$_POST['amavis_spam_tag3_subject_mode'],
+				isset($_POST['amavis_spam_tag3_subject']) ? $_POST['amavis_spam_tag3_subject'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+
+	# General
+	if (isset($_POST['amavis_max_message_size_mode']) && $_POST['amavis_max_message_size_mode'] != "") {
+		$res = process_post_value('max_message_size',$_POST['amavis_max_message_size_mode'],
+				isset($_POST['amavis_max_message_size']) ? $_POST['amavis_max_message_size'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_banned_files_mode']) && $_POST['amavis_banned_files_mode'] != "") {
+		$res = process_post_list('banned_files',$_POST['amavis_banned_files_mode'],
+				isset($_POST['amavis_banned_files']) ? $_POST['amavis_banned_files'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+
+	# Whitelist & blacklist
+	if (isset($_POST['amavis_sender_whitelist_mode']) && $_POST['amavis_sender_whitelist_mode'] != "") {
+		$res = process_post_list('sender_whitelist',$_POST['amavis_sender_whitelist_mode'],
+				isset($_POST['amavis_sender_whitelist']) ? $_POST['amavis_sender_whitelist'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_sender_blacklist_mode']) && $_POST['amavis_sender_blacklist_mode'] != "") {
+		$res = process_post_list('sender_blacklist',$_POST['amavis_sender_blacklist_mode'],
+				isset($_POST['amavis_sender_blacklist']) ? $_POST['amavis_sender_blacklist'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+
+	# Notifications
+	if (isset($_POST['amavis_notify_admin_newvirus_mode']) && $_POST['amavis_notify_admin_newvirus_mode'] != "") {
+		$res = process_post_value('notify_admin_newvirus',$_POST['amavis_notify_admin_newvirus_mode'],
+				isset($_POST['amavis_notify_admin_newvirus']) ? $_POST['amavis_notify_admin_newvirus'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_notify_admin_virus_mode']) && $_POST['amavis_notify_admin_virus_mode'] != "") {
+		$res = process_post_value('notify_admin_virus',$_POST['amavis_notify_admin_virus_mode'],
+				isset($_POST['amavis_notify_admin_virus']) ? $_POST['amavis_notify_admin_virus'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_notify_admin_spam_mode']) && $_POST['amavis_notify_admin_spam_mode'] != "") {
+		$res = process_post_value('notify_admin_spam',$_POST['amavis_notify_admin_spam_mode'],
+				isset($_POST['amavis_notify_admin_spam']) ? $_POST['amavis_notify_admin_spam'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_notify_admin_banned_file_mode']) && $_POST['amavis_notify_admin_banned_file_mode'] != "") {
+		$res = process_post_value('notify_admin_banned_file',$_POST['amavis_notify_admin_banned_file_mode'],
+				isset($_POST['amavis_notify_admin_banned_file']) ? $_POST['amavis_notify_admin_banned_file'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_notify_admin_bad_header_mode']) && $_POST['amavis_notify_admin_bad_header_mode'] != "") {
+		$res = process_post_value('notify_admin_bad_header',$_POST['amavis_notify_admin_bad_header_mode'],
+				isset($_POST['amavis_notify_admin_bad_header']) ? $_POST['amavis_notify_admin_bad_header'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+
+	# Quarantine
+	if (isset($_POST['amavis_quarantine_virus_mode']) && $_POST['amavis_quarantine_virus_mode'] != "") {
+		$res = process_post_value('quarantine_virus',$_POST['amavis_quarantine_virus_mode'],
+				isset($_POST['amavis_quarantine_virus']) ? $_POST['amavis_quarantine_virus'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_quarantine_spam_mode']) && $_POST['amavis_quarantine_spam_mode'] != "") {
+		$res = process_post_value('quarantine_spam',$_POST['amavis_quarantine_spam_mode'],
+				isset($_POST['amavis_quarantine_spam']) ? $_POST['amavis_quarantine_spam'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_quarantine_banned_file_mode']) && $_POST['amavis_quarantine_banned_file_mode'] != "") {
+		$res = process_post_value('quarantine_banned_file',$_POST['amavis_quarantine_banned_file_mode'],
+				isset($_POST['amavis_quarantine_banned_file']) ? $_POST['amavis_quarantine_banned_file'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+	if (isset($_POST['amavis_quarantine_bad_header_mode']) && $_POST['amavis_quarantine_bad_header_mode'] != "") {
+		$res = process_post_value('quarantine_bad_header',$_POST['amavis_quarantine_bad_header_mode'],
+				isset($_POST['amavis_quarantine_bad_header']) ? $_POST['amavis_quarantine_bad_header'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+
+	# Interception
+	if (isset($_POST['amavis_bcc_to_mode']) && $_POST['amavis_bcc_to_mode'] != "") {
+		$res = process_post_value('bcc_to',$_POST['amavis_bcc_to_mode'],
+				isset($_POST['amavis_bcc_to']) ? $_POST['amavis_bcc_to'] : ''
+		);
+		$updates = array_merge($updates,$res);
+	}
+
+	# Whatever is left over
+	if (!empty($_POST['amavis_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['amavis_comment']));
+	}
+	if (isset($_POST['amavis_disabled']) && $_POST['amavis_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['amavis_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}amavis_rules SET $updateStr WHERE ID = ".$db->quote($_POST['amavis_id']));
+		if ($res) {
+?>
+			<div class="notice">Amavis rule updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating Amavis rule!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to Amavis rule</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/amavis-delete.php b/webui/amavis-delete.php
new file mode 100644
index 00000000..3a3ee2dd
--- /dev/null
+++ b/webui/amavis-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Module: Amavis delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Amavis" => "amavis-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a amavis rule was selected
+	if (isset($_POST['amavis_id'])) {
+?>
+		<p class="pageheader">Delete Amavis Rule</p>
+
+		<form action="amavis-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="amavis_id" value="<?php echo $_POST['amavis_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No Amavis rule selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Amavis Rule Delete Results</p>
+<?php
+	if (isset($_POST['amavis_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}amavis_rules WHERE ID = ".$db->quote($_POST['amavis_id']));
+			if ($res) {
+?>
+				<div class="notice">Amavis rule deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting Amavis rule!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Amavis rule not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no Amavis rule ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/amavis-main.php b/webui/amavis-main.php
new file mode 100644
index 00000000..6f374ea9
--- /dev/null
+++ b/webui/amavis-main.php
@@ -0,0 +1,119 @@
+<?php
+# Main amavisd display
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">Amavis Rule List</p>
+
+	<form id="main_form" action="amavis-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'amavis-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'amavis-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'amavis-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Policy</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						${DB_TABLE_PREFIX}amavis_rules.ID, ${DB_TABLE_PREFIX}amavis_rules.Name, ${DB_TABLE_PREFIX}amavis_rules.Disabled,
+						${DB_TABLE_PREFIX}policies.Name AS PolicyName
+
+					FROM 
+						${DB_TABLE_PREFIX}amavis_rules, ${DB_TABLE_PREFIX}policies
+
+					WHERE
+						${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}amavis_rules.PolicyID
+
+					ORDER BY 
+						${DB_TABLE_PREFIX}policies.Name
+			";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="amavis_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->policyname ?></td>
+					<td><?php echo $row->name ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-add.php b/webui/checkhelo-add.php
new file mode 100644
index 00000000..8c9cadfd
--- /dev/null
+++ b/webui/checkhelo-add.php
@@ -0,0 +1,331 @@
+<?php
+# Module: CheckHelo add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to HELO checks" => "checkhelo-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add HELO/EHLO Check</p>
+
+	<form method="post" action="checkhelo-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="checkhelo_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Link to policy</td>
+				<td>
+					<select name="checkhelo_policyid">
+<?php
+						$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+						while ($row = $res->fetchObject()) {
+?>
+							<option value="<?php echo $row->id ?>"><?php echo $row->name ?></option>
+<?php
+						}
+						$res->closeCursor();
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Blacklisting</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Use Blacklist</td>
+				<td>
+					<select name="checkhelo_useblacklist">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Blacklist Period
+					<?php tooltip('checkhelo_blacklist_period'); ?>
+				</td>
+				<td><input type="text" name="checkhelo_blacklistperiod" /></td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Randomization Prevention</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Use HRP
+				</td>
+				<td>
+					<select name="checkhelo_usehrp">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					HRP Period
+					<?php tooltip('checkhelo_blacklist_hrpperiod'); ?>
+				</td>
+				<td><input type="text" name="checkhelo_hrpperiod" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					HRP Limit
+					<?php tooltip('checkhelo_blacklist_hrplimit'); ?>
+				</td>
+				<td><input type="text" name="checkhelo_hrplimit" /></td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Reject (RFC non-compliance)</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Reject Invalid
+					<?php tooltip('checkhelo_rejectinvalid'); ?>
+				</td>
+				<td>
+					<select name="checkhelo_rejectinvalid">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Reject non-literal IP
+					<?php tooltip('checkhelo_rejectip'); ?>
+				</td>
+				<td>
+					<select name="checkhelo_rejectip">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Reject Unresolvable
+					<?php tooltip('checkhelo_rejectunresolv'); ?>
+				</td>
+				<td>
+					<select name="checkhelo_rejectunresolvable">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">&nbsp;</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="checkhelo_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">HELO/EHLO Check Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['checkhelo_policyid'])) {
+?>
+		<div class="warning">Policy ID cannot be empty</div>
+<?php
+
+	# Check name
+	} elseif (empty($_POST['checkhelo_name'])) {
+?>
+		<div class="warning">Name cannot be empty</div>
+<?php
+
+
+	} else {
+
+		# Sort out using of blacklist
+		switch ($_POST['checkhelo_useblacklist']) {
+			case "0":
+				$useBlacklist = null;
+				break;
+			case "1":
+				$useBlacklist = 1;
+				break;
+			case "2":
+				$useBlacklist = 0;
+				break;
+		}
+		# Check period
+		if (empty($_POST['checkhelo_blacklistperiod'])) {
+			$blacklistPeriod = null;
+		} else {
+			$blacklistPeriod = $_POST['checkhelo_blacklistperiod'];
+		}
+
+		# Sort out using of HRP
+		switch ($_POST['checkhelo_usehrp']) {
+			case "0":
+				$useHRP = null;
+				break;
+			case "1":
+				$useHRP = 1;
+				break;
+			case "2":
+				$useHRP = 0;
+				break;
+		}
+		# Check period
+		if (empty($_POST['checkhelo_hrpperiod'])) {
+			$HRPPeriod = null;
+		} else {
+			$HRPPeriod = $_POST['checkhelo_hrpperiod'];
+		}
+		# Check limit
+		if (empty($_POST['checkhelo_hrplimit'])) {
+			$HRPLimit = null;
+		} else {
+			$HRPLimit = $_POST['checkhelo_hrplimit'];
+		}
+
+		# Sort out checking invalid HELO's
+		switch ($_POST['checkhelo_rejectinvalid']) {
+			case "0":
+				$rejectInvalid = null;
+				break;
+			case "1":
+				$rejectInvalid = 1;
+				break;
+			case "2":
+				$rejectInvalid = 0;
+				break;
+		}
+
+		# Sort out checking HELO's for IP's
+		switch ($_POST['checkhelo_rejectip']) {
+			case "0":
+				$rejectIP = null;
+				break;
+			case "1":
+				$rejectIP = 1;
+				break;
+			case "2":
+				$rejectIP = 0;
+				break;
+		}
+
+		# Sort out checking HELO's are resolvable
+		switch ($_POST['checkhelo_rejectunresolvable']) {
+			case "0":
+				$rejectUnresolvable = null;
+				break;
+			case "1":
+				$rejectUnresolvable = 1;
+				break;
+			case "2":
+				$rejectUnresolvable = 0;
+				break;
+		}
+
+		$stmt = $db->prepare("
+			INSERT INTO ${DB_TABLE_PREFIX}checkhelo
+					(
+						PolicyID,Name,
+						UseBlacklist,BlacklistPeriod,
+						UseHRP,HRPPeriod,HRPLimit,
+						RejectInvalid,RejectIP,RejectUnresolvable,
+						Comment,Disabled
+					)					
+				VALUES 
+					(
+						?,?,
+						?,?,
+						?,?,?,
+						?,?,?,
+						?,1
+					)
+		");
+		
+		$res = $stmt->execute(array(
+			$_POST['checkhelo_policyid'],
+			$_POST['checkhelo_name'],
+			$useBlacklist,$blacklistPeriod,
+			$useHRP,$HRPPeriod,$HRPLimit,
+			$rejectInvalid,$rejectIP,$rejectUnresolvable,
+			$_POST['checkhelo_comment']
+		));
+
+		if ($res) {
+?>
+			<div class="notice">HELO/EHLO check created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create HELO/EHLO check</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-blacklist-add.php b/webui/checkhelo-blacklist-add.php
new file mode 100644
index 00000000..9ed60342
--- /dev/null
+++ b/webui/checkhelo-blacklist-add.php
@@ -0,0 +1,112 @@
+<?php
+# Module: CheckHelo (blacklist) add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to blacklist" => "checkhelo-blacklist-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add HELO/EHLO Blacklist</p>
+
+	<form method="post" action="checkhelo-blacklist-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">
+					Helo
+					<?php tooltip('checkhelo_blacklist_helo'); ?>
+				</td>
+				<td><input type="text" name="blacklist_helo" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="blacklist_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">HELO/EHLO Blacklist Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['blacklist_helo'])) {
+?>
+		<div class="warning">Helo cannot be empty</div>
+<?php
+
+	} else {
+		$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}checkhelo_blacklist (Helo,Comment,Disabled) VALUES (?,?,1)");
+		
+		$res = $stmt->execute(array(
+			$_POST['blacklist_helo'],
+			$_POST['blacklist_comment']
+		));
+		
+		if ($res) {
+?>
+			<div class="notice">HELO/EHLO blacklist created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create HELO/EHLO blacklisting</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-blacklist-change.php b/webui/checkhelo-blacklist-change.php
new file mode 100644
index 00000000..94da7ca8
--- /dev/null
+++ b/webui/checkhelo-blacklist-change.php
@@ -0,0 +1,168 @@
+<?php
+# Module: CheckHelo (blacklist) change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to blacklist" => "checkhelo-blacklist-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a checkhelo blacklist was selected
+	if (isset($_POST['blacklist_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				ID, Helo, Comment, 
+				Disabled
+				
+			FROM 
+				${DB_TABLE_PREFIX}checkhelo_blacklist
+
+			WHERE 
+				ID = ?
+			");
+?>
+		<p class="pageheader">Update HELO/EHLO Blacklist</p>
+
+		<form action="checkhelo-blacklist-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="blacklist_id" value="<?php echo $_POST['blacklist_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['blacklist_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Helo
+						<?php tooltip('checkhelo_blacklist_helo'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->helo ?></td>
+					<td><input type="text" name="blacklist_helo" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="blacklist_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="blacklist_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No blacklisting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">HELO/EHLO Blacklisting Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['blacklist_helo'])) {
+		array_push($updates,"Helo = ".$db->quote($_POST['blacklist_helo']));
+	}
+	if (!empty($_POST['blacklist_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['blacklist_comment']));
+	}
+	if (isset($_POST['blacklist_disabled']) && $_POST['blacklist_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['blacklist_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}checkhelo_blacklist SET $updateStr WHERE ID = ".$db->quote($_POST['blacklist_id']));
+		if ($res) {
+?>
+			<div class="notice">HELO/EHLO blacklisting updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating HELO/EHLO blacklisting!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to HELO/EHLO blacklisting</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-blacklist-delete.php b/webui/checkhelo-blacklist-delete.php
new file mode 100644
index 00000000..4dc56440
--- /dev/null
+++ b/webui/checkhelo-blacklist-delete.php
@@ -0,0 +1,113 @@
+<?php
+# Module: CheckHelo (blacklist) delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to blacklist" => "checkhelo-blacklist-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a blacklisting was selected
+	if (isset($_POST['blacklist_id'])) {
+?>
+		<p class="pageheader">Delete HELO/EHLO blacklist</p>
+
+		<form action="checkhelo-blacklist-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="blacklist_id" value="<?php echo $_POST['blacklist_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No HELO/EHLO blacklisting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">HELO/EHLO Blacklist Delete Results</p>
+<?php
+	if (isset($_POST['blacklist_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}checkhelo_blacklist WHERE ID = ".$db->quote($_POST['blacklist_id']));
+			if ($res) {
+?>
+				<div class="notice">HELO/EHLO blacklist deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting HELO/EHLO blacklist!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">HELO/EHLO blacklist not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no whitelist ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-blacklist-main.php b/webui/checkhelo-blacklist-main.php
new file mode 100644
index 00000000..33df11f7
--- /dev/null
+++ b/webui/checkhelo-blacklist-main.php
@@ -0,0 +1,112 @@
+<?php
+# Module: CheckHelo (blacklisting)
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">HELO/EHLO Blacklistings</p>
+
+	<form id="main_form" action="checkhelo-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'checkhelo-blacklist-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'checkhelo-blacklist-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'checkhelo-blacklist-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">HELO/EHLO</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						ID, Helo, Disabled
+
+					FROM 
+						${DB_TABLE_PREFIX}checkhelo_blacklist
+
+					ORDER BY 
+						Helo
+			";
+			$res = $db->query($sql);
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="blacklist_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->helo ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-change.php b/webui/checkhelo-change.php
new file mode 100644
index 00000000..e99979d7
--- /dev/null
+++ b/webui/checkhelo-change.php
@@ -0,0 +1,481 @@
+<?php
+# Module: CheckHelo change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to HELO checks" => "checkhelo-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a helo check was selected
+	if (isset($_POST['checkhelo_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				${DB_TABLE_PREFIX}checkhelo.ID, ${DB_TABLE_PREFIX}checkhelo.PolicyID, ${DB_TABLE_PREFIX}checkhelo.Name, 
+			
+				${DB_TABLE_PREFIX}checkhelo.UseBlacklist, ${DB_TABLE_PREFIX}checkhelo.BlacklistPeriod, 
+
+				${DB_TABLE_PREFIX}checkhelo.UseHRP, ${DB_TABLE_PREFIX}checkhelo.HRPPeriod, ${DB_TABLE_PREFIX}checkhelo.HRPLimit,
+				
+				${DB_TABLE_PREFIX}checkhelo.RejectInvalid, ${DB_TABLE_PREFIX}checkhelo.RejectIP, ${DB_TABLE_PREFIX}checkhelo.RejectUnresolvable,
+
+				${DB_TABLE_PREFIX}checkhelo.Comment, 
+				${DB_TABLE_PREFIX}checkhelo.Disabled,
+				
+				${DB_TABLE_PREFIX}policies.Name AS PolicyName
+				
+			FROM 
+				${DB_TABLE_PREFIX}checkhelo, ${DB_TABLE_PREFIX}policies 
+
+			WHERE 
+				${DB_TABLE_PREFIX}checkhelo.ID = ?
+				AND ${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}checkhelo.PolicyID
+			");
+?>
+		<p class="pageheader">Update HELO/EHLO Check</p>
+
+		<form action="checkhelo-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="checkhelo_id" value="<?php echo $_POST['checkhelo_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['checkhelo_id']));
+
+			$row = $stmt->fetchObject();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="checkhelo_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Link to policy</td>
+					<td class="oldval"><?php echo $row->policyname ?></td>
+					<td>
+						<select name="checkhelo_policyid">
+							<option value="">--</option>
+<?php
+							$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+							while ($row2 = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row2->id ?>" ><?php echo $row2->name ?></option>
+<?php
+							}
+							$res->closeCursor();
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Blacklisting</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Use Blacklist</td>
+					<td class="oldval"><?php 
+							switch ($row->useblacklist) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 0:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkhelo_useblacklist">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Blacklist Period
+						<?php tooltip('checkhelo_blacklist_period'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->blacklistperiod) ? '*inherited*' : $row->blacklistperiod ?></td>
+					<td>
+						<input type="text" name="checkhelo_blacklistperiod" />
+						<select name="checkhelo_blacklistperiod_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Randomization Prevention</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Use HRP
+					</td>
+					<td class="oldval"><?php 
+							switch ($row->usehrp) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 0:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkhelo_usehrp">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						HRP Period
+						<?php tooltip('checkhelo_blacklist_hrpperiod'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->hrpperiod) ? '*inherited*' : $row->hrpperiod ?></td>
+					<td>
+						<input type="text" name="checkhelo_hrpperiod" />
+						<select name="checkhelo_hrpperiod_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						HRP Limit
+						<?php tooltip('checkhelo_blacklist_hrplimit'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->hrplimit) ? '*inherited*' : $row->hrplimit ?></td>
+					<td>
+						<input type="text" name="checkhelo_hrplimit" />
+						<select name="checkhelo_hrplimit_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Reject (RFC non-compliance)</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Reject Invalid
+						<?php tooltip('checkhelo_rejectinvalid'); ?>
+					</td>
+					<td class="oldval"><?php 
+							switch ($row->rejectinvalid) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 0:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkhelo_rejectinvalid">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Reject non-literal IP
+						<?php tooltip('checkhelo_rejectip'); ?>
+					</td>
+					<td class="oldval"><?php 
+							switch ($row->rejectip) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 0:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkhelo_rejectip">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Reject Unresolvable
+						<?php tooltip('checkhelo_rejectunresolv'); ?>
+					</td>
+					<td class="oldval"><?php 
+							switch ($row->rejectunresolvable) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 0:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkhelo_rejectunresolvable">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">&nbsp;</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="checkhelo_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="checkhelo_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No HELO/EHLO check selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">HELO/EHLO Update Results</p>
+<?php
+	$updates = array();
+
+	# Process all our options below
+	if (!empty($_POST['checkhelo_policyid'])) {
+		array_push($updates,"PolicyID = ".$db->quote($_POST['checkhelo_policyid']));
+	}
+
+	if (!empty($_POST['checkhelo_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['checkhelo_name']));
+	}
+
+	if (!empty($_POST['checkhelo_useblacklist'])) {
+		if ($_POST['checkhelo_useblacklist'] == "1") {
+			$useblacklist = null;
+		} elseif ($_POST['checkhelo_useblacklist'] == "2") {
+			$useblacklist = 1;
+		} elseif ($_POST['checkhelo_useblacklist'] == "3") {
+			$useblacklist = 0;
+		}
+		array_push($updates,"UseBlacklist = ".$db->quote($useblacklist));
+	}
+	if (!empty($_POST['checkhelo_blacklistperiod_m'])) {
+		if ($_POST['checkhelo_blacklistperiod_m'] == "1") {
+			$blacklistperiod = null;
+		} elseif ($_POST['checkhelo_blacklistperiod_m'] == "2") {
+			$blacklistperiod = $_POST['checkhelo_blacklistperiod'];
+		}
+		array_push($updates,"BlacklistPeriod = ".$db->quote($blacklistperiod));
+	}
+
+	if (!empty($_POST['checkhelo_usehrp'])) {
+		if ($_POST['checkhelo_usehrp'] == "1") {
+			$usehrp = null;
+		} elseif ($_POST['checkhelo_usehrp'] == "2") {
+			$usehrp = 1;
+		} elseif ($_POST['checkhelo_usehrp'] == "3") {
+			$usehrp = 0;
+		}
+		array_push($updates,"UseHRP = ".$db->quote($usehrp));
+	}
+	if (!empty($_POST['checkhelo_hrpperiod_m'])) {
+		if ($_POST['checkhelo_hrpperiod_m'] == "1") {
+			$hrpperiod = null;
+		} elseif ($_POST['checkhelo_hrpperiod_m'] == "2") {
+			$hrpperiod = $_POST['checkhelo_hrpperiod'];
+		}
+		array_push($updates,"HRPPeriod = ".$db->quote($hrpperiod));
+	}
+	if (!empty($_POST['checkhelo_hrplimit_m'])) {
+		if ($_POST['checkhelo_hrplimit_m'] == "1") {
+			$hrplimit = null;
+		} elseif ($_POST['checkhelo_hrplimit_m'] == "2") {
+			$hrplimit = $_POST['checkhelo_hrplimit'];
+		}
+		array_push($updates,"HRPLimit = ".$db->quote($hrplimit));
+	}
+
+	if (!empty($_POST['checkhelo_rejectinvalid'])) {
+		if ($_POST['checkhelo_rejectinvalid'] == "1") {
+			$rejectinvalid = null;
+		} elseif ($_POST['checkhelo_rejectinvalid'] == "2") {
+			$rejectinvalid = 1;
+		} elseif ($_POST['checkhelo_rejectinvalid'] == "3") {
+			$rejectinvalid = 0;
+		}
+		array_push($updates,"RejectInvalid = ".$db->quote($rejectinvalid));
+	}
+
+	if (!empty($_POST['checkhelo_rejectip'])) {
+		if ($_POST['checkhelo_rejectip'] == "1") {
+			$rejectip = null;
+		} elseif ($_POST['checkhelo_rejectip'] == "2") {
+			$rejectip = 1;
+		} elseif ($_POST['checkhelo_rejectip'] == "3") {
+			$rejectip = 0;
+		}
+		array_push($updates,"RejectIP = ".$db->quote($rejectip));
+	}
+
+	if (!empty($_POST['checkhelo_rejectunresolvable'])) {
+		if ($_POST['checkhelo_rejectunresolvable'] == "1") {
+			$rejectunresolvable = null;
+		} elseif ($_POST['checkhelo_rejectunresolvable'] == "2") {
+			$rejectunresolvable = 1;
+		} elseif ($_POST['checkhelo_rejectunresolvable'] == "3") {
+			$rejectunresolvable = 0;
+		}
+		array_push($updates,"RejectUnresolvable = ".$db->quote($rejectunresolvable));
+	}
+
+	if (!empty($_POST['checkhelo_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['checkhelo_comment']));
+	}
+	if (isset($_POST['checkhelo_disabled']) && $_POST['checkhelo_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['checkhelo_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}checkhelo SET $updateStr WHERE ID = ".$db->quote($_POST['checkhelo_id']));
+		if ($res) {
+?>
+			<div class="notice">HELO/EHLO check updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating HELO/EHLO check!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to HELO/EHLO check</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-delete.php b/webui/checkhelo-delete.php
new file mode 100644
index 00000000..f607b344
--- /dev/null
+++ b/webui/checkhelo-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Module: CheckHelo delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to HELO checks" => "checkhelo-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a helo/helo check was selected
+	if (isset($_POST['checkhelo_id'])) {
+?>
+		<p class="pageheader">Delete HELO/EHLO Check</p>
+
+		<form action="checkhelo-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="checkhelo_id" value="<?php echo $_POST['checkhelo_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No HELO/EHLO check selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">HELO/EHLO Check Delete Results</p>
+<?php
+	if (isset($_POST['checkhelo_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}checkhelo WHERE ID = ".$db->quote($_POST['checkhelo_id']));
+			if ($res) {
+?>
+				<div class="notice">HELO/EHLO check deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting HELO/EHLO check!</div>
+				<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">HELO/EHLO check not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no HELO/EHLO ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/checkhelo-main.php b/webui/checkhelo-main.php
new file mode 100644
index 00000000..8b1c7c61
--- /dev/null
+++ b/webui/checkhelo-main.php
@@ -0,0 +1,119 @@
+<?php
+# Module: CheckHelo
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">HELO/EHLO Checks</p>
+
+	<form id="main_form" action="checkhelo-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'checkhelo-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'checkhelo-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'checkhelo-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Policy</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						${DB_TABLE_PREFIX}checkhelo.ID, ${DB_TABLE_PREFIX}checkhelo.Name, ${DB_TABLE_PREFIX}checkhelo.Disabled,
+						${DB_TABLE_PREFIX}policies.Name AS PolicyName
+
+					FROM 
+						${DB_TABLE_PREFIX}checkhelo, ${DB_TABLE_PREFIX}policies
+
+					WHERE
+						${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}checkhelo.PolicyID
+
+					ORDER BY 
+						${DB_TABLE_PREFIX}policies.Name
+			";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="checkhelo_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->policyname ?></td>
+					<td><?php echo $row->name ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-whitelist-add.php b/webui/checkhelo-whitelist-add.php
new file mode 100644
index 00000000..fdcd3d84
--- /dev/null
+++ b/webui/checkhelo-whitelist-add.php
@@ -0,0 +1,117 @@
+<?php
+# Module: CheckHelo (whitelist) add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to whitelist" => "checkhelo-whitelist-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add HELO/EHLO Whitelist</p>
+
+	<form method="post" action="checkhelo-whitelist-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">
+					Source
+					<?php tooltip('checkhelo_whitelist_source'); ?>
+				</td>
+				<td>
+					<select id="whitelist_type" name="whitelist_type">
+						<option value="SenderIP">Sender IP</option>
+					</select>
+					<input type="text" name="whitelist_source" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="whitelist_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">HELO/EHLO Whitelist Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['whitelist_source'])) {
+?>
+		<div class="warning">Source cannot be empty</div>
+<?php
+
+	} else {
+		$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}checkhelo_whitelist (Source,Comment,Disabled) VALUES (?,?,1)");
+		
+		$res = $stmt->execute(array(
+			$_POST['whitelist_type'] . ":" . $_POST['whitelist_source'],
+			$_POST['whitelist_comment']
+		));
+		
+		if ($res) {
+?>
+			<div class="notice">HELO/EHLO whitelist created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create HELO/EHLO whitelisting</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-whitelist-change.php b/webui/checkhelo-whitelist-change.php
new file mode 100644
index 00000000..b180d14a
--- /dev/null
+++ b/webui/checkhelo-whitelist-change.php
@@ -0,0 +1,173 @@
+<?php
+# Module: CheckHelo (whitelist) change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to whitelist" => "checkhelo-whitelist-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a whitelist was selected
+	if (isset($_POST['whitelist_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				ID, Source, Comment, 
+				Disabled
+				
+			FROM 
+				${DB_TABLE_PREFIX}checkhelo_whitelist
+
+			WHERE 
+				ID = ?
+			");
+?>
+		<p class="pageheader">Update HELO/EHLO Whitelist</p>
+
+		<form action="checkhelo-whitelist-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="whitelist_id" value="<?php echo $_POST['whitelist_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['whitelist_id']));
+
+			$row = $stmt->fetchObject();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Source
+						<?php tooltip('checkhelo_whitelist_source'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->source ?></td>
+					<td>
+						<select id="whitelist_type" name="whitelist_type">
+							<option value="">--</option>
+							<option value="SenderIP">Sender IP</option>
+						</select>
+						<input type="text" name="whitelist_source" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="whitelist_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="whitelist_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No whitelisting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">HELO/EHLO Whitelisting Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['whitelist_type'])) {
+		array_push($updates,"Source = ".$db->quote($_POST['whitelist_type'].":".$_POST['whitelist_source']));
+	}
+	if (!empty($_POST['whitelist_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['whitelist_comment']));
+	}
+	if (isset($_POST['whitelist_disabled']) && $_POST['whitelist_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['whitelist_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}checkhelo_whitelist SET $updateStr WHERE ID = ".$db->quote($_POST['whitelist_id']));
+		if ($res) {
+?>
+			<div class="notice">HELO/EHLO whitelisting updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating HELO/EHLO whitelisting!</div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to HELO/EHLO whitelisting</div>
+		<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkhelo-whitelist-delete.php b/webui/checkhelo-whitelist-delete.php
new file mode 100644
index 00000000..6f6826f6
--- /dev/null
+++ b/webui/checkhelo-whitelist-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Module: CheckHelo (whitelist) delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to whitelist" => "checkhelo-whitelist-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a whitelisting was selected
+	if (isset($_POST['whitelist_id'])) {
+?>
+		<p class="pageheader">Delete HELO/EHLO whitelist</p>
+
+		<form action="checkhelo-whitelist-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="whitelist_id" value="<?php echo $_POST['whitelist_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No HELO/EHLO whitelisting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">HELO/EHLO Whitelist Delete Results</p>
+<?php
+	if (isset($_POST['whitelist_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}checkhelo_whitelist WHERE ID = ".$db->quote($_POST['whitelist_id']));
+			if ($res) {
+?>
+				<div class="notice">HELO/EHLO whitelist deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting HELO/EHLO whitelist!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">HELO/EHLO whitelist not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no whitelist ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/checkhelo-whitelist-main.php b/webui/checkhelo-whitelist-main.php
new file mode 100644
index 00000000..e3d168cc
--- /dev/null
+++ b/webui/checkhelo-whitelist-main.php
@@ -0,0 +1,112 @@
+<?php
+# Module: CheckHelo (whitelisting)
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">HELO/EHLO Whitelistings</p>
+
+	<form id="main_form" action="checkhelo-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'checkhelo-whitelist-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'checkhelo-whitelist-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'checkhelo-whitelist-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Source</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						ID, Source, Disabled
+
+					FROM 
+						${DB_TABLE_PREFIX}checkhelo_whitelist
+
+					ORDER BY 
+						Source
+			";
+			$res = $db->query($sql);
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="whitelist_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->source ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkspf-add.php b/webui/checkspf-add.php
new file mode 100644
index 00000000..b4a3902e
--- /dev/null
+++ b/webui/checkspf-add.php
@@ -0,0 +1,214 @@
+<?php
+# Module: CheckSPF add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to SPF checks" => "checkspf-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add SPF Check</p>
+
+	<form method="post" action="checkspf-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="checkspf_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Link to policy</td>
+				<td>
+					<select name="checkspf_policyid">
+<?php
+						$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+						while ($row = $res->fetchObject()) {
+?>
+							<option value="<?php echo $row->id ?>"><?php echo $row->name ?></option>
+<?php
+						}
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Use SPF</td>
+				<td>
+					<select name="checkspf_usespf">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Reject Failed SPF
+					<?php tooltip('checkspf_rejectfailed'); ?>
+				</td>
+				<td>
+					<select name="checkspf_rejectfailed">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Add SPF Header
+					<?php tooltip('checkspf_addheader'); ?>
+				</td>
+				<td>
+					<select name="checkspf_addheader">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="checkspf_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">SPF Check Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['checkspf_policyid'])) {
+?>
+		<div class="warning">Policy ID cannot be empty</div>
+<?php
+
+	# Check name
+	} elseif (empty($_POST['checkspf_name'])) {
+?>
+		<div class="warning">Name cannot be empty</div>
+<?php
+
+	} else {
+		# Sort out if we going to use SPF or not
+		switch ($_POST['checkspf_usespf']) {
+			case "0":
+				$useSPF = null;
+				break;
+			case "1":
+				$useSPF = 1;
+				break;
+			case "2":
+				$useSPF = 2;
+				break;
+		}
+
+		# And if we reject on failed
+		switch ($_POST['checkspf_rejectfailed']) {
+			case "0":
+				$rejectFailed = null;
+				break;
+			case "1":
+				$rejectFailed = 1;
+				break;
+			case "2":
+				$rejectFailed = 2;
+				break;
+		}
+
+		# And if we add the spf header
+		switch ($_POST['checkspf_addheader']) {
+			case "0":
+				$addHeader = null;
+				break;
+			case "1":
+				$addHeader = 1;
+				break;
+			case "2":
+				$addHeader = 2;
+				break;
+		}
+
+		$stmt = $db->prepare("
+			INSERT INTO ${DB_TABLE_PREFIX}checkspf 
+				(PolicyID,Name,UseSPF,RejectFailedSPF,AddSPFHeader,Comment,Disabled) 
+			VALUES 
+				(?,?,?,?,?,?,1)
+		");
+		
+		$res = $stmt->execute(array(
+			$_POST['checkspf_policyid'],
+			$_POST['checkspf_name'],
+			$useSPF,
+			$rejectFailed,
+			$addHeader,
+			$_POST['checkspf_comment']
+		));
+		
+		if ($res) {
+?>
+			<div class="notice">SPF check created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create SPF check</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkspf-change.php b/webui/checkspf-change.php
new file mode 100644
index 00000000..ea94b4d7
--- /dev/null
+++ b/webui/checkspf-change.php
@@ -0,0 +1,306 @@
+<?php
+# Module: CheckSPF change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to SPF checks" => "checkspf-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a SPF check was selected
+	if (isset($_POST['checkspf_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				${DB_TABLE_PREFIX}checkspf.ID, ${DB_TABLE_PREFIX}checkspf.PolicyID, ${DB_TABLE_PREFIX}checkspf.Name, 
+				${DB_TABLE_PREFIX}checkspf.UseSPF, ${DB_TABLE_PREFIX}checkspf.RejectFailedSPF, 
+				${DB_TABLE_PREFIX}checkspf.AddSPFHeader,
+				${DB_TABLE_PREFIX}checkspf.Comment, ${DB_TABLE_PREFIX}checkspf.Disabled,
+				
+				${DB_TABLE_PREFIX}policies.Name AS PolicyName
+				
+			FROM 
+				${DB_TABLE_PREFIX}checkspf, ${DB_TABLE_PREFIX}policies 
+
+			WHERE 
+				${DB_TABLE_PREFIX}checkspf.ID = ?
+				AND ${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}checkspf.PolicyID
+			");
+?>
+		<p class="pageheader">Update SPF Check</p>
+
+		<form action="checkspf-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="checkspf_id" value="<?php echo $_POST['checkspf_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['checkspf_id']));
+
+			$row = $stmt->fetchObject();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="checkspf_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Link to policy</td>
+					<td class="oldval"><?php echo $row->policyname ?></td>
+					<td>
+						<select name="checkspf_policyid">
+							<option value="">--</option>
+<?php
+							$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+							while ($row2 = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row2->id ?>" ><?php echo $row2->name ?></option>
+<?php
+							}
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Use SPF</td>
+					<td class="oldval"><?php 
+							switch ($row->usespf) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 2:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkspf_usespf">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Reject Failed SPF
+						<?php tooltip('checkspf_rejectfailed'); ?>
+					</td>
+					<td class="oldval"><?php 
+							switch ($row->rejectfailedspf) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 2:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkspf_rejectfailed">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Add SPF Header
+						<?php tooltip('checkspf_addheader'); ?>
+					</td>
+					<td class="oldval"><?php 
+							switch ($row->addspfheader) {
+								case null:
+									echo "Inherit";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								case 2:
+									echo "No";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="checkspf_addheader">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="checkspf_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="checkspf_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No access control selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">SPF Check Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['checkspf_policyid'])) {
+		array_push($updates,"PolicyID = ".$db->quote($_POST['checkspf_policyid']));
+	}
+	if (!empty($_POST['checkspf_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['checkspf_name']));
+	}
+	if (!empty($_POST['checkspf_usespf'])) {
+		if ($_POST['checkspf_usespf'] == "1") {
+			$usespf = null;
+		} elseif ($_POST['checkspf_usespf'] == "2") {
+			$usespf = 1;
+		} elseif ($_POST['checkspf_usespf'] == "3") {
+			$usespf = 2;
+		}
+		array_push($updates,"UseSPF = ".$db->quote($usespf));
+	}
+	if (!empty($_POST['checkspf_rejectfailed'])) {
+		if ($_POST['checkspf_rejectfailed'] == "1") {
+			$rejectfailed = null;
+		} elseif ($_POST['checkspf_rejectfailed'] == "2") {
+			$rejectfailed = 1;
+		} elseif ($_POST['checkspf_rejectfailed'] == "3") {
+			$rejectfailed = 2;
+		}
+		array_push($updates,"RejectFailedSPF = ".$db->quote($rejectfailed));
+	}
+	if (!empty($_POST['checkspf_addheader'])) {
+		if ($_POST['checkspf_addheader'] == "1") {
+			$addheader = null;
+		} elseif ($_POST['checkspf_addheader'] == "2") {
+			$addheader = 1;
+		} elseif ($_POST['checkspf_addheader'] == "3") {
+			$addheader = 2;
+		}
+		array_push($updates,"AddSPFHeader = ".$db->quote($addheader));
+	}
+	if (!empty($_POST['checkspf_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['checkspf_comment']));
+	}
+	if (isset($_POST['checkspf_disabled']) && $_POST['checkspf_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['checkspf_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}checkspf SET $updateStr WHERE ID = ".$db->quote($_POST['checkspf_id']));
+		if ($res) {
+?>
+			<div class="notice">SPF check updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating SPF check!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to SPF check</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkspf-delete.php b/webui/checkspf-delete.php
new file mode 100644
index 00000000..0a7f2062
--- /dev/null
+++ b/webui/checkspf-delete.php
@@ -0,0 +1,113 @@
+<?php
+# Module: CheckSPF delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to SPF checks" => "checkspf-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a SPF check was selected
+	if (isset($_POST['checkspf_id'])) {
+?>
+		<p class="pageheader">Delete SPF Check</p>
+
+		<form action="checkspf-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="checkspf_id" value="<?php echo $_POST['checkspf_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No SPF check selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">SPF Check Delete Results</p>
+<?php
+	if (isset($_POST['checkspf_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}checkspf WHERE ID = ".$db->quote($_POST['checkspf_id']));
+			if ($res) {
+?>
+				<div class="notice">SPF check deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting SPF check!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">SPF check not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no SPF check ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/checkspf-main.php b/webui/checkspf-main.php
new file mode 100644
index 00000000..09df2ac7
--- /dev/null
+++ b/webui/checkspf-main.php
@@ -0,0 +1,119 @@
+<?php
+# Module: CheckSPF
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">SPF Checks</p>
+
+	<form id="main_form" action="checkspf-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'checkspf-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'checkspf-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'checkspf-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Policy</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						${DB_TABLE_PREFIX}checkspf.ID, ${DB_TABLE_PREFIX}checkspf.Name, ${DB_TABLE_PREFIX}checkspf.Disabled,
+						${DB_TABLE_PREFIX}policies.Name AS PolicyName
+
+					FROM 
+						${DB_TABLE_PREFIX}checkspf, ${DB_TABLE_PREFIX}policies
+
+					WHERE
+						${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}checkspf.PolicyID
+
+					ORDER BY 
+						${DB_TABLE_PREFIX}policies.Name
+			";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="checkspf_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->policyname ?></td>
+					<td><?php echo $row->name ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/greylisting-add.php b/webui/greylisting-add.php
new file mode 100644
index 00000000..1b02b617
--- /dev/null
+++ b/webui/greylisting-add.php
@@ -0,0 +1,387 @@
+<?php
+# Module: Greylisting add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to greylisting" => "greylisting-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add Greylisting</p>
+
+	<form method="post" action="greylisting-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="greylisting_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Link to policy</td>
+				<td>
+					<select name="greylisting_policyid">
+<?php
+						$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+						while ($row = $res->fetchObject()) {
+?>
+							<option value="<?php echo $row->id ?>"><?php echo $row->name ?></option>
+<?php
+						}
+						$res->closeCursor();
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Greylisting</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Use Greylisting</td>
+				<td>
+					<select name="greylisting_usegreylisting">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Greylist Period
+					<?php tooltip('greylisting_period'); ?>
+				</td>
+				<td><input type="text" name="greylisting_period" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Track
+					<?php tooltip('greylisting_track'); ?>
+				</td>
+				<td>
+					<select id="greylisting_track" name="greylisting_track"
+							onchange="
+								var myobj = document.getElementById('greylisting_track');
+								var myobj2 = document.getElementById('greylisting_trackextra');
+
+								if (myobj.selectedIndex == 0) {
+									myobj2.disabled = false;
+									myobj2.value = '/32';
+								} else if (myobj.selectedIndex != 0) {
+									myobj2.disabled = true;
+									myobj2.value = 'n/a';
+								}
+					">
+						<option value="SenderIP">Sender IP</option>
+					</select>
+					<input type="text" id="greylisting_trackextra" name="greylisting_trackextra" size="18" value="/32" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Greylist Auth Validity
+					<?php tooltip('greylisting_auth_validity'); ?>
+				</td>
+				<td><input type="text" name="greylisting_authvalidity" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					Greylist UnAuth Validity
+					<?php tooltip('greylisting_unauth_validity'); ?>
+				</td>
+				<td><input type="text" name="greylisting_unauthvalidity" /></td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Auto-Whitelisting</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Use AWL</td>
+				<td>
+					<select name="greylisting_useawl">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					AWL For Period
+					<?php tooltip('greylisting_awl_period'); ?>
+				</td>
+				<td><input type="text" name="greylisting_awlperiod" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					AWL After Count
+					<?php tooltip('greylisting_awl_count'); ?>
+				</td>
+				<td><input type="text" name="greylisting_awlcount" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					AWL After Percentage
+					<?php tooltip('greylisting_awl_percentage'); ?>
+				</td>
+				<td><input type="text" name="greylisting_awlpercentage" /> (blank = inherit, 0 = disable)</td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">Auto-Blacklisting</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Use ABL</td>
+				<td>
+					<select name="greylisting_useabl">
+						<option value="0" selected="selected">Inherit</option>
+						<option value="1">Yes</option>
+						<option value="2">No</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					ABL For Period
+					<?php tooltip('greylisting_abl_period'); ?>
+				</td>
+				<td><input type="text" name="greylisting_ablperiod" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					ABL After Count
+					<?php tooltip('greylisting_abl_count'); ?>
+				</td>
+				<td><input type="text" name="greylisting_ablcount" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">
+					ABL After Percentage
+					<?php tooltip('greylisting_abl_percentage'); ?>
+				</td>
+				<td><input type="text" name="greylisting_ablpercentage" /></td>
+			</tr>
+			<tr>
+				<td colspan="2" class="textcenter" style="border-bottom: 1px dashed black;">&nbsp;</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="greylisting_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Greylisting Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['greylisting_policyid'])) {
+?>
+		<div class="warning">Policy ID cannot be empty</div>
+<?php
+
+	# Check name
+	} elseif (empty($_POST['greylisting_name'])) {
+?>
+		<div class="warning">Name cannot be empty</div>
+<?php
+
+
+	} else {
+
+		# Sort out using of blacklist
+		switch ($_POST['greylisting_usegreylisting']) {
+			case "0":
+				$useGreylisting = null;
+				break;
+			case "1":
+				$useGreylisting = 1;
+				break;
+			case "2":
+				$useGreylisting = 0;
+				break;
+		}
+		# Check period
+		if (empty($_POST['greylisting_period'])) {
+			$greylistPeriod = null;
+		} else {
+			$greylistPeriod = $_POST['greylisting_period'];
+		}
+
+		# Check validity
+		if (empty($_POST['greylisting_authvalidity'])) {
+			$greylistAuthValidity = null;
+		} else {
+			$greylistAuthValidity = $_POST['greylisting_authvalidity'];
+		}
+		if (empty($_POST['greylisting_unauthvalidity'])) {
+			$greylistUnAuthValidity = null;
+		} else {
+			$greylistUnAuthValidity = $_POST['greylisting_unauthvalidity'];
+		}
+
+		# Sort out using of AWL
+		switch ($_POST['greylisting_useawl']) {
+			case "0":
+				$useAWL = null;
+				break;
+			case "1":
+				$useAWL = 1;
+				break;
+			case "2":
+				$useAWL = 0;
+				break;
+		}
+		# AWL period
+		if (empty($_POST['greylisting_awlperiod'])) {
+			$AWLPeriod = null;
+		} else {
+			$AWLPeriod = $_POST['greylisting_awlperiod'];
+		}
+		# AWL count 
+		if (empty($_POST['greylisting_awlcount'])) {
+			$AWLCount = null;
+		} else {
+			$AWLCount = $_POST['greylisting_awlcount'];
+		}
+		# AWL percentage 
+		if (!isset($_POST['greylisting_awlpercentage']) || $_POST['greylisting_awlpercentage'] == "") {
+			$AWLPercentage = null;
+		} else {
+			$AWLPercentage = $_POST['greylisting_awlpercentage'];
+		}
+
+		# Sort out using of ABL
+		switch ($_POST['greylisting_useabl']) {
+			case "0":
+				$useABL = null;
+				break;
+			case "1":
+				$useABL = 1;
+				break;
+			case "2":
+				$useABL = 0;
+				break;
+		}
+		# ABL period
+		if (empty($_POST['greylisting_ablperiod'])) {
+			$ABLPeriod = null;
+		} else {
+			$ABLPeriod = $_POST['greylisting_ablperiod'];
+		}
+		# ABL count 
+		if (empty($_POST['greylisting_ablcount'])) {
+			$ABLCount = null;
+		} else {
+			$ABLCount = $_POST['greylisting_ablcount'];
+		}
+		# ABL percentage 
+		if (!isset($_POST['greylisting_ablpercentage']) || $_POST['greylisting_ablpercentage'] == "") {
+			$ABLPercentage = null;
+		} else {
+			$ABLPercentage = $_POST['greylisting_ablpercentage'];
+		}
+
+		$stmt = $db->prepare("
+			INSERT INTO ${DB_TABLE_PREFIX}greylisting
+					(
+						PolicyID,Name,
+						UseGreylisting,GreylistPeriod,
+						Track,
+						GreylistAuthValidity, GreylistUnAuthValidity,
+
+						UseAutoWhitelist,AutoWhitelistPeriod,AutoWhitelistCount,AutoWhitelistPercentage,
+						UseAutoBlacklist,AutoBlacklistPeriod,AutoBlacklistCount,AutoBlacklistPercentage,
+
+						Comment,Disabled
+					)					
+				VALUES 
+					(
+						?,?,
+						?,?,
+						?,
+						?,?,
+						?,?,?,?,
+						?,?,?,?,
+						?,1
+					)
+		");
+		
+		$res = $stmt->execute(array(
+			$_POST['greylisting_policyid'],
+			$_POST['greylisting_name'],
+
+			$useGreylisting,$greylistPeriod,
+			$_POST['greylisting_track'] . ":" . $_POST['greylisting_trackextra'],
+			$greylistAuthValidity,$greylistUnAuthValidity,
+
+			$useAWL,$AWLPeriod,$AWLCount,$AWLPercentage,
+			$useABL,$ABLPeriod,$ABLCount,$ABLPercentage,
+
+			$_POST['greylisting_comment']
+		));
+
+		if ($res) {
+?>
+			<div class="notice">Greylisting created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create Greylisting</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/greylisting-change.php b/webui/greylisting-change.php
new file mode 100644
index 00000000..175be215
--- /dev/null
+++ b/webui/greylisting-change.php
@@ -0,0 +1,632 @@
+<?php
+# Module: Greylisting change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to greylisting" => "greylisting-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a ${DB_TABLE_PREFIX}greylisting was selected
+	if (isset($_POST['greylisting_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				${DB_TABLE_PREFIX}greylisting.ID, ${DB_TABLE_PREFIX}greylisting.PolicyID, ${DB_TABLE_PREFIX}greylisting.Name, 
+			
+				${DB_TABLE_PREFIX}greylisting.UseGreylisting, ${DB_TABLE_PREFIX}greylisting.GreylistPeriod, 
+
+				${DB_TABLE_PREFIX}greylisting.Track, ${DB_TABLE_PREFIX}greylisting.GreylistAuthValidity, 
+				${DB_TABLE_PREFIX}greylisting.GreylistUnAuthValidity,
+
+				${DB_TABLE_PREFIX}greylisting.useAutoWhitelist, ${DB_TABLE_PREFIX}greylisting.AutoWhitelistPeriod, 
+				${DB_TABLE_PREFIX}greylisting.AutoWhitelistCount, ${DB_TABLE_PREFIX}greylisting.AutoWhitelistPercentage,
+
+				${DB_TABLE_PREFIX}greylisting.useAutoBlacklist, ${DB_TABLE_PREFIX}greylisting.AutoBlacklistPeriod, 
+				${DB_TABLE_PREFIX}greylisting.AutoBlacklistCount, ${DB_TABLE_PREFIX}greylisting.AutoBlacklistPercentage,
+
+				${DB_TABLE_PREFIX}greylisting.Comment, 
+				${DB_TABLE_PREFIX}greylisting.Disabled,
+				
+				${DB_TABLE_PREFIX}policies.Name AS PolicyName
+				
+			FROM 
+				${DB_TABLE_PREFIX}greylisting, ${DB_TABLE_PREFIX}policies 
+
+			WHERE 
+				${DB_TABLE_PREFIX}greylisting.ID = ?
+				AND ${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}greylisting.PolicyID
+			");
+?>
+		<p class="pageheader">Update Greylisting</p>
+
+		<form action="greylisting-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="greylisting_id" value="<?php echo $_POST['greylisting_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['greylisting_id']));
+			
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="greylisting_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Link to policy</td>
+					<td class="oldval"><?php echo $row->policyname ?></td>
+					<td>
+						<select name="greylisting_policyid">
+							<option value="">--</option>
+<?php
+							$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+							while ($row2 = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row2->id ?>" ><?php echo $row2->name ?></option>
+<?php
+							}
+							$res->closeCursor();
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Greylisting</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Use Greylisting</td>
+					<td class="oldval"><?php 
+							switch ($row->usegreylisting) {
+								case null:
+									echo "Inherit";
+									break;
+								case 0:
+									echo "No";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="greylisting_usegreylisting">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Greylist Period
+						<?php tooltip('greylisting_period'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->greylistperiod) ? '*inherited*' : $row->greylistperiod ?></td>
+					<td>
+						<input type="text" name="greylisting_period" />
+						<select name="greylisting_period_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Track
+						<?php tooltip('greylisting_track'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->track ?></td>
+					<td>
+						<select id="greylisting_track" name="greylisting_track"
+								onChange="
+									var myobj = document.getElementById('greylisting_track');
+									var myobj2 = document.getElementById('greylisting_trackextra');
+
+									if (myobj.selectedIndex == 1) {
+										myobj2.disabled = false;
+										myobj2.value = '/32';
+									} else if (myobj.selectedIndex != 1) {
+										myobj2.disabled = true;
+										myobj2.value = 'n/a';
+									}
+							">
+							<option value="">--</option>
+							<option value="SenderIP">Sender IP</option>
+						</select>
+						<input type="text" id="greylisting_trackextra" name="greylisting_trackextra" size="18" value="n/a" disabled="disabled" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Greylist Auth Validity
+						<?php tooltip('greylisting_auth_validity'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->greylistauthvalidity) ? '*inherited*' : $row->greylistauthvalidity ?></td>
+					<td>
+						<input type="text" name="greylisting_authvalidity" />
+						<select name="greylisting_authvalidity_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Greylist UnAuth Validity
+						<?php tooltip('greylisting_unauth_validity'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->greylistunauthvalidity) ? '*inherited*' : $row->greylistunauthvalidity ?></td>
+					<td>
+						<input type="text" name="greylisting_unauthvalidity" />
+						<select name="greylisting_unauthvalidity_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Auto-Whitelisting</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Use AWL</td>
+					<td class="oldval"><?php 
+							switch ($row->useautowhitelist) {
+								case null:
+									echo "Inherit";
+									break;
+								case 0:
+									echo "No";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="greylisting_useawl">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						AWL Period
+						<?php tooltip('greylisting_awl_period'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->autowhitelistperiod) ? '*inherited*' : $row->autowhitelistperiod ?></td>
+					<td>
+						<input type="text" name="greylisting_awlperiod" />
+						<select name="greylisting_awlperiod_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						AWL After Count
+						<?php tooltip('greylisting_awl_count'); ?>
+					</td>
+					<td class="oldval">
+							<?php 
+								if (is_null($row->autowhitelistcount)) {
+									echo '*inherited*';
+								} elseif ($row->autowhitelistcount  == "0") {
+									echo '*disabled*';
+								} else {
+									echo $row->autowhitelistcount;
+								}
+							?>
+					</td>
+					<td>
+						<input type="text" name="greylisting_awlcount" />
+						<select name="greylisting_awlcount_m">
+							<option value="">--</option>
+							<option value="0">Disable</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						AWL After Percentage
+						<?php tooltip('greylisting_awl_percentage'); ?>
+					</td>
+					<td class="oldval">
+							<?php 
+								if (is_null($row->autowhitelistpercentage)) {
+									echo '*inherited*';
+								} elseif ($row->autowhitelistpercentage  == "0") {
+									echo '*disabled*';
+								} else {
+									echo $row->autowhitelistpercentage;
+								}
+							?>
+					</td>
+					<td>
+						<input type="text" name="greylisting_awlpercentage" />
+						<select name="greylisting_awlpercentage_m">
+							<option value="">--</option>
+							<option value="0">Disable</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">Auto-Blacklisting</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Use ABL</td>
+					<td class="oldval"><?php 
+							switch ($row->useautoblacklist) {
+								case null:
+									echo "Inherit";
+									break;
+								case 0:
+									echo "No";
+									break;
+								case 1:
+									echo "Yes";
+									break;
+								default:
+									echo "UNKNOWN";
+									break;
+							}
+					?></td>
+					<td>
+						<select name="greylisting_useabl">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Yes</option>
+							<option value="3">No</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						ABL Period
+						<?php tooltip('greylisting_abl_period'); ?>
+					</td>
+					<td class="oldval"><?php echo is_null($row->autoblacklistperiod) ? '*inherited*' : $row->autoblacklistperiod ?></td>
+					<td>
+						<input type="text" name="greylisting_ablperiod" />
+						<select name="greylisting_ablperiod_m">
+							<option value="">--</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						ABL After Count
+						<?php tooltip('greylisting_abl_count'); ?>
+					</td>
+					<td class="oldval">
+							<?php 
+								if (is_null($row->autoblacklistcount)) {
+									echo '*inherited*';
+								} elseif ($row->autoblacklistcount  == "0") {
+									echo '*disabled*';
+								} else {
+									echo $row->autoblacklistcount;
+								}
+							?>
+					</td>
+					<td>
+						<input type="text" name="greylisting_ablcount" />
+						<select name="greylisting_ablcount_m">
+							<option value="">--</option>
+							<option value="0">Disable</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						ABL After Percentage
+						<?php tooltip('greylisting_abl_percentage'); ?>
+					</td>
+					<td class="oldval">
+							<?php 
+								if (is_null($row->autoblacklistpercentage)) {
+									echo '*inherited*';
+								} elseif ($row->autoblacklistpercentage  == "0") {
+									echo '*disabled*';
+								} else {
+									echo $row->autoblacklistpercentage;
+								}
+							?>
+					</td>
+					<td>
+						<input type="text" name="greylisting_ablpercentage" />
+						<select name="greylisting_ablpercentage_m">
+							<option value="">--</option>
+							<option value="0">Disable</option>
+							<option value="1">Inherit</option>
+							<option value="2">Overwrite</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="3" class="textcenter" style="border-bottom: 1px dashed black;">&nbsp;</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="greylisting_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="greylisting_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No Greylisting check selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Greylisting Update Results</p>
+<?php
+	$updates = array();
+
+	# Process all our options below
+	if (!empty($_POST['greylisting_policyid'])) {
+		array_push($updates,"PolicyID = ".$db->quote($_POST['greylisting_policyid']));
+	}
+
+	if (!empty($_POST['greylisting_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['greylisting_name']));
+	}
+
+	if (!empty($_POST['greylisting_usegreylisting'])) {
+		if ($_POST['greylisting_usegreylisting'] == "1") {
+			$usegreylisting = "NULL";
+		} elseif ($_POST['greylisting_usegreylisting'] == "2") {
+			$usegreylisting = $db->quote(1);
+		} elseif ($_POST['greylisting_usegreylisting'] == "3") {
+			$usegreylisting = $db->quote(0);
+		}
+		array_push($updates,"UseGreylisting = $usegreylisting");
+	}
+
+	if (!empty($_POST['greylisting_period_m'])) {
+		if ($_POST['greylisting_period_m'] == "1") {
+			$period = "NULL";
+		} elseif ($_POST['greylisting_period_m'] == "2") {
+			$period = $db->quote($_POST['greylisting_period']);
+		}
+		array_push($updates,"GreylistPeriod = $period");
+	}
+	
+	if (!empty($_POST['greylisting_track'])) {
+		if ($_POST['greylisting_track'] == "SenderIP") {
+			$track = sprintf('%s:%s',$_POST['greylisting_track'],$_POST['greylisting_trackextra']);
+		} else {
+			$track = $_POST['greylisting_track'];
+		}
+
+		array_push($updates,"Track = ".$db->quote($track));
+	}
+	
+	if (!empty($_POST['greylisting_authvalidity_m'])) {
+		if ($_POST['greylisting_authvalidity_m'] == "1") {
+			$validity = "NULL";
+		} elseif ($_POST['greylisting_authvalidity_m'] == "2") {
+			$validity = $db->quote($_POST['greylisting_authvalidity']);
+		}
+		array_push($updates,"GreylistAuthValidity = $validity");
+	}
+	if (!empty($_POST['greylisting_noauthvalidity_m'])) {
+		if ($_POST['greylisting_noauthvalidity_m'] == "1") {
+			$validity = "NULL";
+		} elseif ($_POST['greylisting_noauthvalidity_m'] == "2") {
+			$validity = $db->quote($_POST['greylisting_noauthvalidity']);
+		}
+		array_push($updates,"GreylistNoAuthValidity = $validity");
+	}
+
+	# Autowhitelist	
+	if (!empty($_POST['greylisting_useawl'])) {
+		if ($_POST['greylisting_useawl'] == "1") {
+			$useawl = "NULL";
+		} elseif ($_POST['greylisting_useawl'] == "2") {
+			$useawl = $db->quote(1);
+		} elseif ($_POST['greylisting_useawl'] == "3") {
+			$useawl = $db->quote(0);
+		}
+		array_push($updates,"UseAutoWhitelist = $useawl");
+	}
+
+	if (!empty($_POST['greylisting_awlperiod_m'])) {
+		if ($_POST['greylisting_awlperiod_m'] == "1") {
+			$awlperiod = "NULL";
+		} elseif ($_POST['greylisting_awlperiod_m'] == "2") {
+			$awlperiod = $db->quote($_POST['greylisting_awlperiod']);
+		}
+		array_push($updates,"AutoWhitelistPeriod = $awlperiod");
+	}
+
+	# AWL Count
+	if (!empty($_POST['greylisting_awlcount_m'])) {
+		if ($_POST['greylisting_awlcount_m'] == "1") {
+			$awlcount = "NULL";
+		} elseif ($_POST['greylisting_awlcount_m'] == "2") {
+			$awlcount = $db->quote($_POST['greylisting_awlcount']);
+		}
+		array_push($updates,"AutoWhitelistCount = $awlcount");
+	}
+
+	# AWL Percentage
+	if (isset($_POST['greylisting_awlpercentage_m'])) {
+		if ($_POST['greylisting_awlpercentage_m'] == "1") {
+			$awlpercentage = "NULL";
+		} else {
+			$awlpercentage = $db->quote($_POST['greylisting_awlpercentage']);
+		}
+		array_push($updates,"AutoWhitelistPercentage = $awlpercentage");
+	}
+
+	# Autoblacklist
+	if (!empty($_POST['greylisting_useabl'])) {
+		if ($_POST['greylisting_useabl'] == "1") {
+			$useabl = "NULL"; 
+		} elseif ($_POST['greylisting_useabl'] == "2") {
+			$useabl = $db->quote(1);
+		} elseif ($_POST['greylisting_useabl'] == "3") {
+			$useabl = $db->quote(0);
+		}
+		array_push($updates,"UseAutoBlacklist = $useabl");
+	}
+
+	if (!empty($_POST['greylisting_ablperiod_m'])) {
+		if ($_POST['greylisting_ablperiod_m'] == "1") {
+			$ablperiod = "NULL";
+		} elseif ($_POST['greylisting_ablperiod_m'] == "2") {
+			$ablperiod = $db->quote($_POST['greylisting_ablperiod']);
+		}
+		array_push($updates,"AutoBlacklistPeriod = $ablperiod");
+	}
+
+	# AWL Count
+	if (!empty($_POST['greylisting_ablcount_m'])) {
+		if ($_POST['greylisting_ablcount_m'] == "1") {
+			$ablcount = "NULL";
+		} elseif ($_POST['greylisting_ablcount_m'] == "2") {
+			$ablcount = $db->quote($_POST['greylisting_ablcount']);
+		}
+		array_push($updates,"AutoBlacklistCount = $ablcount");
+	}
+
+	# AWL Percentage
+	if (isset($_POST['greylisting_ablpercentage_m'])) {
+		if ($_POST['greylisting_ablpercentage_m'] == "1") {
+			$ablpercentage = "NULL";
+		} else {
+			$ablpercentage = $db->quote($_POST['greylisting_ablpercentage']);
+		}
+		array_push($updates,"AutoBlacklistPercentage = $ablpercentage");
+	}
+
+	if (!empty($_POST['greylisting_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['greylisting_comment']));
+	}
+	if (isset($_POST['greylisting_disabled']) && $_POST['greylisting_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['greylisting_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}greylisting SET $updateStr WHERE ID = ".$db->quote($_POST['greylisting_id']));
+		if ($res) {
+?>
+			<div class="notice">Greylisting updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating Greylisting!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to Greylisting</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/greylisting-delete.php b/webui/greylisting-delete.php
new file mode 100644
index 00000000..220062fd
--- /dev/null
+++ b/webui/greylisting-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Module: Greylisting delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to greylisting" => "greylisting-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a greylisting was selected
+	if (isset($_POST['greylisting_id'])) {
+?>
+		<p class="pageheader">Delete Greylisting</p>
+
+		<form action="greylisting-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="greylisting_id" value="<?php echo $_POST['greylisting_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No Greylisting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Greylisting Delete Results</p>
+<?php
+	if (isset($_POST['greylisting_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}greylisting WHERE ID = ".$db->quote($_POST['greylisting_id']));
+			if ($res) {
+?>
+				<div class="notice">Greylisting deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting Greylisting!</div>
+				<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Greylisting not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no Greylisting ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/greylisting-main.php b/webui/greylisting-main.php
new file mode 100644
index 00000000..99edd6ce
--- /dev/null
+++ b/webui/greylisting-main.php
@@ -0,0 +1,129 @@
+<?php
+# Module: Greylisting
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">Greylisting Checks</p>
+
+	<form id="main_form" action="greylisting-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'greylisting-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'greylisting-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'greylisting-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Policy</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						${DB_TABLE_PREFIX}greylisting.ID, ${DB_TABLE_PREFIX}greylisting.Name, ${DB_TABLE_PREFIX}greylisting.Disabled,
+						${DB_TABLE_PREFIX}policies.Name AS PolicyName
+
+					FROM 
+						${DB_TABLE_PREFIX}greylisting, ${DB_TABLE_PREFIX}policies
+
+					WHERE
+						${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}greylisting.PolicyID
+
+					ORDER BY 
+						${DB_TABLE_PREFIX}policies.Name
+			";
+			$res = $db->query($sql);
+
+			# Check if we got a result
+			if ($res) {
+				while ($row = $res->fetchObject()) {
+?>
+					<tr class="resultsitem">
+						<td><input type="radio" name="greylisting_id" value="<?php echo $row->id ?>" /></td>
+						<td><?php echo $row->policyname ?></td>
+						<td><?php echo $row->name ?></td>
+						<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					</tr>
+<?php
+				}
+				$res->closeCursor();
+			# Or not
+			} else {
+?>
+					<tr class="resultsitem">
+						<td class="textcenter warning" colspan="4"><?php print_r($db->errorInfo()) ?></td>
+					</tr>
+<?php
+			}
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/greylisting-whitelist-add.php b/webui/greylisting-whitelist-add.php
new file mode 100644
index 00000000..f4c466b3
--- /dev/null
+++ b/webui/greylisting-whitelist-add.php
@@ -0,0 +1,117 @@
+<?php
+# Module: Greylisting (whitelist) add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to whitelist" => "greylisting-whitelist-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add Greylisting Whitelist</p>
+
+	<form method="post" action="greylisting-whitelist-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">
+					Source
+					<?php tooltip('greylisting_whitelist_source'); ?>
+				</td>
+				<td>
+					<select id="whitelist_type" name="whitelist_type">
+						<option value="SenderIP">Sender IP</option>
+					</select>
+					<input type="text" name="whitelist_source" size="40" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="whitelist_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Greylisting Whitelist Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['whitelist_source'])) {
+?>
+		<div class="warning">Source cannot be empty</div>
+<?php
+
+	} else {
+		$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}greylisting_whitelist (Source,Comment,Disabled) VALUES (?,?,1)");
+		
+		$res = $stmt->execute(array(
+			$_POST['whitelist_type'] . ":" . $_POST['whitelist_source'],
+			$_POST['whitelist_comment']
+		));
+		
+		if ($res) {
+?>
+			<div class="notice">Greylisting whitelist created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create Greylisting whitelisting</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/greylisting-whitelist-change.php b/webui/greylisting-whitelist-change.php
new file mode 100644
index 00000000..05deb7fc
--- /dev/null
+++ b/webui/greylisting-whitelist-change.php
@@ -0,0 +1,174 @@
+<?php
+# Module: Greylisting (whitelist) change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to whitelist" => "greylisting-whitelist-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a whitelist was selected
+	if (isset($_POST['whitelist_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				ID, Source, Comment, 
+				Disabled
+				
+			FROM 
+				${DB_TABLE_PREFIX}greylisting_whitelist
+
+			WHERE 
+				ID = ?
+			");
+?>
+		<p class="pageheader">Update Greylisting Whitelist</p>
+
+		<form action="greylisting-whitelist-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="whitelist_id" value="<?php echo $_POST['whitelist_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['whitelist_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Source
+						<?php tooltip('greylisting_whitelist_source'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->source ?></td>
+					<td>
+						<select id="whitelist_type" name="whitelist_type">
+							<option value="">--</option>
+							<option value="SenderIP">Sender IP</option>
+						</select>
+						<input type="text" name="whitelist_source" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="whitelist_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="whitelist_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No whitelisting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Greylisting Whitelisting Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['whitelist_type'])) {
+		array_push($updates,"Source = ".$db->quote($_POST['whitelist_type'].":".$_POST['whitelist_source']));
+	}
+	if (!empty($_POST['whitelist_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['whitelist_comment']));
+	}
+	if (isset($_POST['whitelist_disabled']) && $_POST['whitelist_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['whitelist_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}greylisting_whitelist SET $updateStr WHERE ID = ".$db->quote($_POST['whitelist_id']));
+		if ($res) {
+?>
+			<div class="notice">Greylisting whitelisting updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating Greylisting whitelisting!</div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to Greylisting whitelisting</div>
+		<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/greylisting-whitelist-delete.php b/webui/greylisting-whitelist-delete.php
new file mode 100644
index 00000000..2dce765c
--- /dev/null
+++ b/webui/greylisting-whitelist-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Module: Greylisting (whitelist) delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to whitelist" => "greylisting-whitelist-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a whitelisting was selected
+	if (isset($_POST['whitelist_id'])) {
+?>
+		<p class="pageheader">Delete Greylisting whitelist</p>
+
+		<form action="greylisting-whitelist-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="whitelist_id" value="<?php echo $_POST['whitelist_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No Greylisting whitelisting selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Greylisting Whitelist Delete Results</p>
+<?php
+	if (isset($_POST['whitelist_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}greylisting_whitelist WHERE ID = ".$db->quote($_POST['whitelist_id']));
+			if ($res) {
+?>
+				<div class="notice">Greylisting whitelist deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting Greylisting whitelist!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Greylisting whitelist not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no whitelist ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/greylisting-whitelist-main.php b/webui/greylisting-whitelist-main.php
new file mode 100644
index 00000000..0a31b531
--- /dev/null
+++ b/webui/greylisting-whitelist-main.php
@@ -0,0 +1,110 @@
+<?php
+# Module: Greylisting (whitelisting)
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">Greylisting Whitelistings</p>
+
+	<form id="main_form" action="greylisting-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'greylisting-whitelist-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'greylisting-whitelist-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'greylisting-whitelist-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Source</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						ID, Source, Disabled
+					FROM 
+						${DB_TABLE_PREFIX}greylisting_whitelist
+					ORDER BY 
+						Source
+			";
+			$res = $db->query($sql);
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="whitelist_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->source ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/images/bg.jpg b/webui/images/bg.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..59fecf01b7513c99d857ee63d7ee2034313aa1f6
GIT binary patch
literal 437
zcmex=<NpH&0WUXCHwH!~28I+MWcdGvLC~c%IlGd9k%5JQfgu4X^p1hgF(p4Kl_BK-
zP=xXSZH5*GMm&ItkqHRE1c<>51}q@J3I|Z_%s^=tpgfWcTnT>0{{swy91L;{Y|M;;
z3`~NI%z}*nk1)i890qhG0&uW#p@{(H1Q?hYnHkwx;Yt~q1QmstSr`l*m4rpu5{;Bu
z#Y6?+vM|&B-(uilW(3;CEXZKbaO~nQF5O>cN|$bIIZ-)TFnYG~gnf?|x!NXZFf^G|
zEOt!In>GEXY0l1Fvw9s89^H7p(Z}%dk!x3P2>xf7JAM0B$zqnid&gd87RHLXUal6F
uej<GIEK~n)uEOI_YkEsoU7O}}Po>B%W3h#OreBa(?-d2fo!j{T-vj`<tXOpb

literal 0
HcmV?d00001

diff --git a/webui/images/bullet.jpg b/webui/images/bullet.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..785700c3646b2bed7f1e3a97b964a57957e1ee5f
GIT binary patch
literal 631
zcmaKoODF|l6vxl^nwjg7`L1rMTij9ZQh60cH;;&tvO@@0lm!cy6e)?2veH!+bXQWc
zu#k;sNr^0!XDManl@%M~%$>|&;Xi$+f4_77ozs{X<{juYmDQC%C_orLFdsoyL^^tg
zfB*-8MnumLEDiUzcS3jv31Q&lOi4&ayA41!d{y`&<~581aYWHkiWQ43Mi~kVx5PwT
zswK^l6~}48m{0{5KRV9H|Hj+{seuO)7?D6FVUm~!5Va1&<6Wtm=MTZ24n+JK;}Gx)
zr9c8Ot|Yo?A}JV*>p9EyLh<I7rRJ6ASM+ZLy}!~pA4tU?#@P={0@48eHK(*~_sqP4
zB<xYia05Btn@ODLK&IhkM9{PJ=GvR1hLg8Aq893kTjp9yl@QIascQ*A`Z4t$T`MVC
zS~*^f&1P>D`FC5ppJK*V=51l$Y3stkYE$vhdP!RTsJ)SqkdYPKoNGCp92}Y6{~Vr~
nxA$6&Dtp7Xb&uA^Qk=Lx?)6RkRipO4F8cBia?-k+Mtk`MI)ZTN

literal 0
HcmV?d00001

diff --git a/webui/images/help.gif b/webui/images/help.gif
new file mode 100644
index 0000000000000000000000000000000000000000..1404a7a126328afb24d3ddb064882caf0cb9dba2
GIT binary patch
literal 302
zcmV+}0nz?PNk%w1VGsZi0K@<Q`~3U%`1$bk_3!fS=Irw0=j++#^xWj?*W2R6+U~&0
z*0Rgyo5SO>y3n1p*{Q3vkgC$0qN;_T%yg8+g^ZM9gS&Zwhgf;DZgzZ0a<4^fszYa{
zJY%H)|Nj6000000A^8La6aXCnEC2ui01yBW000H6U?+-%5CjA<uH6B=K=29(Tg1t-
zFiZjnijm6zfgA*c#RLK<i~@$q1R;<t0Fn&z(IEgJmr7&8xd0rQis3*(Rx+B6TmqPA
zG7f<SdV$9$0cda#0~RTLaTf&(aT*#9g)S9$8y89&aTy5+7#(Mrm=hP691{Q$od*FD
z8ypp%Wd;SEBmoc^84{Bd26`4N2ml8V5)eLYzbp+31p@;L5f;fTA{5pXv?Cz^J12g0
AssI20

literal 0
HcmV?d00001

diff --git a/webui/images/menuleft.gif b/webui/images/menuleft.gif
new file mode 100644
index 0000000000000000000000000000000000000000..f986ecfc27c910701b77a4520ef951bf61c9a859
GIT binary patch
literal 640
zcmd7PO>fe00D$p7>BuSqDME0LWpM^0%G5>Y+}x6}sUvl;_Tbq>zk%^&vV+-0ubxbd
z@j%=T-i+D7MO-!|qtcc(0qg>8*(zjWDQ$UwRpzJg_X(cl@uN%AGY<#AeUQfi(<khZ
z{8qeA*j5yU6~D49+iJC9{3n)SVzF4e-PSa%(P*&3j;gAaN`*V5`(#<Bg>b!IXIQq^
z>oM_ov)SZ0u3RoN!gjG(WW-%nSLirR^Wj8xPf_JUp&%>2XyFS*lBH5flB908lRO}@
zVm6n{X}TJX64h#1FKZ-C>$*--RJB^A_$^)6L{Us665Vb$b?}`OK1)YJG_y$x;Z!P>
zOeV!VM^kh*zhA4>_WCj(qJ5c<L}rs9h)$<NlH{L%!2e{dIbZ+)2jj<4$4|f@{|q0R
zv|z)=MJuu}Gkw`*blkc!dI>sjbgeip4hBY%6~EDP(vOU6SZo_3OCg&xG-VArVGn9G
z-#~|h*HL)(&hC&MHDl2rHil9VgFzE)fI7orAk9-EW=g;Pu`e8D(-M`#PXGRyRw+Dq
z?J90|k9*I~-G1bF2_oNM559`{JPTkET1HI1wF$#rkJJ0$jpwlxaos~|@ChS~+T7lE
w?x$;R!>f7Z)C+hWqQK23=T?38P~i2H?a=YwZi+vjoM+}tkqeG>7&3s_zsge`kN^Mx

literal 0
HcmV?d00001

diff --git a/webui/images/menuright.gif b/webui/images/menuright.gif
new file mode 100644
index 0000000000000000000000000000000000000000..afdd8bd04b1717a44fed336a60214acc76dd2817
GIT binary patch
literal 1398
zcmci9_fyjc00r=GSR#pt7O8i&EeNuLg4H70AquAmNb#VOT&Y#7l;t>~h*0i=3<pCH
z1<DW<(1cMVNSGl+C4+1uAwtL?12V`Y2_ukV|A>Bmes}NQy_2U-gdD!`5{L(6aKK`*
zsMYF~m6e5s1+7-Qy1HsMn+*oT^78Wf`npP`((CnWYik;f#%MGul}eMz#NHqzkT>vp
zNxU8siA3bRA`*#AKAy>BG8hahmCE4bs567C4T85UCR3-=QDz2~mX;_K3X6~Da=9Bh
zrr^zo4MHNFPG4MHluD)CSvr%&qVus#K90^G5eNhv4o9cgPKd}PUawdzo|>AXZloD>
z8kMTms|7MHl}1x*RaE{kM>MWC=!{0g#Kgpun59z7seG(nuM^MnCugZb*+)8!P9l*-
zbJMh$!L>EZ<m4oM1}hW@MIw<xp|Ji3_}_Uf+kpT84g`E^{`3j3$%@!^yP&YB_|DyX
z_e)C4${$ozmixz@-3{IhhbJ^NK51%x`mCk3?fDBNs=WiX@5l*|Bdor&7t_~2Fo@Y|
zd+=L3FZkAXV+10JJWip~=nN+7J(~^k`8g8qG|ijgZ%m#QOQf>7dAUMiyU*VVZmTye
z8cpV<<&{;-+PW36b%0#I99A9x+U}o7LO*?b$Hg<UA>!4uv67wpgJVZU;nfcAVfS~P
z>TV@h`Np*;lDpd|HG!KUwOS8wetk%Wf=BLo!DtFCaQZUxHS$c$ZkzMMip%-z7qKmo
zjgh_W6CJRg)S2<#v`JgLphu(|&7B{6lG*LQQZQZ9eb=qx@y4i{tKe-HdqTLBzLx?V
z!WR5hbU#}3_U>oUvk+0}ImZgms3*|_-BL>JfiymKpl6QJwB<FdZVVx3BjY;G(FS{!
zljz?mPfibIUD@s&;mM^9^=Sm71>mn^hWmA5QWZ2|-zbm*Vzxvz#b5`GN^Vb@fQ}t9
zYXsm5G}ALG-!RYa_>D1wT{UaPl%}6>BYCTU3k-N@kFZ(+2VWt=&MjG(@92#b-i8Eo
z-ED1P=rA`(e6px$XA)9Wyen&7bjQ8eclNH=!`jfom`jzT_X9BVvn4?UUvcR{PO`Wx
zM22iBhq;~yf#K&pBo*OqDU!+vZ<NIPFgjQ+sfs<}w+A@t;3s_yOF~Jj6R)1yv-ND2
zpRD#$b&7Xo{8bm(-{}~+tUk;}TUd9UlQP!`w+R9@W}D=5P02BcH+2ZNRNwlX)X@2-
zrNQl&pOqZ(m$ybAkCeC7dZYeutV~j%T5~vya%7Ey?1Msn(>~XX!lWYG{vk~Hbar!`
ze7Z2Q9NF_mg+keK(72*RpHXZsK)>_;MQ+#NuT(w4{|N1>A|!d>d$~y+3m9IOa-mOH
z3|03_s?*f{&>&FJmT;h%JftN+HN%UXG!1r1)}a}(n3UJtPV!vBK~}ePE#A?m6OB6x
z5f!+CPX_4Txh6D>vB9TZFX#xnZmM)cP<Ne<<W*z2wkfK%Q$HSnQ{usUi2)fzS45D3
z783YZ{-(obRR-?!Qmug*&i*2k72%ne`96AeID;K4wq$;Y@B9AG30O_yF<1D_A8yzm
z&)yqM+~Kv~^wBjT)P5>GF!31V3NcSRePeRrn*9N8SKr8vOte{GniU=r780ZI!XlrT
ze8{~+F~=Orpw71>g-2s<Nxc)DvuSnKyzIH$K<7bz^@DRa<<E&_Ig0eSio?n)8P2&%
VKPrDkiFvR$SA8)qHrE~a?q4F#_#OZN

literal 0
HcmV?d00001

diff --git a/webui/images/specs_bottom.jpg b/webui/images/specs_bottom.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..b01e2fbb59b325c49e933c2c326f6535b655198b
GIT binary patch
literal 871
zcmex=<NpH&0WUXCHwH!~28I+MWcdGvLC~c%IlGd9k%5JQfguVg^o~KzF(p4Kl_BK-
zP=t}0L6n7=jf)q^{LR3?G>L(MSrCX*|KDb4VPJ#<CLoK62}lA72w-Mn1_B_#0s_pe
zV89Ln9B=^A4phy`%*@Kp%EF2y16P8d@&6EmAO`~<!$oFBK?Wv4MrJ|A|3?^R1HHq<
z40JsLu&}bRb22g_1RyK{pb#SqvQky%07fPj2Ne^bFWDHGm^l$z3@2V>VrCR#5!h7h
zAm|vl&`H=>L<rr;0AU7Zkda8@jDm&&4grcE90L>o-(uhaN-+t70+I2(WfshIrXAPY
zV!U8HMu|=KK&2cY*Re9a_!H-z|1|OT=Hs%e*nwK??wE~L>%m%>Kw7Tu2eW}LfwP&I
z*zB32A;JhIBO_4s=9kq^k7wTb^8EB6`M%Pd+s<EJA7|WC$+R%-z>3HXT4Fg|t+OfQ
zOr6bbxN~l4?(fZ?)1;p2+9}_B0rep>qrKvtN1x|MxwLJ}tt~kfw@YKH(4r8p&Oj|y
zmlfEUZtG8+HdwW2rPqGBW{8(TW;}&@8O}xov;Ztz83a64CP9z~!g_(byXv;ADqEA4
v_3Y&>OXKM~bRsq;9qkrFq2eO;Je_#h>2hXgV#EcARlvkxFMwn%h<y_P5Yp2`

literal 0
HcmV?d00001

diff --git a/webui/images/strips_onside.jpg b/webui/images/strips_onside.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..6fc0a3c22e97a2371620a1a68529f42368e565b3
GIT binary patch
literal 392
zcmex=<NpH&0WUXCHwH!~28I+MWcdGvLC~c%IlGd9k%5H)B*^gp9Rr_ZN`6u*L&^c5
z2;=|T3@r?d!~-S-V1@&zb|ywfpezu>C5UDGKfoZ!!NA3Ek(p7Dfk}{&S&;Gn5rz<m
z!+_3&12ztJE=EQ;7s?P|WME=O5oKZ9YF5T7h$043{QnjM4^SnOAhRHYJ;V38u9r0L
ztgRO05p{qXg`m{e-dZ|;-nWgL9Op6KU$M*8dg}Tl#ikVq1yB~t*WDqTKi|7%=3#um
H{{Kw?Y<@O8

literal 0
HcmV?d00001

diff --git a/webui/images/top2.jpg b/webui/images/top2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..3f2f354d4ee23ebfc23d309fc702d7d8860d2d05
GIT binary patch
literal 2114
zcmaJ=dpMM7AAa8VonbI|$Ei{@j)~+H$w$UG4Mt;@`Z8a9qofjIeUdBH@Uc!gtc_yi
z)Uqlxj=5|(t#fip7*y=qtYfPY+a|tu*wnRueD`xbzw5s4=l49%{d?cvvp&2&4p2us
z2Ri`40C-~qtj__GO~|S9VE_U+000Y<7J#Oe_l1+Efp-I@KnRe>AtK_E0KjPg;3NRR
zmjFPZtdD{y0Br%r7z|?(3!6Y-1OpauLLm4Jhzdd2f^a*QjYkl?C?1FZVr47k|C9A5
zKq3Go(2GDM0Fxku1g$p%p3oRTAk6<KKzKxiAcm=b0}3D<goBaKvaB3l9)e{M9GgTr
zpg{rv^M)0%l>xydrdJuFVqldgV`$W;iVOO>JVI72n9>+2^Y`P~vH&Yjc*7?%m`!Xa
z(<><A+u!rb`X<<oi<I>dK*ZKz5`x_Zz0GR^dm)-Q#f1V{K}W0y3-5{(0A7Ux&|J><
zhTUEM9H3$)PH>?{%AvW<hex<u-VJ)NqX<}$5FQ?qH|V&R9r#1m-YN00^6bzT<`WE4
z*X|pFXmdWp%(YuiaC$>|DpWR><OBtqL{YWy(z~Tg7E9d3)?b3^L_W`&v4Dd+F)>^c
zn@S7P9$GJUXJzo{bo#KSrk`v>29E*zG@6TXam_+>=<dF~d+D%EOz(y-Sm^6*@&-q~
z;4my=2{Sk4&lG|%l{KyUaKt^MfR%Xt9}ekB+H(z6T!ulLd+FdsACqJ8RXNPI6A3T<
z&D-RCeq_}qrsbE|btIY1tzbzl?lpT@#a(_S^5;$HK|^OAjf5p>&o`PqANVAx*E1^x
zyN-@0`p%fn?x=U?RqP5G{&*&UT`zxW534rGto6d6-@ew)xfWL1K+r!UL+%&-Qv522
zSFuy4LU!Pay)cW5nW+<a`N-79-d|4f4sr7}(JwK#|Hkj!ZEZijw^Y-j6U|-zOSB~I
z29HsLhkdH1**Nk_VqM%e)+)inM{^OA7Up8DWq0~D3W+myR-abOmrjiyWHYuM7@IJb
zC=PB*_p42FQW`NQ5`OFda~b`yPgO5)tvOXq#Yl#BJ!(KDg3#_vl_CX44eW9y1!hKR
zszuris2Hfn6@^WOPTYStXE1R!^BTOy;Qr|wPQ13+B?x4xVlN1)vd(R?r59KClqgSk
ziYA3yQ>In-uxsN*FLjIdH0d*oZErSN#C0O;z%f3M=p6AKHEA&m$&QQ<+_BVNdGK1<
zp=15bBhb_Aj;co)udNww`L<%#9m;)CIhx9gUJrxa<xcYJE4|LnCJ6#uU#JtjD<_?A
zX}y}q3Fw_43`Vp+#y&557n<R6Rju-_Yk=3e(bun!f1PpnLgoIC^~F8@<4@UF+C83?
z%yljQim%+3e%ba|HuH_r8+b&1VP2l~UgS*O9hd6p-FoMaKHw@Y*S4Mx|0C^u>F-7>
zt`Xx7)%zVC{vB%cWR&JqDHYHW8|`K|6<qW$a^7<vRU-2(J>7mlH|2a$SFZl!jP&iZ
zF4f89%;*P)QVLD`71|H;?Z3C9X4l4LkUyyIH(fA<ECD^<bh0QR`Q8EXRoL4<hZ2Ff
zYLu^oQZ3ib78ichwZD3Ki+_IIs0>g?#mF$g$<WBD4mdynkpwbIQ%4=tVKMTjmyFx`
zL+BMh!*qxM(V!XJ)kz<TTFXg?)YcoFJ><&*IBUAPJZ7<`mnyjs+CY!&DU}<Fm7!eJ
z?X}!aBP9RyB<6a)gE8$x!5|);*Wl^bqc<c%{u6G#%PNI(yh)HYC^Dy=nzFsTyuj#@
zw5^<R+v|PJM~O;DhNYe^aeSR_liC!HxjozWnAfQo9>~e05dCDUA2qw!SkB^yWKpkE
znQTV)L_S-+yiey23LHN8C){eVTRx>4Cf80p;5ei!p(bVXKB?^TQcw^|R*+x5i6`?w
zVTMKnUBN#pk98%vNC$!W7dhipW#~KW$8qn!DopOpg#|OBU`6VxD4OC)wBaqg$Cyfc
zo`sIWIOVyUw?$*>i?wjEY~8U6<pvQhMJip}4f=MjX58H3qnAq{Omi}qIaA5T`;L<e
zo`r{`ML3Q;IRXT0P5<RMI-D$bpLZD}ha3lTgz5SPV#9@0CvWJdXwC9`PZLL9MKLIv
z6IQ<<NxJUChqNMn!UFl)Q5`AGecVaGyEvPQwD-_*WZuDqgm3hysJn?O1>#S(*mCA0
z@4XqlMFY!3iAIZ8VWC!u?ISA>P?a4gPnQN>)6ccoC-a9!u!IiW?^^Z1WiQpA_?zTv
z4M$C3_-tCoRC5cXOUk#_D%J#1M1r>I={!$0TPvWTt#pf-`r-X#e<@G!vW^g?8*JR6
z^YCXy+#$ThOw594sP+r+GG8v~=U%=}^`aP=W1ORN4-tUjuoe-{m@}Uj&5g=b-oE5n
zcLLD*p-L$cL0jC}sXOUetNPJRjGSCX8=3;_evObGinWn#gJ(Tf*TK+}n_GR1e$mH5
G&i@}M`5?*w

literal 0
HcmV?d00001

diff --git a/webui/images/valid-css2.png b/webui/images/valid-css2.png
new file mode 100644
index 0000000000000000000000000000000000000000..c04dbab5769fcc634b40de5422b11bbdb9121de1
GIT binary patch
literal 1588
zcmd5*_dDAO82?s;7~#|?s#H_+oV~@25J9YPq4wyI_K^lp#VSd~=#{D()gbg}Xeb)A
zIIBigs8zE@%Ncj1PEj>4_g~!mJnv`x@Ohs1c|OmZ?uxO83d#xs004DB*}8KX$6W;o
zh>KXMgHZrDv*hZ8MRF~K4<szeD<mW&2IV_<RzOZlP*PG-PEJly7OJlJleV(Bo|=TQ
zhLnYlGz<n)RaMp3(={_Qv(l5XH<ojP%VQiZu?R(+9n24{6y&TN>Z*DJs}_ONh_*M0
z^3_ZT(ZOIa?k<jA?#^CbUcSD*;eP0_urNFxPs9fi2!yz}IKYPn2`CW=ED;GQ6$>kq
zy#Bi^zC!*MLouRKiCCo;&D0^iG)$;7POP^evyjwAr~A#G*?;&vZuiUU2z~nYdQtbS
z(%z`@{`e|(9xvz#0MH=3X%}UR3{~hN{7rEA3Jdk5t9n$tLE25j2L$7sXj59ed9#gT
zyOVM$(W3*S(&?)DE<kHI!e}Dad@9j0I~8A+Y{j4=sxy$RWL#r5syP?kR^asP5&l)l
zwU!EEH_drI136IUHuBtKyb?QI?KM}2TgpYRJat~DyKYuuml}LlUi)se`hV*RI_L>L
z83?0LDEayM1qB6_<;4xv1xzNB#bUL$x07pzQfi0qvqm2_jpwyY6tqr0ZJR3ToO$+k
zmeDu&qJO@A@N?tvQdd_Oo6Q~{AD^0<>X=yVomm@P*ce;l%&l*qZuG9Mu5N5>{K?r}
z|7VZ0v%j;mv;F;GcmMF@<b<1AaxE<3)?6Cpj`2ACpAS$+CsVn{o(Xoew*}I`7f@Uy
zKtOp%a```v0_^(n761S;cd)g_qWU)Tjy=v=OZR<8)k(AT9fNdT#{3oRAPesax)QOI
z8)31aV8+^`fqqa;9gA2POxOO!G3Cvs%jUFsW*KpaeNg$8ZQc^cPK=4!BNeAC8~M4k
zYiGj^CRL)3oA2H^y}M=Cc|)x*Fa%yv8)Or3Y+@X)bT2Kun~d<y-OUv+UfNyayy2Me
zslE2~$2Mh+e#xPbOkdpIdfcO{+}Bk#Sojbo(2#4Ji(?D7^2%RsO9>ICf&JcM@vzW=
z_+vPKmKguSwR5(;;^{D&p(s)--s*3vCyTOp#hU~zzEq@WmZ?8}(|cvnJe2nJ{xqb{
znL!j+^i=eyRq&^8QiOd(HQcIGoo8jW1^F|FAN38E7l~JQr&HjXH}$|;R+i;20O?8O
zS`XnHW4tztRVL!4K~_cDROzV)ba|YIDt*Z-!Y6@}iC$4b67xWmo2hVO^IudXyt!J^
zTWpp}(yp2rnURFUZI~kg6c>JJZ~nur=ZADrDeX@}JC{2ud5Y&m!IvBbn;aTZ4%@O|
zqH+h8=UT_}=nI47yWmgz2J%UX4=@po?IHfC^+lf7k=j_oZX4CQ(LV~2*ES2;N2lYl
z^E$sFGDVV#Wgd%kJ|w+Fl~1h5F6IN8&{t>Z9g`+&I-tI4TSm^le!`Es6OPXle3B(V
z3si#iMPsE}2M(CH<-i|7U;~+7LxPXU#h=zAlV9a599<BIU%1!0m65+FmtgP?p|j<y
zqL4V$85{yOb{`C}4u|@0Wq<zqZa#x!$oq3EuVrxk4<Q+&P}b0g{S~@)0FO#f?>_|y
zXcKy9C8qm5{FW3>ePOwE5ma=()o0o;GJ&lb6+(^a05c`NT`@Cl%DLgglQjb)hmvq{
z{cZLvovg7I6e^2AX9jK!i5}zPI#Yw<EsD2eF!g%z3vM2k2x#rt#ONiH!h4|~YbNpt
z4TVfen+*5cS0Tkmb9P#WXfOLBi9QZ#WQB>yg5f@Pm!%%XJ~^B<LJ`rPO7UlL!wzb>
zXa-s$Z0F!S-<>h7u`5cPm4#7JGVSnO&1rxC-M#kU3G4?>bwHD-%wl8o_3u96r|W}l
cd$A%Xg3HR2q>I_5hTM+=9FQ2>8k<1!zvpp17ytkO

literal 0
HcmV?d00001

diff --git a/webui/images/valid-xhtml10.png b/webui/images/valid-xhtml10.png
new file mode 100644
index 0000000000000000000000000000000000000000..b81de9160bbaa1aaff62924d217b523edbb6f53d
GIT binary patch
literal 1882
zcmeHG`!^E`9G^Tlk6s&D^1QT2@>WDd%wsK^_pmaL+e)(tO=ELITv1_^QKOR3XjqoE
z(N^*Z$)mK2gJ`V`5nb-i{Ri%^_lNsA=kxuX?>XP^IiK_Wp3h|@!c!dt1pxp6b-0(i
zzf6N=)Kig{RkY^nAOIi_K>DIR<NyE_C3!WVf~u<OHVq}MZ9pgl1O|h3baae&X_y&q
z-EXqp&J5ycp>=5g4kIHY7z}1(ZRP0b=xPH+IO`&OTu^QX5kAH^B<vL0G(LE5lIMX$
z%sw*C5`jSYAM*+H_X`LJz+f<^!o8!Tqw#n=fj}UUNPy6CmB>mUwo)VN_SR?yB(55Y
zzpHzu#^CIIV`A-|q&myghjtem9mq}2RF+3pi*H_Az}5E9B5rsI4|lUOj{fY-ZDHb_
zuC&^o5(W7(0H9n&AxB@EZnyiEhH|Tu?p<e7O00EeoK0@L-IWA~qVtZl6sH@cLv3yb
zTwjxn)VSM36c4eRkA%I5wCF!;KYZcPDA^^K5?w`gZOHRz%s<Ma1h-y;w-tFmE%mLs
zhJREU%ehMw&=I0skG|^T1NTsGY6IRj1c@4hCyTwOZ~D#NLVmrEo?wMevoUj=a48?V
zCOEm?9i5q(Nu$w9OH1$Hsc5b*t*fhJu~=L#m)g*GiP@jW8Z2xbD&Y*5J{h_BbhMKH
zwyN`8&GYvUx<pOApIZ7SJ32agdU}S2hIqp>!ndD$KZsvXO5V>(H^jo3nHjNIJSAD0
zo&O<OTv=RPlrFC>t*ouDugg|skNzM3dV!e<4puf)k?4;=ZTy!3aL%4wkvWw+>Er3X
zaYtDykTpPpSI9Y;di}$rU3h0%uHkTZSG3pjuO+`9+kPCJ^-4eQu!m(%pt*{-lX|`Q
zBoKMp7Fsf~EvPma^3IAuM?B;kd#l)az&>tbm3>KH8ZXlb-x5M4OZ_gybURruR7`1V
zE{C5@2k{L*M0^<QTlzISw(+r@vipc>6wxa`i@{PCnq*cZ9W+6MKjUD}f(gW9A1xjD
z9oWl1v89%(uql1?Z9qA$PAOv#c1+<)D|=Q_HmofNANy)v9jG-kYwrhNceSpoQB1!C
zjxk9w#46&kRNggH)Qb7a&V!d%6gdhGlq@B7pfW)}gl@z0w&ZOwBGkVM(f~zuPHY9C
zAwLncVDjeauWYvg$`>%Hzq!ROyU!+lvuB^4xg+xiyrNj-mys0Bw;j%9@auW;zq}gd
zC&BcUeEgY{trFN{f+X#(X@@^BSTV&bKZM9XQOF3R(3sa3lH8?9+V8sJ-xpgYz<pwQ
z#r|xiic($ACTvWz<u1&p<+Z3y;`!5P59`O@wHwP8<PsN>l=q?LG^PUu`r371T5XJU
z$4<&tdEY_4+wo12^D0ep=Lha_nDVq25@S)`XeDEOifUx_UN66<*7vB{D#aJlyT~h2
z$?I~%2?7d`N;;mj;WPt^#5S=%syv4dtrVeV!k2eg@%AM4L`A+7IcFc5NExF5pE9++
z_o|JEpX`&Ks7S6lu3f%-;+tN~CFr{nJk`bEt!=H+vm&xn!I_`fF+)B(;aoMS`g-c;
z(fko%A6>lx7~%Tlx6myX&>Dr7Iw)zDb=4`X9_XxI_1vJayM228=}V#oiI|O4?VB@q
z=!_*Lnzd=E5nsCrK{tU7d!t>MkTmY{l+rR<l=!97wq23y-}o4npe$?_>QT*%?Rmnm
zTBLwMfOWS&TzF!kmfqgF@O(NgJIALUZGd1^#R&vWS;Ef!y{aGB)#Y6_?&oxV;HEBO
z_7^l4tj1)JBiHDC5m!5LM?#iJ70SAdgal0PpHvt7)a0h|AkMDE69Y_RMsmpEYqv1H
z51Ke8$)`rla#nF^X-+(oKVC^kjhb(fzm<(&jP%vRvDdiX-0ySaT;{K1et$jMfatZn
u;lw(QbcUI*<CPD#6wley51=CJGt=eD3Tv_$Lq*}TbOGQV2=@jzEcI{wV?*-*

literal 0
HcmV?d00001

diff --git a/webui/images/wcag1AAA.png b/webui/images/wcag1AAA.png
new file mode 100644
index 0000000000000000000000000000000000000000..964e105a03c059ce6e9c0f318c35f1945794a08d
GIT binary patch
literal 1598
zcmV-E2EqA>P)<h;3K|Lk000e1NJLTq003A30018d0{{R3R2KTu0005nP)t-s00008
z1_KNV1P>1n5e)_x5(yd<3LY2?92^`a9S$oZ5ilkbH7XT3Efzj87$PDfDJdyIG#W-Y
z97;MJPD?*jLm^m3BV9@*VNE7wQ7CCtDQ;LSa$7BXVlhKQLr+abPEJl$QAt!(R9IM8
zWMpJ&YHD+Ha{yYL2w$HJVxSXdqZ(_bA#bQ9a;hqItS@-3FnO;ve6c%#vqFWnM~Jvf
zin&payHt?9Ta~|EmcU|}!fm0(aH7X^q{w`#%$WfIo(lz`4+o<Z3Z@zjs2vWfA`!1E
z6|gQAu`w96I2?gzGlXe0iETEHaX6B6I+l1mntMIMQz^z;EXZCi%40FjX*AMvIoEtX
zqk=%FhC{51MY4`ZwU9`<luEvsOtYV7vY%+goK4<|M9ia6(56$=s#MypR^G8#;EqS)
zl1b*9P3WCY>7Y>Jv|8r4T<pAF@UB<#vRU=HT=>3U^uuBK!(sl*W`l!+jg5_vkdT;|
zn6#&atgNiGw6uV&&Wf|qleyKKzSy0>*`~$ZsmI=|$=|%l(67tjv(DkR(Br(+<^SKG
z#KgqQ%gfx{+`!i7#o6e~-RsZb?9$@y*yixu=<)08>*enC>+<*R^!WAl_44-l^!WS!
z{{H$QSpon600Cl4M??UK1szBL000SaNLh0L002k;002k;M#*bF000C1Nkl<ZNXONd
z{Zkr87{{NZqTzbj6yzlc+DU5{iAg7;G1ZJ+bR-IbsA!6jQjsByWO&iJ+cs_U(ll*N
z8rwQ15!2iMwa?yhjOh;!W0N294D9aB9G`pkyU+7IVE-Kj?DNy&4|cZL?0e6^>buK$
zpaXEdCT=a)aaFC0>oP{&LTHU$W8T>@rrm}K9_#?@b%@PDf-wa=;u<h6Sm0F}6;p-M
zyJC*g)s8g|*>I>rmes-5h0A=}W=|I^@Xe?}T#eE-obJ--&5ku*0@WQTLY}Qd2#Nw`
zm)l}$G-D9w=I7>cTB9pewWQFSIyVQdAHF=ocoUq1BG~g#W*4L?EEr%%8@xp;v3Y}^
zp&DcJu?pR?4o?q{bN)AZgq)v=5l#NX`OjZ}-vXCl!679<WeykX`Pc&I{eEAGv1O{^
z2l?AuNYv<xMwi=Cj72cp$QW|2lc@*eWRma0xeo?DYJpYg^((!0RtCuqlG*~N@C0*=
z&Cuy65|`=pG+klaG&)0P+lTjvJmY*c{14JcIKLV>YHoh2^Uv;Cb=)PT`z3{?!54I+
z)Qoi_SgqCS8f(z`%nA}`XEK?Y7{g^|jy5dt5t-upF!`Mykca#i{OT89q28}8umXiF
z7Me%WP?jJIIshCAQ{r268?%lz#QvA*PHa}F{&l<Du3X_y2`cb_9O{=)7yaTJofmSe
zRacsM1Gx6|v!u)Aaxa?TwYVmRt#}2A@k$&EWH){bH8wl%EAnzGGI5Dt9pR4&xz^<O
z{&!28orfhc^5w5&kKEw;!34R+pT8{=id-g7j>DJ9Q*rUdFxTIfZB7t!%*V*E0lYyD
zPBw_<+`v2i3rzLPauy5NDGY-p6^G>)DYueuE$d#{Q$7KHLPkZ^jq}4MmNog!fd16V
zxI2l19AZvT@aR|&0PQXT-TrRXr1i*XBxZQP1<n)T<M2aKb&roD*Y&@`Bl>rOdrmjO
z&S1`~buAUZkK*AYyaHo$Xsl*!ywC=B`&dx)P}?>~UkGuVSQNvA?D6O4hX$nkmTh_i
zP=Ifi%wN|aD|^xGd?yqwz`D68qnBibQMHYJ&l;XhPGTGKKZl0)t-}lUI^__Ql3-Y6
z7RmuTD?+dcaJvOATHriBJck#Z+2*3$l~O>>g3%N{ut`v=gS(!BjsHraLWnJ*4|Zns
z8=w@y#;TH1QVY!9n_YwylWqB$m9dIo)YTWl15j!%yQt$%UQHzkXtocrvjL?3lE}Nq
z#R@i%Am2(;M2P`fQxaFfPG3#xQi-jLT^ACGJLNRiLJoI+CzU9+lt_zESy~943*CNC
w|5pf&@1GJsetVYK+!WwXPK&|5v&CTFzfC%L+LbxWg#Z8m07*qoM6N<$f*+CpIRF3v

literal 0
HcmV?d00001

diff --git a/webui/includes/config.php b/webui/includes/config.php
new file mode 100644
index 00000000..2dbc7336
--- /dev/null
+++ b/webui/includes/config.php
@@ -0,0 +1,24 @@
+<?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=cluebringer";
+$DB_USER="root";
+#$DB_PASS="";
+$DB_TABLE_PREFIX="";
+
+
+#
+# THE BELOW SECTION IS UNSUPPORTED AND MEANT FOR THE ORIGINAL SPONSOR OF V2
+#
+
+#$DB_POSTFIX_DSN="mysql:host=localhost;dbname=postfix";
+#$DB_POSTFIX_USER="root";
+#$DB_POSTFIX_PASS="";
+
+?>
diff --git a/webui/includes/db.php b/webui/includes/db.php
new file mode 100644
index 00000000..56264973
--- /dev/null
+++ b/webui/includes/db.php
@@ -0,0 +1,51 @@
+<?php
+
+require_once('includes/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/includes/footer.php b/webui/includes/footer.php
new file mode 100644
index 00000000..61bbb749
--- /dev/null
+++ b/webui/includes/footer.php
@@ -0,0 +1,34 @@
+<?php
+
+
+# Print page footer
+function printFooter() 
+{
+?>
+									</td>
+								</tr>
+							</table>
+						</td>
+					</tr>
+				</table>
+			</td>
+		</tr>
+
+		<tr>
+			<td id="footer">Policyd - Copyright &copy; 2008, LinuxRulz - <a href="http://www.policyd.org/v2/">http://www.policyd.org/v2/</a></td>
+		</tr>
+		<tr>
+			<td>
+				<div id="footerimages">
+					<img src="images/valid-xhtml10.png" alt="XHTML 1.0 Valid Logo"/>
+					<img src="images/valid-css2.png" alt="CSS 2.0 Valid Logo"/>
+					<img src="images/wcag1AAA.png" alt="Level Tripple-A Conformance"/>
+				</div>
+			</td>
+		</tr>
+	</table>
+    </body>
+</html>
+<?php
+}
+?>
diff --git a/webui/includes/header.php b/webui/includes/header.php
new file mode 100644
index 00000000..f33c5392
--- /dev/null
+++ b/webui/includes/header.php
@@ -0,0 +1,145 @@
+<?php
+
+include_once("includes/config.php");
+
+
+
+# Print out HTML header
+function printHeader($params = NULL)
+{
+	global $DB_POSTFIX_DSN;
+
+
+    # Pull in params
+    if (!is_null($params)) {
+		if (isset($params['Tabs'])) {
+			$tabs = $params['Tabs'];
+		}
+		if (isset($params['js.onLoad'])) {
+			$jsOnLoad = $params['js.onLoad'];
+		}
+		if (isset($params['Title'])) {
+			$title = $params['Title'];
+		}
+    }
+?>
+<!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>Policyd Web Administration</title>
+	<link rel="stylesheet" type="text/css" href="stylesheet.css" />
+	
+	<script type="text/javascript" src="tooltips/BubbleTooltips.js"></script>
+	<script type="text/javascript">
+		window.onload=function(){enableTooltips(null,"img")};
+	</script>
+    </head>
+
+
+	<body<?php if (!empty($jsOnLoad)) { echo " onLoad=\"".$jsOnLoad."\""; } ?>>
+
+
+	<table id="maintable">
+		<tr>
+			<td id="header">Policyd Web Administration</td>
+		</tr>
+
+		<tr>
+			<td>
+				<table>
+					<tr>
+						<td id="menu">
+	    					<img style="margin-top:-1px; margin-left:-1px;" src="images/top2.jpg" alt="" />
+	    					<p><a href=".">Home</a></p>
+
+							<p>Policies</p>
+							<ul>
+								<li><a href="policy-main.php">Main</a></li>
+								<li><a href="policy-group-main.php">Groups</a></li>
+							</ul>
+
+							<p>Access Control</p>
+							<ul>
+				   				<li><a href="accesscontrol-main.php">Configure</a></li>
+							</ul>
+					
+							<p>HELO/EHLO Checks</p>
+							<ul>
+		    					<li><a href="checkhelo-main.php">Configure</a></li>
+		    					<li><a href="checkhelo-blacklist-main.php">Blacklist</a></li>
+		    					<li><a href="checkhelo-whitelist-main.php">Whitelist</a></li>
+							</ul>
+					
+							<p>SPF Checks</p>
+							<ul>
+		    					<li><a href="checkspf-main.php">Configure</a></li>
+							</ul>
+					
+							<p>Greylisting</p>
+							<ul>
+		    					<li><a href="greylisting-main.php">Configure</a></li>
+		    					<li><a href="greylisting-whitelist-main.php">Whitelist</a></li>
+							</ul>
+					
+							<p>Quotas</p>
+							<ul>
+		    					<li><a href="quotas-main.php">Configure</a></li>
+							</ul>
+					
+							<p>Accounting</p>
+							<ul>
+		    					<li><a href="accounting-main.php">Configure</a></li>
+							</ul>
+					
+							<p>Amavis Integration</p>
+							<ul>
+		    					<li><a href="amavis-main.php">Configure</a></li>
+							</ul>
+<?php
+							# Check if postfix DSN is set
+							if (isset($DB_POSTFIX_DSN) && !empty($DB_POSTFIX_DSN)) 
+							{
+?>
+								<p>Postfix Integration</p>
+								<ul>
+		    						<li><a href="postfix-transports-main.php">Transports</a></li>
+		    						<li><a href="postfix-mailboxes-main.php">Mailboxes</a></li>
+		    						<li><a href="postfix-aliases-main.php">Aliases</a></li>
+		    						<li><a href="postfix-distgroups-main.php">Distribution Groups</a></li>
+								</ul>
+<?php
+							}
+?>					
+	    					<img style="margin-left:-1px; margin-bottom: -6px" src="images/specs_bottom.jpg" alt="" />
+						</td>
+
+						<td class="content">
+							<table class="content">
+<?php
+								# Check if we must display tabs or not
+								if (!empty($tabs)) {
+?>
+									<tr><td id="topmenu"><ul>
+<?php
+										foreach ($tabs as $key => $value) {
+?>											<li>
+												<a href="<?php echo $value ?>" 
+													title="<?php echo $key ?>">
+												<span><?php echo $key ?></span></a>
+											</li>
+<?php
+										}
+?>
+								    	</ul></td></tr>
+<?php
+								}	
+?>
+								<tr>
+									<td>
+<?php
+}
+
+
+# vim: ts=4
+?>
diff --git a/webui/includes/tooltipdata.php b/webui/includes/tooltipdata.php
new file mode 100644
index 00000000..0366d2bf
--- /dev/null
+++ b/webui/includes/tooltipdata.php
@@ -0,0 +1,81 @@
+<?php
+
+# Tooltip data
+$tooltips['policy_priority'] = "Priority. Range 0-100. 0: highest, 100: lowest. Priorities are processed in an ascending fashion, any rule linked to a policy has the potential to inherit, overwrite or merge the previous one.";
+
+$tooltips['policy_member_source'] = "Source: 'any' - Any source, '@domain' - From domain, 'user@domain' - From email address, 'a.b.c.d' - From IP address, 'a.b.c.d/e' - From a CIDR range, '%group' - From a group, '\$sasl_username' - From a SASL username, '\$*' would depict all SASL users.";
+$tooltips['policy_member_destination'] = "Destination. 'any' - Any destination, '@domain' - To domain, 'user@domain' - To to full email address, '%group' - To a group.";
+
+$tooltips['policy_group_member'] = "'@domain' - Domain, 'user@domain' - Full email address, 'a.b.c.d' - IP address, 'a.b.c.d/e' - CIDR range, '\$sasl_username' - From a SASL username, '\$*' would depict all SASL users.";
+
+$tooltips['accesscontrol_verdict'] = "HOLD - Quarantine message. REJECT - Reject message. DISCARD - Drop message. FILTER - Filter message through mechanism. REDIRECT - Redirect message to another email address.";
+$tooltips['accesscontrol_data'] = "Extra data to verdict the message with. For instance if the verdict is 'REJECT' you can set the data to 'Access Denied'.";
+
+$tooltips['checkhelo_blacklist_period'] = "Period in seconds to keep blacklisted server for.";
+$tooltips['checkhelo_blacklist_hrpperiod'] = "Period to look back to see how many HELO/EHLO's have been used, this in seconds.";
+$tooltips['checkhelo_blacklist_hrplimit'] = "Maxmim HELO/EHLO's to receive from host before we blacklist them.";
+$tooltips['checkhelo_rejectinvalid'] = "Reject HELO/EHLO's which are not standards compliant.";
+$tooltips['checkhelo_rejectip'] = "Reject IP's if they are used as the HELO/EHLO. The RFC requirement is FQDN.";
+$tooltips['checkhelo_rejectunresolv'] = "Reject unresolvable HELO/EHLO's, its an RFC requirement that the HELO/EHLO be a FQDN and resolvable.";
+
+$tooltips['checkhelo_blacklist_helo'] = "HELO/EHLO to blacklist.";
+
+$tooltips['checkhelo_whitelist_source'] = "Currently only 'SenderIP' is supported, the input box this can be a CIDR (a.b.c.d/e) range or IP address (a.b.c.d).";
+
+$tooltips['checkspf_rejectfailed'] = "Reject message if it fails SPF check.";
+$tooltips['checkspf_addheader'] = "If message is not rejected, add a header with the SPF information (if any).";
+
+$tooltips['greylisting_period'] = "Period in seconds to greylist for. A sane value is 240. Blank means inherit.";
+$tooltips['greylisting_track'] = "How to track the greylisting, this can currently only be a network mask in CIDR format. A sane value is /24.";
+$tooltips['greylisting_auth_validity'] = "Period in seconds to keep authenticated entries for. This is based on a rolling window. Blank means inherit. A sane value is 604800 (7 days).";
+$tooltips['greylisting_unauth_validity'] = "Period in seconds to keep unauthenticated entries for. This is based on a rolling window. Blank means inherit. A sane value is 86400 (1 day).";
+$tooltips['greylisting_unauth_validity'] = "Period in seconds to keep unauthenticated entries for. This is based on a rolling window. Blank means inherit. A sane value is 86400 (1 day).";
+
+$tooltips['greylisting_awl_period'] = "Period in seconds to automatically whitelist the sending server for. This is updated on in a rolling window fashion. Blank means inherit. A sane value is 604800.";
+$tooltips['greylisting_awl_count'] = "How many successful entries should it take before we whitelist. Blank means inherit, 0 means disable. A sane value for this is 500.";
+$tooltips['greylisting_awl_percentage'] = "This changes the function of the AWL Count, only autowhitelist after Count entries are recieved and Percentage of them are authenticated. Blank means inherit, 0 means disable. A sane set of values are 100 and 95 respectively.";
+
+$tooltips['greylisting_abl_period'] = "Period in seconds to automatically blacklist the sending server for. Blank means inherit. A sane value is 604800 (7 days).";
+$tooltips['greylisting_abl_count'] = "How many failed entries should it take before we blacklist. Blank means inherit, 0 means disable. A sane value for this is 500.";
+$tooltips['greylisting_abl_percentage'] = "This changes the function of the ABL Count, only autoblacklist after Count entries are recieved and Percentage of them are unauthenticated. Blank means inherit, 0 means disable. A sane set of values are 100 and 100 respectively.";
+
+$tooltips['greylisting_whitelist_source'] = "Currently only 'SenderIP' is supported, the input box this can be a CIDR (a.b.c.d/e) range or IP address (a.b.c.d).";
+
+$tooltips['amavis_bypass_virus_checks'] = "Bypass anti-virus checks.";
+$tooltips['amavis_bypass_banned_checks'] = "Bypass banned file checks.";
+$tooltips['amavis_bypass_spam_checks'] = "Bypass spam related checks.";
+$tooltips['amavis_bypass_header_checks'] = "Bypass malformed header checks.";
+$tooltips['amavis_spam_tag_level'] = "Begin tagging email at this score as clean.";
+$tooltips['amavis_spam_tag2_level'] = "Begin tagging email as SPAMMY at this score.";
+$tooltips['amavis_spam_tag3_level'] = "Tag email as SPAMMY at this score, but using you can specify a different subjet line. ie. 'Spam Tag3 Subject.'";
+$tooltips['amavis_spam_kill_level'] = "Score to trigger evasive action. ie. Reject or Quarantine.";
+$tooltips['amavis_spam_dsn_cutoff_level'] = "Spam score at which not to generate delivery status notifications.";
+$tooltips['amavis_spam_quarantine_cutoff_level'] = "Spam score at which not to quarantine.";
+$tooltips['amavis_spam_modifies_subject'] = "Modify email subject for this policy if spam is detected.";
+$tooltips['amavis_spam_tag_subject'] = "Subject to prepend to the email message when message exceeds spam tag level. Macros available are _REQD_ and _SCORE_ which are replaced with the required and actual score respectively.";
+$tooltips['amavis_spam_tag2_subject'] = "Subject to prepend to the email message when message exceeds spam tag2 level. Macros available are _REQD_ and _SCORE_ which are replaced with the required and actual score respectively.";
+$tooltips['amavis_spam_tag3_subject'] = "Subject to prepend to the email message when message exceeds spam tag3 level. Macros available are _REQD_ and _SCORE_ which are replaced with the required and actual score respectively.";
+$tooltips['amavis_max_message_size'] = "Maximum message size allowed. In Kbyte.";
+$tooltips['amavis_banned_files'] = "List of filename extensions and/or types to ban. Separated by , or ; or newline or whitespace. For example .exe,.bat,.dll,audio/*,video/*.";
+$tooltips['amavis_sender_whitelist'] = "Whitelist these senders, this allows them to always bypass the various checks. Email addresses are separated by a comma. Remeber however sender addresses can be forged!";
+$tooltips['amavis_sender_blacklist'] = "Blacklist these senders, this will automatically declare the email message as being spam. Email addresses should be separated by a comma.";
+$tooltips['amavis_notify_admin_newvirus'] = "Send newly encountered virus notifications to this address. This is new viruses encountered since last software start.";
+$tooltips['amavis_notify_admin_virus'] = "Send virus notifications to this address.";
+$tooltips['amavis_notify_admin_spam'] = "Send spam notifications to this address.";
+$tooltips['amavis_notify_admin_banned_file'] = "Send banned file notifications to this address.";
+$tooltips['amavis_notify_admin_bad_header'] = "Send bad header notifications to this address.";
+$tooltips['amavis_quarantine_virus'] = "Email address or facility to quanrantine emails containing viruses to.";
+$tooltips['amavis_quarantine_spam'] = "Email address or facility to quanrantine emails containing spam to.";
+$tooltips['amavis_quarantine_banned_file'] = "Email address or facility to quanrantine emails containing banned files to.";
+$tooltips['amavis_quarantine_bad_header'] = "Email address or facility to quanrantine emails containing bad headers to.";
+$tooltips['amavis_bcc_to'] = "Interception: BCC all email to this email address.";
+
+$tooltips['postfix_transport_type'] = "Transport for this domain, either SMTP to another server or Virtual for local.";
+
+$tooltips['postfix_mailbox_quota'] = "Mailbox size in Mbyte.";
+$tooltips['postfix_mailbox_bcc'] = "This is the Postfix BCC mapping, this occurs BEFORE Amavis integration.";
+
+$tooltips['postfix_alias_goto'] = "The destination email address.";
+
+
+?>
diff --git a/webui/includes/tooltips.php b/webui/includes/tooltips.php
new file mode 100644
index 00000000..708f86e2
--- /dev/null
+++ b/webui/includes/tooltips.php
@@ -0,0 +1,30 @@
+<?php
+# Tooltip handling code
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/tooltipdata.php");
+
+# Create tooltip
+function tooltip($text)
+{
+	global $tooltips;
+?>
+	<span id="tip"><img src="images/help.gif" alt="Tooltip" title="<?php echo htmlspecialchars($tooltips[$text]) ?>" /></span>
+<?php
+}
+
+?>
diff --git a/webui/index.php b/webui/index.php
new file mode 100644
index 00000000..7e5b548b
--- /dev/null
+++ b/webui/index.php
@@ -0,0 +1,145 @@
+<?php
+# Main index file
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+
+
+printHeader();
+
+?>
+	<p class="pageheader">Features Supported</p>
+	<ul>
+		<li>Protocols
+			<ul>
+				<li>Bizanga 
+					<a title="Help on Bizanga protocol" href="http://www.policyd.org/tiki-index.php?page=Bizanga&structure=Documentation" class="help">
+						<img src="images/help.gif" alt="Help" />
+					</a>
+				</li>
+				<li>Postfix
+					<a title="Help on Postfix protocol" href="http://www.policyd.org/tiki-index.php?page=Postfix&structure=Documentation" class="help">
+						<img src="images/help.gif" alt="Help" />
+					</a>
+				</li>
+			</ul>
+		</li>
+
+		<li>Policies &amp; Policy Groups
+			<a title="Help on policies and groups" href="http://www.policyd.org/tiki-index.php?page=Policies%20%26%20Groups&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>Define policy groups made up of various combinations of tags.</li>
+				<li>Define and manage policies comprising of ACL's which can include groups.</li>
+			</ul>
+		</li>
+
+		<li>Access Control
+			<a title="Help on access control" href="http://www.policyd.org/tiki-index.php?page=AccessControl&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>Control access based on policy. eg. Rejecting mail matching a specific policy.</li>
+			</ul>
+		</li>
+
+		<li>Amavis Integration
+			<a title="Help on Amavis integration" href="http://www.policyd.org/tiki-index.php?page=Amavis&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>Anti-virus checks.</li>
+				<li>Anti-spam checks.</li>
+				<li>Banned filename checks.</li>
+				<li>Email header checks.</li>
+				<li>Message size limits.</li>
+				<li>Blacklist/whitelist senders.</li>
+				<li>Email interception (BCC).</li>
+			</ul>
+		</li>
+
+		<li>Greylisting
+			<a title="Help on greylisting" href="http://www.policyd.org/tiki-index.php?page=Greylisting&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>Support for greylisting and masking sender IP addresses.</li>
+				<li>Support for auto-whitelisting and auto-greylisting based on count or count+percentage.</li>
+			</ul>
+		</li>
+
+		<li>HELO/EHLO Checks
+			<a title="Help on HELO/EHLO checks" href="http://www.policyd.org/tiki-index.php?page=CheckHelo&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>HELO/EHLO randomization prevention</li>
+				<li>Blacklisting of HELO/EHLO's ... those used by your own servers</li>
+				<li>Whitelisting of CIDR's which are known to be braindead</li>
+				<li>Check sending server HELO/EHLO for validity and RFC compliance.</li>
+			</ul>
+		</li>
+
+		<li>SPF Checks
+			<a title="Help on SPF checks" href="http://www.policyd.org/tiki-index.php?page=CheckSPF&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>Check the SPF records of a domain and see if the inbound email is allowed or prohibited.</li>
+			</ul>
+		</li>
+
+		<li>Quotas
+			<a title="Help on quotas" href="http://www.policyd.org/tiki-index.php?page=Quotas&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>Define message count quotas for policies.</li>
+				<li>Define cumulative size quotas for policies.</li>
+				<li>Track these quotas based on various methods, including sender IP block, sender user/domain/email address.</li>
+			</ul>
+		</li>
+
+		<li>Accounting
+			<a title="Help on accounting" href="http://www.policyd.org/tiki-index.php?page=Accounting&structure=Documentation" class="help">
+				<img src="images/help.gif" alt="Help" />
+			</a>
+			<ul>
+				<li>Message count and cumulative size accounting.</li>
+				<li>Message count and cumulative size limits per accounting period.</li>
+				<li>Daily, weekly and monthly accounting periods.</li>
+			</ul>
+		</li>
+
+		<li>Postfix Integration
+			<ul>
+				<li>Setup and create transports.</li>
+				<li>Create mailboxes.</li>
+				<li>Create mailbox aliases.</li>
+				<li>Manage distribution groups.</li>
+			</ul>
+		</li>
+
+	</ul>
+<?php
+
+printFooter();
+
+# vim: ts=4
+?>
diff --git a/webui/policy-add.php b/webui/policy-add.php
new file mode 100644
index 00000000..f53c96ea
--- /dev/null
+++ b/webui/policy-add.php
@@ -0,0 +1,128 @@
+<?php
+# Policy add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to policies" => "policy-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add Policy</p>
+
+	<form method="post" action="policy-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="policy_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Priority</td>
+				<td>
+					<input type="text" size="4" name="policy_priority" />
+					<?php tooltip('policy_priority'); ?>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle texttop">Description</td>
+				<td><textarea name="policy_description" cols="40" rows="5" /></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Policy Add Results</p>
+
+<?php
+	# Check name
+	if (empty($_POST['policy_name'])) {
+?>
+		<div class="warning">Policy name cannot be empty</div>
+<?php
+
+	# Check priority
+	} elseif (!isset($_POST['policy_priority'])) {
+?>
+		<div class="warning">Policy priority cannot be empty</div>
+<?php
+
+	# Check description
+	} elseif (empty($_POST['policy_description'])) {
+?>
+		<div class="warning">Policy description cannot be empty</div>
+<?php
+
+	} else {
+		$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}policies (Name,Priority,Description,Disabled) VALUES (?,?,?,1)");
+
+		$res = $stmt->execute(array(
+			$_POST['policy_name'],
+			$_POST['policy_priority'],
+			$_POST['policy_description']
+		));
+		if ($res) {
+?>
+			<div class="notice">Policy created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create policy</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-change.php b/webui/policy-change.php
new file mode 100644
index 00000000..8dcb5e67
--- /dev/null
+++ b/webui/policy-change.php
@@ -0,0 +1,166 @@
+<?php
+# Policy change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to policies" => "policy-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a policy was selected
+	if (isset($_POST['policy_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, Name, Priority, Description, Disabled FROM ${DB_TABLE_PREFIX}policies WHERE ID = ?");
+?>
+		<p class="pageheader">Update Policies</p>
+
+		<form action="policy-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="policy_id" value="<?php echo $_POST['policy_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['policy_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="policy_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Priority</td>
+					<td class="oldval"><?php echo $row->priority ?></td>
+					<td>
+						<input type="text" name="policy_priority" />
+						<?php tooltip('policy_priority'); ?>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Description</td>
+					<td class="oldval texttop"><?php echo $row->description ?></td>
+					<td><textarea name="policy_description" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="policy_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Policy Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['policy_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['policy_name']));
+	}
+	if (isset($_POST['policy_priority']) && $_POST['policy_priority'] != "") {
+		array_push($updates,"Priority = ".$db->quote($_POST['policy_priority']));
+	}
+	if (!empty($_POST['policy_description'])) {
+		array_push($updates,"Description = ".$db->quote($_POST['policy_description']));
+	}
+	if (isset($_POST['policy_disabled']) && $_POST['policy_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['policy_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}policies SET $updateStr WHERE ID = ".$db->quote($_POST['policy_id']));
+		if ($res) {
+?>
+			<div class="notice">Policy updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating policy!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to policy</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-delete.php b/webui/policy-delete.php
new file mode 100644
index 00000000..2e36962d
--- /dev/null
+++ b/webui/policy-delete.php
@@ -0,0 +1,137 @@
+<?php
+# Module: Policy delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to policies" => "policy-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a policy was selected
+	if (isset($_POST['policy_id'])) {
+?>
+		<p class="pageheader">Delete Policy</p>
+
+		<form action="policy-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="policy_id" value="<?php echo $_POST['policy_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Policy Delete Results</p>
+<?php
+	if (isset($_POST['policy_id'])) {
+		
+
+		if ($_POST['confirm'] == "yes") {	
+			$db->beginTransaction();
+
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policy_members WHERE PolicyID = ".$db->quote($_POST['policy_id']));
+			if ($res !== FALSE) {
+?>
+				<div class="notice">Policy members deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting policy members!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+				$db->rollback();
+			}
+
+			if ($res !== FALSE) {
+				$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policies WHERE ID = ".$db->quote($_POST['policy_id']));
+				if ($res) {
+?>
+					<div class="notice">Policy deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting policy!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+					$db->rollback();
+				}
+			}
+
+			if ($res) {
+				$db->commit();
+			}
+		} else {
+?>
+			<div class="notice">Policy not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no policy ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/policy-group-add.php b/webui/policy-group-add.php
new file mode 100644
index 00000000..bf0418e1
--- /dev/null
+++ b/webui/policy-group-add.php
@@ -0,0 +1,104 @@
+<?php
+# Policy group add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "policy-group-main.php",
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Policy Group</p>
+<?php
+?>
+		<form method="post" action="policy-group-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+				<input type="hidden" name="policy_group_id" value="<?php echo $_POST['policy_group_id'] ?>" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td><input type="text" name="policy_group_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td><textarea name="policy_group_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Policy Group Add Results</p>
+
+<?php
+
+	$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}policy_groups (Name,Comment,Disabled) VALUES (?,?,1)");
+	
+	$res = $stmt->execute(array(
+		$_POST['policy_group_name'],
+		$_POST['policy_group_comment']
+	));
+	if ($res) {
+?>
+		<div class="notice">Policy group created</div>
+<?php
+	} else {
+?>
+		<div class="warning">Failed to create policy group</div>
+		<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-group-change.php b/webui/policy-group-change.php
new file mode 100644
index 00000000..65afe1ac
--- /dev/null
+++ b/webui/policy-group-change.php
@@ -0,0 +1,146 @@
+<?php
+# Policy group change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "policy-group-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a policy was selected
+	if (isset($_POST['policy_group_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, Name, Disabled FROM ${DB_TABLE_PREFIX}policy_groups WHERE ID = ?");
+?>
+		<p class="pageheader">Update Policy Group</p>
+
+		<form action="policy-group-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="policy_group_id" value="<?php echo $_POST['policy_group_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['policy_group_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="policy_group_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="policy_group_disabled" />
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Policy Group Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['policy_group_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['policy_group_name']));
+	}
+	if (isset($_POST['policy_group_disabled']) && $_POST['policy_group_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['policy_group_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}policy_groups SET $updateStr WHERE ID = ".$db->quote($_POST['policy_group_id']));
+		if ($res) {
+?>
+			<div class="notice">Policy group updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating policy group!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to policy group</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-group-delete.php b/webui/policy-group-delete.php
new file mode 100644
index 00000000..88e26906
--- /dev/null
+++ b/webui/policy-group-delete.php
@@ -0,0 +1,136 @@
+<?php
+# Policy group delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "policy-group-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a policy group was selected
+	if (isset($_POST['policy_group_id'])) {
+?>
+		<p class="pageheader">Delete Policy Group</p>
+
+		<form action="policy-group-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="policy_group_id" value="<?php echo $_POST['policy_group_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy group selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Policy Group Delete Results</p>
+<?php
+	if (isset($_POST['policy_group_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$db->beginTransaction();
+
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policy_group_members WHERE PolicyGroupID = ".$db->quote($_POST['policy_group_id']));
+			if ($res !== FALSE) {
+?>
+				<div class="notice">Policy group members deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting policy group members!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+				$db->rollback();
+			}
+
+			if ($res !== FALSE) {
+				$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policy_groups WHERE ID = ".$db->quote($_POST['policy_group_id']));
+				if ($res) {
+?>
+					<div class="notice">Policy group deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting policy group!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+					$db->rollback();
+				}
+			}
+
+			if ($res) {
+				$db->commit();
+			}
+		} else {
+?>
+			<div class="notice">Policy group not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no policy group ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/policy-group-main.php b/webui/policy-group-main.php
new file mode 100644
index 00000000..7c38a9e5
--- /dev/null
+++ b/webui/policy-group-main.php
@@ -0,0 +1,101 @@
+<?php
+# Policy groups main screen
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+?>
+	<p class="pageheader">Policy Groups</p>
+
+	<form id="main_form" action="policy-group-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'policy-group-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'policy-group-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'policy-group-delete.php';
+						} else if (myobj.selectedIndex == 6) {
+							myform.action = 'policy-group-member-main.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+				<option value="members">Members</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "SELECT ID, Name, Disabled FROM ${DB_TABLE_PREFIX}policy_groups ORDER BY Name";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="policy_group_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->name ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+printFooter();
+
+# vim: ts=4
+?>
diff --git a/webui/policy-group-member-add.php b/webui/policy-group-member-add.php
new file mode 100644
index 00000000..93bf9229
--- /dev/null
+++ b/webui/policy-group-member-add.php
@@ -0,0 +1,110 @@
+<?php
+# Policy group member add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "policy-group-main.php",
+			"Back to members" => "policy-group-member-main.php?policy_group_id=".$_POST['policy_group_id'],
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Policy Group Member</p>
+<?php
+?>
+		<form method="post" action="policy-group-member-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+				<input type="hidden" name="policy_group_id" value="<?php echo $_POST['policy_group_id'] ?>" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">
+						Member
+						<?php tooltip('policy_group_member'); ?>
+					</td>
+					<td><input type="text" name="policy_group_member_member" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Comment</td>
+					<td><textarea name="policy_group_member_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Policy Group Member Add Results</p>
+
+<?php
+
+	$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}policy_group_members (PolicyGroupID,Member,Comment,Disabled) VALUES (?,?,?,1)");
+	
+	$res = $stmt->execute(array(
+		$_POST['policy_group_id'],
+		$_POST['policy_group_member_member'],
+		$_POST['policy_group_member_comment']
+	));
+	if ($res) {
+?>
+		<div class="notice">Policy group member created</div>
+<?php
+	} else {
+?>
+		<div class="warning">Failed to create policy group member</div>
+		<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-group-member-change.php b/webui/policy-group-member-change.php
new file mode 100644
index 00000000..dad89541
--- /dev/null
+++ b/webui/policy-group-member-change.php
@@ -0,0 +1,160 @@
+<?php
+# Policy group member change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "policy-group-main.php",
+			"Back to members" => "policy-group-member-main.php?policy_group_id=".$_POST['policy_group_id'],
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a policy was selected
+	if (isset($_POST['policy_group_member_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, Member, Comment, Disabled FROM ${DB_TABLE_PREFIX}policy_group_members WHERE ID = ?");
+?>
+		<p class="pageheader">Update Policy Group Member</p>
+
+		<form action="policy-group-member-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="policy_group_id" value="<?php echo $_POST['policy_group_id']; ?>" />
+				<input type="hidden" name="policy_group_member_id" value="<?php echo $_POST['policy_group_member_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['policy_group_member_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Member
+						<?php tooltip('policy_group_member'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->member ?></td>
+					<td><input type="text" name="policy_group_member_member" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="policy_group_member_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="policy_group_member_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Policy Group Member Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['policy_group_member_member'])) {
+		array_push($updates,"Member = ".$db->quote($_POST['policy_group_member_member']));
+	}
+	if (!empty($_POST['policy_group_member_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['policy_group_member_comment']));
+	}
+	if (isset($_POST['policy_group_member_disabled']) && $_POST['policy_group_member_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['policy_group_member_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}policy_group_members SET $updateStr WHERE ID = ".$db->quote($_POST['policy_group_member_id']));
+		if ($res) {
+?>
+			<div class="notice">Policy group member updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating policy group member!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to policy group member</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-group-member-delete.php b/webui/policy-group-member-delete.php
new file mode 100644
index 00000000..4b98be2e
--- /dev/null
+++ b/webui/policy-group-member-delete.php
@@ -0,0 +1,115 @@
+<?php
+# Policy group member delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "policy-group-main.php",
+			"Back to members" => "policy-group-member-main.php?policy_group_id=".$_POST['policy_group_id'],
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a policy group member was selected
+	if (isset($_POST['policy_group_member_id'])) {
+?>
+		<p class="pageheader">Delete Policy Group Member</p>
+
+		<form action="policy-group-member-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="policy_group_id" value="<?php echo $_POST['policy_group_id']; ?>" />
+				<input type="hidden" name="policy_group_member_id" value="<?php echo $_POST['policy_group_member_id']; ?>" />
+			</div>
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy group member selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Policy Group Member Delete Results</p>
+<?php
+	if (isset($_POST['policy_group_member_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policy_group_members WHERE ID = ".$db->quote($_POST['policy_group_member_id']));
+			if ($res) {
+?>
+				<div class="notice">Policy group member deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting policy group member!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Policy group member not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no policy group member ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/policy-group-member-main.php b/webui/policy-group-member-main.php
new file mode 100644
index 00000000..66edbbdd
--- /dev/null
+++ b/webui/policy-group-member-main.php
@@ -0,0 +1,124 @@
+<?php
+# Policy group member screen
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "policy-group-main.php"
+		),
+));
+
+
+# Check a policy group was selected
+if (isset($_REQUEST['policy_group_id'])) {
+
+?>
+	<p class="pageheader">Policy Group Members</p>
+	
+<?php		
+
+	$policy_group_stmt = $db->prepare("SELECT Name FROM ${DB_TABLE_PREFIX}policy_groups WHERE ID = ?");
+	$policy_group_stmt->execute(array($_REQUEST['policy_group_id']));
+	$row = $policy_group_stmt->fetchObject();
+	$policy_group_stmt->closeCursor();
+?>
+	<form id="main_form" action="policy-group-member-main.php" method="post">
+		<div>
+			<input type="hidden" name="policy_group_id" value="<?php echo $_REQUEST['policy_group_id'] ?>" />
+		</div>
+		<div class="textcenter">
+			<div class="notice">Policy Group: <?php echo $row->name ?></div>
+
+			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 = 'policy-group-member-add.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'policy-group-member-change.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'policy-group-member-delete.php';
+							myform.submit();
+						}
+">
+	 
+				<option selected>select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Member</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+
+			$stmt = $db->prepare("SELECT ID, Member, Disabled FROM ${DB_TABLE_PREFIX}policy_group_members WHERE PolicyGroupID = ?");
+			$res = $stmt->execute(array($_REQUEST['policy_group_id']));
+
+			$i = 0;
+
+			# Loop with rows
+			while ($row = $stmt->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="policy_group_member_id" value="<?php echo $row->id ?>" /></td>
+					<td class="textcenter"><?php echo $row->member ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+				}
+				$stmt->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-main.php b/webui/policy-main.php
new file mode 100644
index 00000000..02a444e7
--- /dev/null
+++ b/webui/policy-main.php
@@ -0,0 +1,111 @@
+<?php
+# Policy main screen
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">Policy List</p>
+
+	<form id="main_form" action="policy-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'policy-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'policy-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'policy-delete.php';
+						} else if (myobj.selectedIndex == 6) {
+							myform.action = 'policy-member-main.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+				<option value="members">Members</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Priority</td>
+				<td class="textcenter">Description</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "SELECT ID, Name, Priority, Description, Disabled FROM ${DB_TABLE_PREFIX}policies ORDER BY Priority ASC";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="policy_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->name ?></td>
+					<td class="textcenter"><?php echo $row->priority ?></td>
+					<td><?php echo $row->description ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-member-add.php b/webui/policy-member-add.php
new file mode 100644
index 00000000..3b146a62
--- /dev/null
+++ b/webui/policy-member-add.php
@@ -0,0 +1,132 @@
+<?php
+# Policy member add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to policies" => "policy-main.php",
+			"Back to members" => "policy-member-main.php?policy_id=".$_REQUEST['policy_id'],
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Policy Member</p>
+<?php
+	if (!empty($_POST['policy_id'])) {
+?>
+		<form method="post" action="policy-member-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+				<input type="hidden" name="policy_id" value="<?php echo $_POST['policy_id'] ?>" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle texttop">
+						Source
+						<?php tooltip('policy_member_source'); ?>
+					</td>
+					<td><textarea name="member_source" cols="40" rows="5"/></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">
+						Destination
+						<?php tooltip('policy_member_destination'); ?>
+					</td>
+					<td><textarea name="member_destination" cols="40" rows="5"/></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Comment</td>
+					<td><textarea name="member_comment"></textarea></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy ID, invalid invocation?</div>
+<?php
+	}
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Policy Member Add Results</p>
+
+<?php
+	# Check source and dest are not blank
+	if (empty($_POST['member_source']) && empty($_POST['member_destination'])) {
+?>
+		<div class="warning">A blank member is useless?</div>
+<?php
+
+
+	} else {
+		$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}policy_members (PolicyID,Source,Destination,Comment,Disabled) VALUES (?,?,?,?,1)");
+		
+		$res = $stmt->execute(array(
+			$_POST['policy_id'],
+			$_POST['member_source'],
+			$_POST['member_destination'],
+			$_POST['member_comment']
+		));
+		if ($res) {
+?>
+			<div class="notice">Policy member created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create policy member</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/policy-member-change.php b/webui/policy-member-change.php
new file mode 100644
index 00000000..b7c4f981
--- /dev/null
+++ b/webui/policy-member-change.php
@@ -0,0 +1,181 @@
+<?php
+# Policy member change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to policies" => "policy-main.php",
+			"Back to members" => "policy-member-main.php?policy_id=".$_REQUEST['policy_id'],
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a policy member was selected
+	if (isset($_POST['policy_member_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, Source, Destination, Comment, Disabled FROM ${DB_TABLE_PREFIX}policy_members WHERE ID = ?");
+		$res = $stmt->execute(array($_POST['policy_member_id']));
+		$row = $stmt->fetchObject();
+		$stmt->closeCursor();
+?>
+		<p class="pageheader">Update Policy Member</p>
+
+		<form action="policy-member-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="policy_id" value="<?php echo $_POST['policy_id']; ?>" />
+				<input type="hidden" name="policy_member_id" value="<?php echo $_POST['policy_member_id']; ?>" />
+			</div>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">
+						Source
+						<?php tooltip('policy_member_source'); ?>
+					</td>
+					<td class="oldval texttop"><?php echo $row->source ?></td>
+					<td><textarea name="policy_member_source" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">
+						Destination
+						<?php tooltip('policy_member_destination'); ?>
+					</td>
+					<td class="oldval texttop"><?php echo $row->destination ?></td>
+					<td><textarea name="policy_member_destination" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="policy_member_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="policy_member_disabled" />
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Policy Update Results</p>
+<?php
+	# Check a policy was selected
+	if (isset($_POST['policy_member_id'])) {
+		
+		$updates = array();
+
+		if (!empty($_POST['policy_member_source'])) {
+			array_push($updates,"Source = ".$db->quote($_POST['policy_member_source']));
+		}
+		if (isset($_POST['policy_member_destination']) && $_POST['policy_member_destination'] != "") {
+			array_push($updates,"Destination = ".$db->quote($_POST['policy_member_destination']));
+		}
+		if (!empty($_POST['policy_member_comment'])) {
+			array_push($updates,"Comment = ".$db->quote($_POST['policy_member_comment']));
+		}
+		if (isset($_POST['policy_member_disabled']) && $_POST['policy_member_disabled'] != "") {
+			array_push($updates ,"Disabled = ".$db->quote($_POST['policy_member_disabled']));
+		}
+
+		# Check if we have updates
+		if (sizeof($updates) > 0) {
+			$updateStr = implode(', ',$updates);
+	
+			$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}policy_members SET $updateStr WHERE ID = ".$db->quote($_POST['policy_member_id']));
+			if ($res) {
+?>
+				<div class="notice">Policy member updated</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error updating policy member!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+
+		# Warn
+		} else {
+?>
+			<div class="warning">No policy member updates</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="error">No policy member data available</div>
+<?php
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/policy-member-delete.php b/webui/policy-member-delete.php
new file mode 100644
index 00000000..e00239e6
--- /dev/null
+++ b/webui/policy-member-delete.php
@@ -0,0 +1,116 @@
+<?php
+# Policy member delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to policies" => "policy-main.php",
+			"Back to members" => "policy-member-main.php?policy_id=".$_REQUEST['policy_id'],
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a policy was selected
+	if (isset($_POST['policy_member_id'])) {
+?>
+		<p class="pageheader">Delete Policy Member</p>
+
+		<form action="policy-member-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="policy_id" value="<?php echo $_POST['policy_id']; ?>" />
+				<input type="hidden" name="policy_member_id" value="<?php echo $_POST['policy_member_id']; ?>" />
+			</div>
+
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Policy Member Delete Results</p>
+<?php
+	if (isset($_POST['policy_member_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policy_members WHERE ID = ".$db->quote($_POST['policy_member_id']));
+			if ($res) {
+?>
+				<div class="notice">Policy member deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting policy member!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Policy member not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no policy member ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/policy-member-main.php b/webui/policy-member-main.php
new file mode 100644
index 00000000..b18eebf0
--- /dev/null
+++ b/webui/policy-member-main.php
@@ -0,0 +1,126 @@
+<?php
+# Policy ACL main screen
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to policies" => "policy-main.php"
+		),
+));
+
+
+# Check a policy was selected
+if (isset($_REQUEST['policy_id'])) {
+
+?>
+	<p class="pageheader">Policy Members</p>
+	
+<?php		
+
+	$policy_stmt = $db->prepare("SELECT Name FROM ${DB_TABLE_PREFIX}policies WHERE ID = ?");
+	$policy_stmt->execute(array($_REQUEST['policy_id']));
+	$row = $policy_stmt->fetchObject();
+	$policy_stmt->closeCursor();
+?>
+	<form id="main_form" action="policy-member-main.php" method="post">
+		<div>
+			<input type="hidden" name="policy_id" value="<?php echo $_REQUEST['policy_id'] ?>" />
+		</div>
+		<div class="textcenter">
+			<div class="notice">Policy: <?php echo $row->name ?></div>
+
+			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 = 'policy-member-add.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'policy-member-change.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'policy-member-delete.php';
+							myform.submit();
+						}
+">
+	 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Source</td>
+				<td class="textcenter">Destination</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+
+			$stmt = $db->prepare("SELECT ID, Source, Destination, Disabled FROM ${DB_TABLE_PREFIX}policy_members WHERE PolicyID = ?");
+			$res = $stmt->execute(array($_REQUEST['policy_id']));
+
+			$i = 0;
+
+			# Loop with rows
+			while ($row = $stmt->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="policy_member_id" value="<?php echo $row->id ?>" /></td>
+					<td class="textcenter"><?php echo is_null($row->source) ? 'any' : $row->source ?></td>
+					<td class="textcenter"><?php echo is_null($row->destination) ? 'any' : $row->destination ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+				}
+				$stmt->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-aliases-add.php b/webui/postfix-aliases-add.php
new file mode 100644
index 00000000..9ccb6fb1
--- /dev/null
+++ b/webui/postfix-aliases-add.php
@@ -0,0 +1,135 @@
+<?php
+# Postfix aliases add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Aliases" => "postfix-aliases-main.php",
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Postfix Alias</p>
+<?php
+?>
+		<form method="post" action="postfix-aliases-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">
+						Alias Address
+					</td>
+					<td>
+						<input type="text" name="postfix_alias_address" /> @
+						<select name="postfix_transport_id">
+<?php
+							$sql = "SELECT ID, DomainName FROM ${DB_TABLE_PREFIX}transports WHERE Disabled = 0 ORDER BY DomainName";
+							$res = $db->query($sql);
+
+							while ($row = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row->id ?>">
+									<?php echo $row->domainname ?>
+								</option>
+<?php
+							}
+							$res->closeCursor();
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Goto
+						<?php tooltip('postfix_alias_goto'); ?>
+					</td>
+					<td><input type="text" name="postfix_alias_goto" /></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Postfix Alias Add Results</p>
+
+<?php
+	# Prepare statement
+	$stmt = $db->prepare("SELECT ID, DomainName, Type, Transport, Disabled FROM ${DB_TABLE_PREFIX}transports WHERE ID = ?");
+	$res = $stmt->execute(array($_POST['postfix_transport_id']));
+	$row = $stmt->fetchObject();
+
+	$mailbox = $_POST['postfix_alias_address'] . '@' . $row->domainname;
+
+
+	$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}aliases (TransportID,Address,MailAddress,Goto,Disabled) VALUES (?,?,?,?,0)");
+	$res = $stmt->execute(array(
+		$row->id,
+		$_POST['postfix_alias_address'],
+		$mailbox,
+		$_POST['postfix_alias_goto']
+	));
+	
+	if ($res) {
+?>
+		<div class="notice">Postfix alias created</div>
+<?php
+	} else {
+?>
+		<div class="warning">Failed to create Postfix alias</div>
+		<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-aliases-change.php b/webui/postfix-aliases-change.php
new file mode 100644
index 00000000..2e35a004
--- /dev/null
+++ b/webui/postfix-aliases-change.php
@@ -0,0 +1,156 @@
+<?php
+# Postfix alias change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Aliases" => "postfix-aliases-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a alias was selected
+	if (isset($_POST['postfix_alias_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, MailAddress, Goto, Disabled FROM ${DB_TABLE_PREFIX}aliases WHERE ID = ?");
+?>
+		<p class="pageheader">Update Postfix Alias</p>
+
+		<form action="postfix-aliases-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="postfix_alias_id" value="<?php echo $_POST['postfix_alias_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['postfix_alias_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Alias Address</td>
+					<td class="oldval"><?php echo $row->mailaddress ?></td>
+					<td></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Goto
+						<?php tooltip('postfix_alias_goto'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->goto ?></td>
+					<td><input type="text" name="postfix_alias_goto" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="postfix_alias_disabled" />
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No alias selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Policy Group Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['postfix_alias_goto'])) {
+		array_push($updates ,"Goto = ".$db->quote($_POST['postfix_alias_goto']));
+	}
+	if (isset($_POST['postfix_alias_disabled']) && $_POST['postfix_alias_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['postfix_alias_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}aliases SET $updateStr WHERE ID = ".$db->quote($_POST['postfix_alias_id']));
+		if ($res) {
+?>
+			<div class="notice">Postfix alias updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating Postfix alias!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to Postfix alias</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-aliases-delete.php b/webui/postfix-aliases-delete.php
new file mode 100644
index 00000000..887d10e4
--- /dev/null
+++ b/webui/postfix-aliases-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Postfix alias delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Aliases" => "postfix-aliases-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a Postfix alias was selected
+	if (isset($_POST['postfix_alias_id'])) {
+?>
+		<p class="pageheader">Delete Postfix Alias</p>
+
+		<form action="postfix-aliases-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="postfix_alias_id" value="<?php echo $_POST['postfix_alias_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No Postfix alias selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Postfix Alias Delete Results</p>
+<?php
+	if (isset($_POST['postfix_alias_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}aliases WHERE ID = ".$db->quote($_POST['postfix_alias_id']));
+			if ($res) {
+?>
+				<div class="notice">Postfix alias deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting Postfix alias!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Postfix alias not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no Postfix alias ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/postfix-aliases-main.php b/webui/postfix-aliases-main.php
new file mode 100644
index 00000000..982986a8
--- /dev/null
+++ b/webui/postfix-aliases-main.php
@@ -0,0 +1,100 @@
+<?php
+# Postfix aliases
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+));
+
+?>
+	<p class="pageheader">Postfix Aliases</p>
+
+	<form id="main_form" action="postfix-aliases-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'postfix-aliases-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'postfix-aliases-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'postfix-aliases-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Alias</td>
+				<td class="textcenter">Destination</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "SELECT ID, MailAddress, Goto, Disabled FROM ${DB_TABLE_PREFIX}aliases ORDER BY MailAddress";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="postfix_alias_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->mailaddress ?></td>
+					<td><?php echo $row->goto ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+printFooter();
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-distgroups-add.php b/webui/postfix-distgroups-add.php
new file mode 100644
index 00000000..2e7f772d
--- /dev/null
+++ b/webui/postfix-distgroups-add.php
@@ -0,0 +1,131 @@
+<?php
+# Postfix distribution group add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "postfix-distgroups-main.php",
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Distribution Group</p>
+<?php
+?>
+		<form method="post" action="postfix-distgroups-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+				<input type="hidden" name="postfix_group_id" value="<?php echo $_POST['postfix_group_id'] ?>" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">Mail Address</td>
+					<td>
+						<input type="text" name="postfix_group_address" /> @
+						<select name="postfix_transport_id">
+<?php
+							$sql = "SELECT ID, DomainName FROM ${DB_TABLE_PREFIX}transports WHERE Disabled = 0 ORDER BY DomainName";
+							$res = $db->query($sql);
+
+							while ($row = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row->id ?>">
+									<?php echo $row->domainname ?>
+								</option>
+<?php
+							}
+							$res->closeCursor();
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Comment</td>
+					<td><textarea name="postfix_group_comment"></textarea></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Distribution Group Add Results</p>
+
+<?php
+	# Prepare statement
+	$stmt = $db->prepare("SELECT ID, DomainName, Type, Transport, Disabled FROM ${DB_TABLE_PREFIX}transports WHERE ID = ?");
+	$res = $stmt->execute(array($_POST['postfix_transport_id']));
+	$row = $stmt->fetchObject();
+
+	$mailbox = $_POST['postfix_group_address'] . '@' . $row->domainname;
+
+
+	$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}distribution_groups (TransportID,Address,MailAddress,Comment,Disabled) VALUES (?,?,?,?,0)");
+
+	$res = $stmt->execute(array(
+		$row->id,
+		$_POST['postfix_group_address'],
+		$mailbox,
+		$_POST['postfix_group_comment']
+	));
+
+	if ($res) {
+?>
+		<div class="notice">Distribution group created</div>
+<?php
+	} else {
+?>
+		<div class="warning">Failed to create distribution group</div>
+		<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-distgroups-change.php b/webui/postfix-distgroups-change.php
new file mode 100644
index 00000000..5900010d
--- /dev/null
+++ b/webui/postfix-distgroups-change.php
@@ -0,0 +1,151 @@
+<?php
+# Postfixdistribution group change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "postfix-distgroups-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a group was selected
+	if (isset($_POST['postfix_group_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, MailAddress, Comment, Disabled FROM ${DB_TABLE_PREFIX}distribution_groups WHERE ID = ?");
+?>
+		<p class="pageheader">Update Distribution Group</p>
+
+		<form action="postfix-distgroups-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="postfix_group_id" value="<?php echo $_POST['postfix_group_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['postfix_group_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Mail Address</td>
+					<td class="oldval"><?php echo $row->mailaddress ?></td>
+					<td></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="postfix_group_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="postfix_group_disabled" />
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No distribution group selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Distribution Group Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['postfix_group_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['postfix_group_comment']));
+	}
+	if (isset($_POST['postfix_group_disabled']) && $_POST['postfix_group_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['postfix_group_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}distribution_groups SET $updateStr WHERE ID = ".$db->quote($_POST['postfix_group_id']));
+		if ($res) {
+?>
+			<div class="notice">Distribution group updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating distribution group!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to distribution group</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-distgroups-delete.php b/webui/postfix-distgroups-delete.php
new file mode 100644
index 00000000..c34130ac
--- /dev/null
+++ b/webui/postfix-distgroups-delete.php
@@ -0,0 +1,135 @@
+<?php
+# Distribution group delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "postfix-distgroups-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a postfix group was selected
+	if (isset($_POST['postfix_group_id'])) {
+?>
+		<p class="pageheader">Delete Distribution Group</p>
+
+		<form action="postfix-distgroups-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="postfix_group_id" value="<?php echo $_POST['postfix_group_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No distribution group selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Distribution Group Delete Results</p>
+<?php
+	if (isset($_POST['postfix_group_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			
+			$res = $db->exec("
+				DELETE FROM 
+					${DB_TABLE_PREFIX}distribution_group_members 
+				WHERE 
+					DistributionGroupID = ".$db->quote($_POST['postfix_group_id'])
+			);
+			if ($res !== FALSE) {
+?>
+				<div class="notice">Distribution group members deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting distribution group members!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+				$db->rollback();
+			}
+
+			if ($res !== FALSE) {
+				$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}distribution_groups WHERE ID = ".$db->quote($_POST['postfix_group_id']));
+				if ($res) {
+?>
+					<div class="notice">Distribution group deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting distribution group!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+				}
+			}
+		} else {
+?>
+			<div class="notice">Distribution group not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no distribution group ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/postfix-distgroups-main.php b/webui/postfix-distgroups-main.php
new file mode 100644
index 00000000..b343d458
--- /dev/null
+++ b/webui/postfix-distgroups-main.php
@@ -0,0 +1,101 @@
+<?php
+# Postfix distribution groups main screen
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+));
+
+?>
+	<p class="pageheader">Distribution Groups</p>
+
+	<form id="main_form" action="postfix-distgroups-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'postfix-distgroups-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'postfix-distgroups-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'postfix-distgroups-delete.php';
+						} else if (myobj.selectedIndex == 6) {
+							myform.action = 'postfix-distgroups-member-main.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+				<option value="members">Members</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Mail Address</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "SELECT ID, MailAddress, Disabled FROM ${DB_TABLE_PREFIX}distribution_groups ORDER BY MailAddress";
+			$res = $db->query($sql);
+			
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="postfix_group_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->mailaddress ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+printFooter();
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-distgroups-member-add.php b/webui/postfix-distgroups-member-add.php
new file mode 100644
index 00000000..1811b98c
--- /dev/null
+++ b/webui/postfix-distgroups-member-add.php
@@ -0,0 +1,102 @@
+<?php
+# Postfix distribution group member add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "postfix-distgroups-main.php",
+			"Back to members" => "postfix-distgroups-member-main.php?postfix_group_id=".$_POST['postfix_group_id'],
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Distribution Group Member</p>
+<?php
+?>
+		<form method="post" action="postfix-distgroups-member-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+				<input type="hidden" name="postfix_group_id" value="<?php echo $_POST['postfix_group_id'] ?>" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">Email Address</td>
+					<td><input type="text" name="postfix_group_member_goto" /></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Distribution Group Member Add Results</p>
+
+<?php
+
+	$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}distribution_group_members (DistributionGroupID,Goto,Disabled) VALUES (?,?,0)");
+	
+	$res = $stmt->execute(array(
+		$_POST['postfix_group_id'],
+		$_POST['postfix_group_member_goto']
+	));
+
+
+	if ($res) {
+?>
+		<div class="notice">Distribution group member created</div>
+<?php
+	} else {
+?>
+		<div class="warning">Failed to create distribution group member</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-distgroups-member-change.php b/webui/postfix-distgroups-member-change.php
new file mode 100644
index 00000000..a2d8569a
--- /dev/null
+++ b/webui/postfix-distgroups-member-change.php
@@ -0,0 +1,147 @@
+<?php
+# Postfix distribution group member change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "postfix-distgroups-main.php",
+			"Back to members" => "postfix-distgroups-member-main.php?postfix_group_id=".$_POST['postfix_group_id'],
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a postfix was selected
+	if (isset($_POST['postfix_group_member_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, Goto, Disabled FROM ${DB_TABLE_PREFIX}distribution_group_members WHERE ID = ?");
+?>
+		<p class="pageheader">Update Distribution Group Member</p>
+
+		<form action="postfix-distgroups-member-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="postfix_group_id" value="<?php echo $_POST['postfix_group_id']; ?>" />
+				<input type="hidden" name="postfix_group_member_id" value="<?php echo $_POST['postfix_group_member_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['postfix_group_member_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Email Address</td>
+					<td class="oldval"><?php echo $row->goto ?></td>
+					<td><input type="text" name="postfix_group_member_goto" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="postfix_group_member_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No distribution group selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Distribution Group Member Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['postfix_group_member_goto'])) {
+		array_push($updates,"Goto = ".$db->quote($_POST['postfix_group_member_goto']));
+	}
+	if (isset($_POST['postfix_group_member_disabled']) && $_POST['postfix_group_member_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['postfix_group_member_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}distribution_group_members SET $updateStr WHERE ID = ".$db->quote($_POST['postfix_group_member_id']));
+		if ($res) {
+?>
+			<div class="notice">Distribution group member updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating distribution group member!</div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to distribution group member</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-distgroups-member-delete.php b/webui/postfix-distgroups-member-delete.php
new file mode 100644
index 00000000..cbb624a0
--- /dev/null
+++ b/webui/postfix-distgroups-member-delete.php
@@ -0,0 +1,116 @@
+<?php
+# Postfix distribution group member delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "postfix-group-main.php",
+			"Back to members" => "postfix-distgroups-member-main.php?postfix_group_id=".$_POST['postfix_group_id'],
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a postfix group member was selected
+	if (isset($_POST['postfix_group_member_id'])) {
+?>
+		<p class="pageheader">Delete Distribution Group Member</p>
+
+		<form action="postfix-distgroups-member-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="postfix_group_id" value="<?php echo $_POST['postfix_group_id']; ?>" />
+				<input type="hidden" name="postfix_group_member_id" value="<?php echo $_POST['postfix_group_member_id']; ?>" />
+			</div>
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No distribution group member selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Distribution Group Member Delete Results</p>
+<?php
+	if (isset($_POST['postfix_group_member_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}distribution_group_members WHERE ID = ".$db->quote($_POST['postfix_group_member_id']));
+			
+			if ($res) {
+?>
+				<div class="notice">Distribution group member deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting distribution group member!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Distribution group member not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no distribution group member ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/postfix-distgroups-member-main.php b/webui/postfix-distgroups-member-main.php
new file mode 100644
index 00000000..e93a50d6
--- /dev/null
+++ b/webui/postfix-distgroups-member-main.php
@@ -0,0 +1,131 @@
+<?php
+# Distribution group member screen
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to groups" => "postfix-distgroups-main.php"
+		),
+));
+
+
+# Check a postfix group was selected
+if (isset($_REQUEST['postfix_group_id'])) {
+
+?>
+	<p class="pageheader">Distribution Group Members</p>
+	
+<?php		
+
+	$postfix_group_stmt = $db->prepare("SELECT MailAddress FROM ${DB_TABLE_PREFIX}distribution_groups WHERE ID = ?");
+	$postfix_group_stmt->execute(array($_REQUEST['postfix_group_id']));
+	$row = $postfix_group_stmt->fetchObject();
+	$postfix_group_stmt->closeCursor();
+?>
+	<form id="main_form" action="postfix-distgroups-member-main.php" method="post">
+		<div>
+			<input type="hidden" name="postfix_group_id" value="<?php echo $_REQUEST['postfix_group_id'] ?>" />
+		</div>
+		<div class="textcenter">
+			<div class="notice">Distribution Group: <?php echo $row->mailaddress ?></div>
+
+			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 = 'postfix-distgroups-member-add.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'postfix-distgroups-member-change.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'postfix-distgroups-member-delete.php';
+							myform.submit();
+						}
+">
+	 
+				<option selected>select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Goto</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+
+			$stmt = $db->prepare("
+				SELECT 
+					ID, Goto, Disabled 
+				FROM 
+					${DB_TABLE_PREFIX}distribution_group_members
+				WHERE 
+					DistributionGroupID = ? ORDER BY Goto
+			");
+			$res = $stmt->execute(array($_REQUEST['postfix_group_id']));
+
+			$i = 0;
+
+			# Loop with rows
+			while ($row = $stmt->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="postfix_group_member_id" value="<?php echo $row->id ?>" /></td>
+					<td class="textcenter"><?php echo $row->goto ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$stmt->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-mailboxes-add.php b/webui/postfix-mailboxes-add.php
new file mode 100644
index 00000000..48a15fc9
--- /dev/null
+++ b/webui/postfix-mailboxes-add.php
@@ -0,0 +1,165 @@
+<?php
+# Postfix mailbox add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Mailboxes" => "postfix-mailboxes-main.php",
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Mailbox</p>
+<?php
+?>
+		<form method="post" action="postfix-mailboxes-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">Email Address</td>
+					<td>
+						<input type="text" size="8" name="postfix_mailbox_address" /> @
+						<select name="postfix_transport_id">
+<?php
+							$sql = "SELECT ID, DomainName FROM ${DB_TABLE_PREFIX}transports WHERE Disabled = 0 ORDER BY DomainName";
+							$res = $db->query($sql);
+
+							while ($row = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row->id ?>">
+									<?php echo $row->domainname ?>
+								</option>
+<?php
+							}
+							$res->closeCursor();
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td><input type="text" name="postfix_mailbox_name" id="postfix_mailbox_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Password</td>
+					<td><input type="text" name="postfix_mailbox_password" id="postfix_mailbox_password" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Quota (in Mbyte)
+						<?php tooltip('postfix_mailbox_quota'); ?>
+					</td>
+					<td><input type="text" name="postfix_mailbox_quota" size="5" id="postfix_mailbox_quota" /> (0 = unlimited)</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						BCC
+						<?php tooltip('postfix_mailbox_bcc'); ?>
+					</td>
+					<td><input type="text" name="postfix_mailbox_bcc" id="postfix_mailbox_bcc" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Comment</td>
+					<td><textarea name="postfix_mailbox_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Mailbox Add Results</p>
+
+<?php
+	# Prepare statement
+	$stmt = $db->prepare("SELECT ID, DomainName, Type, Transport, Disabled FROM ${DB_TABLE_PREFIX}transports WHERE ID = ?");
+	$res = $stmt->execute(array($_POST['postfix_transport_id']));
+	$row = $stmt->fetchObject();
+
+	$mailbox = $_POST['postfix_mailbox_address'] . '@' . $row->domainname;
+
+	$stmt = $db->prepare("
+		INSERT INTO ${DB_TABLE_PREFIX}mailboxes 
+			(TransportID,Address,Mailbox,Password,Quota,Name,BCC,Comment,Disabled) 
+		VALUES 
+			(?,?,?,?,?,?,?,?,0)
+	");
+
+	# Encrypt password
+	$password = "{MD5}".base64_encode(pack("H*", md5($_POST['postfix_mailbox_password'])));
+
+	$res = $stmt->execute(array(
+		$_POST['postfix_transport_id'],
+		$_POST['postfix_mailbox_address'],
+		$mailbox,
+		$password,
+		$_POST['postfix_mailbox_quota'],
+		$_POST['postfix_mailbox_name'],
+		$_POST['postfix_mailbox_bcc'],
+		$_POST['postfix_mailbox_comment'],
+	));
+
+
+	if ($res) {
+?>
+		<div class="notice">Mailbox created</div>
+<?php
+	} else {
+?>
+		<div class="warning">Failed to create mailbox</div>
+		<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-mailboxes-change.php b/webui/postfix-mailboxes-change.php
new file mode 100644
index 00000000..4773083e
--- /dev/null
+++ b/webui/postfix-mailboxes-change.php
@@ -0,0 +1,216 @@
+<?php
+# Postfix mailbox change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Mailboxes" => "postfix-mailboxes-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a mailbox was selected
+	if (isset($_POST['postfix_mailbox_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+				SELECT 
+					ID, 
+					Mailbox, 
+					Quota, 
+					Name, 
+					BCC, 
+					Comment, 
+					Disabled 
+				FROM 
+					${DB_TABLE_PREFIX}mailboxes
+				WHERE 
+					ID = ?
+		");
+?>
+		<p class="pageheader">Update Mailbox</p>
+
+		<form action="postfix-mailboxes-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="postfix_mailbox_id" value="<?php echo $_POST['postfix_mailbox_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['postfix_mailbox_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Mailbox</td>
+					<td class="oldval"><?php echo $row->mailbox ?></td>
+					<td></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="postfix_mailbox_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Password</td>
+					<td class="oldval">*encrypted*</td>
+					<td><input type="text" name="postfix_mailbox_password" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Quota (in Mbyte)
+						<?php tooltip('postfix_mailbox_quota'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->quota ?></td>
+					<td><input type="text" name="postfix_mailbox_quota" /> (0 = unlimited)</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						BCC
+						<?php tooltip('postfix_mailbox_bcc'); ?>
+					</td>
+					<td class="oldval"><?php echo $row->bcc ?></td>
+					<td><input type="text" name="postfix_mailbox_bcc" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="postfix_mailbox_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="postfix_mailbox_disabled" />
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No mailbox selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Mailbox Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['postfix_mailbox_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['postfix_mailbox_name']));
+	}
+
+	if (!empty($_POST['postfix_mailbox_password'])) {
+		# Encrypt password
+		$password = "{MD5}".base64_encode(pack("H*", md5($_POST['postfix_mailbox_password'])));
+
+		array_push($updates,"Password = ".$db->quote($password));
+	}
+
+	if (isset($_POST['postfix_mailbox_quota'])) {
+		if (!empty($_POST['postfix_mailbox_quota'])) {
+			$quota = $db->quote($_POST['postfix_mailbox_quota']);
+			array_push($updates,"Quota = ".$quota);
+		}
+	}
+
+	if (!empty($_POST['postfix_mailbox_bcc'])) {
+		array_push($updates,"BCC = ".$db->quote($_POST['postfix_mailbox_bcc']));
+	}
+
+	if (!empty($_POST['postfix_mailbox_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['postfix_mailbox_comment']));
+	}
+
+	if (isset($_POST['postfix_mailbox_disabled']) && $_POST['postfix_mailbox_disabled'] != "") {
+		array_push($updates,"Disabled = ".$db->quote($_POST['postfix_mailbox_disabled']));
+	}
+
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}mailboxes SET $updateStr WHERE ID = ".$db->quote($_POST['postfix_mailbox_id']));
+		if ($res) {
+?>
+			<div class="notice">Mailbox updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating mailbox!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to Postfix mailbox</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-mailboxes-delete.php b/webui/postfix-mailboxes-delete.php
new file mode 100644
index 00000000..6e010821
--- /dev/null
+++ b/webui/postfix-mailboxes-delete.php
@@ -0,0 +1,159 @@
+<?php
+# Postfix mailbox delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Mailboxes" => "postfix-mailboxes-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a Postfix mailbox was selected
+	if (isset($_POST['postfix_mailbox_id'])) {
+?>
+		<p class="pageheader">Delete Mailbox</p>
+
+		<form action="postfix-mailboxes-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="postfix_mailbox_id" value="<?php echo $_POST['postfix_mailbox_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No mailbox selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Mailbox Delete Results</p>
+<?php
+	if (isset($_POST['postfix_mailbox_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			# Grab tracking limits we must delete for
+			$res = $db->query("
+					SELECT 
+						Mailbox
+					FROM 
+						${DB_TABLE_PREFIX}mailboxes
+					WHERE
+						ID = ".$db->quote($_POST['postfix_mailbox_id'])."
+			");
+
+			if ($res !== FALSE) {
+				# Pull in limit ID's
+				$row = $res->fetchObject();
+				$res->closeCursor();
+				$mailbox = $row->mailbox;
+			} else {
+?>
+				<div class="warning">Error selecting mailbox!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+
+			$db->beginTransaction();
+
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}distribution_group_members WHERE Goto = ".$db->quote($mailbox));
+			if ($res !== FALSE) {
+?>
+				<div class="notice">Mailbox removed from distribution groups</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error removing mailbox from distribution groups!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+				$db->rollBack();
+			}
+
+			if ($res !== FALSE) {	
+				$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}mailboxes WHERE ID = ".$db->quote($_POST['postfix_mailbox_id']));
+				if ($res) {
+?>
+					<div class="notice">Mailbox deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting mailbox!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+					$db->rollBack();
+				}
+			}
+
+			if ($res) {
+				$db->commit();
+			}
+
+		} else {
+?>
+			<div class="notice">Mailbox not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no mailbox ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/postfix-mailboxes-main.php b/webui/postfix-mailboxes-main.php
new file mode 100644
index 00000000..bb67e028
--- /dev/null
+++ b/webui/postfix-mailboxes-main.php
@@ -0,0 +1,101 @@
+<?php
+# Postfix mailboxes
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+));
+
+?>
+	<p class="pageheader">Mailboxes</p>
+
+	<form id="main_form" action="postfix-mailboxes-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'postfix-mailboxes-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'postfix-mailboxes-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'postfix-mailboxes-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Mailbox</td>
+				<td class="textcenter">Quota</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "SELECT ID, Mailbox, Quota, Name, Disabled FROM ${DB_TABLE_PREFIX}mailboxes ORDER BY Mailbox";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="postfix_mailbox_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->mailbox ?></td>
+					<td><?php echo $row->quota ?></td>
+					<td><?php echo $row->name ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+?>
+		</table>
+	</form>
+<?php
+
+
+
+printFooter();
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-transports-add.php b/webui/postfix-transports-add.php
new file mode 100644
index 00000000..c8c54f62
--- /dev/null
+++ b/webui/postfix-transports-add.php
@@ -0,0 +1,141 @@
+<?php
+# Postfix transport add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Transports" => "postfix-transports-main.php",
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Postfix Transport</p>
+<?php
+?>
+		<form method="post" action="postfix-transports-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">Domain Name</td>
+					<td><input type="text" name="postfix_transport_domainname" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Type
+						<?php tooltip('postfix_transport_type'); ?>
+					</td>
+					<td>
+						<select name="postfix_transport_type" id="postfix_transport_type"
+								onchange="
+									var myobjs = document.getElementById('postfix_transport_type');
+									var myobji = document.getElementById('postfix_transport_data');
+
+									if (myobjs.selectedIndex == 0) {
+										myobji.disabled = true;
+										myobji.value = 'n/a';
+									} else if (myobjs.selectedIndex != 0) {
+										myobji.disabled = false;
+										myobji.value = 'server hostname here';
+									}
+						">
+							<option value="0">Virtual</option>
+							<option value="1">SMTP</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Data</td>
+					<td><input type="text" name="postfix_transport_data" id="postfix_transport_data" disabled="disabled" value="n/a" /></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Postfix Transport Add Results</p>
+
+<?php
+
+	$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}transports (DomainName,Type,Transport,PTransport,Disabled) VALUES (?,?,?,?,0)");
+
+	# virtual
+	if ($_POST['postfix_transport_type'] == "0") {
+		$transport = $_POST['postfix_transport_domainname'];
+		$ptransport = "virtual:$transport";
+	
+	# smtp
+	} elseif ($_POST['postfix_transport_type'] == "1") {
+		$transport = $_POST['postfix_transport_data'];
+		$ptransport = "smtp:$transport";
+	}
+
+	$res = $stmt->execute(array(
+		$_POST['postfix_transport_domainname'],
+		$_POST['postfix_transport_type'],
+		$transport,
+		$ptransport
+	));
+	if ($res) {
+?>
+		<div class="notice">Postfix transport created</div>
+<?php
+	} else {
+?>
+		<div class="warning">Failed to create Postfix transport</div>
+		<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-transports-change.php b/webui/postfix-transports-change.php
new file mode 100644
index 00000000..9da3f09d
--- /dev/null
+++ b/webui/postfix-transports-change.php
@@ -0,0 +1,186 @@
+<?php
+# Postfix transport change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+include_once("includes/tooltips.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Transports" => "postfix-transports-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a transport was selected
+	if (isset($_POST['postfix_transport_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, DomainName, Type, Transport, Disabled FROM ${DB_TABLE_PREFIX}transports WHERE ID = ?");
+?>
+		<p class="pageheader">Update Postfix Transport</p>
+
+		<form action="postfix-transports-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="postfix_transport_id" value="<?php echo $_POST['postfix_transport_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['postfix_transport_id']));
+
+			$row = $stmt->fetchObject();
+
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Domain Name</td>
+					<td class="oldval"><?php echo $row->domainname ?></td>
+					<td></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">
+						Type
+						<?php tooltip('postfix_transport_type'); ?>
+					</td>
+					<td class="oldval"><?php
+		   				# Translate type	
+						if ($row->type == "0") {
+							echo "Virtual";
+						} elseif ($row->type == "1") {
+							echo "SMTP";
+						}
+					?></td>
+					<td></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Data</td>
+					<td class="oldval"><?php echo $row->transport ?></td>
+<?php
+					if ($row->type == "1") {
+?>
+						<td><input type="text" name="postfix_transport_data" /></td>
+<?php
+					} else {
+?>
+						<td></td>
+<?php
+					}
+?>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="postfix_transport_disabled" />
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Policy Group Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['postfix_transport_type'])) {
+		array_push($updates,"Type = ".$db->quote($_POST['postfix_transport_type']));
+	}
+
+	if (!empty($_POST['postfix_transport_data'])) {
+		# smtp
+		$transport = $_POST['postfix_transport_data'];
+		$ptransport = "smtp:$transport";
+		array_push($updates ,"Transport = ".$db->quote($transport));
+		array_push($updates ,"PTransport = ".$db->quote($ptransport));
+	}
+
+	if (isset($_POST['postfix_transport_disabled']) && $_POST['postfix_transport_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['postfix_transport_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}transports SET $updateStr WHERE ID = ".$db->quote($_POST['postfix_transport_id']));
+		if ($res) {
+?>
+			<div class="notice">Postfix transport updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating Postfix transport!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to Postfix transport</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/postfix-transports-delete.php b/webui/postfix-transports-delete.php
new file mode 100644
index 00000000..09975040
--- /dev/null
+++ b/webui/postfix-transports-delete.php
@@ -0,0 +1,114 @@
+<?php
+# Postfix transport delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to Transports" => "postfix-transports-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a Postfix transport was selected
+	if (isset($_POST['postfix_transport_id'])) {
+?>
+		<p class="pageheader">Delete Postfix Transport</p>
+
+		<form action="postfix-transports-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="postfix_transport_id" value="<?php echo $_POST['postfix_transport_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No Postfix transport selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Postfix Transport Delete Results</p>
+<?php
+	if (isset($_POST['postfix_transport_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}transports WHERE ID = ".$db->quote($_POST['postfix_transport_id']));
+			if ($res) {
+?>
+				<div class="notice">Postfix transport deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting Postfix transport!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Postfix transport not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no Postfix transport ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/postfix-transports-main.php b/webui/postfix-transports-main.php
new file mode 100644
index 00000000..c898c3bd
--- /dev/null
+++ b/webui/postfix-transports-main.php
@@ -0,0 +1,100 @@
+<?php
+# Postfix transports
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_postfix_db();
+
+
+
+printHeader(array(
+));
+
+?>
+	<p class="pageheader">Postfix Transports</p>
+
+	<form id="main_form" action="postfix-transports-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'postfix-transports-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'postfix-transports-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'postfix-transports-delete.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Domain</td>
+				<td class="textcenter">Transport</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "SELECT ID, DomainName, PTransport, Disabled FROM ${DB_TABLE_PREFIX}transports ORDER BY DomainName";
+			$res = $db->query($sql);
+
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="postfix_transport_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->domainname ?></td>
+					<td><?php echo $row->ptransport ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+printFooter();
+
+# vim: ts=4
+?>
diff --git a/webui/quotas-add.php b/webui/quotas-add.php
new file mode 100644
index 00000000..f4d40ff4
--- /dev/null
+++ b/webui/quotas-add.php
@@ -0,0 +1,220 @@
+<?php
+# Module: Quotas add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to quotas" => "quotas-main.php"
+		),
+));
+
+
+
+if ($_POST['frmaction'] == "add") {
+?>
+	<p class="pageheader">Add Quota</p>
+
+	<form method="post" action="quotas-add.php">
+		<div>
+			<input type="hidden" name="frmaction" value="add2" />
+		</div>
+		<table class="entry">
+			<tr>
+				<td class="entrytitle">Name</td>
+				<td><input type="text" name="quota_name" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Track</td>
+				<td>
+					<select id="quota_track" name="quota_track"
+							onchange="
+								var myobj = document.getElementById('quota_track');
+								var myobj2 = document.getElementById('quota_trackextra');
+
+								if (myobj.selectedIndex == 0) {
+									myobj2.disabled = false;
+									myobj2.value = '/32';
+								} else if (myobj.selectedIndex != 0) {
+									myobj2.disabled = true;
+									myobj2.value = 'n/a';
+								}
+					">
+						<option value="SenderIP">Sender IP</option>
+						<option value="Sender:user@domain" selected="selected">Sender:user@domain</option>
+						<option value="Sender:@domain">Sender:@domain</option>
+						<option value="Sender:user@">Sender:user@</option>
+						<option value="Recipient:user@domain">Recipient:user@domain</option>
+						<option value="Recipient:@domain">Recipient:@domain</option>
+						<option value="Recipient:user@">Recipient:user@</option>
+						<option value="SASLUsername">SASLUsername:username</option>
+						<option value="Policy">Policy</option>
+					</select>
+					<input type="text" id="quota_trackextra" name="quota_trackextra" size="18" value="n/a" disabled="disabled" />
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Period</td>
+				<td><input type="text" name="quota_period" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Link to policy</td>
+				<td>
+					<select name="quota_policyid">
+<?php
+						$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+						while ($row = $res->fetchObject()) {
+?>
+							<option value="<?php echo $row->id ?>"><?php echo $row->name ?></option>
+<?php
+						}
+						$res->closeCursor();
+?>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Verdict</td>
+				<td>
+					<select name="quota_verdict">
+						<option value="HOLD">Hold</option>
+						<option value="REJECT" selected="selected">Reject</option>
+						<option value="DEFER">Defer (delay)</option>
+						<option value="DISCARD">Discard (drop)</option>
+						<option value="FILTER">Filter</option>
+						<option value="REDIRECT">Redirect</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Data</td>
+				<td><input type="text" name="quota_data" /></td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Stop processing here</td>
+				<td>
+					<select name="quota_lastquota">
+						<option value="0">No</option>
+						<option value="1">Yes</option>
+					</select>
+				</td>
+			</tr>
+			<tr>
+				<td class="entrytitle">Comment</td>
+				<td><textarea name="quota_comment" cols="40" rows="5"></textarea></td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" />
+				</td>
+			</tr>
+		</table>
+	</form>
+
+<?php
+
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Quota Add Results</p>
+
+<?php
+	# Check policy id
+	if (empty($_POST['quota_policyid'])) {
+?>
+		<div class="warning">Policy ID cannot be empty</div>
+<?php
+
+	# Check name
+	} elseif (empty($_POST['quota_name'])) {
+?>
+		<div class="warning">Name cannot be empty</div>
+<?php
+
+	# Check verdict
+	} elseif (empty($_POST['quota_verdict'])) {
+?>
+		<div class="warning">Verdict cannot be empty</div>
+<?php
+
+	# Check last quota
+	} elseif (!isset($_POST['quota_lastquota'])) {
+?>
+		<div class="warning">Stop procesing here field cannot be empty</div>
+<?php
+
+	} else {
+
+		if ($_POST['quota_track'] == "SenderIP") {
+			$quotaTrack = sprintf('%s:%s',$_POST['quota_track'],$_POST['quota_trackextra']);
+		} else {
+			$quotaTrack = $_POST['quota_track'];
+		}
+
+
+		$stmt = $db->prepare("
+			INSERT INTO ${DB_TABLE_PREFIX}quotas 
+				(PolicyID,Name,Track,Period,Verdict,Data,LastQuota,Comment,Disabled)
+			VALUES 
+				(?,?,?,?,?,?,?,?,1)
+		");
+		
+		$res = $stmt->execute(array(
+			$_POST['quota_policyid'],
+			$_POST['quota_name'],
+			$quotaTrack,
+			$_POST['quota_period'],
+			$_POST['quota_verdict'],
+			$_POST['quota_lastquota'],
+			$_POST['quota_data'],
+			$_POST['quota_comment']
+		));
+		
+		if ($res) {
+?>
+			<div class="notice">Quota created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create quota</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/quotas-change.php b/webui/quotas-change.php
new file mode 100644
index 00000000..7c37ca84
--- /dev/null
+++ b/webui/quotas-change.php
@@ -0,0 +1,279 @@
+<?php
+# Module: Quotas change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to quotas" => "quotas-main.php"
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a quota was selected
+	if (isset($_POST['quota_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("
+			SELECT 
+				${DB_TABLE_PREFIX}quotas.ID, ${DB_TABLE_PREFIX}quotas.PolicyID, ${DB_TABLE_PREFIX}quotas.Name, 
+				${DB_TABLE_PREFIX}quotas.Track, ${DB_TABLE_PREFIX}quotas.Period, 
+				${DB_TABLE_PREFIX}quotas.Verdict, ${DB_TABLE_PREFIX}quotas.Data, 
+				${DB_TABLE_PREFIX}quotas.LastQuota,
+				${DB_TABLE_PREFIX}quotas.Comment, ${DB_TABLE_PREFIX}quotas.Disabled,
+				
+				${DB_TABLE_PREFIX}policies.Name AS PolicyName
+				
+			FROM 
+				${DB_TABLE_PREFIX}quotas, ${DB_TABLE_PREFIX}policies 
+
+			WHERE 
+				${DB_TABLE_PREFIX}quotas.ID = ?
+				AND ${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}quotas.PolicyID
+			");
+?>
+		<p class="pageheader">Update Quota</p>
+
+		<form action="quotas-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="quota_id" value="<?php echo $_POST['quota_id']; ?>" />
+			</div>
+<?php
+
+			$res = $stmt->execute(array($_POST['quota_id']));
+
+			$row = $stmt->fetchObject();
+			$stmt->closeCursor();
+?>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Name</td>
+					<td class="oldval"><?php echo $row->name ?></td>
+					<td><input type="text" name="quota_name" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Link to policy</td>
+					<td class="oldval"><?php echo $row->policyname ?></td>
+					<td>
+						<select name="quota_policyid">
+							<option value="">--</option>
+<?php
+							$res = $db->query("SELECT ID, Name FROM ${DB_TABLE_PREFIX}policies ORDER BY Name");
+							while ($row2 = $res->fetchObject()) {
+?>
+								<option value="<?php echo $row2->id ?>" ><?php echo $row2->name ?></option>
+<?php
+							}
+							$res->closeCursor();
+?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Track</td>
+					<td class="oldval"><?php echo $row->track ?></td>
+					<td>
+						<select id="quota_track" name="quota_track"
+								onChange="
+									var myobj = document.getElementById('quota_track');
+									var myobj2 = document.getElementById('quota_trackextra');
+
+									if (myobj.selectedIndex == 1) {
+										myobj2.disabled = false;
+										myobj2.value = '0.0.0.0/0';
+									} else if (myobj.selectedIndex != 1) {
+										myobj2.disabled = true;
+										myobj2.value = 'n/a';
+									}
+							">
+							<option value="">--</option>
+							<option value="SenderIP">Sender IP</option>
+							<option value="Sender:user@domain">Sender:user@domain</option>
+							<option value="Sender:@domain">Sender:@domain</option>
+							<option value="Sender:user@">Sender:user@</option>
+							<option value="Recipient:user@domain">Recipient:user@domain</option>
+							<option value="Recipient:@domain">Recipient:@domain</option>
+							<option value="Recipient:user@">Recipient:user@</option>
+							<option value="SASLUsername">SASLUsername:username</option>
+							<option value="Policy">Policy</option>
+						</select>
+						<input type="text" id="quota_trackextra" name="quota_trackextra" size="18" value="n/a" disabled="disabled" />
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Period</td>
+					<td class="oldval"><?php echo $row->period ?></td>
+					<td><input type="text" name="quota_period" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Verdict</td>
+					<td class="oldval"><?php echo $row->verdict ?></td>
+					<td>
+						<select name="quota_verdict">
+							<option value="">--</option>
+							<option value="HOLD">Hold</option>
+							<option value="REJECT">Reject</option>
+							<option value="DEFER">Defer (delay)</option>
+							<option value="DISCARD">Discard (drop)</option>
+							<option value="FILTER">Filter</option>
+							<option value="REDIRECT">Redirect</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Data</td>
+					<td class="oldval"><?php echo $row->data ?></td>
+					<td><input type="text" name="quota_data" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Stop processing here</td>
+					<td class="oldval"><?php echo $row->lastquota ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="quota_lastquota">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="quota_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="quota_disabled">
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No quota selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Access Control Update Results</p>
+<?php
+	$updates = array();
+
+	if (!empty($_POST['quota_policyid'])) {
+		array_push($updates,"PolicyID = ".$db->quote($_POST['quota_policyid']));
+	}
+	if (!empty($_POST['quota_name'])) {
+		array_push($updates,"Name = ".$db->quote($_POST['quota_name']));
+	}
+	if (!empty($_POST['quota_track'])) {
+		if ($_POST['quota_track'] == "SenderIP") {
+			$quotaTrack = sprintf('%s:%s',$_POST['quota_track'],$_POST['quota_trackextra']);
+		} else {
+			$quotaTrack = $_POST['quota_track'];
+		}
+
+		array_push($updates,"Track = ".$db->quote($quotaTrack));
+	}
+	if (!empty($_POST['quota_period'])) {
+		array_push($updates,"Period = ".$db->quote($_POST['quota_period']));
+	}
+	if (!empty($_POST['quota_verdict'])) {
+		array_push($updates,"Verdict = ".$db->quote($_POST['quota_verdict']));
+	}
+	if (!empty($_POST['quota_data'])) {
+		array_push($updates,"Data = ".$db->quote($_POST['quota_data']));
+	}
+	if (isset($_POST['quota_lastquota']) && $_POST['quota_lastquota'] != "") {
+		array_push($updates,"LastQuota = ".$db->quote($_POST['quota_lastquota']));
+	}
+	if (!empty($_POST['quota_comment'])) {
+		array_push($updates,"Comment = ".$db->quote($_POST['quota_comment']));
+	}
+	if (isset($_POST['quota_disabled']) && $_POST['quota_disabled'] != "") {
+		array_push($updates ,"Disabled = ".$db->quote($_POST['quota_disabled']));
+	}
+
+	# Check if we have updates
+	if (sizeof($updates) > 0) {
+		$updateStr = implode(', ',$updates);
+
+		$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}quotas SET $updateStr WHERE ID = ".$db->quote($_POST['quota_id']));
+		if ($res) {
+?>
+			<div class="notice">Quota updated</div>
+<?php
+		} else {
+?>
+			<div class="warning">Error updating quota!</div>
+			<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+		}
+
+	} else {
+?>
+		<div class="warning">No changes made to quota</div>
+<?php
+	}
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/quotas-delete.php b/webui/quotas-delete.php
new file mode 100644
index 00000000..bb22c832
--- /dev/null
+++ b/webui/quotas-delete.php
@@ -0,0 +1,206 @@
+<?php
+# Module: Quotas delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to quotas" => "quotas-main.php",
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a quota was selected
+	if (isset($_POST['quota_id'])) {
+?>
+		<p class="pageheader">Delete Quota</p>
+
+		<form action="quotas-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="quota_id" value="<?php echo $_POST['quota_id']; ?>" />
+			</div>
+			
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No quota selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Quota Delete Results</p>
+<?php
+	if (isset($_POST['quota_id'])) {
+
+		if ($_POST['confirm'] == "yes") {
+
+			# Grab tracking limits we must delete for
+			$res = $db->query("
+					SELECT 
+						ID
+					FROM 
+						${DB_TABLE_PREFIX}quotas_limits
+					WHERE
+						QuotasID = ".$db->quote($_POST['quota_id'])."
+			");
+
+			$limitIDs = array();
+
+			if ($res !== FALSE) {
+				# Pull in limit ID's
+				while ($row = $res->fetchObject()) {
+					array_push($limitIDs,$row->id);
+				}
+				$res->closeCursor();
+
+			} else {
+?>
+				<div class="warning">Error selecting quota limit IDs!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+
+
+			# Check last query succeeded, if so continue
+			if ($res !== FALSE) {
+				$db->beginTransaction();
+
+				$stmt = $db->prepare("
+					DELETE FROM 
+						${DB_TABLE_PREFIX}quotas_tracking 
+					WHERE 
+						QuotasLimitsID = ?
+				");
+
+				# Loop with limit ID's, start off true
+				$res = true;
+				foreach ($limitIDs as $id) {
+					$res = $stmt->execute(array($id));
+				}
+
+				if ($res !== FALSE) {
+?>
+					<div class="notice">Quota tracking info deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting quota tracking info!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+					$db->rollBack();
+				}
+			}
+
+
+			# Check last query succeeded, if so continue
+			if ($res !== FALSE) {
+				$stmt = $db->prepare("
+						DELETE FROM 
+							${DB_TABLE_PREFIX}quotas_limits 
+						WHERE 
+							QuotasID = ?"
+				);
+				$res = $stmt->execute(array($_POST['quota_id']));
+
+				if ($res !== FALSE) {
+?>
+					<div class="notice">Quota limits deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting quota limits!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+					$db->rollBack();
+				}
+			}
+
+			# Check last query succeeded, if so continue
+			if ($res !== FALSE) {
+				$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}quotas WHERE ID = ".$db->quote($_POST['quota_id']));
+				if ($res) {
+?>
+					<div class="notice">Quota deleted</div>
+<?php
+				} else {
+?>
+					<div class="warning">Error deleting quota!</div>
+					<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+					$db->rollBack();
+				}
+			}
+
+			# Commit if last transaction succeeded
+			if ($res) {
+				$db->commit();
+			}
+			
+		} else {
+?>
+			<div class="notice">Quota not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no quota ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/quotas-limits-add.php b/webui/quotas-limits-add.php
new file mode 100644
index 00000000..ae93d71d
--- /dev/null
+++ b/webui/quotas-limits-add.php
@@ -0,0 +1,130 @@
+<?php
+# Module: Quotas limits add
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to quotas" => "quotas-main.php",
+			"Back to quota limits" => "quotas-limits-main.php?quota_id=".$_REQUEST['quota_id'],
+		),
+));
+
+
+if ($_POST['frmaction'] == "add")  {
+?>
+	<p class="pageheader">Add Quota Limit</p>
+<?php
+	if (!empty($_POST['quota_id'])) {
+?>
+		<form method="post" action="quotas-limits-add.php">
+			<div>
+				<input type="hidden" name="frmaction" value="add2" />
+				<input type="hidden" name="quota_id" value="<?php echo $_POST['quota_id'] ?>" />
+			</div>
+			<table class="entry">
+				<tr>
+					<td class="entrytitle">Type</td>
+					<td>
+						<select name="limit_type">
+							<option value="MessageCount">Message Count</option>
+							<option value="MessageCumulativeSize">Message Cumulative Size</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Counter Limit</td>
+					<td><input type="text" name="limit_counterlimit" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Comment</td>
+					<td><textarea name="limit_comment"></textarea></td>
+				</tr>
+				<tr>
+					<td colspan="2">
+						<input type="submit" />
+					</td>
+				</tr>
+			</table>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No policy ID, invalid invocation?</div>
+<?php
+	}
+	
+	
+	
+# Check we have all params
+} elseif ($_POST['frmaction'] == "add2") {
+?>
+	<p class="pageheader">Quota Limit Add Results</p>
+
+<?php
+	# Check we have a limit
+	if (empty($_POST['limit_counterlimit'])) {
+?>
+		<div class="warning">Counter limit is required</div>
+<?php
+
+
+	} else {
+		$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}quotas_limits (QuotasID,Type,CounterLimit,Comment,Disabled) VALUES (?,?,?,?,1)");
+		
+		$res = $stmt->execute(array(
+			$_POST['quota_id'],
+			$_POST['limit_type'],
+			$_POST['limit_counterlimit'],
+			$_POST['limit_comment']
+		));
+		if ($res) {
+?>
+			<div class="notice">Quota limit created</div>
+<?php
+		} else {
+?>
+			<div class="warning">Failed to create quota limit</div>
+			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+<?php
+		}
+
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/quotas-limits-change.php b/webui/quotas-limits-change.php
new file mode 100644
index 00000000..631cb115
--- /dev/null
+++ b/webui/quotas-limits-change.php
@@ -0,0 +1,180 @@
+<?php
+# Module: Quotas limits change
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to quotas" => "quotas-main.php",
+			"Back to limits" => "quotas-limits-main.php?quota_id=".$_REQUEST['quota_id'],
+		),
+));
+
+
+
+# Display change screen
+if ($_POST['frmaction'] == "change") {
+
+	# Check a limit was selected
+	if (isset($_POST['quota_limit_id'])) {
+		# Prepare statement
+		$stmt = $db->prepare("SELECT ID, Type, CounterLimit, Comment, Disabled FROM ${DB_TABLE_PREFIX}quotas_limits WHERE ID = ?");
+		$res = $stmt->execute(array($_POST['quota_limit_id']));
+		$row = $stmt->fetchObject();
+		$stmt->closeCursor();
+?>
+		<p class="pageheader">Update Quota Limit</p>
+
+		<form action="quotas-limits-change.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="change2" />
+				<input type="hidden" name="quota_id" value="<?php echo $_POST['quota_id']; ?>" />
+				<input type="hidden" name="quota_limit_id" value="<?php echo $_POST['quota_limit_id']; ?>" />
+			</div>
+			<table class="entry" style="width: 75%;">
+				<tr>
+					<td></td>
+					<td class="entrytitle textcenter">Old Value</td>
+					<td class="entrytitle textcenter">New Value</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Type</td>
+					<td class="oldval texttop"><?php echo $row->type ?></td>
+					<td>
+						<select name="limit_type">
+							<option value="">--</option>
+							<option value="MessageCount">Message Count</option>
+							<option value="MessageCumulativeSize">Message Cumulative Size</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Counter Limit</td>
+					<td class="oldval texttop"><?php echo $row->counterlimit ?></td>
+					<td><input type="text" name="limit_counterlimit" /></td>
+				</tr>
+				<tr>
+					<td class="entrytitle texttop">Comment</td>
+					<td class="oldval texttop"><?php echo $row->comment ?></td>
+					<td><textarea name="limit_comment" cols="40" rows="5"></textarea></td>
+				</tr>
+				<tr>
+					<td class="entrytitle">Disabled</td>
+					<td class="oldval"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+					<td>
+						<select name="limit_disabled" />
+							<option value="">--</option>
+							<option value="0">No</option>
+							<option value="1">Yes</option>
+						</select>		
+					</td>
+				</tr>
+			</table>
+	
+			<p />
+			
+			<div class="textcenter">
+				<input type="submit" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No quota selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "change2") {
+?>
+	<p class="pageheader">Policy Update Results</p>
+<?php
+	# Check a quota was selected
+	if (isset($_POST['quota_limit_id'])) {
+		
+		$updates = array();
+
+		if (!empty($_POST['limit_type'])) {
+			array_push($updates,"Type = ".$db->quote($_POST['limit_type']));
+		}
+		if (!empty($_POST['limit_counterlimit'])) {
+			array_push($updates,"CounterLimit = ".$db->quote($_POST['limit_counterlimit']));
+		}
+		if (!empty($_POST['limit_comment'])) {
+			array_push($updates,"Comment = ".$db->quote($_POST['limit_comment']));
+		}
+		if (isset($_POST['limit_disabled']) && $_POST['limit_disabled'] != "") {
+			array_push($updates ,"Disabled = ".$db->quote($_POST['limit_disabled']));
+		}
+
+		# Check if we have updates
+		if (sizeof($updates) > 0) {
+			$updateStr = implode(', ',$updates);
+	
+			$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}quotas_limits SET $updateStr WHERE ID = ".$db->quote($_POST['quota_limit_id']));
+			if ($res) {
+?>
+				<div class="notice">Quota limit updated</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error updating quota limit!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+
+		# Warn
+		} else {
+?>
+			<div class="warning">No quota limit updates</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="error">No quota limit data available</div>
+<?php
+	}
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/quotas-limits-delete.php b/webui/quotas-limits-delete.php
new file mode 100644
index 00000000..36513dff
--- /dev/null
+++ b/webui/quotas-limits-delete.php
@@ -0,0 +1,116 @@
+<?php
+# Module: Quotas limits delete
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to quotas" => "quotas-main.php",
+			"Back to limits" => "quotas-limits-main.php?quota_id=".$_REQUEST['quota_id'],
+		),
+));
+
+
+
+# Display delete confirm screen
+if ($_POST['frmaction'] == "delete") {
+
+	# Check a quota limit was selected
+	if (isset($_POST['quota_limit_id'])) {
+?>
+		<p class="pageheader">Delete Quota Limit</p>
+
+		<form action="quotas-limits-delete.php" method="post">
+			<div>
+				<input type="hidden" name="frmaction" value="delete2" />
+				<input type="hidden" name="quota_id" value="<?php echo $_POST['quota_id']; ?>" />
+				<input type="hidden" name="quota_limit_id" value="<?php echo $_POST['quota_limit_id']; ?>" />
+			</div>
+
+			<div class="textcenter">
+				Are you very sure? <br />
+				<input type="submit" name="confirm" value="yes" />
+				<input type="submit" name="confirm" value="no" />
+			</div>
+		</form>
+<?php
+	} else {
+?>
+		<div class="warning">No quota limit selected</div>
+<?php
+	}
+	
+	
+	
+# SQL Updates
+} elseif ($_POST['frmaction'] == "delete2") {
+?>
+	<p class="pageheader">Quota Limit Delete Results</p>
+<?php
+	if (isset($_POST['quota_limit_id'])) {
+
+		if ($_POST['confirm'] == "yes") {	
+			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}quotas_limits WHERE ID = ".$db->quote($_POST['quota_limit_id']));
+			if ($res) {
+?>
+				<div class="notice">Quota limit deleted</div>
+<?php
+			} else {
+?>
+				<div class="warning">Error deleting quota limit!</div>
+				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
+<?php
+			}
+		} else {
+?>
+			<div class="notice">Quota limit not deleted, aborted by user</div>
+<?php
+		}
+
+	# Warn
+	} else {
+?>
+		<div class="warning">Invocation error, no quota limit ID</div>
+<?php
+	}
+
+
+
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
+
diff --git a/webui/quotas-limits-main.php b/webui/quotas-limits-main.php
new file mode 100644
index 00000000..9690bef9
--- /dev/null
+++ b/webui/quotas-limits-main.php
@@ -0,0 +1,125 @@
+<?php
+# Module: Quotas limits
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+		"Tabs" => array(
+			"Back to quotas" => "quotas-main.php"
+		),
+));
+
+
+# Check a policy was selected
+if (isset($_REQUEST['quota_id'])) {
+
+	$stmt = $db->prepare("SELECT Type, CounterLimit, Disabled FROM ${DB_TABLE_PREFIX}quota_limits WHERE QuotaID = ?");
+	$quota_stmt = $db->prepare("SELECT Name FROM ${DB_TABLE_PREFIX}quotas WHERE ID = ?");
+	$quota_stmt->execute(array($_REQUEST['quota_id']));
+	$row = $quota_stmt->fetchObject();
+	$quota_stmt->closeCursor();
+?>
+	<p class="pageheader">Quota Limits</p>
+
+	<form id="main_form" action="quotas-limits-main.php" method="post">
+		<div>
+			<input type="hidden" name="quota_id" value="<?php echo $_REQUEST['quota_id'] ?>" />
+		</div>
+		<div class="textcenter">
+
+			<div class="notice">Quota: <?php echo $row->name ?></div>
+
+			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 = 'quotas-limits-add.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'quotas-limits-change.php';
+							myform.submit();
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'quotas-limits-delete.php';
+							myform.submit();
+						}
+">
+	 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Type</td>
+				<td class="textcenter">Counter Limit</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+
+			$stmt = $db->prepare("SELECT ID, Type, CounterLimit, Disabled FROM ${DB_TABLE_PREFIX}quotas_limits WHERE QuotasID = ?");
+			$res = $stmt->execute(array($_REQUEST['quota_id']));
+
+			$i = 0;
+
+			# Loop with rows
+			while ($row = $stmt->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="quota_limit_id" value="<?php echo $row->id ?>" /></td>
+					<td class="textcenter"><?php echo $row->type ?></td>
+					<td class="textcenter"><?php echo $row->counterlimit ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$stmt->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+} else {
+?>
+	<div class="warning">Invalid invocation</div>
+<?php
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/quotas-main.php b/webui/quotas-main.php
new file mode 100644
index 00000000..9e372ded
--- /dev/null
+++ b/webui/quotas-main.php
@@ -0,0 +1,134 @@
+<?php
+# Module: Quotas
+# Copyright (C) 2008, LinuxRulz
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include_once("includes/header.php");
+include_once("includes/footer.php");
+include_once("includes/db.php");
+
+
+
+$db = connect_db();
+
+
+
+printHeader(array(
+));
+
+# If we have no action, display list
+if (!isset($_POST['frmaction']))
+{
+?>
+	<p class="pageheader">Quota List</p>
+
+	<form id="main_form" action="quotas-main.php" method="post">
+
+		<div class="textcenter">
+			Action
+			<select id="main_form_action" name="frmaction" 
+					onchange="
+						var myform = document.getElementById('main_form');
+						var myobj = document.getElementById('main_form_action');
+
+						if (myobj.selectedIndex == 2) {
+							myform.action = 'quotas-add.php';
+						} else if (myobj.selectedIndex == 4) {
+							myform.action = 'quotas-change.php';
+						} else if (myobj.selectedIndex == 5) {
+							myform.action = 'quotas-delete.php';
+						} else if (myobj.selectedIndex == 7) {
+							myform.action = 'quotas-limits-main.php';
+						}
+
+						myform.submit();
+					">
+			 
+				<option selected="selected">select action</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="add">Add</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="change">Change</option>
+				<option value="delete">Delete</option>
+				<option disabled="disabled"> - - - - - - - - - - - </option>
+				<option value="limits">Limits</option>
+			</select> 
+		</div>
+
+		<p />
+
+		<table class="results" style="width: 75%;">
+			<tr class="resultstitle">
+				<td id="noborder"></td>
+				<td class="textcenter">Policy</td>
+				<td class="textcenter">Name</td>
+				<td class="textcenter">Track</td>
+				<td class="textcenter">Period</td>
+				<td class="textcenter">Verdict</td>
+				<td class="textcenter">Data</td>
+				<td class="textcenter">Disabled</td>
+			</tr>
+<?php
+			$sql = "
+					SELECT 
+						${DB_TABLE_PREFIX}quotas.ID, ${DB_TABLE_PREFIX}quotas.Name, ${DB_TABLE_PREFIX}quotas.Track, 
+						${DB_TABLE_PREFIX}quotas.Period, 
+						${DB_TABLE_PREFIX}quotas.Verdict, ${DB_TABLE_PREFIX}quotas.Data, 
+						${DB_TABLE_PREFIX}quotas.Disabled, ${DB_TABLE_PREFIX}quotas.Comment,
+						${DB_TABLE_PREFIX}policies.Name AS PolicyName
+
+					FROM 
+						${DB_TABLE_PREFIX}quotas, ${DB_TABLE_PREFIX}policies
+
+					WHERE
+						${DB_TABLE_PREFIX}policies.ID = ${DB_TABLE_PREFIX}quotas.PolicyID
+
+					ORDER BY 
+						${DB_TABLE_PREFIX}policies.Name
+			";
+			$res = $db->query($sql);
+			
+			while ($row = $res->fetchObject()) {
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="quota_id" value="<?php echo $row->id ?>" /></td>
+					<td><?php echo $row->policyname ?></td>
+					<td><?php echo $row->name ?></td>
+					<td><?php echo $row->track ?></td>
+					<td><?php echo $row->period ?></td>
+					<td><?php echo $row->verdict ?></td>
+					<td><?php echo $row->data ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+<?php
+			}
+			$res->closeCursor();
+?>
+		</table>
+	</form>
+<?php
+
+
+
+}
+
+
+printFooter();
+
+
+# vim: ts=4
+?>
diff --git a/webui/stylesheet.css b/webui/stylesheet.css
new file mode 100644
index 00000000..f007804b
--- /dev/null
+++ b/webui/stylesheet.css
@@ -0,0 +1,247 @@
+/*
+ *
+ * Web interfce stylesheet
+ * Copyright (C) 2008, LinuxRulz
+ * 
+ * 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.
+ */
+
+body{
+	color:#999999;
+	font-family: Arial, Sans-Serif;
+}
+
+
+
+/*
+ * Main table
+ */
+#maintable {
+	width: 100%;
+}
+
+
+/*
+ * Header
+ */
+#header{
+	background: #000000 url('images/bg.jpg') bottom center repeat-x;
+	text-align: center;
+	font-size: 150%;
+	font-weight: bold;
+}
+
+
+
+/*
+ * Left hand menu
+ */
+#menu {
+	background-image: url("images/strips_onside.jpg");
+	background-repeat: repeat-y;
+	vertical-align: top;
+}
+
+#menu img {
+    border: none;
+}
+
+#menu p {
+	padding-right: 10px;
+	margin-left: 5px;
+	color:#888;
+}
+
+#menu a:link, a:visited {
+	color:#888;
+	text-decoration: none;
+}
+
+#menu a:hover, a:active {
+	color:#FF6666;
+}
+
+#menu ul {
+	margin-top: 0px;
+	list-style: url(images/bullet.jpg) disc;
+}
+
+#menu p {
+	font-size: 110%;
+	font-weight: bold;
+	margin-bottom: 0;
+	margin-top: 10px;
+}
+
+
+
+
+/* 
+ * Footer
+ */
+#footer{
+	background: #000000 url('images/bg.jpg') top center repeat-x;
+	text-align: center;
+	font-weight: bold;
+}
+
+#footer a, a:link {
+	color: #999999;
+	text-decoration: none;
+}
+
+#footer a:hover {
+	color: #A5CE77;
+	text-decoration: none;
+}
+
+#footerimages {
+	border: none;
+	text-align: center;
+}
+
+
+/*
+ * Top Menu  (tabs)
+ */
+#topmenu ul {
+	margin: 0;
+	padding: 0 0 0 0;
+	list-style: none;
+}
+#topmenu li {
+	display: inline;
+	margin: 0;
+	padding: 0;
+}
+#topmenu a {
+	float: left;
+	background: url(images/menuleft.gif) no-repeat left top;
+	margin: 0 5px 0 0;
+	padding: 0 0 0 4px;
+	text-decoration: none;
+}
+
+#topmenu a span {
+	float: left;
+	display: block;
+	background: url(images/menuright.gif) no-repeat right top;
+	padding: 5px 15px 4px 6px;
+	color: #000888;
+}
+
+/* Commented Backslash Hack hides rule from IE5-Mac \*/
+#topmenu a span {
+	float: none;
+}
+/* End IE5-Mac hack */
+#topmenu a:hover span {
+	color: #999999;
+}
+#topmenu a:hover {
+	background-position: 0% -42px;
+}
+#topmenu a:hover span {
+	background-position: 100% -42px;
+}
+
+
+/*
+ * Main content
+ */
+.content {
+	width: 100%;
+	vertical-align: top;
+}
+
+/*
+ * Main window content
+ */
+.pageheader {
+	background-color: #999999;
+	color: #000000;
+	width: 100%;
+	border: 1px solid black;
+	text-align: center;
+	font-weight: bold;
+	font-size: 110%;
+}
+
+/* 
+ * Results table 
+ */
+.results {
+	border: none;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+.resultstitle td {
+	font-weight: bolder;
+	border: 1px solid black;
+	padding-left: 5px;
+	padding-right: 5px;
+}
+
+.resultsitem td {
+	border-bottom: 1px dashed black;
+}
+
+
+/* 
+ * Entry tables 
+ */
+.entry {
+	border: solid black 1px;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+.entrytitle {
+	font-weight: bolder;
+}
+
+.oldval {
+	background-color: #eeeeee;
+}
+
+
+/*
+ * Misc
+ */
+.texttop {
+	vertical-align: top;
+}
+
+.textcenter {
+	text-align: center;
+}
+
+#noborder {
+	border: none;
+}
+
+a.help img {
+	border: none;
+}
+
+#tooltip {
+	position: absolute;
+	z-index: 200;
+}
+
+/* 
+ * vim: ts=4 
+ */
diff --git a/webui/tooltips/BubbleTooltips.js b/webui/tooltips/BubbleTooltips.js
new file mode 100644
index 00000000..30a4ea6e
--- /dev/null
+++ b/webui/tooltips/BubbleTooltips.js
@@ -0,0 +1,95 @@
+/*Javascript for Bubble Tooltips by Alessandro Fulciniti
+http://pro.html.it - http://web-graphics.com */
+
+function enableTooltips(id,element){
+var links,i,h;
+if (!element) element = "a";
+if(!document.getElementById || !document.getElementsByTagName) return;
+AddCss();
+h=document.createElement("span");
+h.id="btc";
+h.setAttribute("id","btc");
+h.style.position="absolute";
+document.getElementsByTagName("body")[0].appendChild(h);
+if(id==null) links=document.getElementsByTagName(element);
+else links=document.getElementById(id).getElementsByTagName(element);
+for(i=0;i<links.length;i++){
+    Prepare(links[i]);
+    }
+}
+
+function Prepare(el){
+var tooltip,t,b,s,l;
+t=el.getAttribute("title");
+//if(t==null || t.length==0) t="link:";
+if (t == null) return;
+el.removeAttribute("title");
+tooltip=CreateEl("span","tooltip");
+s=CreateEl("span","top");
+s.appendChild(document.createTextNode(t));
+tooltip.appendChild(s);
+b=CreateEl("b","bottom");
+//l=el.getAttribute("href");
+//if(l.length>28) l=l.substr(0,25)+"...";
+//b.appendChild(document.createTextNode(l));
+//b.appendChild(document.createTextNode("hello world"));
+tooltip.appendChild(b);
+setOpacity(tooltip);
+el.tooltip=tooltip;
+el.onmouseover=showTooltip;
+el.onmouseout=hideTooltip;
+el.onmousemove=Locate;
+}
+
+function showTooltip(e){
+document.getElementById("btc").appendChild(this.tooltip);
+Locate(e);
+}
+
+function hideTooltip(e){
+var d=document.getElementById("btc");
+if(d.childNodes.length>0) d.removeChild(d.firstChild);
+}
+
+function setOpacity(el){
+el.style.filter="alpha(opacity:95)";
+el.style.KHTMLOpacity="0.95";
+el.style.MozOpacity="0.95";
+el.style.opacity="0.95";
+}
+
+function CreateEl(t,c){
+var x=document.createElement(t);
+x.className=c;
+x.style.display="block";
+return(x);
+}
+
+function AddCss(){
+var l=CreateEl("link");
+l.setAttribute("type","text/css");
+l.setAttribute("rel","stylesheet");
+l.setAttribute("href","tooltips/bt.css");
+l.setAttribute("media","screen");
+document.getElementsByTagName("head")[0].appendChild(l);
+}
+
+function Locate(e){
+var posx=0,posy=0;
+if(e==null) e=window.event;
+if(e.pageX || e.pageY){
+    posx=e.pageX; posy=e.pageY;
+    }
+else if(e.clientX || e.clientY){
+    if(document.documentElement.scrollTop){
+        posx=e.clientX+document.documentElement.scrollLeft;
+        posy=e.clientY+document.documentElement.scrollTop;
+        }
+    else{
+        posx=e.clientX+document.body.scrollLeft;
+        posy=e.clientY+document.body.scrollTop;
+        }
+    }
+document.getElementById("btc").style.top=(posy+10)+"px";
+document.getElementById("btc").style.left=(posx-20)+"px";
+}
diff --git a/webui/tooltips/bt.css b/webui/tooltips/bt.css
new file mode 100644
index 00000000..6b735a37
--- /dev/null
+++ b/webui/tooltips/bt.css
@@ -0,0 +1,19 @@
+.tooltip {
+	width: 200px;
+	color: #00000;
+	font: 11px Arial, sans-serif;
+	font-weight: bold;
+	text-decoration: none;
+	text-align: center
+}
+
+.tooltip span.top {
+	padding: 30px 8px 0;
+	background: url(bt.gif) no-repeat top;
+}
+
+.tooltip b.bottom {
+	padding:3px 8px 15px;
+	color: #548912;
+	background: url(bt.gif) no-repeat bottom;
+}
diff --git a/webui/tooltips/bt.gif b/webui/tooltips/bt.gif
new file mode 100644
index 0000000000000000000000000000000000000000..6ea02940edc644c308625e5a21ea8536125e02b3
GIT binary patch
literal 1586
zcmV-22F>|LNk%w1VaNcM0L%aY*x>Nt=J1N0#N+Apj-bZq?DXvL`0(@j_xSsgq{zU_
z<Cv+;ps>)EsLQUr+0xqSv%uM^x!171+R4)8%GBt`(Btj!_P@#C+~V%3x7PUi`v3p{
z000000000000000A^8LW000^QEC2ui0LTEA000I5peBxFX`X1Ru59bRa4gSsZQppV
z?|g3#1VX?^EE<nUO+X+ZBnHW-bV@BPnS#Wy%I$h@SEdvCEt}6jCIg$Wpx<zAfgpfX
z=*~iX&o5e-5C9KY4G(>Xh&BaG5&?pE4HJozlq?5y4gih-2~7<Um7$^{222hC1Dc#o
z3lXEQi3n-|jsuRJP7JWSdk0Mno2iZqO=G;rXKJa-wQF=*$kAPD0M*sC01;wO(%n*Y
z3)bQQsSs=j-swi*<C>_N3fpe#^gFEW*1{CU2^jVNH<*OOx2)O&JPRZNEOS6Xh6X_*
zN}NcsqQ#3538}(24iCnUAVZ2ANwOq?1`HJcpj%-<o5`0Sv25cwZWGL#ICJJ~B1Xc>
z69+v>s6Y;tQCmolDox6Csnev_XmYgWj+WJ{ShH%~%C)Q4uVBLlcu)aC12GCqTwu~b
zfu>Ya<I0u0X>LApRmJMv%eODzsE!msB%q+gAOV?FEh}iZvDCVbtvT{bxw2)-?Odjv
zgBWk*&!9ik3QfASX~(0*(MsiVr33-tu)#e|oAf5gwR7u6-ENowSBnHFn7zCB+`6{`
zD_51g`SQunH$rC~-8uE^)3a|Rh&LXA0`UgoHcp;n^781@_Xa>r!5RqT)uWFuzdreL
z0vL3n;Lg5$`u+t-+diEL@PL5n0f^xLf}tJ8#C8l8r(lE>$|X~U5@M)fV{l!#p>7j?
z_#qt+ig;RxCRVtKhbfwdVv7;72%~5-!kCJTHAePgjsfDxBV9kH=wpy^?MS40Lms)F
zk{Tw-WKB;}=wy^eMoHe3R#s`HZdfv@<(6Dx0j7Cl3fQHRUzT~=nO>^tADcv`=_YA#
z9x3OXk=6O*op|OcW}kfaIhUS11}f;Ff8uHAp)?Vi<D!f<n&_O6Mmmn8HCAfrrIWg;
z>81c+I^(CHhT5r`q*^K}jHzzA>ZqlLS)!-0?)ECHwbpj4iLI)7YMH$rx~qu6GCC};
zxzcv*hQ$i|>zK{rxvYlK_Bk#8v&pXcY?j$7yX}_Mx_PaN-D*24rRCE3?UUioIWC6n
zmicak@v1p5h4q4Y?}GV`xi5qLTKTVl0dF}lf(1W$uzv|hxp06DEBSDJ5i>cleH9aV
zv3eOFx$%GLhW7D%A**{XttI<;GPEg!HgbY3JN7bp9c#QUl`%IqvvD;Cxiif<+x7Eq
zJ^wg#hCy3+Gnz>Yy>y#ROLcT^Me{f{h*3-Zbevhobv4ypbM*CzVN1F)uw}P1wu@=w
zvo_gnTl2PUadUb$%XOQ2H@A6LGk0lK&-gcJf!8>AXoa_UxQ>1My|tZvFV0)zk~5xn
z<#r_wBj$~1ZX)MEQvNvq*O!l8XybYdAgJdef?g!*u7_TC>@>0dx#@dGj(euC@BXOn
zd*dv6@O;niJFdg44k+-dCk!cokVUWB^pa5@RrT0kuRVm)XV1O$;8%a)W#pG{{`u&q
zkJVwFR4~B%@WZeES4mxEi&gK>ufO{F$B&Bq@$(;21XzJAtU&?+OrQc6$iN0V@PQDF
zpadsK!3tV1g0D$Q7B0xa4tnr|APk`h6G)5;1ZOw}NTCW>$if!7@P#mpp$un8!y4M~
zhB(Zj4#C3&Jvab1I}D-_he*UC8u5rLJc|TKL5Bz!;E7O-q7<h{#VT6yidf8|7PrX7
zE_(5cVEmx~^dN$-377(mXiTFT*T}{;y0MC4q(BMckp-0;;Es6AqaOFj$3FV;kAMuM
zAO}gvLK^arfm8r7gmZ#@2m}HYxFZ4%Fv&_%@{*R!Bqleh$xd?elb#GEC`T#EQj+qN
zrc5O&KUtOn2_P*dFn}0kLd#m(@|L*Fr7m~L%U=5Om%t3BFdaZf6@W)SJi$XUm#NHV
kGV__vj3zXvDa~q9^P1MoCN{UJ&2BOw0Vyda2|@q>J3&JXLjV8(

literal 0
HcmV?d00001

-- 
GitLab