]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/usr/bin/perl\r |
2 | #\r | |
3 | # SmoothWall CGIs\r | |
4 | #\r | |
5 | # This code is distributed under the terms of the GPL\r | |
6 | #\r | |
7 | # (c) The SmoothWall Team\r | |
8 | #\r | |
9 | # $Id: upload.cgi,v 1.2.2.21 2005/08/14 23:43:38 gespinasse Exp $\r | |
10 | #\r | |
11 | \r | |
12 | use File::Copy;\r | |
13 | use strict;\r | |
14 | \r | |
15 | # enable only the following on debugging purpose\r | |
16 | #use warnings;\r | |
17 | #use CGI::Carp 'fatalsToBrowser';\r | |
18 | \r | |
19 | require 'CONFIG_ROOT/general-functions.pl';\r | |
20 | require "${General::swroot}/lang.pl";\r | |
21 | require "${General::swroot}/header.pl";\r | |
22 | \r | |
23 | my %uploadsettings=();\r | |
24 | my $errormessage = '';\r | |
25 | \r | |
26 | &Header::showhttpheaders();\r | |
27 | $uploadsettings{'ACTION'} = '';\r | |
28 | \r | |
29 | &Header::getcgihash(\%uploadsettings, {'wantfile' => 1, 'filevar' => 'FH'});\r | |
30 | \r | |
31 | my $extraspeedtouchmessage='';\r | |
32 | my $extrafritzdslmessage='';\r | |
33 | my $extraeciadslmessage='';\r | |
34 | my $modem='';\r | |
35 | my $firmwarename='';\r | |
36 | my $kernel='';\r | |
37 | \r | |
38 | my $speedtouch = &Header::speedtouchversion;\r | |
39 | if ($speedtouch == 4) {\r | |
40 | $modem='v4_b';\r | |
41 | $firmwarename="$Lang::tr{'upload'} ZZZL_3.012";\r | |
42 | } else {\r | |
43 | $modem='v0123';\r | |
44 | $firmwarename="$Lang::tr{'upload'} KQD6_3.012";\r | |
45 | }\r | |
46 | \r | |
47 | $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;\r | |
48 | \r | |
49 | if ($uploadsettings{'ACTION'} eq $firmwarename) {\r | |
50 | if ($modem eq 'v0123' || $modem eq 'v4_b') {\r | |
51 | if (copy ($uploadsettings{'FH'}, "${General::swroot}/alcatelusb/firmware.$modem.bin") != 1) {\r | |
52 | $errormessage = $!;\r | |
53 | } else {\r | |
54 | $extraspeedtouchmessage = $Lang::tr{'upload successful'};\r | |
55 | }\r | |
56 | }\r | |
57 | }\r | |
58 | elsif ($uploadsettings{'ACTION'} eq "$Lang::tr{'upload'} fcdsl-${General::version}.tgz")\r | |
59 | {\r | |
60 | if (copy ($uploadsettings{'FH'}, "/var/patches/fcdsl-x.tgz") != 1) {\r | |
61 | $errormessage = $!;\r | |
62 | } else {\r | |
63 | $extrafritzdslmessage = $Lang::tr{'upload successful'};\r | |
64 | }\r | |
65 | }\r | |
66 | elsif ($uploadsettings{'ACTION'} eq $Lang::tr{'upload synch.bin'})\r | |
67 | {\r | |
68 | if (copy ($uploadsettings{'FH'}, "${General::swroot}/eciadsl/synch.bin") != 1) {\r | |
69 | $errormessage = $!;\r | |
70 | } else {\r | |
71 | $extraeciadslmessage = $Lang::tr{'upload successful'};\r | |
72 | }\r | |
73 | }\r | |
74 | \r | |
75 | &Header::openpage($Lang::tr{'firmware upload'}, 1, '');\r | |
76 | \r | |
77 | &Header::openbigbox('100%', 'left', '', $errormessage);\r | |
78 | \r | |
79 | if ($errormessage) {\r | |
80 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'});\r | |
81 | print "<font class='base'>$errormessage </font>\n";\r | |
82 | &Header::closebox();\r | |
83 | }\r | |
84 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";\r | |
85 | \r | |
86 | &Header::openbox('100%','left', $Lang::tr{'alcatelusb upload'});\r | |
87 | print <<END\r | |
88 | <table width='100%'>\r | |
89 | <tr>\r | |
90 | <td colspan='4'>$Lang::tr{'alcatelusb help'}<br />\r | |
91 | URL: <a href='http://www.speedtouch.com/support.htm'>http://www.speedtouch.com/support.htm</a>\r | |
92 | </td>\r | |
93 | </tr>\r | |
94 | <tr><td colspan='4'>$Lang::tr{'modem'}: Rev <b>$speedtouch</b></td></tr>\r | |
95 | <tr>\r | |
96 | <td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}: </td>\r | |
97 | <td width='45%'><input type="file" size='30' name="FH" /></td>\r | |
98 | <td width='35%' align='center'><input type='submit' name='ACTION' value='$firmwarename' /></td>\r | |
99 | <td width='15%'>\r | |
100 | END\r | |
101 | ;\r | |
102 | if (-e "${General::swroot}/alcatelusb/firmware.$modem.bin") {\r | |
103 | if ($extraspeedtouchmessage ne '') {\r | |
104 | print ("$extraspeedtouchmessage</td>");\r | |
105 | } else {\r | |
106 | print ("$Lang::tr{'present'}</td>");\r | |
107 | }\r | |
108 | } else {\r | |
109 | print ("$Lang::tr{'not present'}</td>");\r | |
110 | }\r | |
111 | print <<END\r | |
112 | </tr>\r | |
113 | </table>\r | |
114 | END\r | |
115 | ;\r | |
116 | \r | |
117 | &Header::closebox();\r | |
118 | \r | |
119 | &Header::openbox('100%','left', $Lang::tr{'eciadsl upload'});\r | |
120 | print <<END\r | |
121 | <table width='100%'>\r | |
122 | <tr>\r | |
123 | <td colspan='4'>$Lang::tr{'eciadsl help'}<br />\r | |
124 | URL: <a href='http://eciadsl.flashtux.org/'>http://eciadsl.flashtux.org/</a>\r | |
125 | </td>\r | |
126 | </tr>\r | |
127 | <tr>\r | |
128 | <td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}: </td>\r | |
129 | <td width='45%'><input type="file" size='30' name="FH" /></td>\r | |
130 | <td width='35%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'upload synch.bin'}' /></td>\r | |
131 | <td width='15%'>\r | |
132 | END\r | |
133 | ;\r | |
134 | if (-e "${General::swroot}/eciadsl/synch.bin") {\r | |
135 | if ($extraeciadslmessage ne '') {\r | |
136 | print ("$extraeciadslmessage</td>");\r | |
137 | } else {\r | |
138 | print ("$Lang::tr{'present'}</td>");\r | |
139 | }\r | |
140 | } else {\r | |
141 | print ("$Lang::tr{'not present'}</td>");\r | |
142 | }\r | |
143 | print <<END\r | |
144 | </tr>\r | |
145 | </table>\r | |
146 | END\r | |
147 | ;\r | |
148 | &Header::closebox();\r | |
149 | \r | |
150 | &Header::openbox('100%','left', $Lang::tr{'fritzdsl upload'});\r | |
151 | print <<END\r | |
152 | <table width='100%'>\r | |
153 | <tr>\r | |
154 | <td colspan='4'>$Lang::tr{'fritzdsl help'}<br />\r | |
155 | URL: <a href='http://www.ipcop.org/'>http://www.ipcop.org/</a>\r | |
156 | </td>\r | |
157 | </tr>\r | |
158 | <tr>\r | |
159 | <td width='5%' class='base' nowrap='nowrap'>$Lang::tr{'upload file'}: </td>\r | |
160 | <td width='45%'><input type="file" size='30' name="FH" /></td>\r | |
161 | <td width='35%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'upload'} fcdsl-${General::version}.tgz"/></td>\r | |
162 | <td width='15%'>\r | |
163 | END\r | |
164 | ;\r | |
165 | if ($extrafritzdslmessage ne '') {\r | |
166 | print ("$extrafritzdslmessage</td></tr><tr><td> </td><td><pre>");\r | |
167 | print `/usr/local/bin/installfcdsl`;\r | |
168 | print ("</pre></td>");\r | |
169 | } else {\r | |
170 | if (-e "/lib/modules/$kernel/misc/fcdsl.o.gz") {\r | |
171 | print ("$Lang::tr{'present'}</td>");\r | |
172 | } else {\r | |
173 | print ("$Lang::tr{'not present'}</td>");\r | |
174 | }\r | |
175 | }\r | |
176 | print <<END\r | |
177 | </tr>\r | |
178 | </table>\r | |
179 | END\r | |
180 | ;\r | |
181 | &Header::closebox();\r | |
182 | \r | |
183 | print "</form>\n";\r | |
184 | \r | |
185 | &Header::closebigbox();\r | |
186 | \r | |
187 | &Header::closepage();\r |