1 | #!/usr/bin/perl |
---|
2 | use vars qw(%set %in); |
---|
3 | use strict; |
---|
4 | $set{'log_file'} = './log.cgi'; #Ot@C¼ |
---|
5 | $set{'max_log'} = 30; #Û |
---|
6 | $set{'max_size'} = 1*1024; #ÅåeeÊ(KB) |
---|
7 | $set{'min_flag'} = 0; #ŬeʧÀðgp·é=1 |
---|
8 | $set{'min_size'} = 100; #ŬeeÊ(KB) |
---|
9 | $set{'max_all_flag'} = 0; #eʧÀðgp·é=1 |
---|
10 | $set{'max_all_size'} = 20*1024; #§ÀeÊ(KB) |
---|
11 | $set{'file_pre'} = 'up'; #t@CÚª« |
---|
12 | $set{'pagelog'} = 10; #1y[WÉ\¦·ét@C |
---|
13 | $set{'base_html'} = 'upload.html'; #1y[WÚÌt@C¼ |
---|
14 | $set{'interval'} = 0; #¯êIPeÔub |
---|
15 | $set{'deny_host'} = ''; #eÖ~IP/HOST ,ÅæØé ex.(bbtec.net,219.119.66,ac.jp) |
---|
16 | $set{'admin_name'} = 'admin'; #ÇÒOCID |
---|
17 | $set{'admin_pass'} = '1234'; #ÇÒpX[h |
---|
18 | |
---|
19 | # Ⱥ5ÚðÄÝè·éÛÉÍPATHCfBNgÍ / ÅIíé±Æ |
---|
20 | # $set{'html_dir'},$set{'base_cgi'}ð ./ ÈOÉÝè·éê, |
---|
21 | # ܽÍDLkeyðgpµ Ȩ©ÂHTMLLbV
($set{'dummy_html'} = 2 or 3)ðgp·éêÍ |
---|
22 | # $set{'base_cgi'} , $set{'http_html_path'} , $set{'http_src_path'} ðtpX(http://`` or /``)ÅLq·é |
---|
23 | $set{'html_dir'} = './'; # àHTMLÛ¶fBNg |
---|
24 | $set{'src_dir'} = './src/'; # àt@CÛ¶fBNg |
---|
25 | $set{'base_cgi'} = './upload.cgi'; # ±ÌXNvg¼ http://`ÌwèÂ\ |
---|
26 | $set{'http_html_path'} = './'; # htmlQÆ httpPATH http://`ÌwèÂ\ |
---|
27 | $set{'http_src_path'} = './src/'; # fileQÆ httpPATH http://`ÌwèÂ\ |
---|
28 | |
---|
29 | $set{'dlkey'} = 0; # DLKeyðgp·é=1,DLkeyK{=2 |
---|
30 | $set{'up_ext'} = 'txt,lzh,zip,rar,gca,mpg,mp3,avi,swf,bmp,jpg,gif,png'; #Abv[hÅ«éî{g£q ¼pp¬¶ ,ÅæØé |
---|
31 | $set{'up_all'} = 0; #o^ÈOÌàÌàUP³¹çêéæ¤É·é=1 |
---|
32 | $set{'ext_org'} = 0; #$set{'up_all'}ª1ÌIWiÌg£qÉ·é=1 |
---|
33 | $set{'deny_ext'} = 'php,php3,phtml,rb,sh,bat,dll'; #eÖ~Ìg£q ¼pp¬¶ ,ÅæØé |
---|
34 | $set{'change_ext'} = 'cgi->txt,pl->txt,log->txt,jpeg->jpg,mpeg->mpg'; #g£qÏ· O->ã ¼pp¬¶ ,ÅæØé |
---|
35 | |
---|
36 | $set{'home_url'} = ''; #[HOME]ÌNæ ÎpXÍ http://©çnÜéâÎpX |
---|
37 | $set{'html_all'} = 1; #[ALL]ðo·=1 |
---|
38 | $set{'dummy_html'} = 0; #t@CÂÊHTMLð쬷é Êít@CÌÝ=1,DLKeyÝèt@CÌÝ=2,·×Ä=3 |
---|
39 | $set{'find_crypt'} = 1; #ûZIPðo·é=1 |
---|
40 | $set{'binary_compare'} = 0; #ù¶t@CÆoCiär·é=1 |
---|
41 | $set{'post_flag'} = 0; #PostKeyðgp·é=1 |
---|
42 | $set{'post_key'} = 'postkey'; #PostKey ,ÅæØéÆ¡wè ex.(postkey1,postkey2) |
---|
43 | $set{'disp_error'} = 1; #[U[ÉG[ð\¦·é=1 |
---|
44 | $set{'error_level'} = 1; #G[OðL^·é=1 |
---|
45 | $set{'error_log'} = './error.cgi'; #G[Ot@C¼ |
---|
46 | $set{'error_size'} = 1024; # G[OÅåeÊ(KB) §Àȵ=0 |
---|
47 | $set{'zero_clear'} = 1; #t@Cª©Â©çÈ¢êO©çí·é=1 |
---|
48 | |
---|
49 | $set{'disp_comment'} = 1; #Rgð\¦·é=1 |
---|
50 | $set{'disp_date'} = 1; #útð\¦·é=1 |
---|
51 | $set{'disp_size'} = 1; #TCYð\¦·é=1 |
---|
52 | $set{'disp_mime'} = 1; #MIMETYPEð\¦·é=1 |
---|
53 | $set{'disp_orgname'} = 1; #IWit@C¼ð\¦·é=1 |
---|
54 | |
---|
55 | $set{'per_upfile'} = 0666; #Abv[ht@CÌp[~bV suexec=0604,other=0666 |
---|
56 | $set{'per_dir'} = 0777; #\[XAbvfBNgÌp[~bV suexec=0701,other=0777 |
---|
57 | $set{'per_logfile'} = 0666; #Ot@CÌp[~bV@suexec=0600,other=0666 |
---|
58 | $set{'link_target'} = ''; #target®« |
---|
59 | |
---|
60 | #------ |
---|
61 | $set{'ver'} = '2005/10/10e'; |
---|
62 | $set{'char_delname'} = 'D'; |
---|
63 | |
---|
64 | $in{'time'} = time(); $in{'date'} = conv_date($in{'time'}); |
---|
65 | $in{'addr'} = $ENV{'REMOTE_ADDR'}; |
---|
66 | $in{'host'} = gethostbyaddr(pack('C4',split(/\./, $in{'addr'})), 2) || $ENV{'REMOTE_HOST'} || '(none)'; |
---|
67 | |
---|
68 | if($in{'addr'} eq $in{'host'}){ $in{'host'} = '(none)'; } |
---|
69 | |
---|
70 | $set{'html_head'} =<<"EOM"; |
---|
71 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
72 | <html lang="ja"> |
---|
73 | <HEAD> |
---|
74 | <META name="robots" content="noindex,nofollow"> |
---|
75 | <META name="ROBOTS" content="NOINDEX,NOFOLLOW"> |
---|
76 | <META http-equiv="Content-type" content="text/html; charset=Shift_JIS"> |
---|
77 | <META http-equiv="Pragma" content="no-cache"> |
---|
78 | <META http-equiv="Cache-Control" content="no-cache"> |
---|
79 | <META http-equiv="Expires" content="0"> |
---|
80 | <TITLE>Uploader</TITLE> |
---|
81 | EOM |
---|
82 | |
---|
83 | $set{'html_css'} =<<"EOM"; |
---|
84 | <META http-equiv="Content-Style-Type" content="text/css"> |
---|
85 | <STYLE type="text/css"><!-- |
---|
86 | input,td{ font-size: 10pt;font-family:Chicago,Verdana,Arial,sans-serif,"lr oSVbN"; } |
---|
87 | a:hover { background-color:#EECCCC; } |
---|
88 | input,textarea{ border-top : 1px solid ; border-bottom : 1px solid ; border-left : 1px solid ; border-right : 1px solid ;font-size:10pt;background-color:#FFFFFF; } |
---|
89 | --> |
---|
90 | </STYLE> |
---|
91 | EOM |
---|
92 | |
---|
93 | unless(-e $set{'log_file'}){ &init; } |
---|
94 | unless(-e $set{'base_html'}){ &makehtml; } |
---|
95 | { #fR[h |
---|
96 | my $readbuffsize = 1024*8; |
---|
97 | if ($ENV{'REQUEST_METHOD'} eq "POST" && $ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/i){ |
---|
98 | if ($ENV{'CONTENT_LENGTH'} > ($set{'max_size'} * 1024 + 1024)){ if($ENV{'SERVER_SOFTWARE'} =~ /IIS/){ while(read(STDIN,my $buff,$readbuffsize)){} } &error(106,$ENV{'CONTENT_LENGTH'});} |
---|
99 | }else{ |
---|
100 | if ($ENV{'CONTENT_LENGTH'} > 1024*100){ error(98); } |
---|
101 | } |
---|
102 | my %ck; foreach(split(/;/,$ENV{'HTTP_COOKIE'})){ my($key,$val) = split(/=/); $key =~ s/\s//g; $ck{$key} = $val;} |
---|
103 | my @ck = split(/<>/,$ck{'SN_USER'}); |
---|
104 | if(length($ck[0]) < 5){ |
---|
105 | my @salt = ('a'..'z', 'A'..'Z', '0'..'9', '.', '/'); srand; |
---|
106 | my $salt = $salt[int(rand(@salt))] . $salt[int(rand(@salt))]; |
---|
107 | $in{'user'} = crypt($in{'addr'}.$in{'time'}, $salt); |
---|
108 | }else{ $in{'user'} = $ck[0]; } |
---|
109 | |
---|
110 | if($ENV{'REQUEST_METHOD'} eq "POST" && $ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/i){ |
---|
111 | my %FORM; my $subbuff; my $filename; my $valuename; |
---|
112 | my $upflag; my $valueflag; my $bound; my $mime; |
---|
113 | my $readlength = 0; |
---|
114 | my $random = int(rand(900000)) + 100000; |
---|
115 | my $endflag = 0; |
---|
116 | binmode(STDIN); |
---|
117 | while(<STDIN>){ $readlength += length($_); if(/(--.*)\r\n$/){ $bound = $1; last; }} |
---|
118 | if(-e "$set{'src_dir'}$random.temporary"){ $random++; } |
---|
119 | if(-e "$set{'src_dir'}$random.temporary"){ $random++; } |
---|
120 | if(-e "$set{'src_dir'}$random.temporary"){ &error(204); } |
---|
121 | |
---|
122 | open(OUT,">$set{'src_dir'}$random.temporary"); |
---|
123 | binmode(OUT); |
---|
124 | my $formbuff; |
---|
125 | while(my $buff = <STDIN>){ |
---|
126 | $readlength += length($buff); |
---|
127 | if($upflag == 1){ if($buff =~ /Content-Type:\s(.*)\r\n$/i){ $mime = $1; } $upflag++; next;} |
---|
128 | if($upflag == 2){ |
---|
129 | while(1){ |
---|
130 | my $readblen; my $filebuff; |
---|
131 | if($ENV{'CONTENT_LENGTH'} - $readlength < $readbuffsize){ $readblen = $ENV{'CONTENT_LENGTH'} - $readlength; } |
---|
132 | else{ $readblen = $readbuffsize; } |
---|
133 | if(!read(STDIN,$filebuff,$readblen)){ last }; |
---|
134 | $readlength += length($filebuff); |
---|
135 | if($ENV{'CONTENT_LENGTH'} - $readlength < $readbuffsize){ |
---|
136 | my $readblen = $ENV{'CONTENT_LENGTH'} - $readlength; |
---|
137 | read(STDIN,my $subbuff,$readblen); |
---|
138 | $readlength += length($subbuff); |
---|
139 | $filebuff .= $subbuff; |
---|
140 | $endflag = 1; |
---|
141 | } |
---|
142 | my $offset = index($filebuff,$bound); |
---|
143 | if($offset >= 0){ |
---|
144 | $buff = substr($filebuff,0,$offset-2); my $subbuff = substr($filebuff,$offset); |
---|
145 | print OUT $buff; $upflag = 0; $formbuff .= $subbuff; last; |
---|
146 | }else{ print OUT $filebuff; } |
---|
147 | } |
---|
148 | if($endflag){ last; } |
---|
149 | next; |
---|
150 | } |
---|
151 | if($buff =~ /^Content-Disposition:\sform-data;\sname=\"upfile\";\sfilename=\"(.*)\"\r\n$/i){ |
---|
152 | $filename = $1; $upflag = 1; next; |
---|
153 | } |
---|
154 | $formbuff .= $buff; |
---|
155 | } |
---|
156 | close(OUT); |
---|
157 | chmod($set{'per_upfile'},"$set{'src_dir'}$random.temporary"); |
---|
158 | { my $value; |
---|
159 | foreach my $buff(split(/\r\n/,$formbuff)){ |
---|
160 | $buff .= "\r\n"; |
---|
161 | if($buff =~ /^$bound\-\-/){ $FORM{$value} =~ s/\r\n$//; $valueflag = 0; last;} |
---|
162 | if($buff =~ /^$bound/){ $FORM{$value} =~ s/\r\n$//; $valueflag = 0; next;} |
---|
163 | if($valueflag == 1){ $valueflag++; next; } |
---|
164 | if($valueflag == 2){ $FORM{$value} .= $buff; } |
---|
165 | if($buff =~ /^Content-Disposition: form-data; name=\"(.+)\"\r\n$/){ $value = $1; $valueflag++; } |
---|
166 | } |
---|
167 | } |
---|
168 | if($upflag || $valueflag){ unlink("$set{'src_dir'}$random.temporary"); &error(108);} |
---|
169 | |
---|
170 | $in{'postname'} = $FORM{'postname'}; |
---|
171 | $in{'org_pass'} = $in{'pass'} = $FORM{'pass'}; |
---|
172 | $in{'dlkey'} = $FORM{'dlkey'}; |
---|
173 | $in{'comment'} = $FORM{'comment'}; |
---|
174 | $in{'jcode'} = $FORM{'jcode'}; |
---|
175 | $in{'postkey'} = $FORM{'postkey'}; |
---|
176 | $in{'upfile'} = $filename; |
---|
177 | $in{'type'} = $mime; |
---|
178 | $in{'tmpfile'} = "$set{'src_dir'}$random.temporary"; |
---|
179 | $in{'orgname'} = $in{'upfile'}; |
---|
180 | if(-s "$in{'tmpfile'}" == 0){ unlink("$in{'tmpfile'}"); &error(99) } |
---|
181 | if($set{'min_flag'} && ((-s "$in{'tmpfile'}") < $set{'min_size'} * 1024)){ &error(107,(-s "$in{'tmpfile'}"));} |
---|
182 | if((-s "$in{'tmpfile'}") > $set{'max_size'} * 1024){ &error(106,(-s "$in{'tmpfile'}"));} |
---|
183 | if($set{'post_flag'} && !check_postkey($in{'postkey'})){ &error(109); } |
---|
184 | if($set{'dlkey'} == 2 && !$in{'dlkey'}){ unlink("$in{'tmpfile'}"); &error(61); } |
---|
185 | }else{ |
---|
186 | my ($buffer,%FORM,@admin_delno); |
---|
187 | if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});} |
---|
188 | else { $buffer = $ENV{'QUERY_STRING'}; } |
---|
189 | my @pairs = split(/&/,$buffer); |
---|
190 | foreach my $pair (@pairs) { |
---|
191 | my ($name, $value) = split(/=/, $pair); |
---|
192 | $value =~ tr/+/ /; |
---|
193 | $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; |
---|
194 | if($name eq 'admin_delno'){ |
---|
195 | push(@admin_delno,$value); |
---|
196 | }else{ |
---|
197 | $FORM{$name} = $value; |
---|
198 | } |
---|
199 | } |
---|
200 | $in{'delpass'} = $FORM{'delpass'}; |
---|
201 | $in{'delno'} = $FORM{'delno'}; |
---|
202 | $in{'file'} = $FORM{'file'}; |
---|
203 | $in{'dlkey'} = $FORM{'dlkey'}; |
---|
204 | $in{'mode'} = $FORM{'mode'}; |
---|
205 | $in{'checkmode'} = $FORM{'checkmode'}; |
---|
206 | $in{'admin_delno'} = join(',',@admin_delno); |
---|
207 | if($in{'delno'} eq $set{'admin_name'} && $in{'delpass'} eq $set{'admin_pass'}){ &admin_mode(); } |
---|
208 | if(!$in{'delno'} && $in{'delpass'} eq $set{'admin_pass'}){ &makehtml; &quit; } |
---|
209 | } |
---|
210 | |
---|
211 | my @denyhost = split(/,/,$set{'deny_host'}); |
---|
212 | foreach my $value (@denyhost){ |
---|
213 | if ($in{'addr'} =~ /$value/ || $in{'host'} =~ /$value/){ &error(101);} |
---|
214 | } |
---|
215 | |
---|
216 | my @form = ($in{'postname'},$in{'comment'},$in{'orgname'},$in{'type'},$in{'dlkey'}); |
---|
217 | foreach my $value (@form) { |
---|
218 | if (length($value) > 128) { $value = substr($value,0,128).'...'; } |
---|
219 | # $value =~ s/&/&/g; |
---|
220 | $value =~ s/"/"/g; |
---|
221 | $value =~ s/</</g; |
---|
222 | $value =~ s/>/>/g; |
---|
223 | $value =~ s/\r//g; |
---|
224 | $value =~ s/\n//g; |
---|
225 | $value =~ s/\t//g; |
---|
226 | $value =~ s/\0//g; |
---|
227 | } |
---|
228 | ($in{'postname'},$in{'comment'},$in{'orgname'},$in{'type'},$in{'dlkey'}) = @form; |
---|
229 | } |
---|
230 | |
---|
231 | |
---|
232 | if($in{'mode'} eq 'delete'){ &delete(); &quit(); } |
---|
233 | if($in{'mode'} eq 'dl'){ &dlfile;} #DL |
---|
234 | if(!$in{'upfile'}){ &error(99); } |
---|
235 | |
---|
236 | {#C |
---|
237 | |
---|
238 | open(IN,$set{'log_file'})||&error(303); |
---|
239 | my @log = <IN>; |
---|
240 | close(IN); |
---|
241 | my ($no,$lastip,$lasttime) = split(/<>/,$log[0]); |
---|
242 | |
---|
243 | if($set{'interval'} && $in{'time'} <= ($lasttime + $set{'interval'}) && $in{'addr'} eq $lastip){ &error(203);} |
---|
244 | $in{'ext'} = extfind($in{'orgname'}); if(!$in{'ext'}){ &error(202); } |
---|
245 | |
---|
246 | my $orgname; |
---|
247 | if(split(/\//,$in{'orgname'}) > split(/\\/,$in{'orgname'})){ my @name = split(/\//,$in{'orgname'}); $orgname = $name[$#name]; } |
---|
248 | else{ my @name = split(/\\/,$in{'orgname'}); $orgname = $name[$#name];} |
---|
249 | |
---|
250 | my @salt = ('a'..'z', 'A'..'Z', '0'..'9', '.', '/'); |
---|
251 | srand; |
---|
252 | my $salt = $salt[int(rand(@salt))] . $salt[int(rand(@salt))]; |
---|
253 | $in{'pass'} = crypt($in{'pass'}, $salt); |
---|
254 | |
---|
255 | if($set{'binary_compare'}){ |
---|
256 | my @files = globfile("$set{'src_dir'}",".*"); |
---|
257 | my @dir = globdir("$set{'src_dir'}",".*"); |
---|
258 | foreach my $dir (@dir){ push(@files,globfile($dir."/",".*")); } |
---|
259 | foreach my $value (@files){ |
---|
260 | next if($value =~ /\.temporary$/); |
---|
261 | if(binarycmp($in{'tmpfile'},$value)){ unlink($in{'tmpfile'}); &error(205,$value);} |
---|
262 | } |
---|
263 | } |
---|
264 | |
---|
265 | if($set{'find_crypt'}){ |
---|
266 | open(FILE,$in{'tmpfile'}); binmode(FILE); seek(FILE,0,0); read(FILE,my $buff,4); my $crypt_flag = 0; |
---|
267 | if($buff =~ /^\x50\x4b\x03\x04$/){ seek(FILE,6,0); read(FILE,my $buff,1); $crypt_flag = 1 if(($buff & "\x01") eq "\x01"); } |
---|
268 | close(FILE); |
---|
269 | $in{'comment'} = '<font color="#FF0000">*</font>'.$in{'comment'} if($crypt_flag); |
---|
270 | } |
---|
271 | |
---|
272 | open(IN,$set{'log_file'})||&error(303); |
---|
273 | @log = <IN>; |
---|
274 | close(IN); |
---|
275 | ($no,$lastip,$lasttime) = split(/<>/,$log[0]); |
---|
276 | shift(@log); |
---|
277 | $no++; |
---|
278 | my $tmpno = sprintf("%04d",$no); |
---|
279 | |
---|
280 | my $dlsalt; |
---|
281 | my $filedir; |
---|
282 | my $allsize = (-s $in{'tmpfile'}); |
---|
283 | |
---|
284 | if($set{'dlkey'} && $in{'dlkey'}){ |
---|
285 | my @salt = ('a'..'z', 'A'..'Z', '0'..'9'); srand; |
---|
286 | for (my $c = 1; $c <= 20; ++$c) { $dlsalt .= $salt[int(rand(@salt))]; } |
---|
287 | $filedir = "$set{'src_dir'}$set{'file_pre'}${tmpno}.$in{'ext'}_$dlsalt/"; |
---|
288 | mkdir($filedir,$set{'per_dir'}); |
---|
289 | rename("$in{'tmpfile'}","$filedir$set{'file_pre'}$tmpno.$in{'ext'}"); |
---|
290 | open(OUT,">${filedir}index.html"); |
---|
291 | close(OUT); |
---|
292 | chmod($set{'per_upfile'},"${filedir}index.html"); |
---|
293 | $in{'comment'} = '<font color="#FF0000">[DLKey] </font>'.$in{'comment'}; |
---|
294 | }else{ |
---|
295 | undef $in{'dlkey'}; |
---|
296 | rename("$in{'tmpfile'}","$set{'src_dir'}$set{'file_pre'}$tmpno.$in{'ext'}"); |
---|
297 | } |
---|
298 | |
---|
299 | if (length($orgname) > 128) { $orgname = substr($orgname,0,128).'...'; } |
---|
300 | |
---|
301 | my @note; |
---|
302 | if($set{'post_flag'} && $set{'post_key'}){ |
---|
303 | push(@note,'PostKey:'.$in{'postkey'}); |
---|
304 | } |
---|
305 | if($ENV{'SERVER_SOFTWARE'} =~ /Apache|IIS/){ |
---|
306 | my $disptime; |
---|
307 | my $time = time() - $in{'time'}; |
---|
308 | my @str = ('Upload:','b'); |
---|
309 | my $disptime = $time.$str[1]; |
---|
310 | push(@note,$str[0].$disptime); |
---|
311 | } |
---|
312 | if($in{'dlkey'}){ |
---|
313 | my @salt = ('a'..'z', 'A'..'Z', '0'..'9', '.', '/'); srand; |
---|
314 | my $salt = $salt[int(rand(@salt))] . $salt[int(rand(@salt))]; |
---|
315 | my $crypt_dlkey = crypt($in{'dlkey'}, $salt); |
---|
316 | push(@note,"DLKey<!-- DLKey:".$crypt_dlkey." --><!-- DLpath:".$dlsalt." -->"); |
---|
317 | } |
---|
318 | my $note = join(',',@note); |
---|
319 | my $usersalt = substr($in{'user'},0,2); |
---|
320 | my $userid = crypt($in{'user'},$usersalt); |
---|
321 | $in{'time'} = time(); |
---|
322 | # $in{'date'} = conv_date(time()); |
---|
323 | my @new; |
---|
324 | $new[0] = "$no<>$in{'addr'}<>$in{'time'}<>1\n"; |
---|
325 | my $addlog = "$no<>$in{'postname'}<>$in{'ext'}<>$in{'date'}<>$in{'comment'}<>$in{'type'}<>$orgname<>$in{'addr'}<>$in{'host'}<>$in{'pass'},$userid<>$set{'file_pre'}<>$note<>1\n"; |
---|
326 | $new[1] = $addlog; |
---|
327 | |
---|
328 | # open(OUT,">>./alllog.cgi"); print OUT $addlog; close(OUT); |
---|
329 | |
---|
330 | my $i = 2; |
---|
331 | |
---|
332 | foreach my $value (@log){ |
---|
333 | my ($no,$postname,$ext,$date,$comment,$mime,$orgname,$addr,$host,$pass,$filepre,$note,$dummy) = split(/<>/,$value); |
---|
334 | if(!$dummy){ $filepre = $set{'file_pre'};} |
---|
335 | $no = sprintf("%04d",$no); |
---|
336 | |
---|
337 | my $filename; |
---|
338 | my $filedir; |
---|
339 | if($note =~ /DLpath:(.+)\s/){ |
---|
340 | my $dlpath = $1; |
---|
341 | $filename = "$set{'src_dir'}$filepre$no.${ext}_$dlpath/$filepre$no.$ext"; |
---|
342 | $filedir = "$set{'src_dir'}$filepre$no.${ext}_$dlpath/"; |
---|
343 | }else{ |
---|
344 | $filename = "$set{'src_dir'}$filepre$no.$ext"; |
---|
345 | } |
---|
346 | $allsize += (-s $filename); |
---|
347 | |
---|
348 | if($i <= $set{'max_log'} && !($set{'max_all_flag'} && $set{'max_all_size'}*1024 < $allsize)){ |
---|
349 | if((-e $filename)||!$set{'zero_clear'}){ push(@new,$value); $i++; } |
---|
350 | }else{ |
---|
351 | if(unlink($filename)){ |
---|
352 | unlink("$set{'src_dir'}$filepre$no.$ext.html"); if($filedir){ foreach(globfile($filedir,".*")){ unlink; } } rmdir($filedir); |
---|
353 | }elsif(unlink($filename)){ |
---|
354 | unlink("$set{'src_dir'}$filepre$no.$ext.html"); if($filedir){ foreach(globfile($filedir,".*")){ unlink; } } rmdir($filedir); |
---|
355 | }elsif(-e $filename){ |
---|
356 | push(@new,$value); |
---|
357 | }else{ |
---|
358 | unlink("$set{'src_dir'}$filepre$no.$ext.html"); if($filedir){ foreach(globfile($filedir,".*")){ unlink; } } rmdir($filedir); |
---|
359 | } |
---|
360 | } |
---|
361 | } |
---|
362 | logwrite(@new); |
---|
363 | if($in{'dlkey'} && ( $set{'dummy_html'} == 2 || $set{'dummy_html'} == 3)){ |
---|
364 | &makedummyhtml("$set{'file_pre'}$tmpno.$in{'ext'}",$in{'comment'},"$set{'file_pre'}$tmpno.$in{'ext'}",$dlsalt,$in{'date'},$in{'type'},$orgname,$no); |
---|
365 | }elsif(!$in{'dlkey'} && ($set{'dummy_html'} == 1 || $set{'dummy_html'} == 3)){ |
---|
366 | &makedummyhtml("$set{'file_pre'}$tmpno.$in{'ext'}"); |
---|
367 | } |
---|
368 | &makehtml(); &quit(); |
---|
369 | } |
---|
370 | |
---|
371 | sub makehtml{ |
---|
372 | |
---|
373 | my ($buff,$init,$postval,$dlkey); |
---|
374 | my $page = 0; my $i = 1; |
---|
375 | |
---|
376 | open(IN,$set{'log_file'})||&error(303); |
---|
377 | my $log = my @log = <IN>; |
---|
378 | close(IN); |
---|
379 | |
---|
380 | if($log == 1){ $log++; $init++;} |
---|
381 | my $lastpage = int(($log - 2)/$set{'pagelog'}) + 1; |
---|
382 | $postval = ' obj.postkey.value = unescape(p[2]);' if($set{'post_flag'}); |
---|
383 | my $header =<<"EOM"; |
---|
384 | $set{'html_head'}<META http-equiv="Content-Script-Type" content="text/javascript"> |
---|
385 | <script type="text/javascript"> |
---|
386 | <!-- |
---|
387 | function getCookie(obj,cookiename){ |
---|
388 | var i,str; c = new Array(); p = new Array("","",""); str = document.cookie;c = str.split(";"); |
---|
389 | for (i = 0; i < c.length; i++) { if (c[i].indexOf(cookiename+"=") >= 0) { p = (c[i].substr(c[i].indexOf("=")+1)).split("<>"); break; }} |
---|
390 | if(cookiename == "SN_UPLOAD"){ obj.postname.value = unescape(p[0]); obj.pass.value = unescape(p[1]);$postval } |
---|
391 | else if(cookiename == "SN_DEL"){ obj.delpass.value = unescape(p[1]);} |
---|
392 | return true; |
---|
393 | } |
---|
394 | function delnoin(no){ |
---|
395 | document.Del.delno.value = no; |
---|
396 | document.Del.del.focus(); |
---|
397 | } |
---|
398 | //--> |
---|
399 | </script> |
---|
400 | $set{'html_css'}</HEAD> |
---|
401 | <body bgcolor="#ffffff" text="#000000" LINK="#6060FF" VLINK="#6060FF" ALINK="#6060FF" onload="getCookie(document.Form,'SN_UPLOAD');getCookie(document.Del,'SN_DEL');"> |
---|
402 | <table summary="title" width="100%"><tr><td bgcolor="#caccff"><strong><font size="4" color="#3366cc">Uploader</font></strong></td></tr></table> |
---|
403 | <p> |
---|
404 | Now.. Testing.. |
---|
405 | </p> |
---|
406 | EOM |
---|
407 | my $maxsize = 'Max '.dispsize($set{'max_size'}*1024); |
---|
408 | my ($minsize,$total); |
---|
409 | if($set{'min_flag'}){ $minsize = 'Min '.dispsize($set{'min_size'}*1024).' - '; } |
---|
410 | if($set{'max_all_flag'}){ $total .= ' Total '.dispsize($set{'max_all_size'}*1024);} |
---|
411 | $header .= qq|<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="$set{'base_cgi'}" name="Form">NAME (ȪÂ)<br><INPUT TYPE=text SIZE="20" NAME="postname"><br> FILE $minsize$maxsize (*$set{'max_log'}Files$total)<br>|; |
---|
412 | $header .='<INPUT TYPE=file SIZE="40" NAME="upfile">'; |
---|
413 | $header .= ' DLKey: <INPUT TYPE=text SIZE="8" NAME="dlkey" maxlength="8">' if($set{'dlkey'}); |
---|
414 | $header .= ' |
---|
415 | DELKey: <INPUT TYPE=password SIZE="10" NAME="pass" maxlength="8"><br> |
---|
416 | COMMENT<br> |
---|
417 | <INPUT TYPE=text SIZE="45" NAME="comment"> |
---|
418 | <INPUT TYPE=hidden NAME="jcode" VALUE="¿"> |
---|
419 | <INPUT TYPE=submit VALUE="Upload"><INPUT TYPE=reset VALUE="Cancel"><br> |
---|
420 | '; |
---|
421 | if($set{'post_flag'}){ $header .= 'PostKey<br><INPUT TYPE=password SIZE="10" NAME="postkey" maxlength="10">'; } |
---|
422 | $header .= '</FORM>'; |
---|
423 | |
---|
424 | my $allsize = 0; |
---|
425 | my @files = globfile("$set{'src_dir'}",".*"); |
---|
426 | my @dir = globdir("$set{'src_dir'}",".*"); |
---|
427 | foreach my $dir (@dir){ push(@files,globfile($dir."/",".*")); } |
---|
428 | foreach my $value (@files){ $allsize += (-s "$value"); } |
---|
429 | |
---|
430 | $allsize = dispsize($allsize); |
---|
431 | |
---|
432 | my $footer = "</table><HR size=1>Used ${allsize}\n<br>"; |
---|
433 | if($set{'up_all'} && !$set{'ext_org'}){ $footer .= $set{'up_ext'}.' +'; } |
---|
434 | elsif(!$set{'up_all'}){ $footer .= $set{'up_ext'}; } |
---|
435 | $footer .= "\n<table summary=\"footer\" width=\"100%\"><tr><td><div align=left><FORM METHOD=POST ACTION=\"$set{'base_cgi'}\" name=\"Del\"><span style='font-size:9pt'><input type=hidden name=mode value=delete>No.<input type=text size=4 name=delno> key<input type=password size=4 name=delpass> <input type=submit value=\"del\" name=del></span></form></div>\n"; |
---|
436 | $footer .= "</td><td><div align=right><!-- $set{'ver'} --><a href=\"http://sugachan.dip.jp/download/\" target=\"_blank\"><small>Sn Uploader</small></a></div></td></tr></table>\n</body>\n</html>"; |
---|
437 | |
---|
438 | my $info_title = "<table summary=\"upinfo\" width=\"100%\">\n<tr><td></td><td>NAME</td><td>FILE</td>"; |
---|
439 | if($set{'disp_comment'}){ $info_title .= "<td>COMMENT</td>"; } if($set{'disp_size'}){ $info_title .= "<td>SIZE</td>"; } if($set{'disp_date'}){ $info_title .= "<td>DATE</td>"; } |
---|
440 | if($set{'disp_mime'}){ $info_title .= "<td>MIME</td>"; } if($set{'disp_orgname'}){ $info_title .= "<td>ORIG</td>"; } |
---|
441 | $info_title .= "</tr>\n"; |
---|
442 | |
---|
443 | my $home_url_link; |
---|
444 | if($set{'home_url'}){ $home_url_link = qq|<a href="$set{'home_url'}">[HOME]</a> |;} |
---|
445 | if($set{'html_all'}){ |
---|
446 | my $buff; my $no = 1; my $time = time; my $subheader; |
---|
447 | foreach my $value (@log){ |
---|
448 | my ($no,$postname,$ext,$date,$comment,$mime,$orgname,$addr,$host,$pass,$dummy) = split(/<>/,$value); |
---|
449 | if(!$dummy){ next; } |
---|
450 | $buff .= makeitem($value); |
---|
451 | } |
---|
452 | $subheader .= "[ALL] "; |
---|
453 | while($no <= $lastpage){ |
---|
454 | if($no == $page) { $subheader .= "\[$no\] ";} |
---|
455 | else{ if($no == 1){ $subheader .= "<a href=\"$set{'http_html_path'}$set{'base_html'}?$time\">\[$no\]</a> "} |
---|
456 | else{$subheader .= "<a href=\"$set{'http_html_path'}$no.html?$time\">\[$no\]</a> ";} } |
---|
457 | $no++; |
---|
458 | } |
---|
459 | $subheader .= $info_title; |
---|
460 | open(OUT,">$set{'html_dir'}all.html")||&error(306,"$set{'html_dir'}all.html"); |
---|
461 | print OUT $header."<hr size=1>".$home_url_link.$subheader."<hr size=1>".$buff.$footer; |
---|
462 | close(OUT); |
---|
463 | chmod($set{'per_upfile'},"$set{'html_dir'}all.html"); |
---|
464 | }else{ unlink("$set{'html_dir'}all.html"); } |
---|
465 | |
---|
466 | while($log > $i){ |
---|
467 | $buff .= makeitem($log[$i]) unless($init); |
---|
468 | if(($i % $set{'pagelog'}) == 0||$i == $log -1){ |
---|
469 | $page++; my $subheader; my $no = 1; my $time = time; |
---|
470 | if($set{'html_all'}){ $subheader .= "<a href=\"./all.html?$time\">[ALL]</a> "; } |
---|
471 | while($no <= $lastpage){ |
---|
472 | if($no == $page) { $subheader .= "\[$no\] ";} |
---|
473 | else{ if($no == 1){ $subheader .= "<a href=\"$set{'http_html_path'}$set{'base_html'}?$time\">\[$no\]</a> "} |
---|
474 | else{$subheader .= "<a href=\"$set{'http_html_path'}$no.html?$time\">\[$no\]</a> ";} |
---|
475 | } |
---|
476 | $no++; |
---|
477 | } |
---|
478 | $subheader .= $info_title; |
---|
479 | my $loghtml; |
---|
480 | if($page == 1){ $loghtml = "$set{'html_dir'}$set{'base_html'}"; } |
---|
481 | else{ $loghtml = "$set{'html_dir'}$page.html"; } |
---|
482 | |
---|
483 | open(OUT,">$loghtml") || &error(306,"$loghtml"); |
---|
484 | print OUT $header."<hr size=1>".$home_url_link.$subheader."<hr size=1>".$buff.$footer; |
---|
485 | close(OUT); |
---|
486 | chmod($set{'per_upfile'},$loghtml); |
---|
487 | undef $buff; |
---|
488 | } |
---|
489 | $i++; |
---|
490 | } |
---|
491 | |
---|
492 | while($page < 1000){ |
---|
493 | $page ++; |
---|
494 | if(-e "$set{'html_dir'}$page.html"){ unlink("$set{'html_dir'}$page.html"); }else{ last; } |
---|
495 | } |
---|
496 | } |
---|
497 | |
---|
498 | sub delete{ |
---|
499 | my $mode = $_[0]; |
---|
500 | my @delno = split(/,/,$_[1]); |
---|
501 | my $delno; my $flag = 0; my $tmpaddr; |
---|
502 | my $delnote; |
---|
503 | |
---|
504 | if($in{'delno'} =~ /(\d+)/){ $delno = $1; } |
---|
505 | if($mode ne 'admin' && !$in{'delno'}){ return; } |
---|
506 | elsif($mode ne 'admin' && !$delno){ &error(401,$in{'delno'}); } |
---|
507 | |
---|
508 | open(IN,$set{'log_file'})|| &error(303); |
---|
509 | my @log = <IN>; |
---|
510 | close(IN); |
---|
511 | |
---|
512 | if($in{'addr'} =~ /(\d+).(\d+).(\d+).(\d+)/){ $tmpaddr = "$1.$2.$3."; } |
---|
513 | my $findflag = 0; |
---|
514 | foreach my $value (@log){ |
---|
515 | my ($no,$postname,$ext,$date,$comment,$mime,$orgname,$addr,$host,$pass,$filepre,$note,$dummy) = split(/<>/,$value); |
---|
516 | $delnote = $note; |
---|
517 | my $delflag = 0; |
---|
518 | if(!$addr){ next; } |
---|
519 | if($mode eq 'admin'){ |
---|
520 | foreach my $delno (@delno){ if($no == $delno){ $delflag = 1; last; } } |
---|
521 | }elsif($no == $delno){ |
---|
522 | $findflag = 1; |
---|
523 | unless ($addr =~ /^$tmpaddr/){ |
---|
524 | my ($pass,$id) = split(/,/,$pass); |
---|
525 | my $delpass = $in{'delpass'} || $in{'addr'}.time(); |
---|
526 | my $salt = substr($pass, 0, 2); $delpass = crypt($delpass,$salt); |
---|
527 | my $usersalt = substr($in{'user'},0,2); my $userid = crypt($in{'user'},$usersalt); |
---|
528 | if ($in{'delpass'} ne $set{'admin_pass'} && $delpass ne $pass && $userid ne $id){ |
---|
529 | if($mode ne 'admin'){ if(!$dummy){ $filepre = $set{'file_pre'};} $no = sprintf("%04d",$no); &error(404,"$filepre$no.$ext");} |
---|
530 | } |
---|
531 | } |
---|
532 | $delflag = 1; |
---|
533 | } |
---|
534 | if($delflag){ |
---|
535 | # open(OUT,">>./del.cgi"); print OUT $value; close(OUT); |
---|
536 | $flag = 1; |
---|
537 | if(!$dummy){ $filepre = $set{'file_pre'};} |
---|
538 | $no = sprintf("%04d",$no); |
---|
539 | my $filename; |
---|
540 | my ($dlpath,$filedir); |
---|
541 | if($delnote =~ /DLpath:(.+)\s/){ |
---|
542 | $dlpath = $1; |
---|
543 | $filename = "$set{'src_dir'}$filepre$no.${ext}_$dlpath/$filepre$no.$ext"; |
---|
544 | $filedir = "$set{'src_dir'}$filepre$no.${ext}_$dlpath/"; |
---|
545 | }else{ |
---|
546 | $filename = "$set{'src_dir'}$filepre$no.$ext"; |
---|
547 | } |
---|
548 | |
---|
549 | if(unlink($filename)){ |
---|
550 | unlink("$set{'src_dir'}$filepre$no.$ext.html"); if($filedir){ foreach(globfile($filedir,".*")){ unlink; } rmdir($filedir);} undef $value; |
---|
551 | }elsif(unlink($filename)){ |
---|
552 | unlink("$set{'src_dir'}$filepre$no.$ext.html"); if($filedir){ foreach(globfile($filedir,".*")){ unlink; } rmdir($filedir);} undef $value; |
---|
553 | }elsif(!(-e $filename)){ |
---|
554 | unlink("$set{'src_dir'}$filepre$no.$ext.html"); if($filedir){ foreach(globfile($filedir,".*")){ unlink; } rmdir($filedir);} undef $value; |
---|
555 | }else{ |
---|
556 | if($mode ne 'admin'){ &error(403,"$filepre$no.$ext");} |
---|
557 | } |
---|
558 | } |
---|
559 | } |
---|
560 | if($mode ne 'admin' && !$findflag){ &error(402,$delno); } |
---|
561 | if($flag){ |
---|
562 | logwrite(@log); |
---|
563 | &makehtml(); |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|
567 | |
---|
568 | sub quit{ |
---|
569 | my ($cookiename,$buff); |
---|
570 | my $flag = 0; |
---|
571 | my @tmpfiles = globfile("$set{'src_dir'}","\.temporary"); |
---|
572 | foreach my $value (@tmpfiles){ if((stat($value))[10] < time - 60*60){ unlink("$value"); $flag++; } } |
---|
573 | &makehtml() if($flag); |
---|
574 | $buff =<<"EOM"; |
---|
575 | $set{'html_head'}<META HTTP-EQUIV="Refresh" CONTENT="1;URL=$set{'http_html_path'}$set{'base_html'}"> |
---|
576 | EOM |
---|
577 | if($in{'jcode'} || $in{'mode'} eq 'delete'){ |
---|
578 | $buff .=<<"EOM"; |
---|
579 | <META HTTP-EQUIV="Set-Cookie" content="SN_USER=$in{'user'}<>1; path=/; expires=Tue, 31-Dec-2030 23:59:59 GMT"> |
---|
580 | <META HTTP-EQUIV="CONTENT-SCRIPT-TYPE" CONTENT="text/javascript"> |
---|
581 | <script type="text/javascript"> |
---|
582 | <!-- |
---|
583 | setCookie(); |
---|
584 | function setCookie() { |
---|
585 | var key0,key1,key2; |
---|
586 | var tmp = "path=/; expires=Tue, 31-Dec-2030 23:59:59; "; |
---|
587 | EOM |
---|
588 | if($in{'jcode'}){ |
---|
589 | my %ck; foreach(split(/;/,$ENV{'HTTP_COOKIE'})){ my($key,$val) = split(/=/); $key =~ s/\s//g; $ck{$key} = $val;} |
---|
590 | my @ck = split(/<>/,$ck{'SN_DEL'}); |
---|
591 | if(!$ck[0] && $in{'org_pass'}){ $buff .= qq|\tdocument.cookie = "SN_DEL="+escape('$in{'org_pass'}')+"<>;"+ tmp;\n|;} |
---|
592 | $cookiename = 'SN_UPLOAD'; $buff .= "\tkey0 = escape('$in{'postname'}'); key1 = escape('$in{'org_pass'}'); key2 = escape('$in{'postkey'}');\n";} |
---|
593 | else{ $cookiename = 'SN_DEL'; $buff .= "\tkey0 = ''; key1 = escape('$in{'delpass'}'); key2 = '';\n"; } |
---|
594 | $buff .= qq|\tdocument.cookie = "$cookiename="+key0+"<>"+key1+"<>"+key2+"; "+ tmp;\n}\n//-->\n</script>\n|; |
---|
595 | } |
---|
596 | $buff .=<<"EOM"; |
---|
597 | <body> |
---|
598 | <br><br><div align=center><font size="+1"><br><br> |
---|
599 | <a href="$set{'http_html_path'}$set{'base_html'}?$in{'time'}">click here!</a></font><br> |
---|
600 | </div> |
---|
601 | </body></html> |
---|
602 | EOM |
---|
603 | print "Content-type: text/html\n\n"; |
---|
604 | print $buff; |
---|
605 | exit; |
---|
606 | } |
---|
607 | |
---|
608 | sub admin_mode{ |
---|
609 | &errorclear() if($in{'mode'} eq 'errorclear'); |
---|
610 | &delete('admin',$in{'admin_delno'}) if($in{'mode'} eq 'delete'); |
---|
611 | |
---|
612 | open(IN,$set{'log_file'})||error(303); |
---|
613 | my @log = <IN>; |
---|
614 | close(IN); |
---|
615 | |
---|
616 | my ($header,$buff,$footer,$value); |
---|
617 | $buff =<<"EOM"; |
---|
618 | $set{'html_head'}$set{'html_css'}</HEAD> |
---|
619 | <body bgcolor="#ffffff" text="#000000" LINK="#6060FF" VLINK="#6060FF" ALINK="#6060FF"> |
---|
620 | EOM |
---|
621 | |
---|
622 | $buff .= leaddisp(0,1,1).'<a name="up"></a><table summary="title" width="100%"><tr><td bgcolor="#caccff"><strong><font size="4" color="#3366cc">Upload Info</font></strong></td></tr></table>'; |
---|
623 | $buff .= qq|<table summary="check"><tr><td><form action="$set{'base_cgi'}" method="POST"><input type=hidden name="checkmode" value="allcheck"><input type=hidden name=delno value="$in{'delno'}"><input type=hidden name=delpass value="$in{'delpass'}"><input type=submit value="·×Ä`FbN"></form></td><td><form action="$set{'base_cgi'}" method="POST"><input type=hidden name="checkmode" value="nocheck"><input type=hidden name=delno value="$in{'delno'}"><input type=hidden name=delpass value="$in{'delpass'}"><input type=submit value="·×ÄO·"></form></td><td><form action="$set{'base_cgi'}" method="POST"><input type=hidden name=delpass value="$set{'admin_pass'}"><input type=submit value="HTMLðXV·é/OAEg"></form></td></tr></table>\n<form action="$set{'base_cgi'}" method="POST"><input type=hidden name="mode" value="delete"><input type=hidden name=delno value="$in{'delno'}"><input type=hidden name=delpass value="$in{'delpass'}"><input type=submit value="`FbNµ½àÌðí"><br>\n|."<table summary=\"upinfo\" width=\"100%\">\n<tr><td>DEL</td><td>NAME</td><td>FILE</td><td>COMMENT</td><td>SIZE</td><td>ADDR</td><td>HOST</td><td>DATE</td><td>NOTE</td><td>MIME</td><td>ORIG</td></tr>\n"; |
---|
624 | shift(@log); |
---|
625 | foreach (@log){ $buff .= makeitem($_,'admin'); } |
---|
626 | $buff .= '</table></form><br><br>'; |
---|
627 | |
---|
628 | if($set{'error_level'}){ |
---|
629 | $buff .= leaddisp(-1,0,1).'<a name="error"></a><table summary="errortitle" width="100%"><tr><td bgcolor="#caccff"><strong><font size="4" color="#3366cc">Error Info</font></strong></td></tr></table>'; |
---|
630 | $buff .= qq|<form action="$set{'base_cgi'}" method="POST"><input type=hidden name=mode value="errorclear"><input type=hidden name=delno value="$in{'delno'}"><input type=hidden name=delpass value="$in{'delpass'}"><input type=submit value="G[ONA"></form>|; |
---|
631 | $buff .= "<table summary=\"errorinfo\" width=\"100%\">\n<tr><td>DATE</td><td>ADDR</td><td>HOST</td><td>NOTE</td></tr>\n"; |
---|
632 | if(open(IN,$set{'error_log'})){ @log = reverse(<IN>); close(IN); foreach (@log){ my ($date,$no,$note,$addr,$host) = split(/<>/); $buff .= "<tr><td>$date</td><td>$addr</td><td>$host</td><td>$note</td></tr>\n"; }} |
---|
633 | $buff .= "</table><br><br>\n"; |
---|
634 | } |
---|
635 | |
---|
636 | $buff .= leaddisp(-1,-1,0); |
---|
637 | $buff .= '<a name="set"></a><table summary="settitle" width="100%"><tr><td bgcolor="#caccff"><strong><font size="4" color="#3366cc">Setting Info</font></strong></td></tr></table>'."\n<table summary=\"setting\">\n"; |
---|
638 | $buff .= tablestr('XNvgVer',$set{'ver'}); |
---|
639 | $buff .= tablestr('COt@C',$set{'log_file'}); |
---|
640 | if($set{'error_level'}){ |
---|
641 | $buff .= tablestr('G[Ot@C',$set{'error_log'}); |
---|
642 | if($set{'error_size'}){ $buff .= tablestr('G[OÅåeÊ',dispsize($set{'error_size'}*1024).' '.($set{'error_size'}*1024).'Bytes'); } |
---|
643 | else{ $buff .= tablestr('G[OÅåeʧÀ','³'); } |
---|
644 | }else{ $buff .= tablestr('G[OL^','³'); } |
---|
645 | $buff .= tablestr('Û',$set{'max_log'}); |
---|
646 | $buff .= tablestr('ÅåeeÊ',dispsize($set{'max_size'}*1024).' '.($set{'max_size'}*1024).'Bytes'); |
---|
647 | |
---|
648 | if($set{'min_flag'}){ $buff .= tablestr('Ŭ§ÀeÊ',dispsize($set{'min_size'}*1024).' '.($set{'min_size'}*1024).'Bytes'); } |
---|
649 | else{ $buff .= tablestr('Ŭ§ÀeÊ',"³"); } |
---|
650 | if($set{'max_all_flag'}){ $buff .= tablestr('eʧÀ',dispsize($set{'max_all_size'}*1024).' '.($set{'max_all_size'}*1024).'Bytes'); } |
---|
651 | else{ $buff .= tablestr('eʧÀ',"³"); } |
---|
652 | |
---|
653 | $buff .= tablestr("t@CÚª«",$set{'file_pre'}); |
---|
654 | $buff .= tablestr("HTMLÛ¶fBNg",$set{'html_dir'}); |
---|
655 | $buff .= tablestr("t@CÛ¶fBNg",$set{'src_dir'}); |
---|
656 | if($set{'http_html_path'} && $set{'html_dir'} ne $set{'http_html_path'}){ $buff .= "<tr><td>HTTP_HTML_PATH</td><td>$set{'http_html_path'}</td></tr>\n";} |
---|
657 | if($set{'http_src_path'} && $set{'src_dir'} ne $set{'http_src_path'}){ $buff .= "<tr><td>HTTP_SRC_PATH</td><td>$set{'http_src_path'}</td></tr>\n";} |
---|
658 | $buff .= tablestr('1y[WÉ\¦·ét@C',$set{'pagelog'}); |
---|
659 | if($set{'interval'} > 0){ $value = $set{'interval'}.'b'; }else{ $value = '³'; } |
---|
660 | $buff .= tablestr('¯êIPeÔub§À',$value); |
---|
661 | if($set{'up_ext'}){ $set{'up_ext'} =~ s/,/ /g; $buff .= tablestr('eÂ\î{g£q',$set{'up_ext'}); } |
---|
662 | if($set{'deny_ext'}){ $set{'deny_ext'} =~ s/,/ /g; $buff .= tablestr('eÖ~g£q',$set{'deny_ext'}); } |
---|
663 | if($set{'change_ext'}){ $set{'change_ext'} =~ s/,/ /g; $set{'change_ext'} =~ s/>/>/g; $buff .= tablestr('g£qÏ·',$set{'change_ext'}); } |
---|
664 | |
---|
665 | if($set{'up_all'}){ $buff .= tablestr('wèOg£qAbv[hÂ','L'); if($set{'ext_org'}){ $buff .= tablestr('wèOt@Cg£q','IWi'); }else{ $buff .= tablestr('wèOt@Cg£q','bin'); }} |
---|
666 | else{$buff .= tablestr('wèOg£qAbv[hÂ','³');} |
---|
667 | |
---|
668 | if($set{'find_crypt'}){ $value = 'L'; }else{ $value = '³';} |
---|
669 | $buff .= tablestr('ûA[JCuo(ZIP)',$value); |
---|
670 | if($set{'binary_compare'}){ $value = 'L'; }else{ $value = '³';} |
---|
671 | $buff .= tablestr('oCiär',$value); |
---|
672 | if($set{'post_flag'}){ $value = 'L'; }else{ $value = '³';} |
---|
673 | $buff .= tablestr('PostKeye§À',$value); |
---|
674 | if($set{'dlkey'}){ if($set{'dlkey'} == 2){$value = 'K{'}else{$value = 'CÓ';}}else{ $value = '³';} |
---|
675 | $buff .= tablestr('DLkey',$value); |
---|
676 | if($set{'dummy_html'}){ if($set{'dummy_html'} == 3){$value = 'ALL'}elsif($set{'dummy_html'} == 2){$value = 'DLKeyÌÝ';}else{$value = 'Êít@CÌÝ';}}else{ $value = '³';} |
---|
677 | $buff .= tablestr('ÂÊHTMLLbV
',$value); |
---|
678 | if($set{'disp_error'}){ $value = 'L'; }else{ $value = '³';} |
---|
679 | $buff .= tablestr('[UG[\¦',$value); |
---|
680 | if($set{'zero_clear'}){ $value = 'L'; }else{ $value = '³';} |
---|
681 | $buff .= tablestr('íÏt@CXg©®Á',$value); |
---|
682 | if($set{'home_url'}){ $buff .= "<tr><td>HOMEURL</td><td>$set{'home_url'}</td></tr>\n";} |
---|
683 | |
---|
684 | $buff .= '</table></body></html>'; |
---|
685 | |
---|
686 | print "Content-type: text/html\n\n"; |
---|
687 | print $buff; |
---|
688 | exit; |
---|
689 | } |
---|
690 | |
---|
691 | sub extfind{ |
---|
692 | my $orgname = @_[0]; |
---|
693 | my @filename = split(/\./,$orgname); |
---|
694 | my $ext = $filename[$#filename]; |
---|
695 | $ext =~ tr/[A-Z]/[a-z]/; |
---|
696 | foreach my $value (split(/,/,$set{'change_ext'})){ my ($src,$dst) = split(/->/,$value); if($ext eq $src){ $ext = $dst; last; }} |
---|
697 | foreach my $value (split(/,/,$set{'deny_ext'})){ if($ext eq $value){ &error(206,$ext); }} |
---|
698 | foreach my $value (split(/,/,$set{'up_ext'})){ if ($ext eq $value) { return $value; } } |
---|
699 | if(length($ext) >= 5 || length($ext) == 0){ $ext = 'bin'; } |
---|
700 | unless ($ext =~ /^[A-Za-z0-9]+$/){ $ext = 'bin'; } |
---|
701 | if($set{'up_all'} && $set{'ext_org'}){ return $ext;} |
---|
702 | elsif($set{'up_all'}){ return 'bin'; } |
---|
703 | return 0; |
---|
704 | } |
---|
705 | |
---|
706 | |
---|
707 | sub conv_date{ |
---|
708 | my @date = gmtime($_[0] + 9*60*60); |
---|
709 | $date[5] -= 100; $date[4]++; |
---|
710 | if ($date[5] < 10) { $date[5] = "0$date[5]" ; } if ($date[4] < 10) { $date[4] = "0$date[4]" ; } |
---|
711 | if ($date[3] < 10) { $date[3] = "0$date[3]" ; } if ($date[2] < 10) { $date[2] = "0$date[2]" ; } |
---|
712 | if ($date[1] < 10) { $date[1] = "0$date[1]" ; } if ($date[0] < 10) { $date[0] = "0$date[0]" ; } |
---|
713 | my @w = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); |
---|
714 | return ("$date[5]/$date[4]/$date[3]($w[$date[6]]),$date[2]:$date[1]:$date[0]"); |
---|
715 | } |
---|
716 | |
---|
717 | sub dispsize{ |
---|
718 | my $size = $_[0]; |
---|
719 | if($size >= 1024*1024*1024*100){ $size = int($size/1024/1024/1024).'GB';} |
---|
720 | elsif($size >= 1024*1024*1024*10){ $size = sprintf("%.1fGB",$size/1024/1024/1024);} |
---|
721 | elsif($size > 1024*1024*1024){ $size = sprintf("%.2fGB",$size/1024/1024/1024);} |
---|
722 | elsif($size >= 1024*1024*100){ $size = int($size/1024/1024).'MB'; } |
---|
723 | elsif($size > 1024*1024){ $size = sprintf("%.1fMB",$size/1024/1024); } |
---|
724 | elsif($size > 1024){ $size = int($size/1024).'KB'; } |
---|
725 | else{ $size = int($size).'B';} |
---|
726 | return $size; |
---|
727 | } |
---|
728 | |
---|
729 | sub makeitem{ |
---|
730 | my ($src,$mode) = @_; my ($buff,$check,$target); |
---|
731 | my ($no,$postname,$ext,$date,$comment,$mime,$orgname,$addr,$host,$pass,$filepre,$note,$dummy) = split(/<>/,$src); |
---|
732 | if(!$dummy){ $filepre = $set{'file_pre'}; } |
---|
733 | my $orgno = $no; |
---|
734 | $no = sprintf("%04d",$no); |
---|
735 | my $size = 0; |
---|
736 | my $dlpath = 0; |
---|
737 | |
---|
738 | if($note =~ /DLpath:(.+)\s/){ |
---|
739 | $dlpath = $1; |
---|
740 | $size = dispsize(-s "$set{'src_dir'}$filepre$no.${ext}_$dlpath/$filepre$no.$ext"); |
---|
741 | }else{ |
---|
742 | $size = dispsize(-s "$set{'src_dir'}$filepre$no.$ext"); |
---|
743 | } |
---|
744 | |
---|
745 | my $path = $set{'http_src_path'} || $set{'src_dir'}; |
---|
746 | if($set{'link_target'}){ $target = qq| target="$set{'link_target'}"|; } |
---|
747 | if($mode eq 'admin'){ |
---|
748 | if($dlpath){ $path .= "$filepre$no.${ext}_$dlpath/"; } |
---|
749 | if($addr eq $host){ undef $host; } |
---|
750 | if($in{'checkmode'} eq 'allcheck'){$check = ' checked';} |
---|
751 | $buff = "<tr><td><INPUT TYPE=checkbox NAME=\"admin_delno\" VALUE=\"$no\"$check></td><td>$postname</td><td><a href=\"$path$filepre$no.$ext\"$target>$filepre$no.$ext</a></td><td>$comment</td><td>$size</td><td>$addr</td><td>$host</td><td>$date</td><td>$note</td><td>$mime</td><td>$orgname</td></tr>\n"; |
---|
752 | }else{ |
---|
753 | my($d_com,$d_date,$d_size,$d_mime,$d_org); |
---|
754 | if($set{'disp_comment'}){ $d_com = "<td>$comment</td>"; } if($set{'disp_size'}){ $d_size = "<td>$size</td>"; } if($set{'disp_date'}){ $d_date= "<td>$date</td>"; } |
---|
755 | if($set{'disp_mime'}){ $d_mime = "<td>$mime</td>"; } if($set{'disp_orgname'}){ $d_org = "<td>$orgname</td>"; } |
---|
756 | if(-e "$set{'src_dir'}$filepre$no.$ext.html"){$buff = "<tr><td><SCRIPT type=\"text/javascript\" Language=\"JavaScript\"><!--\ndocument.write(\"<a href=\\\"javascript:delnoin($orgno)\\\">$set{'char_delname'}<\\/a>\");\n// --></SCRIPT></td><td>$postname</td><td><a href=\"$path$filepre$no.$ext.html\"$target>$filepre$no.$ext</a></td>$d_com$d_size$d_date$d_mime$d_org</tr>\n";} |
---|
757 | elsif($dlpath){$buff = "<tr><td><SCRIPT type=\"text/javascript\" Language=\"JavaScript\"><!--\ndocument.write(\"<a href=\\\"javascript:delnoin($orgno)\\\">$set{'char_delname'}<\\/a>\");\n// --></SCRIPT></td><td>$postname</td><td><a href=\"$set{'base_cgi'}?mode=dl&file=$orgno\">$filepre$no.$ext</a></td>$d_com$d_size$d_date$d_mime$d_org</tr>\n";} |
---|
758 | else{ $buff = "<tr><td><SCRIPT type=\"text/javascript\" Language=\"JavaScript\"><!--\ndocument.write(\"<a href=\\\"javascript:delnoin($orgno)\\\">$set{'char_delname'}<\\/a>\");\n// --></SCRIPT></td><td>$postname</td><td><a href=\"$path$filepre$no.$ext\"$target>$filepre$no.$ext</a></td>$d_com$d_size$d_date$d_mime$d_org</tr>\n";} |
---|
759 | } |
---|
760 | return $buff; |
---|
761 | } |
---|
762 | |
---|
763 | sub makedummyhtml{ |
---|
764 | my ($filename,$com,$file,$orgdlpath,$date,$mime,$orgname,$no) = @_; |
---|
765 | my $buff; |
---|
766 | |
---|
767 | if(!$no){ |
---|
768 | $buff = "<html><head><title>$filename</title></head><body>"; |
---|
769 | $buff .= qq|Download <a href="./$filename">$filename</a>|; |
---|
770 | $buff .= '</body></html>'; |
---|
771 | }else{ |
---|
772 | $buff = cryptfiledl($com,$file,$orgdlpath,$date,$mime,$orgname,$no); |
---|
773 | } |
---|
774 | |
---|
775 | open(OUT,">$set{'src_dir'}$filename.html")||&error(307,"$set{'src_dir'}$filename.html"); |
---|
776 | print OUT $buff; |
---|
777 | close(OUT); |
---|
778 | chmod($set{'per_upfile'},"$set{'src_dir'}$filename.html"); |
---|
779 | return 1; |
---|
780 | } |
---|
781 | |
---|
782 | |
---|
783 | sub logwrite{ |
---|
784 | my @log = @_; |
---|
785 | open(OUT,"+>$set{'log_file'}")||&error(304); |
---|
786 | eval{ flock(OUT, 2);}; |
---|
787 | eval{ truncate(OUT, 0);}; |
---|
788 | seek(OUT, 0, 0); |
---|
789 | print OUT @log; |
---|
790 | eval{ flock(OUT, 8);}; |
---|
791 | close(OUT); |
---|
792 | chmod($set{'per_upfile'},$set{'log_file'}); |
---|
793 | return 1; |
---|
794 | } |
---|
795 | |
---|
796 | sub binarycmp{ |
---|
797 | my ($src,$dst) = @_; |
---|
798 | return 0 if (-s $src != -s $dst); |
---|
799 | open(SRC,$src)||return 0; open(DST,$dst)||return 0; |
---|
800 | my ($buff,$buff2); |
---|
801 | binmode(SRC); binmode(DST); seek(SRC,0,0); seek(DST,0,0); |
---|
802 | while(read(SRC,$buff,8192)){ read(DST,$buff2,8192); if($buff ne $buff2){ close(SRC); close(DST); return 0; } } |
---|
803 | close(SRC); close(DST); |
---|
804 | return 1; |
---|
805 | } |
---|
806 | |
---|
807 | sub init{ |
---|
808 | my $buff; |
---|
809 | if(open(OUT,">$set{'log_file'}")){ |
---|
810 | print OUT "0<>0<>0<>1\n"; |
---|
811 | close(OUT); |
---|
812 | chmod($set{'per_logfile'},$set{'log_file'}); |
---|
813 | }else{ |
---|
814 | $buff = "<tr><td>COÌì¬É¸sµÜµ½</td></tr>"; |
---|
815 | } |
---|
816 | |
---|
817 | unless (-d "$set{'src_dir'}"){ |
---|
818 | if(mkdir("$set{'src_dir'}",$set{'per_dir'})){ |
---|
819 | chmod($set{'per_dir'},"$set{'src_dir'}"); |
---|
820 | open(OUT,">$set{'src_dir'}index.html"); |
---|
821 | close(OUT); |
---|
822 | chmod($set{'per_upfile'},"$set{'src_dir'}index.html"); |
---|
823 | }else{ |
---|
824 | $buff .= "<tr><td>SourceÛ¶fBNgÌì¬É¸sµÜµ½</td></tr>"; |
---|
825 | } |
---|
826 | } |
---|
827 | |
---|
828 | unless (-d "$set{'html_dir'}"){ |
---|
829 | if(mkdir("$set{'html_dir'}",$set{'per_dir'})){ |
---|
830 | chmod($set{'per_dir'},"$set{'html_dir'}"); |
---|
831 | }else{ |
---|
832 | $buff .= "<tr><td>HTMLÛ¶fBNgÌì¬É¸sµÜµ½</td></tr>"; |
---|
833 | } |
---|
834 | } |
---|
835 | |
---|
836 | if($buff){ |
---|
837 | $buff .= "<tr><td>fBNgÉ«Ý Àª é©mFµÄ¾³¢</td></tr>"; |
---|
838 | &error_disp($buff,'init'); |
---|
839 | } |
---|
840 | } |
---|
841 | |
---|
842 | sub check_postkey{ |
---|
843 | my $inputkey = @_[0]; |
---|
844 | my @key = split(/,/,$set{'post_key'}); |
---|
845 | foreach my $key (@key){ if($inputkey eq $key){ return 1; } } |
---|
846 | return 0; |
---|
847 | } |
---|
848 | |
---|
849 | sub leaddisp{ |
---|
850 | my @src = @_; |
---|
851 | my ($str,$count); |
---|
852 | foreach my $value (@src){ |
---|
853 | my ($mark,$name,$link); $count++; |
---|
854 | if($count == 1){ $name = 'Upload Info'; $link = 'up'; } |
---|
855 | elsif($count == 2){ $name = 'Error Info'; $link = 'error'; next if(!$set{'error_level'}); } |
---|
856 | elsif($count == 3){ $name = 'Setting Info'; $link = 'set'; } |
---|
857 | if($value){ if($value > 0){ $mark = '¥'; }else{ $mark = '£'; } $str .= qq|<a href="#$link">${mark}${name}</a> |; } |
---|
858 | else{ $str .= qq|[$name] |; } |
---|
859 | } |
---|
860 | return $str; |
---|
861 | } |
---|
862 | |
---|
863 | sub errorclear{ |
---|
864 | open(OUT,">$set{'error_log'}")||return 0; |
---|
865 | eval{ flock(OUT, 2);}; eval{ truncate(OUT, 0);}; seek(OUT, 0, 0); eval{ flock(OUT, 8);}; close(OUT); |
---|
866 | chmod($set{'per_upfile'},$set{'log_file'}); |
---|
867 | return 1; |
---|
868 | } |
---|
869 | |
---|
870 | sub tablestr{ |
---|
871 | my ($value1,$value2) = @_; |
---|
872 | return ("<tr><td>$value1</td><td>$value2</td></tr>\n"); |
---|
873 | } |
---|
874 | |
---|
875 | sub globfile{ |
---|
876 | my ($src_dir,$filename) = @_; |
---|
877 | opendir(DIR,$src_dir)||return 0; my @dir = readdir(DIR); closedir(DIR); |
---|
878 | my @new = (); foreach my $value (@dir){ push(@new,"$src_dir$value") if($value =~ /$filename/ && !(-d "$src_dir$value")); } |
---|
879 | return @new; |
---|
880 | } |
---|
881 | |
---|
882 | sub globdir{ |
---|
883 | my ($src_dir,$dir) = @_; |
---|
884 | opendir(DIR,$src_dir)||return 0; my @dir = readdir(DIR); closedir(DIR); |
---|
885 | my @new = (); foreach my $value (@dir){ if($value eq '.' ||$value eq '..' ){ next; } push(@new,"$src_dir$value") if($value =~ /$dir/ && (-d "$src_dir$value")); } |
---|
886 | return @new; |
---|
887 | } |
---|
888 | |
---|
889 | sub error_disp{ |
---|
890 | my ($message,$mode) = @_; |
---|
891 | my $url; |
---|
892 | if($mode eq 'init'){ $url = qq|<a href="$set{'base_cgi'}">[[h]</a>|; }else{ $url = qq|<a href="$set{'http_html_path'}$set{'base_html'}">[ßé]</a>|; } |
---|
893 | my $buff =<<"EOM"; |
---|
894 | $set{'html_head'}$set{'html_css'}</HEAD> |
---|
895 | <body bgcolor="#ffffff" text="#000000" LINK="#6060FF" VLINK="#6060FF" ALINK="#6060FF"> |
---|
896 | <div align="center"> |
---|
897 | <table summary="error"> |
---|
898 | $message |
---|
899 | <tr><td></td></tr> |
---|
900 | <tr><td><div align="center">$url</div></td></tr> |
---|
901 | </table> |
---|
902 | <br><br> |
---|
903 | <table summary="info"> |
---|
904 | <tr> |
---|
905 | <td>DATE</td><td>$in{'date'}</td></tr> |
---|
906 | <tr><td>ADDR</td><td>$in{'addr'}</td></tr> |
---|
907 | <tr><td>HOST</td><td>$in{'host'}</td></tr> |
---|
908 | </table> |
---|
909 | </div> |
---|
910 | </body></html> |
---|
911 | EOM |
---|
912 | print "Content-type: text/html\n\n"; |
---|
913 | print $buff; |
---|
914 | exit; |
---|
915 | } |
---|
916 | |
---|
917 | sub error{ |
---|
918 | my ($no,$note) = @_; |
---|
919 | if (length($note) > 64) { $note = substr($note,0,64).'...'; } |
---|
920 | $note =~ s/&/&/g; $note =~ s/\"/"/g; $note =~ s/</</g; $note =~ s/>/>/g; $note =~ s/\r//g; $note =~ s/\n//g; $note =~ s/\t//g; $note =~ s/\0//g; |
---|
921 | my ($message,$dispmsg,$flag); |
---|
922 | |
---|
923 | if($no == 98){ $message = ""; } |
---|
924 | elsif($no == 99){ $message = "UpFileȵ"; } |
---|
925 | elsif($no == 101){ $message = "eÖ~HOST"; } |
---|
926 | elsif($no == 106){ $flag = 1; $message = "POSTTCY´ß"; $note = dispsize($note); $dispmsg= '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>Abv[ht@C('.$note.')Í ÅåeÊÝè('.dispsize($set{'max_size'}*1024).')ðz¦Ä¢Ü·</td></tr>';} |
---|
927 | elsif($no == 107){ $flag = 1; $message = "POSTTCY߬"; $note = dispsize($note); $dispmsg= '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>Abv[ht@C('.$note.')Í Å¬eÊÝè('.dispsize($set{'min_size'}*1024).')¢Å·</td></tr>';} |
---|
928 | elsif($no == 108){ $flag = 1; $message = "POSTf[^s®S"; $dispmsg = '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>POSTf[^ªs®SÅ·</td></tr>';} |
---|
929 | elsif($no == 109){ $flag = 1; $message = "POSTKeysêv"; $dispmsg = '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>POSTKeyªêvµÜ¹ñ</td></tr>';} |
---|
930 | elsif($no == 202){ $flag = 1; $message = "g£qí¸"; $dispmsg = '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>eÅ«ég£qÍ'.$set{'up_ext'}.'Å·</td></tr>';} |
---|
931 | elsif($no == 203){ $flag = 1; $message = "e·¬"; $dispmsg = '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>¯êIPAhX©ç'.$set{'interval'}.'bÈàÉÄeūܹñ</td></tr>';} |
---|
932 | elsif($no == 204){ $flag = 1; $message = "êt@C«ß¸"; $dispmsg = '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>êt@CÌì¬É¸sµÜµ½</td></tr>';} |
---|
933 | elsif($no == 205){ $flag = 1; $message = "¯êt@C¶Ý"; $note =~ /([^\/]+)$/; my $filename = $1; $dispmsg = '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>¯êt@Cª '.$filename.' ɶݵܷ</td></tr>';} |
---|
934 | elsif($no == 206){ $flag = 1; $message = "Ö~g£q"; $dispmsg = '<tr><td>t@CðAbv[hūܹñŵ½</td></tr><tr><td>g£q '.$note.' ÍAbv[hūܹñ</td></tr>';} |
---|
935 | elsif($no == 303){ $flag = 1; $message = "Ot@CÉÇÝ߸"; $dispmsg = '<tr><td>COÌÇÝÝɸsµÜµ½</td></tr>';} |
---|
936 | elsif($no == 304){ $flag = 1; $message = "Ot@Cɫ߸"; $dispmsg = '<tr><td>COÌ«ÝɸsµÜµ½</td></tr>';} |
---|
937 | elsif($no == 306){ $message = "t@CXgHTML«ß¸";} |
---|
938 | elsif($no == 307){ $message = "t@CHTMLt@C«ß¸";} |
---|
939 | elsif($no == 401){ $flag = 1; $message = "íNo.oÅ«¸"; $dispmsg = '<tr><td>t@Cðíūܹñŵ½</td></tr><tr><td>'.$note.' ©çíNo.ðoūܹñŵ½</td></tr><tr><td>'.$set{'file_pre'}.'0774.zipÌê No.ÉÍ 774 ðü͵ܷ</td></tr>';} |
---|
940 | elsif($no == 402){ $flag = 1; $note = sprintf("%04d",int($note)); $message = "íNo.¶Ý¹¸"; $dispmsg = '<tr><td>t@Cðíūܹñŵ½</td></tr><tr><td>'.$set{'file_pre'}.$note.'.*** ÍCOɶݵܹñ</td></tr>';} |
---|
941 | elsif($no == 403){ $flag = 1; $message = "íANZXÛ"; $dispmsg = '<tr><td>t@Cðíūܹñŵ½</td></tr><tr><td>t@CíðͽµÄ¢Ü·ª '.$note.' Ìt@CÌíªÛ³êܵ½</td></tr><tr><td>ANZXªßèÈêÍÔðu¢ÄÄì·éÆíÅ«é±Æª èÜ·</td></tr>';} |
---|
942 | elsif($no == 404){ $flag = 1; $message = "íKeysêv"; $dispmsg = '<tr><td>t@Cðíūܹñŵ½</td></tr><tr><td>'.$note.' íKeyªêvµÜ¹ñŵ½</td></tr>';} |
---|
943 | |
---|
944 | elsif($no == 51){ $flag = 1; $message = "[DLMode] No.©Â©ç¸"; $dispmsg = '<tr><td>[DLMode] t@Cª©Â©èܹñŵ½</td></tr><tr><td>'.$note.' ©çt@CNo.ðoūܹñŵ½</td></tr>'; } |
---|
945 | elsif($no == 52){ $flag = 1; $message = "[DLMode] File©Â©ç¸"; $dispmsg = '<tr><td>[DLMode] t@Cª©Â©èܹñŵ½</td></tr><tr><td>'.$set{'file_pre'}.$note.'.*** ÍCOɶݵܹñ</td></tr>'; } |
---|
946 | elsif($no == 53){ $flag = 1; $message = "[DLMode] DLkey¢Ýè"; $dispmsg = '<tr><td>[DLMode] orgDLkeyError</td></tr><tr><td>'.$note.' DLKeyª¢ÝèÅ·</td></tr>'; } |
---|
947 | elsif($no == 54){ $flag = 1; $message = "[DLMode] DLkeysêv"; $dispmsg = '<tr><td>[DLMode] orgDLkeyError</td></tr><tr><td>'.$note.' DLKeyªêvµÜ¹ñŵ½</td></tr>'; } |
---|
948 | elsif($no == 55){ $flag = 1; $message = "[DLMode] File Oepn Error"; $dispmsg = '<tr><td>[DLMode] Open Error</td></tr><tr><td>'.$note.' t@CÌÇÝÝɸsµÜµ½</td></tr>'; } |
---|
949 | elsif($no == 56){ $flag = 1; $message = "[DLMode] File Not Found"; $dispmsg = '<tr><td>[DLMode] Not Found</td></tr><tr><td>'.$note.' t@Cª¶ÝµÜ¹ñ</td></tr>'; } |
---|
950 | |
---|
951 | elsif($no == 61){ $flag = 1; $message = "DLkey¢Ýè"; $dispmsg = '<tr><td>DLKeyª¢ÝèÅ·</td></tr>'; } |
---|
952 | |
---|
953 | unlink($in{'tmpfile'}); |
---|
954 | if($note){$message .= ' ';} |
---|
955 | if($set{'error_level'} && $no > 100){ |
---|
956 | unless(-e $set{'error_log'}){ |
---|
957 | open(OUT,">$set{'error_log'}"); |
---|
958 | close(OUT); |
---|
959 | chmod($set{'per_logfile'},$set{'error_log'}); |
---|
960 | } |
---|
961 | if($set{'error_size'} && ((-s $set{'error_log'}) > $set{'error_size'} * 1024)){ |
---|
962 | my $err_bkup = "$set{'error_log'}.bak.cgi"; |
---|
963 | unlink($err_bkup); |
---|
964 | rename($set{'error_log'},$err_bkup); |
---|
965 | open(OUT,">$set{'error_log'}"); |
---|
966 | close(OUT); |
---|
967 | chmod($set{'per_logfile'},$set{'error_log'}); |
---|
968 | } |
---|
969 | open(OUT,">>$set{'error_log'}"); |
---|
970 | print OUT "$in{'date'}<>$no<>$message$note<>$in{'addr'}<>$in{'host'}<>1\n"; |
---|
971 | close(OUT); |
---|
972 | } |
---|
973 | &error_disp($dispmsg) if($flag && $set{'disp_error'}); |
---|
974 | &quit(); |
---|
975 | } |
---|
976 | |
---|
977 | sub dlfile{ |
---|
978 | my $msg; |
---|
979 | my ($orgdlkey,$orgdlpath); |
---|
980 | my ($dlext,$dlfilepre); |
---|
981 | my ($dl_date,$dl_comment,$dl_size,$dl_mime,,$dl_orgname); |
---|
982 | my $dlno = 0; |
---|
983 | my $findflag; |
---|
984 | |
---|
985 | open(IN,$set{'log_file'})||&error(303); |
---|
986 | my @log = <IN>; |
---|
987 | close(IN); |
---|
988 | shift(@log); |
---|
989 | |
---|
990 | if($in{'file'} =~ /(\d+)/){ $dlno = $1; } |
---|
991 | if($dlno == 0) { &error(51,$in{'file'}); } |
---|
992 | |
---|
993 | foreach my $value (@log){ |
---|
994 | my ($no,$postname,$ext,$date,$comment,$mime,$orgname,$addr,$host,$pass,$filepre,$note,$dummy) = split(/<>/,$value); |
---|
995 | my @note = split(/,/,$note); |
---|
996 | if(int($dlno) == $no){ |
---|
997 | $dl_comment = $comment; |
---|
998 | $dl_mime = $mime; |
---|
999 | $dl_date = $date; |
---|
1000 | $dl_orgname = $orgname; |
---|
1001 | $dlext = $ext; |
---|
1002 | $dlfilepre = $filepre; |
---|
1003 | foreach my $tmpnote (@note){ |
---|
1004 | if($tmpnote =~ /\!--\sDLKey:(.+)\s--.*\!--\sDLpath:(.+)\s--/){ |
---|
1005 | $orgdlkey = $1; |
---|
1006 | $orgdlpath = $2; |
---|
1007 | last; |
---|
1008 | } |
---|
1009 | } |
---|
1010 | $findflag = 1; |
---|
1011 | last; |
---|
1012 | } |
---|
1013 | } |
---|
1014 | |
---|
1015 | my $dlfile = $dlfilepre.sprintf("%04d",int($dlno)).'.'.$dlext; |
---|
1016 | if(!(-e "$set{'src_dir'}${dlfile}_$orgdlpath/$dlfile")){ &error(56,"$dlfile----$set{'src_dir'}${dlfile}_$orgdlpath/$dlfile"); } |
---|
1017 | |
---|
1018 | if($in{'dlkey'}){ |
---|
1019 | my $dlsalt = substr($orgdlkey,0,2); |
---|
1020 | my $dlkey = crypt($in{'dlkey'},$dlsalt); |
---|
1021 | |
---|
1022 | if($findflag == 0){ &error(52,$dlfile); } |
---|
1023 | elsif(!$orgdlkey){ &error(53,$dlfile); } |
---|
1024 | elsif($orgdlkey ne $dlkey && $set{'admin_pass'} ne $in{'dlkey'}){ &error(54,$dlfile); } |
---|
1025 | #print "Location: $set{'http_src_path'}${dlfile}_$orgdlpath/$dlfile\n\n"; |
---|
1026 | my $buff =<<"EOM"; |
---|
1027 | $set{'html_head'}$set{'html_css'} |
---|
1028 | <META HTTP-EQUIV="Refresh" CONTENT="1;URL=$set{'http_src_path'}${dlfile}_$orgdlpath/$dlfile"> |
---|
1029 | </HEAD> |
---|
1030 | <body bgcolor="#ffffff" text="#000000" LINK="#6060FF" VLINK="#6060FF" ALINK="#6060FF"> |
---|
1031 | <div align="center"> |
---|
1032 | <br> |
---|
1033 | <table summary="dlfrom"> |
---|
1034 | <tr><td>òÎÈ¢êÍ <a href="$set{'http_src_path'}${dlfile}_$orgdlpath/$dlfile">±¿ç</a> ©ç</td></tr> |
---|
1035 | </table> |
---|
1036 | </div> |
---|
1037 | </body></html> |
---|
1038 | EOM |
---|
1039 | print "Content-type: text/html\n\n"; |
---|
1040 | print $buff; |
---|
1041 | }else{ |
---|
1042 | my $buff = cryptfiledl($dl_comment,$dlfile,$orgdlpath,$dl_date,$dl_mime,$dl_orgname,$dlno); |
---|
1043 | print "Content-type: text/html\n\n"; |
---|
1044 | print $buff; |
---|
1045 | } |
---|
1046 | exit; |
---|
1047 | } |
---|
1048 | |
---|
1049 | sub cryptfiledl{ |
---|
1050 | my($com,$file,$orgdlpath,$date,$mime,$orgname,$no) = @_; |
---|
1051 | my($d_com,$d_date,$d_size,$d_mime,$d_org); |
---|
1052 | |
---|
1053 | if($set{'disp_comment'}){ $d_com = "<tr><td>COMMENT</td><td>$com</td></td>"; } if($set{'disp_size'}){ $d_size = "<tr><td>SIZE</td><td>".dispsize(-s "$set{'src_dir'}${file}_$orgdlpath/$file")." (".(-s "$set{'src_dir'}${file}_$orgdlpath/$file")."bytes)"."</td></tr>"; } if($set{'disp_date'}){ $d_date= "<tr><td>DATE</td><td>$date</td></tr>"; } |
---|
1054 | if($set{'disp_mime'}){ $d_mime = "<tr><td>ORGMIME</td><td>$mime</td></tr>"; } if($set{'disp_orgname'}){ $d_org = "<tr><td>ORGNAME</td><td>$orgname</td></tr>"; } |
---|
1055 | |
---|
1056 | my $buff =<<"EOM"; |
---|
1057 | $set{'html_head'}$set{'html_css'}</HEAD> |
---|
1058 | <body bgcolor="#ffffff" text="#000000" LINK="#6060FF" VLINK="#6060FF" ALINK="#6060FF"> |
---|
1059 | <div align="center"> |
---|
1060 | <br> |
---|
1061 | $file ÉÍDLKeyªÝè³êĢܷ |
---|
1062 | <table summary="dlform"> |
---|
1063 | <tr><td></td></tr> |
---|
1064 | <FORM METHOD=POST ACTION="$set{'base_cgi'}" name="DL"> |
---|
1065 | <tr><td> |
---|
1066 | <input type=hidden name=file value=$no> |
---|
1067 | <input type=hidden name=jcode value="¿"> |
---|
1068 | <input type=hidden name=mode value=dl></td></tr> |
---|
1069 | $d_com$d_date$d_size$d_mime$d_org |
---|
1070 | <tr><td>DLKey:<input type=text size=8 name="dlkey"></td></tr> |
---|
1071 | <tr><td><input type=submit value="DownLoad"></td></tr> |
---|
1072 | </FORM> |
---|
1073 | </table> |
---|
1074 | </div> |
---|
1075 | </body></html> |
---|
1076 | EOM |
---|
1077 | |
---|
1078 | return $buff; |
---|
1079 | } |
---|