Page 1 of 2

How know the web path (some servers have public_html dir, ot

Posted: Tue Mar 29, 2005 12:12 pm
by astrix
How know the web path (some servers have public_html dir, others other)

Is possible know with PHP which is the real web path?

In some servers FTP connect directly to the web path, others have subdirectories and the public_html are the real web path... Others use other name (www for example)...

Is possible retrieve from PHP which is the real web path?

Well, in reality me problem is more complex, I pass to a script the ip, username and password of a remote server and I want to automatically upload a file to the web root directory of the remote server via ftp (ftp_connect, ftp_login... etc) and I not find how to know with code which is the web root directory, not all servers have public_html, other the web root directory is www and others connect directly via ftp to the web root directory...

I am searching in the web for the answer and no find the solution... Well, but I think is logical that has to be possible to know the web root directory...

Thanks in advance...!!!

Posted: Tue Mar 29, 2005 12:19 pm
by feyd
$_SERVER['DOCUMENT_ROOT']

Posted: Tue Mar 29, 2005 12:26 pm
by astrix
feyd wrote:$_SERVER['DOCUMENT_ROOT']
Thanks feyd, but $_SERVER['DOCUMENT_ROOT'] not is valid because I need the web root of the remote server accesed by ftp, with $_SERVER['DOCUMENT_ROOT'] I retrieve the web root directory of the php file that do the connection, not the web root directory of the web accessed by ftp...

Thanks feyd...

Posted: Tue Mar 29, 2005 12:30 pm
by feyd
You have to find that out from the remote server. i.e. run such a thing on the remote server, or have the person input the information. There are too many differing possibilities to program for them all. You can make several for known styles though.. but it should still be customizable, as a host may make them completely different..

Posted: Tue Mar 29, 2005 12:35 pm
by astrix
feyd wrote:You have to find that out from the remote server. i.e. run such a thing on the remote server, or have the person input the information. There are too many differing possibilities to program for them all. You can make several for known styles though.. but it should still be customizable, as a host may make them completely different..
But automatically not is possible?

I not know also if the vars is possible to run via ftp, for example, is possible in a remote server accessed by ftp use vars how:

$_SERVER['HTTP_HOST']
$_SERVER['SCRIPT_FILENAME']
$_SERVER['DOCUMENT_ROOT']

Etc...?

Also I think the info are in the server, the server have info of which is the web root directory (public_html or other), this info should be know with php becuase are a server info...

Posted: Tue Mar 29, 2005 12:49 pm
by feyd
those would all be relative to the server php is running on.. not the remote location. You need to be given the information for the remote location. That's pretty standard procedure when getting ftp information from someone else..

Posted: Tue Mar 29, 2005 1:25 pm
by astrix
feyd wrote:those would all be relative to the server php is running on.. not the remote location. You need to be given the information for the remote location. That's pretty standard procedure when getting ftp information from someone else..
Ok... I think is possible the ftp_rawlist do any info about the whcich is the web root path?

I need to check this, I think is possible are the only way for retrieve info of the remote server accessed by ftp...

Posted: Tue Mar 29, 2005 1:30 pm
by feyd
you can read the ftp directory list and such, but if you don't definitively know where to place the file, you could mistakenly mess something up. So be careful in your assumptions.

Posted: Tue Mar 29, 2005 1:43 pm
by astrix
feyd wrote:you can read the ftp directory list and such, but if you don't definitively know where to place the file, you could mistakenly mess something up. So be careful in your assumptions.
Ok feyd, well, appear to be are some special info in the ftp_rawlist, I execute ftp_rawlist in one of me webs and appear this:

drwxr-xr-x 4 ftpuser ftpgroup 4096 Jun 25 2003 cpanel3-skel
drwxr-xr-x 6 ftpuser ftpgroup 4096 Nov 11 2003 cpanelbranding
drwxr-x--- 3 ftpuser ftpgroup 4096 Oct 15 2003 etc
drwx------ 2 ftpuser ftpgroup 4096 Feb 28 00:10 logs
drwxrwx--- 3 ftpuser ftpgroup 4096 Mar 29 19:28 mail
drwxr-xr-x 3 ftpuser ftpgroup 4096 Nov 19 2003 public_ftp
drwxr-x--- 60 ftpuser ftpgroup 8192 Mar 29 15:59 public_html
drwx------ 8 ftpuser ftpgroup 4096 Jan 18 00:48 tmp
lrwxrwxrwx 1 ftpuser ftpgroup 11 May 21 2004 www -> public_html

You know where is detailed onfo about the return of ftp_rawlist?

In http://www.php.net the info is very little, not is detailed:
Return Values
Returns an array where each element corresponds to one line of text.

The output is not parsed in any way. The system type identifier returned by ftp_systype() can be used to determine how the results should be interpreted.
But this special value:

drwxr-x--- 60 ftpuser ftpgroup 8192 Mar 29 15:59 public_html

60

Is possible do something info... I need to search for ftp_rawlist output... Wath do you think?

Posted: Tue Mar 29, 2005 1:49 pm
by feyd
here's how the info breaks down for the following:

drwxrwxrwx

the first letter tells you what it is, directory is a 'd', link is a 'l' and so forth.
each set of three characters after the first details the permissions it has:

r is read
w is write
x is execution

Posted: Tue Mar 29, 2005 1:52 pm
by timvw
actually that is useless info...

the place where you see 60 indicaties the filesize (in bytes) but is not useful for directories..

Posted: Tue Mar 29, 2005 1:55 pm
by astrix
timvw wrote:actually that is useless info...

the place where you see 60 indicaties the filesize (in bytes) but is not useful for directories..
Is sure?

I think the size is this parameter:

drwxr-x--- 60 ftpuser ftpgroup 8192 Mar 29 15:59 public_html

??? But I not know well the return of ftp_rawlist....

I think is this parameter because an archive in this root directory are:

-rw-r--r-- 1 ftpuser ftpgroup 180594 Nov 17 2003 site_cp_access.log

And in me cuteftp the size of the site_cp_access.log are 0.17 MB...

Posted: Tue Mar 29, 2005 1:59 pm
by astrix
feyd wrote:here's how the info breaks down for the following:

drwxrwxrwx

the first letter tells you what it is, directory is a 'd', link is a 'l' and so forth.
each set of three characters after the first details the permissions it has:

r is read
w is write
x is execution
Yes, the first letter of the first item in the array are the info about if is dir, file or syslink, the other part of the first item is the chmod, but the second item of the array???

drwxr-x--- 60 ftpuser ftpgroup 8192 Mar 29 15:59 public_html

Posted: Tue Mar 29, 2005 3:42 pm
by astrix
I believe I have the solution... Is the symlink...

Appear to be if the web root directory not is the ftp root directory always exists a symlink to the web root directory, for example in the list of ftp_rawlist:

drwxr-xr-x 4 ftpuser ftpgroup 4096 Jun 25 2003 cpanel3-skel
drwxr-xr-x 6 ftpuser ftpgroup 4096 Nov 11 2003 cpanelbranding
drwxr-x--- 3 ftpuser ftpgroup 4096 Oct 15 2003 etc
drwx------ 2 ftpuser ftpgroup 4096 Feb 28 00:10 logs
drwxrwx--- 3 ftpuser ftpgroup 4096 Mar 29 19:28 mail
drwxr-xr-x 3 ftpuser ftpgroup 4096 Nov 19 2003 public_ftp
drwxr-x--- 60 ftpuser ftpgroup 8192 Mar 29 15:59 public_html
drwx------ 8 ftpuser ftpgroup 4096 Jan 18 00:48 tmp
lrwxrwxrwx 1 ftpuser ftpgroup 11 May 21 2004 www -> public_html

The last item is a symlink - is symlink becuase the first letter are a "l" (lrwxrwxrwx) - to the public_html (www -> public_html) that is the web root directory... In cases of servers that connect by ftp directly to the web root - yahoo hostings for example - not exists a symlink...

If any attempt to delete the symlink directory in the ftp root, all the web root directory is deleted also, because this I believe the symlink exists always if the web root not is the same of the ftp root...

I believe cheking for the symlinks is possible know which is the web root directory...

Any know if this is well? Won't be exceptions?

Posted: Tue Mar 29, 2005 4:00 pm
by timvw
sorry, my mistake, the 60 doesn't indicate filesize... if i'm not mistaken it indicates the number of "links" to the file.


but there is no relationship between a symlink and your www rootdir.