/** * Verify a previously created Captcha phrase. * @param @passedValue string containing the phrase recieved from the user. * @return bool True if the value matches the captcha phrase, false otherwise. */ public static function verify($passedValue) { $realv = Session::pull("CAPTCHA_VALUE"); if (strtolower($passedValue) === strtolower($realv)) { return true; } return false; }
public static function init($configFile) { $opts = null; $apcEnabled = (bool) ini_get('apc.enabled'); if ($apcEnabled && apc_exists('hmcsoftmvc-config')) { if (file_exists($configFile)) { $lastModTime = filemtime($configFile); $lastConfTime = 0; if (apc_exists('hmcsoftmvc-config-updated')) { $lastConfTime = apc_fetch('hmcsoftmvc-config-updated'); } if ($lastConfTime < $lastModTime) { $opts = json_decode(file_get_contents($configFile), true); apc_store('hmcsoftmvc-config', $opts); apc_store('hmcsoftmvc-config-updated', $lastModTime); } else { $opts = apc_fetch('hmcsoftmvc-config'); } } } else { if (is_readable($configFile)) { $opts = json_decode(file_get_contents($configFile), true); } } $defaults = self::get_defaults(); if ($opts !== null) { self::$options = (array) self::merge_defaults($defaults, (array) $opts); } self::$options = Hooks::run('config', self::$options); if (self::$options['SITE']['LANGUAGE'] == null) { //try to figure if we support the user's language. $userlangs = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $foundLang = false; foreach (self::$options['SITE']['LANGUAGES'] as $ourLang) { if (!$foundLang) { foreach ($userlangs as $ulang) { if (!$foundLang && $ulang === $ourLang) { self::$options['SITE']['LANGUAGE'] = $ourLang; $foundLang = true; } } } } if (!$foundLang) { self::$options['SITE']['LANGUAGE'] = self::$options['SITE']['DEFAULTLANG']; } } if (isset(self::$options['SITE'])) { if (isset(self::$options['ENVIRONMENT'])) { if (self::$options['SITE']['ENVIRONMENT'] == 'development') { error_reporting(E_NONE); } else { error_reporting(E_NONE); } } //set timezone if (isset(self::$options['SITE']['TIMEZONE'])) { date_default_timezone_set(self::$options['SITE']['TIMEZONE']); } } //turn on output buffering ob_start(); //turn on custom error handling if (isset(self::$options['LOG'])) { \HMC\Logger::init(self::$options['LOG']); if (isset(self::$options['LOG']['EXCEPTIONS'])) { set_exception_handler(self::$options['LOG']['EXCEPTIONS']); } else { set_exception_handler('HMC\\Logger::exceptionHandler'); } if (isset(self::$options['LOG']['ERRORS'])) { set_error_handler(self::$options['LOG']['ERRORS']); } else { set_error_handler('HMC\\Logger::errorHandler'); } } //start sessions if (isset(self::$options['SESSION'])) { Session::init(self::$options['SESSION']); } else { Session::init(); } return self::$options; }