includes/sessions.php
changeset 1158 e733f984c990
parent 1155 a1770361ef88
child 1160 c0e0a1787a63
equal deleted inserted replaced
1155:a1770361ef88 1158:e733f984c990
  3485   }
  3485   }
  3486   
  3486   
  3487   /**
  3487   /**
  3488    * For the given code ID, returns the correct CAPTCHA code, or false on failure
  3488    * For the given code ID, returns the correct CAPTCHA code, or false on failure
  3489    * @param string $hash The unique ID assigned to the code
  3489    * @param string $hash The unique ID assigned to the code
       
  3490    * @param bool If true, the code is NOT deleted from the database. Use with caution!
  3490    * @return string The correct confirmation code
  3491    * @return string The correct confirmation code
  3491    */
  3492    */
  3492   
  3493   
  3493   function get_captcha($hash)
  3494   function get_captcha($hash, $nodelete = false)
  3494   {
  3495   {
  3495     global $db, $session, $paths, $template, $plugins; // Common objects
  3496     global $db, $session, $paths, $template, $plugins; // Common objects
  3496     
  3497     
  3497     if ( !preg_match('/^[a-f0-9]{32}([a-z0-9]{8})?$/', $hash) )
  3498     if ( !preg_match('/^[a-f0-9]{32}([a-z0-9]{8})?$/', $hash) )
  3498     {
  3499     {
  3514     }
  3515     }
  3515     
  3516     
  3516     list($code_id, $code) = $db->fetchrow_num();
  3517     list($code_id, $code) = $db->fetchrow_num();
  3517     
  3518     
  3518     $db->free_result();
  3519     $db->free_result();
  3519     $this->sql('DELETE FROM ' . table_prefix . "captcha WHERE code_id = $code_id;");
  3520     
       
  3521     // delete it
       
  3522     if ( !$nodelete )
       
  3523       $this->sql('DELETE FROM ' . table_prefix . "captcha WHERE code_id = $code_id;");
  3520     
  3524     
  3521     return $code;
  3525     return $code;
  3522   }
  3526   }
  3523   
  3527   
  3524   /**
  3528   /**