/** * Show the verification code or let it hear. * Accessed by ?action=verificationcode */ public function action_verificationcode() { global $context, $scripturl; $verification_id = isset($_GET['vid']) ? $_GET['vid'] : ''; $code = $verification_id && isset($_SESSION[$verification_id . '_vv']) ? $_SESSION[$verification_id . '_vv']['code'] : (isset($_SESSION['visual_verification_code']) ? $_SESSION['visual_verification_code'] : ''); // Somehow no code was generated or the session was lost. if (empty($code)) { header('Content-Type: image/gif'); die("GIF89a€!ù,D;"); } elseif (isset($_REQUEST['sound'])) { loadLanguage('Login'); loadTemplate('Register'); $context['verification_sound_href'] = $scripturl . '?action=verificationcode;rand=' . md5(mt_rand()) . ($verification_id ? ';vid=' . $verification_id : '') . ';format=.wav'; $context['sub_template'] = 'verification_sound'; Template_Layers::getInstance()->removeAll(); obExit(); } elseif (empty($_REQUEST['format'])) { require_once SUBSDIR . '/Graphics.subs.php'; if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { header('HTTP/1.1 400 Bad Request'); } elseif (isset($_REQUEST['letter'])) { $_REQUEST['letter'] = (int) $_REQUEST['letter']; if ($_REQUEST['letter'] > 0 && $_REQUEST['letter'] <= strlen($code) && !showLetterImage(strtolower($code[$_REQUEST['letter'] - 1]))) { header('Content-Type: image/gif'); die("GIF89a€!ù,D;"); } } else { header('Content-Type: image/gif'); die("GIF89a€!ù,D;"); } } elseif ($_REQUEST['format'] === '.wav') { require_once SUBSDIR . '/Sound.subs.php'; if (!createWaveFile($code)) { header('HTTP/1.1 400 Bad Request'); } } // We all die one day... die; }
function VerificationCode() { global $sourcedir, $modSettings, $context, $scripturl; // Somehow no code was generated or the session was lost. if (empty($_SESSION['visual_verification_code'])) { header('HTTP/1.1 408 - Request Timeout'); } elseif (isset($_REQUEST['sound'])) { loadLanguage('Login'); loadTemplate('Register'); $context['verificiation_sound_href'] = $scripturl . '?action=verificationcode;rand=' . md5(mt_rand()) . ';format=.wav'; $context['sub_template'] = 'verification_sound'; $context['template_layers'] = array(); obExit(); } elseif (empty($_REQUEST['format'])) { require_once $sourcedir . '/Subs-Graphics.php'; if (in_array('gd', get_loaded_extensions()) && !showCodeImage($_SESSION['visual_verification_code'])) { header('HTTP/1.1 400 Bad Request'); } elseif (isset($_REQUEST['letter'])) { $_REQUEST['letter'] = (int) $_REQUEST['letter']; if ($_REQUEST['letter'] > 0 && $_REQUEST['letter'] <= strlen($_SESSION['visual_verification_code']) && !showLetterImage(strtolower($_SESSION['visual_verification_code'][$_REQUEST['letter'] - 1]))) { header('HTTP/1.1 400 Bad Request'); } } else { header('HTTP/1.1 400 Bad Request'); } } elseif ($_REQUEST['format'] === '.wav') { require_once $sourcedir . '/Subs-Sound.php'; if (!createWaveFile($_SESSION['visual_verification_code'])) { header('HTTP/1.1 400 Bad Request'); } } // We all die one day... die; }