|
Posted by frizzle on 05/29/06 14:29
Bent Stigsen wrote:
> frizzle wrote:
> [snip]
> > $_SERVER['QUERY_STRING'] = '/artists/nirvana/mtv_unplugged'
> > $array[0] => artists
> > $array[1] => nirvana
> > $array[2] => mtv_unplugged
> > $array[3] => NULL
> [snip]
>
> This one above is your real problem. You would need some mechanism to
> determine what kind last element is, file or part of path. A lazy way
> could be to set the criteria or just make the assumption that files
> always has an attached extension (i.e. '.' in the name).
>
> For instance:
> function DefineLoc(){
> $loc = explode('/', trim( $_SERVER['QUERY_STRING'], '/' ) );
> if (strrpos(end($loc), '.')===false) $loc[] = null;
> reset($loc);
> return $loc;
> };
>
> If you have pathnames containing '.', then you would have to write
> some code that can make the distinction.
>
> /Bent
Actually what i have is quite similar to what you suggest. But it still
doesn't solve my double slash problem, where the value should be NULL.
The thingy i have to check if a filename is specified is the following:
if( preg_match( '/(\.html)$/', $loc[3] ) ){
$song_url = preg_replace( '/(\.html)$/', '', $loc[3] );
$song_extension = TRUE;
}else{
$song_extension = FALSE;
};
It checks all values in the array are UrlSafe(), wich means that they
are A-z, 0-9, -, _ That's also why i delete the last '.html', because
else validation would return false.
Frizzle.
[Back to original message]
|