User Tools

Site Tools


tools:db:spbimporter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tools:db:spbimporter [2019/01/12 17:53] – external edit 127.0.0.1tools:db:spbimporter [2020/01/01 00:04] (current) – removed arvid
Line 1: Line 1:
-====== SPB Importer ====== 
  
-**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. 
- 
- 
-===== Installing and using ===== 
- 
-  - Copy the code that follows into a file named ''isoconvert.php'' and put it in your flatpress/ installation dir. 
-  - Put the file in your flatpress/ root and point your browser to %%http://yoursite/flatpress/isoconvert.php%% 
-  - **IMPORTANT**: Don't forget to **delete** this file once you're done with importing. 
- 
- 
- 
-===== Important additional information ===== 
- 
-''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 [[tools:db:dump|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''. 
- 
-===== isoconvert.php ===== 
-<file php isoconvert.php> 
-<?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."; 
-  
- } 
- 
-?> 
-</file> 
tools/db/spbimporter.1547312012.txt.gz · Last modified: 2019/01/12 17:53 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki