fixes for dualstack by tilman19

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-04-29 10:02:44 +02:00
parent 80f19c7dfb
commit 8aa74a9b90
5 changed files with 72 additions and 82 deletions

View File

@@ -128,6 +128,8 @@ if($page == 'domains'
{ {
$row['customername'] = getCorrectFullUserDetails($row); $row['customername'] = getCorrectFullUserDetails($row);
$row = htmlentities_array($row); $row = htmlentities_array($row);
// display a nice list of IP's
$row['ipandport'] = str_replace("\n", "<br />", $row['ipandport']);
eval("\$domains.=\"" . getTemplate("domains/domains_domain") . "\";"); eval("\$domains.=\"" . getTemplate("domains/domains_domain") . "\";");
$count++; $count++;
} }
@@ -993,32 +995,24 @@ if($page == 'domains'
$additional_ip_condition = ''; $additional_ip_condition = '';
} }
$ipandport = intval($_POST['ipandport']); $ipandports = array();
$ipandport_check = $db->query_first("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = '" . $db->escape($ipandport) . "' AND `ssl` = '0'" . $additional_ip_condition); if (isset($_POST['ipandport']) && !is_array($_POST['ipandport'])) {
$ipandports = array();
if (isset($_POST['ipandport']) && !is_array($_POST['ipandport']))
{
$_POST['ipandport'] = unserialize($_POST['ipandport']); $_POST['ipandport'] = unserialize($_POST['ipandport']);
} }
if (isset($_POST['ipandport']) && is_array($_POST['ipandport'])) if (isset($_POST['ipandport']) && is_array($_POST['ipandport'])) {
{ foreach($_POST['ipandport'] as $ipandport) {
foreach($_POST['ipandport'] as $ipandport) $ipandport = intval($ipandport);
{ $ipandport_check = $db->query_first("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = '" . $db->escape($ipandport) . "' " . $additional_ip_condition);
$ipandport = intval($ipandport); if (!isset($ipandport_check['id'])
$ipandport_check = $db->query_first("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = '" . $db->escape($ipandport) . "' " . $additional_ip_condition); || $ipandport_check['id'] == '0'
if(!isset($ipandport_check['id']) || $ipandport_check['id'] != $ipandport
|| $ipandport_check['id'] == '0' ) {
|| $ipandport_check['id'] != $ipandport) standard_error('ipportdoesntexist');
{ } else {
standard_error('ipportdoesntexist'); $ipandports[] = $ipandport;
} }
else }
{ }
$ipandports[] = $ipandport;
}
}
}
if($settings['system']['use_ssl'] == "1" if($settings['system']['use_ssl'] == "1"
&& isset($_POST['ssl_ipandport'])) && isset($_POST['ssl_ipandport']))
@@ -1029,28 +1023,20 @@ if($page == 'domains'
$ssl_redirect = (int)$_POST['ssl_redirect']; $ssl_redirect = (int)$_POST['ssl_redirect'];
} }
$ssl_ipandport = intval($_POST['ssl_ipandport']);
$ssl_ipandport_check = $db->query_first("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = '" . $db->escape($ssl_ipandport) . "' AND `ssl` = '1'" . $additional_ip_condition);
$ssl_ipandports = array(); $ssl_ipandports = array();
if (isset($_POST['ssl_ipandport']) && !is_array($_POST['ssl_ipandport'])) if (isset($_POST['ssl_ipandport']) && !is_array($_POST['ssl_ipandport'])) {
{
$_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']); $_POST['ssl_ipandport'] = unserialize($_POST['ssl_ipandport']);
} }
if (isset($_POST['ssl_ipandport']) && is_array($_POST['ssl_ipandport'])) if (isset($_POST['ssl_ipandport']) && is_array($_POST['ssl_ipandport'])) {
{ foreach ($_POST['ssl_ipandport'] as $ssl_ipandport) {
foreach($_POST['ssl_ipandport'] as $ssl_ipandport)
{
$ssl_ipandport = intval($ssl_ipandport); $ssl_ipandport = intval($ssl_ipandport);
$ssl_ipandport_check = $db->query_first("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = '" . $db->escape($ssl_ipandport) . "' " . $additional_ip_condition); $ssl_ipandport_check = $db->query_first("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = '" . $db->escape($ssl_ipandport) . "' " . $additional_ip_condition);
if(!isset($ssl_ipandport_check['id']) if (!isset($ssl_ipandport_check['id'])
|| $ssl_ipandport_check['id'] == '0' || $ssl_ipandport_check['id'] == '0'
|| $ssl_ipandport_check['id'] != $ssl_ipandport) || $ssl_ipandport_check['id'] != $ssl_ipandport
{ ) {
standard_error('ipportdoesntexist'); standard_error('ipportdoesntexist');
} } else {
else
{
$ssl_ipandports[] = $ssl_ipandport; $ssl_ipandports[] = $ssl_ipandport;
} }
} }

View File

@@ -2154,5 +2154,5 @@ if (isFroxlorVersion('0.9.29-dev3')) {
$db->query("ALTER TABLE `".TABLE_PANEL_DOMAINS."` DROP `ssl_ipandport`;"); $db->query("ALTER TABLE `".TABLE_PANEL_DOMAINS."` DROP `ssl_ipandport`;");
lastStepStatus(0); lastStepStatus(0);
updateToVersion('0.9.28-svn6'); updateToVersion('0.9.29-dev4');
} }

View File

@@ -15,7 +15,7 @@
* *
*/ */
class htmlform class htmlform
{ {
/** /**
* internal tmp-variable to store form * internal tmp-variable to store form
@@ -39,7 +39,7 @@ class htmlform
{ {
/* /*
* here be section title & image * here be section title & image
*/ */
$title = $section['title']; $title = $section['title'];
$image = $section['image']; $image = $section['image'];
@@ -47,7 +47,7 @@ class htmlform
{ {
continue; continue;
} }
if (!isset($section['nobuttons']) || $section['nobuttons'] == false) { if (!isset($section['nobuttons']) || $section['nobuttons'] == false) {
eval("self::\$_form .= \"" . getTemplate("misc/form/table_section", "1") . "\";"); eval("self::\$_form .= \"" . getTemplate("misc/form/table_section", "1") . "\";");
} else { } else {
@@ -83,9 +83,9 @@ class htmlform
$data_field = str_replace("\t", "", $data_field); $data_field = str_replace("\t", "", $data_field);
$data_field = $fielddata['next_to_prefix'].$data_field; $data_field = $fielddata['next_to_prefix'].$data_field;
self::$_form = str_replace( self::$_form = str_replace(
'{NEXTTOFIELD_'.$fielddata['next_to'].'}', '{NEXTTOFIELD_'.$fielddata['next_to'].'}',
$data_field, $data_field,
self::$_form self::$_form
); );
$nexto = false; $nexto = false;
} }
@@ -150,8 +150,8 @@ class htmlform
$extras .= ' size="'.$data['size'].'"'; $extras .= ' size="'.$data['size'].'"';
} }
if(isset($data['autocomplete'])) { if(isset($data['autocomplete'])) {
$extras .= ' autocomplete="'.$data['autocomplete'].'"'; $extras .= ' autocomplete="'.$data['autocomplete'].'"';
} }
// add support to save reloaded forms // add support to save reloaded forms
if (isset($data['value'])) { if (isset($data['value'])) {
@@ -161,7 +161,7 @@ class htmlform
} else { } else {
$value = ''; $value = '';
} }
$ulfield = ($unlimited == true ? '&nbsp;'.$data['ul_field'] : ''); $ulfield = ($unlimited == true ? '&nbsp;'.$data['ul_field'] : '');
if(isset($data['display']) && $data['display'] != '') if(isset($data['display']) && $data['display'] != '')
{ {
@@ -182,7 +182,7 @@ class htmlform
if(isset($data['rows'])) { if(isset($data['rows'])) {
$extras .= ' rows="'.$data['rows'].'"'; $extras .= ' rows="'.$data['rows'].'"';
} }
// add support to save reloaded forms // add support to save reloaded forms
if (isset($data['value'])) { if (isset($data['value'])) {
$value = $data['value']; $value = $data['value'];
@@ -201,7 +201,7 @@ class htmlform
{ {
return $data['yesno_var']; return $data['yesno_var'];
} }
private static function _labelField($data = array()) private static function _labelField($data = array())
{ {
return $data['value']; return $data['value'];
@@ -217,33 +217,33 @@ class htmlform
} else { } else {
$select_var = ''; $select_var = '';
} }
return '<select return '<select
id="'.$fieldname.'" id="'.$fieldname.'"
name="'.$fieldname.'" name="'.$fieldname.'"
'.(isset($data['class']) ? ' class="'.$data['class'] .'" ' : '').' '.(isset($data['class']) ? ' class="'.$data['class'] .'" ' : '').'
>' >'
.$select_var. .$select_var.
'</select>'; '</select>';
} }
/** /**
* Function to generate checkboxes. * Function to generate checkboxes.
* *
* <code> * <code>
* $data = array( * $data = array(
* 'label' => $lng['customer']['email_imap'], * 'label' => $lng['customer']['email_imap'],
* 'type' => 'checkbox', * 'type' => 'checkbox',
* 'values' => array( * 'values' => array(
* array( 'label' => 'active', * array( 'label' => 'active',
* 'value' => '1' * 'value' => '1'
* ) * )
* ), * ),
* 'value' => array('1'), * 'value' => array('1'),
* 'mandatory' => true * 'mandatory' => true
* ) * )
* </code> * </code>
* *
* @param string $fieldname contains the fieldname * @param string $fieldname contains the fieldname
* @param array $data contains the data array * @param array $data contains the data array
*/ */
@@ -254,7 +254,7 @@ class htmlform
} else { } else {
$checked = array(); $checked = array();
} }
if (isset($_SESSION['requestData'])) { if (isset($_SESSION['requestData'])) {
if(isset($_SESSION['requestData'][$fieldname])) { if(isset($_SESSION['requestData'][$fieldname])) {
$checked = array($_SESSION['requestData'][$fieldname]); $checked = array($_SESSION['requestData'][$fieldname]);
@@ -262,14 +262,14 @@ class htmlform
$checked = array(); $checked = array();
} }
} }
// default value is none, so the checkbox isn't an array // default value is none, so the checkbox isn't an array
$isArray = ''; $isArray = '';
if (count($data['values']) > 1) { if (count($data['values']) > 1 || (isset($data['is_array']) && $data['is_array'] == 1)) {
$isArray = '[]'; $isArray = '[]';
} }
// will contain the output // will contain the output
$output = ""; $output = "";
foreach($data['values'] as $val) { foreach($data['values'] as $val) {
@@ -282,11 +282,11 @@ class htmlform
break; break;
} }
} }
$output .= '<label><input type="checkbox" name="'.$fieldname.$isArray.'" value="'.$val['value'].'" '.$isChecked.'/>'.$key.'</label>'; $output .= '<label><input type="checkbox" name="'.$fieldname.$isArray.'" value="'.$val['value'].'" '.$isChecked.'/>'.$key.'</label>';
} }
return $output; return $output;
} }
} }

View File

@@ -91,13 +91,15 @@ return array(
'type' => 'checkbox', 'type' => 'checkbox',
'values' => $ipsandports, 'values' => $ipsandports,
'value' => array($settings['system']['defaultip']), 'value' => array($settings['system']['defaultip']),
'is_array' => 1,
'mandatory' => true 'mandatory' => true
), ),
'ssl_ipandport' => array( 'ssl_ipandport' => array(
'label' => 'IP/Port (SSL)', 'label' => 'IP/Port (SSL)',
'type' => 'checkbox', 'type' => 'checkbox',
'values' => $ssl_ipsandports, 'values' => $ssl_ipsandports,
'value' => '' 'value' => '',
'is_array' => 1
), ),
'ssl_redirect' => array( 'ssl_redirect' => array(
'visible' => ($settings['system']['use_ssl'] == '1' ? ($ssl_ipsandports != '' ? true : false) : false), 'visible' => ($settings['system']['use_ssl'] == '1' ? ($ssl_ipsandports != '' ? true : false) : false),

View File

@@ -102,13 +102,15 @@ return array(
'type' => 'checkbox', 'type' => 'checkbox',
'values' => $ipsandports, 'values' => $ipsandports,
'value' => $usedips, 'value' => $usedips,
'is_array' => 1,
'mandatory' => true 'mandatory' => true
), ),
'ssl_ipandport' => array( 'ssl_ipandport' => array(
'label' => 'IP/Port (SSL)', 'label' => 'IP/Port (SSL)',
'type' => 'checkbox', 'type' => 'checkbox',
'values' => $ssl_ipsandports, 'values' => $ssl_ipsandports,
'value' => $usedips 'value' => $usedips,
'is_array' => 1
), ),
'ssl_redirect' => array( 'ssl_redirect' => array(
'visible' => ($settings['system']['use_ssl'] == '1' ? ($ssl_ipsandports != '' ? true : false) : false), 'visible' => ($settings['system']['use_ssl'] == '1' ? ($ssl_ipsandports != '' ? true : false) : false),