#!/usr/bin/php4 -q ",$temp2["body"]); $temp2["body"] = str_replace("[","<",$temp2["body"]); $temp2["body"] = str_replace("]",">",$temp2["body"]); $temp2["body"] = utf8_encode($temp2["body"]); $temp2["subject"] = utf8_encode($temp2["subject"]); echo "Body:". $temp2["body"] . "\n"; $temp2["date"] = $temp[9]; echo "Date:". $temp2["date"] . "\n"; $sql = "insert into wp_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_category,post_excerpt,post_status,comment_status,ping_status,post_name,post_parent,menu_order) values ( 1, '" . date("Y-m-d H:i:s", $temp2["date"]) . "', '" . date("Y-m-d H:i:s", $temp2["date"] - (2*3600)) . "' , '" . $temp2["body"] . "', '" . $temp2["subject"] . "', 0, '', 'publish', 'open', 'open', '" . substr($post["subject"],0,200) . "', 0, 0)"; echo "QUERY: " . $sql . "\n"; /* FIX ÅÄÖ */ /* echo mysql_query("SET names 'latin1'"); */ $res = mysql_query($sql); echo "MYSQL: " . $res . "\n"; $res = mysql_query("select max(id) from wp_posts;"); $postID = mysql_result($res,0); echo "Post: $post, inserted as ID $postID\n"; if (file_exists($commentdir) && is_dir($commentdir)) { $pdh = opendir($commentdir); while (($commentfile = readdir($pdh)) !== false) { if (is_dir($commentdir . '/' . $commentfile)) continue; $comment = file_get_contents($commentdir . '/' . $commentfile); $temp = explode("|", $comment); $temp2["author"] = utf8_encode(mysql_escape_string($temp[3])); $temp2["date"] = utf8_encode($temp[5]); $temp2["body"] = utf8_encode(mysql_escape_string($temp[7])); $temp2["email"] = utf8_encode(mysql_escape_string($temp[9])); /* FIX URL */ $temp2["body"] = str_replace("[url=","",$temp2["body"]); $temp2["body"] = str_replace("[","<",$temp2["body"]); $temp2["body"] = str_replace("]",">",$temp2["body"]); $sql="iNSERT INTO wp_comments (comment_post_id,comment_author,comment_author_email,comment_date,comment_date_gmt,comment_content,comment_karma,comment_approved,comment_agent,comment_parent,user_id) VALUES ( '" . $postID . "', '" . $temp2["author"] . "', '" . $temp2["email"] . "', '" . date("Y-m-d H:i:s", $temp2["date"]) . "', '" . date("Y-m-d H:i:s", $temp2["date"] - (2*3600)) . "' , '" . $temp2["body"] . "', 0, '1', 'sphpblog2wp', 0, 0)"; echo "COMMENT QUERY:\n" . $sql . "\n"; $ret = mysql_query($sql); echo "MYSQL COMMENT INSERT: ". $ret ."\n"; $res = mysql_query("select max(comment_id) from wp_comments;"); $commentID = mysql_result($res,0); echo "-- Comment: $commentdir/$commentfile, inserted as ID $commentID\n"; } closedir($pdh); } } closedir($dh); echo "Done!\n"; } } else echo "Not a directory\n"; mysql_close($db); /* BELONGS TO TEST CODE }}}} */ ?>