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