Is there a way in PHP how to determine an absolute path given a relative path without actually resolving symlinks? Something like the realpath function but without symlink resolution.
Or alternatively, is there some easy way to check whether user (who uses my browsing PHP script to view files) did not accidentally step out of Apache virtual host’s home directory? (or disallow him to use the nasty . and .. in paths)
Thanks!
I don’t know PHP native solution for this, but here’s one nice absolute path implementation from a comment in the PHP docs:
(edited for formatting & typos)