summaryrefslogtreecommitdiffstats
path: root/class
diff options
context:
space:
mode:
Diffstat (limited to 'class')
-rw-r--r--class/Parser.php35
1 files changed, 26 insertions, 9 deletions
diff --git a/class/Parser.php b/class/Parser.php
index 5146044..57b0a77 100644
--- a/class/Parser.php
+++ b/class/Parser.php
@@ -191,15 +191,32 @@ class Parser
} else if ($TimRemote > $row['stamp']) {
self::log("Loading $UrlRemote");
- $fic=gzopen($UrlRemote, "r");
- if ($fic) {
- $txt="";
- while ($buf=gzread($fic, 8196)) {
- $txt .= $buf;
+ $txt = file_get_contents($UrlRemote);
+ if (!$txt) {
+ self::log("ERROR : can't read $UrlRemote");
+ } else if (str_ends_with($UrlRemote, '.xml')) {
+ // OK
+ } else if (str_ends_with($UrlRemote, '.xz')) {
+ if (function_exists('xzdecode')) {
+ $txt = xzdecode($txt);
+ } else {
+ self::log("ERROR : missing xz php extension");
+ return NULL;
}
- self::log("Read " . strlen($txt) . " bytes");
- gzclose($fic);
-
+ } else if (str_ends_with($UrlRemote, '.zst')) {
+ if (function_exists('zstd_uncompress')) {
+ $txt = zstd_uncompress($txt);
+ } else {
+ self::log("ERROR : missing zstd php extension");
+ return NULL;
+ }
+ } else if (str_ends_with($UrlRemote, '.gz')) {
+ $txt = gzdecode($txt);
+ } else {
+ self::log("ERROR : unkown compression");
+ return NULL;
+ }
+ if ($txt) {
$primary = simplexml_load_string($txt);
if ($primary) {
self::log("Read " . $primary->attributes() . " packages");
@@ -210,7 +227,7 @@ class Parser
self::log("ERROR : can't parse $UrlRemote");
}
} else {
- self::log("ERROR : can't read $UrlRemote");
+ self::log("ERROR : can't uncompress $UrlRemote");
}
} else {
self::log("no update needed : $TimRemote / " . $row['stamp']);