-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpme-keys-delete.php
More file actions
75 lines (73 loc) · 2.5 KB
/
pme-keys-delete.php
File metadata and controls
75 lines (73 loc) · 2.5 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?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();
}
if(count($pathParts) == 3) {
$audience = $pathParts[2];
$deleteStatement = $pdo->prepare('DELETE FROM profile_keys WHERE profile=? and enc_with_grp=?');
$deleteStatement->bindValue(1, $profile['name'], PDO::PARAM_STR);
$deleteStatement->bindValue(2, $audience, PDO::PARAM_STR);
try {
if($deleteStatement->execute() && $deleteStatement->rowCount() > 0) {
http_response_code(204);
} else {
http_response_code(404);
echo 'Keys not found';
}
} catch (PDOException $e) {
http_response_code(500);
echo 'Internal server error';
exit();
}
} elseif(count($pathParts) == 4) {
$audience = $pathParts[2];
$group = $pathParts[3];
$deleteStatement = $pdo->prepare('DELETE FROM profile_keys WHERE profile=? and enc_with_grp=? and grp=?');
$deleteStatement->bindValue(1, $profile['name'], PDO::PARAM_STR);
$deleteStatement->bindValue(2, $audience, PDO::PARAM_STR);
$deleteStatement->bindValue(3, $group, PDO::PARAM_STR);
try {
if($deleteStatement->execute() && $deleteStatement->rowCount() > 0) {
http_response_code(204);
} else {
http_response_code(404);
echo 'Keys not found';
}
} catch (PDOException $e) {
http_response_code(500);
echo 'Internal server error';
exit();
}
} elseif(count($pathParts) == 5) {
$audience = $pathParts[2];
$group = $pathParts[3];
$round = $pathParts[4];
$deleteStatement = $pdo->prepare('DELETE FROM profile_keys WHERE profile=? and enc_with_grp=? and grp=? and rnd=?');
$deleteStatement->bindValue(1, $profile['name'], PDO::PARAM_STR);
$deleteStatement->bindValue(2, $audience, PDO::PARAM_STR);
$deleteStatement->bindValue(3, $group, PDO::PARAM_STR);
$deleteStatement->bindValue(4, $round, PDO::PARAM_STR);
try {
if($deleteStatement->execute() && $deleteStatement->rowCount() > 0) {
http_response_code(204);
} else {
http_response_code(404);
echo 'Keys not found';
}
} catch (PDOException $e) {
http_response_code(500);
echo 'Internal server error';
exit();
}
} else {
http_response_code(500);
echo 'Internal server error';
exit();
}