summaryrefslogtreecommitdiffstats
path: root/inc/download.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2023-11-15 19:05:43 +0100
committerSimon Rettberg2023-11-15 19:05:43 +0100
commit1f6846bd10682f4c6a82b3c950c71ae76288a7f1 (patch)
tree3eb39784e1123dd7c348e846798069061dbe5d6a /inc/download.inc.php
parentRemove 32bit support (diff)
downloadslx-admin-1f6846bd10682f4c6a82b3c950c71ae76288a7f1.tar.gz
slx-admin-1f6846bd10682f4c6a82b3c950c71ae76288a7f1.tar.xz
slx-admin-1f6846bd10682f4c6a82b3c950c71ae76288a7f1.zip
[inc/Download] Fix downloading from Wikipedia
Diffstat (limited to 'inc/download.inc.php')
-rw-r--r--inc/download.inc.php5
1 files changed, 5 insertions, 0 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);