Commit Diff
Diff:
302b7e40ac6e03c59e1f6d061031a1221c0e39a0
4e4305b65bba125624cc243da5be3e45d8f341de
Commit:
4e4305b65bba125624cc243da5be3e45d8f341de
Tree:
4578a5bbaec6610aa8718cc4ca53053e5f72f21b
Author:
jrmu <jrmu@ircnow.org>
Committer:
jrmu <jrmu@ircnow.org>
Date:
Sun Oct 11 12:43:47 2020 UTC
Message:
Refactored code to be modular
blob - /dev/null
blob + 6842a669ac82a8663eb27c962e3afcf4ada02163 (mode 644)
--- /dev/null
+++ captcha.php
@@ -0,0 +1,54 @@
+<?php
+
+$fpr = "hash: ".$_REQUEST["id"]."\n";
+$fpr .= "remote addr: ".$_SERVER['REMOTE_ADDR']."\n";
+$fpr .= "http_x_forwarded: ".$_SERVER['HTTP_X_FORWARDED_FOR']."\n";
+$fpr .= "time: ".date("Y-m-d H:i:s")."\n";
+foreach (getallheaders() as $name => $value) {
+ $fpr .= "$name: $value\n";
+}
+$fpr .= "\n";
+$vhost = base64_decode($_REQUEST["vhost"]);
+$file = '../../botnow/www';
+$current = file_get_contents($file);
+$current .= $fpr;
+file_put_contents($file, $current);
+
+session_start();
+$captcha = $vhost;
+
+// The capcha will be stored
+// for the session
+$_SESSION["captcha"] = $captcha;
+
+// Generate a 50x24 standard captcha image
+$im = imagecreatetruecolor(50, 24);
+
+// Blue color
+$bg = imagecolorallocate($im, 22, 86, 165);
+
+// White color
+$fg = imagecolorallocate($im, 255, 255, 255);
+
+// Give the image a blue background
+imagefill($im, 0, 0, $bg);
+
+// Print the captcha text in the image
+// with random position & size
+imagestring($im, rand(1, 7), rand(1, 7),
+ rand(1, 7), $captcha, $fg);
+
+// VERY IMPORTANT: Prevent any Browser Cache!!
+header("Cache-Control: no-store,
+ no-cache, must-revalidate");
+
+// The PHP-file will be rendered as image
+header('Content-type: image/png');
+
+// Finally output the captcha as
+// PNG image the browser
+imagepng($im);
+
+// Free memory
+imagedestroy($im);
+?>