input = $input; $this->server = $server; $this->requestHeaders = $requestHeaders; } public function getPathInfo() { if (!$this->pathInfo) { $pathInfo = $this->getEnv('PATH_INFO'); if (false !== strpos($pathInfo, '?')) { $msg = "PATH_INFO cannot have a (?) mark in it. Currently it is: $pathInfo"; throw new LogicException($msg); } $this->pathInfo = $pathInfo; } return $this->pathInfo; } /** * getUrlObjAndFakeGet * * @access public * @return array */ public function getUrlObj() { if (!$this->url) { /** * We can't just use PATH_INFO unfortunately as it has url entities * decoded. We must use REQUEST_URI that keeps url encoding and * figure out a new, fake PATH_INFO that does contain url encoded characters. **/ $reqUri = $this->getRequestUri(); if (0 === strpos( $reqUri, $scriptName = $this->getEnv('SCRIPT_NAME')) ) { $strlen = strlen($scriptName); $pathInfoWithGet = substr($reqUri, $strlen); $parts = explode('?', $pathInfoWithGet, 2); # PATH_INFO, but keeping the URL encoded stuff! $pathInfo = $parts[0]; $qs = isset($parts[1]) ? $parts[1] : null; } else if ($redUrl = $this->getEnv('REDIRECT_URL')) { $parts = explode('?', $reqUri, 2); $reqUriWithoutQuery = $parts[0]; $qs = isset($parts[1]) ? $parts[1] : null; $reqUriPathParts = explode('/', $reqUriWithoutQuery); $realPathInfo = $this->getPathInfo(); $realPathInfoPathParts = explode('/', $realPathInfo); # redirect url parts $redUrlPathParts = explode('/', $redUrl); $rebuildPathInfoParts = array(); while ( $realPathInfoPathParts && end($realPathInfoPathParts) === end($redUrlPathParts) ) { array_pop($realPathInfoPathParts); array_pop($redUrlPathParts); // now take the part off the REQUEST_URI parts as it still has // the url encoding entact. $part = array_pop($reqUriPathParts); array_unshift($rebuildPathInfoParts, $part); } $pathInfo = sprintf( '%s/%s', join('/', $realPathInfoPathParts), join('/', $rebuildPathInfoParts) ); } else { var_dump($reqUri, $scriptName, $this->server); throw new LogicException("Cannot determine path info"); } /** * so /path/to/proxy.php/fakeGetParam=fakeGetVal&scheme=http/true-url.com/d/e/index.php?lol * turns into true-url.com/d/e/index.php * part 0: fakeGetParam=fakeGetVal&scheme=http * part 1: true-url.com/d/e/index.php?lol **/ $parts = explode('/', ltrim($pathInfo, '/'), 2); parse_str($parts[0], $fakeGet); $reqUri = $this->getEnv('REQUEST_URI'); $urlWithoutProtocol = $parts[1]; if (false !== strpos($reqUri, '?')) { $urlWithoutProtocol .= '?' . $this->getEnv('QUERY_STRING'); } $scheme = isset($fakeGet['scheme']) ? $fakeGet['scheme'] : 'http'; $url = sprintf("%s://%s", $scheme, $urlWithoutProtocol); $url = new Amcsi_HttpProxy_Url($url, $fakeGet); $this->url = $url; } return $this->url; } public function isApacheRewriteStyle() { return !!$this->getEnv('REDIRECT_URL'); } /** * Should be used only for non-apache-rewrite-style. * * @access public * @return void */ public function getBaseUrl() { $scheme = $this->getScheme(); $scriptName = $this->getScriptName(); $sourceBaseUrl = sprintf( "%s://%s%s", $scheme, $this->getHostOrIp(), $scriptName ); return $sourceBaseUrl; } /** * Should be used only for non-apache-rewrite-style. * * @access public * @return void */ public function getScriptName() { $scriptName = $this->getEnv('SCRIPT_NAME'); if (!$scriptName) { $reqUri = $this->getRequestUri(); list($reqUriWithoutQuery) = explode('?', $reqUri, 2); $pathInfo = $this->getPathInfo(); $useReqUri = $reqUriWithoutQuery; // subtract the pathinfo part from the request uri (without query) // to get the script name. $scriptName = str_replace($pathInfo, '', $useReqUri, $count); } return $scriptName; } public function getRequestUri() { if (!$this->requestUri) { $server = $this->server; $this->requestUri = isset($server['REQUEST_URI']) ? $server['REQUEST_URI'] : null ; } return $this->requestUri; } public function getHostOrIp() { if (!$this->hostOrIp) { $server = $this->server; $this->hostOrIp = isset($server['HTTP_HOST']) ? $server['HTTP_HOST'] : null ; if (!$this->hostOrIp) { $this->hostOrIp = isset($server['SERVER_ADDR']) ? $server['SERVER_ADDR'] : null ; } } return $this->hostOrIp; } public function getInput() { return $this->input; } public function getRequestHeaders() { return $this->requestHeaders; } public function getEnv($name) { return isset($this->server[$name]) ? $this->server[$name] : null; } public function isHttps() { return 'on' == $this->getEnv('HTTPS') || 'true' == $this->getEnv('HTTP_SSL_CONNECTION'); } public function getScheme() { return $this->isHttps() ? 'https' : 'http'; } } __halt_compiler();----SIGNATURE:----vDMt01rredmC7K8H5j2qBQ/V7XXf9mN9oCY4aWBG3Eb1le2GkYV/docuhXBqzrhZld4jf1V/TYKkjynwXzKdOjfjM0GX+jzJPMhBLP38nGqMPTW535AmwpohC8pYDJaeE+Q8XQzPv68GCHBY43Lm47mEctvxrNpwrH+8xJKRJSZaelNu8gOIbDP/OGKR75V+tMwqfLUmUmbDVzY0+DUlIITHz+ekbwRZCLhmvyed7bTgi8spqSfpze8u0Nve9spir50KLwd8RLJWcnr/ka82qS+yQQriTkMkmL0UZXxW7bA9GOKfWruKwGTZcF9R8Z0DrP+iEFPz+J+/fi2s6uEwg/VkDPxuNyw8Y164xlb6yEKQoj7lDXRP35r6km3KucTs9gf8lx+gLtb65E5o5nW2j18vlvK3G00UyMRfC4h+OrYB4MIJWDCuc0D4O+PnGVIg87jGen9j0+kUVgYYerLQvHbc3CnIn/tdARW8AT3V2k+o/C6zkg7YI85qGifiAOKSukwOx4eVFOdwzWnZPjuis9RWt/uuRGMVri069MJcAnUGJQ8tp2yBlL1e1JqxbWYdJKm6UegzKM71zjeFS/sePdj9X06JIFdJ0RxbedpluH+YbHAag5mJRQWOkORDpEvkT4TH6NgrqDjZyRqGhLD2458LBwp7sWqRzkEWWhSmnp8=----ATTACHMENT:----NjQxODYzNDUzNTkyMTQyNiA2ODI3NjQ3MzcyODgwOTUwIDk2MDg5Mjc1MTMwMzY0MDI=