Re: cvs: phpweb / get_download.php
| From: | David | Date: | Thu, 15 May 2003 21:07:58 +0000 |
| Subject: | Re: cvs: phpweb / get_download.php | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-17718@lists.php.net to get a copy of this message | ||
Hi Rasmus
You might want to do something like this, which I use on my sites. The
top-level directory has a .site_root file... $relative_path ends up as a
filesystem path to the root and $root ends up as a relative URI to the
root, and they continue to work in public_html or anywhere else that the
site isn't at the root on a given server.
$i = 0;
$relative_path = '';
while (!file_exists($relative_path.'.site_root') and $i < 5) {
$i ++;
$relative_path .= '../';
}
if ($i >= 5) {
trigger_error('ROOT001', E_USER_ERROR);
}
preg_match("/(.*\/)[^\/]+/", $SCRIPT_NAME, $matches);
$root = $matches[1];
/* Kill duplicate // since Apache doesn't canonicalise */
while ($root != ($root = str_replace('//', '/', $root))) ;
/* Determine the URI to the root of this web */
while ($i > 0) {
if (!preg_match("/(.*\/)[^\/]+\//", $root, $matches)) {
trigger_error('ROOT002', E_USER_ERROR);
}
$root = $matches[1];
$i --;
}
if (!$root) {
$root = "/";
}
For http://www.blah.com/~david/php/phpweb/error/error.html
$relative_path = "../";
$root = "/~david/php/phpweb/";
For http://www.php.net/test.html
$relative_path = "";
$root = "/";
Of course it wouldn't be worth doing this just for the error page :)
David
On Thu, 15 May 2003, Rasmus Lerdorf wrote:
> On Thu, 15 May 2003, David Croft wrote:
> > david Thu May 15 14:42:09 2003 EDT
> >
> > Modified files:
> > /phpweb get_download.php
> > Log:
> > back out rasmus' include_path fix on this file, presumably it's using
> > mod_rewrite or something
>
> Ah, this page can end up getting loaded by the 404 handler sitting in
> /error/index.php and then the relative path will be wrong. There is
> really no good reason the error handler needs to be in a different
> directory. Should probably just be /error.php instead.
>
> -Rasmus
>
>
--
|> /+\ \| | |>
David Croft
Infotrek