Skip to content

Instantly share code, notes, and snippets.

@alfredfrancis
Last active April 16, 2016 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfredfrancis/7b16cab1e1d17cbdd34095a2d89cf604 to your computer and use it in GitHub Desktop.
Save alfredfrancis/7b16cab1e1d17cbdd34095a2d89cf604 to your computer and use it in GitHub Desktop.
<html>
<head>
prove that you are not a bot.type the word you see in the screen
</head>
<body>
<?php
session_start();
if(!isset($_SESSION["random"]) || !isset($_POST['user']) )
{
$random = str_shuffle("dgds235");
$_SESSION["random"] = $random;
$im = imagecreate(300, 30);
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// Write the string at the top left
imagestring($im, 5, 0, 0, $random , $textcolor);
// Output the image
imagepng($im, "file.png");
echo "<img src=\"file.png\"/>";
imagedestroy($im);
}
?>
<br>
type the words in the above picture
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="text" name="user">
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['user']) and isset($_SESSION["random"]))
{
$rand = $_POST['user'];
if ($rand == $_SESSION["random"])
{
echo "<br>you are not a bot";
}
else{
echo $_POST['user'];
echo $_SESSION["random"];
echo "<br>you are a bot";
}
session_unset();
session_destroy();
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment