id : null)); return $token; } /** * Confirm a token * * @param string $token Token string * @return bool Returns true or false or throws an error depending on success. */ public static function confirm($token,$delete_on_success=false){ $res = self::get($token); if(!$res || $res['confirm_time'] || ($res['expire'] && strtotime($res['expire']) < time())){ return false;} if(!\in_array($res['class'], self::$type_handlers)){ throw new \SYSTEM\LOG\ERROR('Token_handler class not known to Token class. Please register it first.');} if(!\call_user_func_array(array($res['class'], 'confirm'),array($res))){ return false;} if($delete_on_success){ return \SYSTEM\SQL\SYS_TOKEN_DELETE::QI(array($token)); } else { return \SYSTEM\SQL\SYS_TOKEN_CONFIRM::QI(array( \SYSTEM\SECURITY\security::isLoggedIn() ? \SYSTEM\SECURITY\security::getUser()->id : null, $token)); } } /** * Get a existing token from db * * @param string $token Token string * @return array Returns database entry for the given Token if it exists. */ public static function get($token){ return \SYSTEM\SQL\SYS_TOKEN_GET::Q1(array($token));} }