Skip to content

Instantly share code, notes, and snippets.

@rymate1234
Created March 17, 2012 22:32
Show Gist options
  • Save rymate1234/2065904 to your computer and use it in GitHub Desktop.
Save rymate1234/2065904 to your computer and use it in GitHub Desktop.
wut O_o
<?php
$user = $_POST['username'];
$captcha_idx = trim($_POST['captcha_index']);
$captcha = trim($_POST['captcha']);
require_once("questions.php");
require_once('recaptchalib.php');
$privatekey = "6LdpEc8SAAAAAJuq24X8fM9kBp3XerQssMwAPC-H";
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!is_numeric($captcha_idx) || !$captcha
|| $captchas[$captcha_idx]["answer"] != $captcha) {
die("Error: wrong answer to the question.");
}
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
$con = mysql_connect("127.0.0.1", "root", "");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
$db = mysql_select_db("testdb", $con);
echo $user + "</br>";
$sql = "INSERT INTO whitelist (name) VALUES ('" + $user + "')";
echo $sql;
if (!mysql_query($sql, $con)) {
die('Error: ' . mysql_error());
}
mysql_close($con);
}
?>
<html>
<head>
<title>Register for the Whitelist!</title>
<style type="text/css">
h1 {
font-size: 2.50em;
}
#page-wrap {
width: 480px;
background: white;
margin: 20px auto;
padding: 20px;
}
a.reveal {
font-size: 65%;
padding: 3px;
background: #009900;
color: white;
font-family: Georgia, serif;
font-style: italic;
cursor: pointer;
}
a.hide {
font-size: 65%;
padding: 3px;
background: #990000;
color: white;
font-family: Georgia, serif;
font-style: italic;
cursor: pointer;
}
body,input
{
font-family:Calibri;
color:#333;
}
.spoiler .inner
{
border:1px solid #eee;
padding:3px;margin:3px;
}
.form
{
border:1px solid #eee;
padding:5px;margin:5px;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script>
<script src="runonload.js"></script>
<script src="tutorial.js"></script>
<script type="text/javascript">
$(document).ready(function() {
isShowing = false;
$("div.inner").hide();
$('<a class="reveal">Toggle Rules &gt;&gt;</a> ').insertBefore('div.inner');
$("a.reveal").click(function(){
if (isShowing == false) {
$(this).parents("div.spoiler").children("div.inner").fadeIn(600);
$("a.reveal").addClass("hide");
isShowing = true;
} else {
$(this).parents("div.spoiler").children("div.inner").fadeOut(600);
$("a.reveal").removeClass("hide");
isShowing = false;
}
});
});
</script>
</head>
<body>
<div id="page-wrap">
<h1>Register for the Whitelist</h1>
<p>Please read the rules before filling out the form :)</p>
<div class="spoiler">
<div class="inner">
<ol class="rules">
<li>No Griefing - Griefing is not tolerated and anyone griefing will be rolled back and banned</li>
<li>No Minecraft Multiplayer Hacks. This Includes xray mods, flymods, chest finders, and other hacks.</li>
<li>Respect the admins</li>
<li>Stealing, PvP and TNT traps are ALLOWED.</li>
<li>No profanities. We have young kids on this server (sadly)</li>
<li>No spawn PvP</li>
</ol>
</div>
</div>
<br>
<div class="form">
<form method="post" action="add.php">
<p><label for="user">Minecraft Username: </label><input type="text" name="username"/><br /> </p>
<?php
require_once("questions.php");
$tabindex = 5;
$captcha_index = rand(0, count($captchas) - 1);
?>
<input type="hidden"
name="captcha_index" value="<?php echo $captcha_index; ?>" />
<p><?php echo $captchas[$captcha_index]["question"]; ?>
<?php foreach ($captchas[$captcha_index]["options"] as $captcha_answer) { ?>
<br /><label for="captcha_<?php echo $captcha_answer; ?>">
<input tabindex="<?php echo $tabindex++; ?>"
id="captcha_<?php echo $captcha_answer; ?>" type="radio"
name="captcha" value="<?php echo $captcha_answer; ?>"
/><?php echo $captcha_answer; ?></label>
<?php } ?></p>
<?php
require_once('recaptchalib.php');
$publickey = "6LdpEc8SAAAAAHE2ikFXQQ4PI6gNTqi9kRR3jLoL"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
<input type="submit" value="ADD ME NAOW" class="button"/>
</form>
</div
</div>
</body>
</html>
<?php
$captchas = Array();
$captchas[0] = array(
"question" => "What color is the sky?",
"answer" => "blue",
"options" => array("blue", "red", "orange"));
$captchas[1] = array(
"question" => "Is stealing allowed?",
"answer" => "Yes",
"options" => array("Yes", "Nope", "I didn't read the rules, I stupid! ^_^"));
$captchas[2] = array(
"question" => "Who owns the server?",
"answer" => "rymate1234",
"options" => array("Team Avolition", "rcs10", "cake!!!", "rymate1234", "I HAVE NO IDEA!"));
$captchas[3] = array(
"question" => "Do you agree to the rules?",
"answer" => "Yes!",
"options" => array("Yes!", "No!"));
$captchas[4] = array(
"question" => "This question has an answer! HAHAHA CAPTCHA SOLVERS",
"answer" => "The answer",
"options" => array("The answer", "No, I'm the answer!", "I IZ ANSWER!", "The first one might be the answer!", "I'm a captcha solver bot, and I hate you."));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment