-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
executable file
·57 lines (49 loc) · 1.42 KB
/
Copy pathdelete.php
File metadata and controls
executable file
·57 lines (49 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
// Include private functions
require_once 'private.php';
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
global $secret_key;
$name = isset($_GET['name']) ? trim($_GET['name']) : '';
$key = isset($_GET['key']) ? trim($_GET['key']) : '';
if (empty($name) || empty($key)) {
http_response_code(400);
echo json_encode([
"error_code" => 1,
"error_message" => "Both 'name' and 'key' parameters are required."
]);
exit;
}
// Get consolidated data
$storageData = getStorageData($key, $secret_key);
if (!isset($storageData[$name])) {
http_response_code(404);
echo json_encode([
"error_code" => 2,
"error_message" => "Data not found."
]);
exit;
}
// Remove the API from storage
unset($storageData[$name]);
// Save updated data (keep empty file to prevent sample refill)
if (!saveStorageData($key, $secret_key, $storageData)) {
http_response_code(500);
echo json_encode([
"error_code" => 3,
"error_message" => "Failed to update the storage file."
]);
exit;
}
http_response_code(200);
echo json_encode([
"error_code" => 0,
"error_message" => "API deleted successfully."
]);
exit;
}
http_response_code(405);
echo json_encode([
"error_code" => 4,
"error_message" => "Method not allowed."
]);
?>