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