Re: Remove domain: What do think of this approach?
| From: | Robin Vickery | Date: | Wed, 16 May 2007 08:51:48 +0000 |
| Subject: | Re: Remove domain: What do think of this approach? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255008@lists.php.net to get a copy of this message | ||
On 16/05/07, Micky Hulse <micky@ambiguism.com> wrote:
Hi folks, I hope everyone is having a good week. :) Let me cut to the chase... Basically, I need to get this: http://www.site.com/folder/foo To work like this: $_SERVER['DOCUMENT_ROOT'].'folder/foo/file.ext'; For use with getimagesize() and a few other functions (trying to avoid possible open_basedir restrictions.) Here is what I got so far: # Determine http type: $http_s = ($_SERVER['HTTPS'] == on) ? 'https://' : 'http://'; # Get root path: $from_root = str_replace($http_s.$_SERVER['SERVER_NAME'], '', http://www.site.com/folder/foo); echo $_SERVER['DOCUMENT_ROOT'].$from_root; /* ** Output: ** /web1/httpd/htdocs/blogs/images/uploads */ So, do you think I can rely upon the above script? I have a feeling the answer will be no.... Or, anyone have any tips/improvements?use parse_url() http://www.php.net/parse_url then append the 'path' part to document root ?