h00j
3 years ago
7 changed files with 172 additions and 20 deletions
@ -4,8 +4,65 @@ |
|||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
||||
"This file is @generated automatically" |
"This file is @generated automatically" |
||||
], |
], |
||||
"content-hash": "e78104dfc51d725ae15a17e7a70e7ca3", |
"content-hash": "1e3723687369c82eea457d2dded76b74", |
||||
"packages": [ |
"packages": [ |
||||
|
{ |
||||
|
"name": "dapphp/securimage", |
||||
|
"version": "4.0.2", |
||||
|
"source": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/dapphp/securimage.git", |
||||
|
"reference": "aabde76d839d75a238970661187f83312c2eeda7" |
||||
|
}, |
||||
|
"dist": { |
||||
|
"type": "zip", |
||||
|
"url": "https://api.github.com/repos/dapphp/securimage/zipball/aabde76d839d75a238970661187f83312c2eeda7", |
||||
|
"reference": "aabde76d839d75a238970661187f83312c2eeda7", |
||||
|
"shasum": "" |
||||
|
}, |
||||
|
"require": { |
||||
|
"ext-gd": "*", |
||||
|
"php": ">=5.4" |
||||
|
}, |
||||
|
"suggest": { |
||||
|
"ext-pdo": "For database storage support", |
||||
|
"ext-pdo_mysql": "For MySQL database support", |
||||
|
"ext-pdo_sqlite": "For SQLite3 database support" |
||||
|
}, |
||||
|
"type": "library", |
||||
|
"autoload": { |
||||
|
"classmap": [ |
||||
|
"securimage.php" |
||||
|
], |
||||
|
"psr-4": { |
||||
|
"Securimage\\": "./" |
||||
|
} |
||||
|
}, |
||||
|
"notification-url": "https://packagist.org/downloads/", |
||||
|
"license": [ |
||||
|
"BSD-3-Clause" |
||||
|
], |
||||
|
"authors": [ |
||||
|
{ |
||||
|
"name": "Drew Phillips", |
||||
|
"email": "[email protected]" |
||||
|
} |
||||
|
], |
||||
|
"description": "PHP CAPTCHA Library", |
||||
|
"homepage": "https://www.phpcaptcha.org", |
||||
|
"keywords": [ |
||||
|
"Forms", |
||||
|
"anti-spam", |
||||
|
"captcha", |
||||
|
"security" |
||||
|
], |
||||
|
"support": { |
||||
|
"issues": "https://github.com/dapphp/securimage/issues", |
||||
|
"source": "https://github.com/dapphp/securimage/tree/4.0.2" |
||||
|
}, |
||||
|
"abandoned": true, |
||||
|
"time": "2020-05-30T10:05:48+00:00" |
||||
|
}, |
||||
{ |
{ |
||||
"name": "geoip/geoip", |
"name": "geoip/geoip", |
||||
"version": "v1.17", |
"version": "v1.17", |
||||
@ -212,16 +269,16 @@ |
|||||
}, |
}, |
||||
{ |
{ |
||||
"name": "symfony/polyfill-ctype", |
"name": "symfony/polyfill-ctype", |
||||
"version": "v1.22.0", |
"version": "v1.23.0", |
||||
"source": { |
"source": { |
||||
"type": "git", |
"type": "git", |
||||
"url": "https://github.com/symfony/polyfill-ctype.git", |
"url": "https://github.com/symfony/polyfill-ctype.git", |
||||
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e" |
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" |
||||
}, |
}, |
||||
"dist": { |
"dist": { |
||||
"type": "zip", |
"type": "zip", |
||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", |
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", |
||||
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e", |
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", |
||||
"shasum": "" |
"shasum": "" |
||||
}, |
}, |
||||
"require": { |
"require": { |
||||
@ -233,7 +290,7 @@ |
|||||
"type": "library", |
"type": "library", |
||||
"extra": { |
"extra": { |
||||
"branch-alias": { |
"branch-alias": { |
||||
"dev-main": "1.22-dev" |
"dev-main": "1.23-dev" |
||||
}, |
}, |
||||
"thanks": { |
"thanks": { |
||||
"name": "symfony/polyfill", |
"name": "symfony/polyfill", |
||||
@ -271,7 +328,7 @@ |
|||||
"portable" |
"portable" |
||||
], |
], |
||||
"support": { |
"support": { |
||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0" |
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" |
||||
}, |
}, |
||||
"funding": [ |
"funding": [ |
||||
{ |
{ |
||||
@ -287,20 +344,20 @@ |
|||||
"type": "tidelift" |
"type": "tidelift" |
||||
} |
} |
||||
], |
], |
||||
"time": "2021-01-07T16:49:33+00:00" |
"time": "2021-02-19T12:13:01+00:00" |
||||
}, |
}, |
||||
{ |
{ |
||||
"name": "twig/twig", |
"name": "twig/twig", |
||||
"version": "v1.44.2", |
"version": "v1.44.5", |
||||
"source": { |
"source": { |
||||
"type": "git", |
"type": "git", |
||||
"url": "https://github.com/twigphp/Twig.git", |
"url": "https://github.com/twigphp/Twig.git", |
||||
"reference": "138c493c5b8ee7cff3821f80b8896d371366b5fe" |
"reference": "dd4353357c5a116322e92a00d16043a31881a81e" |
||||
}, |
}, |
||||
"dist": { |
"dist": { |
||||
"type": "zip", |
"type": "zip", |
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/138c493c5b8ee7cff3821f80b8896d371366b5fe", |
"url": "https://api.github.com/repos/twigphp/Twig/zipball/dd4353357c5a116322e92a00d16043a31881a81e", |
||||
"reference": "138c493c5b8ee7cff3821f80b8896d371366b5fe", |
"reference": "dd4353357c5a116322e92a00d16043a31881a81e", |
||||
"shasum": "" |
"shasum": "" |
||||
}, |
}, |
||||
"require": { |
"require": { |
||||
@ -353,7 +410,7 @@ |
|||||
], |
], |
||||
"support": { |
"support": { |
||||
"issues": "https://github.com/twigphp/Twig/issues", |
"issues": "https://github.com/twigphp/Twig/issues", |
||||
"source": "https://github.com/twigphp/Twig/tree/v1.44.2" |
"source": "https://github.com/twigphp/Twig/tree/v1.44.5" |
||||
}, |
}, |
||||
"funding": [ |
"funding": [ |
||||
{ |
{ |
||||
@ -365,7 +422,7 @@ |
|||||
"type": "tidelift" |
"type": "tidelift" |
||||
} |
} |
||||
], |
], |
||||
"time": "2021-01-05T10:10:05+00:00" |
"time": "2021-09-17T08:35:19+00:00" |
||||
} |
} |
||||
], |
], |
||||
"packages-dev": [], |
"packages-dev": [], |
||||
|
@ -0,0 +1,72 @@ |
|||||
|
<?php |
||||
|
require_once('inc/bootstrap.php'); |
||||
|
$expires_in = 120; |
||||
|
|
||||
|
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; |
||||
|
} |
||||
|
|
||||
|
function cleanup() { |
||||
|
global $expires_in; |
||||
|
prepare("DELETE FROM `captchas` WHERE `created_at` < ?")->execute([time() - $expires_in]); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
$mode = @$_GET['mode']; |
||||
|
switch ($mode) { |
||||
|
case 'get': |
||||
|
if (!isset ($_GET['extra'])) { |
||||
|
$_GET['extra'] = $config['captcha']['extra']; |
||||
|
} |
||||
|
|
||||
|
header("Content-type: application/json"); |
||||
|
$extra = $_GET['extra']; |
||||
|
$cookie = rand_string(20, "abcdefghijklmnopqrstuvwxyz"); |
||||
|
$i = new Securimage(['send_headers' => false, 'no_exit' => true]); |
||||
|
$i->createCode(); |
||||
|
ob_start(); |
||||
|
$i->show(); |
||||
|
$rawimg = ob_get_contents(); |
||||
|
$b64img = 'data:image/png;base64,'.base64_encode($rawimg); |
||||
|
$html = '<img src="'.$b64img.'">'; |
||||
|
ob_end_clean(); |
||||
|
$cdata = $i->getCode(); |
||||
|
$query = prepare("INSERT INTO `captchas` (`cookie`, `extra`, `text`, `created_at`) VALUES (?, ?, ?, ?)"); |
||||
|
$query->execute([$cookie, $extra, $cdata->code_display, $cdata->creationTime]); |
||||
|
if (isset($_GET['raw'])) { |
||||
|
$_SESSION['captcha_cookie'] = $cookie; |
||||
|
header('Content-Type: image/png'); |
||||
|
echo $rawimg; |
||||
|
} else { |
||||
|
echo json_encode(["cookie" => $cookie, "captchahtml" => $html, "expires_in" => $expires_in]); |
||||
|
} |
||||
|
break; |
||||
|
case 'check': |
||||
|
cleanup(); |
||||
|
if (!isset ($_GET['mode']) || !isset ($_GET['cookie']) || !isset ($_GET['extra']) || !isset ($_GET['text'])) { |
||||
|
die(); |
||||
|
} |
||||
|
|
||||
|
$query = prepare("SELECT * FROM `captchas` WHERE `cookie` = ? AND `extra` = ?"); |
||||
|
$query->execute([$_GET['cookie'], $_GET['extra']]); |
||||
|
|
||||
|
$ary = $query->fetchAll(); |
||||
|
|
||||
|
if (!$ary) { |
||||
|
echo "0"; |
||||
|
} else { |
||||
|
$query = prepare("DELETE FROM `captchas` WHERE `cookie` = ? AND `extra` = ?"); |
||||
|
$query->execute([$_GET['cookie'], $_GET['extra']]); |
||||
|
} |
||||
|
|
||||
|
if ($ary[0]['text'] !== $_GET['text']) { |
||||
|
echo "0"; |
||||
|
} else { |
||||
|
echo "1"; |
||||
|
} |
||||
|
break; |
||||
|
} |
After Width: | Height: | Size: 3.0 KiB |
Loading…
Reference in new issue