|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Elgg front controller entry point |
|
4
|
|
|
* |
|
5
|
|
|
* @package Elgg |
|
6
|
|
|
* @subpackage Core |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/* |
|
10
|
|
|
* Rewrite rules for PHP cli webserver used for testing. Do not use on production sites |
|
11
|
|
|
* as normal web server replacement. |
|
12
|
|
|
* |
|
13
|
|
|
* You need to explicitly point to index.php in order for router to work properly: |
|
14
|
|
|
* |
|
15
|
|
|
* <code>php -S localhost:8888 index.php</code> |
|
16
|
|
|
*/ |
|
17
|
|
|
if (php_sapi_name() === 'cli-server') { |
|
18
|
|
|
$urlPath = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
19
|
|
|
|
|
20
|
|
|
if (preg_match('/^\/cache\/(.*)$/', $urlPath, $matches)) { |
|
21
|
|
|
$_GET['request'] = $matches[1]; |
|
22
|
|
|
require('engine/handlers/cache_handler.php'); |
|
23
|
|
|
exit; |
|
24
|
|
|
} else if (preg_match('/^\/export\/([A-Za-z]+)\/([0-9]+)\/?$/', $urlPath, $matches)) { |
|
25
|
|
|
$_GET['view'] = $matches[1]; |
|
26
|
|
|
$_GET['guid'] = $matches[2]; |
|
27
|
|
|
require('engine/handlers/export_handler.php'); |
|
28
|
|
|
exit; |
|
29
|
|
|
} else if (preg_match('/^\/export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$/', $urlPath, $matches)) { |
|
30
|
|
|
$_GET['view'] = $matches[1]; |
|
31
|
|
|
$_GET['guid'] = $matches[2]; |
|
32
|
|
|
$_GET['type'] = $matches[3]; |
|
33
|
|
|
$_GET['idname'] = $matches[4]; |
|
34
|
|
|
require('engine/handlers/export_handler.php'); |
|
35
|
|
|
exit; |
|
36
|
|
|
} else if (preg_match("/^\/rewrite.php$/", $urlPath, $matches)) { |
|
37
|
|
|
require('install.php'); |
|
38
|
|
|
exit; |
|
39
|
|
|
} else if ($urlPath !== '/' && file_exists(__DIR__ . $urlPath)) { |
|
40
|
|
|
// serve the requested resource as-is. |
|
41
|
|
|
return false; |
|
42
|
|
|
} else { |
|
43
|
|
|
$_GET['__elgg_uri'] = $urlPath; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
// allow testing from the upgrade page before the site is upgraded. |
|
48
|
|
|
if (isset($_GET['__testing_rewrite'])) { |
|
49
|
|
|
if (isset($_GET['__elgg_uri']) && false !== strpos($_GET['__elgg_uri'], '__testing_rewrite')) { |
|
50
|
|
|
echo "success"; |
|
51
|
|
|
} |
|
52
|
|
|
exit; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
require_once(dirname(__FILE__) . "/engine/start.php"); |
|
56
|
|
|
|
|
57
|
|
|
$router = _elgg_services()->router; |
|
58
|
|
|
$request = _elgg_services()->request; |
|
59
|
|
|
|
|
60
|
|
|
// TODO use formal Response object instead |
|
61
|
|
|
header("Content-Type: text/html;charset=utf-8"); |
|
62
|
|
|
|
|
63
|
|
|
if (!$router->route($request)) { |
|
|
|
|
|
|
64
|
|
|
forward('', '404'); |
|
65
|
|
|
} |
If an expression can have both
false, andnullas possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.