54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if (isset($_POST['pid']))
|
|
{
|
|
if (isset($_SESSION['token'])) {
|
|
$token = $_SESSION['token'];
|
|
$user=$_POST['pid'];
|
|
//$pid =$_POST[]; // Replace with your actual PID or get it dynamically from your application
|
|
|
|
// Ensure $pid is properly sanitized or validated before using in the URL
|
|
|
|
//-------------------API CALL------------------------------------//
|
|
|
|
$jsonFilePath = __DIR__ . '/../urls/api_endpoints.json';
|
|
$jsonData = file_get_contents($jsonFilePath);
|
|
$endpoints = json_decode($jsonData, true);
|
|
$url = $endpoints['connection_delete'] . $user;
|
|
//---------------------------ENDS HERE-----------------------------------------//
|
|
|
|
|
|
$headers = [
|
|
"Authorization: Bearer $token",
|
|
];
|
|
|
|
$options = [
|
|
'http' => [
|
|
'header' => implode("\r\n", $headers),
|
|
'method' => 'DELETE',
|
|
'ignore_errors' => true
|
|
],
|
|
'ssl' => [
|
|
'verify_peer' => false,
|
|
'verify_peer_name' => false
|
|
]
|
|
];
|
|
|
|
$context = stream_context_create($options);
|
|
$response = file_get_contents($url, false, $context);
|
|
|
|
if ($response !== false) {
|
|
echo '<script>window.location.href = "../configuration/connectionprofile.php";</script>';
|
|
exit;
|
|
}
|
|
else
|
|
{
|
|
$response = json_encode(['status' => 'error', 'message' => 'Failed to fetch data']);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
?>
|