logifuture with proxy wip

This commit is contained in:
salam committed 2026-01-05 16:23:14 +01:00
1 parent a96abae35a
commit 2e57e49f08
19 files changed
+196 -77

No files matched your search

+39 -22
View File
@@ -16,7 +16,10 @@ class Curl
$proxy = Nuh::$options['p'] ?? 0;
if ($debug) {
Notice::note($url);
Notice::note($url, 'g');
if ($proxy) {
Notice::note(Nuh::$options['proxy'], 'r');
}
}
if ($read) {
@@ -29,22 +32,10 @@ class Curl
return json_decode($file, true);
}
// POST
if (isset($_config['post'])) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($_config['post']));
}
// JSON
if (isset($_config['header'])) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $_config['header']);
}
if ($proxy) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, Nuh::$options['proxy']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
@@ -55,34 +46,60 @@ class Curl
'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx',
]);
} else {
$ch = curl_init($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
// POST
if (isset($_config['post'])) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($_config['post']));
}
// JSON
if (isset($_config['header'])) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $_config['header']);
}
}
$data = curl_exec($ch);
$file = curl_exec($ch);
$curl_errorno = curl_errno($ch);
if ($curl_errorno) {
Notice::note('curl_errorno: '.self::curlerrorcode($curl_errorno));
}
if (PHP_VERSION_ID < 80000) {
curl_close($ch);
}
if ($save) {
$filename = app_path().self::$testfiles.strtolower(str_replace(' ', '_', Nuh::$options['name'])).'.json';
file_put_contents($filename, $data);
file_put_contents($filename, $file);
Notice::note('file saved localy', 'g');
}
return json_decode($data, true);
$data = json_decode($file, true);
switch (json_last_error()) {
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
}
return $data;
}
public static function curlerrorcode($id)