-
Notifications
You must be signed in to change notification settings - Fork 158
/
index.php
46 lines (39 loc) · 1021 Bytes
/
index.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* This is the main front-end entry point for TestSwarm.
*
* All HTML-based views served to web browsers start here.
* The recommended configuration will have web requests
* rewritten from a path to a query string calling index.php
*
* @author Timo Tijhof
* @since 0.1.0
* @package TestSwarm
*/
// Valid entry point
define( 'SWARM_ENTRY', 'INDEX' );
require_once __DIR__ . '/inc/init.php';
session_start();
$pageObj = $swarmContext->getRequest()->getPageInstance();
if ( $swarmContext->getRequest()->getHeader( 'X-Swarm-Partial' ) ) {
header( 'X-Swarm-Partial: 1' );
if ( $pageObj instanceof Page ) {
$pageObj->outputPartial();
} else {
Page::httpStatusHeader( 404 );
}
exit;
}
if ( $pageObj instanceof Page ) {
try {
$pageObj->output();
} catch ( Exception $e ) {
$pageObj = Error500Page::newFromContext( $swarmContext );
$pageObj->setExceptionObj( $e );
$pageObj->output();
}
} else {
$pageObj = Error404Page::newFromContext( $swarmContext );
$pageObj->output();
}
exit;