-
-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathrouter.php
More file actions
145 lines (134 loc) · 6.63 KB
/
router.php
File metadata and controls
145 lines (134 loc) · 6.63 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../config.php');
$requested_uri = $_SERVER['REQUEST_URI'];
if (str_contains('router.php', (string) $requested_uri)) {
throw new \Exception('bad');
}
$contents = '';
try {
if ($requested_uri === '/') {
$contents = XdebugDotOrg\Controller\HomeController::index()->render();
} elseif ($requested_uri === '/updates') {
$contents = XdebugDotOrg\Controller\HomeController::updates()->render();
} elseif ($requested_uri === '/download') {
$contents = XdebugDotOrg\Controller\HomeController::download()->render();
} elseif ($requested_uri === '/download/historical') {
$contents = XdebugDotOrg\Controller\HomeController::historicalReleases()->render();
} elseif (preg_match('/^\/docs(\/([A-Za-z_]+))?(\/([a-z]{2}))?/', (string) $requested_uri, $matches)) {
$pages = [
'install', 'develop', 'trace',
'profiler', 'step_debug', 'code_coverage', 'compat', 'errors', 'faq', 'dbgpClient', 'dbgp',
'garbage_collection', 'flamegraphs', 'contributing', 'dbgpClient', 'dbgpProxy', 'upgrade_guide',
'xdebugctl',
];
$redirectDevelopPages = [ 'basic', 'display', 'stack_trace' ];
$redirectDocPages = [
'debugclient' => 'dbgpClient',
];
$language = null;
if (isset($matches[4])) {
if ($matches[2] == 'upgrade_guide' && $matches[4] == 'ja') {
$language = $matches[4];
}
}
if (isset($matches[2])) {
if ($matches[2] === 'all_settings') {
$contents = XdebugDotOrg\Controller\Docs\SettingsController::all()->render();
} elseif ($matches[2] === 'all_functions') {
$contents = XdebugDotOrg\Controller\Docs\FunctionsController::all()->render();
} elseif ($matches[2] === 'all_related_content') {
$contents = XdebugDotOrg\Controller\Docs\RelatedContentController::all()->render();
} elseif ($matches[2] === 'remote') {
header("HTTP/1.1 301 Moved Permanently");
header('Location: /docs/step_debug');
exit();
} elseif (in_array($matches[2], $pages)) {
$contents = XdebugDotOrg\Controller\DocsController::section($matches[2], $language)->render();
} elseif (array_key_exists($matches[2], $redirectDocPages)) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: /docs/{$redirectDocPages[$matches[2]]}");
exit();
} elseif (in_array($matches[2], $redirectDevelopPages)) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: /docs/develop#{$matches[2]}");
exit();
} else {
header("HTTP/1.0 404 Not Found");
$contents = XdebugDotOrg\Controller\FourOhFourController::error()->render();
}
} else {
$contents = XdebugDotOrg\Controller\DocsController::index()->render();
}
} elseif (preg_match('/^\/announcements\/(\d\d\d\d-\d\d-\d\d)\/?/', (string) $requested_uri, $matches)) {
$contents = XdebugDotOrg\Controller\NewsController::item($matches[1])->render();
} elseif ($requested_uri === '/announcements') {
$contents = XdebugDotOrg\Controller\NewsController::items()->render();
} elseif ($requested_uri === '/license') {
$contents = XdebugDotOrg\Controller\HomeController::license('1.03')->render();
} elseif (preg_match('/^\/license\/((1\.01)|(1\.03))/', (string) $requested_uri, $matches)) {
$contents = XdebugDotOrg\Controller\HomeController::license($matches[1])->render();
} elseif ($requested_uri === '/support') {
$contents = XdebugDotOrg\Controller\SupportController::index()->render();
} elseif ($requested_uri === '/support-commercial') {
$contents = XdebugDotOrg\Controller\SupportController::commercial()->render();
} elseif ($requested_uri === '/funding') {
$contents = XdebugDotOrg\Controller\FundingController::index()->render();
} elseif (preg_match('@^/funding/(.*)/updates/(.*)@', (string) $requested_uri, $matches)) {
$contents = XdebugDotOrg\Controller\FundingController::project_update( $matches[1], $matches[2] )->render();
} elseif (preg_match('/^\/funding\/(.*)/', (string) $requested_uri, $matches)) {
$contents = XdebugDotOrg\Controller\FundingController::project( $matches[1] )->render();
} elseif ($requested_uri === '/reporting-bugs') {
$contents = XdebugDotOrg\Controller\SupportController::reporting_bugs()->render();
} elseif ($requested_uri === '/log') {
$contents = XdebugDotOrg\Controller\SupportController::log()->render();
} elseif ($requested_uri === '/ai') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: /");
exit();
} elseif (preg_match('/^\/support\/buy\/([-\w]+)\/(\w+)/', (string) $requested_uri, $matches)) {
$contents = XdebugDotOrg\Controller\StripeController::stripeResult( $matches[1], $matches[2] )->render();
} elseif (preg_match('/^\/support\/buy\/([-\w]+)/', (string) $requested_uri, $matches)) {
$result = XdebugDotOrg\Controller\StripeController::buyForm($matches[1]);
if ($result instanceof XdebugDotOrg\Core\HtmlResponse) {
$contents = $result->render();
} else if ($result instanceof XdebugDotOrg\Core\HtmlRedirect) {
header("HTTP/1.1 302 Found");
header("Location: " . $result->getURI());
exit();
}
} elseif ($requested_uri === '/wizard') {
$contents = XdebugDotOrg\Controller\WizardController::index()->render();
} elseif ($requested_uri === '/core2.css') {
header('Content-type: text/css');
die(file_get_contents('core2.css'));
} elseif (preg_match('@/(.*woff2)$@', (string) $requested_uri, $matches)) {
header('Content-Type: font/woff2');
die(file_get_contents($matches[1]));
} elseif (preg_match('@/(.*png)$@', (string) $requested_uri, $matches)) {
header('Content-Type: image/png');
die(file_get_contents($matches[1]));
} elseif (preg_match('@/(.*jpg)$@', (string) $requested_uri, $matches)) {
header('Content-Type: image/jpeg');
die(file_get_contents($matches[1]));
} elseif (preg_match('@/(.*svg)$@', (string) $requested_uri, $matches)) {
header('Content-Type: image/svg+xml');
die(file_get_contents($matches[1]));
} elseif (preg_match('@/(.*svg.gz)$@', (string) $requested_uri, $matches)) {
header('Content-Encoding: gzip');
header('Content-Type: image/svg+xml');
die(file_get_contents($matches[1]));
} elseif (preg_match('/^\/ci.json/', (string) $requested_uri, $matches)) {
XdebugDotOrg\Controller\CiController::summary()->render();
die();
} elseif (preg_match('/^\/ci(\?r=.*)?/', (string) $requested_uri, $matches)) {
$contents = XdebugDotOrg\Controller\CiController::index()->render();
} else {
header("HTTP/1.0 404 Not Found");
$contents = XdebugDotOrg\Controller\FourOhFourController::error()->render();
}
} catch (\XdebugDotOrg\PageNotFoundException $e) {
header("HTTP/1.0 404 Not Found");
$contents = XdebugDotOrg\Controller\FourOhFourController::error($e->getMessage())->render();
}
echo XdebugDotOrg\Controller\TemplateController::default($contents)->render();