/** * Will log out a user * * Takes a username, email or member id and logs that user out. If it can't find * a match it will look for the currently logged user if any. Best to leave this * function's arguments empty. If logoutis failing, make sure your SMF cookie is * being set on path '/', otherwise we can't delete it. Also, try leaving the * function parameter empty to let the script auto-detect the currently logged in * user for you. * * @param string $username user's member name (or int member id or string email) * @return bool whether logout was successful or not * @since 0.1.2 */ function smfapi_logout($username = '') { global $user_info, $smcFunc; if ($user_info['is_guest']) { smfapi_loadUserSettings(); } if ('' == $username) { if ($user_info['is_guest']) { return false; } else { $username = $user_info['username']; } } $user_data = smfapi_getUserData($username); if (!$user_data || empty($user_data)) { // no user by that name return false; } // delete them from log_online $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_online WHERE id_member = {int:current_member}', array('current_member' => $user_data['id_member'])); if (isset($_SESSION['pack_ftp'])) { $_SESSION['pack_ftp'] = null; } // they cannot be open ID verified any longer. if (isset($_SESSION['openid'])) { unset($_SESSION['openid']); } // it won't be first login anymore. if (isset($_SESSION['openid'])) { unset($_SESSION['first_login']); } // destroy the cookie smfapi_setLoginCookie(-3600, 0); return true; }
/** * Will log out a user * * Takes a username, email or member id and logs that user out. If it can't find * a match it will look for the currently logged user if any. * * @param string $username user's member name (or int member id or string email) * @return bool whether logout was successful or not * @since 0.1.0 */ function smfapi_logout($username = '') { global $sourcedir, $user_info, $user_settings, $context, $modSettings, $smcFunc; if ('' == $username && $user_info['is_guest']) { return false; } $user_data = smfapi_getUserData($username); if (!$user_data) { if (isset($user_info['id_member']) && false !== smfapi_getUserById($user_info['id_member'])) { $user_data['id_member'] = $user_info['id_member']; } else { return false; } } // if you log out, you aren't online anymore :P. $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_online WHERE id_member = {int:current_member}', array('current_member' => $user_data['id_member'])); if (isset($_SESSION['pack_ftp'])) { $_SESSION['pack_ftp'] = null; } // they cannot be open ID verified any longer. if (isset($_SESSION['openid'])) { unset($_SESSION['openid']); } // it won't be first login anymore. unset($_SESSION['first_login']); smfapi_setLoginCookie(-3600, 0); return true; }
/** * Short description * * Long description * * @param * @return */ protected function logout_userRest() { try { $this->loadApi(); } catch (Exception $e) { throw new \Exception($e->getMessage()); } global $user_info, $smcFunc; if (isset($user_info['id']) && 0 != $user_info['id']) { // remove from online log $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_online WHERE id_member = {int:current_member}', array('current_member' => $user_info['id'])); } // wreck the cookie smfapi_setLoginCookie(-3600, 0); $this->data = 'true'; }