The subject says it all really.
For example I have a directory /var/www/wiki/lib/plugins/indexmenu which is a symbolic link to /home/chris/src/dokuwiki-plugins/indexmenu. I want a way (in PHP in particular) to be able to navigate up to /var/www/wiki but everything I try program-wise takes me back to the /home/chris tree.
I'm sure on the old SunOs/Solaris systems I used if you navigated up on the command line it didn't go backwards up symbolic links, but on this xubuntu 10.04 system if I do, for example, 'ls ../..' when I'm in /var/www/wiki/lib/plugins/indexmenu I see the contents of /home/chris/src which somehow feels wrong to me.
The real issue is in PHP though as there are many places in dokuwiki which use ../../.. to access things and there doesn't seem to be an easy way to do this when there are symbolic links involved. One can use regular expressions to prune /var/www/wiki/lib/plugins/indexmenu down to /var/www/wiki/ but this seems a bit of a sledgehammer to crack a nut.
On Sat, Aug 13, 2011 at 11:56:07AM +0100, Chris G wrote:
The subject says it all really.
For example I have a directory /var/www/wiki/lib/plugins/indexmenu which is a symbolic link to /home/chris/src/dokuwiki-plugins/indexmenu. I want a way (in PHP in particular) to be able to navigate up to /var/www/wiki but everything I try program-wise takes me back to the /home/chris tree.
I'm sure on the old SunOs/Solaris systems I used if you navigated up on the command line it didn't go backwards up symbolic links, but on this xubuntu 10.04 system if I do, for example, 'ls ../..' when I'm in /var/www/wiki/lib/plugins/indexmenu I see the contents of /home/chris/src which somehow feels wrong to me.
The real issue is in PHP though as there are many places in dokuwiki which use ../../.. to access things and there doesn't seem to be an easy way to do this when there are symbolic links involved. One can use regular expressions to prune /var/www/wiki/lib/plugins/indexmenu down to /var/www/wiki/ but this seems a bit of a sledgehammer to crack a nut.
More to the point after a little further testing the *real* problem is that __FILE__ resolves to the 'real' name of the file, with symbolic links resolved.
So __FILE__ in the file /var/www/wiki/lib/plugins/indexmenu/fred.php is '/home/chris/src/dokuwiki-plugins/indexmenu/fred.php' so however I manipulate it I can't get to /var/www/wiki. What I need is a way to find the home directory of a file in PHP and I can't really see any practical way of doing it.
So, given a file /var/www/wiki/lib/plugins/indexmenu/fred.php where indexmenu is a symbolic link, how can fred.php work out that it is in directory /var/www/wiki/lib/plugins/indexmenu?
On 13/08/11 12:31, Chris G wrote:
On Sat, Aug 13, 2011 at 11:56:07AM +0100, Chris G wrote:
The subject says it all really.
For example I have a directory /var/www/wiki/lib/plugins/indexmenu which is a symbolic link to /home/chris/src/dokuwiki-plugins/indexmenu. I want a way (in PHP in particular) to be able to navigate up to /var/www/wiki but everything I try program-wise takes me back to the /home/chris tree.
I'm sure on the old SunOs/Solaris systems I used if you navigated up on the command line it didn't go backwards up symbolic links, but on this xubuntu 10.04 system if I do, for example, 'ls ../..' when I'm in /var/www/wiki/lib/plugins/indexmenu I see the contents of /home/chris/src which somehow feels wrong to me.
The real issue is in PHP though as there are many places in dokuwiki which use ../../.. to access things and there doesn't seem to be an easy way to do this when there are symbolic links involved. One can use regular expressions to prune /var/www/wiki/lib/plugins/indexmenu down to /var/www/wiki/ but this seems a bit of a sledgehammer to crack a nut.
More to the point after a little further testing the *real* problem is that __FILE__ resolves to the 'real' name of the file, with symbolic links resolved.
So __FILE__ in the file /var/www/wiki/lib/plugins/indexmenu/fred.php is '/home/chris/src/dokuwiki-plugins/indexmenu/fred.php' so however I manipulate it I can't get to /var/www/wiki. What I need is a way to find the home directory of a file in PHP and I can't really see any practical way of doing it.
So, given a file /var/www/wiki/lib/plugins/indexmenu/fred.php where indexmenu is a symbolic link, how can fred.php work out that it is in directory /var/www/wiki/lib/plugins/indexmenu?
I dunno if this will help but pwd -P will give the physical directory. Maybe calling that from php with the shell_exec function.
On Sat, Aug 13, 2011 at 04:21:50PM +0100, nev young wrote:
On 13/08/11 12:31, Chris G wrote:
On Sat, Aug 13, 2011 at 11:56:07AM +0100, Chris G wrote:
The subject says it all really.
For example I have a directory /var/www/wiki/lib/plugins/indexmenu which is a symbolic link to /home/chris/src/dokuwiki-plugins/indexmenu. I want a way (in PHP in particular) to be able to navigate up to /var/www/wiki but everything I try program-wise takes me back to the /home/chris tree.
I'm sure on the old SunOs/Solaris systems I used if you navigated up on the command line it didn't go backwards up symbolic links, but on this xubuntu 10.04 system if I do, for example, 'ls ../..' when I'm in /var/www/wiki/lib/plugins/indexmenu I see the contents of /home/chris/src which somehow feels wrong to me.
The real issue is in PHP though as there are many places in dokuwiki which use ../../.. to access things and there doesn't seem to be an easy way to do this when there are symbolic links involved. One can use regular expressions to prune /var/www/wiki/lib/plugins/indexmenu down to /var/www/wiki/ but this seems a bit of a sledgehammer to crack a nut.
More to the point after a little further testing the *real* problem is that __FILE__ resolves to the 'real' name of the file, with symbolic links resolved.
So __FILE__ in the file /var/www/wiki/lib/plugins/indexmenu/fred.php is '/home/chris/src/dokuwiki-plugins/indexmenu/fred.php' so however I manipulate it I can't get to /var/www/wiki. What I need is a way to find the home directory of a file in PHP and I can't really see any practical way of doing it.
So, given a file /var/www/wiki/lib/plugins/indexmenu/fred.php where indexmenu is a symbolic link, how can fred.php work out that it is in directory /var/www/wiki/lib/plugins/indexmenu?
I dunno if this will help but pwd -P will give the physical directory. Maybe calling that from php with the shell_exec function.
That's the wrong way round! :-)
I want the not-physical (can't think of a better name) directory and that's what's rather difficult to get in PHP. Not to mention that I need the directory relative to the PHP script's path, not the current working directory.
I have a workaround/fix now which uses $_SERVER["SCRIPT_FILENAME"], however I'm not really sure if this is a proper cure. It does work for the particular case in question at the moment though.
On 13/08/11 16:28, Chris G wrote:
On Sat, Aug 13, 2011 at 04:21:50PM +0100, nev young wrote:
On 13/08/11 12:31, Chris G wrote:
On Sat, Aug 13, 2011 at 11:56:07AM +0100, Chris G wrote:
The subject says it all really.
For example I have a directory /var/www/wiki/lib/plugins/indexmenu which is a symbolic link to /home/chris/src/dokuwiki-plugins/indexmenu. I want a way (in PHP in particular) to be able to navigate up to /var/www/wiki but everything I try program-wise takes me back to the /home/chris tree.
I'm sure on the old SunOs/Solaris systems I used if you navigated up on the command line it didn't go backwards up symbolic links, but on this xubuntu 10.04 system if I do, for example, 'ls ../..' when I'm in /var/www/wiki/lib/plugins/indexmenu I see the contents of /home/chris/src which somehow feels wrong to me.
The real issue is in PHP though as there are many places in dokuwiki which use ../../.. to access things and there doesn't seem to be an easy way to do this when there are symbolic links involved. One can use regular expressions to prune /var/www/wiki/lib/plugins/indexmenu down to /var/www/wiki/ but this seems a bit of a sledgehammer to crack a nut.
More to the point after a little further testing the *real* problem is that __FILE__ resolves to the 'real' name of the file, with symbolic links resolved.
So __FILE__ in the file /var/www/wiki/lib/plugins/indexmenu/fred.php is '/home/chris/src/dokuwiki-plugins/indexmenu/fred.php' so however I manipulate it I can't get to /var/www/wiki. What I need is a way to find the home directory of a file in PHP and I can't really see any practical way of doing it.
So, given a file /var/www/wiki/lib/plugins/indexmenu/fred.php where indexmenu is a symbolic link, how can fred.php work out that it is in directory /var/www/wiki/lib/plugins/indexmenu?
I dunno if this will help but pwd -P will give the physical directory. Maybe calling that from php with the shell_exec function.
That's the wrong way round! :-)
I want the not-physical (can't think of a better name) directory and that's what's rather difficult to get in PHP. Not to mention that I need the directory relative to the PHP script's path, not the current working directory.
Ah soz. I'm quite good at getting the wrong stick end. :-)