]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
25 | #use warnings; | |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
27 | ||
28 | require '/var/ipfire/general-functions.pl'; | |
29 | require "${General::swroot}/lang.pl"; | |
30 | require "${General::swroot}/header.pl"; | |
31 | ||
32 | my %dnssettings=(); | |
33 | my $errormessage = ''; | |
34 | ||
35 | &Header::showhttpheaders(); | |
36 | ||
37 | &General::readhash("${General::swroot}/dns/settings", \%dnssettings); | |
38 | ||
39 | &Header::getcgihash(\%dnssettings); | |
40 | ||
41 | &Header::openpage($Lang::tr{'dns title'}, 1, ); | |
42 | ||
43 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
44 | ||
45 | if ($dnssettings{'ACTION'} eq $Lang::tr{'save'}) { | |
46 | if ((&General::validip($dnssettings{"DNS0"}) == 1)&&(&General::validip($dnssettings{"DNS1"}) == 1)) { | |
47 | if ($errormessage eq "") { | |
48 | &General::writehash("${General::swroot}/dns/settings", \%dnssettings); | |
49 | &Header::openbox('100%', 'left', $Lang::tr{'dns saved'}); | |
50 | print "<font class='base'>$Lang::tr{'dns saved txt'}</font>\n"; | |
51 | &Header::closebox(); | |
52 | } | |
53 | } else { | |
54 | if ((&General::validip($dnssettings{"DNS0"}) == 0)&&(&General::validip($dnssettings{"DNS1"}) == 1)){ | |
55 | $errormessage = $Lang::tr{'dns error 0'}; | |
56 | } | |
57 | if ((&General::validip($dnssettings{"DNS1"}) == 0)&&(&General::validip($dnssettings{"DNS0"}) == 1)){ | |
58 | $errormessage = $Lang::tr{'dns error 1'}; | |
59 | } | |
60 | if ((&General::validip($dnssettings{"DNS1"}) == 0)&&(&General::validip($dnssettings{"DNS0"}) == 0)){ | |
61 | $errormessage = $Lang::tr{'dns error 01'}; | |
62 | } | |
63 | } | |
64 | } | |
65 | ||
66 | if ($dnssettings{'RECONNECT'} eq $Lang::tr{'reconnect'}) { | |
67 | system("/usr/local/bin/redctrl restart >/dev/null 2>&1 &"); | |
68 | &Header::openbox('100%', 'left', $Lang::tr{'dns address recon'} ); | |
69 | print "<font class='base'>$Lang::tr{'dns address done'}</font>\n"; | |
70 | &Header::closebox(); | |
71 | } | |
72 | ||
73 | # DPC move error message to top so it is seen! | |
74 | if ($errormessage) { | |
75 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
76 | print "<font class='base'>$errormessage </font>\n"; | |
77 | &Header::closebox(); | |
78 | } | |
79 | ||
80 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
81 | ||
82 | &Header::openbox('100%', 'left', $Lang::tr{'dns header'}); | |
83 | print <<END | |
84 | ||
85 | <table border="0" width='100%'> | |
86 | <tr> | |
87 | <td colspan="2"><font class='base'>$Lang::tr{'dns desc'}<br /><img src="/images/dns_link.png" border="0" align="absmiddle"/><a href="http://wiki.ipfire.org/$Lang::tr{'lang'}/configuration/dns_list" target="_blank">$Lang::tr{'dns list'}</a></font></td> | |
88 | </tr> | |
89 | <tr> | |
90 | <td colspan="2"> </td> | |
91 | </tr> | |
92 | <tr> | |
93 | <td width="25%"><font class='base'>$Lang::tr{'dns new 0'}</font></td> | |
94 | <td width="75%"><input type="text" name="DNS0" maxlength="15" value="$dnssettings{"DNS0"}"/></td> | |
95 | </tr> | |
96 | <tr> | |
97 | <td><font class='base'>$Lang::tr{'dns new 1'}</font></td> | |
98 | <td><input type="text" name="DNS1" maxlength="15" value="$dnssettings{"DNS1"}"/></td> | |
99 | </tr> | |
100 | <tr> | |
101 | <td colspan="2"><hr /></td> | |
102 | </tr> | |
103 | <tr> | |
104 | <td colspan="2"><div align="center"> | |
105 | <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /> | |
106 | | |
107 | <input type='submit' name='RECONNECT' value='$Lang::tr{'reconnect'}' /> | |
108 | </div> | |
109 | </td> | |
110 | </tr> | |
111 | </table> | |
112 | ||
113 | END | |
114 | ; | |
115 | ||
116 | &Header::closebox(); | |
117 | ||
118 | print "</form>\n"; | |
119 | ||
120 | &Header::closebigbox(); | |
121 | ||
122 | &Header::closepage(); | |
123 |