테터툴즈 테이블의 머리말을 입력하세요. (기본값:tts)
get_var("SELECT ID FROM $wp_post_table ORDER BY ID desc LIMIT 1;") + 1; //echo $wp_post_last_ID; $pID = Array(); // 글의 ID $cID = Array(); // 갈래의 ID $c2ID = Array(); // 작은 갈래의 ID // 큰 갈래 옮기기 $tt_cat = mysql_query("SELECT * FROM $tt_cat_table ORDER BY no;"); while($cat = mysql_fetch_array($tt_cat,MYSQL_ASSOC)) { $cat_ID = $cat["no"]; $cat_name = $cat["label"]; $cat_name = iconv('EUC-KR', 'UTF-8', $cat_name); $same_name_ID = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$cat_name'"); if ($same_name_ID) $cID[$cat_ID] = $same_name_ID; else { $wpdb->query("INSERT INTO $wpdb->categories (cat_name) VALUES ('$cat_name')"); $cID[$cat_ID] = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$cat_name'"); } $unknown_cat1 = $cat['no']; } // 작은 갈래 옮기기 $tt_small_cat = mysql_query("SELECT * FROM $tt_small_cat_table ORDER BY no"); while($cat = mysql_fetch_array($tt_small_cat,MYSQL_ASSOC)) { $cat_ID = $cat["no"]; $cat_name = $cat["label"]; $cat_name = iconv('EUC-KR', 'UTF-8', $cat_name); $category_parent = $cat["pno"]; $same_name_ID = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$cat_name';"); if ($same_name_ID) $c2ID[$cat_ID] = $same_name_ID; else { $category_parent = $cID[$category_parent]; $wpdb->query("INSERT INTO $wpdb->categories (cat_name,category_parent) VALUES ('$cat_name',$category_parent)"); $c2ID[$cat_ID] = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$cat_name';"); } } // 글 옮기기 $tt_post = mysql_query("SELECT * FROM $tt_post_table ORDER BY no;"); while($post = mysql_fetch_array($tt_post,MYSQL_ASSOC)) { $ID = $post["no"]; $post_author = 1; $post_date = date("Y-m-d H:i:s", $post["regdate"]); $post_date_gmt = get_gmt_from_date($post_date); $post_content = $post["body"]; $post_title = $post["title"]; $post_status = $post["is_public"]?"publish":"private"; $comment_status = $post["perm_rp"]?"open":"closed"; $ping_status = $post["perm_tb"]?"open":"closed"; //$post_name = urlencode($post_title); //$post_name = sanitize_title($post_title, $post_ID); $post_modified = $post_date; $post_modified_gmt = $post_date_gmt; // UTF-8로 변환 $post_content = iconv("EUC-KR","UTF-8",$post_content); $post_title = iconv("EUC-KR","UTF-8",$post_title); /* // alt가 없는 img에 alt 속성 부여하기 $reg = "/]*>/"; preg_match($reg,$post_content,$matches); foreach($matches as $match) { $match_old = $match; $match = str_replace("heygom.com/tt","heygom.com/blog",$match); $match = str_replace("uploaded/","myfiles/",$match); $match = str_replace("http://heygom.com/blog",".",$match); $match = str_replace("http://www.heygom.com/blog",".",$match); if (substr($match,-2,1) != "/") { $match = substr($match,0,strlen($match)-1)."/>"; } if (strpos($match,"alt") < 1) { $match = substr($match,0,strlen($match)-2)." alt=\"\"/>"; } $post_content = str_replace($match_old,$match,$post_content); } */ $post_content = str_replace(""","\"",$post_content); // 숨김 기능 및 첨부 파일, 스타일 등이 있으면 알려줌 $showhide = strstr($post_content,"[#M_"); $attachedImage = strstr($post_content,"[##_"); /* $customStyle = strstr($post_content,"".$post_title." : "; if ($showhide) { echo " "; } if ($attachedImage) { echo " "; } /* if ($customStyle) { echo " "; } if ($customLink) { echo " "; } $post_content = str_replace("
","
",$post_content); $post_content = str_replace("
","",$post_content); */ $post_name = $ID; // 데이터베이스에 저장 if (!$pID[$ID] = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'")) { $wpdb->query("INSERT INTO $wpdb->posts (post_author,post_date,post_date_gmt,post_content,post_title,post_status,comment_status,ping_status,post_modified,post_modified_gmt, post_name) VALUES ('$post_author','$post_date','$post_date_gmt','$post_content','$post_title','$post_status','$comment_status','$ping_status','$post_modified','$post_modified_gmt', '$post_name')"); $pID[$ID] = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID desc LIMIT 1"); $category1 = $post['category1']; $category2 = $post['category2']; if ($category2 > 0) { $category = $c2ID[$category2]; } else { $category = $cID[$category1]; } if ( !$category ) $category = $unknown_cat1; $wpdb->query("INSERT INTO $wpdb->post2cat (post_id,category_id) VALUES ($pID[$ID],$category)"); } } // 답글 옮기기 $tt_comment = mysql_query("SELECT * FROM $tt_comment_table ORDER BY no;"); while($comment = mysql_fetch_array($tt_comment,MYSQL_ASSOC)) { $comment_post_ID = $pID[$comment["pno"]]; $comment_author = addslashes($comment["name"]); $comment_author_url = $comment["homepage"]; $comment_author_IP = $comment["ip"]; $comment_date = date("Y-m-d H:i:s", $comment["regdate"]); $comment_date_gmt = get_gmt_from_date($comment_date); $comment_content = $comment["body"]; // UTF-8로 바꾸기 $comment_author = iconv("EUC-KR","UTF-8",$comment_author); $comment_content = iconv("EUC-KR","UTF-8",$comment_content); if(!$wpdb->get_var("SELECT comment_ID FROM $wpdb->comments WHERE comment_author = '$comment_author' AND comment_content = '$comment_content'") && $comment_post_ID) { $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content) VALUES ($comment_post_ID, '$comment_author', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content')"); } } // 트랙백 옮기기 $tt_trackback = mysql_query("SELECT * FROM $tt_trackback_table ORDER BY no"); while($trackback = mysql_fetch_array($tt_trackback,MYSQL_ASSOC)) { $comment_post_ID = $pID[$trackback["pno"]]; $comment_author = addslashes($trackback["site"]); $comment_author_url = $trackback["url"]; $comment_author_IP = $trackback["ip"]; $comment_date = date("Y-m-d H:i:s",$trackback["regdate"]); $comment_date_gmt = get_gmt_from_date($comment_date); $comment_content = addslashes($trackback["body"]); $comment_type = "trackback"; // UTF-8로 바꾸기 $comment_author = iconv("EUC-KR","UTF-8",$comment_author); $comment_content = iconv("EUC-KR","UTF-8",$comment_content); $comment_content = str_replace(""","\"",$comment_content); if(!$wpdb->get_var("SELECT comment_ID FROM $wpdb->comments WHERE comment_author = '$comment_author' AND comment_content = '$comment_content'") && $comment_post_ID) { $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_type) VALUES ($comment_post_ID, '$comment_author', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content','$comment_type')"); } } upgrade_all(); echo "
작업 완료"; ?>