选择语言 :

 Core_Form::get_token

获取一个token的数据数组

array Core_Form::get_token( )
返回值
  • array
File: ./core/classes/form.class.php
public static function get_token()
{
    $key   = '_form_token/' . date('Ymd') .'/'. Text::random('distinct', 16);
    $value = Text::random(null, 32);

    $cache_time = (int)Core::config('form_token_cache_time', 0);

    $token = array();
    if (!$cache_time>0)
    {
        # 将value加密后传入表单
        $token['value'] = Text::rc4_encrypt($value, null, $cache_time);
    }
    else
    {
        # 将value存在缓存中
        Cache::instance(Core::config('form_token_cache_name'))->set($key, $value, $cache_time);
    }

    $token['key']  = Text::rc4_encrypt($key);
    $token['hash'] = Form::get_token_hash($value, $key);

    return $token;
}