User Tools

Site Tools


it:tools:db:spbimporter

Differences

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

Link to this comparison view

it:tools:db:spbimporter [2019/01/12 17:53] – external edit 127.0.0.1it:tools:db:spbimporter [2020/01/01 00:03] (current) – removed arvid
Line 1: Line 1:
-====== SPB Importer ====== 
  
-Traduzione italiana (a tratti libera) del documento [[tools:db:spbimporter|SPB Importer]]. 
- 
-//[[drudo3@gmail.com|Luciano P.]] 2007/07/03// 
- 
-Fare un **BACKUP** della cartella ''content/'' prima di eseguire lo script. 
- 
-''isoconvert.php'' importa e converte il "database" di SPB (Simple PHP Blog), codificato con il set iso-8859-1, per FlatPress ricodificato in UTF-8; inoltre rimuove alcune chiavi non supportate (//relatedlink//) e spazi bianchi. 
- 
-===== Installazione ed uso ===== 
- 
-  - Copiare il codice riportato poco sotto in un file, salvare con nome ''isoconvert.php'' e metterlo nella cartella di installazione di FlatPress. 
-  - Una volta messo nella cartella root di installazione, puntare il browser su http://yoursite/flatpress/isoconvert.php 
-  - **IMPORTANTE**: non dimenticare di **cancellare** questo file una volta terminata l' importazione. 
- 
- 
- 
-===== Altre Informazioni Importanti ===== 
- 
-''isoconvert.php'' può importare anche da file archiviati in formato GZ. 
- 
-L' importazione di file .gz è disabilitata di default, così per permettere la conversione si deve aggiungere un campo, quindi far puntare il browser al file in questo modo: 
-http://mysite/flatpress/isoconvert.php?ungz=true 
- 
-**ATTENZIONE** in caso vengano SALTATI (SKIPPED) alcuni file GZ, NON è possibile far eseguire lo script una seconda volta con il parametro ''ungz=true'', poichè i rimanenti file sono già stati convertiti! Si consiglia quindi in questo caso di **cancellare** la cartella content/ e mettere al suo interno un backup pulito di SPB e quindi rieseguire lo script. Naturalmente è necessario un **backup** di riserva. 
- 
-E' possibile anche eseguire lo script [[tools:db:dump|DB Dump]] che genera un elenco di problemi comunemente riscontrabili. Se [[tools:db:dump|DB Dump]] elenca dei file GZ, allora **si deve** prima eseguire ''isoconvert.php'' ''con ungz=true''. 
- 
-===== isoconvert.php ===== 
- 
- 
-<code 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."; 
-  
- } 
- 
-?> 
-</code> 
it/tools/db/spbimporter.1547312016.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