git-svn-id: http://xe-core.googlecode.com/svn/trunk@1416 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-05-16 05:47:04 +00:00
parent 1b727a32a1
commit b4ed25f564
4 changed files with 30 additions and 34 deletions

View file

@ -118,14 +118,14 @@
* @brief 로그 남김 * @brief 로그 남김
**/ **/
function actStart($query) { function actStart($query) {
if(__DEBUG__ < 2) return; if(__DEBUG__ < 2 && !defined('__STOP_DEBUG__')) return;
$this->setError(0,'success'); $this->setError(0,'success');
$this->query = $query; $this->query = $query;
$this->act_start = getMicroTime(); $this->act_start = getMicroTime();
} }
function actFinish() { function actFinish() {
if(__DEBUG__ < 2 || !$this->query) return; if(__DEBUG__ < 2 || !$this->query || defined('__STOP_DEBUG__')) return;
$this->act_finish = getMicroTime(); $this->act_finish = getMicroTime();
$elapsed_time = $this->act_finish - $this->act_start; $elapsed_time = $this->act_finish - $this->act_start;
$GLOBALS['__db_elapsed_time__'] += $elapsed_time; $GLOBALS['__db_elapsed_time__'] += $elapsed_time;

View file

@ -19,7 +19,7 @@
* @brief TemplateHandler의 기생성된 객체를 return * @brief TemplateHandler의 기생성된 객체를 return
**/ **/
function &getInstance() { function &getInstance() {
if(__DEBUG__==3) { if(__DEBUG__==3 && !defined('__STOP_DEBUG__')) {
if(!isset($GLOBALS['__TemplateHandlerCalled__'])) $GLOBALS['__TemplateHandlerCalled__']=1; if(!isset($GLOBALS['__TemplateHandlerCalled__'])) $GLOBALS['__TemplateHandlerCalled__']=1;
else $GLOBALS['__TemplateHandlerCalled__']++; else $GLOBALS['__TemplateHandlerCalled__']++;
} }
@ -35,7 +35,7 @@
**/ **/
function compile($tpl_path, $tpl_filename, $tpl_file = '') { 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).'/'; $tpl_path = ereg_replace('(\/+)$', '', $tpl_path).'/';
@ -59,7 +59,7 @@
// Context와 compiled_tpl_file로 컨텐츠 생성 // Context와 compiled_tpl_file로 컨텐츠 생성
$output = $this->_fetch($compiled_tpl_file, $buff); $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; return $output;
} }

View file

@ -11,6 +11,8 @@
var $oMemberController = null; var $oMemberController = null;
var $oDocumentController = null; var $oDocumentController = null;
var $imported_count = 0;
/** /**
* @brief 초기화 * @brief 초기화
**/ **/
@ -82,7 +84,11 @@
* @brief import 실행 * @brief import 실행
**/ **/
function procImporterAdminImport() { function procImporterAdminImport() {
set_time_limit(0); // 실행시간 무한대로 설정
@set_time_limit(0);
// 디버그 메세지의 양이 무척 커지기에 디버그 메세지 생성을 중단
define('__STOP_DEBUG__', true);
// 변수 체크 // 변수 체크
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
@ -95,8 +101,10 @@
$this->oXml = new XmlParser(); $this->oXml = new XmlParser();
// module_srl이 있으면 module데이터로 판단하여 처리, 아니면 회원정보로.. // module_srl이 있으면 module데이터로 판단하여 처리, 아니면 회원정보로..
if($module_srl) return $this->importModule($xml_file, $module_srl, $category_srl); if($module_srl) $this->importModule($xml_file, $module_srl, $category_srl);
return $this->importMember($xml_file); else $this->importMember($xml_file);
$this->setMessage( sprintf(Context::getLang('msg_import_finished'), $this->imported_count) );
} }
/** /**
@ -108,28 +116,21 @@
$this->oMemberController = &getController('member'); $this->oMemberController = &getController('member');
$fp = fopen($xml_file, "r"); $fp = @fopen($xml_file, "r");
$readed_size = 0;
if($fp) { if($fp) {
while(!feof($fp) && $readed_size<=$filesize) { $buff = '';
$str = fgets($fp, 256); while(!feof($fp)) {
$readed_size += strlen($str); $str = fgets($fp,1024);
$buff .= $str; $buff .= $str;
$buff = preg_replace_callback('!<member user_id="([^\"]*)">([^<]*)</member>!is', array($this, '_importMember'), $buff); $buff = preg_replace_callback("!<member user_id=\"([^\"]*)\">(.*?)<\/member>!is", array($this, '_importMember'), $buff);
if(eregi('</root>', $str)) break;
} }
fclose($fp); fclose($fp);
} }
return new Object(0,'msg_import_finished');
} }
function _importMember($matches) { function _importMember($matches) {
$user_id = $matches[1]; $user_id = $matches[1];
$buff = sprintf('<member>%s</member>',base64_decode($matches[2])); $xml_doc = $this->oXml->parse($matches[0]);
$xml_doc = $this->oXml->parse($buff);
$args->user_id = $xml_doc->member->user_id->body; $args->user_id = $xml_doc->member->user_id->body;
$args->user_name = $xml_doc->member->user_name->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_mailing = $xml_doc->member->allow_mailing->body;
$args->allow_message = 'Y'; $args->allow_message = 'Y';
$output = $this->oMemberController->insertMember($args); $output = $this->oMemberController->insertMember($args);
if($output->toBool()) { if($output->toBool()) {
$member_srl = $output->get('member_srl'); $member_srl = $output->get('member_srl');
if($xml_doc->member->image_nickname->body) { if($xml_doc->member->image_nickname->body) {
$image_nickname = base64_decode($xml_doc->member->image_nickname->body); $image_nickname = base64_decode($xml_doc->member->image_nickname->body);
$fp = fopen('./files/cache/tmp_imagefile','w'); FileHandler::writeFile('./files/cache/tmp_imagefile', $image_nickname);
fwrite($fp, $image_nickname);
fclose($fp);
$this->oMemberController->insertImageName($member_srl, './files/cache/tmp_imagefile'); $this->oMemberController->insertImageName($member_srl, './files/cache/tmp_imagefile');
@unlink('./files/cache/tmp_imagefile');
} }
if($xml_doc->member->image_mark->body) { if($xml_doc->member->image_mark->body) {
$image_mark = base64_decode($xml_doc->member->image_mark->body); $image_mark = base64_decode($xml_doc->member->image_mark->body);
$fp = fopen('./files/cache/tmp_imagefile','w'); FileHandler::writeFile('./files/cache/tmp_imagefile', $image_mark);
fwrite($fp, $image_mark);
fclose($fp);
$this->oMemberController->insertImageMark($member_srl, './files/cache/tmp_imagefile'); $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) { if($xml_doc->member->signature->body) {
$oMemberController->putSignature($member_srl, $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 ''; return '';
} }

View file

@ -36,7 +36,7 @@
$lang->msg_sync_member = '동기화 버튼을 클릭하시면 회원정보와 게시물정보의 동기화를 시작합니다.'; $lang->msg_sync_member = '동기화 버튼을 클릭하시면 회원정보와 게시물정보의 동기화를 시작합니다.';
$lang->msg_no_xml_file = 'XML파일을 찾을 수 없습니다. 경로를 다시 확인해주세요'; $lang->msg_no_xml_file = 'XML파일을 찾을 수 없습니다. 경로를 다시 확인해주세요';
$lang->msg_invalid_xml_file = '잘못된 형식의 XML파일입니다'; $lang->msg_invalid_xml_file = '잘못된 형식의 XML파일입니다';
$lang->msg_import_finished = '데이터 입력이 완료되었습니다. 상황에 따라 입력되지 못한 데이터가 있을 수 있습니다.'; $lang->msg_import_finished = '%d개의 데이터 입력이 완료되었습니다. 상황에 따라 입력되지 못한 데이터가 있을 수 있습니다.';
// 주절 주절.. // 주절 주절..
$lang->about_type_member = '데이터 이전 대상이 회원정보일 경우 선택해주세요'; $lang->about_type_member = '데이터 이전 대상이 회원정보일 경우 선택해주세요';