1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-25 04:23:38 +01:00
php-phpbb/phpBB/includes/ucp/ucp_confirm.php
David M 74799e168d - We are now at _seven_ different policies, not counting the non-GD version. We must remove something...
- Made the CAPTCHA system idiot proof, disabling all the policies still lets an image get created.
- We handle the case of a user having GD but no TTF. Thankfully, we have CAPTCHAs that don't need TTF!
- Fixed that stupid language string...
- Renamed Occlude to Overlap
- Shape is now only enabled if TTF support is detected


git-svn-id: file:///svn/phpbb/trunk@5985 89ea8834-ac86-4346-8a33-228a782c2dd0
2006-05-30 04:27:14 +00:00

90 lines
2.1 KiB
PHP

<?php
/**
*
* @package VC
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @package VC
* ucp_confirm
* Visual confirmation
*
* Note to potential users of this code ...
*
* Remember this is released under the _GPL_ and is subject
* to that licence. Do not incorporate this within software
* released or distributed in any way under a licence other
* than the GPL. We will be watching ... ;)
*/
class ucp_confirm
{
function main($id, $mode)
{
global $db, $user, $phpbb_root_path, $config;
// Do we have an id? No, then just exit
$confirm_id = request_var('id', '');
$type = request_var('type', 0);
if (!$confirm_id || !$type)
{
exit;
}
// Try and grab code for this id and session
$sql = 'SELECT code
FROM ' . CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
AND confirm_id = '" . $db->sql_escape($confirm_id) . "'
AND confirm_type = $type";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// If we have a row then grab data else create a new id
if (!$row)
{
exit;
}
// Some people might want the olde style CAPTCHA even if they have GD enabled, this also saves us from people who have GD but no TTF
$policy_modules = array('policy_entropy', 'policy_3dbitmap');
if (function_exists('imagettfbbox') && function_exists('imagettftext'))
{
$policy_modules[] = 'policy_overlap';
$policy_modules[] = 'policy_shape';
$policy_modules[] = 'policy_cells';
$policy_modules[] = 'policy_stencil';
$policy_modules[] = 'policy_composite';
}
foreach ($policy_modules as $key => $name)
{
if ($config[$name] === '0')
{
unset($policy_modules[$key]);
}
}
$policy = '';
if (extension_loaded('gd') && sizeof($policy_modules))
{
include($phpbb_root_path . 'includes/captcha/captcha_gd.php');
$policy = $policy_modules[array_rand($policy_modules)];
}
else
{
include($phpbb_root_path . 'includes/captcha/captcha_non_gd.php');
}
$captcha = new captcha();
$captcha->execute($row['code'], $policy);
exit;
}
}
?>