• _mf_

    (@_mf_)


    After discussing this briefly, I am releasing a first very preliminar version of my pMachine 2.0 import to WordPress 1.0.1 . This is for the current download version, not any CVS or more advanced/betas. It is released under the GPL.
    The file is available here (update: scroll down for v 0.2).
    PROCEED WITH CAUTION – BACKUP YOUR WP SETUP FIRST!
    For some reason, categories are not displayed OK although database tables & fields seem to match.This may only work on a brand new install of WP, since member IDs are assumed to be sequential.
    I tried it on my own pMachine 2.0 site and this is the result (forgive the broken design under IE). I use Mozilla Firefox (formerly Firebird) 0.8.
    This is what’s working:
    – Import of members AND non-members information, including admin or “active” level
    – Import of categories
    – Categories equivalency so category IDs match when importing posts
    – Importing of posts
    – Importing of comments, including all details (timestamps, IP for anon-posts, full member/non member info)
    Some features:
    – Debug mode for viewing before doing things – will not show categories properly since there are 2 steps in the script
    – Complete trace of everything being done, including every SQL query, even when in Debug mode
    – Since passwords are encrypted in pmachine, I set the password to the first 6 characters of the encrypted thing, which ends up being a unique pwd. Not ideal, but enough to notify users to change it (instead of re-registering)
    Here’s what needs to be fixed:
    – Display of categories (see my resulting site for an example)
    – Translation of special/ISO characters to UTF-8 or HTML entities
    – Translation of pMachine code to whatever WP uses (again, see my target site for examples of URLs and other code being displayed instead of rendered)
    – More validation
    Please email me any code updates, via my website (there’s a contact form), or post here.
    Enjoy!

Viewing 15 replies - 1 through 15 (of 26 total)
  • This is great!
    I’ve been waiting for this (hence my messages to Chritina, hoping to try myself at updating her script) and WP1.1-final in order to move my entire blog out of pM – looks like it’s coming at long last! Thank you !
    One thing I wondered myself while thinking about starting from scratch : how do you deal with upload pictures ? Do you copy them and replace the code in the post, or is it up to the owner to edit the message accordingly, reuploading the file to the right place ?
    Try creating a Importers page on the Wiki, maybe that might launch a few more efforts, and gather some help around your own.
    Again: thank you!

    Thread Starter _mf_

    (@_mf_)

    Glad to see you appreciate it. I only had 1 post among 157 containing a picture, so I was going to change it manually. However this can be tweaked for further automation.
    Right now I’d rather have the categories display problem fixed, perhaps later today I’ll five it ashot unless someone’s patience lasts less than mine ??
    Cheers!

    Moderator Matt Mullenweg

    (@matt)

    It would be great if this code complied with WP coding style guidelines so it could be easily integrated with the main release.

    Thread Starter _mf_

    (@_mf_)

    I focused on error trapping and clear output, coding from 11pm to 5am with a baby crying didn’t help. If anyone wants to throw some time at it, I can’t do that right now.

    mrpeer

    (@mrpeer)

    Hello, i’ve got an error while importing posts & comments and I think it’s a probleme with quotes.

    willm

    (@willm)

    _mf_ : the devs may not appreciate your efforts but I’m sure future users will ??

    Thread Starter _mf_

    (@_mf_)

    WillM: In fact being asked to clean up my code to include it as part of the package indicates they *do* appreciate it ??
    Mr. Peer: Can you share the exact error messages as generated , including the SQL queries ? I have lots of single quotes in my french posts and imported without problem.

    mrpeer

    (@mrpeer)


    SELECT * FROM pm_weblog WHERE weblog='weblog'
    Calculating category equivalency for this post : pMachine (1) = WP (2)
    SELECT pm.id, wpc.category_nicename, pm.category, wpc.cat_ID, wpc.cat_name FROM wp_categories as wpc, pm_categories as pm WHERE (LOWER(REPLACE(pm.category,' ','-'))=wpc.category_nicename) AND (pm.id=1)
    Inserting post "Welcome"
    INSERT INTO wp_posts (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified) VALUES ('2', '2002-08-17 15:37:55', 'Bienvenue à moi, à vous... Voilà, c'est le premier message de ce blog... Whaou, quelle émotion... :) PS : Mettez des commentaires à mes posts, ?a fera plaisir
    ', 'Welcome', '2', '', 'welcome', 'publish', '2002-08-17 15:37:55')
    Invalid query: You have an error in your SQL syntax near 'est le premier message de ce blog... Whaou, quelle émotion... :) PS : Mett' at line 4

    Problem seems to be with “c’est”, obviously. Needs a check here…

    Thread Starter _mf_

    (@_mf_)

    The SQL query has to be escaped so the single quotes don’t break it. I’ll be releasing a new version when time permits, unless someone sends me the fix before. Thx. for pointing that out, MrPeer!

    Thread Starter _mf_

    (@_mf_)

    MrPeer: I think your PHP setup’s magic_quotes settings may affect this. So, escaping the string may not be the best idea. Let’s try this… change the lines around line 263 for this:
    $query = ‘INSERT INTO $tableposts
    (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified)
    VALUES
    (“$post_author_id”, “$posted”, “$content”, “$title”, “$category”, “$excerpt”, “$post_name”, “publish”, “$posted”)’;
    Let us know if that works for you.

    mrpeer

    (@mrpeer)

    it doesn’t work :
    Inserting post “Welcome”
    INSERT INTO $tableposts (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified) VALUES (“$post_author_id”, “$posted”, “$content”, “$title”, “$category”, “$excerpt”, “$post_name”, “publish”, “$posted”)
    Invalid query: Table ‘peer2.$tableposts’ doesn’t exist

    Problème de double-quote, je pense.
    Peer, m’est avis que c’est plut?t :
    $query = “INSERT INTO $tableposts
    (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified)
    VALUES
    (‘$post_author_id’, ‘$posted’, ‘$content’, ‘$title’, ‘$category’, ‘$excerpt’, ‘$post_name’, ‘publish’, ‘$posted’)”;
    (donc, inverser les ” et les ‘ )
    Non ?

    Thread Starter _mf_

    (@_mf_)

    Xibe: The current code is like what you posted.
    Mr. Peer: Don’t know what I was thinking… This is untested but you can try it. Find these two lines:
    $content = $post[‘body’] . “<P />” . $post[‘more’];
    $excerpt = $post[‘blurb’];
    Change to:
    $content = addslashes($post[‘body’] . “<P />” . $post[‘more’]);
    $excerpt = addslashes($post[‘blurb’]);
    This may also be needed for the users descriptions. Change:
    $wp_description = $user[‘bio’] . “\nLocation: ” . $user[‘location’] . “\nOccupation: ” . $user[‘occupation’] . “\nInterests: ” . $user[‘interests’] ;
    To:
    $wp_description = addslashes($user[‘bio’] . “\nLocation: ” . $user[‘location’] . “\nOccupation: ” . $user[‘occupation’] . “\nInterests: ” . $user[‘interests’] );
    Reference:
    https://ca2.php.net/manual/en/function.addslashes.php
    I will be testing and posting a fix tonight.

    As far as I can understand, all posts are set to “publish” ? What about the pM posts that are not yet public ?
    (I have quite a few myself, waiting to be completed)
    Or did I read this excerpt the wrong way ?

Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘ANNOUNCE: PMachine 2.0 import (v0.1)’ is closed to new replies.