Custom captcha question #510
Unanswered
crazy4cars69
asked this question in
Q&A
Replies: 3 comments 1 reply
-
I got to working on captcha, but ran into some errors.
For
The error it gives me |
Beta Was this translation helpful? Give feedback.
1 reply
-
you probably fucked up something in the captcha verification in post.php |
Beta Was this translation helpful? Give feedback.
0 replies
-
The following code was posted by a user on August 14 and then deleted. I saved the email where I got notified of it, in case it's helpful to anyone: <?php
session_start();
function rand_string($length, $charset) {
$ret = "";
while ($length--) {
$ret .= mb_substr($charset, rand(0, mb_strlen($charset, 'utf-8')-1), 1, 'utf-8');
}
return $ret;
}
//$ch = curl_init($config['domain'].'/'.$config['captcha']['provider_check'] . "?" . http_build_query([
// 'mode' => 'check',
// 'text' => $_POST['captcha_text'],
// 'extra' => $config['captcha']['extra'],
//
$mode = $_GET['mode'];
$extra = isset($_GET['extra']) ? $_GET['extra'] : '12345678'; // what is doing??
if ($mode == 'get') {
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Content-type: image/png');
$captcha = rand(1000, 9999);
$im = imagecreatetruecolor(180, 50);
$bg = imagecolorallocate($im, 20, 20, 30);
$fg = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
imagestring($im, rand(5, 12), rand(5, 12), rand(5, 12), $captcha, $fg);
$_SESSION['captcha_cookie'] = hash("md5",$captcha);
$_SESSION['captcha_text'] = hash("md5",$captcha);
imagepng($im);
imagedestroy($im);
} else if ($mode == 'check') {
//var_dump($_GET);
//var_dump($_GET);
$text = $_GET['text'];
$extra = $_GET['extra'];
$cookie = $_GET['cookie'];
//echo($_SESSION['captcha_text']);
//die($text);
if ( hash("md5",$text) == $cookie )
{
print(1);
exit(0);
}
print(0);
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How to get started with writing custom captcha?
What are the things necessary for it to work with vichan?
I'm looking to write similar to one in /inc/captcha/ but wanting to write my own
Beta Was this translation helpful? Give feedback.
All reactions