コード例 #1
0
ファイル: pluggable.php プロジェクト: nxtclass/NXTClass
 /**
  * Creates a random, one time use token.
  *
  * @since 2.0.3
  *
  * @param string|int $action Scalar value to add context to the nonce.
  * @return string The one use form token
  */
 function nxt_create_nonce($action = -1)
 {
     $user = nxt_get_current_user();
     $uid = (int) $user->ID;
     $i = nxt_nonce_tick();
     return substr(nxt_hash($i . $action . $uid, 'nonce'), -12, 10);
 }
コード例 #2
0
function jfb_debug_nonce_components()
{
    global $opt_jfb_generated_nonce;
    $user = nxt_get_current_user();
    $uid = (int) $user->id;
    $nonce_life = apply_filters('nonce_life', 86400);
    $time = time();
    $nonce_tick = ceil(time() / ($nonce_life / 2));
    $tick_verify = nxt_nonce_tick();
    $hash = nxt_hash($i . $action . $uid, 'nonce');
    $nonce = substr($hash, -12, 10);
    return "NONCE: {$nonce}, uid: {$uid}, life: {$nonce_life}, time: {$time}, tick: {$nonce_tick}, verify: {$tick_verify}, hash: {$hash}";
}