Skip to content
Snippets Groups Projects
Commit 8651ee8d authored by tbrehm's avatar tbrehm
Browse files

- Added form and list for firewalls

- added server module for firewall and database.
parent 7120b51c
No related branches found
No related tags found
No related merge requests found
<?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
<?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
<?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
<?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
<?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
<?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
...@@ -68,6 +68,18 @@ $items[] = array( 'title' => 'Edit Server IP', ...@@ -68,6 +68,18 @@ $items[] = array( 'title' => 'Edit Server IP',
$module['nav'][] = array( 'title' => 'Servers', $module['nav'][] = array( 'title' => 'Servers',
'open' => 1, 'open' => 1,
'items' => $items); '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 // cleanup
...@@ -117,7 +129,7 @@ $module['nav'][] = array( 'title' => 'Language Editor', ...@@ -117,7 +129,7 @@ $module['nav'][] = array( 'title' => 'Language Editor',
'items' => $items); 'items' => $items);
// aufr�umen // cleanup
unset($items); unset($items);
/* /*
...@@ -135,7 +147,7 @@ $module['nav'][] = array( 'title' => 'File Sync.', ...@@ -135,7 +147,7 @@ $module['nav'][] = array( 'title' => 'File Sync.',
'items' => $items); 'items' => $items);
// aufr�umen // cleanup
unset($items); unset($items);
*/ */
......
<?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
<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'}">
\ No newline at end of file
<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>
\ No newline at end of file
...@@ -37,7 +37,10 @@ class server_module { ...@@ -37,7 +37,10 @@ class server_module {
'server_delete', 'server_delete',
'server_ip_insert', 'server_ip_insert',
'server_ip_update', 'server_ip_update',
'server_ip_delete'); 'server_ip_delete',
'firewall_insert',
'firewall_update',
'firewall_delete');
/* /*
This function is called when the module is loaded This function is called when the module is loaded
...@@ -65,6 +68,7 @@ class server_module { ...@@ -65,6 +68,7 @@ class server_module {
$app->modules->registerTableHook('server','server_module','process'); $app->modules->registerTableHook('server','server_module','process');
$app->modules->registerTableHook('server_ip','server_module','process'); $app->modules->registerTableHook('server_ip','server_module','process');
$app->modules->registerTableHook('firewall','server_module','process');
// Register service // Register service
//$app->services->registerService('httpd','web_module','restartHttpd'); //$app->services->registerService('httpd','web_module','restartHttpd');
...@@ -90,6 +94,11 @@ class server_module { ...@@ -90,6 +94,11 @@ class server_module {
if($action == 'u') $app->plugins->raiseEvent('server_ip_update',$data); if($action == 'u') $app->plugins->raiseEvent('server_ip_update',$data);
if($action == 'd') $app->plugins->raiseEvent('server_ip_delete',$data); if($action == 'd') $app->plugins->raiseEvent('server_ip_delete',$data);
break; 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 switch
} // end function } // end function
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment