function main($id, $mode) { global $db, $user, $phpbb_root_path, $config, $phpEx; // 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, seed FROM ' . CONFIRM_TABLE . "\n\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\tAND confirm_id = '" . $db->sql_escape($confirm_id) . "'\n\t\t\t\tAND 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; } if ($config['captcha_gd']) { include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx; } else { include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx; } $captcha = new captcha(); $captcha->execute($row['code'], $row['seed']); garbage_collection(); exit_handler(); }
function main($id, $mode) { global $db, $user, $auth, $template; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/board'); $captcha_vars = array('captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS'); if (isset($_GET['demo'])) { $captcha_vars = array_keys($captcha_vars); foreach ($captcha_vars as $captcha_var) { $config[$captcha_var] = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var]; } if ($config['captcha_gd']) { include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx; } else { include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx; } $captcha = new captcha(); $captcha->execute(gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)), time()); exit; } $config_vars = array('enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', 'confirm_refresh' => 'CONFIRM_REFRESH', 'captcha_gd' => 'CAPTCHA_GD'); $this->tpl_name = 'acp_captcha'; $this->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; add_form_key($form_key); $submit = request_var('submit', ''); if ($submit && check_form_key($form_key)) { $config_vars = array_keys($config_vars); foreach ($config_vars as $config_var) { set_config($config_var, request_var($config_var, '')); } $captcha_vars = array_keys($captcha_vars); foreach ($captcha_vars as $captcha_var) { $value = request_var($captcha_var, 0); if ($value >= 0) { set_config($captcha_var, $value); } } add_log('admin', 'LOG_CONFIG_VISUAL'); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } else { if ($submit) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action)); } else { $preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&demo=demo")); if (@extension_loaded('gd')) { $template->assign_var('GD', true); } foreach ($config_vars as $config_var => $template_var) { $template->assign_var($template_var, isset($_REQUEST[$config_var]) ? request_var($config_var, '') : $config[$config_var]); } foreach ($captcha_vars as $captcha_var => $template_var) { $var = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var]; $template->assign_var($template_var, $var); $preview_image_src .= "&{$captcha_var}=" . $var; } $template->assign_vars(array('CAPTCHA_PREVIEW' => $preview_image_src, 'PREVIEW' => isset($_POST['preview']))); } } }
function execute() { if (empty($this->code)) { if (!$this->load_code()) { // invalid request, bail out return false; } } $captcha = new captcha(); define('IMAGE_OUTPUT', 1); $captcha->execute($this->code, $this->seed); }
function main($id, $mode) { global $db, $user, $phpbb_root_path, $config, $phpEx; // 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 . " \n\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "' \n\t\t\t\tAND confirm_id = '" . $db->sql_escape($confirm_id) . "'\n\t\t\t\tAND 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 += array('policy_overlap', 'policy_shape', 'policy_cells', 'policy_stencil', '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.' . $phpEx; $policy = $policy_modules[array_rand($policy_modules)]; } else { include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx; } $captcha = new captcha(); $captcha->execute($row['code'], $policy); exit; }
<?php exit; $code = "1234567890"; $seed = 1231413213; $captcha_gd = false; if ($captcha_gd) { include './captcha_gd.php'; } else { include './captcha_non_gd.php'; } $captcha = new captcha(); $captcha->execute($code, $seed); exit;