X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fwebredirect.php;h=311ae976b6a5c6394a36e7d4dec1c09c3b14d294;hb=076412639089ff7a5dfd8ae1652faf1683c322e5;hp=0de8baa6992da1f7873455cd365c5e861c939d60;hpb=d0edeb70f254ed642b59c7c3636b7802266bcfe4;p=platal.git diff --git a/htdocs/webredirect.php b/htdocs/webredirect.php index 0de8baa..311ae97 100644 --- a/htdocs/webredirect.php +++ b/htdocs/webredirect.php @@ -21,28 +21,27 @@ require_once 'xorg.inc.php'; -new Platal('core'); +$platal = new Xorg('core'); global $globals; -list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPLIT_NO_EMPTY); -$res = XDB::query( - "SELECT redirecturl - FROM auth_user_quick AS a - INNER JOIN aliases AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias')) - WHERE al.alias = {?} - GROUP BY redirecturl", $username); +$path = ltrim($platal->pl_self(), '/'); +@list($username, $path) = explode('/', $path, 2); -if ($url = $res->fetchOneCell()) { - $url = preg_replace('@/+$@', '', $url); - if ($path) { - http_redirect("http://$url/$path"); - } else { - http_redirect("http://$url"); +if ($username && !is_null($user = User::getSilent($username))) { + $url = XDB::fetchOneCell('SELECT url + FROM carvas + WHERE uid = {?}', $user->id()); + if ($url) { + $url = preg_replace('@/+$@', '', $url); + if ($path) { + http_redirect("http://$url/$path"); + } else { + http_redirect("http://$url"); + } } } -header("HTTP/1.0 404 Not Found"); - +header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); ?>