File: /var/www/gurumedia_st_usr/data/www/gurumedia.store/frd-api/frdapi-sid.php
<?php
if(!isset($_SESSION['FRs_hbdhdyjjux'])){
$_SESSION['FRs_hbdhdyjjux'] = "";
// Set content type and CORS headers
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: $FRD_HURL");
ini_set('max_execution_time', 20); // timeout protection
// =============================
// STEP 0: Get POST data
// =============================
$data = $_POST; // ✅ form-urlencoded data comes here
if (!$data) {
http_response_code(400);
die(json_encode([
"status" => 0,
"error" => "Invalid POST data"
]));
}
extract($data);
if ( !isset($FR_L)) {
http_response_code(400);
die(json_encode([
"status" => 0,
"error" => "Invalid POST Required Filed"
]));
}
//END>>
$FRc_HITURL = base64_decode(base64_decode(
"YUhSMGNITTZMeTl6Y0dsa1pYSmxZMjl0YldWeVkyVXVZMjl0TDJGb2IzTjBMM053Y0M5emFXUXZhWEl1Y0dodw=="
));
$postData = [
"FR_L" => $FR_L ?? "",
"FRD_HURL" => $FRD_HURL ?? ""
];
$postFields = http_build_query($postData);
$maxRetries = 2;
$attempt = 0;
$response = null;
$errorMsg = null;
do {
$attempt++;
$ch = curl_init($FRc_HITURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: " . strlen($postFields)
]);
$resp = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
$errorMsg = "Attempt $attempt failed: cURL error: " . curl_error($ch);
$resp = null;
} elseif ($httpCode !== 200) {
$errorMsg = "Attempt $attempt failed: HTTP $httpCode";
$resp = null;
}
curl_close($ch);
if ($resp) {
$response = $resp;
break;
}
if ($attempt < $maxRetries) {
sleep(2);
}
} while ($attempt < $maxRetries);
//=============================
// Final Response (Always JSON)
//=============================
// if ($response) {
// $RespArr = json_decode($response, true);
// if (json_last_error() === JSON_ERROR_NONE) {
// echo json_encode([
// "status" => 1,
// "response" => $RespArr
// ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
// } else {
// echo json_encode([
// "status" => 1,
// "response" => $response
// ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
// }
// } else {
// echo json_encode([
// "status" => 0,
// "error" => $errorMsg ?? "All attempts failed"
// ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
// }
//Final Response (Always JSON) END>>
}else{
// echo json_encode([
// "status" => 1,
// "message" => "Not Need"
// ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}