Commit 8473cb63 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) cleanup some vars

parent 2ecd7bb8
...@@ -71,10 +71,6 @@ if (!is_array($config['ipsec']['phase2'])) { ...@@ -71,10 +71,6 @@ if (!is_array($config['ipsec']['phase2'])) {
$config['ipsec']['phase2'] = array(); $config['ipsec']['phase2'] = array();
} }
$a_phase1 = &$config['ipsec']['phase1'];
$a_phase2 = &$config['ipsec']['phase2'];
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// fetch data // fetch data
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) { if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
...@@ -91,12 +87,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -91,12 +87,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
,encryption-algorithm,halgo,dhgroup,lifetime,authentication_method,descr,nat_traversal ,encryption-algorithm,halgo,dhgroup,lifetime,authentication_method,descr,nat_traversal
,interface,iketype,dpd_delay,dpd_maxfail,remote-gateway,pre-shared-key,certref ,interface,iketype,dpd_delay,dpd_maxfail,remote-gateway,pre-shared-key,certref
,caref,reauth_enable,rekey_enable"; ,caref,reauth_enable,rekey_enable";
if (isset($p1index) && isset($a_phase1[$p1index])) { if (isset($p1index) && isset($config['ipsec']['phase1'][$p1index])) {
// 1-on-1 copy // 1-on-1 copy
foreach (explode(",", $phase1_fields) as $fieldname) { foreach (explode(",", $phase1_fields) as $fieldname) {
$fieldname = trim($fieldname); $fieldname = trim($fieldname);
if(isset($a_phase1[$p1index][$fieldname])) { if(isset($config['ipsec']['phase1'][$p1index][$fieldname])) {
$pconfig[$fieldname] = $a_phase1[$p1index][$fieldname]; $pconfig[$fieldname] = $config['ipsec']['phase1'][$p1index][$fieldname];
} elseif (!isset($pconfig[$fieldname])) { } elseif (!isset($pconfig[$fieldname])) {
// initialize element // initialize element
$pconfig[$fieldname] = null; $pconfig[$fieldname] = null;
...@@ -106,19 +102,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -106,19 +102,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// attributes with some kind of logic behind them... // attributes with some kind of logic behind them...
if (!isset($_GET['dup']) || !is_numericint($_GET['dup'])) { if (!isset($_GET['dup']) || !is_numericint($_GET['dup'])) {
// don't copy the ikeid on dup // don't copy the ikeid on dup
$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid']; $pconfig['ikeid'] = $config['ipsec']['phase1'][$p1index]['ikeid'];
} }
$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']); $pconfig['disabled'] = isset($config['ipsec']['phase1'][$p1index]['disabled']);
$pconfig['remotebits'] = null; $pconfig['remotebits'] = null;
$pconfig['remotenet'] = null ; $pconfig['remotenet'] = null ;
if (isset($a_phase1[$p1index]['remote-subnet']) && strpos($a_phase1[$p1index]['remote-subnet'],'/') !== false) { if (isset($a_phase1[$p1index]['remote-subnet']) && strpos($config['ipsec']['phase1'][$p1index]['remote-subnet'],'/') !== false) {
list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']); list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $config['ipsec']['phase1'][$p1index]['remote-subnet']);
} elseif (isset($a_phase1[$p1index]['remote-subnet'])) { } elseif (isset($config['ipsec']['phase1'][$p1index]['remote-subnet'])) {
$pconfig['remotenet'] = $a_phase1[$p1index]['remote-subnet']; $pconfig['remotenet'] = $config['ipsec']['phase1'][$p1index]['remote-subnet'];
} }
if (isset($a_phase1[$p1index]['mobile'])) { if (isset($config['ipsec']['phase1'][$p1index]['mobile'])) {
$pconfig['mobile'] = true; $pconfig['mobile'] = true;
} }
} else { } else {
...@@ -153,6 +149,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -153,6 +149,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$a_phase1 = &$config['ipsec']['phase1'];
if (isset($_POST['p1index']) && is_numericint($_POST['p1index'])) { if (isset($_POST['p1index']) && is_numericint($_POST['p1index'])) {
$p1index = $_POST['p1index']; $p1index = $_POST['p1index'];
} }
...@@ -241,8 +238,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -241,8 +238,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} }
if (isset($a_phase2) && (count($a_phase2))) { if (count($config['ipsec']['phase2'])) {
foreach ($a_phase2 as $phase2) { foreach ($config['ipsec']['phase2'] as $phase2) {
if ($phase2['ikeid'] == $pconfig['ikeid']) { if ($phase2['ikeid'] == $pconfig['ikeid']) {
if (($pconfig['protocol'] == "inet") && ($phase2['mode'] == "tunnel6")) { if (($pconfig['protocol'] == "inet") && ($phase2['mode'] == "tunnel6")) {
$input_errors[] = gettext("There is a Phase 2 using IPv6, you cannot use IPv4."); $input_errors[] = gettext("There is a Phase 2 using IPv6, you cannot use IPv4.");
...@@ -631,7 +628,7 @@ function dpdchkbox_change() { ...@@ -631,7 +628,7 @@ function dpdchkbox_change() {
<option value="<?=$kidx;?>" <?= $kidx == $pconfig['iketype'] ? "selected=\"selected\"" : "";?> > <option value="<?=$kidx;?>" <?= $kidx == $pconfig['iketype'] ? "selected=\"selected\"" : "";?> >
<?=$name;?> <?=$name;?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_iketype"> <div class="hidden" for="help_for_iketype">
...@@ -650,7 +647,7 @@ function dpdchkbox_change() { ...@@ -650,7 +647,7 @@ function dpdchkbox_change() {
<option value="<?=$protocol;?>" <?=$protocol == $pconfig['protocol'] ? "selected=\"selected\"" : "";?> > <option value="<?=$protocol;?>" <?=$protocol == $pconfig['protocol'] ? "selected=\"selected\"" : "";?> >
<?=$name?> <?=$name?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_protocol"> <div class="hidden" for="help_for_protocol">
...@@ -690,7 +687,7 @@ function dpdchkbox_change() { ...@@ -690,7 +687,7 @@ function dpdchkbox_change() {
<option value="<?=$iface;?>" <?= $iface == $pconfig['interface'] ? "selected=\"selected\"" : "" ?> > <option value="<?=$iface;?>" <?= $iface == $pconfig['interface'] ? "selected=\"selected\"" : "" ?> >
<?=htmlspecialchars($ifacename);?> <?=htmlspecialchars($ifacename);?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_interface"> <div class="hidden" for="help_for_interface">
...@@ -710,7 +707,7 @@ function dpdchkbox_change() { ...@@ -710,7 +707,7 @@ function dpdchkbox_change() {
</div> </div>
</td> </td>
</tr> </tr>
<?php endif; <?php endif;
?> ?>
<tr> <tr>
<td><a id="help_for_remotegw" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td> <td><a id="help_for_remotegw" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
...@@ -746,9 +743,9 @@ function dpdchkbox_change() { ...@@ -746,9 +743,9 @@ function dpdchkbox_change() {
} }
?> ?>
<option value="<?=$method_type;?>" <?= $method_type == $pconfig['authentication_method'] ? "selected=\"selected\"" : "";?> > <option value="<?=$method_type;?>" <?= $method_type == $pconfig['authentication_method'] ? "selected=\"selected\"" : "";?> >
<?=$method_params['name'];?> <?=$method_params['name'];?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_authmethod"> <div class="hidden" for="help_for_authmethod">
...@@ -764,10 +761,10 @@ function dpdchkbox_change() { ...@@ -764,10 +761,10 @@ function dpdchkbox_change() {
$modes = array("main" => "Main", "aggressive" => "Aggressive"); $modes = array("main" => "Main", "aggressive" => "Aggressive");
foreach ($modes as $mode => $mdescr) : foreach ($modes as $mode => $mdescr) :
?> ?>
<option value="<?=$mode;?>" <?= $mode == $pconfig['mode'] ? "selected=\"selected\"" : "" ;?> > <option value="<?=$mode;?>" <?= $mode == $pconfig['mode'] ? "selected=\"selected\"" : "" ;?> >
<?=$mdescr;?> <?=$mdescr;?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_mode"> <div class="hidden" for="help_for_mode">
...@@ -821,9 +818,9 @@ endforeach; ?> ...@@ -821,9 +818,9 @@ endforeach; ?>
} }
?> ?>
<option value="<?=$id_type;?>" <?= $id_type == $pconfig['peerid_type'] ? "selected=\"selected\"" : "";?> > <option value="<?=$id_type;?>" <?= $id_type == $pconfig['peerid_type'] ? "selected=\"selected\"" : "";?> >
<?=$id_params['desc'];?> <?=$id_params['desc'];?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<input name="peerid_data" type="text" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>" /> <input name="peerid_data" type="text" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>" />
...@@ -855,7 +852,7 @@ endforeach; ?> ...@@ -855,7 +852,7 @@ endforeach; ?>
<option value="<?=$cert['refid'];?>" <?= isset($pconfig['certref']) && $pconfig['certref'] == $cert['refid'] ? "selected=\"selected\"" : ""?>> <option value="<?=$cert['refid'];?>" <?= isset($pconfig['certref']) && $pconfig['certref'] == $cert['refid'] ? "selected=\"selected\"" : ""?>>
<?=$cert['descr'];?> <?=$cert['descr'];?>
</option> </option>
<?php endforeach; <?php endforeach;
endif; endif;
?> ?>
</select> </select>
...@@ -869,7 +866,7 @@ endforeach; ?> ...@@ -869,7 +866,7 @@ endforeach; ?>
<td> <td>
<select name="caref" class="formselect"> <select name="caref" class="formselect">
<?php <?php
$config__ca = isset($config['ca']) ? $config['ca'] : array(); $config__ca = isset($config['ca']) ? $config['ca'] : array();
foreach ($config__ca as $ca) : foreach ($config__ca as $ca) :
$selected = ""; $selected = "";
if ($pconfig['caref'] == $ca['refid']) { if ($pconfig['caref'] == $ca['refid']) {
...@@ -879,7 +876,7 @@ endforeach; ?> ...@@ -879,7 +876,7 @@ endforeach; ?>
<option value="<?=$ca['refid'];?>" <?= isset($pconfig['caref']) && $pconfig['caref'] == $ca['refid'] ? "selected=\"selected\"":"";?>> <option value="<?=$ca['refid'];?>" <?= isset($pconfig['caref']) && $pconfig['caref'] == $ca['refid'] ? "selected=\"selected\"":"";?>>
<?=htmlspecialchars($ca['descr']);?> <?=htmlspecialchars($ca['descr']);?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_caref"> <div class="hidden" for="help_for_caref">
...@@ -926,7 +923,7 @@ endforeach; ?> ...@@ -926,7 +923,7 @@ endforeach; ?>
<option value="<?=$algo;?>" <?= $algo == $pconfig['halgo'] ? "selected=\"selected\"" : "";?>> <option value="<?=$algo;?>" <?= $algo == $pconfig['halgo'] ? "selected=\"selected\"" : "";?>>
<?=$algoname;?> <?=$algoname;?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_halgo"> <div class="hidden" for="help_for_halgo">
...@@ -957,7 +954,7 @@ endforeach; ?> ...@@ -957,7 +954,7 @@ endforeach; ?>
<option value="<?=$keygroup;?>" <?= $keygroup == $pconfig['dhgroup'] ? "selected=\"selected\"" : "";?>> <option value="<?=$keygroup;?>" <?= $keygroup == $pconfig['dhgroup'] ? "selected=\"selected\"" : "";?>>
<?=$keygroupname;?> <?=$keygroupname;?>
</option> </option>
<?php endforeach; <?php endforeach;
?> ?>
</select> </select>
<div class="hidden" for="help_for_dhgroup"> <div class="hidden" for="help_for_dhgroup">
......
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