Source code of Leftypol imageboard
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
921 B

require_once 'inc/functions.php';
require_once 'inc/lib/securimage/securimage.php';
if(!isset($config['securimage']) || !$config['securimage']){
error('Securimage captcha not enabled.'); //TODO error image
$image=new Securimage(array('config_file'=>__DIR__ . '/inc/captchaconfig.php'));
$code=$image->getCode(false, true);
$query=prepare('INSERT INTO captchas(ip, code, time) VALUES(:ip, :code, NOW())');
$query->bindValue(':ip', $ip);
$query->bindValue(':code', $code);
$query->execute() or error(db_error($query));
$query=prepare('SELECT count(*) from captchas where ip=:ip');
$query->bindValue(':ip', $ip);
$query->execute() or error(db_error($query));
$query=prepare('DELETE from captchas where ip=:ip ORDER BY time asc LIMIT 1');
$query->bindValue(':ip', $ip);
$query->execute()or error(db_error($query));