[PHP] Getting The Document Root

2006-02-02 Thread Jeremy Privett
I'm looking for a method that would be able to extract the user's true 
document root (e.g. /home/jeremy/public_html/) so that I can use it for 
some filesystem scanning functions. I'm trying to avoid hard-coding 
supported document roots in favor of being able to dynamically detect 
it, but nothing is coming to mind. I thought I would consult some of the 
minds of the mailing list for advice. Any ideas or code would be greatly 
appreciated.


--
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Silvio Porcellana [tradeOver]

Jeremy Privett wrote:
I'm looking for a method that would be able to extract the user's true 
document root (e.g. /home/jeremy/public_html/) so that I can use it for 
some filesystem scanning functions. I'm trying to avoid hard-coding 
supported document roots in favor of being able to dynamically detect 
it, but nothing is coming to mind. I thought I would consult some of the 
minds of the mailing list for advice. Any ideas or code would be greatly 
appreciated.




You can try with __FILE__

quote from=http://php.net/manual/en/language.constants.predefined.php;
 The full path and filename of the file. If used inside an include, the 
name of the included file is returned. Since PHP 4.0.2, __FILE__ always 
contains an absolute path whereas in older versions it contained 
relative path under some circumstances.

/quote

and then use 'dirname()'
http://php.net/manual/en/function.dirname.php

Ciao!
Silvio

--
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Jeremy Privett

[EMAIL PROTECTED] wrote:


the DOCUMENT_ROOT server variable (available to php/perl in the
standard methods for getting these) will give you the server's
document root.

in php, look at the output of:  phpinfo()



 Original Message 
 


Date: Thursday, February 02, 2006 07:14:22 AM -0600
From: Jeremy Privett [EMAIL PROTECTED]
To: php-general@lists.php.net
Subject: [PHP] Getting The Document Root

I'm looking for a method that would be able to extract the user's
true document root (e.g. /home/jeremy/public_html/) so that I can
use it for some filesystem scanning functions. I'm trying to avoid
hard-coding supported document roots in favor of being able to
dynamically detect it, but nothing is coming to mind. I thought I
would consult some of the minds of the mailing list for advice. Any
ideas or code would be greatly appreciated.

--
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   



-- End Original Message --



 

No, what I'm looking for is the root of the document root, if that makes 
any sense.


--
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Barry

Jeremy Privett wrote:

No, what I'm looking for is the root of the document root, if that makes 
any sense.



not at all ^_^

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Getting The Document Root

2006-02-02 Thread Jim Moseby
   
 
 No, what I'm looking for is the root of the document root, if 
 that makes 
 any sense.


How about $_SERVER['DOCUMENT_ROOT']?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Jeremy Privett

George Pitcher wrote:


Jeremy,

I think I lead you down the wrong path with my last reply.

have a look at $_ENV['ORIG_PATH_TRANSLATED'] which, on my WinXP Apache2 box
gives 'C:\Apache\Apache2\htdocs\testsite\phpinfo.php'.
Is that what you are after?

George
 



I think my original message may have been confusing. I'll give a better 
example:


I have a path: /home/jeremy/public_html/test/test.php

What I want off of the path is just the root of the user's document 
root (e.g. where he stores all his publically viewable files): 
/home/jeremy/public_html/


Now, the document root can vary from server to server ... Like /var/www/ 
or /home/jeremy/www/ or whatever. So, I'd like to know if there was a 
way to dynamically fetch it, instead of putting together a list of the 
known document roots (hard-coding supported ones).


I hope that makes more sense!

--
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread John Nichel

Jeremy Privett wrote:

George Pitcher wrote:


Jeremy,

I think I lead you down the wrong path with my last reply.

have a look at $_ENV['ORIG_PATH_TRANSLATED'] which, on my WinXP 
Apache2 box

gives 'C:\Apache\Apache2\htdocs\testsite\phpinfo.php'.
Is that what you are after?

George
 



I think my original message may have been confusing. I'll give a better 
example:


I have a path: /home/jeremy/public_html/test/test.php

What I want off of the path is just the root of the user's document 
root (e.g. where he stores all his publically viewable files): 
/home/jeremy/public_html/


Now, the document root can vary from server to server ... Like /var/www/ 
or /home/jeremy/www/ or whatever. So, I'd like to know if there was a 
way to dynamically fetch it, instead of putting together a list of the 
known document roots (hard-coding supported ones).


I hope that makes more sense!


$_SERVER['DOCUMENT_ROOT']
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Jeremy Privett

John Nichel wrote:


$_SERVER['DOCUMENT_ROOT']
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server 



Nope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains 
/home/jeremy/public_html/test/ ... All I want is to the public_html part.


--
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Joe Henry

you could try pathinfo()

http://us3.php.net/pathinfo



On Feb 2, 2006, at 8:59 AM, Jeremy Privett wrote:


John Nichel wrote:


$_SERVER['DOCUMENT_ROOT']
http://www.php.net/manual/en/ 
reserved.variables.php#reserved.variables.server


Nope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains  
/home/jeremy/public_html/test/ ... All I want is to the public_html  
part.


--
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread John Nichel

Jeremy Privett wrote:

John Nichel wrote:


$_SERVER['DOCUMENT_ROOT']
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server 




Nope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains 
/home/jeremy/public_html/test/ ... All I want is to the public_html part.




'DOCUMET_ROOT' will return what the web server's document root is, no 
matter what directory on that web server the script is run.


ie, I'm running apache, look here

http://www.nichel.net/docroot.php
http://www.nichel.net/test/docroot.php
http://www.nichel.net/bob/docroot.php
http://www.nichel.net/bob/fred/docroot.php

All four of those 'docroot.php' scripts are the same:

?php


echo ( $_SERVER['DOCUMENT_ROOT'] );


?

But they're in four different directories.  Document root is just that, 
it's the directory where Apache (or other web servers) start serving 
files from for the particular domain.


Either you're webserver is seriously hosed (I can't even imagine how), 
or document root is not what you're thinking it is.  If you place a 
script three levels below the 'test' directory which echo's out document 
root, what's the output?


--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Jeremy Privett

John Nichel wrote:


Jeremy Privett wrote:


John Nichel wrote:


$_SERVER['DOCUMENT_ROOT']
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server 





Nope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains 
/home/jeremy/public_html/test/ ... All I want is to the public_html 
part.




'DOCUMET_ROOT' will return what the web server's document root is, no 
matter what directory on that web server the script is run.


ie, I'm running apache, look here

http://www.nichel.net/docroot.php
http://www.nichel.net/test/docroot.php
http://www.nichel.net/bob/docroot.php
http://www.nichel.net/bob/fred/docroot.php

All four of those 'docroot.php' scripts are the same:

?php


echo ( $_SERVER['DOCUMENT_ROOT'] );


?

But they're in four different directories.  Document root is just 
that, it's the directory where Apache (or other web servers) start 
serving files from for the particular domain.


Either you're webserver is seriously hosed (I can't even imagine how), 
or document root is not what you're thinking it is.  If you place a 
script three levels below the 'test' directory which echo's out 
document root, what's the output?


Aha. So that DOES work. I see what the problem is now. I'm testing off 
of a sub-domain, so the document root is the root for that sub-domain. 
That's why it was tripping me up.


Thanks guys, that did the trick! :-)

--
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread tedd
I think my original message may have been confusing. I'll give a 
better example:


I have a path: /home/jeremy/public_html/test/test.php

What I want off of the path is just the root of the user's 
document root (e.g. where he stores all his publically viewable 
files): /home/jeremy/public_html/


Now, the document root can vary from server to server ... Like 
/var/www/ or /home/jeremy/www/ or whatever. So, I'd like to know if 
there was a way to dynamically fetch it, instead of putting together 
a list of the known document roots (hard-coding supported ones).


I hope that makes more sense!



Try this:

echo(pre);
print_r($_SERVER);
echo(/pre);

Maybe you'll find something there.

tedd
--

http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Richard Lynch
On Thu, February 2, 2006 7:14 am, Jeremy Privett wrote:
 I'm looking for a method that would be able to extract the user's true
 document root (e.g. /home/jeremy/public_html/) so that I can use it
 for
 some filesystem scanning functions. I'm trying to avoid hard-coding
 supported document roots in favor of being able to dynamically detect
 it, but nothing is coming to mind. I thought I would consult some of
 the
 minds of the mailing list for advice. Any ideas or code would be
 greatly
 appreciated.

What you want is in the output from:
?php phpinfo();?

Just search for the directory on your site that you know is correct,
and figure out which variables you need to get that.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting The Document Root

2006-02-02 Thread Richard Lynch
On Thu, February 2, 2006 9:59 am, Jeremy Privett wrote:
 John Nichel wrote:

 $_SERVER['DOCUMENT_ROOT']
 http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server


 Nope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains
 /home/jeremy/public_html/test/ ... All I want is to the public_html
 part.

dirname($_SERVER['DOCUMENT_ROOT'])
http://php.net/dirname

Though, really, you're not making any sense at all...

Whatever it is you are trying to do, you're probably doing it wrong...

That said, again, if the value you want isn't in, or derivable from,
phpinfo() then you probably can't get it...

If you always want one directory *above* DOCUMENT_ROOT, dirname is
your answer.  If that's not what you want, then I doubt anybody will
understand what you want from what's posted so far.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php