-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsign_guestbook.php
More file actions
72 lines (52 loc) · 1.48 KB
/
Copy pathsign_guestbook.php
File metadata and controls
72 lines (52 loc) · 1.48 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
<?php
# this is the php used to make a new comment on my digital guestbook
# this is just a random string to prevent automated bots
$key = "";
#ini_set('display_errors', '1');
#ini_set('display_startup_errors', '1');
#error_reporting(E_ALL);
if(false == isset($_GET["name"])) {
echo "{\"error\":\"no name\"}";
exit();
}
if(false == isset($_GET["post"])) {
echo "{\"error\":\"no post\"}";
exit();
}
#if(false == isset($_GET["content"])) {
# echo "{\"error\":\"no content\"}";
# exit();
#}
if(false == isset($_GET["key"])) {
echo "{\"error\":\"need key\"}";
exit();
}
$name = $_GET["name"];
$post = $_GET["post"];
$content = $_SERVER['REMOTE_ADDR'];
if ($_GET["key"] == $key) {
# add your db credentials
$conn = new mysqli("localhost", "", "", "");
$ban_check = $conn->prepare("SELECT * FROM `bans` WHERE banned=1 AND ip=?;");
$ban_check->bind_param('s', $content);
$ban_check->execute();
$result = $ban_check->get_result();
$count = 0;
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$count +=1;
}
}
if($count > 0) {
echo "{\"error\":\" Your IP was banned from posting!\"}";
exit();
}
$stmt = $conn->prepare("INSERT INTO `posts`(`post_date`, `name`, `post`, `uid`, `title`) VALUES (CURRENT_TIMESTAMP,?,?,NULL,?);");
$stmt->bind_param('sss',$name, $post, $content);
$stmt->execute();
$result = $stmt->get_result();
echo "{\"error\":\"none\"}";
} else {
echo "{\"error\":\"bad key\"}";
}
?>