From bdc194ab1db9bda88ec7e0e2ddd336f7ce50f578 Mon Sep 17 00:00:00 2001 From: zero Date: Fri, 27 Jun 2008 08:23:23 +0000 Subject: [PATCH] =?UTF-8?q?=EC=BA=90=EC=8B=9C=EB=A5=BC=20=EC=A7=80?= =?UTF-8?q?=EC=9A=B0=EB=8A=94=20=EC=99=B8=EB=B6=80=20=ED=88=B4=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=B6=94=EA=B0=80.=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=9D=84=20=ED=95=B8=EB=93=A4=EB=A7=81=ED=95=A0?= =?UTF-8?q?=EB=95=8C=20=EA=B2=BD=EB=A1=9C=EB=A5=BC=20=EC=A0=9C=EB=8C=80?= =?UTF-8?q?=EB=A1=9C=20=EC=B0=BE=EC=95=84=EC=84=9C=20=EC=B2=98=EB=A6=AC?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4331 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .htaccess | 1 + .../member_communication.addon.php | 2 +- classes/context/Context.class.php | 8 +++ classes/db/DB.class.php | 2 +- classes/file/FileHandler.class.php | 57 +++++++++++++++--- classes/template/TemplateHandler.class.php | 10 ++-- classes/widget/WidgetHandler.class.php | 2 +- config/func.inc.php | 9 ++- modules/admin/admin.class.php | 4 +- modules/board/board.admin.controller.php | 2 +- modules/comment/comment.class.php | 2 +- modules/comment/comment.model.php | 2 +- modules/communication/communication.view.php | 2 +- .../document/document.admin.controller.php | 2 +- modules/document/document.class.php | 33 +++++------ modules/document/document.controller.php | 4 +- modules/document/document.item.php | 4 +- modules/file/file.controller.php | 4 +- modules/importer/extract.class.php | 4 +- .../importer/importer.admin.controller.php | 10 ++-- modules/importer/ttimport.class.php | 6 +- .../integration_search.admin.controller.php | 2 +- modules/layout/layout.admin.controller.php | 10 ++-- modules/layout/layout.admin.view.php | 2 +- modules/layout/layout.class.php | 2 +- modules/lifepod/lifepod.admin.controller.php | 2 +- modules/member/member.controller.php | 10 ++-- .../member/openid_lib/class_HTTPRetriever.php | 2 +- .../member/openid_lib/libcurlexternal.inc.php | 6 +- .../member/openid_lib/libcurlnative.inc.php | 2 +- modules/menu/menu.admin.controller.php | 10 ++-- modules/module/module.controller.php | 2 +- modules/opage/opage.admin.controller.php | 2 +- modules/opage/opage.view.php | 2 +- modules/point/point.admin.controller.php | 5 +- .../springnote.admin.controller.php | 2 +- .../tccommentnotify.controller.php | 4 +- modules/widget/widget.controller.php | 6 +- tools/cache_cleaner/form.html | 32 ++++++++++ tools/cache_cleaner/index.php | 58 +++++++++++++++++++ tools/cache_cleaner/style.css | 10 ++++ 41 files changed, 246 insertions(+), 95 deletions(-) create mode 100644 tools/cache_cleaner/form.html create mode 100644 tools/cache_cleaner/index.php create mode 100644 tools/cache_cleaner/style.css diff --git a/.htaccess b/.htaccess index 3b31f0629..89fcec0fc 100644 --- a/.htaccess +++ b/.htaccess @@ -12,6 +12,7 @@ RewriteRule ^(.+)/common/tpl/(.*) ./common/tpl/$2 [L] RewriteRule ^(.+)/widgets/(.*) ./widgets/$2 [L] RewriteRule ^(.+)/layouts/(.*) ./layouts/$2 [L] RewriteRule ^(.+)/addons/(.*) ./addons/$2 [L] +RewriteRule ^(.+)/tools/(.*) ./tools/$2 [L] # page RewriteRule ^([a-zA-Z0-9_]+)/([[:digit:]]+)page$ ./index.php?mid=$1&page=$2 [L] diff --git a/addons/member_communication/member_communication.addon.php b/addons/member_communication/member_communication.addon.php index ca0bd2c21..26563ce0a 100644 --- a/addons/member_communication/member_communication.addon.php +++ b/addons/member_communication/member_communication.addon.php @@ -33,7 +33,7 @@ $flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl); if(file_exists($flag_file)) { - @unlink($flag_file); + FileHandler::removeFile($flag_file); Context::loadLang('./addons/member_communication/lang'); $script = sprintf('', Context::getLang('alert_new_message_arrived'), Context::getRequestUri().'?module=communication&act=dispCommunicationNewMessage'); diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index f2038af1a..6be9ec809 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -185,6 +185,14 @@ if(is_object($oDB)&&method_exists($oDB, 'close')) $oDB->close(); } + /** + * @brief DB의 및 기타 정보 load + **/ + function loadDBInfo() { + $oContext = &Context::getInstance(); + return $oContext->_loadDBInfo(); + } + /** * @brief DB 정보를 설정하고 DB Type과 DB 정보를 return **/ diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index e7cdb0e10..9e973a3b6 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -496,7 +496,7 @@ if(!is_array($tables)) $tables = array($tables); foreach($tables as $alias => $table) { $filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table); - @unlink($filename); + FileHandler::removeFile($filename); FileHandler::writeFile( $filename, '' ); } diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 5742b9963..f89494940 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -9,10 +9,21 @@ class FileHandler extends Handler { + /** + * @brief 대상 파일이름이나 디렉토리의 위치를 확인함 + **/ + function getRealPath($source) { + if(substr($source,0,1)=='/') return $source; + if(substr($source,0,2)=='./') $source = substr($source,2); + return _XE_PATH_.$source; + } + /** * @brief 파일의 내용을 읽어서 return **/ function readFile($file_name) { + $file_name = FileHandler::getRealPath($file_name); + if(!file_exists($file_name)) return; $filesize = filesize($file_name); if($filesize<1) return; @@ -35,6 +46,8 @@ * @brief $buff의 내용을 파일에 쓰기 **/ function writeFile($file_name, $buff, $mode = "w") { + $file_name = FileHandler::getRealPath($file_name); + $pathinfo = pathinfo($file_name); $path = $pathinfo['dirname']; if(!is_dir($path)) FileHandler::makeDir($path); @@ -47,38 +60,58 @@ @chmod($file_name, 0644); } + /** + * @brief 파일 삭제 + **/ + function removeFile($file_name) { + $file_name = FileHandler::getRealPath($file_name); + if(file_exists($file_name)) @unlink($file_name); + } + + /** + * @brief 파일이름이나 디렉토리명이나 위치 변경 + **/ + function rename($source, $target) { + $source = FileHandler::getRealPath($source); + $target = FileHandler::getRealPath($target); + @rename($source, $target); + } + /** * @brief 특정 디렉토리를 이동 **/ function moveDir($source_dir, $target_dir) { - if(!is_dir($source_dir)) return; - - if(!is_dir($target_dir)) { - FileHandler::makeDir($target_dir); - @unlink($target_dir); - } - - @rename($source_dir, $target_dir); + FileHandler::rename($source_dir, $target_dir); } /** * @brief $path내의 파일들을 return ('.', '..', '.로 시작하는' 파일들은 제외) **/ function readDir($path, $filter = '', $to_lower = false, $concat_prefix = false) { + $path = FileHandler::getRealPath($path); + if(substr($path,-1)!='/') $path .= '/'; if(!is_dir($path)) return array(); + $oDir = dir($path); while($file = $oDir->read()) { if(substr($file,0,1)=='.') continue; + if($filter && !preg_match($filter, $file)) continue; + if($to_lower) $file = strtolower($file); + if($filter) $file = preg_replace($filter, '$1', $file); else $file = $file; - if($concat_prefix) $file = $path.$file; + if($concat_prefix) { + $file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file); + } + $output[] = $file; } if(!$output) return array(); + return $output; } @@ -108,6 +141,7 @@ * @brief 지정된 디렉토리 이하 모두 파일을 삭제 **/ function removeDir($path) { + $path = FileHandler::getRealPath($path); if(!is_dir($path)) return; $directory = dir($path); while($entry = $directory->read()) { @@ -145,6 +179,8 @@ * @brief 원격파일을 다운받아서 특정 위치에 저장 **/ function getRemoteFile($url, $target_filename) { + $target_filename = FileHandler::getRealPath($target_filename); + $url_info = parse_url($url); if(!$url_info['port']) $url_info['port'] = 80; @@ -191,6 +227,9 @@ * @brief 특정 이미지 파일을 특정 위치로 옮김 (옮길때 이미지의 크기를 리사이징할 수 있음..) **/ function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop') { + $source_file = FileHandler::getRequestUri($source_file); + $target_file = FileHandler::getRequestUri($target_file); + if(!file_exists($source_file)) return; if(!$resize_width) $resize_width = 100; if(!$resize_height) $resize_height = $resize_width; diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index 3a69da858..fe163ffeb 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -45,17 +45,17 @@ if(!$tpl_file) $tpl_file = $tpl_path.$tpl_filename; // tpl_file이 비어 있거나 해당 파일이 없으면 return - if(!$tpl_file || !file_exists($tpl_file)) return; + if(!$tpl_file || !file_exists(FileHandler::getRealPath($tpl_file))) return; $this->tpl_path = $tpl_path; $this->tpl_file = $tpl_file; // compiled된(or 될) 파일이름을 구함 - $compiled_tpl_file = $this->_getCompiledFileName($tpl_file); + $compiled_tpl_file = FileHandler::getRealPath($this->_getCompiledFileName($tpl_file)); // 일단 컴파일 $buff = $this->_compile($tpl_file, $compiled_tpl_file); - + // Context와 compiled_tpl_file로 컨텐츠 생성 $output = $this->_fetch($compiled_tpl_file, $buff, $tpl_path); @@ -83,9 +83,9 @@ function _compile($tpl_file, $compiled_tpl_file) { if(!file_exists($compiled_tpl_file)) return $this->_compileTplFile($tpl_file, $compiled_tpl_file); - $source_ftime = filemtime($tpl_file); + $source_ftime = filemtime(FileHandler::getRealPath($tpl_file)); $target_ftime = filemtime($compiled_tpl_file); - if($source_ftime>$target_ftime || $target_ftime < filemtime('./classes/template/TemplateHandler.class.php') ) return $this->_compileTplFile($tpl_file, $compiled_tpl_file); + if($source_ftime>$target_ftime || $target_ftime < filemtime(_XE_PATH_.'classes/template/TemplateHandler.class.php') ) return $this->_compileTplFile($tpl_file, $compiled_tpl_file); } /** diff --git a/classes/widget/WidgetHandler.class.php b/classes/widget/WidgetHandler.class.php index da0779b77..d1c2c0161 100644 --- a/classes/widget/WidgetHandler.class.php +++ b/classes/widget/WidgetHandler.class.php @@ -74,7 +74,7 @@ FileHandler::writeFile($cache_file, $widget_content); // lock 파일 제거 - @unlink($lock_file); + FileHandler::removeFile($lock_file); return $widget_content; } diff --git a/config/func.inc.php b/config/func.inc.php index c2f53c381..cf34e214d 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -472,8 +472,13 @@ * 현재 요청받은 스크립트 경로를 return **/ function getScriptPath() { - $url = $_SERVER['PHP_SELF']?$_SERVER['PHP_SELF']:($_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:$_SERVER['URL']); - return preg_replace('/index.php/i','',$url); + static $url = null; + if($url === null) { + $document_root = str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']); + $file = str_replace('\\','/',__FILE__); + $url = preg_replace('/index.php/i','',str_replace('config/func.inc.php','',str_replace($document_root, '', $file))); + } + return $url; } /** diff --git a/modules/admin/admin.class.php b/modules/admin/admin.class.php index a373b8db2..003c0585f 100644 --- a/modules/admin/admin.class.php +++ b/modules/admin/admin.class.php @@ -46,9 +46,9 @@ FileHandler::removeFilesInDir("./files/cache/queries"); // ./files/cache/news* 파일 삭제 - $directory = dir("./files/cache/"); + $directory = dir(_XE_PATH_."files/cache/"); while($entry = $directory->read()) { - if(substr($entry,0,11)=='newest_news') @unlink("./files/cache/".$entry); + if(substr($entry,0,11)=='newest_news') FileHandler::removeFile("./files/cache/".$entry); } $directory->close(); } diff --git a/modules/board/board.admin.controller.php b/modules/board/board.admin.controller.php index 5022e7237..cb31848ec 100644 --- a/modules/board/board.admin.controller.php +++ b/modules/board/board.admin.controller.php @@ -67,7 +67,7 @@ $del_var = $obj->{"del_".$vars->name}; unset($obj->{"del_".$vars->name}); if($del_var == 'Y') { - @unlink($module_info->{$vars->name}); + FileHandler::removeFile($module_info->{$vars->name}); continue; } diff --git a/modules/comment/comment.class.php b/modules/comment/comment.class.php index a59119792..a91565427 100644 --- a/modules/comment/comment.class.php +++ b/modules/comment/comment.class.php @@ -5,7 +5,7 @@ * @brief comment 모듈의 high class **/ - require_once('./modules/comment/comment.item.php'); + require_once(_XE_PATH_.'modules/comment/comment.item.php'); class comment extends ModuleObject { diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 13cf50051..d396142ce 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -285,7 +285,7 @@ } // 성공시 lock파일 제거 - @unlink($lock_file); + FileHandler::removeFile($lock_file); } /** diff --git a/modules/communication/communication.view.php b/modules/communication/communication.view.php index bfb8a0d9b..58ea86774 100644 --- a/modules/communication/communication.view.php +++ b/modules/communication/communication.view.php @@ -78,7 +78,7 @@ // 플래그 삭제 $flag_path = './files/communication_extra_info/new_message_flags/'.getNumberingPath($logged_info->member_srl); $flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl); - @unlink($flag_file); + FileHandler::removeFile($flag_file); $this->setTemplateFile('new_message'); } diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php index 016250d3d..e00155cdd 100644 --- a/modules/document/document.admin.controller.php +++ b/modules/document/document.admin.controller.php @@ -397,7 +397,7 @@ $this->deleteThumbnailFile($path."/".$entry); } else { if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) continue; - @unlink($path.'/'.$entry); + FileHandler::removeFile($path.'/'.$entry); } } } diff --git a/modules/document/document.class.php b/modules/document/document.class.php index 6339c4632..671577d46 100644 --- a/modules/document/document.class.php +++ b/modules/document/document.class.php @@ -5,7 +5,7 @@ * @brief document 모듈의 high 클래스 **/ - require_once('./modules/document/document.item.php'); + require_once(_XE_PATH_.'modules/document/document.item.php'); class document extends ModuleObject { @@ -31,7 +31,7 @@ $oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count")); $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); - $oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count")); + $oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count")); // 2007. 10. 17 모듈이 삭제될때 등록된 글도 모두 삭제하는 트리거 추가 $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); @@ -182,30 +182,27 @@ **/ if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); - // 2008. 04. 23 blamed count 컬럼 추가 - if(!$oDB->isColumnExists("documents", "blamed_count")) - { - $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true); - $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); - } + // 2008. 04. 23 blamed count 컬럼 추가 + if(!$oDB->isColumnExists("documents", "blamed_count")) { + $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true); + $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); + } - if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) - { - $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); - } + if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) { + $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); + } - if(!$oDB->isColumnExists("document_voted_log", "point")) - $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); - - return new Object(0,'success_updated'); - } + if(!$oDB->isColumnExists("document_voted_log", "point")) + $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); + return new Object(0,'success_updated'); + } /** * @brief 캐시 파일 재생성 **/ function recompileCache() { // 게시글 분류 캐시 파일 삭제 - FileHandler::removeFilesInDir("./files/cache/document_category"); + FileHandler::removeFilesInDir(_XE_PATH_."files/cache/document_category"); } /** diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 089f3757c..3d9912f48 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -762,8 +762,8 @@ $category_list = $output->data; if(!$category_list) { - @unlink($xml_file); - @unlink($php_file); + FileHandler::removeFile($xml_file); + FileHandler::removeFile($php_file); return false; } if(!is_array($category_list)) $category_list = array($category_list); diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 76b1e7863..ad48e925f 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -455,7 +455,7 @@ if(file_exists($thumbnail_file)) { $file_created_time = date("YmdHis",filemtime($thumbnail_file)); $modified_time = $this->get('last_update'); - if($modified_time > $file_created_time) @unlink($thumbnail_file); + if($modified_time > $file_created_time) FileHandler::removeFile($thumbnail_file); } if(file_exists($thumbnail_file)&&filesize($thumbnail_file)<1) return; @@ -500,7 +500,7 @@ $tmp_file = sprintf('%sthumbnail_%d.tmp.jpg', $document_path, $width); FileHandler::getRemoteFile($target_src, $tmp_file); FileHandler::createImageFile($tmp_file, $thumbnail_file, $width, $height, 'jpg', $config->thumbnail_type); - @unlink($tmp_file); + FileHandler::removeFile($tmp_file); return Context::getRequestUri().$thumbnail_file; } diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index 902411888..29d7a016c 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -346,7 +346,7 @@ if(!$trigger_output->toBool()) return $trigger_output; // 삭제 성공하면 파일 삭제 - @unlink($uploaded_filename); + FileHandler::removeFile($uploaded_filename); return $output; } @@ -415,7 +415,7 @@ FileHandler::makeDir($path); // 파일 이동 - @rename($old_file, $new_file); + FileHandler::rename($old_file, $new_file); // DB 정보도 수정 unset($args); diff --git a/modules/importer/extract.class.php b/modules/importer/extract.class.php index 9d43b75fd..8f16060fc 100644 --- a/modules/importer/extract.class.php +++ b/modules/importer/extract.class.php @@ -50,7 +50,7 @@ * @brief 지정된 파일의 지시자를 염 **/ function openFile() { - @unlink($this->cache_index_file); + FileHandler::removeFile($this->cache_index_file); $this->index_fd = fopen($this->cache_index_file,"a"); // local 파일일 경우 @@ -140,7 +140,7 @@ $buff = FileHandler::readFile($target_file); fwrite($fd, FileHandler::readFile($target_file)); - @unlink($target_file); + FileHandler::removeFile($target_file); } fwrite($fd, ''); fclose($fd); diff --git a/modules/importer/importer.admin.controller.php b/modules/importer/importer.admin.controller.php index 5789f5563..170458fcb 100644 --- a/modules/importer/importer.admin.controller.php +++ b/modules/importer/importer.admin.controller.php @@ -190,7 +190,7 @@ // 대상 파일을 읽여서 파싱후 입력 $xmlObj = $oXmlParser->loadXmlFile($target_file); - @unlink($target_file); + FileHandler::removeFile($target_file); if(!$xmlObj) continue; // 객체 정리 @@ -326,7 +326,7 @@ // 대상 파일을 읽여서 파싱후 입력 $xmlObj = $oXmlParser->loadXmlFile($target_file); - @unlink($target_file); + FileHandler::removeFile($target_file); if(!$xmlObj) continue; // 객체 정리 @@ -433,7 +433,7 @@ $oDocumentController = &getController('document'); $oDocumentController->makeCategoryFile($module_srl); } - @unlink($category_file); + FileHandler::removeFile($category_file); } $category_list = $category_titles = array(); @@ -558,7 +558,7 @@ } fclose($fp); - @unlink($target_file); + FileHandler::removeFile($target_file); } fclose($f); @@ -793,7 +793,7 @@ // 디렉토리 생성 if(!FileHandler::makeDir($path)) continue; - if(preg_match('/^\.\/files\/cache\/tmp/i',$file_obj->file)) @rename($file_obj->file, $filename); + if(preg_match('/^\.\/files\/cache\/tmp/i',$file_obj->file)) FileHandler::rename($file_obj->file, $filename); else @copy($file_obj->file, $filename); // DB입력 diff --git a/modules/importer/ttimport.class.php b/modules/importer/ttimport.class.php index d8f6c5319..8d3b14881 100644 --- a/modules/importer/ttimport.class.php +++ b/modules/importer/ttimport.class.php @@ -55,7 +55,7 @@ } $oDocumentController->makeCategoryFile($module_srl); } - @unlink($category_file); + FileHandler::removeFile($category_file); } $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); @@ -239,7 +239,7 @@ } fclose($fp); - @unlink($target_file); + FileHandler::removeFile($target_file); } fclose($f); @@ -298,7 +298,7 @@ // 디렉토리 생성 if(!FileHandler::makeDir($path)) continue; - @rename($file_obj->file, $filename); + FileHandler::rename($file_obj->file, $filename); // DB입력 unset($file_obj->file); diff --git a/modules/integration_search/integration_search.admin.controller.php b/modules/integration_search/integration_search.admin.controller.php index e536ba756..1e03bdb3a 100644 --- a/modules/integration_search/integration_search.admin.controller.php +++ b/modules/integration_search/integration_search.admin.controller.php @@ -61,7 +61,7 @@ $del_var = $obj->{"del_".$vars->name}; unset($obj->{"del_".$vars->name}); if($del_var == 'Y') { - @unlink($module_info->{$vars->name}); + FileHandler::removeFile($module_info->{$vars->name}); continue; } diff --git a/modules/layout/layout.admin.controller.php b/modules/layout/layout.admin.controller.php index 4ae95fcb0..6cddda824 100644 --- a/modules/layout/layout.admin.controller.php +++ b/modules/layout/layout.admin.controller.php @@ -92,7 +92,7 @@ unset($extra_vars->{"del_".$name}); if($del_var == 'Y') { $extra_vars->{$name} = ''; - @unlink($extra_vars->{$name}); + FileHandler::removeFile($extra_vars->{$name}); continue; } @@ -140,7 +140,7 @@ $output = executeQuery('layout.updateLayout', $args); if($output->toBool()) { $cache_file = sprintf('./files/cache/layout/%s.%s.cache.php', $args->layout_srl, Context::getLangType()); - @unlink($cache_file); + FileHandler::removeFile($cache_file); } return $output; } @@ -157,12 +157,12 @@ if(count($cache_list)) { foreach($cache_list as $cache_file) { $pos = strpos($cache_file, $layout_srl.'_'); - if($pos>0) unlink($cache_file); + if($pos>0)FileHandler::removeFile($cache_file); } } $layout_file = sprintf('./files/cache/layout/%d.html', $layout_srl); - if(file_exists($layout_file)) @unlink($layout_file); + if(file_exists($layout_file)) FileHandler::removeFile($layout_file); // 레이아웃 삭제 $args->layout_srl = $layout_srl; @@ -200,7 +200,7 @@ if(!$layout_srl) return new Object(-1, 'msg_invalid_request'); $layout_file = sprintf('./files/cache/layout/%d.html', $layout_srl); - @unlink($layout_file); + FileHandler::removeFile($layout_file); $this->setMessage('success_reset'); } diff --git a/modules/layout/layout.admin.view.php b/modules/layout/layout.admin.view.php index f29142a7e..10bc47936 100644 --- a/modules/layout/layout.admin.view.php +++ b/modules/layout/layout.admin.view.php @@ -155,7 +155,7 @@ Context::set('layout_tpl', $layout_tpl); // 임시 파일 삭제 - @unlink($edited_layout_file); + FileHandler::removeFile($edited_layout_file); $this->setTemplateFile('layout_preview'); } diff --git a/modules/layout/layout.class.php b/modules/layout/layout.class.php index cff9e0c72..93def1d09 100644 --- a/modules/layout/layout.class.php +++ b/modules/layout/layout.class.php @@ -53,7 +53,7 @@ $directory = dir($path); while($entry = $directory->read()) { if ($entry == "." || $entry == ".." || preg_match('/\.html$/i',$entry) ) continue; - @unlink($path."/".$entry); + FileHandler::removeFile($path."/".$entry); } $directory->close(); } diff --git a/modules/lifepod/lifepod.admin.controller.php b/modules/lifepod/lifepod.admin.controller.php index 40b9d2434..46f55c901 100644 --- a/modules/lifepod/lifepod.admin.controller.php +++ b/modules/lifepod/lifepod.admin.controller.php @@ -183,7 +183,7 @@ $del_var = $obj->{"del_".$vars->name}; unset($obj->{"del_".$vars->name}); if($del_var == 'Y') { - @unlink($module_info->{$vars->name}); + FileHandler::removeFile($module_info->{$vars->name}); continue; } diff --git a/modules/member/member.controller.php b/modules/member/member.controller.php index 2eff8ac47..51bb88b49 100644 --- a/modules/member/member.controller.php +++ b/modules/member/member.controller.php @@ -617,7 +617,7 @@ if($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl) { $oMemberModel = &getModel('member'); $profile_image = $oMemberModel->getProfileImage($member_srl); - @unlink($profile_image->file); + FileHandler::removeFile($profile_image->file); } return new Object(0,'success'); } @@ -640,7 +640,7 @@ if($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl) { $oMemberModel = &getModel('member'); $image_name = $oMemberModel->getImageName($member_srl); - @unlink($image_name->file); + FileHandler::removeFile($image_name->file); } return new Object(0,'success'); } @@ -705,7 +705,7 @@ if($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl) { $oMemberModel = &getModel('member'); $image_mark = $oMemberModel->getImageMark($member_srl); - @unlink($image_mark->file); + FileHandler::removeFile($image_mark->file); } return new Object(0,'success'); } @@ -830,7 +830,7 @@ $path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($member_srl)); $filename = sprintf('%s%d.signature.php', $path, $member_srl); - if(!$check_signature) return @unlink($filename); + if(!$check_signature) return FileHandler::removeFile($filename); $buff = sprintf('%s', $signature); FileHandler::makeDir($path); @@ -842,7 +842,7 @@ **/ function delSignature($member_srl) { $filename = sprintf('files/member_extra_info/signature/%s%d.gif', getNumberingPath($member_srl), $member_srl); - @unlink($filename); + FileHandler::removeFile($filename); } /** diff --git a/modules/member/openid_lib/class_HTTPRetriever.php b/modules/member/openid_lib/class_HTTPRetriever.php index 58f841bd7..5f5d79434 100755 --- a/modules/member/openid_lib/class_HTTPRetriever.php +++ b/modules/member/openid_lib/class_HTTPRetriever.php @@ -443,7 +443,7 @@ class HTTPRetriever { if (time()-filemtime($filename)>$this->caching) { $this->progress(HRP_DEBUG,"Page in cache is expired"); - @unlink($filename); + FileHandler::removeFile($filename); return false; } diff --git a/modules/member/openid_lib/libcurlexternal.inc.php b/modules/member/openid_lib/libcurlexternal.inc.php index f0e8d23ad..96ad7caee 100755 --- a/modules/member/openid_lib/libcurlexternal.inc.php +++ b/modules/member/openid_lib/libcurlexternal.inc.php @@ -341,7 +341,7 @@ function curl_setopt($ch,$option,$value) { } fclose($fp); // if a temporary file was previously created, unlink it - if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]); + if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"]))FileHandler::removeFile($settings["upload-file"]["value"]); // set the new upload-file filename $settings["upload-file"]["value"] = $tmpfilename; @@ -581,7 +581,7 @@ function curl_close($ch) { $settings = &$opt["settings"]; // if the user used CURLOPT_INFILE to specify a file to upload, remove the // temporary file created for the CURL binary - if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]); + if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"]))FileHandler::removeFile($settings["upload-file"]["value"]); } unset($GLOBALS["_CURLEXT_OPT"][$ch]); @@ -634,4 +634,4 @@ function curl_version() { } } -?> \ No newline at end of file +?> diff --git a/modules/member/openid_lib/libcurlnative.inc.php b/modules/member/openid_lib/libcurlnative.inc.php index d1c3884a3..445ab3faf 100755 --- a/modules/member/openid_lib/libcurlnative.inc.php +++ b/modules/member/openid_lib/libcurlnative.inc.php @@ -399,7 +399,7 @@ function curl_close($ch) { $settings = &$opt["settings"]; // if the user used CURLOPT_INFILE to specify a file to upload, remove the // temporary file created for the CURL binary - if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]); + if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"]))FileHandler::removeFile($settings["upload-file"]["value"]); } unset($GLOBALS["_CURLNAT_OPT"][$ch]); diff --git a/modules/menu/menu.admin.controller.php b/modules/menu/menu.admin.controller.php index 8a99451b4..7d4713fd0 100644 --- a/modules/menu/menu.admin.controller.php +++ b/modules/menu/menu.admin.controller.php @@ -55,7 +55,7 @@ if(count($cache_list)) { foreach($cache_list as $cache_file) { $pos = strpos($cache_file, $menu_srl.'_'); - if($pos>0) unlink($cache_file); + if($pos>0)FileHandler::removeFile($cache_file); } } @@ -196,9 +196,9 @@ $xml_file = $this->makeXmlFile($args->menu_srl); // 이미지 버튼 모두 삭제 - if($item_info->normal_btn) @unlink($item_info->normal_btn); - if($item_info->hover_btn) @unlink($item_info->hover_btn); - if($item_info->active_btn) @unlink($item_info->active_btn); + if($item_info->normal_btn) FileHandler::removeFile($item_info->normal_btn); + if($item_info->hover_btn) FileHandler::removeFile($item_info->hover_btn); + if($item_info->active_btn) FileHandler::removeFile($item_info->active_btn); $this->add('xml_file', $xml_file); $this->add('menu_title', $menu_title); @@ -305,7 +305,7 @@ $menu_item_srl = Context::get('menu_item_srl'); $target = Context::get('target'); $filename = Context::get('filename'); - @unlink($filename); + FileHandler::removeFile($filename); $this->add('target', $target); } diff --git a/modules/module/module.controller.php b/modules/module/module.controller.php index 5181ec57d..c1ff3a0ab 100644 --- a/modules/module/module.controller.php +++ b/modules/module/module.controller.php @@ -61,7 +61,7 @@ $output = executeQuery('module.deleteModuleConfig', $args); if(!$output->toBool()) return $output; - @unlink( sprintf('./files/cache/module_info/%s.config.php',$module) ); + FileHandler::removeFile( sprintf('./files/cache/module_info/%s.config.php',$module) ); // 변수 정리후 query 실행 $output = executeQuery('module.insertModuleConfig', $args); diff --git a/modules/opage/opage.admin.controller.php b/modules/opage/opage.admin.controller.php index 1bf5ad0bb..d809425e0 100644 --- a/modules/opage/opage.admin.controller.php +++ b/modules/opage/opage.admin.controller.php @@ -71,7 +71,7 @@ // 캐시 파일 삭제 $cache_file = sprintf("./files/cache/opage/%d.cache.php", $module_info->module_srl); - if(file_exists($cache_file)) @unlink($cache_file); + if(file_exists($cache_file)) FileHandler::removeFile($cache_file); // 등록 성공후 return될 메세지 정리 $this->add("module_srl", $module_args->module_srl); diff --git a/modules/opage/opage.view.php b/modules/opage/opage.view.php index 3b700edfb..72114bcaa 100644 --- a/modules/opage/opage.view.php +++ b/modules/opage/opage.view.php @@ -101,7 +101,7 @@ // 캐시 검사 if($caching_interval <1 || !file_exists($cache_file) || filemtime($cache_file) + $caching_interval*60 <= time() || filemtime($cache_file){"del_".$vars->name}; unset($obj->{"del_".$vars->name}); if($del_var == 'Y') { - @unlink($module_info->{$vars->name}); + FileHandler::removeFile($module_info->{$vars->name}); continue; } diff --git a/modules/tccommentnotify/tccommentnotify.controller.php b/modules/tccommentnotify/tccommentnotify.controller.php index 20fdabb72..9013866a6 100644 --- a/modules/tccommentnotify/tccommentnotify.controller.php +++ b/modules/tccommentnotify/tccommentnotify.controller.php @@ -83,7 +83,7 @@ if( file_exists($this->cachedir.$this->cachefile) ) { - unlink($this->cachedir.$this->cachefile); + FileHandler::removeFile($this->cachedir.$this->cachefile); } $oModel = &getModel('tccommentnotify'); @@ -101,7 +101,7 @@ $this->sendCommentNotify($data->comment_srl); } } - unlink($lockFilePath); + FileHandler::removeFile($lockFilePath); } function deleteFromQueue($comment_srl) diff --git a/modules/widget/widget.controller.php b/modules/widget/widget.controller.php index 3b843971e..01d49be59 100644 --- a/modules/widget/widget.controller.php +++ b/modules/widget/widget.controller.php @@ -31,7 +31,7 @@ if($vars->widget_sequence) { $cache_path = './files/cache/widget_cache/'; $cache_file = sprintf('%s%d.%s.cache', $cache_path, $vars->widget_sequence, Context::getLangType()); - @unlink($cache_file); + FileHandler::removeFile($cache_file); } if($vars->widget_cache>0) $vars->widget_sequence = getNextSequence(); @@ -50,7 +50,7 @@ $cache_path = './files/cache/widget_cache/'; $cache_file = sprintf('%s%d.%s.cache', $cache_path, $vars->widget_sequence, Context::getLangType()); - @unlink($cache_file); + FileHandler::removeFile($cache_file); // 코드 출력 $this->add('widget_code', $widget_code); @@ -75,7 +75,7 @@ if($vars->widget_sequence) { $cache_path = './files/cache/widget_cache/'; $cache_file = sprintf('%s%d.%s.cache', $cache_path, $vars->widget_sequence, Context::getLangType()); - @unlink($cache_file); + FileHandler::removeFile($cache_file); } if($vars->widget_cache>0) $vars->widget_sequence = getNextSequence(); diff --git a/tools/cache_cleaner/form.html b/tools/cache_cleaner/form.html new file mode 100644 index 000000000..5a4ff3a1b --- /dev/null +++ b/tools/cache_cleaner/form.html @@ -0,0 +1,32 @@ + + + + + + XE Cache Cleaner + + + + +

XE Cache Cleaner

+
+ + +
{$msg}
+ + +
+ + + + + + + + + + + +
+ + diff --git a/tools/cache_cleaner/index.php b/tools/cache_cleaner/index.php new file mode 100644 index 000000000..fcad6ea92 --- /dev/null +++ b/tools/cache_cleaner/index.php @@ -0,0 +1,58 @@ + + * @brief XE 캐시파일 및 불필요한 파일 정리 + **/ + + /** + * @brief 기본적인 상수 선언, 웹에서 직접 호출되는 것을 막기 위해 체크하는 상수 선언 + **/ + define('__ZBXE__', true); + + /** + * @brief 필요한 설정 파일들을 include + **/ + require_once('../../config/config.inc.php'); + + // id/ password 구함 + $id = $_POST['id']; + $pw = $_POST['pw']; + + // 저장되어 있는 비밀번호와 비교 + $oContext = &Context::getInstance(); + $oContext->init(); + $db_info = $oContext->getDBInfo(); + + // install 모듈의 언어파일을 로드 + Context::loadLang(_XE_PATH_.'modules/install/lang'); + + // 설치가 되어 있지 않을 경우 + if(!Context::isInstalled()) { + + $msg = Context::getLang('msg_db_not_setted'); + + // 인증 정보가 없을 경우 + } elseif(!isset($id) || !isset($pw)) { + + + // 입력된 정보와 저장된 정보 비교 + } else if($id !== $db_info->db_userid || $pw !== $db_info->db_password) { + + if($id !== $db_info->db_userid) $msg = sprintf($lang->filter->equalto, Context::getLang('user_id')); + else $msg = sprintf($lang->filter->equalto, Context::getLang('password')); + + // 캐시 파일 제거 + } else if($id === $db_info->db_userid && $pw === $db_info->db_password) { + + $oAdminController = &getAdminController('admin'); + $oAdminController->procAdminRecompileCacheFile(); + $msg = Context::getLang('success_reset'); + + } + + Context::set('msg', $msg); + + $oTemplate = &TemplateHandler::getInstance(); + print $oTemplate->compile('./tools/cache_cleaner/','form'); +?> diff --git a/tools/cache_cleaner/style.css b/tools/cache_cleaner/style.css new file mode 100644 index 000000000..228b7fd70 --- /dev/null +++ b/tools/cache_cleaner/style.css @@ -0,0 +1,10 @@ +h1 { font-size:1.5em; font-family:tahoma; margin:0; padding:0; } +hr { border:none; border-top:1px solid #555555; border-bottom:1px solid #888888; margin:0; margin-bottom:10px; padding:0; } +blockquote { border:1px solid red; color:red; width:280px; margin:0 0 10px 0; padding:10px;} + +code { display:block; clear:both; margin-bottom:10px;} +code label { float:left; display:block; width:150px; } +code input { display:block; width:150px; border:1px solid #AAAAAA; } + +input.submit { width:300px; border:1px solid #AAAAAA;} +