protected function storeCurrentUrlForLoginRedirection() { if (in_array(strtolower($this->action_name_from_uri), ['login', 'action-login', 'actionlogin', 'action_login', 'logout', 'action-logout', 'actionlogout', 'action_logout'])) { return; } $uri = $this->request->getUri(); $base_path = s3MVC_GetBaseUrlPath(); $fragment = $uri->getFragment(); $query = $uri->getQuery(); $path = $uri->getPath(); $path = $base_path . '/' . ltrim($path, '/'); $curr_url = $path . ($query ? '?' . $query : '') . ($fragment ? '#' . $fragment : ''); //start a new session if none exists session_status() !== PHP_SESSION_ACTIVE && session_start(); //store current url in session $_SESSION[static::SESSN_PARAM_LOGIN_REDIRECT] = $curr_url; }
/** * * Converts a uri object to a string in the format <scheme>://<server_address>/<path>?<query_string>#<fragment> * * @param \Psr\Http\Message\UriInterface $uri uri object to be converted to a string * * @return string the string represntation of the uri object. * Eg. http://someserver.com/controller/action */ function s3MVC_UriToString(\Psr\Http\Message\UriInterface $uri) { $scheme = $uri->getScheme(); $authority = $uri->getAuthority(); $basePath = s3MVC_GetBaseUrlPath(); $path = $uri->getPath(); $query = $uri->getQuery(); $fragment = $uri->getFragment(); $path = $basePath . '/' . ltrim($path, '/'); return ($scheme ? $scheme . ':' : '') . ($authority ? '//' . $authority : '') . $path . ($query ? '?' . $query : '') . ($fragment ? '#' . $fragment : ''); }