diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2007-12-09 06:09:10 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2007-12-09 06:09:10 +0000 |
commit | b875f3061a6591de849d8c01240cefaf359d13ac (patch) | |
tree | 547ff183511859088b239a080e5e6360303f441d | |
parent | 5d721fa0d83032a15862c7f390674e0a14f4f87f (diff) | |
download | pfsense-b875f3061a6591de849d8c01240cefaf359d13ac.zip pfsense-b875f3061a6591de849d8c01240cefaf359d13ac.tar.gz |
Convert the dns server code into a for loop and add 2 more dns servers on. Now we can easily control how many dns servers we want to allow entry for. Also get rid of code duplication.
-rw-r--r-- | etc/inc/system.inc | 23 | ||||
-rwxr-xr-x | usr/local/www/system.php | 37 |
2 files changed, 21 insertions, 39 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc index e231fd1..64e4a60 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -140,18 +140,17 @@ function system_resolvconf_generate($dynupdate = false) { services_dhcpd_configure(); } - /* setup static routes for dns servers */ - if($config['system']['dns1gwint']) { - $if = $config['system']['dns1gwint']; - $gw = $config['interfaces'][$if]['if']; - exec("route delete {$syscfg['dnsserver'][0]}"); - exec("route add {$syscfg['dnsserver'][0]} -gw {$gw}"); - } - if($config['system']['dns2gwint']) { - $if = $config['system']['dns2gwint']; - $gw = $config['interfaces'][$if]['if']; - exec("route delete {$syscfg['dnsserver'][1]}"); - exec("route add {$syscfg['dnsserver'][1]} -gw {$gw}"); + for($dnscounter=1; $dnscounter<5; $dnscounter++) { + /* setup static routes for dns servers */ + if($config['system']['dns{$dnscounter}gwint']) { + $if = $config['system']['dns{$dnscounter}gwint']; + if($if) { + $gw = $config['interfaces'][$if]['if']; + $dnscountermo = $dnscounter - 1; + exec("route delete {$syscfg['dnsserver'][$dnscountermo]}"); + exec("route add {$syscfg['dnsserver'][$dnscountermo]} -gw {$gw}"); + } + } } return 0; diff --git a/usr/local/www/system.php b/usr/local/www/system.php index 04885d6..3744d85 100755 --- a/usr/local/www/system.php +++ b/usr/local/www/system.php @@ -226,54 +226,37 @@ include("head.inc"); <?php $multiwan = false; foreach($config['interfaces'] as $int) - if($int['gateway']) + if($int['gateway']) $multiwan = true; $ints = get_interface_list(); if($multiwan) echo "<td><b>Use gateway</td>"; ?> </tr> +<?php for($dnscounter=1; $dnscounter<5; $dnscounter++): ?> <tr> - <td> - <input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"> + <td> + <input name="dns{$dnscounter}" type="text" class="formfld unknown" id="dns{$dnscounter}" size="20" value="<?=htmlspecialchars($pconfig['dns{$dnscounter}']);?>"> </td> <?php - $ints = get_interface_list(); if($multiwan) { - echo "<td><select name='dns1gwint'>\n"; - echo "<option></option>"; + echo "<td><select name='dns{$dnscounter}gwint'>\n"; + echo "<option value=''>wan</option>"; foreach($ints as $int) { $friendly = $int['friendly']; - if($config['interfaces'][$friendly]['gateway']) { + if($config['interfaces'][$friendly]['gateway']) { $selected = ""; - if($pconfig['dns1gwint'] == $int) + if($pconfig['dns{$dnscounter}gwint'] == $int) $selected = " SELECTED"; echo "<option value='{$friendly}'{$selected}>{$friendly}</option>"; } } echo "</select>"; } - ?></td></tr> - <tr><td> - <input name="dns2" type="text" class="formfld unknown" id="dns22" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"> - </td> - <?php - if($multiwan) { - echo "<td><select name='dns2gwint'>\n"; - echo "<option></option>"; - foreach($ints as $int) { - $friendly = $int['friendly']; - if($config['interfaces'][$friendly]['gateway']) { - $selected = ""; - if($pconfig['dns2gwint'] == $int) - $selected = " SELECTED"; - echo "<option value='{$friendly}'{$selected}>{$friendly}</option>"; - } - } - echo "</select></td>"; - } ?> + </td> </tr> +<?php endfor; ?> </table> <br> <span class="vexpl">IP addresses; these are also used for |