Changeset 4331 for sandbox

Show
Ignore:
Timestamp:
06/27/2008 05:23:23 PM (2 months ago)
Author:
zero
Message:

캐시를 지우는 외부 툴 스크립트 추가. 파일을 핸들링할때 경로를 제대로 찾아서 처리할 수 있도록 코드 수정

Location:
sandbox
Files:
5 added
38 modified

Legend:

Unmodified
Added
Removed
  • sandbox/.htaccess

    r4278 r4331  
    1313RewriteRule ^(.+)/layouts/(.*) ./layouts/$2 [L] 
    1414RewriteRule ^(.+)/addons/(.*) ./addons/$2 [L] 
     15RewriteRule ^(.+)/tools/(.*) ./tools/$2 [L] 
    1516 
    1617# page  
  • sandbox/addons/member_communication/member_communication.addon.php

    r4230 r4331  
    3434 
    3535        if(file_exists($flag_file)) { 
    36             @unlink($flag_file); 
     36            FileHandler::removeFile($flag_file); 
    3737            Context::loadLang('./addons/member_communication/lang'); 
    3838 
  • sandbox/classes/context/Context.class.php

    r4312 r4331  
    184184            $oDB = &DB::getInstance(); 
    185185            if(is_object($oDB)&&method_exists($oDB, 'close')) $oDB->close(); 
     186        } 
     187 
     188        /** 
     189         * @brief DB의 및 기타 정보 load 
     190         **/ 
     191        function loadDBInfo() { 
     192            $oContext = &Context::getInstance(); 
     193            return $oContext->_loadDBInfo(); 
    186194        } 
    187195 
  • sandbox/classes/db/DB.class.php

    r4290 r4331  
    497497            foreach($tables as $alias => $table) { 
    498498                $filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table); 
    499                 @unlink($filename); 
     499                FileHandler::removeFile($filename); 
    500500                FileHandler::writeFile( $filename, '' ); 
    501501            } 
  • sandbox/classes/file/FileHandler.class.php

    r4290 r4331  
    1111 
    1212        /** 
     13         * @brief 대상 파일이름이나 디렉토리의 위치를 확인함 
     14         **/ 
     15        function getRealPath($source) { 
     16            if(substr($source,0,1)=='/') return $source; 
     17            if(substr($source,0,2)=='./') $source = substr($source,2); 
     18            return _XE_PATH_.$source; 
     19        } 
     20 
     21        /** 
    1322         * @brief 파일의 내용을 읽어서 return 
    1423         **/ 
    1524        function readFile($file_name) { 
     25            $file_name = FileHandler::getRealPath($file_name); 
     26 
    1627            if(!file_exists($file_name)) return; 
    1728            $filesize = filesize($file_name); 
     
    3647         **/ 
    3748        function writeFile($file_name, $buff, $mode = "w") { 
     49            $file_name = FileHandler::getRealPath($file_name); 
     50 
    3851            $pathinfo = pathinfo($file_name); 
    3952            $path = $pathinfo['dirname']; 
     
    4962 
    5063        /** 
     64         * @brief 파일 삭제 
     65         **/ 
     66        function removeFile($file_name) { 
     67            $file_name = FileHandler::getRealPath($file_name); 
     68            if(file_exists($file_name)) @unlink($file_name); 
     69        } 
     70 
     71        /** 
     72         * @brief 파일이름이나 디렉토리명이나 위치 변경 
     73         **/ 
     74        function rename($source, $target) { 
     75            $source = FileHandler::getRealPath($source); 
     76            $target = FileHandler::getRealPath($target); 
     77            @rename($source, $target); 
     78        } 
     79 
     80        /** 
    5181         * @brief 특정 디렉토리를 이동 
    5282         **/ 
    5383        function moveDir($source_dir, $target_dir) { 
    54             if(!is_dir($source_dir)) return; 
    55  
    56             if(!is_dir($target_dir)) { 
    57                 FileHandler::makeDir($target_dir); 
    58                 @unlink($target_dir); 
    59             } 
    60  
    61             @rename($source_dir, $target_dir);  
     84            FileHandler::rename($source_dir, $target_dir); 
    6285        } 
    6386 
     
    6689         **/ 
    6790        function readDir($path, $filter = '', $to_lower = false, $concat_prefix = false) { 
     91            $path = FileHandler::getRealPath($path); 
     92 
    6893            if(substr($path,-1)!='/') $path .= '/'; 
    6994            if(!is_dir($path)) return array(); 
     95 
    7096            $oDir = dir($path); 
    7197            while($file = $oDir->read()) { 
    7298                if(substr($file,0,1)=='.') continue; 
     99 
    73100                if($filter && !preg_match($filter, $file)) continue; 
     101 
    74102                if($to_lower) $file = strtolower($file); 
     103 
    75104                if($filter) $file = preg_replace($filter, '$1', $file); 
    76105                else $file = $file; 
    77106 
    78                 if($concat_prefix) $file = $path.$file; 
     107                if($concat_prefix) { 
     108                    $file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file); 
     109                } 
     110 
    79111                $output[] = $file; 
    80112            } 
    81113            if(!$output) return array(); 
     114 
    82115            return $output; 
    83116        } 
     
    109142         **/ 
    110143        function removeDir($path) { 
     144            $path = FileHandler::getRealPath($path); 
    111145            if(!is_dir($path)) return; 
    112146            $directory = dir($path); 
     
    146180         **/ 
    147181        function getRemoteFile($url, $target_filename) { 
     182            $target_filename = FileHandler::getRealPath($target_filename); 
     183 
    148184            $url_info = parse_url($url); 
    149185 
     
    192228         **/ 
    193229        function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop') { 
     230            $source_file = FileHandler::getRequestUri($source_file); 
     231            $target_file = FileHandler::getRequestUri($target_file); 
     232 
    194233            if(!file_exists($source_file)) return; 
    195234            if(!$resize_width) $resize_width = 100; 
  • sandbox/classes/template/TemplateHandler.class.php

    r4087 r4331  
    4646 
    4747            // tpl_file이 비어 있거나 해당 파일이 없으면 return 
    48             if(!$tpl_file || !file_exists($tpl_file)) return; 
     48            if(!$tpl_file || !file_exists(FileHandler::getRealPath($tpl_file))) return; 
    4949 
    5050            $this->tpl_path = $tpl_path; 
     
    5252 
    5353            // compiled된(or 될) 파일이름을 구함 
    54             $compiled_tpl_file = $this->_getCompiledFileName($tpl_file); 
     54            $compiled_tpl_file = FileHandler::getRealPath($this->_getCompiledFileName($tpl_file)); 
    5555 
    5656            // 일단 컴파일 
    5757            $buff = $this->_compile($tpl_file, $compiled_tpl_file); 
    58  
     58             
    5959            // Context와 compiled_tpl_file로 컨텐츠 생성 
    6060            $output = $this->_fetch($compiled_tpl_file, $buff, $tpl_path); 
     
    8484            if(!file_exists($compiled_tpl_file)) return $this->_compileTplFile($tpl_file, $compiled_tpl_file); 
    8585 
    86             $source_ftime = filemtime($tpl_file); 
     86            $source_ftime = filemtime(FileHandler::getRealPath($tpl_file)); 
    8787            $target_ftime = filemtime($compiled_tpl_file); 
    88             if($source_ftime>$target_ftime || $target_ftime < filemtime('./classes/template/TemplateHandler.class.php') ) return $this->_compileTplFile($tpl_file, $compiled_tpl_file); 
     88            if($source_ftime>$target_ftime || $target_ftime < filemtime(_XE_PATH_.'classes/template/TemplateHandler.class.php') ) return $this->_compileTplFile($tpl_file, $compiled_tpl_file); 
    8989        } 
    9090 
  • sandbox/classes/widget/WidgetHandler.class.php

    r4322 r4331  
    7575 
    7676            // lock 파일 제거 
    77             @unlink($lock_file); 
     77            FileHandler::removeFile($lock_file); 
    7878 
    7979            return $widget_content; 
  • sandbox/config/func.inc.php

    r4316 r4331  
    473473     **/ 
    474474    function getScriptPath() { 
    475         $url = $_SERVER['PHP_SELF']?$_SERVER['PHP_SELF']:($_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:$_SERVER['URL']); 
    476         return preg_replace('/index.php/i','',$url); 
     475        static $url = null; 
     476        if($url === null) { 
     477            $document_root = str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']); 
     478            $file = str_replace('\\','/',__FILE__); 
     479            $url = preg_replace('/index.php/i','',str_replace('config/func.inc.php','',str_replace($document_root, '', $file))); 
     480        } 
     481        return $url; 
    477482    } 
    478483 
  • sandbox/modules/admin/admin.class.php

    r4184 r4331  
    4747 
    4848            // ./files/cache/news* 파일 삭제 
    49             $directory = dir("./files/cache/"); 
     49            $directory = dir(_XE_PATH_."files/cache/"); 
    5050            while($entry = $directory->read()) { 
    51                 if(substr($entry,0,11)=='newest_news') @unlink("./files/cache/".$entry); 
     51                if(substr($entry,0,11)=='newest_news') FileHandler::removeFile("./files/cache/".$entry); 
    5252            } 
    5353            $directory->close(); 
  • sandbox/modules/board/board.admin.controller.php

    r4208 r4331  
    6868                    unset($obj->{"del_".$vars->name}); 
    6969                    if($del_var == 'Y') { 
    70                         @unlink($module_info->{$vars->name}); 
     70                        FileHandler::removeFile($module_info->{$vars->name}); 
    7171                        continue; 
    7272                    } 
  • sandbox/modules/comment/comment.class.php

    r4197 r4331  
    66     **/ 
    77 
    8     require_once('./modules/comment/comment.item.php'); 
     8    require_once(_XE_PATH_.'modules/comment/comment.item.php'); 
    99 
    1010    class comment extends ModuleObject { 
  • sandbox/modules/comment/comment.model.php

    r4251 r4331  
    286286 
    287287            // 성공시 lock파일 제거 
    288             @unlink($lock_file); 
     288            FileHandler::removeFile($lock_file); 
    289289        } 
    290290 
  • sandbox/modules/communication/communication.view.php

    r4226 r4331  
    7979            $flag_path = './files/communication_extra_info/new_message_flags/'.getNumberingPath($logged_info->member_srl); 
    8080            $flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl); 
    81             @unlink($flag_file); 
     81            FileHandler::removeFile($flag_file); 
    8282 
    8383            $this->setTemplateFile('new_message'); 
  • sandbox/modules/document/document.admin.controller.php

    r4226 r4331  
    398398                    } else { 
    399399                        if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) continue; 
    400                         @unlink($path.'/'.$entry); 
     400                        FileHandler::removeFile($path.'/'.$entry); 
    401401                    } 
    402402                } 
  • sandbox/modules/document/document.class.php

    r4140 r4331  
    66     **/ 
    77 
    8     require_once('./modules/document/document.item.php'); 
     8    require_once(_XE_PATH_.'modules/document/document.item.php'); 
    99 
    1010    class document extends ModuleObject { 
     
    3232            $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice")); 
    3333            $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); 
    34             $oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count")); 
     34            $oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count")); 
    3535 
    3636            // 2007. 10. 17 모듈이 삭제될때 등록된 글도 모두 삭제하는 트리거 추가 
     
    183183            if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl")); 
    184184 
    185             // 2008. 04. 23 blamed count 컬럼 추가 
    186             if(!$oDB->isColumnExists("documents", "blamed_count"))  
    187             { 
    188                 $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true);  
    189                 $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); 
    190             } 
    191  
    192             if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) 
    193             { 
    194                 $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); 
    195             } 
    196  
    197             if(!$oDB->isColumnExists("document_voted_log", "point"))  
    198                 $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true);  
    199  
    200             return new Object(0,'success_updated'); 
    201         } 
     185            // 2008. 04. 23 blamed count 컬럼 추가 
     186            if(!$oDB->isColumnExists("documents", "blamed_count")) { 
     187                $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true);  
     188                $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); 
     189            } 
     190 
     191            if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) { 
     192                $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); 
     193            } 
     194 
     195            if(!$oDB->isColumnExists("document_voted_log", "point"))  
     196            $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true);  
     197                return new Object(0,'success_updated'); 
     198            } 
    202199 
    203200        /** 
     
    206203        function recompileCache() { 
    207204            // 게시글 분류 캐시 파일 삭제 
    208             FileHandler::removeFilesInDir("./files/cache/document_category"); 
     205            FileHandler::removeFilesInDir(_XE_PATH_."files/cache/document_category"); 
    209206        } 
    210207 
  • sandbox/modules/document/document.controller.php

    r4300 r4331  
    763763 
    764764            if(!$category_list) { 
    765                 @unlink($xml_file); 
    766                 @unlink($php_file); 
     765                FileHandler::removeFile($xml_file); 
     766                FileHandler::removeFile($php_file); 
    767767                return false; 
    768768            } 
  • sandbox/modules/document/document.item.php

    r4324 r4331  
    456456                $file_created_time = date("YmdHis",filemtime($thumbnail_file)); 
    457457                $modified_time = $this->get('last_update'); 
    458                 if($modified_time > $file_created_time) @unlink($thumbnail_file); 
     458                if($modified_time > $file_created_time) FileHandler::removeFile($thumbnail_file); 
    459459            } 
    460460 
     
    501501                FileHandler::getRemoteFile($target_src, $tmp_file); 
    502502                FileHandler::createImageFile($tmp_file, $thumbnail_file, $width, $height, 'jpg', $config->thumbnail_type); 
    503                 @unlink($tmp_file); 
     503                FileHandler::removeFile($tmp_file); 
    504504                return Context::getRequestUri().$thumbnail_file; 
    505505            } 
  • sandbox/modules/file/file.controller.php

    r4264 r4331  
    347347 
    348348            // 삭제 성공하면 파일 삭제 
    349             @unlink($uploaded_filename); 
     349            FileHandler::removeFile($uploaded_filename); 
    350350 
    351351            return $output; 
     
    416416 
    417417                // 파일 이동 
    418                 @rename($old_file, $new_file); 
     418                FileHandler::rename($old_file, $new_file); 
    419419 
    420420                // DB 정보도 수정 
  • sandbox/modules/importer/extract.class.php

    r3947 r4331  
    5151         **/ 
    5252        function openFile() { 
    53             @unlink($this->cache_index_file); 
     53            FileHandler::removeFile($this->cache_index_file); 
    5454            $this->index_fd = fopen($this->cache_index_file,"a"); 
    5555 
     
    141141                fwrite($fd, FileHandler::readFile($target_file)); 
    142142 
    143                 @unlink($target_file); 
     143                FileHandler::removeFile($target_file); 
    144144            } 
    145145            fwrite($fd, '</items>'); 
  • sandbox/modules/importer/importer.admin.controller.php

    r4226 r4331  
    191191                // 대상 파일을 읽여서 파싱후 입력 
    192192                $xmlObj = $oXmlParser->loadXmlFile($target_file); 
    193                 @unlink($target_file); 
     193                FileHandler::removeFile($target_file); 
    194194                if(!$xmlObj) continue; 
    195195 
     
    327327                // 대상 파일을 읽여서 파싱후 입력 
    328328                $xmlObj = $oXmlParser->loadXmlFile($target_file); 
    329                 @unlink($target_file); 
     329                FileHandler::removeFile($target_file); 
    330330                if(!$xmlObj) continue; 
    331331 
     
    434434                    $oDocumentController->makeCategoryFile($module_srl); 
    435435                } 
    436                 @unlink($category_file); 
     436                FileHandler::removeFile($category_file); 
    437437            } 
    438438 
     
    559559 
    560560                fclose($fp); 
    561                 @unlink($target_file); 
     561                FileHandler::removeFile($target_file); 
    562562            } 
    563563 
     
    794794                        if(!FileHandler::makeDir($path)) continue; 
    795795 
    796                         if(preg_match('/^\.\/files\/cache\/tmp/i',$file_obj->file)) @rename($file_obj->file, $filename); 
     796                        if(preg_match('/^\.\/files\/cache\/tmp/i',$file_obj->file)) FileHandler::rename($file_obj->file, $filename); 
    797797                        else @copy($file_obj->file, $filename); 
    798798 
  • sandbox/modules/importer/ttimport.class.php

    r4058 r4331  
    5656                    $oDocumentController->makeCategoryFile($module_srl); 
    5757                } 
    58                 @unlink($category_file); 
     58                FileHandler::removeFile($category_file); 
    5959            } 
    6060            $category_list = $category_titles = array(); 
     
    240240 
    241241                fclose($fp); 
    242                 @unlink($target_file); 
     242                FileHandler::removeFile($target_file); 
    243243            } 
    244244 
     
    299299            if(!FileHandler::makeDir($path)) continue; 
    300300 
    301             @rename($file_obj->file, $filename); 
     301            FileHandler::rename($file_obj->file, $filename); 
    302302 
    303303            // DB입력 
  • sandbox/modules/integration_search/integration_search.admin.controller.php

    r3528