]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/upload.cgi
git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848...
[ipfire-2.x.git] / html / cgi-bin / upload.cgi
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
12 use File::Copy;
13 use strict;
14
15 # enable only the following on debugging purpose
16 #use warnings;
17 #use CGI::Carp 'fatalsToBrowser';
18
19 require 'CONFIG_ROOT/general-functions.pl';
20 require "${General::swroot}/lang.pl";
21 require "${General::swroot}/header.pl";
22
23 my %uploadsettings=();
24 my $errormessage = '';
25
26 &Header::showhttpheaders();
27 $uploadsettings{'ACTION'} = '';
28
29 &Header::getcgihash(\%uploadsettings, {'wantfile' => 1, 'filevar' => 'FH'});
30
31 my $extraspeedtouchmessage='';
32 my $extrafritzdslmessage='';
33 my $extraeciadslmessage='';
34 my $modem='';
35 my $firmwarename='';
36 my $kernel='';
37
38 my $speedtouch = &Header::speedtouchversion;
39 if ($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
49 if ($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 }
58 elsif ($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 }
66 elsif ($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
79 if ($errormessage) {
80 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
81 print "<font class='base'>$errormessage&nbsp;</font>\n";
82 &Header::closebox();
83 }
84 print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
85
86 &Header::openbox('100%','left', $Lang::tr{'alcatelusb upload'});
87 print <<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%'>
100 END
101 ;
102 if (-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 }
111 print <<END
112 </tr>
113 </table>
114 END
115 ;
116
117 &Header::closebox();
118
119 &Header::openbox('100%','left', $Lang::tr{'eciadsl upload'});
120 print <<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%'>
132 END
133 ;
134 if (-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 }
143 print <<END
144 </tr>
145 </table>
146 END
147 ;
148 &Header::closebox();
149
150 &Header::openbox('100%','left', $Lang::tr{'fritzdsl upload'});
151 print <<END
152 <table width='100%'>
153 <tr>
154 <td colspan='4'>$Lang::tr{'fritzdsl help'}<br />
155 URL: <a href='http://www.ipcop.org/'>http://www.ipcop.org/</a>
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%'>
163 END
164 ;
165 if ($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 }
176 print <<END
177 </tr>
178 </table>
179 END
180 ;
181 &Header::closebox();
182
183 print "</form>\n";
184
185 &Header::closebigbox();
186
187 &Header::closepage();