### 화일 업로드와 오에카키 저장을 위한 디렉토리 (내부 경로를 사용) $UploadDir = "./upload"; # by gypark. file upload ### 화일 업로드와 오에카키 저장을 위한 URL (http:// 시작하는 절대경로 사용) $UploadUrl = ""; # by gypark, URL for the directory containing uploaded file # if undefined, it has the same value as $UploadDir
... $MaxPost = 1024 * 1024 * 1; # 바이트 단위로 설정, 이 경우 1MB 가 된다. ... $UploadDir = "$DataDir/upload"; # 추가 $UploadUrl = ""; # 추가 ...
############### ### added by gypark ### 패치를 위해 추가된 환경설정 변수 use vars qw( $UserGotoBar $UserGotoBar2 $UserGotoBar3 $UserGotoBar4 $ConfigFile $SOURCEHIGHLIGHT @SRCHIGHLANG $LinkFirstChar $EditGuideInExtern $SizeTopFrame $SizeBottomFrame $LogoPage $CheckTime $LinkDir $IconDir $CountDir $UploadDir $UploadUrl # UploadDir, UploadUrl 추가 ); ### ###############
my @ScriptPath = split('/', "$ENV{SCRIPT_NAME}"); $CGI::POST_MAX = $MaxPost; ############### ### replaced by gypark ### file upload # $CGI::DISABLE_UPLOADS = 1; # no uploads $CGI::DISABLE_UPLOADS = 0; ### ############### $q = new CGI; $q->autoEscape(undef); ############### ### added by gypark ### file upload if ($q->cgi_error() =~ m/^413/) { print $q->redirect(-url=>"http:$ENV{SCRIPT_NAME}?action=upload&error=3"); exit 1; } $UploadUrl = "http:$UploadDir" if ($UploadUrl eq ""); ### ############### $Now = time; # Reset in case script is persistent $ScriptName = pop(@ScriptPath); # Name used in links ... }
sub GetSiteUrl { my ($site) = @_; my ($data, $url, $status); if (!$InterSiteInit) { $InterSiteInit = 1; ############### ### replaced by gypark ### file upload # ($status, $data) = &ReadFile($InterFile); # return "" if (!$status); # %InterSite = split(/\s+/, $data); # Later consider defensive code ($status, $data) = &ReadFile($InterFile); if ($status) { %InterSite = split(/\s+/, $data); } $InterSite{'Upload'} = "$UploadUrl\/"; ### ############### } $url = $InterSite{$site} if (defined($InterSite{$site})); return $url; }
sub DoOtherRequest { ... } elsif ($action eq "version") { &DoShowVersion(); ############### ### added by gypark ### 최근변경내역에 북마크 기능 도입 } elsif ($action eq "bookmark") { &DoBookmark(); ### ############### ############### ### added by gypark ### file upload } elsif ($action eq "upload") { &DoUpload(); ### ############### } else { # Later improve error reporting &ReportError(Ts('Invalid action parameter %s', $action)); } return; ... }
sub DoEdit { ... function help(s) { var w = window.open(s, "Help", "width=500,height=400, resizable=1, scrollbar s=1"); w.focus(); } //--> </script> |; ############### ### added by gypark ### file upload print qq| <script language="javascript" type="text/javascript"> <!-- function upload() { var w = window.open("$ScriptName?action=upload", "upload", "width=640,height=250,resizable=1,statusbar=1,scrollbars=1"); w.focus(); } //--> </script> |; ### ############### ... ### replaced by gypark ### 미리보기 버튼에 번역함수 적용 # print q(<input type="button" name="prev1" value="Popup Preview" onclick="javascript:preview();">); # luke added print q(<input type="button" name="prev1" value="). T('Popup Preview') . q(" onclick="javascript:preview();">); # luke added ### ############### ############### ### added by gypark ### file upload print " ".q(<input type="button" name="prev1" value="). T('Upload File') . q(" onclick="javascript:upload();">); ### ############### if ($isConflict) { print "\n<br><hr noshade size=1><p><strong>", T('This is the text you submitted:'), ... }
sub DoUpload { my $file; my $upload = &GetParam('upload'); my $prev_error = &GetParam('error', ""); my @uploadError = ( T('Upload completed successfully'), T('Invalid filename'), T('You can not upload html or any executable scripts'), T('File is too large'), T('File has no content'), T('Failed to get lock'), ); my $result; print &GetHttpHeader(); print &GetHtmlHeader("$SiteName : ". T('Upload File'), ""); print $q->h2(T('Upload File')) . "\n"; if (!(&UserCanEdit("",1))) { print T('Uploading is not allowed'); print $q->end_html; return; } if ($prev_error) { print "<b>$uploadError[$prev_error]</b><br><hr>\n"; } elsif ($upload) { $file = &GetParam('upload_file'); $result = &UploadFile($file); print "<b>$uploadError[$result]</b><br><hr>\n"; } &PrintUploadFileForm(); print $q->end_html; } sub PrintUploadFileForm { print T('Select the file you want to upload') . "\n"; print "<br>".Ts('File must be smaller than %s MB', ($MaxPost / 1024 / 1024)) . "\n"; print $q->start_form('post',"$ScriptName", 'multipart/form-data') . "\n"; print "<input type='hidden' name='action' value='upload'>"; print "<input type='hidden' name='upload' value='1'>" . "\n"; print "<center>" . "\n"; print $q->filefield("upload_file","",60,80) . "\n"; print " " . "\n"; print $q->submit(T('Upload')) . "\n"; print "</center>" . "\n"; print $q->endform(); } sub UploadFile { my ($file) = @_; my ($filename); my ($target); if ($file =~ m/\//) { $file =~ m/(.*)\/([^\/]*)/; $filename = $2; } elsif ($file =~ m/\\/) { $file =~ m/(.*)\\([^\\]*)/; $filename = $2; } else { $filename = $file; } if (($filename eq "") || ($filename =~ /\0/)) { return 1; } if ($filename =~ m/(\.pyc|\.py|\.pl|\.html|\.htm|\.php|\.cgi)$/i) { return 2; } $filename =~ s/ /_/g; &RequestLockDir('upload', 5, 2, 0) || return 5; my $target = GetUniqueUploadFilename( $UploadDir, $filename ); my $target_full = "$UploadDir/$target"; &CreateDir($UploadDir); if (!open (FILE, ">$target_full")) { &ReleaseLockDir('upload'); die Ts('cant opening %s', $target_full) . ": $!"; } &ReleaseLockDir('upload'); binmode FILE; while (<$file>) { print FILE $_; } close(FILE); chmod(0644, "$target_full"); if ((-s "$target_full") > $MaxPost) { unlink "$target_full"; return 3; } if ((-s "$target_full") == 0) { unlink "$target_full"; return 4; } print T('Following is the Interlink of your file') . "<br>\n"; print "<div style='text-align:center; font-size:larger; font-weight:bold;'>\n"; print "Upload:$target "; print $q->button( -name=>T("Copy"), -onClick=>"copy_clip('','Upload:$target')" ); print "</div>\n"; return 0; }
Upload File 화일 업로드 Upload completed successfully 업로드가 성공적으로 끝났습니다 Invalid filename 화일 이름이 올바르지 않습니다 You can not upload html or any executable scripts html 또는 실행 스크립트는 올릴 수 없습니다 File is too large 화일이 너무 큽니다 File has no content 화일의 내용이 없습니다 Failed to get lock 업로드를 위한 lock 을 얻지 못했습니다 Following is the Interlink of your file 다음 주소를 복사해서 사용하세요 Uploading is not allowed 업로드가 허용되지 않습니다 Select the file you want to upload 업로드할 화일을 선택하세요 File must be smaller than %s MB 화일 크기는 %s MB 이하여야 합니다. Upload 업로드 cant opening %s %s 를 열 수 없습니다
ext1.42b - 소스들이 재수정 되었습니다. 꼭 확인하세요 /UploadedFiles매크로와 /오에카키도 같이 수정됩니다.
ext2.4 - 업로드된 파일의 인터링크 주소를 클립보드에 복사할 수 있는 버튼 추가.
ext2.17a - 파일 이름이 중복될 때 확장자 직전에 숫자를 붙이도록 변경. UseModWiki소스수정/GetUniqueUploadFilename함수를 사용
혹시 MS윈도에서 IE 외에 다른 브라우저를 사용하시는 분들 계시면 연습장에서 업로드 테스트 좀 해봐주세요~