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

This commit is contained in:
zero 2007-05-16 01:57:34 +00:00
parent c459b1bf0d
commit 1b727a32a1
6 changed files with 141 additions and 17 deletions

View file

@ -7,6 +7,10 @@
class importerController extends importer {
var $oXml = null;
var $oMemberController = null;
var $oDocumentController = null;
/**
* @brief 초기화
**/
@ -75,24 +79,127 @@
}
/**
* @brief import xml file
* XML File을 읽어서 파싱 입력..
* @brief import 실행
**/
function procImporterAdminImport() {
set_time_limit(0);
// 변수 체크
$module_srl = Context::get('module_srl');
$category_srl = Context::get('category_srl');
$category_srl = Context::get('category_list');
$xml_file = Context::get('xml_file');
// 파일을 찾을 수 없으면 에러 표시
if(!file_exists($xml_file)) return new Object(-1,'msg_no_xml_file');
// XML Parser로 XML을 읽음
$xml_doc = XmlParser::loadXmlFile($xml_file);
$this->oXml = new XmlParser();
$this->setError(-1);
$this->setMessage('haha');
// module_srl이 있으면 module데이터로 판단하여 처리, 아니면 회원정보로..
if($module_srl) return $this->importModule($xml_file, $module_srl, $category_srl);
return $this->importMember($xml_file);
}
/**
* @brief 회원정보 import
**/
function importMember($xml_file) {
$filesize = filesize($xml_file);
if($filesize<1) return;
$this->oMemberController = &getController('member');
$fp = fopen($xml_file, "r");
$readed_size = 0;
if($fp) {
while(!feof($fp) && $readed_size<=$filesize) {
$str = fgets($fp, 256);
$readed_size += strlen($str);
$buff .= $str;
$buff = preg_replace_callback('!<member user_id="([^\"]*)">([^<]*)</member>!is', array($this, '_importMember'), $buff);
if(eregi('</root>', $str)) break;
}
fclose($fp);
}
return new Object(0,'msg_import_finished');
}
function _importMember($matches) {
$user_id = $matches[1];
$buff = sprintf('<member>%s</member>',base64_decode($matches[2]));
$xml_doc = $this->oXml->parse($buff);
$args->user_id = $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->birthday = $xml_doc->member->birthday->body;
$args->email_address = $xml_doc->member->email_address->body;
$args->password = $xml_doc->member->password->body;
$args->regdate = $xml_doc->member->regdate->body;
$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);
$this->oMemberController->insertImageName($member_srl, './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);
$this->oMemberController->insertImageMark($member_srl, './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);
return '';
}
/**
* @brief 게시물 import
**/
function importModule($xml_file) {
$filesize = filesize($xml_file);
if($filesize<1) return;
$this->oDocumentController = &getController('document');
$fp = fopen($xml_file, "r");
$readed_size = 0;
if($fp) {
while(!feof($fp) && $readed_size<=$filesize) {
$str = fgets($fp, 1024);
$readed_size += strlen($str);
$buff .= $str;
$buff = preg_replace_callback('!<document sequence="([^\"]*)">([^<]*)</document>!is', array($this, '_importModule'), $buff);
}
fclose($fp);
}
return new Object(-1,'haha');
}
function _importModule($matches) {
$user_id = $matches[1];
$xml_doc = sprintf('<document>%s</document>',base64_decode($matches[2]));
return '';
}
}
?>