From b4ed25f564d0bc7da5f5c1b60fb3e0a4d80e48a5 Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 16 May 2007 05:47:04 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@1416 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/db/DB.class.php | 4 +- classes/template/TemplateHandler.class.php | 6 +-- modules/importer/importer.controller.php | 52 ++++++++++------------ modules/importer/lang/ko.lang.php | 2 +- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index 2940370d0..1bee58895 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -118,14 +118,14 @@ * @brief 로그 남김 **/ function actStart($query) { - if(__DEBUG__ < 2) return; + if(__DEBUG__ < 2 && !defined('__STOP_DEBUG__')) return; $this->setError(0,'success'); $this->query = $query; $this->act_start = getMicroTime(); } function actFinish() { - if(__DEBUG__ < 2 || !$this->query) return; + if(__DEBUG__ < 2 || !$this->query || defined('__STOP_DEBUG__')) return; $this->act_finish = getMicroTime(); $elapsed_time = $this->act_finish - $this->act_start; $GLOBALS['__db_elapsed_time__'] += $elapsed_time; diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index 6e70e0170..3f19e3dbe 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -19,7 +19,7 @@ * @brief TemplateHandler의 기생성된 객체를 return **/ function &getInstance() { - if(__DEBUG__==3) { + if(__DEBUG__==3 && !defined('__STOP_DEBUG__')) { if(!isset($GLOBALS['__TemplateHandlerCalled__'])) $GLOBALS['__TemplateHandlerCalled__']=1; else $GLOBALS['__TemplateHandlerCalled__']++; } @@ -35,7 +35,7 @@ **/ function compile($tpl_path, $tpl_filename, $tpl_file = '') { // 디버그를 위한 컴파일 시작 시간 저장 - if(__DEBUG__==3) $start = getMicroTime(); + if(__DEBUG__==3 && !defined('__STOP_DEBUG__') ) $start = getMicroTime(); // 변수 체크 $tpl_path = ereg_replace('(\/+)$', '', $tpl_path).'/'; @@ -59,7 +59,7 @@ // Context와 compiled_tpl_file로 컨텐츠 생성 $output = $this->_fetch($compiled_tpl_file, $buff); - if(__DEBUG__==3) $GLOBALS['__template_elapsed__'] += getMicroTime() - $start; + if(__DEBUG__==3 && !defined('__STOP_DEBUG__')) $GLOBALS['__template_elapsed__'] += getMicroTime() - $start; return $output; } diff --git a/modules/importer/importer.controller.php b/modules/importer/importer.controller.php index c20897157..779c89f72 100644 --- a/modules/importer/importer.controller.php +++ b/modules/importer/importer.controller.php @@ -11,6 +11,8 @@ var $oMemberController = null; var $oDocumentController = null; + var $imported_count = 0; + /** * @brief 초기화 **/ @@ -82,7 +84,11 @@ * @brief import 실행 **/ function procImporterAdminImport() { - set_time_limit(0); + // 실행시간 무한대로 설정 + @set_time_limit(0); + + // 디버그 메세지의 양이 무척 커지기에 디버그 메세지 생성을 중단 + define('__STOP_DEBUG__', true); // 변수 체크 $module_srl = Context::get('module_srl'); @@ -95,8 +101,10 @@ $this->oXml = new XmlParser(); // module_srl이 있으면 module데이터로 판단하여 처리, 아니면 회원정보로.. - if($module_srl) return $this->importModule($xml_file, $module_srl, $category_srl); - return $this->importMember($xml_file); + if($module_srl) $this->importModule($xml_file, $module_srl, $category_srl); + else $this->importMember($xml_file); + + $this->setMessage( sprintf(Context::getLang('msg_import_finished'), $this->imported_count) ); } /** @@ -108,28 +116,21 @@ $this->oMemberController = &getController('member'); - $fp = fopen($xml_file, "r"); - $readed_size = 0; + $fp = @fopen($xml_file, "r"); if($fp) { - while(!feof($fp) && $readed_size<=$filesize) { - $str = fgets($fp, 256); - $readed_size += strlen($str); - + $buff = ''; + while(!feof($fp)) { + $str = fgets($fp,1024); $buff .= $str; - $buff = preg_replace_callback('!([^<]*)!is', array($this, '_importMember'), $buff); - - if(eregi('', $str)) break; + $buff = preg_replace_callback("!(.*?)<\/member>!is", array($this, '_importMember'), $buff); } fclose($fp); } - - return new Object(0,'msg_import_finished'); } function _importMember($matches) { $user_id = $matches[1]; - $buff = sprintf('%s',base64_decode($matches[2])); - $xml_doc = $this->oXml->parse($buff); + $xml_doc = $this->oXml->parse($matches[0]); $args->user_id = $xml_doc->member->user_id->body; $args->user_name = $xml_doc->member->user_name->body; @@ -142,32 +143,27 @@ $args->allow_mailing = $xml_doc->member->allow_mailing->body; $args->allow_message = 'Y'; $output = $this->oMemberController->insertMember($args); - if($output->toBool()) { $member_srl = $output->get('member_srl'); if($xml_doc->member->image_nickname->body) { $image_nickname = base64_decode($xml_doc->member->image_nickname->body); - $fp = fopen('./files/cache/tmp_imagefile','w'); - fwrite($fp, $image_nickname); - fclose($fp); - + FileHandler::writeFile('./files/cache/tmp_imagefile', $image_nickname); $this->oMemberController->insertImageName($member_srl, './files/cache/tmp_imagefile'); + @unlink('./files/cache/tmp_imagefile'); } if($xml_doc->member->image_mark->body) { $image_mark = base64_decode($xml_doc->member->image_mark->body); - $fp = fopen('./files/cache/tmp_imagefile','w'); - fwrite($fp, $image_mark); - fclose($fp); - + FileHandler::writeFile('./files/cache/tmp_imagefile', $image_mark); $this->oMemberController->insertImageMark($member_srl, './files/cache/tmp_imagefile'); + @unlink('./files/cache/tmp_imagefile'); } - @unlink('./files/cache/tmp_imagefile'); if($xml_doc->member->signature->body) { $oMemberController->putSignature($member_srl, $xml_doc->member->signature->body); } - } - usleep(100); + $this->imported_count ++; + if(!$this->imported_count%500) usleep(200); + } return ''; } diff --git a/modules/importer/lang/ko.lang.php b/modules/importer/lang/ko.lang.php index 702e47fae..91e13d0e2 100644 --- a/modules/importer/lang/ko.lang.php +++ b/modules/importer/lang/ko.lang.php @@ -36,7 +36,7 @@ $lang->msg_sync_member = '동기화 버튼을 클릭하시면 회원정보와 게시물정보의 동기화를 시작합니다.'; $lang->msg_no_xml_file = 'XML파일을 찾을 수 없습니다. 경로를 다시 확인해주세요'; $lang->msg_invalid_xml_file = '잘못된 형식의 XML파일입니다'; - $lang->msg_import_finished = '데이터 입력이 완료되었습니다. 상황에 따라 입력되지 못한 데이터가 있을 수 있습니다.'; + $lang->msg_import_finished = '%d개의 데이터 입력이 완료되었습니다. 상황에 따라 입력되지 못한 데이터가 있을 수 있습니다.'; // 주절 주절.. $lang->about_type_member = '데이터 이전 대상이 회원정보일 경우 선택해주세요';