1
|
<?php
|
2
|
# parses any dotpath in the query string
|
3
|
|
4
|
require_once dirname(__FILE__)."/util.php";
|
5
|
|
6
|
$path = $_SERVER["QUERY_STRING"];
|
7
|
|
8
|
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c
|
9
|
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
|
10
|
# remove any [] escape, e.g. a.b=[c.d] -> a/b=c.d (the ] must be at the end)
|
11
|
$path = rm_prefix(".", $path); # . prefix forces interpretation as a dotpath
|
12
|
do
|
13
|
{
|
14
|
$old_path = $path;
|
15
|
$path = preg_replace('/^([^&]*\/)?(?=.)(\.?[^.\/&]*?)(?:\[([^\[\]\/&]*)\])?\.([^\/&]*)$/',
|
16
|
'$1$2$3/$4', $path);
|
17
|
} while ($path !== $old_path);
|
18
|
|
19
|
$url = ensure_suffix("/", $_SERVER["PATH_INFO"]).$path;
|
20
|
header("Location: ".$url);
|
21
|
?>
|