]> git.wh0rd.org - tt-rss.git/commitdiff
support gzipped xml import
authorAndrew Dolgov <fox@fakecake.org>
Wed, 28 Dec 2011 07:00:58 +0000 (11:00 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Wed, 28 Dec 2011 07:00:58 +0000 (11:00 +0400)
include/functions.php

index 018e518ebad0f411fef244a2b099822ea35f1f7c..1b780d955210d042d38e7338a4439813fd878f13 100644 (file)
                return $rv;
        }
 
+       if (!function_exists('gzdecode')) {
+               function gzdecode($string) { // no support for 2nd argument
+                       return file_get_contents('compress.zlib://data:who/cares;base64,'.
+                               base64_encode($string));
+               }
+       }
+
        function perform_data_import($link, $filename, $owner_uid) {
 
                $num_imported = 0;
                $num_processed = 0;
                $num_feeds_created = 0;
 
-               $doc = DOMDocument::load($filename);
+               $doc = @DOMDocument::load($filename);
+
+               if (!$doc) {
+                       $contents = file_get_contents($filename);
+
+                       if ($contents) {
+                               $data = @gzuncompress($contents);
+                       }
+
+                       if (!$data) {
+                               $data = @gzdecode($contents);
+                       }
+
+                       if ($data)
+                               $doc = DOMDocument::loadXML($data);
+               }
 
                if ($doc) {