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