From 3382bce16dd885d4f2894c18c2d4c82438be1dcc Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 28 Dec 2011 11:00:58 +0400 Subject: [PATCH] support gzipped xml import --- include/functions.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/include/functions.php b/include/functions.php index 018e518e..1b780d95 100644 --- a/include/functions.php +++ b/include/functions.php @@ -5116,13 +5116,35 @@ 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) { -- 2.39.5