Skip to content

Commit a706988

Browse files
committed
- Added new fields to serverIP list and form.
- Added a new IP validator to the tform library which validates IPv4 and IPv6 addresses.
1 parent 40c436b commit a706988

File tree

7 files changed

+140
-8
lines changed

7 files changed

+140
-8
lines changed

interface/lib/classes/tform.inc.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,36 @@ function validateField($field_name, $field_value, $validators) {
805805
$this->errorMessage .= $errmsg."<br />\r\n";
806806
}
807807
}
808+
break;
809+
case 'ISIP':
810+
//* Check if its a IPv4 or IPv6 address
811+
if(function_exists('filter_var')) {
812+
if(!filter_var($field_value,FILTER_VALIDATE_IP)) {
813+
$errmsg = $validator['errmsg'];
814+
if(isset($this->wordbook[$errmsg])) {
815+
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
816+
} else {
817+
$this->errorMessage .= $errmsg."<br />\r\n";
818+
}
819+
}
820+
} else {
821+
//* Check content with regex, if we use php < 5.2
822+
$ip_ok = 0;
823+
if(preg_match("/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i", $field_value)){
824+
$ip_ok = 1;
825+
}
826+
if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
827+
$ip_ok = 1;
828+
}
829+
if($ip_ok == 0) {
830+
$errmsg = $validator['errmsg'];
831+
if(isset($this->wordbook[$errmsg])) {
832+
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
833+
} else {
834+
$this->errorMessage .= $errmsg."<br />\r\n";
835+
}
836+
}
837+
}
808838
break;
809839
case 'CUSTOM':
810840
// Calls a custom class to validate this record

interface/web/admin/form/server_ip.tform.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,27 @@
9595
),
9696
'value' => ''
9797
),
98+
'client_id' => array (
99+
'datatype' => 'INTEGER',
100+
'formtype' => 'SELECT',
101+
'default' => '',
102+
'datasource' => array ( 'type' => 'SQL',
103+
'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name',
104+
'keyfield'=> 'client_id',
105+
'valuefield'=> 'contact_name'
106+
),
107+
'value' => array(0 => ' ')
108+
),
109+
'ip_type' => array (
110+
'datatype' => 'VARCHAR',
111+
'formtype' => 'SELECT',
112+
'default' => '',
113+
'value' => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6')
114+
),
98115
'ip_address' => array (
99116
'datatype' => 'VARCHAR',
100117
'formtype' => 'TEXT',
101-
'validators' => array ( 0 => array ( 'type' => 'ISIPV4',
118+
'validators' => array ( 0 => array ( 'type' => 'ISIP',
102119
'errmsg'=> 'ip_error_wrong'),
103120
1 => array ( 'type' => 'UNIQUE',
104121
'errmsg'=> 'ip_error_unique'),
@@ -117,6 +134,17 @@
117134
'default' => 'y',
118135
'value' => array(0 => 'n',1 => 'y')
119136
),
137+
'virtualhost_port' => array (
138+
'datatype' => 'VARCHAR',
139+
'formtype' => 'TEXT',
140+
'default' => '',
141+
'value' => '',
142+
'separator' => '',
143+
'width' => '15',
144+
'maxlength' => '15',
145+
'rows' => '',
146+
'cols' => ''
147+
),
120148
##################################
121149
# ENDE Datenbankfelder
122150
##################################
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
$wb["server_id_txt"] = 'Server';
3+
$wb["client_id_txt"] = 'Client';
4+
$wb["ip_type_txt"] = 'Type';
35
$wb["ip_address_txt"] = 'IP Address';
46
$wb["virtualhost_txt"] = 'HTTP NameVirtualHost';
7+
$wb["virtualhost_port_txt"] = 'HTTP Ports';
58
$wb["ip_error_wrong"] = 'The IP address is invalid';
69
$wb["ip_error_unique"] = 'The IP address must be unique';
710
?>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
22
$wb["list_head_txt"] = 'IP Addresses';
33
$wb["server_id_txt"] = 'Server';
4+
$wb["client_id_txt"] = 'Client';
45
$wb["ip_address_txt"] = 'IP Address';
56
$wb["add_new_record_txt"] = 'Add new IP Address';
7+
$wb["virtualhost_txt"] = 'HTTP Vhost';
8+
$wb["virtualhost_port_txt"] = 'HTTP Ports';
9+
$wb["ip_type_txt"] = 'Type';
610
?>

interface/web/admin/list/server_ip.list.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
/*
33
Datatypes:
44
- INTEGER
@@ -58,11 +58,51 @@
5858
'width' => '',
5959
'value' => '');
6060

61+
$liste['item'][] = array( 'field' => 'client_id',
62+
'datatype' => 'VARCHAR',
63+
'formtype' => 'SELECT',
64+
'op' => 'like',
65+
'prefix' => '%',
66+
'suffix' => '%',
67+
'datasource' => array ( 'type' => 'SQL',
68+
'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name',
69+
'keyfield'=> 'client_id',
70+
'valuefield'=> 'contact_name'
71+
),
72+
'width' => '',
73+
'value' => '');
74+
75+
$liste['item'][] = array( 'field' => 'ip_type',
76+
'datatype' => 'VARCHAR',
77+
'formtype' => 'SELECT',
78+
'op' => '=',
79+
'prefix' => '',
80+
'suffix' => '',
81+
'width' => '',
82+
'value' => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6'));
83+
6184
$liste['item'][] = array( 'field' => 'ip_address',
6285
'datatype' => 'VARCHAR',
6386
'op' => '=',
6487
'prefix' => '',
6588
'suffix' => '',
6689
'width' => '');
6790

91+
$liste["item"][] = array( 'field' => "virtualhost",
92+
'datatype' => "VARCHAR",
93+
'formtype' => "SELECT",
94+
'op' => "=",
95+
'prefix' => "",
96+
'suffix' => "",
97+
'width' => "",
98+
'value' => array('y' => "<div id=\"ir-Yes\" class=\"swap\"><span>Yes</span></div>",'n' => "<div class=\"swap\" id=\"ir-No\"><span>No</span></div>"));
99+
100+
101+
$liste['item'][] = array( 'field' => 'virtualhost_port',
102+
'datatype' => 'VARCHAR',
103+
'op' => '=',
104+
'prefix' => '',
105+
'suffix' => '',
106+
'width' => '');
107+
68108
?>

interface/web/admin/templates/server_ip_edit.htm

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,41 @@ <h2><tmpl_var name="list_head_txt"></h2>
22
<p><tmpl_var name="list_desc_txt"></p>
33

44
<div class="panel panel_server_ip">
5-
5+
66
<div class="pnl_formsarea">
7-
<fieldset class="inlineLabels">
7+
<fieldset class="inlineLabels"><legend>IP Address</legend>
88
<div class="ctrlHolder">
99
<label for="server_id">{tmpl_var name='server_id_txt'}</label>
1010
<select name="server_id" id="server_id" class="selectInput">
1111
{tmpl_var name='server_id'}
1212
</select>
1313
</div>
14+
<div class="ctrlHolder">
15+
<label for="client_id">{tmpl_var name='client_id_txt'}</label>
16+
<select name="client_id" id="client_id" class="selectInput">
17+
{tmpl_var name='client_id'}
18+
</select>
19+
</div>
20+
<div class="ctrlHolder">
21+
<label for="ip_type">{tmpl_var name='ip_type_txt'}</label>
22+
<select name="ip_type" id="ip_type" class="selectInput">
23+
{tmpl_var name='ip_type'}
24+
</select>
25+
</div>
1426
<div class="ctrlHolder">
1527
<label for="ip_address">{tmpl_var name='ip_address_txt'}</label>
16-
<input name="ip_address" id="ip_address" value="{tmpl_var name='ip_address'}" size="15" maxlength="15" type="text" class="textInput formLengthIPv4" />
28+
<input name="ip_address" id="ip_address" value="{tmpl_var name='ip_address'}" size="15" maxlength="255" type="text" class="textInput" />
1729
</div>
1830
<div class="ctrlHolder">
1931
<p class="label">{tmpl_var name='virtualhost_txt'}</p>
2032
<div class="multiField">
2133
{tmpl_var name='virtualhost'}
2234
</div>
2335
</div>
36+
<div class="ctrlHolder">
37+
<label for="virtualhost_port">{tmpl_var name='virtualhost_port_txt'}</label>
38+
<input name="virtualhost_port" id="virtualhost_port" value="{tmpl_var name='virtualhost_port'}" size="15" maxlength="15" type="text" class="textInput" />
39+
</div>
2440
</fieldset>
2541

2642
<input type="hidden" name="id" value="{tmpl_var name='id'}">

interface/web/admin/templates/server_ip_list.htm

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<h2><tmpl_var name="list_head_txt"></h2>
2-
<p><tmpl_var name="list_desc_txt"></p>
32

43
<div class="panel panel_list_server_ip">
54

@@ -19,20 +18,32 @@ <h2><tmpl_var name="list_head_txt"></h2>
1918
<thead>
2019
<tr>
2120
<th class="tbl_col_server_id" scope="col"><tmpl_var name="server_id_txt"></th>
21+
<th class="tbl_col_client_id" scope="col"><tmpl_var name="client_id_txt"></th>
22+
<th class="tbl_col_ip_type" scope="col"><tmpl_var name="ip_type_txt"></th>
2223
<th class="tbl_col_ip_address" scope="col"><tmpl_var name="ip_address_txt"></th>
24+
<th class="tbl_col_virtualhost" scope="col"><tmpl_var name="virtualhost_txt"></th>
25+
<th class="tbl_col_virtualhost_port" scope="col"><tmpl_var name="virtualhost_port_txt"></th>
2326
<th class="tbl_col_buttons" scope="col">&nbsp;</th>
2427
</tr>
2528
<tr>
2629
<td class="tbl_col_server_id"><select name="search_server_id" onChange="submitForm('pageForm','admin/server_ip_list.php');">{tmpl_var name='search_server_id'}</select></td>
27-
<td class="tbl_col_ip_address"><input type="text" name="search_ip_address" value="{tmpl_var name='search_ip_address'}" onblur="submitForm('pageForm','admin/server_ip_list.php');" /></td>
30+
<td class="tbl_col_client_id"><select name="search_client_id" onChange="submitForm('pageForm','admin/server_ip_list.php');">{tmpl_var name='search_client_id'}</select></td>
31+
<td class="tbl_col_ip_type"><select name="search_ip_type" onChange="submitForm('pageForm','admin/server_ip_list.php');">{tmpl_var name='search_ip_type'}</select></td>
32+
<td class="tbl_col_ip_address"><input type="text" name="search_ip_address" value="{tmpl_var name='search_ip_address'}" /></td>
33+
<td class="tbl_col_virtualhost"><select name="search_virtualhost" onChange="submitForm('pageForm','admin/server_ip_list.php');">{tmpl_var name='search_virtualhost'}</select></td>
34+
<td class="tbl_col_virtualhost_port"><input type="text" name="search_virtualhost_port" value="{tmpl_var name='search_virtualhost_port'}" /></td>
2835
<td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','admin/server_ip_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
2936
</tr>
3037
</thead>
3138
<tbody>
3239
<tmpl_loop name="records">
3340
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
3441
<td class="tbl_col_server_id"><a href="#" onClick="loadContent('admin/server_ip_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="server_id"}</a></td>
42+
<td class="tbl_col_client_id"><a href="#" onClick="loadContent('admin/server_ip_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="client_id"}</a></td>
43+
<td class="tbl_col_ip_type"><a href="#" onClick="loadContent('admin/server_ip_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="ip_type"}</a></td>
3544
<td class="tbl_col_ip_address"><a href="#" onClick="loadContent('admin/server_ip_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="ip_address"}</a></td>
45+
<td class="tbl_col_virtualhost"><a href="#" onClick="loadContent('admin/server_ip_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="virtualhost"}</a></td>
46+
<td class="tbl_col_virtualhost_port"><a href="#" onClick="loadContent('admin/server_ip_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="virtualhost_port"}</a></td>
3647
<td class="tbl_col_buttons">
3748
<div class="buttons icons16">
3849
<a class="icons16 icoDelete" href="javascript: del_record('admin/server_ip_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
@@ -43,7 +54,7 @@ <h2><tmpl_var name="list_head_txt"></h2>
4354
</tbody>
4455
<tfoot>
4556
<tr>
46-
<td class="tbl_footer tbl_paging" colspan="3"><tmpl_var name="paging"></td>
57+
<td class="tbl_footer tbl_paging" colspan="7"><tmpl_var name="paging"></td>
4758
</tr>
4859
</tfoot>
4960
</table>

0 commit comments

Comments
 (0)