106 lines
3.2 KiB
PHP
106 lines
3.2 KiB
PHP
<?php
|
|
$db = mysqli_connect('', '', '', '');
|
|
mysqli_set_charset($db, "utf8");
|
|
|
|
if(isset($_POST['name'])){
|
|
$name=$_POST['name'];
|
|
|
|
if(isset($_POST['g-recaptcha-response'])){
|
|
$captcha=$_POST['g-recaptcha-response'];
|
|
}
|
|
|
|
$secretKey = "";
|
|
$ip = $_SERVER['REMOTE_ADDR'];
|
|
// post request to server
|
|
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secretKey) . '&response=' . urlencode($captcha);
|
|
$response = file_get_contents($url);
|
|
$responseKeys = json_decode($response,true);
|
|
// should return JSON with success as true
|
|
if($responseKeys["success"]) {
|
|
|
|
$receive = true;
|
|
$name = preg_replace('/[^a-zA-Z -\x7f\-\xff]/', '', $name);
|
|
$name = preg_replace('/-+/', '-', $name);
|
|
$name = str_replace('\' ', '\'', ucwords(str_replace('\'', '\' ', strtolower($name))));
|
|
|
|
$query = 'SELECT `name` FROM `pronoia` ORDER BY `id` DESC;';
|
|
$result = mysqli_query($db, $query);
|
|
$row = mysqli_fetch_object($result);
|
|
if($row->name == $name){
|
|
while($row->name == $name){ //ALWAYS have at least 2 different name entries in the table
|
|
$row = mysqli_fetch_object($result);
|
|
}
|
|
}
|
|
|
|
$god = $row->name;
|
|
|
|
if($name != ""){
|
|
$ip = $_SERVER['REMOTE_ADDR'];
|
|
$query = "SELECT * FROM `pronoia` WHERE `time` >= CURDATE() and `ip` LIKE '".$ip."';";
|
|
$result = mysqli_query($db, $query);
|
|
if(!mysqli_fetch_array($result)){
|
|
$query = 'INSERT INTO `pronoia` (`name`, `ip`, `time`) VALUES ("'.$name.'", "'.$ip.'", NOW());';
|
|
mysqli_query($db, $query);
|
|
} else {
|
|
//echo 'someone already made a post from that IP today';
|
|
}
|
|
} else {
|
|
//echo 'Name empty..';
|
|
}
|
|
|
|
} else {
|
|
//echo 'reCAPTCHA invalid...';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Pronoia</title>
|
|
<meta name="author" content="Victor Giers">
|
|
<meta name="date" content="2019-03-13">
|
|
<script>
|
|
var move = function(){
|
|
document.forms['enterName'].submit();
|
|
};
|
|
window.addEventListener('keydown',function(e){if(e.keyIdentifier=='U+000A'||e.keyIdentifier=='Enter'||e.keyCode==13){if(e.target.nodeName=='INPUT'&&e.target.type=='text'){e.preventDefault();return false;}}},true);
|
|
</script>
|
|
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div id="content">
|
|
<?php
|
|
if(isset($receive)) {
|
|
?>
|
|
|
|
|
|
I love you.<br/>
|
|
I will always protect you.<br/>
|
|
I want you to achieve all your goals.<br/>
|
|
The universe is conspiring in your favour.<br/>
|
|
Everything that happens is always just what you need for your personal growth.<br/>
|
|
You are great, strong and able to achieve everything.<br/>
|
|
Yours sincerely,<br/>
|
|
<?=$god ?>
|
|
|
|
<?php
|
|
} else {
|
|
?>
|
|
<center>
|
|
<form id="comment_form" name="enterName" action="index.php" method="post">
|
|
<input type="text" name="name" placeholder="Enter name (optional)" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter name (optional)'" maxlength="50"><br><br>
|
|
<div class="g-recaptcha" data-sitekey="" data-callback="move"></div>
|
|
</form>
|
|
</center>
|
|
<?php
|
|
|
|
}
|
|
?>
|
|
</div>
|
|
<div class="stars"></div>
|
|
<div class="twinkling"></div>
|
|
</body>
|
|
</html>
|