mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-15 08:47:52 -05:00
* Replace deprecated CURLOPT_ENCODING The CURLOPT_ENCODING setting has been deprecated in favor of CURLOPT_ACCEPT_ENCODING. Signed-off-by: Michael Meier <mmeier1986@gmail.com> * Sync with our SimplePie fork PR https://github.com/FreshRSS/simplepie/pull/67 https://github.com/simplepie/simplepie/pull/960 https://github.com/simplepie/simplepie/pull/962 * Our SimplePie PR merged --------- Signed-off-by: Michael Meier <mmeier1986@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
37 lines
1.1 KiB
PHP
Executable File
37 lines
1.1 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
declare(strict_types=1);
|
|
|
|
if (php_sapi_name() !== 'cli') {
|
|
echo 'Error: This script may only be invoked from command line!', PHP_EOL;
|
|
die(3);
|
|
}
|
|
|
|
$options = getopt('', ['url::', 'connect_timeout::', 'timeout::']);
|
|
$address = is_string($options['url'] ?? null) ? $options['url'] : 'http://localhost/api/';
|
|
$ch = curl_init($address);
|
|
if ($ch === false) {
|
|
fwrite(STDERR, 'Error: Failed to initialize cURL!' . PHP_EOL);
|
|
die(4);
|
|
}
|
|
curl_setopt_array($ch, [
|
|
CURLOPT_CONNECTTIMEOUT => is_numeric($options['connect_timeout'] ?? null) ? (int)$options['connect_timeout'] : 3,
|
|
CURLOPT_TIMEOUT => is_numeric($options['timeout'] ?? null) ? (int)$options['timeout'] : 5,
|
|
CURLOPT_ACCEPT_ENCODING => '', //Enable all encodings
|
|
CURLOPT_HTTPHEADER => [
|
|
'Connection: close',
|
|
],
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
]);
|
|
$content = curl_exec($ch);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
if ($httpCode !== 200 || !is_string($content)) {
|
|
die(1);
|
|
}
|
|
|
|
$content = rtrim($content, "\n\r");
|
|
if (!str_starts_with($content, '<!DOCTYPE html>') || !str_ends_with($content, '</html>') || !str_contains($content, '/scripts/api.js')) {
|
|
die(2);
|
|
}
|