4 require_once(
'./modules/importer/extract.class.php');
46 if(strncasecmp(
'http://', $filename, 7) === 0)
48 if(ini_get(
'allow_url_fopen'))
50 $fp = @fopen($filename,
"r");
53 $str = fgets($fp, 100);
58 if(stristr($str,
'tattertools')) $type =
'TTXML';
60 $this->
add(
'type', $type);
63 $resultMessage = $lang->found_xml_file;
65 else $resultMessage = $lang->cannot_url_file;
67 else $resultMessage = $lang->cannot_allow_fopen_in_phpini;
69 $this->
add(
'exists', $isExists);
75 if(file_exists($realPath) && is_file($realPath)) $isExists =
'true';
76 $this->
add(
'exists', $isExists);
78 if($isExists ==
'true')
82 $fp = fopen($realPath,
"r");
83 $str = fgets($fp, 100);
84 if(stristr($str,
'tattertools')) $type =
'TTXML';
87 $this->
add(
'type', $type);
88 $resultMessage = $lang->found_xml_file;
90 else $resultMessage = $lang->not_found_xml_file;
92 $this->
add(
'result_message', $resultMessage);
102 $member_config = $oMemberModel->getMemberConfig();
104 $postFix = ($member_config->identifier ==
'email_address') ?
'ByEmail' :
'';
111 if($db_info->db_type !=
"cubrid")
124 foreach (
$output->data as $val)
126 $args->user_id = $val->user_id;
127 $args->member_srl = $val->member_srl;
129 if($tmp->toBool () ===
true)
147 foreach (
$output->data as $val)
149 $args->user_id = $val->user_id;
150 $args->member_srl = $val->member_srl;
152 if($tmp->toBool () ===
true)
184 $output = $oExtract->set($xml_file,
'<members ',
'</members>',
'<member>',
'</member>');
185 if(
$output->toBool()) $oExtract->saveItems();
188 $output = $oExtract->set($xml_file,
'<messages ',
'</messages>',
'<message>',
'</message>');
189 if(
$output->toBool()) $oExtract->saveItems();
193 $output = $oExtract->set($xml_file,
'',
'',
'',
'');
199 while (!feof($oExtract->fd))
201 $str = fgets($oExtract->fd, 1024);
202 if(strstr($str,
'<category>'))
205 $str = strstr($str,
'<category>');
207 if(substr($str,0,strlen(
'<post ')) ==
'<post ')
break;
208 if ($started) $buff .= $str;
210 $buff =
'<categories>'.$buff.
'</categories>';
211 $oExtract->closeFile();
212 $category_filename = sprintf(
'%s/%s', $oExtract->cache_path,
'category.xml');
216 $output = $oExtract->set($xml_file,
'',
'',
'',
'');
221 while (!feof($oExtract->fd))
223 $str = fgets($oExtract->fd, 1024);
224 if(strstr($str,
'<guestbook>'))
227 $str = strstr($str,
'<guestbook>');
231 $pos = strpos($str,
'</guestbook>');
234 $buff .= substr($str, 0, $pos + strlen(
'</guestbook>'));
240 $oExtract->closeFile();
241 $guestbook_filename = sprintf(
'%s/%s', $oExtract->cache_path,
'guestbook.xml');
244 $output = $oExtract->set($xml_file,
'<blog',
'</blog>',
'<post ',
'</post>');
245 if(
$output->toBool()) $oExtract->saveItems();
251 $output = $oExtract->set($xml_file,
'<categories>',
'</categories>',
'<category',
'</category>');
254 $oExtract->mergeItems(
'category.xml');
256 $output = $oExtract->set($xml_file,
'<posts ',
'</posts>',
'<post>',
'</post>');
257 if(
$output->toBool()) $oExtract->saveItems();
264 $this->
add(
'error',0);
265 $this->
add(
'status',-1);
270 $this->
add(
'type',$type);
271 $this->
add(
'total',$oExtract->getTotalCount());
273 $this->
add(
'key', $oExtract->getKey());
274 $this->
add(
'status',0);
290 $guestbook_target_module =
Context::get(
'guestbook_target_module');
293 $index_file =
'./files/cache/importer/'.$key.
'/index';
294 if(!file_exists($index_file))
return new BaseObject(-1,
'msg_invalid_xml_file');
299 if(!$target_module)
return new BaseObject(-1,
'msg_invalid_request');
302 $columnList = array(
'module_srl',
'module');
303 $target_module_info =
$oModuleModel->getModuleInfoByModuleSrl($target_module, $columnList);
306 if($ttimporter) require_once($ttimporter);
309 $cur = $oTT->importModule($key, $cur, $index_file, $this->unit_count, $target_module, $guestbook_target_module, $user_id, $target_module_info->module);
319 if(!$target_module)
return new BaseObject(-1,
'msg_invalid_request');
320 $cur = $this->
importModule($key, $cur, $index_file, $target_module);
324 $this->
add(
'type',$type);
325 $this->
add(
'total',$total);
326 $this->
add(
'cur',$cur);
327 $this->
add(
'key', $key);
328 $this->
add(
'target_module', $target_module);
352 $this->oMemberModel =
getModel(
'member');
354 $default_group = $this->oMemberModel->getDefaultGroup();
355 $default_group_srl = $default_group->group_srl;
360 $f = fopen($index_file,
"r");
362 for($i=0;$i<$cur;$i++) fgets($f, 1024);
368 $target_file = trim(fgets($f, 1024));
372 if(!$xmlObj)
continue;
374 $obj =
new stdClass();
376 $obj->user_id = base64_decode($xmlObj->member->user_id->body);
377 $obj->password = base64_decode($xmlObj->member->password->body);
378 $obj->user_name = base64_decode($xmlObj->member->user_name->body);
379 $obj->nick_name = base64_decode($xmlObj->member->nick_name->body);
381 $obj->email_address = base64_decode($xmlObj->member->email->body);
382 $obj->homepage = base64_decode($xmlObj->member->homepage->body);
383 $obj->blog = base64_decode($xmlObj->member->blog->body);
384 $obj->birthday = substr(base64_decode($xmlObj->member->birthday->body),0,8);
385 $obj->allow_mailing = base64_decode($xmlObj->member->allow_mailing->body);
386 $obj->point = base64_decode($xmlObj->member->point->body);
387 $obj->image_nickname = base64_decode($xmlObj->member->image_nickname->buff->body);
388 $obj->image_mark = base64_decode($xmlObj->member->image_mark->buff->body);
389 $obj->profile_image = base64_decode($xmlObj->member->profile_image->buff->body);
390 $obj->signature = base64_decode($xmlObj->member->signature->body);
391 $obj->regdate = base64_decode($xmlObj->member->regdate->body);
392 $obj->last_login = base64_decode($xmlObj->member->last_login->body);
394 if($xmlObj->member->extra_vars)
396 foreach($xmlObj->member->extra_vars as $key => $val)
398 if(in_array($key, array(
'node_name',
'attrs',
'body')))
continue;
399 $obj->extra_vars->{$key} = base64_decode($val->body);
403 if(
$obj->homepage && strncasecmp(
'http://',
$obj->homepage, 7) !== 0 && strncasecmp(
'https://',
$obj->homepage, 8) !== 0)
$obj->homepage =
'http://'.$obj->homepage;
405 if(!preg_match(
'/^[a-z]+[\w-]*[a-z0-9_]+$/i',
$obj->user_id))
407 $obj->user_id = preg_replace(
'/[^a-z0-9_-]+/i',
'',
$obj->user_id);
409 if(!preg_match(
'/^[a-z]+[\w-]*[a-z0-9_]+$/i',
$obj->user_id))
411 $obj->user_id =
't' .
$obj->member_srl;
414 if(!preg_match(
'/^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/',
$obj->email_address))
416 $obj->email_address =
$obj->user_id .
'@example.com';
418 list(
$obj->email_id,
$obj->email_host) = explode(
'@',
$obj->email);
420 if(
$obj->allow_mailing!=
'Y')
$obj->allow_mailing =
'N';
422 $obj->allow_message =
'Y';
423 if(!in_array(
$obj->allow_message, array(
'Y',
'N',
'F')))
$obj->allow_message=
'Y';
427 $obj->list_order = -1 *
$obj->member_srl;
430 unset(
$obj->extra_vars);
433 $args =
new stdClass;
438 $obj->user_id .=
'_'.$obj->member_srl;
441 $args =
new stdClass;
446 $obj->user_id .=
'_'.$obj->member_srl;
449 $args =
new stdClass;
450 $args->email_address =
$obj->email_address;
454 $obj->email_address =
$obj->user_id .
'@example.com';
464 $oMail->setTitle(
"Password update for your " .
getFullSiteUrl() .
" account");
465 $webmaster_name = $member_config->webmaster_name?$member_config->webmaster_name:
'Webmaster';
466 $oMail->setContent(
"Dear $obj->user_name, <br /><br />
467 We recently migrated our site to XpressEngine. Since you password was encrypted we could not migrate it too, so please reset it by following this link:
468 <a href='" .
getFullSiteUrl() .
"/?act=dispMemberFindAccount' >" .
getFullSiteUrl() .
"?act=dispMemberFindAccount</a>. You need to enter you email address and hit the 'Find account' button. You will then receive an email with a new, generated password that you can change after login. <br /><br />
470 Thank you for your understanding,<br />
473 $oMail->setSender($webmaster_name, $member_config->webmaster_email);
474 $oMail->setReceiptor(
$obj->user_name,
$obj->email);
482 $obj->group_srl = $default_group_srl;
485 if(
$obj->image_nickname)
487 $target_path = sprintf(
'files/member_extra_info/image_name/%s/',
getNumberingPath(
$obj->member_srl));
488 $target_filename = sprintf(
'%s%d.gif', $target_path,
$obj->member_srl);
492 if(
$obj->image_mark && file_exists(
$obj->image_mark))
494 $target_path = sprintf(
'files/member_extra_info/image_mark/%s/',
getNumberingPath(
$obj->member_srl));
495 $target_filename = sprintf(
'%s%d.gif', $target_path,
$obj->member_srl);
499 if(
$obj->profile_image)
501 $target_path = sprintf(
'files/member_extra_info/profile_image/%s/',
getNumberingPath(
$obj->member_srl));
502 $target_filename = sprintf(
'%s%d.gif', $target_path,
$obj->member_srl);
509 $signature_buff = sprintf(
'<?php if(!defined("__XE__")) exit();?>%s', $signature);
511 $target_path = sprintf(
'files/member_extra_info/signature/%s/',
getNumberingPath(
$obj->member_srl));
513 $target_filename = sprintf(
'%s%d.signature.php', $target_path,
$obj->member_srl);
538 $f = fopen($index_file,
"r");
540 for($i=0;$i<$cur;$i++) fgets($f, 1024);
542 for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
546 $target_file = trim(fgets($f, 1024));
548 $xmlObj = $oXmlParser->loadXmlFile($target_file);
550 if(!$xmlObj)
continue;
553 $obj->receiver = base64_decode($xmlObj->message->receiver->body);
554 $obj->sender = base64_decode($xmlObj->message->sender->body);
555 $obj->title = base64_decode($xmlObj->message->title->body);
556 $obj->content = base64_decode($xmlObj->message->content->body);
557 $obj->readed = base64_decode($xmlObj->message->readed->body)==
'Y'?
'Y':
'N';
558 $obj->regdate = base64_decode($xmlObj->message->regdate->body);
559 $obj->readed_date = base64_decode($xmlObj->message->readed_date->body);
561 if(!
$obj->sender)
continue;
562 $sender_args->user_id =
$obj->sender;
563 $sender_output =
executeQuery(
'member.getMemberInfo',$sender_args);
564 $sender_srl = $sender_output->data->member_srl;
568 $sender_args->email_address =
$obj->sender;
569 $sender_output =
executeQuery(
'member.getMemberInfoByEmailAddress',$sender_args);
570 $sender_srl = $sender_output->data->member_srl;
572 if(!$sender_srl)
continue;
574 $receiver_args->user_id =
$obj->receiver;
575 if(!
$obj->receiver)
continue;
576 $receiver_output =
executeQuery(
'member.getMemberInfo',$receiver_args);
577 $receiver_srl = $receiver_output->data->member_srl;
580 unset($receiver_args);
581 $receiver_args->email_address =
$obj->receiver;
582 $receiver_output =
executeQuery(
'member.getMemberInfoByEmailAddress',$receiver_args);
583 $receiver_srl = $receiver_output->data->member_srl;
585 if(!$receiver_srl)
continue;
587 $sender_args->sender_srl = $sender_srl;
588 $sender_args->receiver_srl = $receiver_srl;
589 $sender_args->message_type =
'S';
590 $sender_args->title =
$obj->title;
591 $sender_args->content =
$obj->content;
592 $sender_args->readed =
$obj->readed;
593 $sender_args->regdate =
$obj->regdate;
594 $sender_args->readed_date =
$obj->readed_date;
597 $sender_args->list_order = $sender_args->message_srl * -1;
603 $receiver_args->message_srl = $sender_args->related_srl;
604 $receiver_args->list_order = $sender_args->related_srl*-1;
605 $receiver_args->sender_srl = $sender_srl;
606 if(!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl;
607 $receiver_args->receiver_srl = $receiver_srl;
608 $receiver_args->message_type =
'R';
609 $receiver_args->title =
$obj->title;
610 $receiver_args->content =
$obj->content;
611 $receiver_args->readed =
$obj->readed;
612 $receiver_args->regdate =
$obj->regdate;
613 $receiver_args->readed_date =
$obj->readed_date;
638 $category_list = $category_titles = array();
640 if(count($category_list))
foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
642 $category_file = preg_replace(
'/index$/i',
'category.xml', $index_file);
643 if(file_exists($category_file))
648 $xmlDoc = $this->oXmlParser->loadXmlFile($category_file);
650 $categories = $xmlDoc->items->category;
653 if(!is_array($categories)) $categories = array($categories);
654 $match_sequence = array();
655 foreach($categories as $k => $v)
657 $category = trim(base64_decode($v->body));
658 if(!$category || $category_titles[$category])
continue;
660 $sequence = $v->attrs->sequence;
661 $parent = $v->attrs->parent;
664 $obj->title = $category;
666 if($parent)
$obj->parent_srl = $match_sequence[$parent];
669 if(
$output->toBool()) $match_sequence[$sequence] =
$output->get(
'category_srl');
677 $category_list = $category_titles = array();
679 if(count($category_list))
foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
685 foreach(
$output->data as $key => $val) $extra_keys[$val->eid] =
true;
690 $f = fopen($index_file,
"r");
692 for($i=0;$i<$cur;$i++) fgets($f, 1024);
694 for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
698 $target_file = trim(fgets($f, 1024));
700 if(!file_exists($target_file))
continue;
702 $fp = fopen($target_file,
"r");
717 $str = fgets($fp, 1024);
719 if(trim($str) ==
'<post>')
724 else if(substr($str,0,11) ==
'<trackbacks')
730 else if(substr($str,0,9) ==
'<comments')
736 else if(substr($str,0,9) ==
'<attaches')
738 $obj->uploaded_count = $this->importAttaches($fp,
$module_srl,
$obj->document_srl, $files);
742 elseif(trim($str) ==
'<extra_vars>')
748 if($started) $buff[] = $str;
751 $xmlDoc = $this->oXmlParser->parse(implode(
'', $buff));
753 $category = base64_decode($xmlDoc->post->category->body);
754 if($category_titles[$category])
$obj->category_srl = $category_titles[$category];
756 $obj->member_srl = 0;
758 $obj->is_notice = base64_decode($xmlDoc->post->is_notice->body)==
'Y'?
'Y':
'N';
760 $obj->title = base64_decode($xmlDoc->post->title->body);
761 $obj->content = base64_decode($xmlDoc->post->content->body);
762 $obj->readed_count = base64_decode($xmlDoc->post->readed_count->body);
763 $obj->voted_count = base64_decode($xmlDoc->post->voted_count->body);
764 $obj->blamed_count = base64_decode($xmlDoc->post->blamed_count->body);
765 $obj->password = base64_decode($xmlDoc->post->password->body);
766 $obj->user_name = base64_decode($xmlDoc->post->user_name->body);
767 $obj->nick_name = base64_decode($xmlDoc->post->nick_name->body);
769 $obj->user_id = base64_decode($xmlDoc->post->user_id->body);
770 $obj->email_address = base64_decode($xmlDoc->post->email->body);
771 $obj->homepage = base64_decode($xmlDoc->post->homepage->body);
772 if(
$obj->homepage && strncasecmp(
'http://',
$obj->homepage, 7) !== 0 && strncasecmp(
'https://',
$obj->homepage, 8) !== 0)
$obj->homepage =
'http://'.$obj->homepage;
773 $obj->tags = base64_decode($xmlDoc->post->tags->body);
774 $obj->regdate = base64_decode($xmlDoc->post->regdate->body);
775 $obj->last_update = base64_decode($xmlDoc->post->update->body);
776 $obj->last_updater = base64_decode($xmlDoc->post->last_updater->body);
777 if(!
$obj->last_update)
$obj->last_update =
$obj->regdate;
778 $obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body);
779 $obj->list_order =
$obj->update_order =
$obj->document_srl*-1;
780 $obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body)!=
'N'?
'ALLOW':
'DENY';
781 $obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body)!=
'N'?
'Y':
'N';
782 $obj->notify_message = base64_decode($xmlDoc->post->is_notice->body);
784 if(!preg_match(
'/^[a-z]+[\w-]*[a-z0-9_]+$/i',
$obj->user_id))
786 $obj->user_id = preg_replace(
'/[^a-z0-9_-]+/i',
'',
$obj->user_id);
788 if(!preg_match(
'/^[a-z]+[\w-]*[a-z0-9_]+$/i',
$obj->user_id))
790 $obj->user_id =
't' .
$obj->member_srl;
793 if(!preg_match(
'/^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/',
$obj->email_address))
795 $obj->email_address =
$obj->user_id .
'@example.com';
800 foreach($files as $key => $val)
802 $obj->content = preg_replace(
'/(src|href)\=(["\']?)'.preg_quote($key).
'(["\']?)/i',
'$1="'.$val.
'"',
$obj->content);
803 $obj->content = preg_replace(
'/(["\']?).\/files\/(.+)\/'.preg_quote($key).
'([^"\']+)(["\']?)/i',
'"'.$val.
'"',
$obj->content);
804 $obj->content = preg_replace(
'/(["\']?)files\/(.+)\/'.preg_quote($key).
'([^"\']+)(["\']?)/i',
'"'.$val.
'"',
$obj->content);
812 $tag_list = explode(
',',
$obj->tags);
813 $tag_count = count($tag_list);
814 for($i=0;$i<$tag_count;$i++)
816 $args =
new stdClass;
819 $args->document_srl =
$obj->document_srl;
820 $args->tag = trim($tag_list[$i]);
822 if(!
$args->tag)
continue;
832 if(!$val->value)
continue;
835 $e_args->document_srl =
$obj->document_srl;
836 $e_args->var_idx = $val->var_idx;
837 $e_args->value = $val->value;
838 $e_args->lang_code = $val->lang_code;
839 $e_args->eid = $val->eid;
841 if(!preg_match(
'/^(title|content)_(.+)$/i',$e_args->eid) && !$extra_keys[$e_args->eid])
845 $ek_args->var_idx = $val->var_idx;
846 $ek_args->var_name = $val->eid;
847 $ek_args->var_type =
'text';
848 $ek_args->var_is_required =
'N';
849 $ek_args->var_default =
'';
850 $ek_args->eid = $val->eid;
852 $extra_keys[$ek_args->eid] =
true;
885 $str = fgets($fp, 1024);
887 if(trim($str) ==
'</trackbacks>')
break;
889 if(trim($str) ==
'<trackback>') $started =
true;
891 if($started) $buff .= $str;
893 if(trim($str) ==
'</trackback>')
895 $xmlDoc = $this->oXmlParser->parse($buff);
901 $obj->url = base64_decode($xmlDoc->trackback->url->body);
902 $obj->title = base64_decode($xmlDoc->trackback->title->body);
903 $obj->blog_name = base64_decode($xmlDoc->trackback->blog_name->body);
904 $obj->excerpt = base64_decode($xmlDoc->trackback->excerpt->body);
905 $obj->regdate = base64_decode($xmlDoc->trackback->regdate->body);
906 $obj->ipaddress = base64_decode($xmlDoc->trackback->ipaddress->body);
907 $obj->list_order = -1*
$obj->trackback_srl;
931 $sequences = array();
935 $str = fgets($fp, 1024);
937 if(trim($str) ==
'</comments>')
break;
939 if(trim($str) ==
'<comment>')
947 if(substr($str,0,9) ==
'<attaches')
953 if($started) $buff .= $str;
955 if(trim($str) ==
'</comment>')
957 $xmlDoc = $this->oXmlParser->parse($buff);
959 $sequence = base64_decode($xmlDoc->comment->sequence->body);
960 $sequences[$sequence] =
$obj->comment_srl;
961 $parent = base64_decode($xmlDoc->comment->parent->body);
965 if($parent)
$obj->parent_srl = $sequences[$parent];
966 else $obj->parent_srl = 0;
969 $obj->is_secret = base64_decode($xmlDoc->comment->is_secret->body)==
'Y'?
'Y':
'N';
970 $obj->notify_message = base64_decode($xmlDoc->comment->notify_message->body)==
'Y'?
'Y':
'N';
971 $obj->content = base64_decode($xmlDoc->comment->content->body);
972 $obj->voted_count = base64_decode($xmlDoc->comment->voted_count->body);
973 $obj->blamed_count = base64_decode($xmlDoc->comment->blamed_count->body);
974 $obj->password = base64_decode($xmlDoc->comment->password->body);
975 $obj->user_name =base64_decode($xmlDoc->comment->user_name->body);
976 $obj->nick_name = base64_decode($xmlDoc->comment->nick_name->body);
978 $obj->user_id = base64_decode($xmlDoc->comment->user_id->body);
979 $obj->member_srl = 0;
980 $obj->email_address = base64_decode($xmlDoc->comment->email->body);
981 $obj->homepage = base64_decode($xmlDoc->comment->homepage->body);
982 $obj->regdate = base64_decode($xmlDoc->comment->regdate->body);
983 $obj->last_update = base64_decode($xmlDoc->comment->update->body);
984 if(!
$obj->last_update)
$obj->last_update =
$obj->regdate;
985 $obj->ipaddress = base64_decode($xmlDoc->comment->ipaddress->body);
986 $obj->status = base64_decode($xmlDoc->comment->status->body)==
''?
'1':base64_decode($xmlDoc->comment->status->body);
987 $obj->list_order =
$obj->comment_srl*-1;
989 if(!preg_match(
'/^[a-z]+[\w-]*[a-z0-9_]+$/i',
$obj->user_id))
991 $obj->user_id = preg_replace(
'/[^a-z0-9_-]+/i',
'',
$obj->user_id);
993 if(!preg_match(
'/^[a-z]+[\w-]*[a-z0-9_]+$/i',
$obj->user_id))
995 $obj->user_id =
't' .
$obj->member_srl;
998 if(!preg_match(
'/^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/',
$obj->email_address))
1000 $obj->email_address =
$obj->user_id .
'@example.com';
1005 foreach($files as $key => $val)
1007 $obj->content = preg_replace(
'/(src|href)\=(["\']?)'.preg_quote($key).
'(["\']?)/i',
'$1="'.$val.
'"',
$obj->content);
1011 $list_args =
new stdClass;
1012 $list_args->comment_srl =
$obj->comment_srl;
1013 $list_args->document_srl =
$obj->document_srl;
1014 $list_args->module_srl =
$obj->module_srl;
1015 $list_args->regdate =
$obj->regdate;
1017 if(!
$obj->parent_srl)
1019 $list_args->head = $list_args->arrange =
$obj->comment_srl;
1020 $list_args->depth = 0;
1026 $parent_args->comment_srl =
$obj->parent_srl;
1027 $parent_output =
executeQuery(
'comment.getCommentListItem', $parent_args);
1029 if(!$parent_output->toBool() || !$parent_output->data)
continue;
1030 $parent = $parent_output->data;
1032 $list_args->head = $parent->head;
1033 $list_args->depth = $parent->depth+1;
1034 if($list_args->depth<2) $list_args->arrange =
$obj->comment_srl;
1037 $list_args->arrange = $parent->arrange;
1067 $uploaded_count = 0;
1072 $file_obj =
new stdClass;
1075 $str = trim(fgets($fp, 1024));
1077 if(trim($str) ==
'</attaches>')
break;
1079 if(trim($str) ==
'<attach>')
1082 $file_obj->upload_target_srl = $upload_target_srl;
1089 else if(trim($str) ==
'<file>')
1091 $file_obj->file = $this->saveTemporaryFile($fp);
1095 if($started) $buff .= $str;
1097 if(trim($str) ==
'</attach>')
1099 $xmlDoc = $this->oXmlParser->parse($buff.$str);
1101 $file_obj->source_filename = base64_decode($xmlDoc->attach->filename->body);
1102 $file_obj->download_count = base64_decode($xmlDoc->attach->download_count->body);
1104 if(!$file_obj->file)
1106 $url = base64_decode($xmlDoc->attach->url->body);
1107 $path = base64_decode($xmlDoc->attach->path->body);
1108 if($path && file_exists($path)) $file_obj->file = $path;
1111 $file_obj->file = $this->getTmpFilename();
1116 if(file_exists($file_obj->file))
1120 if(preg_match(
"/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_obj->source_filename))
1123 $file_obj->source_filename = preg_replace(
'/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i',
'$0-x', $file_obj->source_filename);
1124 $file_obj->source_filename = str_replace(array(
'<',
'>'), array(
'%3C',
'%3E'), $file_obj->source_filename);
1128 $ext = substr(strrchr($file_obj->source_filename,
'.'),1);
1129 $_filename = $random->createSecureSalt(32,
'hex').
'.'.$ext;
1130 $filename = $path.$_filename;
1133 while(file_exists($filename))
1135 $filename = $path.preg_replace(
'/\.([a-z0-9]+)$/i',
'_'.$idx.
'.$1', $_filename);
1139 $file_obj->direct_download =
'Y';
1144 $filename = $path.$random->createSecureSalt(32,
'hex');
1145 $file_obj->direct_download =
'N';
1150 if(strncmp(
'./files/cache/importer/', $file_obj->file, 23) === 0)
1156 copy($file_obj->file, $filename);
1160 unset($file_obj->file);
1161 if(file_exists($filename))
1163 $file_obj->uploaded_filename = $filename;
1164 $file_obj->file_size = filesize($filename);
1165 $file_obj->comment = NULL;
1166 $file_obj->member_srl = 0;
1167 $file_obj->sid = $random->createSecureSalt(32,
'hex');
1168 $file_obj->isvalid =
'Y';
1175 $tmp_obj->source_filename = $file_obj->source_filename;
1176 if($file_obj->direct_download ==
'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename;
1177 else $files[$file_obj->source_filename] =
getUrl(
'',
'module',
'file',
'act',
'procFileDownload',
'file_srl',$file_obj->file_srl,
'sid',$file_obj->sid);
1183 return $uploaded_count;
1192 $path =
"./files/cache/importer";
1194 $filename = sprintf(
"%s/%d", $path, rand(11111111,99999999));
1195 if(file_exists($filename)) $filename .= rand(111,999);
1206 $temp_filename = $this->getTmpFilename();
1207 $f = fopen($temp_filename,
"w");
1212 $str = trim(fgets($fp, 1024));
1213 if(trim($str) ==
'</file>')
break;
1217 if(substr($buff,-7)==
'</buff>')
1219 fwrite($f, base64_decode(substr($buff, 6, -7)));
1224 return $temp_filename;
1238 $buff .= $str = trim(fgets($fp, 1024));
1239 if(trim($str) ==
'</extra_vars>')
break;
1241 if(!$buff)
return array();
1243 $buff =
'<extra_vars>'.$buff;
1245 $xmlDoc = $this->oXmlParser->parse($buff);
1246 if(!count($xmlDoc->extra_vars->key))
return array();
1249 foreach($xmlDoc->extra_vars->key as $k => $v)
1254 $vobj->var_idx = base64_decode($v->var_idx->body);
1255 $vobj->lang_code = base64_decode($v->lang_code->body);
1256 $vobj->value = base64_decode($v->value->body);
1257 $vobj->eid = base64_decode($v->eid->body);
1262 $vobj->var_idx = $index;
1264 $vobj->value = base64_decode($v->body);
1265 $vobj->eid =
'extra_vars'.$index;
setMessage($message= 'success', $type=NULL)
getController($module_name)
getNumberingPath($no, $size=3)
importModule($key, $cur, $index_file, $module_srl)
foreach($sitemap as $id=> &$val) $extra_vars
writeFile($filename, $buff, $mode="w")
procImporterAdminImport()
procImporterAdminPreProcessing()
getRemoteFile($url, $target_filename, $body=null, $timeout=3, $method= 'GET', $content_type=null, $headers=array(), $cookies=array(), $post_data=array(), $request_config=array())
importMessage($key, $cur, $index_file)
importComments($fp, $module_srl, $document_srl)
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
importTrackbacks($fp, $module_srl, $document_srl)
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
importAttaches($fp, $module_srl, $upload_target_srl, &$files)
importMember($key, $cur, $index_file)
procImporterAdminCheckXmlFile()
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang