]>
Commit | Line | Data |
---|---|---|
e0639d80 JPT |
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 | ||
9ed70c0e | 66 | if ($dnssettings{'RECONNECT'} eq $Lang::tr{'reconnect'}) { |
e0639d80 JPT |
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 | ||
2e1432c4 JPT |
73 | if ($dnssettings{'DELETE'} eq $Lang::tr{'delete'}) { |
74 | system("cat /dev/null > ${General::swroot}/dns/settings &"); | |
75 | &Header::openbox('100%', 'left', $Lang::tr{'dns address deleted'} ); | |
76 | print "<font class='base'>$Lang::tr{'dns address deleted txt'}</font>\n"; | |
77 | &Header::closebox(); | |
78 | } | |
79 | ||
e0639d80 JPT |
80 | # DPC move error message to top so it is seen! |
81 | if ($errormessage) { | |
82 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
83 | print "<font class='base'>$errormessage </font>\n"; | |
84 | &Header::closebox(); | |
85 | } | |
86 | ||
87 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
88 | ||
89 | &Header::openbox('100%', 'left', $Lang::tr{'dns header'}); | |
90 | print <<END | |
91 | ||
92 | <table border="0" width='100%'> | |
93 | <tr> | |
94 | <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> | |
95 | </tr> | |
96 | <tr> | |
97 | <td colspan="2"> </td> | |
98 | </tr> | |
99 | <tr> | |
100 | <td width="25%"><font class='base'>$Lang::tr{'dns new 0'}</font></td> | |
101 | <td width="75%"><input type="text" name="DNS0" maxlength="15" value="$dnssettings{"DNS0"}"/></td> | |
102 | </tr> | |
103 | <tr> | |
104 | <td><font class='base'>$Lang::tr{'dns new 1'}</font></td> | |
105 | <td><input type="text" name="DNS1" maxlength="15" value="$dnssettings{"DNS1"}"/></td> | |
106 | </tr> | |
107 | <tr> | |
108 | <td colspan="2"><hr /></td> | |
109 | </tr> | |
110 | <tr> | |
111 | <td colspan="2"><div align="center"> | |
112 | <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /> | |
113 | | |
2e1432c4 JPT |
114 | <input type='submit' name='DELETE' value='$Lang::tr{'delete'}' /> |
115 | | |
9ed70c0e | 116 | <input type='submit' name='RECONNECT' value='$Lang::tr{'reconnect'}' /> |
e0639d80 JPT |
117 | </div> |
118 | </td> | |
119 | </tr> | |
120 | </table> | |
121 | ||
122 | END | |
123 | ; | |
124 | ||
125 | &Header::closebox(); | |
126 | ||
127 | print "</form>\n"; | |
128 | ||
129 | &Header::closebigbox(); | |
130 | ||
131 | &Header::closepage(); | |
132 |