This is just a dirty hack, but I think it'll be quicker to impliment.

I added a new key, <details> by hand to my existing alias entries.

<aliases>
 <alias>
   <name>Netblocks</name>
   <address>192.168.0.0/17 10.10.0.0/19 172.168.16.0/24</address>
   <details>Bob's netblock||random netblock</details>
   <descr>Netblocks of questionable value</descr>
 </alias>
</aliases>

I then did the following to firewall_aliases_edit.php:
*** firewall_aliases_edit.php   Wed Dec 28 11:00:34 2005
--- firewall_aliases_edit.jc    Wed Dec 28 14:49:51 2005
***************
*** 62,67 ****
--- 62,72 ----
                       $pconfig['type'] = "port";

       $pconfig['descr'] = $a_aliases[$id]['descr'];
+       $address_details = explode('|', $a_aliases[$id]['detail']);
+       if (is_array($address_details))
+               $address_detail = $address_details[0];
+       else
+               $address_detail = $address_details;
 }

 if ($_POST) {
***************
*** 295,301 ****
--- 300,308 ----
                       <?php
                       $counter = 0;
                       $address = $a_aliases[$id]['address'];
+                       $address_detail = $a_aliases[$id]['detail'];
                       $item = explode(" ", $address);
+                       $item3 = explode("|", $address_detail);
                       foreach($item as $ww) {
                               $address = $item[$counter];
                               $address_subnet = "";
***************
*** 306,311 ****
--- 313,319 ----
$address_subnet = $item2[1];
                                       }
                               }
+                               $item4 = $item3[$counter];
if($counter > 0) $tracker = $counter + 1;
                       ?>
<tr><td> <input name="address<?php echo $tracker; ?>" type="text" class="formfld" id="address<?php echo $tracker; ?>" size="20" value="<?=htmlspecialchars($address);?>"></td><td>
***************
*** 315,320 ****
--- 323,329 ----
<option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
                         <?php endfor; ?>
                       </select>
+ </td><td><?=htmlspecialchars($item4);?></td><td>
                         <?php
                               if($counter > 0)
echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\">";


My details come out as expected, lined up with the appropriate entry. This cuts down the amount of input validation required, and eliminates needing to work on the pf conf generator, it can just safely ignore the new key.

It's not as clean as my earlier idea, but I think I stand a far better chance of making it work at the moment. : )

Joshua Coombs

Reply via email to