]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/import_export/init.php
import_export: various bugfixes
[tt-rss.git] / plugins / import_export / init.php
index d4bdec826a83f1bf71179090a313842156165714..7c628909ff11de71df78981d4ec696df35495d73 100644 (file)
@@ -106,11 +106,13 @@ class Import_Export extends Plugin implements IHandler {
                if (file_exists($exportname)) {
                        header("Content-type: text/xml");
 
+                       $timestamp_suffix = date("Y-m-d", filemtime($exportname));
+
                        if (function_exists('gzencode')) {
-                               header("Content-Disposition: attachment; filename=TinyTinyRSS_exported.xml.gz");
+                               header("Content-Disposition: attachment; filename=TinyTinyRSS_exported_${timestamp_suffix}.xml.gz");
                                echo gzencode(file_get_contents($exportname));
                        } else {
-                               header("Content-Disposition: attachment; filename=TinyTinyRSS_exported.xml");
+                               header("Content-Disposition: attachment; filename=TinyTinyRSS_exported_${timestamp_suffix}.xml");
                                echo file_get_contents($exportname);
                        }
                } else {
@@ -189,6 +191,8 @@ class Import_Export extends Plugin implements IHandler {
                $num_processed = 0;
                $num_feeds_created = 0;
 
+               libxml_disable_entity_loader(false);
+
                $doc = @DOMDocument::load($filename);
 
                if (!$doc) {
@@ -206,6 +210,8 @@ class Import_Export extends Plugin implements IHandler {
                                $doc = DOMDocument::loadXML($data);
                }
 
+               libxml_disable_entity_loader(true);
+
                if ($doc) {
 
                        $xpath = new DOMXpath($doc);
@@ -235,10 +241,13 @@ class Import_Export extends Plugin implements IHandler {
                                        $article = array();
 
                                        foreach ($article_node->childNodes as $child) {
-                                               if ($child->nodeName != 'label_cache')
-                                                       $article[$child->nodeName] = db_escape_string($child->nodeValue);
-                                               else
+                                               if ($child->nodeName == 'content') {
+                                                       $article[$child->nodeName] = db_escape_string($child->nodeValue, false);
+                                               } else if ($child->nodeName == 'label_cache') {
                                                        $article[$child->nodeName] = $child->nodeValue;
+                                               } else {
+                                                       $article[$child->nodeName] = db_escape_string($child->nodeValue);
+                                               }
                                        }
 
                                        //print_r($article);
@@ -344,7 +353,6 @@ class Import_Export extends Plugin implements IHandler {
                                                                $score = (int) $article['score'];
 
                                                                $tag_cache = $article['tag_cache'];
-                                                               $label_cache = db_escape_string($article['label_cache']);
                                                                $note = $article['note'];
 
                                                                //print "Importing " . $article['title'] . "<br/>";
@@ -357,9 +365,9 @@ class Import_Export extends Plugin implements IHandler {
                                                                                published, score, tag_cache, label_cache, uuid, note)
                                                                        VALUES ($ref_id, $owner_uid, $feed, false,
                                                                                NULL, $marked, $published, $score, '$tag_cache',
-                                                                                       '$label_cache', '', '$note')");
+                                                                                       '', '', '$note')");
 
-                                                               $label_cache = json_decode($label_cache, true);
+                                                               $label_cache = json_decode($article['label_cache'], true);
 
                                                                if (is_array($label_cache) && $label_cache["no-labels"] != 1) {
                                                                        foreach ($label_cache as $label) {
@@ -381,9 +389,9 @@ class Import_Export extends Plugin implements IHandler {
 
                        print "<p>" .
                                __("Finished: ").
-                               vsprintf(ngettext("%d article processed, ", "%d articles processed, ", $num_processed), $num_processed).
-                               vsprintf(ngettext("%d imported, ", "%d imported, ", $num_imported), $num_imported).
-                               vsprintf(ngettext("%d feed created.", "%d feeds created.", $num_feeds_created), $num_feeds_created).
+                               vsprintf(_ngettext("%d article processed, ", "%d articles processed, ", $num_processed), $num_processed).
+                               vsprintf(_ngettext("%d imported, ", "%d imported, ", $num_imported), $num_imported).
+                               vsprintf(_ngettext("%d feed created.", "%d feeds created.", $num_feeds_created), $num_feeds_created).
                                        "</p>";
 
                } else {