summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-11-15 19:05:43 +0100
committerSimon Rettberg2023-11-15 19:05:43 +0100
commit1f6846bd10682f4c6a82b3c950c71ae76288a7f1 (patch)
tree3eb39784e1123dd7c348e846798069061dbe5d6a
parentRemove 32bit support (diff)
downloadslx-admin-1f6846bd10682f4c6a82b3c950c71ae76288a7f1.tar.gz
slx-admin-1f6846bd10682f4c6a82b3c950c71ae76288a7f1.tar.xz
slx-admin-1f6846bd10682f4c6a82b3c950c71ae76288a7f1.zip
[inc/Download] Fix downloading from Wikipedia
-rw-r--r--inc/download.inc.php5
-rw-r--r--modules-available/sysconfig/addmodule_branding.inc.php4
2 files changed, 8 insertions, 1 deletions
diff --git a/inc/download.inc.php b/inc/download.inc.php
index 578992a6..2eef219c 100644
--- a/inc/download.inc.php
+++ b/inc/download.inc.php
@@ -27,6 +27,8 @@ class Download
curl_setopt(self::$curlHandle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt(self::$curlHandle, CURLOPT_AUTOREFERER, true);
curl_setopt(self::$curlHandle, CURLOPT_MAXREDIRS, 6);
+ curl_setopt(self::$curlHandle, CURLOPT_ACCEPT_ENCODING, '');
+ curl_setopt(self::$curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_FTP | CURLPROTO_FTPS | CURLPROTO_HTTP | CURLPROTO_HTTPS);
}
curl_setopt(self::$curlHandle, CURLOPT_URL, $url);
@@ -41,6 +43,7 @@ class Download
public static function asString(string $url, int $timeout, ?int &$code)
{
$ch = self::initCurl($url, $timeout);
+ curl_setopt($ch, CURLOPT_FILE, null);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$code = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
@@ -68,6 +71,7 @@ class Download
}
}
$ch = self::initCurl($url, $timeout);
+ curl_setopt($ch, CURLOPT_FILE, null);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
@@ -90,6 +94,7 @@ class Download
if ($fh === false)
ErrorHandler::traceError("Could not open $target for writing.");
$ch = self::initCurl($url, $timeout);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_FILE, $fh);
$res = curl_exec($ch);
$code = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
diff --git a/modules-available/sysconfig/addmodule_branding.inc.php b/modules-available/sysconfig/addmodule_branding.inc.php
index 5d94a489..52d466fe 100644
--- a/modules-available/sysconfig/addmodule_branding.inc.php
+++ b/modules-available/sysconfig/addmodule_branding.inc.php
@@ -47,8 +47,10 @@ class Branding_ProcessFile extends AddModule_Base
if (strpos($url, '://') === false)
$url = "http://$url";
$title = false;
- if (!Branding_ProcessFile::downloadSvg($this->svgFile, $url, $title))
+ if (!Branding_ProcessFile::downloadSvg($this->svgFile, $url, $title)) {
+ @unlink($this->svgFile);
Util::redirect('?do=SysConfig&action=addmodule&step=Branding_Start');
+ }
Session::set('logo_name', $title);
}
chmod($this->svgFile, 0644);