diff --git a/webui/accesscontrol-add.php b/webui/accesscontrol-add.php new file mode 100644 index 0000000000000000000000000000000000000000..7a0d91e9853b459a901a41edcaff049145927e70 --- /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 0000000000000000000000000000000000000000..bba8491bbd32eb8944125042fee78f71424e077b --- /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 0000000000000000000000000000000000000000..ec7f017c2a542e6f517affd4108c1999bf41235a --- /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 0000000000000000000000000000000000000000..5f9b2bcf7a42b9ae7276e64326ad936aef32b365 --- /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 0000000000000000000000000000000000000000..f03264f066c7bc1dc08458d5a03fb346e69aca80 --- /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 0000000000000000000000000000000000000000..62fbc21bebeb9307688c3ec50be90a6e58b8a5ed --- /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 0000000000000000000000000000000000000000..12fa60ee590419fe379398f4e60d172e30f814cd --- /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 0000000000000000000000000000000000000000..8d594d85a3e31c02f1cb72ad4510f11d262b704f --- /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 0000000000000000000000000000000000000000..af6d218efffd6151b6eb04fd239a353ec885650a --- /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 & 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;"> </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 0000000000000000000000000000000000000000..db23369ad2490ad764177fd696e188e1f0b118fb --- /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 & 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;"> </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 0000000000000000000000000000000000000000..3a3ee2dd708336ffbf38cd6a872209ed01a3c955 --- /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 0000000000000000000000000000000000000000..6f374ea9b4ee631b936fed9c5b638bca7338e4ca --- /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 0000000000000000000000000000000000000000..8c9cadfd50e748e4c77d6603f0ac94974872d4f3 --- /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;"> </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 0000000000000000000000000000000000000000..9ed603422c81d7356d0fc85bd6ebb3b09e060d77 --- /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 0000000000000000000000000000000000000000..94da7ca84015b450d920a59fd8336b6fac4b0f05 --- /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 0000000000000000000000000000000000000000..4dc56440b08a9a8a6b41d927096061f1af370549 --- /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 0000000000000000000000000000000000000000..33df11f7de34ada5b2b2f1a8d91844e930dba52b --- /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 0000000000000000000000000000000000000000..e99979d73ff72ee6b7675a6e9ce6083c0fcaef7e --- /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;"> </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 0000000000000000000000000000000000000000..f607b3442ba1fd6f1b0b13c5fe148bbb0d90874a --- /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 0000000000000000000000000000000000000000..8b1c7c6158a78b0a0e9ab56d18eef27615832fd8 --- /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 0000000000000000000000000000000000000000..fdcd3d84bc1583cb0c04d846439c9f7faab2ce67 --- /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 0000000000000000000000000000000000000000..b180d14a6266611c55a08d05d2b21b6419c7979f --- /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 0000000000000000000000000000000000000000..6f6826f6ff878f6857a64ef0ef6e156b4eac761a --- /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 0000000000000000000000000000000000000000..e3d168cc12ea2ca0e52d9a156ce3485983ff97cf --- /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 0000000000000000000000000000000000000000..b4a3902e087414d72edad27ebf3c0036a4301984 --- /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 0000000000000000000000000000000000000000..ea94b4d774a57d2e8edafe074d7676c6ec56545b --- /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 0000000000000000000000000000000000000000..0a7f2062ffe0c73f7516cd6d31b44193083e05c6 --- /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 0000000000000000000000000000000000000000..09df2ac7aefc0db4b7432d08c2cc2ce3bf0b7235 --- /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 0000000000000000000000000000000000000000..1b02b6174d282baf49133a3699a02dcb52cc32ea --- /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;"> </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 0000000000000000000000000000000000000000..175be21528dc63f4245d0b50319ee8678605b42a --- /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;"> </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 0000000000000000000000000000000000000000..220062fd764ba6b253852b2bfc727a64b3e1c49a --- /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 0000000000000000000000000000000000000000..99edd6ce5d20f5348a9398fc129a9df2ad8bc421 --- /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 0000000000000000000000000000000000000000..f4c466b31304b099a17a9ef54037603282b4a0ac --- /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 0000000000000000000000000000000000000000..05deb7fc06b3e1bcdad65c1a88d2ae2a246f7011 --- /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 0000000000000000000000000000000000000000..2dce765cd18c018b4de1db2870b3acbe1572a488 --- /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 0000000000000000000000000000000000000000..0a31b531d4de84a9e7ef6c0118b4985b2aa6f8fe --- /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 Binary files /dev/null and b/webui/images/bg.jpg differ diff --git a/webui/images/bullet.jpg b/webui/images/bullet.jpg new file mode 100644 index 0000000000000000000000000000000000000000..785700c3646b2bed7f1e3a97b964a57957e1ee5f Binary files /dev/null and b/webui/images/bullet.jpg differ diff --git a/webui/images/help.gif b/webui/images/help.gif new file mode 100644 index 0000000000000000000000000000000000000000..1404a7a126328afb24d3ddb064882caf0cb9dba2 Binary files /dev/null and b/webui/images/help.gif differ diff --git a/webui/images/menuleft.gif b/webui/images/menuleft.gif new file mode 100644 index 0000000000000000000000000000000000000000..f986ecfc27c910701b77a4520ef951bf61c9a859 Binary files /dev/null and b/webui/images/menuleft.gif differ diff --git a/webui/images/menuright.gif b/webui/images/menuright.gif new file mode 100644 index 0000000000000000000000000000000000000000..afdd8bd04b1717a44fed336a60214acc76dd2817 Binary files /dev/null and b/webui/images/menuright.gif differ diff --git a/webui/images/specs_bottom.jpg b/webui/images/specs_bottom.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b01e2fbb59b325c49e933c2c326f6535b655198b Binary files /dev/null and b/webui/images/specs_bottom.jpg differ diff --git a/webui/images/strips_onside.jpg b/webui/images/strips_onside.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6fc0a3c22e97a2371620a1a68529f42368e565b3 Binary files /dev/null and b/webui/images/strips_onside.jpg differ diff --git a/webui/images/top2.jpg b/webui/images/top2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3f2f354d4ee23ebfc23d309fc702d7d8860d2d05 Binary files /dev/null and b/webui/images/top2.jpg differ diff --git a/webui/images/valid-css2.png b/webui/images/valid-css2.png new file mode 100644 index 0000000000000000000000000000000000000000..c04dbab5769fcc634b40de5422b11bbdb9121de1 Binary files /dev/null and b/webui/images/valid-css2.png differ diff --git a/webui/images/valid-xhtml10.png b/webui/images/valid-xhtml10.png new file mode 100644 index 0000000000000000000000000000000000000000..b81de9160bbaa1aaff62924d217b523edbb6f53d Binary files /dev/null and b/webui/images/valid-xhtml10.png differ diff --git a/webui/images/wcag1AAA.png b/webui/images/wcag1AAA.png new file mode 100644 index 0000000000000000000000000000000000000000..964e105a03c059ce6e9c0f318c35f1945794a08d Binary files /dev/null and b/webui/images/wcag1AAA.png differ diff --git a/webui/includes/config.php b/webui/includes/config.php new file mode 100644 index 0000000000000000000000000000000000000000..2dbc7336fc0d8fdf96648396a35254c9d3d91ceb --- /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 0000000000000000000000000000000000000000..562649734cd5bb894eda057b46e27dc0d9e64d0c --- /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 0000000000000000000000000000000000000000..61bbb7495968df281c3dba9e293b8396bf5b420e --- /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 © 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 0000000000000000000000000000000000000000..f33c5392beed602521c2c98e87e52819ef42ae2d --- /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 0000000000000000000000000000000000000000..0366d2bf301ed0d60c0c279e6ae0617666e5a92f --- /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 0000000000000000000000000000000000000000..708f86e23e812e0f12aeeebdf2d6c7faf3fa9a97 --- /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 0000000000000000000000000000000000000000..7e5b548bafebe1118a09265b3ded5904430cf773 --- /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 & 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 0000000000000000000000000000000000000000..f53c96ea691ad7b377d0380d8033dc3ecd4ad16d --- /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 0000000000000000000000000000000000000000..8dcb5e678d43980992dde3b151dc17858cffc89e --- /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 0000000000000000000000000000000000000000..2e36962d1691654f9139c7c90603e9fc05e93b79 --- /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 0000000000000000000000000000000000000000..bf0418e11ac65c7c815980ea6a5dce6cc51dd3bd --- /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 0000000000000000000000000000000000000000..65afe1acb81ae7a2fc1a6d6318afabde5fd129b6 --- /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 0000000000000000000000000000000000000000..88e269065663368a18e12ad0a6c1a08194606a70 --- /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 0000000000000000000000000000000000000000..7c38a9e5790b1aaac163d21dc3725828416499c1 --- /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 0000000000000000000000000000000000000000..93bf92294ef255dd7dd97d8085366fa20a5b0ad4 --- /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 0000000000000000000000000000000000000000..dad8954132147a1b1c744ebbbfd41d338740ed98 --- /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 0000000000000000000000000000000000000000..4b98be2e5a44db8e1f30b7bb4e49038b3ca76a00 --- /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 0000000000000000000000000000000000000000..66edbbdd1d1338f27d35fb64347d186a819675c3 --- /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 0000000000000000000000000000000000000000..02a444e7f28824331d2592bc13f696e3ecc40afb --- /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 0000000000000000000000000000000000000000..3b146a62b538a4ad1446bb720e6e6313e3d08fe6 --- /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 0000000000000000000000000000000000000000..b7c4f9817c43ab8dc12d78f1ea6444cf923ee80f --- /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 0000000000000000000000000000000000000000..e00239e6174fb8478c16e3b819d213e14f249978 --- /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 0000000000000000000000000000000000000000..b18eebf03e7436871765d4350f316fb9ae78fc31 --- /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 0000000000000000000000000000000000000000..9ccb6fb1930268e2eded0a71d75d0815d88281f0 --- /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 0000000000000000000000000000000000000000..2e35a004d2d1fac289baca078f175da022e7179c --- /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 0000000000000000000000000000000000000000..887d10e481fe8fd74c235424e801b8dd6fd9a0b2 --- /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 0000000000000000000000000000000000000000..982986a819d75c91ed889ba437b807e67fcb4b83 --- /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 0000000000000000000000000000000000000000..2e7f772d9bb78d7e5cc1e1c62656cf98597ab3c8 --- /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 0000000000000000000000000000000000000000..5900010db56047523403cc0cae834a54b4222b88 --- /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 0000000000000000000000000000000000000000..c34130ac8a1d039ed5337ad0bb7412ee10c64177 --- /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 0000000000000000000000000000000000000000..b343d4584b22080963aaa82483123b5fedfc6b3c --- /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 0000000000000000000000000000000000000000..1811b98c59f62c6092d2387e1e8ab58fdc296394 --- /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 0000000000000000000000000000000000000000..a2d8569aab47ad7479af5fe705fba7abab7c7ac7 --- /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 0000000000000000000000000000000000000000..cbb624a0da6d3edeec6f41c0673e80d8ffbbde2d --- /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 0000000000000000000000000000000000000000..e93a50d6f87411ac7a28cbff71a7732ec6c6f018 --- /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 0000000000000000000000000000000000000000..48a15fc9d34f8294eac4b56fe34c424694e1d985 --- /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 0000000000000000000000000000000000000000..4773083ee4ddf94804d7905aaaacb442373c4601 --- /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 0000000000000000000000000000000000000000..6e01082141c3cd9bbcb602b765621df468c9f303 --- /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 0000000000000000000000000000000000000000..bb67e02879abd5322ac3377c55beb98678b58f09 --- /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 0000000000000000000000000000000000000000..c8c54f62d416f68494e4c75fe4e4e7fa9b9d9922 --- /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 0000000000000000000000000000000000000000..9da3f09d69fe5f0827c948091e4ce8132e02fe01 --- /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 0000000000000000000000000000000000000000..099750404159218605a18a9055973c4c75297fb0 --- /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 0000000000000000000000000000000000000000..c898c3bd47ae3b4ed41fefc9bef24611ccdbfeba --- /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 0000000000000000000000000000000000000000..f4d40ff4141d411e628ff33707624636dac23442 --- /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 0000000000000000000000000000000000000000..7c37ca8451b1bf54675b63ab5183e6ca742c05a3 --- /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 0000000000000000000000000000000000000000..bb22c832fd1f91302f1af8f7b707992768f96a90 --- /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 0000000000000000000000000000000000000000..ae93d71db595ebf10689ba3043b85d5098e19b6e --- /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 0000000000000000000000000000000000000000..631cb115afbd802b2284aa4dcb4dd78b284337ab --- /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 0000000000000000000000000000000000000000..36513dffa33db9135312a8fa011f480a92c6c308 --- /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 0000000000000000000000000000000000000000..9690bef9be216acc54ea6661161812eba37684e4 --- /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 0000000000000000000000000000000000000000..9e372dedec6c571a2897394a2a935a03a37e262e --- /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 0000000000000000000000000000000000000000..f007804b59e426971e617118508161259e66f3ad --- /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 0000000000000000000000000000000000000000..30a4ea6e43fe5c0391805fa8c1b4fe2495c37276 --- /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 0000000000000000000000000000000000000000..6b735a377ae96c20abce153ab1699c9ca8a0d59b --- /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 Binary files /dev/null and b/webui/tooltips/bt.gif differ