tbrehm
2011-09-09 a7069883ae7d838f8144589c25df61f45d983572
- Added new fields to serverIP list and form.
- Added a new IP validator to the tform library which validates IPv4 and IPv6 addresses.
7 files modified
148 ■■■■■ changed files
interface/lib/classes/tform.inc.php 30 ●●●●● patch | view | raw | blame | history
interface/web/admin/form/server_ip.tform.php 30 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_ip.lng 3 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_ip_list.lng 4 ●●●● patch | view | raw | blame | history
interface/web/admin/list/server_ip.list.php 42 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_ip_edit.htm 22 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_ip_list.htm 17 ●●●● patch | view | raw | blame | history
interface/lib/classes/tform.inc.php
@@ -806,6 +806,36 @@
                                          }
                                        }
                                break;
                                case 'ISIP':
                                //* Check if its a IPv4 or IPv6 address
                                if(function_exists('filter_var')) {
                                    if(!filter_var($field_value,FILTER_VALIDATE_IP)) {
                                        $errmsg = $validator['errmsg'];
                                        if(isset($this->wordbook[$errmsg])) {
                                            $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
                                        } else {
                                            $this->errorMessage .= $errmsg."<br />\r\n";
                                        }
                                    }
                                } else {
                                    //* Check content with regex, if we use php < 5.2
                                    $ip_ok = 0;
                                    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)){
                                        $ip_ok = 1;
                                    }
                                    if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
                                        $ip_ok = 1;
                                    }
                                    if($ip_ok == 0) {
                                        $errmsg = $validator['errmsg'];
                                        if(isset($this->wordbook[$errmsg])) {
                                            $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
                                        } else {
                                            $this->errorMessage .= $errmsg."<br />\r\n";
                                        }
                                    }
                                }
                                break;
                                case 'CUSTOM':
                                        // Calls a custom class to validate this record
                                        if($validator['class'] != '' and $validator['function'] != '') {
interface/web/admin/form/server_ip.tform.php
@@ -95,10 +95,27 @@
                                     ),
            'value'        => ''
        ),
        'client_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name',
                                        'keyfield'=> 'client_id',
                                        'valuefield'=> 'contact_name'
                                     ),
            'value'        => array(0 => ' ')
        ),
        'ip_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6')
        ),
        'ip_address' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISIPV4',
            'validators'    => array (     0 => array (    'type'    => 'ISIP',
                                                        'errmsg'=> 'ip_error_wrong'),
                                        1 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'ip_error_unique'),
@@ -117,6 +134,17 @@
            'default'    => 'y',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'virtualhost_port' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '15',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # ENDE Datenbankfelder
    ##################################
interface/web/admin/lib/lang/en_server_ip.lng
@@ -1,7 +1,10 @@
<?php
$wb["server_id_txt"] = 'Server';
$wb["client_id_txt"] = 'Client';
$wb["ip_type_txt"] = 'Type';
$wb["ip_address_txt"] = 'IP Address';
$wb["virtualhost_txt"] = 'HTTP NameVirtualHost';
$wb["virtualhost_port_txt"] = 'HTTP Ports';
$wb["ip_error_wrong"] = 'The IP address is invalid';
$wb["ip_error_unique"] = 'The IP address must be unique';
?>
interface/web/admin/lib/lang/en_server_ip_list.lng
@@ -1,6 +1,10 @@
<?php
$wb["list_head_txt"] = 'IP Addresses';
$wb["server_id_txt"] = 'Server';
$wb["client_id_txt"] = 'Client';
$wb["ip_address_txt"] = 'IP Address';
$wb["add_new_record_txt"] = 'Add new IP Address';
$wb["virtualhost_txt"] = 'HTTP Vhost';
$wb["virtualhost_port_txt"] = 'HTTP Ports';
$wb["ip_type_txt"] = 'Type';
?>
interface/web/admin/list/server_ip.list.php
@@ -1,4 +1,4 @@
<?php
<?php
/*
    Datatypes:
    - INTEGER
@@ -58,6 +58,29 @@
                            'width'        => '',
                            'value'        => '');
$liste['item'][] = array(    'field'        => 'client_id',
                            'datatype'    => 'VARCHAR',
                            'formtype'    => 'SELECT',
                            'op'        => 'like',
                            'prefix'    => '%',
                            'suffix'    => '%',
                            'datasource'    => array (     'type'    => 'SQL',
                                                        'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name',
                                                        'keyfield'=> 'client_id',
                                                        'valuefield'=> 'contact_name'
                                                       ),
                            'width'        => '',
                            'value'        => '');
$liste['item'][] = array(    'field'        => 'ip_type',
                            'datatype'    => 'VARCHAR',
                            'formtype'    => 'SELECT',
                            'op'        => '=',
                            'prefix'    => '',
                            'suffix'    => '',
                            'width'        => '',
                            'value'        => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6'));
$liste['item'][] = array(    'field'        => 'ip_address',
                            'datatype'    => 'VARCHAR',
                            'op'        => '=',
@@ -65,4 +88,21 @@
                            'suffix'    => '',
                            'width'        => '');  
$liste["item"][] = array(    'field'        => "virtualhost",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "SELECT",
                            'op'        => "=",
                            'prefix'    => "",
                            'suffix'    => "",
                            'width'        => "",
                            'value'        => array('y' => "<div id=\"ir-Yes\" class=\"swap\"><span>Yes</span></div>",'n' => "<div class=\"swap\" id=\"ir-No\"><span>No</span></div>"));
$liste['item'][] = array(    'field'        => 'virtualhost_port',
                            'datatype'    => 'VARCHAR',
                            'op'        => '=',
                            'prefix'    => '',
                            'suffix'    => '',
                            'width'        => '');
?>
interface/web/admin/templates/server_ip_edit.htm
@@ -2,9 +2,9 @@
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_ip">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
    <fieldset class="inlineLabels"><legend>IP Address</legend>
      <div class="ctrlHolder">
          <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput">
@@ -12,8 +12,20 @@
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="client_id">{tmpl_var name='client_id_txt'}</label>
        <select name="client_id" id="client_id" class="selectInput">
                    {tmpl_var name='client_id'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="ip_type">{tmpl_var name='ip_type_txt'}</label>
        <select name="ip_type" id="ip_type" class="selectInput">
                    {tmpl_var name='ip_type'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="ip_address">{tmpl_var name='ip_address_txt'}</label>
        <input name="ip_address" id="ip_address" value="{tmpl_var name='ip_address'}" size="15" maxlength="15" type="text" class="textInput formLengthIPv4" />
        <input name="ip_address" id="ip_address" value="{tmpl_var name='ip_address'}" size="15" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='virtualhost_txt'}</p>
@@ -21,6 +33,10 @@
                        {tmpl_var name='virtualhost'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="virtualhost_port">{tmpl_var name='virtualhost_port_txt'}</label>
        <input name="virtualhost_port" id="virtualhost_port" value="{tmpl_var name='virtualhost_port'}" size="15" maxlength="15" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
interface/web/admin/templates/server_ip_list.htm
@@ -1,5 +1,4 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_server_ip">
@@ -19,12 +18,20 @@
        <thead>
          <tr>
            <th class="tbl_col_server_id" scope="col"><tmpl_var name="server_id_txt"></th>
            <th class="tbl_col_client_id" scope="col"><tmpl_var name="client_id_txt"></th>
            <th class="tbl_col_ip_type" scope="col"><tmpl_var name="ip_type_txt"></th>
            <th class="tbl_col_ip_address" scope="col"><tmpl_var name="ip_address_txt"></th>
            <th class="tbl_col_virtualhost" scope="col"><tmpl_var name="virtualhost_txt"></th>
            <th class="tbl_col_virtualhost_port" scope="col"><tmpl_var name="virtualhost_port_txt"></th>
            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <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>
            <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>
            <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>
            <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>
            <td class="tbl_col_ip_address"><input type="text" name="search_ip_address" value="{tmpl_var name='search_ip_address'}" /></td>
            <td class="tbl_col_virtualhost"><select name="search_virtualhost" onChange="submitForm('pageForm','admin/server_ip_list.php');">{tmpl_var name='search_virtualhost'}</select></td>
            <td class="tbl_col_virtualhost_port"><input type="text" name="search_virtualhost_port" value="{tmpl_var name='search_virtualhost_port'}" /></td>
            <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>
          </tr>
        </thead>
@@ -32,7 +39,11 @@
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <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>
            <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>
            <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>
            <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>
            <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>
            <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>
            <td class="tbl_col_buttons">
              <div class="buttons icons16">    
                <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 @@
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="3"><tmpl_var name="paging"></td>
            <td class="tbl_footer tbl_paging" colspan="7"><tmpl_var name="paging"></td>
          </tr>
        </tfoot>
      </table>