diff --git a/interface/web/admin/firewall_del.php b/interface/web/admin/firewall_del.php new file mode 100644 index 0000000000000000000000000000000000000000..0df60d19f669a94b595731a0f97ea03ea50c3836 --- /dev/null +++ b/interface/web/admin/firewall_del.php @@ -0,0 +1,51 @@ +<?php + +/* +Copyright (c) 2008, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/****************************************** +* Begin Form configuration +******************************************/ + +$list_def_file = "list/firewall.list.php"; +$tform_def_file = "form/firewall.tform.php"; + +/****************************************** +* End Form configuration +******************************************/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); + +//* Check permissions for module +$app->auth->check_module_permissions('admin'); + +$app->uses("tform_actions"); +$app->tform_actions->onDelete(); + +?> \ No newline at end of file diff --git a/interface/web/admin/firewall_edit.php b/interface/web/admin/firewall_edit.php new file mode 100644 index 0000000000000000000000000000000000000000..6f426ac9d5b7b68e6599c9844808699de7b815bb --- /dev/null +++ b/interface/web/admin/firewall_edit.php @@ -0,0 +1,58 @@ +<?php +/* +Copyright (c) 2008, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/****************************************** +* Begin Form configuration +******************************************/ + +$tform_def_file = "form/firewall.tform.php"; + +/****************************************** +* End Form configuration +******************************************/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); + +//* Check permissions for module +$app->auth->check_module_permissions('admin'); + +// Loading classes +$app->uses('tpl,tform,tform_actions'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + +} + +$page = new page_action; +$page->onLoad(); + +?> \ No newline at end of file diff --git a/interface/web/admin/firewall_list.php b/interface/web/admin/firewall_list.php new file mode 100644 index 0000000000000000000000000000000000000000..d958f4503395adabb43b5e0c5b8acf33b2ec2c7f --- /dev/null +++ b/interface/web/admin/firewall_list.php @@ -0,0 +1,52 @@ +<?php + +/* +Copyright (c) 2008, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); + +/****************************************** +* Begin Form configuration +******************************************/ + +$list_def_file = "list/firewall.list.php"; + +/****************************************** +* End Form configuration +******************************************/ + +//* Check permissions for module +$app->auth->check_module_permissions('admin'); + +$app->uses('listform_actions'); + +$app->listform_actions->onLoad(); + + +?> \ No newline at end of file diff --git a/interface/web/admin/form/firewall.tform.php b/interface/web/admin/form/firewall.tform.php new file mode 100644 index 0000000000000000000000000000000000000000..40593ca4e5b0c04053b99bb94a69d08bf8ae6ad9 --- /dev/null +++ b/interface/web/admin/form/firewall.tform.php @@ -0,0 +1,112 @@ +<?php + +/* + Form Definition + + Tabledefinition + + Datatypes: + - INTEGER (Forces the input to Int) + - DOUBLE + - CURRENCY (Formats the values to currency notation) + - VARCHAR (no format check, maxlength: 255) + - TEXT (no format check) + - DATE (Dateformat, automatic conversion to timestamps) + + Formtype: + - TEXT (Textfield) + - TEXTAREA (Textarea) + - PASSWORD (Password textfield, input is not shown when edited) + - SELECT (Select option field) + - RADIO + - CHECKBOX + - CHECKBOXARRAY + - FILE + + VALUE: + - Wert oder Array + + Hint: + The ID field of the database table is not part of the datafield definition. + The ID field must be always auto incement (int or bigint). + + +*/ + +$form["title"] = "Firewall"; +$form["description"] = ""; +$form["name"] = "firewall"; +$form["action"] = "firewall_edit.php"; +$form["db_table"] = "firewall"; +$form["db_table_idx"] = "firewall_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "firewall"; +$form["list_default"] = "firewall_list.php"; +$form["auth"] = 'yes'; // yes / no + +$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['firewall'] = array ( + 'title' => "Firewall", + 'width' => 100, + 'template' => "templates/firewall_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'server_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'validators' => array ( 0 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'firewall_error_unique'), + ), + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'value' => '' + ), + 'tcp_port' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\s0-9\,]{0,255}$/', + 'errmsg'=> 'tcp_ports_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'udp_port' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\s0-9\,]{0,255}$/', + 'errmsg'=> 'tcp_ports_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'active' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + + +?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_firewall.lng b/interface/web/admin/lib/lang/en_firewall.lng new file mode 100644 index 0000000000000000000000000000000000000000..03989fad76e6793104dda29a33d653801626d644 --- /dev/null +++ b/interface/web/admin/lib/lang/en_firewall.lng @@ -0,0 +1,11 @@ +<?php +$wb["server_id_txt"] = 'Server'; +$wb["tcp_port_txt"] = 'Open TCP ports'; +$wb["udp_port_txt"] = 'Open UDP ports'; +$wb["tcp_port_help_txt"] = 'Separated by comma'; +$wb["udp_port_help_txt"] = 'Separated by comma'; +$wb["active_txt"] = 'Active'; +$wb["btn_save_txt"] = 'Save'; +$wb["btn_cancel_txt"] = 'Cancel'; +$wb["firewall_error_unique"] = 'There is already a firewall record for this server.'; +?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_firewall_list.lng b/interface/web/admin/lib/lang/en_firewall_list.lng new file mode 100644 index 0000000000000000000000000000000000000000..4189191ff5bc11a2dbe024521060baf697701b6c --- /dev/null +++ b/interface/web/admin/lib/lang/en_firewall_list.lng @@ -0,0 +1,14 @@ +<?php +$wb["list_head_txt"] = 'Firewall'; +$wb["active_txt"] = 'Active'; +$wb["server_id_txt"] = 'Server'; +$wb["tcp_port_txt"] = 'Open TCP ports'; +$wb["udp_port_txt"] = 'Open UDP ports'; +$wb["page_txt"] = 'Page'; +$wb["page_of_txt"] = 'of'; +$wb["page_next_txt"] = 'Next'; +$wb["page_back_txt"] = 'Back'; +$wb["delete_txt"] = 'Delete'; +$wb["filter_txt"] = 'Filter'; +$wb["add_new_record_txt"] = 'Add Firewall record'; +?> \ No newline at end of file diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php index 8a787a44578b3662fb7389d91e38c3cd27e5fa71..4a730654f66c74ca0714b8255e9b614e82fdab47 100644 --- a/interface/web/admin/lib/module.conf.php +++ b/interface/web/admin/lib/module.conf.php @@ -68,6 +68,18 @@ $items[] = array( 'title' => 'Edit Server IP', $module['nav'][] = array( 'title' => 'Servers', 'open' => 1, 'items' => $items); +// cleanup +unset($items); + + +$items[] = array( 'title' => 'Firewall', + 'target' => 'content', + 'link' => 'admin/firewall_list.php'); + + +$module['nav'][] = array( 'title' => 'Firewall', + 'open' => 1, + 'items' => $items); // cleanup @@ -117,7 +129,7 @@ $module['nav'][] = array( 'title' => 'Language Editor', 'items' => $items); -// aufr�umen +// cleanup unset($items); /* @@ -135,7 +147,7 @@ $module['nav'][] = array( 'title' => 'File Sync.', 'items' => $items); -// aufr�umen +// cleanup unset($items); */ diff --git a/interface/web/admin/list/firewall.list.php b/interface/web/admin/list/firewall.list.php new file mode 100644 index 0000000000000000000000000000000000000000..94633fef4a067a1321b3215a9bbb9555f87a4047 --- /dev/null +++ b/interface/web/admin/list/firewall.list.php @@ -0,0 +1,93 @@ +<?php + +/* + Datatypes: + - INTEGER + - DOUBLE + - CURRENCY + - VARCHAR + - TEXT + - DATE +*/ + + + +// Name of the list +$liste["name"] = "firewall"; + +// Database table +$liste["table"] = "firewall"; + +// Index index field of the database table +$liste["table_idx"] = "firewall_id"; + +// Search Field Prefix +$liste["search_prefix"] = "search_"; + +// Records per page +$liste["records_per_page"] = 15; + +// Script File of the list +$liste["file"] = "firewall_list.php"; + +// Script file of the edit form +$liste["edit_file"] = "firewall_edit.php"; + +// Script File of the delete script +$liste["delete_file"] = "firewall_del.php"; + +// Paging Template +$liste["paging_tpl"] = "templates/paging.tpl.htm"; + +// Enable auth +$liste["auth"] = "yes"; + + +/***************************************************** +* Suchfelder +*****************************************************/ + +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "Yes",'n' => "No")); + +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} AND db_server = 1 ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => "", + 'value' => ""); + + +$liste["item"][] = array( 'field' => "tcp_port", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + + +$liste["item"][] = array( 'field' => "udp_port", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +?> \ No newline at end of file diff --git a/interface/web/admin/templates/firewall_edit.htm b/interface/web/admin/templates/firewall_edit.htm new file mode 100644 index 0000000000000000000000000000000000000000..ad0dd09fd02c637cff5553563bf9971c6fa2ca83 --- /dev/null +++ b/interface/web/admin/templates/firewall_edit.htm @@ -0,0 +1,32 @@ +<table width="500" border="0" cellspacing="0" cellpadding="2"> + <tr> + <td class="frmText11">{tmpl_var name='server_id_txt'}:</td> + <td class="frmText11"> + <select name="server_id" class="text"> + {tmpl_var name='server_id'} + </select> + </td> + </tr> + <tr> + <td class="frmText11">{tmpl_var name='tcp_port_txt'}:</td> + <td class="frmText11"><input name="tcp_port" type="text" class="text" value="{tmpl_var name='tcp_port'}" size="30" maxlength="255"> ({tmpl_var name='tcp_port_help_txt'})</td> + </tr> + <tr> + <td class="frmText11">{tmpl_var name='udp_port_txt'}:</td> + <td class="frmText11"><input name="udp_port" type="text" class="text" value="{tmpl_var name='udp_port'}" size="30" maxlength="255">({tmpl_var name='udp_port_help_txt'})</td> + </tr> + <tr> + <td class="frmText11">{tmpl_var name='active_txt'}:</td> + <td class="frmText11">{tmpl_var name='active'}</td> + </tr> <tr> + <td class="frmText11"> </td> + <td class="frmText11"> </td> + </tr> + <tr> + <td> </td> + <td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/firewall_edit.php');"><div class="buttonEnding"></div> + <input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/firewall_list.php');"><div class="buttonEnding"></div> + </td> + </tr> +</table> +<input type="hidden" name="id" value="{tmpl_var name='id'}"> \ No newline at end of file diff --git a/interface/web/admin/templates/firewall_list.htm b/interface/web/admin/templates/firewall_list.htm new file mode 100644 index 0000000000000000000000000000000000000000..e2afad689aabb5931097a9298eb942513039d980 --- /dev/null +++ b/interface/web/admin/templates/firewall_list.htm @@ -0,0 +1,31 @@ +<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br /> +<input type="button" value="{tmpl_var name="add_new_record_txt"}" class="button" onClick="loadContent('admin/firewall_edit.php');" /><div class="buttonEnding"></div><br /><br /> +<table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable"> + <tr> + <td class="tblHead"><tmpl_var name="active_txt"></td> + <td class="tblHead"><tmpl_var name="server_id_txt"></td> + <td class="tblHead"><tmpl_var name="tcp_port_txt"></td> + <td class="tblHead"><tmpl_var name="udp_port_txt"></td> + <td class="tblHead"> </td> + </tr> + <tr> + <td class="frmText11"><select name="search_active" onChange="submitForm('pageForm','admin/firewall_list.php');">{tmpl_var name='search_active'}</select></td> + <td class="frmText11"><select name="search_server_id" onChange="submitForm('pageForm','admin/firewall_list.php');">{tmpl_var name='search_server_id'}</select></td> + <td class="frmText11"><input type="text" name="search_tcp_port" value="{tmpl_var name='search_tcp_port'}" class="text" /></td> + <td class="frmText11"><input type="text" name="search_udp_port" value="{tmpl_var name='search_udp_port'}" class="text" /></td> + <td class="frmText11" align="right"><input name="Filter" type="button" id="Filter" value="{tmpl_var name="filter_txt"}" class="button" onClick="submitForm('pageForm','admin/firewall_list.php');"><div class="buttonEnding"></div></td> + </tr> + <tmpl_loop name="records"> + <tr bgcolor="{tmpl_var name="bgcolor"}"> + <td class="frmText11"><a href="#" onClick="loadContent('admin/firewall_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="active"}</a></td> + <td class="frmText11"><a href="#" onClick="loadContent('admin/firewall_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="server_id"}</a></td> + <td class="frmText11"><a href="#" onClick="loadContent('admin/firewall_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="tcp_port"}</a></td> + <td class="frmText11"><a href="#" onClick="loadContent('admin/firewall_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="udp_port"}</a></td> + <td class="frmText11" align="right"><a href="javascript: del_record('admin/firewall_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');" class="frmText11"><img src="themes/{tmpl_var name='theme'}/icons/list_icon_delete.png" alt="{tmpl_var name='delete_txt'}" border="0" /></a></td> + </tr> + </tmpl_loop> + + <tr> + <td colspan="5" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td> + </tr> +</table> \ No newline at end of file diff --git a/server/mods-available/server_module.inc.php b/server/mods-available/server_module.inc.php index 1d672abde2ed094af0fd24cf5044d33c9f0f332f..a9e28dd714065a4e0a4effe6d6053a24fd927935 100644 --- a/server/mods-available/server_module.inc.php +++ b/server/mods-available/server_module.inc.php @@ -37,7 +37,10 @@ class server_module { 'server_delete', 'server_ip_insert', 'server_ip_update', - 'server_ip_delete'); + 'server_ip_delete', + 'firewall_insert', + 'firewall_update', + 'firewall_delete'); /* This function is called when the module is loaded @@ -65,6 +68,7 @@ class server_module { $app->modules->registerTableHook('server','server_module','process'); $app->modules->registerTableHook('server_ip','server_module','process'); + $app->modules->registerTableHook('firewall','server_module','process'); // Register service //$app->services->registerService('httpd','web_module','restartHttpd'); @@ -90,6 +94,11 @@ class server_module { if($action == 'u') $app->plugins->raiseEvent('server_ip_update',$data); if($action == 'd') $app->plugins->raiseEvent('server_ip_delete',$data); break; + case 'firewall': + if($action == 'i') $app->plugins->raiseEvent('firewall_insert',$data); + if($action == 'u') $app->plugins->raiseEvent('firewall_update',$data); + if($action == 'd') $app->plugins->raiseEvent('firewall_delete',$data); + break; } // end switch } // end function