Project

General

Profile

« Previous | Next » 

Revision 13613

web/index.php: subpath@host? redirects: also support multiple @ and nested . in prefix: @host? -> host?b.c.a

View differences:

index.php
13 13
	};
14 14
}
15 15

  
16
function user2path($user) # multiple @ and nested . OK: a@b.c@host -> host?b.c.a
17
{ return implode(".", array_reverse(explode("@", $user))); }
18

  
16 19
# redirect subpath@host? -> host?subpath (one type of prefix redirect)
17 20
# better than subpath.host because case is preserved and special chars allowed
18 21
# must require trailing ? , to avoid needing login to view the page itself
22
# subpath prefix: see format in user2path()
19 23
if (substr($_SERVER["REQUEST_URI"], -1/*last char*/) === "?")
20 24
{
21 25
	if (!isset($_SERVER["PHP_AUTH_USER"])) # browser first omits Authorization
......
24 28
	}
25 29
	elseif ($_SERVER["PHP_AUTH_USER"] !== "")
26 30
	{
27
		header("Location: ?".$_SERVER["PHP_AUTH_USER"]);
31
		header("Location: ?".user2path($_SERVER["PHP_AUTH_USER"]));
28 32
		exit;
29 33
	}
30 34
	# otherwise, user empty so just display page

Also available in: Unified diff