From ed7391e775885ed3bc6ac41e428487e4f6fec208 Mon Sep 17 00:00:00 2001 From: zero Date: Thu, 15 Mar 2007 09:45:49 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@460 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/template/TemplateHandler.class.php | 18 +++++++------ modules/board/skins/default/comment_form.html | 6 ++++- modules/board/skins/default/write_form.html | 3 +-- modules/file/file.controller.php | 26 +++++++++---------- modules/file/file.model.php | 8 +++--- modules/file/queries/deleteFiles.xml | 2 +- modules/file/queries/getFiles.xml | 2 +- modules/file/queries/getFilesCount.xml | 2 +- modules/file/queries/insertFile.xml | 2 +- modules/file/schemas/files.xml | 2 +- modules/pagemaker/tpl.admin/write_form.html | 1 + 11 files changed, 39 insertions(+), 33 deletions(-) diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index cd77a54d8..e71001a55 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -26,11 +26,11 @@ if(__DEBUG__) $start = getMicroTime(); // 변수 체크 - if(substr($tpl_path,-1)!='/') $tpl_path .= '/'; + $this->tpl_path = ereg_replace('(\/+)$', '', $this->tpl_path).'/'; if(substr($tpl_filename,-5)!='.html') $tpl_filename .= '.html'; // tpl_file 변수 생성 - $tpl_file = $tpl_path.$tpl_filename; + $tpl_file = $this->tpl_path.$tpl_filename; // tpl_file이 비어 있거나 해당 파일이 없으면 return if(!$tpl_file || !file_exists($tpl_file)) return; @@ -75,12 +75,12 @@ $buff = FileHandler::readFile($tpl_file); if(!$buff) return; + // 이미지 태그 img의 src의 값이 http:// 나 / 로 시작하지 않으면 제로보드의 root경로부터 시작하도록 변경 + $buff = preg_replace_callback('!img([^>]*)src=[\'"]{1}(.*?)[\'"]{1}!is', array($this, '_compileImgPath'), $buff); + // 변수를 변경 $buff = preg_replace_callback('/\{[^@^ ]([^\}]+)\}/i', array($this, '_compileVarToContext'), $buff); - // 이미지 태그 img의 src의 값이 ./ 로 시작하면 {$tpl_path}로 변경 - $buff = preg_replace_callback('!src=[\'"]{1}(.*?)[\'"]{1}!is', array($this, '_compileImgPath'), $buff); - // 결과를 출력하지 않는 구문 변경 $buff = preg_replace_callback('/\{\@([^\}]+)\}/i', array($this, '_compileVarToSilenceExecute'), $buff); @@ -118,11 +118,13 @@ **/ function _compileImgPath($matches) { $str1 = $matches[0]; - $str2 = $matches[1]; + $str2 = $matches[2]; $path = $str2; - if(!eregi("^\.\/(images|img)",$path)) return $str1; - $path = 'tpl_path?>'.substr($path,2); + if(substr($path,0,1)=='/' || eregi(":\/\/",$path)) return $str1; + + $path = preg_replace('/^([\.\/]+)/','',$path); + $path = 'tpl_path?>'.$path; return str_replace($str2, $path, $str1); } diff --git a/modules/board/skins/default/comment_form.html b/modules/board/skins/default/comment_form.html index 0f42c12b2..c93760f13 100644 --- a/modules/board/skins/default/comment_form.html +++ b/modules/board/skins/default/comment_form.html @@ -56,7 +56,11 @@ {$lang->content} - + + {@$upload_target_srl = $document_srl} + + + diff --git a/modules/board/skins/default/write_form.html b/modules/board/skins/default/write_form.html index 7497af49e..108e1d64c 100644 --- a/modules/board/skins/default/write_form.html +++ b/modules/board/skins/default/write_form.html @@ -68,10 +68,9 @@ {$lang->content} + {@$upload_target_srl = $document_srl} - - diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index 5d15f11ed..eeb2278d1 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -16,7 +16,7 @@ /** * @brief 첨부파일 추가 **/ - function insertFile($module_srl, $document_srl) { + function insertFile($module_srl, $upload_target_srl) { $file_info = Context::get('file'); // 정상적으로 업로드된 파일이 아니면 오류 출력 @@ -24,11 +24,11 @@ // 이미지인지 기타 파일인지 체크하여 upload path 지정 if(eregi("\.(jpg|jpeg|gif|png|wmv|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi)$", $file_info['name'])) { - $path = sprintf("./files/attach/images/%s/%s/", $module_srl,$document_srl); + $path = sprintf("./files/attach/images/%s/%s/", $module_srl,$upload_target_srl); $filename = $path.$file_info['name']; $direct_download = 'Y'; } else { - $path = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); + $path = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $upload_target_srl); $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); $direct_download = 'N'; } @@ -48,7 +48,7 @@ // 파일 정보를 정리 $args->file_srl = $oDB->getNextSequence(); - $args->document_srl = $document_srl; + $args->upload_target_srl = $upload_target_srl; $args->module_srl = $module_srl; $args->direct_download = $direct_download; $args->source_filename = $file_info['name']; @@ -96,16 +96,16 @@ /** * @brief 특정 문서의 첨부파일을 모두 삭제 **/ - function deleteFiles($module_srl, $document_srl) { + function deleteFiles($module_srl, $upload_target_srl) { $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; + $args->upload_target_srl = $upload_target_srl; $output = $oDB->executeQuery('file.deleteFiles', $args); if(!$output->toBool()) return $output; // 실제 파일 삭제 - $path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $document_srl); - $path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); + $path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $upload_target_srl); + $path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $upload_target_srl); FileHandler::removeDir($path[0]); FileHandler::removeDir($path[1]); @@ -133,14 +133,14 @@ } /** - * @brief document_srl을 키로 하는 첨부파일을 찾아서 java script 코드로 return + * @brief upload_target_srl을 키로 하는 첨부파일을 찾아서 java script 코드로 return **/ - function printUploadedFileList($document_srl) { + function printUploadedFileList($upload_target_srl) { // file의 Model객체 생성 $oFileModel = &getModel('file'); // 첨부파일 목록을 구함 - $file_list = $oFileModel->getFiles($document_srl); + $file_list = $oFileModel->getFiles($upload_target_srl); $file_count = count($file_list); // 루프를 돌면서 $buff 변수에 java script 코드를 생성 @@ -149,7 +149,7 @@ $file_info = $file_list[$i]; if(!$file_info->file_srl) continue; - $buff .= sprintf("parent.editor_insert_uploaded_file(\"%d\", \"%d\",\"%s\", \"%d\", \"%s\", \"%s\", \"%s\");\n", $document_srl, $file_info->file_srl, $file_info->source_filename, $file_info->file_size, FileHandler::filesize($file_info->file_size), $file_info->direct_download=='Y'?$file_info->uploaded_filename:'', $file_info->sid); + $buff .= sprintf("parent.editor_insert_uploaded_file(\"%d\", \"%d\",\"%s\", \"%d\", \"%s\", \"%s\", \"%s\");\n", $upload_target_srl, $file_info->file_srl, $file_info->source_filename, $file_info->file_size, FileHandler::filesize($file_info->file_size), $file_info->direct_download=='Y'?$file_info->uploaded_filename:'', $file_info->sid); } header("Content-Type: text/html; charset=UTF-8"); @@ -159,7 +159,7 @@ header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); - $buff = sprintf("", $document_srl, $buff); + $buff = sprintf("", $upload_target_srl, $buff); print $buff; exit(); } diff --git a/modules/file/file.model.php b/modules/file/file.model.php index 7e49259ee..4996b84ea 100644 --- a/modules/file/file.model.php +++ b/modules/file/file.model.php @@ -16,10 +16,10 @@ /** * @brief 특정 문서에 속한 첨부파일의 개수를 return **/ - function getFilesCount($document_srl) { + function getFilesCount($upload_target_srl) { $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; + $args->upload_target_srl = $upload_target_srl; $output = $oDB->executeQuery('file.getFilesCount', $args); return (int)$output->data->count; } @@ -38,10 +38,10 @@ /** * @brief 특정 문서에 속한 파일을 모두 return **/ - function getFiles($document_srl) { + function getFiles($upload_target_srl) { $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; + $args->upload_target_srl = $upload_target_srl; $args->sort_index = 'file_srl'; $output = $oDB->executeQuery('file.getFiles', $args); diff --git a/modules/file/queries/deleteFiles.xml b/modules/file/queries/deleteFiles.xml index d4ee8b8df..bbc75fe52 100644 --- a/modules/file/queries/deleteFiles.xml +++ b/modules/file/queries/deleteFiles.xml @@ -3,6 +3,6 @@ - + diff --git a/modules/file/queries/getFiles.xml b/modules/file/queries/getFiles.xml index d4e1510f9..ca9d34185 100644 --- a/modules/file/queries/getFiles.xml +++ b/modules/file/queries/getFiles.xml @@ -3,7 +3,7 @@
- + diff --git a/modules/file/queries/getFilesCount.xml b/modules/file/queries/getFilesCount.xml index a03e6a3e0..2c9f6e949 100644 --- a/modules/file/queries/getFilesCount.xml +++ b/modules/file/queries/getFilesCount.xml @@ -6,6 +6,6 @@ - + diff --git a/modules/file/queries/insertFile.xml b/modules/file/queries/insertFile.xml index 873310014..7b48c85ab 100644 --- a/modules/file/queries/insertFile.xml +++ b/modules/file/queries/insertFile.xml @@ -4,7 +4,7 @@ - + diff --git a/modules/file/schemas/files.xml b/modules/file/schemas/files.xml index f18807bfd..24222babc 100644 --- a/modules/file/schemas/files.xml +++ b/modules/file/schemas/files.xml @@ -1,7 +1,7 @@
+ - diff --git a/modules/pagemaker/tpl.admin/write_form.html b/modules/pagemaker/tpl.admin/write_form.html index 146c4945c..06d7e398a 100644 --- a/modules/pagemaker/tpl.admin/write_form.html +++ b/modules/pagemaker/tpl.admin/write_form.html @@ -45,6 +45,7 @@
{$lang->content} + {@upload_target_srl = $document_srl}