'homepage', 'method' => 'hash', 'type' => 'both', 'checkSession' => false, 'checkIp' => false, 'salt' => '', ); # what type of captcha public static $types = array('passive', 'active', 'both'); # what method to use public static $methods = array('hash', 'db', 'session'); /** * @param array $data: * - captcha_time, result/captcha * @param array $options: * - salt (required) * - checkSession, checkIp, hashType (all optional) * 2011-06-11 ms */ public static function buildHash($data, $options, $init = false) { if ($init) { $data['captcha_time'] = time(); $data['captcha'] = $data['result']; } $hashValue = date(FORMAT_DB_DATETIME, (int)$data['captcha_time']).'_'; $hashValue .= ($options['checkSession'])?session_id().'_' : ''; $hashValue .= ($options['checkIp'])?env('REMOTE_ADDR').'_' : ''; if ($options['type'] !== 'passive') { $hashValue .= $data['captcha']; } return Security::hash($hashValue, isset($options['hashType']) ? $options['hashType'] : null, $options['salt']); } }