Metrics: Use native functions instead of cURL - better compatibility
This commit is contained in:
parent
3491b00a32
commit
03c0f2e805
|
@ -55,17 +55,19 @@ if(!empty($_COOKIE["tsw_allow_metrics"])) {
|
||||||
$data = json_encode($data);
|
$data = json_encode($data);
|
||||||
$url = "https://wruczek.tech/tsw-metrics/";
|
$url = "https://wruczek.tech/tsw-metrics/";
|
||||||
|
|
||||||
// If cURL is available, use it
|
$options = [
|
||||||
if (function_exists("curl_version")) {
|
"http" => [
|
||||||
$ch = curl_init($url);
|
"header" => "Content-Type: application/json",
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
|
"method" => "POST",
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
"content" => $data
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
]
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
];
|
||||||
$response = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
//echo $response;
|
$context = stream_context_create($options);
|
||||||
|
$response = file_get_contents($url, false, $context);
|
||||||
|
|
||||||
|
if ($response !== "ok") {
|
||||||
|
echo "Error sending metrics :(";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue