Project

General

Profile

1 8362 aaronmk
<?php
2
# parses any dotpath in the query string
3
4
require_once dirname(__FILE__)."/util.php";
5
6 8499 aaronmk
$path = $_SERVER["QUERY_STRING"];
7 8362 aaronmk
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 8490 aaronmk
$path = rm_prefix(".", $path); # . prefix forces interpretation as a dotpath
12 8362 aaronmk
do
13
{
14
	$old_path = $path;
15 8499 aaronmk
	$path = preg_replace('/^([^&]*\/)?(?=.)(\.?[^.\/&]*?)(?:\[([^\[\]\/&]*)\])?\.([^\/&]*)$/',
16 8362 aaronmk
		'$1$2$3/$4', $path);
17
} while ($path !== $old_path);
18
19 8499 aaronmk
$url = ensure_suffix("/", $_SERVER["PATH_INFO"]).$path;
20 8362 aaronmk
header("Location: ".$url);
21
?>