Commit fbeb11d1 authored by Florian Schaal's avatar Florian Schaal

re-add rewrite ipv6 on mirror - lost in conversion from SVN to git

parent d6742cf3
......@@ -941,37 +941,54 @@ class tform_base {
}
}
break;
case 'V6PREFIXEND':
$explode_field_value = explode(':',$field_value);
// if ($explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]=='' ){ }
if (!$explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]!='' ) {
$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 'V6PREFIXLENGTH':
// find shortes ipv6 subnet can`t be longer
$sql_v6 = $app->db->queryOneRecord("SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND virtualhost = 'y' ORDER BY CHAR_LENGTH(ip_address) ASC LIMIT 0,1;");
$sql_v6_explode=explode(':',$sql_v6['ip_address']);
$explode_field_value = explode(':',$field_value);
if (count($sql_v6_explode) < count($explode_field_value) && isset($sql_v6['ip_address'])) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg].$sql_v6[ip_address]."<br />\r\n";
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
break;
case 'ISV6PREFIX':
$v6_prefix_ok = 0;
$explode_field_value = explode(':', $field_value);
$v6_prefix_ok=0;
$explode_field_value = explode(':',$field_value);
if ($explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]=='' ){
if ( count($explode_field_value) <= 9 ) {
if(filter_var(substr($field_value, 0, strlen($field_value)-2), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) or filter_var(substr($field_value, 0, strlen($field_value)-2).'::0', FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) or filter_var(substr($field_value, 0, strlen($field_value)-2).':0', FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) {
if (filter_var(substr($field_value,0,strlen($field_value)-2),FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).'::0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).':0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) ) {
$v6_prefix_ok = 1;
}
}
} else {
$v6_prefix_ok = 2;
}
// check subnet against defined server-ipv6
$sql_v6 = $app->db->queryOneRecord("SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND virtualhost = 'y' LIMIT 0,1");
$sql_v6_explode=explode(':', $sql_v6['ip_address']);
if ( count($sql_v6_explode) < count($explode_field_value) && isset($sql_v6['ip_address']) ) {
$v6_prefix_ok = 3;
}
if($v6_prefix_ok == 0) {
if($v6_prefix_ok <> 1) {
$errmsg = $validator['errmsg'];
}
if($v6_prefix_ok == 2) {
$errmsg = 'IPv6 Prefix must end with ::';
}
if($v6_prefix_ok == 3) {
$errmsg = 'IPv6 Prefix too long (according to Server IP Addresses)';
}
if($v6_prefix_ok <> 1){
$this->errorMessage .= $errmsg."<br />\r\n";
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
break;
case 'ISIPV4':
$vip=1;
if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
......
......@@ -89,8 +89,12 @@ $form["tabs"]['server'] = array(
'v6_prefix' => array(
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array(0 => array('type' => 'ISV6PREFIX',
'errmsg' => 'v6_prefix_wrong'),
'validators' => array( 0 => array('type' => 'ISV6PREFIX',
'errmsg' => 'v6_prefix_wrong'),
1 => array('type' => 'V6PREFIXEND',
'errmsg' => 'v6_prefix_end'),
2 => array('type' => 'V6PREFIXLENGTH',
'errmsg' => 'v6_prefix_length')
),
'default' => ''
),
......
......@@ -191,4 +191,7 @@ $wb['munin_user_txt'] = 'Munin User';
$wb['munin_password_txt'] = 'Munin Password';
$wb['munin_url_error_regex'] = 'Invalid Munin URL';
$wb['munin_url_note_txt'] = 'Placeholder:';
$wb["v6_prefix_txt"] = 'IPv6 Prefix';
$wb["vhost_rewrite_v6_txt"] = 'Rewrite IPv6 on Mirror';
$wb["v6_prefix_length"] = 'Prefix too long according to defined IPv6 ';
?>
......@@ -35,14 +35,12 @@
<label for="website_autoalias">{tmpl_var name='website_autoalias_txt'}</label>
<input name="website_autoalias" id="website_autoalias" value="{tmpl_var name='website_autoalias'}" size="40" maxlength="255" type="text" class="textInput" />&nbsp;{tmpl_var name='website_autoalias_note_txt'} <a href="javascript:void(0);" class="addPlaceholder">[client_id]</a>, <a href="javascript:void(0);" class="addPlaceholder">[client_username]</a>, <a href="javascript:void(0);" class="addPlaceholder">[website_id]</a>, <a href="javascript:void(0);" class="addPlaceholder">[website_domain]</a>
</div>
<!--
<div class="ctrlHolder apache">
<label for="vhost_rewrite_v6">{tmpl_var name='vhost_rewrite_v6_txt'}</label>
<div class="multiField">
{tmpl_var name='vhost_rewrite_v6'}
</div>
</div>
-->
<div class="ctrlHolder apache">
<label for="vhost_conf_dir">{tmpl_var name='vhost_conf_dir_txt'}</label>
<input name="vhost_conf_dir" id="vhost_conf_dir" value="{tmpl_var name='vhost_conf_dir'}" size="40" maxlength="255" type="text" class="textInput" />
......
......@@ -1435,9 +1435,11 @@ class apache2_plugin {
//* Add vhost for IPv6 IP
if($data['new']['ipv6_address'] != '') {
if ($conf['serverconfig']['web']['vhost_rewrite_v6'] == 'y') {
if (isset($conf['serverconfig']['server']['v6_prefix']) && $conf['serverconfig']['server']['v6_prefix'] <> '') {
$explode_v6prefix=explode(':', $conf['serverconfig']['server']['v6_prefix']);
//* rewrite ipv6 on mirrors
/* chang $conf to $web_config */
if ($web_config['serverconfig']['web']['vhost_rewrite_v6'] == 'y') {
if (isset($web_config['serverconfig']['server']['v6_prefix']) && $web_config['serverconfig']['server']['v6_prefix'] <> '') {
$explode_v6prefix=explode(':', $web_config['serverconfig']['server']['v6_prefix']);
$explode_v6=explode(':', $data['new']['ipv6_address']);
for ( $i = 0; $i <= count($explode_v6prefix)-3; $i++ ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment