Okie, no problem
This will take some work.
You could use the explode() function to split the base path into an array.
Then you could do the same with the relative path.
Now you have two arrays that contain the subdirectory names of
the base and relative path.
Now you can check to see if the first element of the relative_array
contains ".."
if it does, that means you have to move one directory backwards in the base path, so you remove the last element from the base_array.
Then you can chck the second element in the relative array, etc.