diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index 6191596d1..7e8c79af1 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -324,7 +324,7 @@ } if(strpos($name,'.')!==false&&strpos($value,'.')!==false) { - list($column_name) = explode('.',$value); + list($table_name, $column_name) = explode('.',$value); if($column_type[$column_name]) return $value; } diff --git a/modules/importer/conf/info.xml b/modules/importer/conf/info.xml index 9e1e4c849..5c005e528 100644 --- a/modules/importer/conf/info.xml +++ b/modules/importer/conf/info.xml @@ -1,12 +1,12 @@ - + 제로보드 데이터 이전 Zeroboard data transferation 数据导入 ZBデータ移転 Transferencia de los datos de ZeroBoard Трансферинг данных Zeroboard - + 제로 Zero zero diff --git a/modules/importer/conf/module.xml b/modules/importer/conf/module.xml index b36dd8932..290cacd22 100644 --- a/modules/importer/conf/module.xml +++ b/modules/importer/conf/module.xml @@ -3,9 +3,8 @@ - - - + + diff --git a/modules/importer/importer.admin.controller.php b/modules/importer/importer.admin.controller.php index b86566e53..df0443e03 100644 --- a/modules/importer/importer.admin.controller.php +++ b/modules/importer/importer.admin.controller.php @@ -7,26 +7,14 @@ class importerAdminController extends importer { - var $oXml = null; var $oMemberController = null; var $oMemberModel = null; - var $oDocumentController = null; - var $oFileController = null; - var $oCommentController = null; - var $oTrackbackController = null; - - var $total_count = ''; - var $start_position = 0; - var $position = 0; - var $limit_count = 50; - var $file_point = 0; var $default_group_srl = 0; - var $module_srl = 0; - var $target_path = 0; - var $category_srl = 0; - var $category_list = array(); - var $msg = null; + var $oDocumentController = null; + var $oDocumentModel = null; + var $oCommentController = null; + var $oTrackbackController = null; /** * @brief 초기화 @@ -34,427 +22,12 @@ function init() { } - /** - * @brief import step1 - * import하려는 대상에 따라 결과값을 구해서 return - * 회원정보 : next_step=2, module_list = null - * 모듈정보 : next_step=12, module_list = modules.. - * 회원정보 동기화 : next_step=3 - **/ - function procImporterAdminStep1() { - $source_type = Context::get('source_type'); - switch($source_type) { - case 'module' : - // 모듈 목록을 구함 - $oModuleModel = &getModel('module'); - $module_list = $oModuleModel->getMidList(); - foreach($module_list as $key => $val) { - $module_list_arr[] = sprintf('%d,%s (%s)', $val->module_srl, $val->browser_title, $val->mid); - } - if(count($module_list_arr)) $module_list = implode("\n",$module_list_arr); - $next_step = 12; - break; - case 'member' : - $next_step = 2; - break; - case 'syncmember' : - $next_step = 3; - break; - } - - $this->add('next_step', $next_step); - $this->add('module_list', $module_list); - } - - /** - * @brief import step12 - * module_srl을 이용하여 대상 모듈에 카테고리값이 있는지 확인하여 - * 있으면 카테고리 정보를 return, 아니면 파일 업로드 단계로 이동 - **/ - function procImporterAdminStep12() { - $target_module= Context::get('target_module'); - - // 대상 모듈의 카테고리 목록을 구해옴 - $oDocumentModel = &getModel('document'); - $category_list = $oDocumentModel->getCategoryList($target_module); - - if(count($category_list)) { - foreach($category_list as $key => $val) { - $category_list_arr[] = sprintf('%d,%s', $val->category_srl, $val->title); - } - if(count($category_list_arr)) { - $category_list = implode("\n",$category_list_arr); - $next_step = 13; - } - } else { - $category_list = null; - $next_step = 2; - } - - $this->add('next_step', $next_step); - $this->add('category_list', $category_list); - } - - /** - * @brief import 실행 - **/ - function procImporterAdminImport() { - // 실행시간 무한대로 설정 - @set_time_limit(0); - - // 변수 체크 - $this->module_srl = Context::get('module_srl'); - $this->target_path = Context::get('target_path'); - if(substr($this->target_path,-1)!="/") $this->target_path .= "/"; - $this->category_srl = Context::get('category_srl'); - $xml_file = Context::get('xml_file'); - $this->start_position = $this->position = (int)Context::get('position'); - $this->total_count = (int)Context::get('total_count'); - $this->file_point = (int)Context::get('file_point'); - - // 파일을 찾을 수 없으면 에러 표시 - if(!file_exists($xml_file)) return new Object(-1,'msg_no_xml_file'); - - $this->oXml = new XmlParser(); - - $oDB = &DB::getInstance(); - $oDB->begin(); - - // module_srl이 있으면 module데이터로 판단하여 처리, 아니면 회원정보로.. - if($this->module_srl) { - $this->limit_count = 100; - $is_finished = $this->importDocument($xml_file); - } else { - $this->limit_count = 500; - $is_finished = $this->importMember($xml_file); - } - - $oDB->commit(); - - if($is_finished) { - $this->add('is_finished', 'Y'); - $this->add('position', $this->total_count); - $this->add('total_count', $this->total_count); - $this->setMessage( sprintf(Context::getLang('msg_import_finished'), $this->position) ); - } else { - $this->add('position', $this->position); - $this->add('total_count', $this->total_count); - $this->add('file_point', $this->file_point); - $this->add('is_finished', 'N'); - - $this->setMessage( $this->msg ); - } - } - - /** - * @brief 회원정보 import - **/ - function importMember($xml_file) { - $filesize = filesize($xml_file); - if($filesize<1) return true; - - $this->oMemberController = &getController('member'); - $this->oMemberModel = &getModel('member'); - - $default_group = $this->oMemberModel->getDefaultGroup(); - $this->default_group_srl = $default_group->group_srl; - - $is_finished = true; - - $fp = @fopen($xml_file, "r"); - if($this->file_point) fseek($fp, $this->file_point, SEEK_SET); - if($fp) { - $buff = ''; - while(!feof($fp)) { - $str = fgets($fp,1024); - $buff .= $str; - - $buff = preg_replace_callback("!]*)>!is", array($this, '_parseRootInfo'), $buff); - $buff = preg_replace_callback("!(.*?)<\/member>!is", array($this, '_importMember'), $buff); - - if($this->start_position+$this->limit_count <= $this->position) { - $is_finished = false; - $this->file_point = ftell($fp) - strlen($buff);; - break; - } - } - fclose($fp); - } - - return $is_finished; - } - - function _importMember($matches) { - $user_id = $matches[1]; - $xml_doc = $this->oXml->parse($matches[0]); - - $args->user_id = strtolower($xml_doc->member->user_id->body); - $args->user_name = $xml_doc->member->user_name->body; - $args->nick_name = $xml_doc->member->nick_name->body; - $args->homepage = $xml_doc->member->homepage->body; - $args->blog = $xml_doc->member->blog->body; - if($args->homepage && !eregi("^http:\/\/",$args->homepage)) $args->homepage = 'http://'.$args->homepage; - if($args->blog && !eregi("^http:\/\/",$args->blog)) $args->blog = 'http://'.$args->blog; - $args->birthday = $xml_doc->member->birthday->body; - $args->email_address = $xml_doc->member->email_address->body; - list($args->email_id, $args->email_host) = explode('@', $args->email_address); - if(!$args->email_host) $args->email_host = $args->email_id; - $args->password = $xml_doc->member->password->body; - $args->regdate = $xml_doc->member->regdate->body; - $args->allow_mailing = $xml_doc->member->allow_mailing->body; - if($args->allow_mailing!='Y') $args->allow_mailing = 'N'; - $args->allow_message = 'Y'; - if(!in_array($args->allow_message, array('Y','N','F'))) $args->allow_message= 'Y'; - - $args->member_srl = getNextSequence(); - $output = executeQuery('member.insertMember', $args); - - if(!$output->toBool()) { - // 닉네임이 같으면 닉네임을 변경후 재 입력 - $member_srl = $this->oMemberModel->getMemberSrlByNickName($args->nick_name); - if($member_srl) { - $args->nick_name .= rand(111,999); - $output = executeQuery('member.insertMember', $args); - } - } - - if($output->toBool()) { - - // 기본 그룹 가입 시킴 - $member_srl = $args->member_srl; - $args->group_srl = $this->default_group_srl; - executeQuery('member.addMemberToGroup',$args); - - // 이미지네임 - if($xml_doc->member->image_nickname->body) { - $image_nickname = base64_decode($xml_doc->member->image_nickname->body); - - $target_path = sprintf('files/member_extra_info/image_name/%s/', getNumberingPath($args->member_extra_info)); - $target_filename = sprintf('%s%d.gif', $target_path, $args->member_srl); - - FileHandler::makeDir($target_path); - FileHandler::writeFile($target_filename, $image_nickname); - } - - // 이미지 마크 - if($xml_doc->member->image_mark->body) { - $image_mark = base64_decode($xml_doc->member->image_mark->body); - - $target_path = sprintf('files/member_extra_info/image_mark/%s/', getNumberingPath($args->member_srl)); - $target_filename = sprintf('%s%d.gif', $target_path, $args->member_srl); - - FileHandler::makeDir($target_path); - FileHandler::writeFile($target_filename, $image_mark); - } - - // 서명 - if(trim($xml_doc->member->signature->body)) { - $signature = removeHackTag(base64_decode($xml_doc->member->signature->body)); - $signature_buff = sprintf('%s', $signature); - - $target_path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($args->member_srl)); - $target_filename = sprintf('%s%d.signature.php', $target_path, $args->member_srl); - - FileHandler::makeDir($target_path); - FileHandler::writeFile($target_filename, $signature_buff); - } - } else { - $this->msg .= $args->user_id." : ".$output->getMessage()."
"; - } - - $this->position++; - - return ''; - } - - /** - * @brief 게시물정보 import - **/ - function importDocument($xml_file) { - $filesize = filesize($xml_file); - if($filesize<1) return; - - $this->oDocumentController = &getController('document'); - $this->oFileController = &getController('file'); - $this->oCommentController = &getController('comment'); - $this->oTrackbackController = &getController('trackback'); - - $oDocumentModel = &getModel('document'); - $tmp_category_list = $oDocumentModel->getCategoryList($this->module_srl); - if(count($tmp_category_list)) { - foreach($tmp_category_list as $key => $val) $this->category_list[$val->title] = $key; - } else { - $this->category_list = array(); - } - - $is_finished = true; - - $fp = @fopen($xml_file, "r"); - if($this->file_point) fseek($fp, $this->file_point, SEEK_SET); - if($fp) { - $buff = ''; - while(!feof($fp)) { - $str = fread($fp,1024); - $buff .= $str; - $buff = preg_replace_callback("!]*)>!is", array($this, '_parseRootInfo'), $buff); - if(!$this->category_srl) $buff = preg_replace_callback("!(.*?)!is", array($this, '_parseCategoryInfo'), $buff); - $buff = preg_replace_callback("!(.*?)<\/document>!is", array($this, '_importDocument'), $buff); - - if($this->start_position+$this->limit_count <= $this->position) { - $is_finished = false; - $this->file_point = ftell($fp) - strlen($buff);; - break; - } - } - fclose($fp); - } - - return $is_finished; - } - - function _importDocument($matches) { - $sequence = $matches[1]; - $matches[0] = str_replace(array('',''),'',$matches[0]); - $xml_doc = $this->oXml->parse($matches[0]); - - // 문서 번호와 내용 미리 구해 놓기 - $args->document_srl = getNextSequence(); - $args->content = $xml_doc->document->content->body; - - // 첨부파일 미리 등록 - $files = $xml_doc->document->files->file; - if($files && !is_array($files)) $files = array($files); - if(count($files)) { - foreach($files as $key => $val) { - $filename = $val->filename->body; - $path = $val->path->body; - $download_count = (int)$val->download_count->body; - - $tmp_filename = './files/cache/tmp_uploaded_file'; - - $path = $this->target_path.$path; - - if(!eregi("^http",$path)) { - if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) { - $tmp_path = iconv("UTF-8","EUC-KR",$path); - if(file_exists($tmp_path)) $path = $tmp_path; - } - if(file_exists($path)) @copy($path, $tmp_filename); - - } else FileHandler::getRemoteFile($path, $tmp_filename); - - if(file_exists($tmp_filename)) { - $file_info['tmp_name'] = $tmp_filename; - $file_info['name'] = $filename; - $this->oFileController->insertFile($file_info, $this->module_srl, $args->document_srl, $download_count, true); - - // 컨텐츠의 내용 수정 (이미지 첨부파일 관련) - if(eregi("\.(jpg|gif|jpeg|png)$", $filename)) $args->content = str_replace($filename, sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $args->document_srl, $filename), $args->content); - } - @unlink($tmp_filename); - } - } - - // 문서 입력 - $args->module_srl = $this->module_srl; - if($this->category_srl) $args->category_srl = $this->category_srl; - elseif($xml_doc->document->category->body) $args->category_srl = $this->category_list[$xml_doc->document->category->body]; - $args->is_notice = $xml_doc->document->is_notice->body; - $args->is_secret = $xml_doc->document->is_secret->body; - $args->title = $xml_doc->document->title->body; - $args->readed_count = $xml_doc->document->readed_count->body; - $args->voted_count = $xml_doc->document->voted_count->body; - $args->comment_count = $xml_doc->document->comment_count->body; - $args->trackback_count = $xml_doc->document->trackback_count->body; - $args->uploaded_count = $xml_doc->document->uploaded_count->body; - $args->password = $xml_doc->document->password->body; - $args->nick_name = $xml_doc->document->nick_name->body; - $args->member_srl = 0; - $args->user_id = $xml_doc->document->user_id->body; - $args->user_name = $xml_doc->document->user_name->body; - $args->email_address = $xml_doc->document->email_address->body; - $args->homepage = $xml_doc->document->homepage->body; - $args->tags = $xml_doc->document->tags->body; - $args->regdate = $xml_doc->document->regdate->body; - $args->ipaddress = $xml_doc->document->ipaddress->body; - $args->allow_comment = $xml_doc->document->allow_comment->body; - $args->lock_comment = $xml_doc->document->lock_comment->body; - $args->allow_trackback = $xml_doc->document->allow_trackback->body; - $args->extra_vars1 = $xml_doc->document->extra_vars1->body; - $args->extra_vars2 = $xml_doc->document->extra_vars2->body; - $args->extra_vars3 = $xml_doc->document->extra_vars3->body; - $args->extra_vars4 = $xml_doc->document->extra_vars4->body; - $args->extra_vars5 = $xml_doc->document->extra_vars5->body; - $args->extra_vars6 = $xml_doc->document->extra_vars6->body; - $args->extra_vars7 = $xml_doc->document->extra_vars7->body; - $args->extra_vars8 = $xml_doc->document->extra_vars8->body; - $args->extra_vars9 = $xml_doc->document->extra_vars9->body; - $args->extra_vars10 = $xml_doc->document->extra_vars10->body; - $args->extra_vars11 = $xml_doc->document->extra_vars11->body; - $args->extra_vars12 = $xml_doc->document->extra_vars12->body; - $args->extra_vars13 = $xml_doc->document->extra_vars13->body; - $args->extra_vars14 = $xml_doc->document->extra_vars14->body; - $args->extra_vars15 = $xml_doc->document->extra_vars15->body; - $args->extra_vars16 = $xml_doc->document->extra_vars16->body; - $args->extra_vars17 = $xml_doc->document->extra_vars17->body; - $args->extra_vars18 = $xml_doc->document->extra_vars18->body; - $args->extra_vars19 = $xml_doc->document->extra_vars19->body; - $args->extra_vars20 = $xml_doc->document->extra_vars20->body; - - $output = $this->oDocumentController->insertDocument($args, true); - if($output->toBool()) { - - // 코멘트 입력 - $comments = $xml_doc->document->comments->comment; - if($comments && !is_array($comments)) $comments = array($comments); - if(count($comments)) { - foreach($comments as $key => $val) { - $comment_args->document_srl = $args->document_srl; - $comment_args->comment_srl = getNextSequence(); - $comment_args->module_srl = $this->module_srl; - //$comment_args->parent_srl = $val->parent_srl->body; - $comment_args->parent_srl = 0; - $comment_args->content = $val->content->body; - $comment_args->password = $val->password->body; - $comment_args->nick_name = $val->nick_name->body; - $comment_args->user_id = $val->user_id->body; - $comment_args->user_name = $val->user_name->body; - $comment_args->member_srl = 0; - $comment_args->email_address = $val->email_address->body; - $comment_args->regdate = $val->regdate->body; - $comment_args->ipaddress = $val->ipaddress->body; - $this->oCommentController->insertComment($comment_args, true); - } - } - - // 트랙백 입력 - $trackbacks = $xml_doc->document->trackbacks->trackback; - if($trackbacks && !is_array($trackbacks)) $trackbacks = array($trackbacks); - if(count($trackbacks)) { - foreach($trackbacks as $key => $val) { - $trackback_args->document_srl = $args->document_srl; - $trackback_args->module_srl = $this->module_srl; - $trackback_args->url = $val->url->body; - $trackback_args->title = $val->title->body; - $trackback_args->blog_name = $val->blog_name->body; - $trackback_args->excerpt = $val->excerpt->body; - $trackback_args->regdate = $val->regdate->body; - $trackback_args->ipaddress = $val->ipaddress->body; - $this->oTrackbackController->insertTrackback($trackback_args, true); - } - } - } else { - $this->msg .= $sequence." : ".$output->getMessage()."
"; - } - - $this->position++; - return ''; - } - /** * @brief 회원정보와 게시물 정보를 싱크 **/ function procImporterAdminSync() { + set_time_limit(0); + // 게시물정보 싱크 $output = executeQuery('importer.updateDocumentSync'); @@ -465,34 +38,667 @@ } /** - * @brief 정보를 읽어서 정보를 구함 + * @brief 회원xml 파일을 분석해서 import **/ - function _parseRootInfo($matches) { - $root = $matches[0].''; - $xml_doc = $this->oXml->parse($root); - $this->total_count = $xml_doc->root->attrs->count; + function procImporterAdminMemberImport() { + set_time_limit(0); + + $xml_file = Context::get('xml_file'); + $total_count = (int)Context::get('total_count'); + $success_count = (int)Context::get('success_count'); + $readed_line = (int)Context::get('readed_line'); + + // xml_file 경로가 없으면 에러~ + if(!$xml_file) return new Object(-1, 'msg_no_xml_file'); + + // local 파일 지정인데 파일이 없으면 역시 에러~ + if(!eregi('^http:',$xml_file) && (!eregi("\.xml$", $xml_file) || !file_exists($xml_file)) ) return new Object(-1,'msg_no_xml_file'); + + // 이제부터 데이터를 가져오면서 처리 + $fp = $this->getFilePoint($xml_file); + if(!$fp) return new Object(-1,'msg_no_xml_file'); + + // 회원 입력을 위한 기본 객체들 생성 + $this->oMemberController = &getController('member'); + $this->oMemberModel = &getModel('member'); + + // 기본 회원 그룹을 구함 + $default_group = $this->oMemberModel->getDefaultGroup(); + $this->default_group_srl = $default_group->group_srl; + + $obj = null; + $extra_var = null; + $is_extra_var = false; + + $inserted_count = 0; + + // 본문 데이터부터 처리 시작 + $read_line = 0; + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + + if($str == "
") $read_line ++; + if($read_line < $readed_line) continue; + + // 한 아이템 준비 시작 + if($str == '') { + $obj = $extra_var = null; + $is_extra_var = false; + continue; + + // 추가 변수 시자r 일 경우 + } elseif($str == '') { + $is_extra_var = true; + + // 추가 변수 종료 일 경우 + } elseif($str == '') { + $is_extra_var = false; + $obj->extra_vars = $extra_var; + + // 아이템 종료시 DB 입력 + } else if( $str == '') { + if($this->importMember($obj)) $inserted_count ++; + if($inserted_count >= 300) { + $manual_break = true; + break; + } + + // members 태그 체크 (전체 개수를 구함) + } else if(substr($str,0,8)=='') { + break; + + // 이미지 마크, 이미지이름, 프로필 사진일 경우 + } else if(in_array($str, array('','',''))) { + + // binary buffer일 경우 임의의 위치에 파일을 저장시켜 놓고 그 파일의 경로를 return + $key = substr($str,1,strlen($str)-2); + $filename = $this->readFileBuff($fp, $key); + $obj->{$key} = $filename; + + // 변수 체크 + } else { + $buff .= $str; + $pos = strpos($buff, '>'); + $key = substr($buff, 1, $pos-1); + if(substr($buff, -1 * ( strlen($key)+3)) == '') { + $val = base64_decode(substr($buff, $pos, strlen($buff)-$pos*2-2)); + if($is_extra_var) $extra_var->{$key} = $val; + else $obj->{$key} = $val; + $buff = null; + } + } + } + + fclose($fp); + + $success_count += $inserted_count; + + if($manual_break) { + $this->add('total_count',$total_count); + $this->add('success_count',$success_count); + $this->add('readed_line',$read_line); + $this->add('is_finished','0'); + $this->setMessage(sprintf(Context::getLang('msg_importing'), $total_count, $success_count)); + } else { + $this->add('is_finished','1'); + $this->setMessage(sprintf(Context::getLang('msg_import_finished'), $success_count, $total_count)); + } } /** - * @brief 정보를 읽어서 정보를 구함 + * @brief 주어진 xml 파일을 파싱해서 회원 정보 입력 **/ - function _parseCategoryInfo($matches) { - $xml_doc = $this->oXml->parse($matches[0]); + function importMember($obj) { + // homepage, blog의 url을 정확히 만듬 + if($obj->homepage && !eregi("^http:\/\/",$obj->homepage)) $obj->homepage = 'http://'.$obj->homepage; + if($obj->blog && !eregi("^http:\/\/",$obj->blog)) $obj->blog = 'http://'.$obj->blog; - $category_list = $xml_doc->categories->category; - if(!$category_list) return; + $obj->email_address = $obj->email; + list($obj->email_id, $obj->email_host) = explode('@', $obj->email); - if(!is_array($category_list)) $category_list = array($category_list); + if($obj->allow_mailing!='Y') $obj->allow_mailing = 'N'; - $oDocumentController = &getAdminController('document'); + $obj->allow_message = 'Y'; + if(!in_array($obj->allow_message, array('Y','N','F'))) $obj->allow_message= 'Y'; - foreach($category_list as $key => $val) { - $title = $val->body; - if($this->category_list[$title]) continue; + $obj->member_srl = getNextSequence(); - $output = $oDocumentController->insertCategory($this->module_srl, $title); - $this->category_list[$title] = $output->get('category_srl'); + $extra_vars = $obj->extra_vars; + unset($obj->extra_vars); + $obj->extra_vars = serialize($extra_vars); + + $output = executeQuery('member.insertMember', $obj); + + // 입력실패시 닉네임 중복인지 확인 + if(!$output->toBool()) { + + // 닉네임 중복이라면 닉네임을 바꾸어서 입력 + $nick_args->nick_name = $obj->nick_name; + $nick_output = executeQuery('member.getMemberSrl', $nick_args); + if($nick_ouptut->data->member_srl) { + $obj->nick_name .= rand(111,999); + $output = executeQuery('member.insertMember', $obj); + } } + + // 입력 성공시 + if($output->toBool()) { + + // 기본 그룹 가입 시킴 + $obj->group_srl = $this->default_group_srl; + executeQuery('member.addMemberToGroup',$obj); + + // 이미지네임 + if($obj->image_nickname && file_exists($obj->image_nickname)) { + $target_path = sprintf('files/member_extra_info/image_name/%s/', getNumberingPath($obj->member_srl)); + $target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl); + @rename($obj->image_nickname, $target_filename); + } + + // 이미지마크 + if($obj->image_mark && file_exists($obj->image_mark)) { + $target_path = sprintf('files/member_extra_info/image_mark/%s/', getNumberingPath($obj->member_srl)); + if(!is_dir($target_path)) FileHandler::makeDir($target_path); + $target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl); + @rename($obj->image_mark, $target_filename); + } + + // 프로필 이미지 + if($obj->profile_image && file_exists($obj->profile_image)) { + $target_path = sprintf('files/member_extra_info/profile_image/%s/', getNumberingPath($obj->member_srl)); + if(!is_dir($target_path)) FileHandler::makeDir($target_path); + $target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl); + @rename($obj->profile_image, $target_filename); + } + + // 서명 + if($obj->signature) { + $signature = removeHackTag($obj->signature); + $signature_buff = sprintf('%s', $signature); + + $target_path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($obj->member_srl)); + if(!is_dir($target_path)) FileHandler::makeDir($target_path); + $target_filename = sprintf('%s%d.signature.php', $target_path, $obj->member_srl); + + FileHandler::writeFile($target_filename, $signature_buff); + } + return true; + } + + return false; + } + + function procImporterAdminModuleImport() { + set_time_limit(0); + + $xml_file = Context::get('xml_file'); + $target_module = Context::get('target_module'); + $total_count = (int)Context::get('total_count'); + $success_count = (int)Context::get('success_count'); + $readed_line = (int)Context::get('readed_line'); + + // xml_file 경로가 없으면 에러~ + if(!$xml_file) return new Object(-1, 'msg_no_xml_file'); + + // local 파일 지정인데 파일이 없으면 역시 에러~ + if(!eregi('^http:',$xml_file) && (!eregi("\.xml$", $xml_file) || !file_exists($xml_file)) ) return new Object(-1,'msg_no_xml_file'); + + // 필요한 객체 미리 생성 + $this->oDocumentController = &getController('document'); + $this->oDocumentModel = &getModel('document'); + $this->oCommentController = &getController('comment'); + $this->oTrackbackController = &getController('trackback'); + + // 타켓 모듈의 유무 체크 + if(!$target_module) return new Object(-1,'msg_invalid_request'); + $module_srl = $target_module; + + // 타겟 모듈의 카테고리 정보 구함 + $category_list = $this->oDocumentModel->getCategoryList($module_srl); + if(count($category_list)) { + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; + } else { + $category_list = $category_titles = array(); + } + + // 이제부터 데이터를 가져오면서 처리 + $fp = $this->getFilePoint($xml_file); + if(!$fp) return new Object(-1,'msg_no_xml_file'); + + $manual_break = false; + $obj = null; + $document_srl = null; + + $inserted_count = 0; + + // 본문 데이터부터 처리 시작 + $read_line = 0; + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + + if($str == "") $read_line ++; + if($read_line < $readed_line) continue; + + // 한 아이템 준비 시작 + if(substr($str,0,6) == '') { + $obj = null; + $obj->module_srl = $module_srl; + $obj->document_srl = getNextSequence(); + continue; + + // 아이템 종료시 DB 입력 + } else if( $str == '') { + if($this->importDocument($obj)) $inserted_count ++; + if($inserted_count >= 50) { + $manual_break = true; + break; + } + + // posts 태그 체크 (전체 개수를 구함) + } else if(substr($str,0,6)=='') { + $manual_break = false; + break; + + // 카테고리 입력 + } else if($str == '') { + $this->importCategoris($fp, $module_srl, $category_list, $category_titles); + continue; + + // 엮인글 입력 + } else if(substr($str,0,11) == 'trackbacks = $this->importTrackbacks($fp); + + // 댓글 입력 + } else if(substr($str,0,9) == 'comments = $this->importComments($fp); + + // 첨부파일 입력 + } else if(substr($str,0,9) == 'attaches = $this->importAttaches($fp); + + // 추가 변수 시작 일 경우 + } elseif($str == '') { + $this->importExtraVars($fp, $obj); + + // 변수 체크 + } else { + $buff .= $str; + $pos = strpos($buff, '>'); + $key = substr($buff, 1, $pos-1); + if(substr($buff, -1 * ( strlen($key)+3)) == '') { + $val = base64_decode(substr($buff, $pos, strlen($buff)-$pos*2-2)); + if($key == 'category' && $category_titles[$val]) $obj->category_srl = $category_titles[$val]; + else $obj->{$key} = $val; + $buff = null; + } + } + } + + fclose($fp); + + $success_count += $inserted_count; + + if($manual_break) { + $this->add('total_count',$total_count); + $this->add('success_count',$success_count); + $this->add('readed_line',$read_line); + $this->add('is_finished','0'); + $this->setMessage(sprintf(Context::getLang('msg_importing'), $total_count, $success_count)); + } else { + $this->add('is_finished','1'); + $this->setMessage(sprintf(Context::getLang('msg_import_finished'), $success_count, $total_count)); + } + } + + /** + * @brief 엮인글 정리 + **/ + function importTrackbacks($fp) { + $trackbacks = array(); + $obj = null; + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + if($str == '') break; + elseif($str == '') { + $obj = null; + continue; + + } elseif($str == '') { + $trackbacks[] = $obj; + continue; + } + + $buff .= $str; + $pos = strpos($buff, '>'); + $key = substr($buff, 1, $pos-1); + if(substr($buff, -1 * ( strlen($key)+3)) == '') { + $val = base64_decode(substr($buff, $pos, strlen($buff)-$pos*2-2)); + $obj->{$key} = $val; + $buff = null; + } + } + + return $trackbacks; + } + + /** + * @brief 댓글 정리 + **/ + function importComments($fp) { + $comments = array(); + $obj = null; + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + // 댓글 전체 끝 + if($str == '') break; + + // 개별 댓글 시작 + elseif($str == '') { + $obj = null; + continue; + + // 댓글 끝 + } elseif($str == '') { + $comments[] = $obj; + continue; + // 첨부파일이 있을때 + } elseif($str == '') { + $obj->attaches = $this->importAttaches($fp); + } + + $buff .= $str; + $pos = strpos($buff, '>'); + $key = substr($buff, 1, $pos-1); + if(substr($buff, -1 * ( strlen($key)+3)) == '') { + $val = base64_decode(substr($buff, $pos, strlen($buff)-$pos*2-2)); + $obj->{$key} = $val; + $buff = null; + } + } + + return $comments; + } + + /** + * @brief 댓글 정리 + **/ + function importAttaches($fp) { + $attaches = array(); + $obj = null; + $index = 0; + + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + if($str == '') break; + elseif($str == '') { + $obj = null; + continue; + + } elseif($str == '') { + $attaches[] = $obj; + continue; + + // 첨부파일 + } else if($str == '') { + // binary buffer일 경우 임의의 위치에 파일을 저장시켜 놓고 그 파일의 경로를 return + $filename = $this->readFileBuff($fp, 'file'); + $obj->file = $filename; + } + + $buff .= $str; + $pos = strpos($buff, '>'); + $key = substr($buff, 1, $pos-1); + if(substr($buff, -1 * ( strlen($key)+3)) == '') { + $val = base64_decode(substr($buff, $pos, strlen($buff)-$pos*2-2)); + $obj->{$key} = $val; + $buff = null; + } + } + + return $attaches; + } + + /** + * @brief 카테고리 정보 가져오기 + **/ + function importCategoris($fp, $module_srl, &$category_list, &$category_titles) { + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + if($str == '') break; + + $category = base64_decode(substr($str,10,-11)); + if($category_titles[$category]) continue; + + $obj = null; + $obj->title = $category; + $obj->module_srl = $module_srl; + $output = $this->oDocumentController->insertCategory($obj); + } + + $category_list = $this->oDocumentModel->getCategoryList($module_srl); + if(count($category_list)) { + foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl; + } else { + $category_list = $category_titles = array(); + } + } + + /** + * @brief 게시글 추가 변수 설정 + **/ + function importExtraVars($fp, &$obj) { + $index = 1; + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + if($str == '') break; + + $buff .= $str; + $pos = strpos($buff, '>'); + $key = substr($buff, 1, $pos-1); + if(substr($buff, -1 * ( strlen($key)+3)) == '') { + $val = base64_decode(substr($buff, $pos, strlen($buff)-$pos*2-2)); + $obj->{"extra_vars".$index} = $val; + $buff = null; + } + } + } + + /** + * @brief 게시글 입력 + **/ + function importDocument($obj) { + // 본문, 댓글, 엮인글, 첨부파일별로 변수 정리 + $comments = $obj->comments; + $trackbacks = $obj->trackbacks; + $attaches = $obj->attaches; + unset($obj->comments); + unset($obj->trackbacks); + unset($obj->attaches); + + // 첨부파일 미리 등록 + if(count($attaches)) { + foreach($attaches as $key => $val) { + $filename = $val->filename; + $download_count = (int)$val->download_count; + $file = $val->file; + + if(!file_exists($file)) continue; + + $file_info['tmp_name'] = $file; + $file_info['name'] = $filename; + + $oFileController = &getController('file'); + $oFileController->insertFile($file_info, $obj->module_srl, $obj->document_srl, $download_count, true); + + // 컨텐츠의 내용 수정 (이미지 첨부파일 관련) + if(eregi("\.(jpg|gif|jpeg|png)$", $filename)) $obj->content = str_replace($filename, sprintf('./files/attach/images/%s/%s/%s', $obj->module_srl, $obj->document_srl, $filename), $obj->content); + @unlink($file); + } + } + + // 게시글 등록 + $obj->member_srl = 0; + $obj->password_is_hashed = true; + $output = $this->oDocumentController->insertDocument($obj, true); + + // 등록 실패시 첨부파일을 일단 모두 지움 + if(!$output->toBool()) { + return false; + } + + // 댓글 부모/자식 관계 정리하기 위한 변수 + $comment_parent_srls = array(); + + // 댓글 등록 + if(count($comments)) { + foreach($comments as $key => $val) { + // 댓글 내용 정리 + $comment_args->comment_srl = getNextSequence(); + $comment_parent_srls[$val->sequence] = $comment_args->comment_srl; + $comment_args->parent_srl = $comment_parent_srls[$val->parent]; + $comment_args->module_srl = $obj->module_srl; + $comment_args->document_srl = $obj->document_srl; + $comment_args->content = $val->content; + $comment_args->password = $val->password; + $comment_args->nick_name = $val->nick_name; + $comment_args->user_id = $val->user_id; + $comment_args->user_name = $val->user_name; + $comment_args->member_srl = 0; + $comment_args->email_address = $val->email; + $comment_args->homepage = $val->homepage; + $comment_args->regdate = $val->regdate; + $comment_args->ipaddress = $val->ipaddress; + + // 첨부파일 미리 등록 + if(count($val->attaches)) { + foreach($val->attaches as $key => $val) { + $filename = $val->filename; + $download_count = (int)$val->download_count; + $file = $val->file; + + if(!file_exists($file)) continue; + + $file_info['tmp_name'] = $file; + $file_info['name'] = $filename; + + $oFileController = &getController('file'); + $oFileController->insertFile($file_info, $obj->module_srl, $comment_args->comment_srl, $download_count, true); + + // 컨텐츠의 내용 수정 (이미지 첨부파일 관련) + if(eregi("\.(jpg|gif|jpeg|png)$", $filename)) $obj->content = str_replace($filename, sprintf('./files/attach/images/%s/%s/%s', $obj->module_srl, $obj->document_srl, $filename), $obj->content); + @unlink($file); + } + } + + + $this->oCommentController->insertComment($comment_args, true); + } + } + + // 엮인글 등록 + if(count($trackbacks)) { + foreach($trackbacks as $key => $val) { + $val->module_srl = $obj->module_srl; + $val->document_srl = $obj->document_srl; + $this->oTrackbackController->insertTrackback($val, true); + } + } + + return true; + } + + + /** + * @brief 파일포인터 return (local or http wrapper) + **/ + function getFilePoint($filename) { + $fp = null; + if(eregi('^http:', $filename)) { + $url_info = parse_url($filename); + if(!$url_info['port']) $url_info['port'] = 80; + if(!$url_info['path']) $url_info['path'] = '/'; + + $fp = @fsockopen($url_info['host'], $url_info['port']); + if($fp) { + + // 한글 파일이 있으면 한글파일 부분만 urlencode하여 처리 (iconv 필수) + $path = $url_info['path']; + if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) { + $path_list = explode('/',$path); + $cnt = count($path_list); + $filename = $path_list[$cnt-1]; + $filename = urlencode(iconv("UTF-8","EUC-KR",$filename)); + $path_list[$cnt-1] = $filename; + $path = implode('/',$path_list); + $url_info['path'] = $path; + } + + $header = sprintf("GET %s?%s HTTP/1.0\r\nHost: %s\r\nReferer: %s://%s\r\nConnection: Close\r\n\r\n", $url_info['path'], $url_info['query'], $url_info['host'], $url_info['scheme'], $url_info['host']); + @fwrite($fp, $header); + while(!feof($fp)) { + $str = fgets($fp, 1024); + if(!trim($str)) break; + } + } + } else { + $fp = fopen($filename,"r"); + } + + return $fp; + } + + /** + * @biref 임의로 사용할 파일이름을 return + **/ + function getTmpFilename($key) { + $path = "./files/cache/tmp"; + if(!is_dir($path)) FileHandler::makeDir($path); + $filename = sprintf("%s/%s.%d", $path, $key, rand(11111111,99999999)); + if(file_exists($filename)) $filename .= rand(111,999); + return $filename; + } + + /** + * @brief 특정 파일포인트로부터 key에 해당하는 값이 나타날때까지 buff를 읽음 + **/ + function readFileBuff($fp,$key) { + $temp_filename = $this->getTmpFilename($key); + $f = fopen($temp_filename, "w"); + + $buff = ''; + while(!feof($fp)) { + $str = trim(fgets($fp, 1024)); + if($str == sprintf('', $key)) break; + + $buff .= $str; + + if(substr($buff, -7) == '') { + fwrite($f, base64_decode(substr($buff, 6, -7))); + $buff = null; + } + } + fclose($f); + return $temp_filename; } } ?> diff --git a/modules/importer/importer.admin.view.php b/modules/importer/importer.admin.view.php index b866cc35b..496072ba5 100644 --- a/modules/importer/importer.admin.view.php +++ b/modules/importer/importer.admin.view.php @@ -20,7 +20,28 @@ **/ function dispImporterAdminContent() { $this->setTemplatePath($this->module_path.'tpl'); - $this->setTemplateFile('index'); + + $source_type = Context::get('source_type'); + switch($source_type) { + case 'member' : + $template_filename = "member"; + break; + case 'module' : + // 전체 모듈 목록 구함 + $oModuleModel = &getModel('module'); + $mid_list = $oModuleModel->getMidList(); + Context::set('mid_list', $mid_list); + + $template_filename = "module"; + break; + case 'sync' : + $template_filename = "sync"; + break; + default : + $template_filename = "index"; + break; + } + $this->setTemplateFile($template_filename); } } diff --git a/modules/importer/lang/en.lang.php b/modules/importer/lang/en.lang.php index 22357871b..5d330649a 100644 --- a/modules/importer/lang/en.lang.php +++ b/modules/importer/lang/en.lang.php @@ -39,7 +39,7 @@ $lang->msg_no_xml_file = 'Could not find XML file. Please check the path again'; $lang->msg_invalid_xml_file = 'Invalid type of XML file.'; $lang->msg_importing = 'Writing %d datas of %d. (If it keeps being frozen, click the button "Continue")'; - $lang->msg_import_finished = '%d datas were inputted completely. Depending on the situation, there might be some datas which couldn\'t be inputted.'; + $lang->msg_import_finished = '%d/%d datas were inputted completely. Depending on the situation, there might be some datas which couldn\'t be inputted.'; $lang->msg_sync_completed = 'Completed synchronzing member article and comments.'; // blah blah.. diff --git a/modules/importer/lang/es.lang.php b/modules/importer/lang/es.lang.php index 67d54fde1..daf550288 100644 --- a/modules/importer/lang/es.lang.php +++ b/modules/importer/lang/es.lang.php @@ -39,7 +39,7 @@ $lang->msg_no_xml_file = 'No se puede encontrar el archivo XML. Verifique su ruta.'; $lang->msg_invalid_xml_file = 'Tipo de archivo XML inválido.'; $lang->msg_importing = 'Ingresando %d dotos de %d. (Si esto mantiene paralizado presione el botón "Continuar".)'; - $lang->msg_import_finished = '%d datos fueron completamente ingresados. Dependiendo del caso, pueden haber algunos datos no ingresados.'; + $lang->msg_import_finished = '%d/%d datos fueron completamente ingresados. Dependiendo del caso, pueden haber algunos datos no ingresados.'; $lang->msg_sync_completed = 'Sincronización del usuario, artículo y respuestas finalizadas.'; // bla bla... diff --git a/modules/importer/lang/jp.lang.php b/modules/importer/lang/jp.lang.php index a301918de..7b96e8648 100644 --- a/modules/importer/lang/jp.lang.php +++ b/modules/importer/lang/jp.lang.php @@ -39,7 +39,7 @@ $lang->msg_no_xml_file = 'XMLファイルが見つかりません。パスをもう一度確認してください。'; $lang->msg_invalid_xml_file = 'XMLファイルのフォーマットが正しくありません。'; $lang->msg_importing = '%d個のデータの内、%d個を変換中です(止まったままの場合は「続ける」ボタンをクリックしてください)。'; - $lang->msg_import_finished = '%d個のデータ変換が完了しました。場合によって変換されていないデータがあることもあります。'; + $lang->msg_import_finished = '%d/%d個のデータ変換が完了しました。場合によって変換されていないデータがあることもあります。'; $lang->msg_sync_completed = '会員情報、書き込みデータ、コメントのデータの同期化(変換)が完了しました。'; // Bla, Blah.. diff --git a/modules/importer/lang/ko.lang.php b/modules/importer/lang/ko.lang.php index ff4104517..991860fd2 100644 --- a/modules/importer/lang/ko.lang.php +++ b/modules/importer/lang/ko.lang.php @@ -39,7 +39,7 @@ $lang->msg_no_xml_file = 'XML파일을 찾을 수 없습니다. 경로를 다시 확인해주세요'; $lang->msg_invalid_xml_file = '잘못된 형식의 XML파일입니다'; $lang->msg_importing = '%d개의 데이터중 %d개를 입력중입니다. (계속 멈추어 있으면 "계속진행" 버튼을 클릭해주세요)'; - $lang->msg_import_finished = '%d개의 데이터 입력이 완료되었습니다. 상황에 따라 입력되지 못한 데이터가 있을 수 있습니다.'; + $lang->msg_import_finished = '%d/%d 개의 데이터 입력이 완료되었습니다. 상황에 따라 입력되지 못한 데이터가 있을 수 있습니다.'; $lang->msg_sync_completed = '회원과 게시물, 댓글의 동기화가 완료되었습니다.'; // 주절 주절.. diff --git a/modules/importer/lang/ru.lang.php b/modules/importer/lang/ru.lang.php index d746413cc..bb637e3b6 100644 --- a/modules/importer/lang/ru.lang.php +++ b/modules/importer/lang/ru.lang.php @@ -39,7 +39,7 @@ $lang->msg_no_xml_file = 'XML файл не найден. Пожалуйста, проверьте путь еще раз'; $lang->msg_invalid_xml_file = 'Неверный тип XML файла.'; $lang->msg_importing = 'Пишем %d данные %d. (Если процесс "завис", нажмите кнопку "Продолжить")'; - $lang->msg_import_finished = '%d данные были поностью импортированы. В зависимости от ситуации, некоторые данные могут не быть импортированы.'; + $lang->msg_import_finished = '%d/%d данные были поностью импортированы. В зависимости от ситуации, некоторые данные могут не быть импортированы.'; $lang->msg_sync_completed = 'Выполнена синхронизация пользователей, статей и комментариев.'; // blah blah.. чепуха) diff --git a/modules/importer/lang/zh-CN.lang.php b/modules/importer/lang/zh-CN.lang.php index c88649e6c..7b69af528 100644 --- a/modules/importer/lang/zh-CN.lang.php +++ b/modules/importer/lang/zh-CN.lang.php @@ -39,7 +39,7 @@ $lang->msg_no_xml_file = '找不到XML文件,请重新确认路径。'; $lang->msg_invalid_xml_file = '错误形式的XML文件!'; $lang->msg_importing = '%d个的数据中正在输入 %d个。 (长时间没有响应时请按“继续进行”按钮)'; - $lang->msg_import_finished = '已完成输入%d个数据。根据情况的不同可能有没有被导入的数据。'; + $lang->msg_import_finished = '已完成输入%d/%d个数据。根据情况的不同可能有没有被导入的数据。'; $lang->msg_sync_completed = '已完成会员和文章,评论的同步。'; // 说明 diff --git a/modules/importer/tpl/filter/import_xml.xml b/modules/importer/tpl/filter/import_xml.xml deleted file mode 100644 index 620edeacf..000000000 --- a/modules/importer/tpl/filter/import_xml.xml +++ /dev/null @@ -1,14 +0,0 @@ - -
- - - - - - - - - - - -
diff --git a/modules/importer/tpl/filter/step12.xml b/modules/importer/tpl/filter/step12.xml deleted file mode 100644 index fa56efb05..000000000 --- a/modules/importer/tpl/filter/step12.xml +++ /dev/null @@ -1,13 +0,0 @@ - -
- - - - - - - - - - -
diff --git a/modules/importer/tpl/index.html b/modules/importer/tpl/index.html index a267aabd9..257c46c81 100644 --- a/modules/importer/tpl/index.html +++ b/modules/importer/tpl/index.html @@ -1,8 +1,5 @@ - - - - +

{$lang->importer} {$lang->cmd_management}

@@ -11,22 +8,24 @@
-
+ + + - + - + - +
{$lang->import_step_title[1]} - {$lang->import_step_desc[1]}
{$lang->about_type_module}
{$lang->about_type_member}
{$lang->about_type_syncmember}
@@ -37,98 +36,3 @@ - - - - - - - - - - - - - - diff --git a/modules/importer/tpl/js/importer_admin.js b/modules/importer/tpl/js/importer_admin.js index 8b6077718..48bbf797f 100644 --- a/modules/importer/tpl/js/importer_admin.js +++ b/modules/importer/tpl/js/importer_admin.js @@ -3,135 +3,106 @@ * @author zero (zero@nzeo.com) * @brief importer에서 사용하는 javascript **/ - -/* Step 1 처리 */ -function completeStep1(ret_obj) { - var error = ret_obj['error']; - var message = ret_obj['message']; - var next_step = ret_obj['next_step']; - var module_list = ret_obj['module_list']; - - if(module_list) { - var sel = xGetElementById("target_module"); - var module_list_arr = module_list.split("\n"); - for(var i=0;i0) { - var module_srl = sel_module.options[sel_module.selectedIndex].value; - fo_obj.module_srl.value = module_srl; - } - - var sel_category = xGetElementById("target_category"); - if(sel_category.options.length>1) { - var category_srl = sel_category.options[sel_category.selectedIndex].value; - fo_obj.category_srl.value = category_srl; - } - - var target_path = xGetElementById("target_path").value; - fo_obj.target_path.value = target_path; - - procFilter(fo_obj, import_xml); - - - xGetElementById('step2_status').style.display = 'block'; - return false; -} - -/* Step Complete Import */ -function completeImport(ret_obj) { - var message = ret_obj['message']; - var is_finished = ret_obj['is_finished']; - var position = ret_obj['position']; - var file_point = ret_obj['file_point']; - var total_count = ret_obj['total_count']; - - if(total_count>0) { - var bar = xGetElementById('bar'); - var status = xGetElementById('bar_status'); - var per = parseInt(position/total_count*100,10) - xInnerHtml(status, position+'/'+total_count+' ('+per+'%)'); - bar.style.width = per+'%'; - } - - if(is_finished=='Y') { - alert(ret_obj["message"]); - location.href = location.href; - } else { - var fo_obj = xGetElementById('fo_step2'); - fo_obj.position.value = position; - fo_obj.file_point.value = file_point; - fo_obj.total_count.value = total_count; - message = message.replace(/</g,"<").replace(/>/g,">"); - - var obj = xGetElementById('step2_position'); - var txt = xInnerHtml(obj); - if(txt.length > 1024*10) txt = ''; - if(message != "success") xInnerHtml(obj, txt+message); - obj.scrollTop += xHeight(obj); - procFilter(fo_obj, import_xml); - } -} - -function doManualProcess() { - var fo_obj = xGetElementById('fo_step2'); - procFilter(fo_obj, import_xml); -} - /* 회원정보와 게시물의 싱크 */ -function doStep3(fo_obj) { - exec_xml('importer','procImporterAdminSync', new Array(), completeStep3); +function doSync(fo_obj) { + exec_xml('importer','procImporterAdminSync', new Array(), completeSync); return false; } -function completeStep3(ret_obj) { +function completeSync(ret_obj) { alert(ret_obj['message']); location.href=location.href; } + + +/* 회원정보 데이터 import */ +function doImportMember(fo_obj) { + var xml_file = fo_obj.xml_file.value; + if(!xml_file) return false; + + var params = new Array(); + params['xml_file'] = xml_file; + params['total_count'] = fo_obj.total_count.value; + params['success_count'] = fo_obj.success_count.value; + params['readed_line'] = fo_obj.readed_line.value; + + var response_tags = new Array("error","message", "total_count", "success_count", "readed_line", "is_finished"); + + fo_obj.xml_file.disabled = true; + xGetElementById("status").style.display = "block"; + xGetElementById("status_button_prev").style.display = "none"; + xGetElementById("status_button").style.display = "block"; + + exec_xml('importer','procImporterAdminMemberImport', params, completeImportMember, response_tags); + + return false; +} + +function completeImportMember(ret_obj) { + var total_count = ret_obj['total_count']; + var success_count = ret_obj['success_count']; + var readed_line = ret_obj['readed_line']; + var is_finished = ret_obj['is_finished']; + + if(is_finished == '1') { + alert(ret_obj['message']); + xInnerHtml("status", ret_obj['message']); + } else { + xInnerHtml("status", ret_obj['message']); + + var fo_obj = xGetElementById("fo_import"); + fo_obj.total_count.value = total_count; + fo_obj.success_count.value = success_count; + fo_obj.readed_line.value = readed_line; + doImportMember(fo_obj); + } +} + +/* 모듈 데이터 import */ +function doImportModule(fo_obj) { + var target_module = fo_obj.target_module.options[fo_obj.target_module.selectedIndex].value; + if(!target_module) return false; + + var xml_file = fo_obj.xml_file.value; + if(!xml_file) return false; + + var params = new Array(); + params['xml_file'] = xml_file; + params['target_module'] = target_module; + params['total_count'] = fo_obj.total_count.value; + params['success_count'] = fo_obj.success_count.value; + params['readed_line'] = fo_obj.readed_line.value; + + var response_tags = new Array("error","message", "total_count", "success_count", "readed_line", "is_finished"); + + fo_obj.target_module.disabled = true; + fo_obj.xml_file.disabled = true; + xGetElementById("status").style.display = "block"; + xGetElementById("status_button_prev").style.display = "none"; + xGetElementById("status_button").style.display = "block"; + + exec_xml('importer','procImporterAdminModuleImport', params, completeImportModule, response_tags); + + return false; +} + +function completeImportModule(ret_obj, response_tags) { + var total_count = ret_obj['total_count']; + var success_count = ret_obj['success_count']; + var readed_line = ret_obj['readed_line']; + var is_finished = ret_obj['is_finished']; + + if(is_finished == '1') { + alert(ret_obj['message']); + xInnerHtml("status", ret_obj['message']); + } else { + xInnerHtml("status", ret_obj['message']); + + var fo_obj = xGetElementById("fo_import"); + fo_obj.total_count.value = total_count; + fo_obj.success_count.value = success_count; + fo_obj.readed_line.value = readed_line; + doImportModule(fo_obj); + } +} + diff --git a/modules/importer/tpl/member.html b/modules/importer/tpl/member.html new file mode 100644 index 000000000..f844605ad --- /dev/null +++ b/modules/importer/tpl/member.html @@ -0,0 +1,33 @@ + + + +

{$lang->importer} {$lang->cmd_management}

+ +
{nl2br($lang->about_importer)}
+ +
+
+ + + + + + + + + + + + +
{$lang->import_step_title[2]} - {$lang->import_step_desc[2]}
+ +

ex1) ../member.xml

+

ex2) http://...../member.xml

+
+
+ +
+ + +
+
diff --git a/modules/importer/tpl/module.html b/modules/importer/tpl/module.html new file mode 100644 index 000000000..b1bb5fe0e --- /dev/null +++ b/modules/importer/tpl/module.html @@ -0,0 +1,51 @@ + + + +

{$lang->importer} {$lang->cmd_management}

+ + +
{nl2br($lang->about_importer)}
+ + +
+
+ + + + + + + + + +
{$lang->import_step_title[1]} - {$lang->import_step_desc[12]}
+ +
+ + + + + + + + + +
{$lang->import_step_title[2]} - {$lang->import_step_desc[2]}
+ +

ex1) ../member.xml

+

ex2) http://...../member.xml

+
+
+ +
+ + + +
+
+ diff --git a/modules/importer/tpl/sync.html b/modules/importer/tpl/sync.html new file mode 100644 index 000000000..6068c5b91 --- /dev/null +++ b/modules/importer/tpl/sync.html @@ -0,0 +1,16 @@ + + + +

{$lang->importer} {$lang->cmd_management}

+ + +
{nl2br($lang->about_importer)}
+ +
+ + + + + +
{$lang->import_step_title[3]} - {$lang->import_step_desc[3]}
+
diff --git a/modules/tag/tag.controller.php b/modules/tag/tag.controller.php index 8e61a026e..4de779b38 100644 --- a/modules/tag/tag.controller.php +++ b/modules/tag/tag.controller.php @@ -55,7 +55,9 @@ $tag_list = explode(',',$tags); $tag_count = count($tag_list); for($i=0;$i<$tag_count;$i++) { - $args->tag = $tag_list[$i]; + unset($args->tag); + $args->tag = trim($tag_list[$i]); + if(!$args->tag) continue; $output = executeQuery('tag.insertTag', $args); if(!$output->toBool()) return $output; }