tbrehm
2008-06-14 8651ee8d1730dd737ea62446f5a73f92887c4c4d
- Added form and list for firewalls
- added server module for firewall and database.
2 files modified
9 files added
481 ■■■■■ changed files
interface/web/admin/firewall_del.php 51 ●●●●● patch | view | raw | blame | history
interface/web/admin/firewall_edit.php 58 ●●●●● patch | view | raw | blame | history
interface/web/admin/firewall_list.php 52 ●●●●● patch | view | raw | blame | history
interface/web/admin/form/firewall.tform.php 112 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_firewall.lng 11 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_firewall_list.lng 14 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/module.conf.php 16 ●●●● patch | view | raw | blame | history
interface/web/admin/list/firewall.list.php 93 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/firewall_edit.htm 32 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/firewall_list.htm 31 ●●●●● patch | view | raw | blame | history
server/mods-available/server_module.inc.php 11 ●●●●● patch | view | raw | blame | history
interface/web/admin/firewall_del.php
New file
@@ -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();
?>
interface/web/admin/firewall_edit.php
New file
@@ -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();
?>
interface/web/admin/firewall_list.php
New file
@@ -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();
?>
interface/web/admin/form/firewall.tform.php
New file
@@ -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
    ##################################
    )
);
?>
interface/web/admin/lib/lang/en_firewall.lng
New file
@@ -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.';
?>
interface/web/admin/lib/lang/en_firewall_list.lng
New file
@@ -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';
?>
interface/web/admin/lib/module.conf.php
@@ -68,6 +68,18 @@
$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 @@
                            'items'    => $items);
// aufr�umen
// cleanup
unset($items);
/*
@@ -135,7 +147,7 @@
                            'items'    => $items);
// aufr�umen
// cleanup
unset($items);
*/
interface/web/admin/list/firewall.list.php
New file
@@ -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'        => "");
?>
interface/web/admin/templates/firewall_edit.htm
New file
@@ -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">&nbsp;</td>
    <td class="frmText11">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</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>&nbsp;
      <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'}">
interface/web/admin/templates/firewall_list.htm
New file
@@ -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">&nbsp;</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>
server/mods-available/server_module.inc.php
@@ -37,7 +37,10 @@
                                    '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 @@
        
        $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 @@
                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