summaryrefslogtreecommitdiffstats
path: root/usr/local/www/firewall_aliases_edit.php
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-10-18 11:26:03 -0300
committerRenato Botelho <garga@FreeBSD.org>2013-10-18 11:26:03 -0300
commit4e8a79a83043c0880651d749ac67528615a03d90 (patch)
treeaa8a4b4435eb4a6a10827c1ea7820c1d556a83a1 /usr/local/www/firewall_aliases_edit.php
parentea1084476533bf9452d9f6f1012787c5c73e3939 (diff)
downloadpfsense-4e8a79a83043c0880651d749ac67528615a03d90.zip
pfsense-4e8a79a83043c0880651d749ac67528615a03d90.tar.gz
Fix #3242 and some code cleanup:
- Only explode '/' and set address_subnet when address is a subnet, it fixes issue reported at #3242 - While I'm here, do some cleanup on the way addresses are treated - Remove unecessary variable $tracker, we already have $counter set with the same value - Use if:endif and while:endwhile where there is html block inside the block - Use more meaning names for variables instead of item, item2, item3 and item4 - Use while($counter <= $count()) instead of using foreach referencing array using $counter inside
Diffstat (limited to 'usr/local/www/firewall_aliases_edit.php')
-rwxr-xr-xusr/local/www/firewall_aliases_edit.php36
1 files changed, 15 insertions, 21 deletions
diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php
index 0f5ea1f..8ec6ce2 100755
--- a/usr/local/www/firewall_aliases_edit.php
+++ b/usr/local/www/firewall_aliases_edit.php
@@ -705,30 +705,24 @@ if (empty($tab)) {
<?php
$counter = 0;
- $address = $pconfig['address'];
- if ($address <> "") {
- $item = explode(" ", $address);
- $item3 = explode("||", $pconfig['detail']);
- foreach($item as $ww) {
- $address = $item[$counter];
- $address_subnet = "";
- $item2 = explode("/", $address);
- foreach($item2 as $current) {
- if($item2[1] <> "") {
- $address = $item2[0];
- $address_subnet = $item2[1];
- }
-
+ if ($pconfig['address'] <> ""):
+ $addresses = explode(" ", $pconfig['address']);
+ $details = explode("||", $pconfig['detail']);
+ while ($counter < count($addresses)):
+ if (is_subnet($addresses[$counter])) {
+ list($address, $address_subnet) = explode("/", $addresses[$counter]);
+ } else {
+ $address = $addresses[$counter];
+ $address_subnet = "";
}
- $item4 = $item3[$counter];
- $tracker = $counter;
+ $detail = $details[$counter];
?>
<tr>
<td>
- <input autocomplete="off" name="address<?php echo $tracker; ?>" type="text" class="formfldalias ipv4v6" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
+ <input autocomplete="off" name="address<?php echo $counter; ?>" type="text" class="formfldalias ipv4v6" id="address<?php echo $counter; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
</td>
<td>
- <select name="address_subnet<?php echo $tracker; ?>" class="formselect ipv4v6" id="address_subnet<?php echo $tracker; ?>">
+ <select name="address_subnet<?php echo $counter; ?>" class="formselect ipv4v6" id="address_subnet<?php echo $counter; ?>">
<option></option>
<?php for ($i = 128; $i >= 1; $i--): ?>
<option value="<?=$i;?>" <?php if (($i == $address_subnet) || ($i == $pconfig['updatefreq'])) echo "selected=\"selected\""; ?>><?=$i;?></option>
@@ -736,7 +730,7 @@ if (empty($tab)) {
</select>
</td>
<td>
- <input name="detail<?php echo $tracker; ?>" type="text" class="formfld unknown" id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
+ <input name="detail<?php echo $counter; ?>" type="text" class="formfld unknown" id="detail<?php echo $counter; ?>" size="50" value="<?=$detail;?>" />
</td>
<td>
<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="" title="<?=gettext("remove this entry"); ?>" /></a>
@@ -745,8 +739,8 @@ if (empty($tab)) {
<?php
$counter++;
- } // end foreach
- } // end if
+ endwhile;
+ endif;
?>
</tbody>
</table>
OpenPOWER on IntegriCloud