4 @require_once(
'./modules/importer/extract.class.php');
34 function importModule($key, $cur, $index_file, $unit_count,
$module_srl, $guestbook_module_srl, $user_id, $module_name=null)
41 $category_list = $category_titles = array();
43 if(count($category_list))
foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
45 $category_file = preg_replace(
'/index$/i',
'category.xml', $index_file);
46 if(file_exists($category_file))
49 $xmlDoc = $this->oXmlParser->loadXmlFile($category_file);
51 if($xmlDoc->categories->category)
53 $categories = array();
57 $match_sequence = array();
58 foreach($categories as $k => $v)
61 if(!$category || $category_titles[$category])
continue;
64 $obj->title = $category;
66 if($v->parent)
$obj->parent_srl = $match_sequence[$v->parent];
69 if(
$output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] =
$output->get(
'category_srl');
75 $category_list = $category_titles = array();
77 if(count($category_list))
foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
80 $member_info = $oMemberModel->getMemberInfoByUserID($user_id);
85 $f = fopen($index_file,
"r");
87 for($i=0;$i<$cur;$i++) fgets($f, 1024);
89 for($idx=$cur;$idx<$cur+$unit_count;$idx++)
93 $target_file = trim(fgets($f, 1024));
95 if(!file_exists($target_file))
continue;
97 $fp = fopen($target_file,
"r");
103 $obj->uploaded_count = 0;
112 $str = fgets($fp, 1024);
114 if(substr($str,0,5) ==
'<post')
120 else if(substr($str,0,12) ==
'<attachment ')
126 if($started) $buff .= $str;
129 $xmlDoc = $this->oXmlParser->parse(
'<post>'.$buff);
131 $author_xml_id = $xmlDoc->post->author->body;
133 if($xmlDoc->post->category->body)
135 $tmp_arr = explode(
'/',$xmlDoc->post->category->body);
136 $category = trim($tmp_arr[count($tmp_arr)-1]);
137 if($category_titles[$category])
$obj->category_srl = $category_titles[$category];
140 $obj->is_notice =
'N';
141 $obj->status = in_array($xmlDoc->post->visibility->body, array(
'public',
'syndicated'))?
$oDocumentModel->getConfigStatus(
'public'):
$oDocumentModel->getConfigStatus(
'secret');
142 $obj->title = $xmlDoc->post->title->body;
143 $obj->content = $xmlDoc->post->content->body;
144 $obj->password = md5($xmlDoc->post->password->body);
145 $obj->commentStatus = $xmlDoc->post->acceptcomment->body==
'1'?
'ALLOW':
'DENY';
146 $obj->allow_trackback = $xmlDoc->post->accepttrackback->body==
'1'?
'Y':
'N';
149 $obj->regdate = date(
"YmdHis",$xmlDoc->post->published->body);
150 $obj->last_update = date(
"YmdHis", $xmlDoc->post->modified->body);
151 if(!
$obj->last_update)
$obj->last_update =
$obj->regdate;
155 $tag = $xmlDoc->post->tag;
158 if(!is_array($tag)) $tag = array($tag);
159 foreach($tag as $key => $val) $tmp_tags[] = $val->body;
160 $obj->tags = implode(
',',$tmp_tags);
163 $obj->readed_count = 0;
164 $obj->voted_count = 0;
165 $obj->nick_name = $member_info->nick_name;
166 $obj->user_name = $member_info->user_name;
167 $obj->user_id = $member_info->user_id;
168 $obj->member_srl = $member_info->member_srl;
169 $obj->email_address = $member_info->email_address;
170 $obj->homepage = $member_info->homepage;
171 $obj->ipaddress = $_REMOTE[
'SERVER_ADDR'];
172 $obj->list_order =
$obj->update_order =
$obj->document_srl*-1;
173 $obj->notify_message =
'N';
175 $obj->content = str_replace(
'[##_ATTACH_PATH_##]/',
'',
$obj->content);
178 foreach($files as $key => $val) {
179 $obj->content = preg_replace(
'/(src|href)\=(["\']?)'.preg_quote($key).
'(["\']?)/i',
'$1="'.$val->url.
'"',
$obj->content);
183 $obj->content = preg_replace_callback(
'!\[##_Movie\|([^\|]*)\|(.*?)_##\]!is', array($this,
'_replaceTTMovie'),
$obj->content);
187 $this->files = $files;
188 $obj->content = preg_replace_callback(
'!\[##_([a-z0-9]+)\|([^\|]*)\|([^\|]*)\|(.*?)_##\]!is', array($this,
'_replaceTTAttach'),
$obj->content);
191 $obj->trackback_count = 0;
192 if($xmlDoc->post->trackback)
194 $trackbacks = $xmlDoc->post->trackback;
195 if(!is_array($trackbacks)) $trackbacks = array($trackbacks);
196 if(count($trackbacks))
198 foreach($trackbacks as $key => $val)
203 $tobj->document_srl =
$obj->document_srl;
204 $tobj->url = $val->url->body;
205 $tobj->title = $val->title->body;
206 $tobj->blog_name = $val->site->body;
207 $tobj->excerpt = $val->excerpt->body;
208 $tobj->regdate = date(
"YmdHis",$val->received->body);
209 $tobj->ipaddress = $val->ip->body;
210 $tobj->list_order = -1*$tobj->trackback_srl;
217 $obj->comment_count = 0;
218 if($xmlDoc->post->comment)
220 $comment = $xmlDoc->post->comment;
221 if(!is_array($comment)) $comment = array($comment);
222 foreach($comment as $key => $val)
225 if($parent_srl ===
false)
continue;
227 $obj->comment_count++;
230 $child_comment = $val->comment;
231 if(!is_array($child_comment)) $child_comment = array($child_comment);
232 foreach($child_comment as $k => $v)
235 if($result !==
false)
$obj->comment_count++;
241 if($module_name ==
'textyle')
243 $args->document_srl =
$obj->document_srl;
245 $args->logs = serialize(null);
248 $status_published = array(
'public',
'syndicated');
250 if(!in_array($xmlDoc->post->visibility->body, $status_published))
252 $obj->module_srl = $member_info->member_srl;
263 $tag_list = explode(
',',
$obj->tags);
264 $tag_count = count($tag_list);
265 for($i=0;$i<$tag_count;$i++)
267 $args =
new stdClass;
270 $args->document_srl =
$obj->document_srl;
271 $args->tag = trim($tag_list[$i]);
273 if(!
$args->tag)
continue;
287 $guestbook_file = preg_replace(
'/index$/i',
'guestbook.xml', $index_file);
288 if(file_exists($guestbook_file))
291 $xmlDoc = $this->oXmlParser->loadXmlFile($guestbook_file);
293 if($guestbook_module_srl && $xmlDoc->guestbook->comment)
295 $comment = $xmlDoc->guestbook->comment;
296 if(!is_array($comment)) $comment = array($comment);
298 if($module_name ==
'textyle')
300 foreach($comment as $key => $val)
306 $child_comment = $val->comment;
307 if(!is_array($child_comment)) $child_comment = array($child_comment);
308 foreach($child_comment as $k => $v)
319 foreach($comment as $key => $val)
322 $obj->module_srl = $guestbook_module_srl;
324 $obj->uploaded_count = 0;
325 $obj->is_notice =
'N';
327 $obj->content = nl2br($val->content->body);
331 if (
$obj->title ==
'')
$obj->title =
'Untitled';
333 $obj->commentStatus =
'ALLOW';
334 $obj->allow_trackback =
'N';
335 $obj->regdate = date(
"YmdHis",$val->written->body);
336 $obj->last_update = date(
"YmdHis", $val->written->body);
337 if(!
$obj->last_update)
$obj->last_update =
$obj->regdate;
339 $obj->readed_count = 0;
340 $obj->voted_count = 0;
341 if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
344 $obj->nick_name = $member_info->nick_name;
345 $obj->user_name = $member_info->user_name;
346 $obj->user_id = $member_info->user_id;
347 $obj->member_srl = $member_info->member_srl;
348 $obj->email_address = $member_info->email_address;
349 $obj->homepage = $member_info->homepage;
353 $obj->password = $val->password->body;
354 $obj->nick_name = $val->commenter->name->body;
355 $obj->member_srl = 0;
356 $homepage = $val->commenter->homepage->body;
358 $obj->ipaddress = $val->commenter->ip->body;
359 $obj->list_order =
$obj->update_order =
$obj->document_srl*-1;
360 $obj->notify_message =
'N';
361 $obj->trackback_count = 0;
363 $obj->comment_count = 0;
366 $child_comment = $val->comment;
367 if(!is_array($child_comment)) $child_comment = array($child_comment);
368 foreach($child_comment as $k => $v)
371 if($result !==
false)
$obj->comment_count++;
399 if($textyle_guestbook_srl>0)
401 $tobj->textyle_guestbook_srl = $textyle_guestbook_srl;
408 $tobj->is_secret = $val->secret->body==
'1'?1:-1;
409 $tobj->content = nl2br($val->content->body);
410 if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
412 $tobj->password =
'';
413 $tobj->nick_name = $member_info->nick_name;
414 $tobj->user_name = $member_info->user_name;
415 $tobj->user_id = $member_info->user_id;
416 $tobj->member_srl = $member_info->member_srl;
417 $tobj->homepage = $member_info->homepage;
418 $tobj->email_address = $member_info->email_address;
422 $tobj->password = $val->password->body;
423 $tobj->nick_name = $val->commenter->name->body;
424 $tobj->homepage = $val->commenter->homepage->body;
425 $tobj->member_srl = 0;
427 $tobj->last_update = $tobj->regdate = date(
"YmdHis",$val->written->body);
428 $tobj->ipaddress = $val->commenter->ip->body;
432 $tobj->parent_srl = $parent_srl;
433 $tobj->list_order = $tobj->parent_srl * -1;
437 $tobj->list_order = $tobj->textyle_guestbook_srl*-1;
442 if(
$output->toBool())
return $tobj->textyle_guestbook_srl;
461 $file_obj->upload_target_srl = $upload_target_srl;
466 $str = fgets($fp, 1024);
468 if(trim($str) ==
'</attachment>')
break;
470 if(substr($str, 0, 9)==
'<content>')
478 if(!file_exists($file_obj->file))
return false;
480 $buff .=
'</attachment>';
482 $xmlDoc = $this->oXmlParser->parse($buff);
484 $file_obj->source_filename = $xmlDoc->attachment->label->body;
485 $file_obj->download_count = $xmlDoc->attachment->downloads->body;
486 $name = $xmlDoc->attachment->name->body;
488 if(preg_match(
"/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename))
491 $filename = $path.$file_obj->source_filename;
492 $file_obj->direct_download =
'Y';
497 $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
498 $file_obj->direct_download =
'N';
505 unset($file_obj->file);
506 $file_obj->uploaded_filename = $filename;
507 $file_obj->file_size = filesize($filename);
508 $file_obj->comment = NULL;
509 $file_obj->member_srl = 0;
510 $file_obj->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999)));
511 $file_obj->isvalid =
'Y';
518 if($file_obj->direct_download ==
'Y') $files[$name]->url = $file_obj->uploaded_filename;
519 else $files[$name]->url =
getUrl(
'',
'module',
'file',
'act',
'procFileDownload',
'file_srl',$file_obj->file_srl,
'sid',$file_obj->sid);
520 $files[$name]->direct_download = $file_obj->direct_download;
521 $files[$name]->source_filename = $file_obj->source_filename;
534 $path =
"./files/cache/importer";
536 $filename = sprintf(
"%s/%d", $path, rand(11111111,99999999));
537 if(file_exists($filename)) $filename .= rand(111,999);
550 $buff = substr($buff, 9);
554 $str = trim(fgets($fp, 1024));
556 if(substr($str, -10) ==
'</content>')
break;
559 $buff = substr($buff, 0, -10);
561 $f = fopen($temp_filename,
"w");
562 fwrite($f, base64_decode($buff));
564 return $temp_filename;
575 if(!$name)
return $matches[0];
577 $obj = $this->files[$name];
579 if(
$obj->direct_download ==
'Y')
582 if(preg_match(
'/\.(jpg|gif|jpeg|png)$/i',
$obj->source_filename))
584 return sprintf(
'<img editor_component="image_link" src="%s" alt="%s" />',
$obj->url, str_replace(
'"',
'\\"',$matches[4]));
589 return sprintf(
'<img src="./common/img/blank.gif" editor_component="multimedia_link" multimedia_src="%s" width="400" height="320" style="display:block;width:400px;height:320px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center;" auto_start="false" alt="" />',
$obj->url);
595 return sprintf(
'<a href="%s">%s</a>',
$obj->url,
$obj->source_filename);
606 if(!$key)
return $matches[0];
609 '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'.
610 '<param name="movie" value="http://flvs.daum.net/flvPlayer.swf?vid='.urlencode($key).
'"/>'.
611 '<param name="allowScriptAccess" value="always"/>'.
612 '<param name="allowFullScreen" value="true"/>'.
613 '<param name="bgcolor" value="#000000"/>'.
614 '<embed src="http://flvs.daum.net/flvPlayer.swf?vid='.urlencode($key).
'" width="100%" height="402" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" bgcolor="#000000"/>'.
634 $tobj->is_secret = $val->secret->body==
'1'?
'Y':
'N';
635 $tobj->notify_message =
'N';
636 $tobj->content = nl2br($val->content->body);
637 $tobj->voted_count = 0;
639 if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
641 $tobj->password =
'';
642 $tobj->nick_name = $member_info->nick_name;
643 $tobj->user_name = $member_info->user_name;
644 $tobj->user_id = $member_info->user_id;
645 $tobj->member_srl = $member_info->member_srl;
646 $tobj->homepage = $member_info->homepage;
647 $tobj->email_address = $member_info->email_address;
651 $tobj->password = $val->password->body;
652 $tobj->nick_name = $val->commenter->name->body;
653 $tobj->homepage = $val->commenter->homepage->body;
654 $tobj->member_srl = 0;
656 $tobj->last_update = $tobj->regdate = date(
"YmdHis",$val->written->body);
657 $tobj->ipaddress = $val->commenter->ip->body;
658 $tobj->list_order = $tobj->comment_srl*-1;
659 $tobj->sequence = $sequence;
660 $tobj->parent_srl = $parent_srl;
662 $list_args =
new stdClass;
663 $list_args->comment_srl = $tobj->comment_srl;
664 $list_args->document_srl = $tobj->document_srl;
665 $list_args->module_srl = $tobj->module_srl;
666 $list_args->regdate = $tobj->regdate;
668 if(!$tobj->parent_srl)
670 $list_args->head = $list_args->arrange = $tobj->comment_srl;
671 $list_args->depth = 0;
677 $parent_args->comment_srl = $tobj->parent_srl;
678 $parent_output =
executeQuery(
'comment.getCommentListItem', $parent_args);
680 if(!$parent_output->toBool() || !$parent_output->data)
return false;
681 $parent = $parent_output->data;
683 $list_args->head = $parent->head;
684 $list_args->depth = $parent->depth+1;
685 if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl;
688 $list_args->arrange = $parent->arrange;
698 if(
$output->toBool())
return $tobj->comment_srl;
713 if(!
$obj->category)
return;
714 if(!is_array(
$obj->category)) $c = array(
$obj->category);
715 else $c =
$obj->category;
719 $priority = $val->priority->body;
720 $name = $val->name->body;
722 $obj->priority = $priority;
724 $obj->sequence = $idx;
725 $obj->parent = $parent;
727 $category[$idx] =
$obj;
importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name=null)
getController($module_name)
getNumberingPath($no, $size=3)
_replaceTTAttach($matches)
insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, $parent_srl=0, $author_xml_id=null)
insertComment($val, $module_srl, $document_srl, $member_info, $parent_srl=0, $author_xml_id)
arrangeCategory($obj, &$category, &$idx, $parent=0)
saveTemporaryFile($fp, $buff)
cut_str($string, $cut_size=0, $tail= '...')
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
_replaceTTMovie($matches)
importAttaches($fp, $module_srl, $upload_target_srl, &$files, $buff)