request = new ParameterBag($this->stripSlashesIfMagicQuotes($request)); $this->query = new ParameterBag($this->stripSlashesIfMagicQuotes($query)); $this->attributes = new ParameterBag($attributes); $this->cookies = new ParameterBag($this->stripSlashesIfMagicQuotes($cookies)); $this->files = new FileBag($files); $this->server = new ServerBag($server); $this->headers = new HeaderBag($this->server->getHeaders()); $this->content = $content; $this->languages = null; $this->charsets = null; $this->encodings = null; $this->acceptableContentTypes = null; $this->pathInfo = null; $this->requestUri = null; $this->baseUrl = null; $this->basePath = null; $this->method = null; $this->format = null; } /** * Get URL segments from the path info * * @see \Elgg\Http\Request::getPathInfo() * * @return array */ public function getUrlSegments() { $path = trim($this->query->get('__elgg_uri'), '/'); if (!$path) { return array(); } return explode('/', $path); } /** * Get first URL segment from the path info * * @see \Elgg\Http\Request::getUrlSegments() * * @return string */ public function getFirstUrlSegment() { $segments = $this->getUrlSegments(); if ($segments) { return array_shift($segments); } else { return ''; } } /** * {@inheritdoc} */ public function getClientIp() { $ip = parent::getClientIp(); if ($ip == $this->server->get('REMOTE_ADDR')) { // try one more $ip_addresses = $this->server->get('HTTP_X_REAL_IP'); if ($ip_addresses) { return array_pop(explode(',', $ip_addresses)); } } return $ip; } /** * Strip slashes if magic quotes is on * * @param mixed $data Data to strip slashes from * @return mixed */ protected function stripSlashesIfMagicQuotes($data) { if (get_magic_quotes_gpc()) { return _elgg_stripslashes_deep($data); } else { return $data; } } }