Passed
Push — gc_invite_api-mod ( 8472c1...b55498 )
by
unknown
28:35 queued 13:21
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $router->route($request) of type null|boolean is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
64
	forward('', '404');
65
}