You are here: Re: is_subdir « PHP Programming Language « IT news, forums, messages
Re: is_subdir

Posted by Andrι Hδnsel on 07/11/06 23:32

Mel schrieb:
> On 2006-07-10 03:49:12 +1000, "AndrΓ© HΓ€nsel" <andre@webkr.de> said:
>
> > ImOk schrieb:
> >> is_dir ("./mysubdir/mysubsubdir" )
> >
> > That only determines if ./mysubdir/mysubsubdir is a directory. It makes
> > no statement about whether it is a subdirectory of another directory.
> >
> > is_dir('../../nosubdir) will return true (if the dir exits, of course),
> > although it is no subdir of the working dir.
>
> Wouldn't you just try to open it as a directory from the context of the
> parent and if it opens, then it's a subdir?

If there were no ".."s in the world, that would work.
I would have to get some kind of temporary chroot, but that would
probably also dereference the symlinks.

But another idea:
There connot be an escaped slash in a path, can it?
What does a path like "dir\/subdir" mean?
a) a subdirectory of the current path named "dir/subdir"
b) a directory named "dir\" with a subdirectory named "subdir"
I think, it's answer b.

If that is true, it will be safe to just explode the path by "/",
traverse it and convert every "." to nothing and every ".." to "go one
step up" (if I am not already in /).

Right?

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация