]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/dhcp.cgi
dhcpcd.exe geschrieben.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / dhcp.cgi
index be7e0bf5319ab1ffb7bb85bc88fe125d74c4c57c..91383373412e8cec74fffd8f18c1dd8c71a379f8 100644 (file)
@@ -25,7 +25,7 @@ use strict;
 #use warnings;
 #use CGI::Carp 'fatalsToBrowser';
 
-require 'CONFIG_ROOT/general-functions.pl';
+require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 #workaround to suppress a warning when a variable is used only once
@@ -38,18 +38,20 @@ my %mainsettings=();
 my %timesettings=();
 my $setting = "${General::swroot}/dhcp/settings";
 our $filename1 = "${General::swroot}/dhcp/advoptions";         # Field separator is TAB in this file (comma is standart)
-                                                       # because we need commas in the some data
+                                                                       # because we need commas in the some data
 our $filename2 = "${General::swroot}/dhcp/fixleases";
-our $filename3 = "${General::swroot}/dhcp/advoptions-list"; # Describe the allowed syntax for dhcp options
+our $filename3 = "${General::swroot}/dhcp/advoptions-list";    # Describe the allowed syntax for dhcp options
 my $errormessage = '';
 my $warnNTPmessage = '';
 my @nosaved=();
+my %color = ();
 
 #Basic syntax allowed for new Option definition. Not implemented: RECORDS & array of RECORDS 
 our $OptionTypes = 'boolean|((un)?signed )?integer (8|16|32)|ip-address|text|string|encapsulate \w+|array of ip-address';
 
 &Header::showhttpheaders();
-our @ITFs=('GREEN','BLUE');
+our @ITFs=('GREEN');
+if (&Header::blue_used()){push(@ITFs,'BLUE');}
 
 #Settings1 for the first screen box
 foreach my $itf (@ITFs) {
@@ -66,6 +68,8 @@ foreach my $itf (@ITFs) {
     $dhcpsettings{"DNS2_${itf}"} = '';
     $dhcpsettings{"NTP1_${itf}"} = '';
     $dhcpsettings{"NTP2_${itf}"} = '';
+    $dhcpsettings{"NEXT_${itf}"} = '';
+    $dhcpsettings{"FILE_${itf}"} = '';
 }
 
 $dhcpsettings{'SORT_FLEASELIST'} = 'FIPADDR';
@@ -99,6 +103,7 @@ foreach my $itf (@ITFs) {
 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
 &General::readhash("${General::swroot}/time/settings", \%timesettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
 
 #Get GUI values
 &Header::getcgihash(\%dhcpsettings);
@@ -206,7 +211,12 @@ if ($dhcpsettings{'ACTION'} eq $Lang::tr{'save'}) {
                        goto ERROR;
                }               
            }
-
+           if ($dhcpsettings{"NEXT_${itf}"}) {
+               if (!(&General::validip($dhcpsettings{"NEXT_${itf}"}))) {
+                       $errormessage = "next-server on ${itf}: " . $Lang::tr{'invalid ip'};
+                       goto ERROR;
+               }
+           }
            if ($dhcpsettings{"NTP1_${itf}"}) {
                if (!(&General::validip($dhcpsettings{"NTP1_${itf}"}))) {
                        $errormessage = "DHCP on ${itf}: " . $Lang::tr{'invalid primary ntp'};
@@ -532,7 +542,7 @@ print <<END
     <td width='25%' class='boldbase'><b><font color='${lc_itf}'>$Lang::tr{"$lc_itf interface"}</font></b></td>
     <td class='base'>$Lang::tr{'enabled'}
     <input type='checkbox' name='ENABLE_${itf}' $checked{'ENABLE'}{'on'} /></td>
-    <td width='25%' class='base'>$Lang::tr{'ip address'}/$Lang::tr{'netmask'}:</td><td><b>$netsettings{"${itf}_ADDRESS"}/$netsettings{"${itf}_NETMASK"}</b></td>
+    <td width='25%' class='base'>$Lang::tr{'ip address'}<br />$Lang::tr{'netmask'}:</td><td><b>$netsettings{"${itf}_ADDRESS"}<br />$netsettings{"${itf}_NETMASK"}</b></td>
 </tr><tr>
     <td width='25%' class='base'>$Lang::tr{'start address'}&nbsp;<img src='/blob.gif' alt='*' /></td>
     <td width='25%'><input type='text' name='START_ADDR_${itf}' value='$dhcpsettings{"START_ADDR_${itf}"}' /></td>
@@ -563,6 +573,11 @@ print <<END
     <td><input type='text' name='WINS1_${itf}' value='$dhcpsettings{"WINS1_${itf}"}' /></td>
     <td class='base'>$Lang::tr{'secondary wins server address'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
     <td><input type='text' name='WINS2_${itf}' value='$dhcpsettings{"WINS2_${itf}"}' /></td>
+</tr><tr>
+    <td class='base'>next-server:&nbsp;<img src='/blob.gif' alt='*' /></td>
+    <td><input type='text' name='NEXT_${itf}' value='$dhcpsettings{"NEXT_${itf}"}' /></td>
+    <td class='base'>filename:&nbsp;<img src='/blob.gif' alt='*' /></td>
+    <td><input type='text' name='FILE_${itf}' value='$dhcpsettings{"FILE_${itf}"}' /></td>
 </tr>
 </table>
 <hr />
@@ -576,9 +591,7 @@ print <<END
     <td class='base' width='25%'><img src='/blob.gif' align='top' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
     <td class='base' width='30%'>$warnNTPmessage</td>
     <td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
-    <td width='5%' align='right'>
-        <a href='${General::adminmanualurl}/services.html#services_dhcp' target='_blank'>
-        <img src='/images/web-support.png' alt='$Lang::tr{'online help en'}' title='$Lang::tr{'online help en'}' /></a></td>
+    <td width='5%' align='right'>&nbsp;</td>
 </tr>
 </table>
 </form>
@@ -710,9 +723,9 @@ foreach my $line (@current1) {
     if ($dhcpsettings{'KEY1'} eq $key) {
        print "<tr bgcolor='${Header::colouryellow}'>";
     } elsif ($key % 2) {
-       print "<tr bgcolor='${Header::table2colour}'>";
+       print "<tr bgcolor='$color{'color22'}'>";
     } else {
-       print "<tr bgcolor='${Header::table1colour}'>"; 
+       print "<tr bgcolor='$color{'color20'}'>"; 
     }
 
     print <<END
@@ -908,9 +921,9 @@ foreach my $line (@current2) {
     if ($dhcpsettings{'KEY2'} eq $key) {
        print "<tr bgcolor='${Header::colouryellow}'>";
     } elsif ($key % 2) {
-       print "<tr bgcolor='${Header::table2colour}'>";
+       print "<tr bgcolor='$color{'color22'}'>";
     } else {
-       print "<tr bgcolor='${Header::table1colour}'>"; 
+       print "<tr bgcolor='$color{'color20'}'>"; 
     }
     my $TAG0 = '';
     my $TAG1 = '';
@@ -1001,7 +1014,6 @@ END
 
 &Header::closebox();
 
-
 foreach my $itf (@ITFs) {
     if ($dhcpsettings{"ENABLE_${itf}"} eq 'on') {
        # display leases with a list of actions to do with the global select checkbox.
@@ -1138,6 +1150,8 @@ sub buildconf {
            print FILE "\toption netbios-name-servers " . $dhcpsettings{"WINS1_${itf}"}     if ($dhcpsettings{"WINS1_${itf}"});
            print FILE ", " . $dhcpsettings{"WINS2_${itf}"}                            if ($dhcpsettings{"WINS2_${itf}"});
            print FILE ";\n"                                                           if ($dhcpsettings{"WINS1_${itf}"});
+           print FILE "\tnext-server " . $dhcpsettings{"NEXT_${itf}"} . ";\n" if ($dhcpsettings{"NEXT_${itf}"});
+           print FILE "\tfilename \"" . $dhcpsettings{"FILE_${itf}"} . "\";\n" if ($dhcpsettings{"FILE_${itf}"});
            print FILE "\tdefault-lease-time " . ($dhcpsettings{"DEFAULT_LEASE_TIME_${itf}"} * 60). ";\n";
            print FILE "\tmax-lease-time "     . ($dhcpsettings{"MAX_LEASE_TIME_${itf}"} * 60)    . ";\n";
            print FILE "\tallow bootp;\n" if ($dhcpsettings{"ENABLEBOOTP_${itf}"} eq 'on');
@@ -1160,7 +1174,7 @@ sub buildconf {
            }# foreach line
            print FILE "} #$itf\n";
 
-           system ('/bin/touch', "${General::swroot}/dhcp/enable_${lc_itf}");
+           system ('/usr/bin/touch', "${General::swroot}/dhcp/enable_${lc_itf}");
            &General::log("DHCP on ${itf}: " . $Lang::tr{'dhcp server enabled'})
        } else {
            unlink "${General::swroot}/dhcp/enable_${lc_itf}";
@@ -1186,7 +1200,9 @@ sub buildconf {
        }
     }
     close FILE;
-    system '/usr/local/bin/restartdhcp';
+    if ( $dhcpsettings{"ENABLE_GREEN"} eq 'on' || $dhcpsettings{"ENABLE_BLUE"} eq 'on' ) {system '/usr/local/bin/dhcpctrl enable >/dev/null 2>&1';}
+    else {system '/usr/local/bin/dhcpctrl disable >/dev/null 2>&1';}
+    system '/usr/local/bin/dhcpctrl restart >/dev/null 2>&1';
 }
 
 #