-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpme-connect-delete.php
More file actions
42 lines (37 loc) · 1.32 KB
/
pme-connect-delete.php
File metadata and controls
42 lines (37 loc) · 1.32 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
<?php
if (!defined('CORRECT_ENTRY')) {
http_response_code(500);
echo 'Internal server error';
exit();
}
if($_SERVER['REQUEST_METHOD'] !== 'DELETE') {
http_response_code(405);
echo 'Method not allowed';
exit();
}
$establishId = $pathParts[3];
$deletePreparedKeysStatement = $pdo->prepare('DELETE FROM `prepared_keys` WHERE `profile` = ? and `establish_id` = ?');
$deletePreparedKeysStatement->bindValue(1, $profile['name'], PDO::PARAM_STR);
$deletePreparedKeysStatement->bindValue(2, $establishId , PDO::PARAM_STR);
try {
$deletePreparedKeysStatement->execute();
} catch (PDOException $e) {
http_response_code(500);
echo 'Internal server error';
exit();
}
$deleteSPreparedConnectionStatement = $pdo->prepare('DELETE FROM `prepared_connections` WHERE `profile` = ? and `establish_id` = ?');
$deleteSPreparedConnectionStatement->bindValue(1, $profile['name'], PDO::PARAM_STR);
$deleteSPreparedConnectionStatement->bindValue(2, $establishId , PDO::PARAM_STR);
try {
if($deleteSPreparedConnectionStatement->execute() && $deleteSPreparedConnectionStatement->rowCount() > 0) {
http_response_code(204);
} else {
http_response_code(404);
echo 'Prepared connection not found';
}
} catch (PDOException $e) {
http_response_code(500);
echo 'Internal server error';
exit();
}