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
|
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/common.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$returnCode = "success";
if($_POST["botcheck"] != "isopod" or $_POST['msg']) {
$returnCode = "botcheckfailed";
} else if(!$_POST["name"]) {
$returnCode = "noname";
} else if(!$_POST["message"]) {
$returnCode = "nomessage";
} else if(
$_POST["website"] and !preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $_POST["website"])
or $_POST["cool"] and !preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $_POST["cool"])
) {
$returnCode = "invalidlink";
} else {
date_default_timezone_set("America/Edmonton");
$modstatus = $defaultmodstatus;
$bannedwords = json_decode(file_get_contents($datadir."bannedwords.json"));
$bwspotted = false;
foreach($bannedwords as $word) {
if(preg_grep($word, $_POST)) {
$modstatus = 0;
}
}
if($modstatus < 1) {
$returnCode = "review";
}
$currentPost = array(
"entry" => $_POST["entry"],
"sourceip" => $_SERVER['REMOTE_ADDR'],
"date" => time(),
"name" => $_POST["name"],
"message" => $_POST["message"],
"found" => $_POST["found"],
"website" => $_POST["website"],
"cool" => $_POST["cool"],
"reply" => "",
"modstatus" => $modstatus
);
$filename = $datadir."posts.json";
$extantPosts = json_decode(file_get_contents($filename));
array_push($extantPosts, $currentPost);
file_put_contents($filename, json_encode($extantPosts, JSON_PRETTY_PRINT));
}
}
$referrer = preg_replace("/\?.*/", "", $_SERVER['HTTP_REFERER']);
header("Location: $referrer?return=$returnCode");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Guestbook</title>
<link href="../style.css" rel="stylesheet" type="text/css" media="all">
<style type="text/css">
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/seasonal.php'); ?>
</head>
<body>
<p>Your post has been submitted! It's weird that you're seeing this page though. Maybe your browser can't process location headers? At any rate, click <?php echo "<a href='./?return=$returnCode'>here</a>"; ?> to get where you're supposed to be right now.</p>
</body>
</html>
|