Example #1
0
            }
            # most likely DST causing the variation, so
        }
        gb::log(LOG_WARNING, 'unable to exactly deduce timezone -- guessing %s%d', $mindiff < 0 ? '-' : '+', $mindiff);
        return $mindiff;
    }
}
@ini_set('max_execution_time', '0');
set_time_limit(0);
gb::$title[] = 'Import Wordpress';
if (isset($_FILES['wpxml'])) {
    if ($_FILES['wpxml']['error']) {
        gb::$errors[] = 'file upload failed with unknown error (maybe you forgot to select the file?).';
    }
    if (!gb::$errors) {
        $importer = new WordpressImporter();
        $importer->includeAttachments = @gb_strbool($_POST['include-attachments']);
        $importer->includeComments = @gb_strbool($_POST['include-comments']);
    }
    include_once '../_header.php';
    ?>
<style type="text/css">
		div.msg {
			border-top:1px solid #ddd;
		}
		div.msg.error { background:#fed; }
		div.msg p.time {
			float:left;
			font-family:monospace;
			color:#357;
			width:15%;
Example #2
0
                $category_statement->execute(array(':post_id' => $wp->post_id, ':taxonomy_id' => $this->categories[(string) $category['nicename']]));
            } elseif ($category['domain'] == 'post_tag') {
                $tag_statement->execute(array(':post_id' => $wp->post_id, ':taxonomy_id' => $this->tags[(string) $category['nicename']]));
            } else {
                echo 'Unknown category type: ', $category['domain'], "\n";
            }
        }
    }
    protected function process_comments_for(SimpleXMLElement $post, SimpleXMLElement $wp, PDOStatement $comment_statement)
    {
        foreach ($wp->comment as $comment) {
            // Ignore pingbacks and trackbacks for now
            if ($comment->comment_type == 'pingback' || $comment->comment_type == 'trackback') {
                continue;
            }
            $comment_statement->execute(array(':id' => $comment->comment_id, ':post_id' => $wp->post_id, ':author' => $comment->comment_author, ':email' => $comment->comment_author_email, ':url' => (string) $comment->comment_author_url, ':ip' => $comment->comment_author_IP, ':date' => strtotime($comment->comment_date), ':content' => (string) $comment->comment_content, ':parent_comment_id' => $comment->comment_parent == 0 ? null : $comment->comment_parent, ':status' => $comment->comment_approved == 1 ? 'visible' : 'pending'));
        }
    }
    protected function finalise()
    {
        $this->db->query('UPDATE blog_comments SET email = "*****@*****.**", url = "http://dan.cx/" WHERE author = "Daniel15"');
    }
}
//header('Content-Type: text/plain');
echo '<pre>';
$importer = new WordpressImporter();
$importer->connectToDB('daniel15_new', 'root', 'password');
$importer->load('c:/Users/Daniel/Downloads/daniel15039sblog.wordpress.2011-05-03.xml');
$importer->process();
?>
All done!