-
Notifications
You must be signed in to change notification settings - Fork 1
/
detect-app.php
29 lines (24 loc) · 1.01 KB
/
detect-app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/*
* Copyright (c) 2014, webvariants GmbH & Co. KG, http://www.webvariants.de
*
* This file is released under the terms of the MIT license. You can find the
* complete text in the attached LICENSE file or online at:
*
* http://www.opensource.org/licenses/mit-license.php
*/
// determine application based on the request URI
function _sly_router($server) {
$base = dirname($server['SCRIPT_NAME']);
$reqUri = rawurldecode($server['REQUEST_URI']);
$reqUri = substr($reqUri, strlen($base));
$reqUri = preg_replace('/[?&].*$/', '', $reqUri);
$reqUri = trim($reqUri, '/');
// route other app URIs (be careful not to confuse the assets)
if (preg_match('#^backend(?!/assets/)(/|$)#', $reqUri)) return array('backend', 'backend');
if (preg_match('#^setup(?!/assets/)(/|$)#', $reqUri)) return array('setup', 'setup');
if (preg_match('#^(assets|mediapool)/#', $reqUri)) return array('assets', '/');
// everything else goes through the frontend
return array('frontend', '/');
}
return _sly_router($_SERVER);