-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifyreview.php
More file actions
53 lines (45 loc) · 1.41 KB
/
Copy pathmodifyreview.php
File metadata and controls
53 lines (45 loc) · 1.41 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
<?php
session_start();
if(!isset($_SESSION['email']) || empty($_SESSION['email'])){
http_response_code(401);
echo("Unauthorized");
exit(0);
}
$database_key = file_get_contents('/api-keys/database.key');
$mysqli_con = new mysqli("localhost","http",$database_key,"cleanlineslawncare");
$valid_database = true;
foreach($_POST as $key => $value) {
if (strpos($key, 'delete_') === 0) {
if($value != "1"){
continue;
}
$review_id = str_replace("delete_","",$key);
if(!is_numeric($review_id)){
continue;
}
$review_id = strval($review_id);
if(!mysqli_connect_errno()){
$sql = "DELETE FROM reviews WHERE review_id=?;";
if($stmt = $mysqli_con->prepare($sql)){
$stmt->bind_param('i', $review_id);
$stmt->execute();
$stmt->store_result();
$stmt->close();
} else {
$valid_database = false;
}
} else {
$valid_database = false;
}
}
}
$mysqli_con->close();
if( !$valid_database ){
http_response_code(500);
echo("Invalid database");
exit(0);
}
http_response_code(200);
echo("Success!");
exit(0);
?>