Everything you need to know :)
.:: FlatPress Home :: FlatPress support forum :: FlatPress@Twitter ::.
This is an old revision of the document!
BACKUP your original content/
before running your script.
isoconvert.php
imports and converts from SPB iso-8859-1 charset to FP UTF-8; also it removes some offending keys (relatedlink) ad blank keys.
isoconvert.php
and put it in your flatpress/ installation dir.
isoconvert.php
can import from GZ too. If you enabled GZ compression in SPB you should uncompress those files.
GZ import is disabled by default, so to issue the conversion you must point your browser to http://mysite/flatpress/isoconvert.php?ungz=true
WARNING Once you run this script, if you SKIPPED GZ files, then you should run the script once again with ungz=true
, but this would mean converting twice files that were not SKIPPED. So you must delete the content/ dir and put a fresh copy before re-executing the script. Of course this mean you must always have a backup ready.
You can also try the DB Dump script, which should list most of the issues you may find. If dump
lists GZ files, then you'll have to run isoconvert
with ungz=true
.
<?php header('Content-Type: text/plain'); require_once('defaults.php'); require_once(INCLUDES_DIR.'includes.php'); error_reporting(E_ALL); class utfencoder extends fs_filelister { var $_directory = CONTENT_DIR; var $foundgz = false; function _checkFile($d,$f) { $p="$d/$f"; if (is_dir($p)) { return 1; } else { $DO_GZ = (isset($_GET['ungz']))? $_GET['ungz'] : false; echo "Converting $p ... "; $s = io_load_file($p); if ((strpos( $p, '.gz' ) !== false ) ) { if (!$DO_GZ) { $this->foundgz = true; echo "GZ: SKIPPED\n"; return 2; } echo "[WARNING] File was GZ, moving to TXT... "; $s = gzinflate(substr($s, 10 )); if (strpos($f, 'view_counter')!== false) { io_write_file($d . '/view_counter.txt'); echo "(uncompressed) "; } $f = substr($f, 0,-3); unlink($p); $p = "$d/$f"; } $s = mb_convert_encoding($s, 'UTF-8', 'ISO-8859-1'); if (($f != 'view_counter.txt') && (strpos($s, 'VERSION|') === false)) { echo " IMPORTING $f from old versions "; // compatibility with old versions -__-' $cont = explode('|', $s); if (strpos($f, 'entry')!==false) { $s = "VERSION|0.3|SUBJECT|{$cont[0]}|CONTENT|{$cont[2]}|DATE|{$cont[1]}"; } elseif (strpos($f, 'comment')!==false) { $s = "VERSION|0.3|NAME|{$cont[0]}|CONTENT|{$cont[2]}|DATE|{$cont[1]}"; } else { echo "SKIPPED\n"; return; } } // remove or replace offending keys $s = str_replace('relatedlink', 'RELATEDLINK', $s); $s = str_replace('TB_PING||', '', $s); $s = io_write_file($p, $s); echo "DONE\n"; } } } echo "======= FlatPress importer =======\n\n" ; echo "Starting process...\n"; $o =& new utfencoder; echo "\n\nFINISHED"; if ($o->foundgz) { echo "\nWARNING: DataBase contained GZ Files: FlatPress can't read GZipped files,\n" ; echo "so you should call again this script as in /isoconvert.php?ungz=true\n\n"; echo "Please notice that you will LOSE your original GZ files, so DO A BACKUP first."; } ?>