PhpWiki2MediaWiki
PhpWiki is non standard and not well supported lately. WikiWorld moved to a [new server] with [php5]. Running WikiWorld failed miserably using either the php4 version it was using or importing into the latest php5 version, so WE decided it was time to convert to a more standard wiki, the one used by [Wikipedia].
We used shell and sed like this:
http://meta.wikimedia.org/wiki/Documentation:PhpWiki_conversion
I enhanced it to encode bare WikiWords, %%% newlines, and <verbatim> markups
cat phpwikiconvert
# typeset markup
s/_\([^_]*\)_/''\1''/g # italic -- OK
s/\*\([^\*]*\)\*/'''\1'''/g # boldface -- OK
s!=\([^=]*\)=!<code>\1</code>!g # fixed-width -- OK
# header markup -- OK
s/!!!\(.*\)$/==\1==/g
s/!!\(.*\)$/===\1===/g
s/!\(.*\)$/====\1====/g
# table markup (hopefully)
s!\([^|][^|]*\)|!\1||!g
s!^|!|-\n|!g # convert row start -- OK
s!.*plugin OldStyleTable.*!\{\|! # convert table start -- mostly OK
s!^?>$!\|\}! # convert table end -- mostly OK
# link markup
s!\[\(.*\)|\(http.*\)]![\2 \1]!g # url format -- OK
s!\[\(.*\)|\(.*\)\]![\2|\1]!g # switch display and link text -- OK
s!\[\([^]]*\)\]![[\1]]!g # double bracketize -- OK
s!\[\[\(http.*\)\]\]![\1]!g # undo double-bracketing urls by above -- OK
# redirects
s!<?plugin RedirectTo page=\(.*\)?>!#REDIRECT [[\1]]!
# quotes
s!"!\\"!g
# %%% newlines - jim
s/!%%%/<br>/
s/<verbatim>/<pre>/
s!</vertatim>!</ pre>! # take out space b4 running - jim
#wikiwords - jim - allowing numbers added afterwards
s/^\([A-Z][a-z0-9][a-z0-9]*[A-Z][A-Za-z0-9]*\)/[[\1]]/
s/ \([A-Z][a-z0-9][a-z0-9]*[A-Z][A-Za-z0-9]*\)/ [[\1]]/g
Files in the converted directory containing double back slashes got errors which I fixed by hand
grep -l "\\\\\\\\" * # will list any having double slashes
Files orginally having space in the name were not loaded with spaces in the name so I updated the load script to fix that.
for file in *; do
title=`echo $file|sed 's!/!/!g;s|_| |g'|perl -n -e "print ucfirst;"`
cat <<END | mysql -u <username> -p<password> <databasename>
INSERT INTO page
(page_id, page_namespace, page_title, page_counter, page_restrictions, page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)
VALUES
(NULL,0, "$title", 0,, 0, 1, RAND(), NOW() 0, 0, LENGTH("`cat $file`"));
INSERT INTO text (old_id, old_text, old_flags)
VALUES (NULL, "`cat $file`", "utf-8");
INSERT INTO revision
(rev_id, rev_page, rev_text_id, rev_comment, rev_minor_edit, rev_user, rev_user_text, rev_timestamp)
SELECT NULL, page_id, LAST_INSERT_ID(),"PhpWikiMigration", 0, 1 ,"Admin", NOW() 0 FROM page WHERE page_title = "$title";
UPDATE page,revision
SET page.page_latest = LAST_INSERT_ID()
WHERE page.page_id = revision.rev_page