Elgg  Version 1.11
index.php
Go to the documentation of this file.
1 <?php
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 if (!$router->route($request)) {
61  forward('', '404');
62 }
$router
Definition: index.php:57
$request
Definition: index.php:58
exit
Definition: reorder.php:12
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:432
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:419
_elgg_services()
Definition: autoloader.php:14
elgg echo
Translates a string.
Definition: languages.js:43
elgg require
Throw an error if the required package isn&#39;t present.
Definition: elgglib.js:164