-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
129 lines (81 loc) · 2.08 KB
/
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
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
<?php
//
// Configure the environment
//
$appMode = getenv( 'APPMODE' );
if( ! defined( 'ENT_SUBSTITUTE' ) ) {
define( 'ENT_SUBSTITUTE', 0 );
}
//
// Load the Fat Free Framework
//
$f3 = require( 'lib/php/fatfree/base.php' );
//
// Load the configuration
//
$f3->config( 'app/_config.ini' );
//
// Load the routes
//
$f3->config( 'app/_routes.ini' );
//
// Load the AJAX API endpoints
//
$f3->config( 'app/_ajax.ini' );
//
// Define some usefull constants taking values
// set in the configuration files
//
define( 'ANALYTICS_CODE', $f3->get( 'ANALYTICS_CODE' ) );
define( 'SALT', $f3->get( 'SALT' ) );
define( 'APP_NAME', $f3->get( 'APP_NAME' ) );
define( 'APP_DOMAIN', $f3->get( 'APP_DOMAIN' ) );
define( 'APP_DIR', __DIR__ );
define( 'WEB_DIR', $f3->get( 'WEB_DIR' ) );
define( 'AUTHOR', $f3->get( 'AUTHOR' ) );
define( 'DEBUG', ( ! empty( $appMode )
? ( $appMode == 'development'
? true
: false )
: false ) );
//
// Set error reporting
//
if( DEBUG ) {
// Turn on error reporting in DEBUG mode
error_reporting( E_ALL & ~E_NOTICE );
ini_set( 'display_errors', 'On' );
} else {
// ...otherwise SHUT UP!
error_reporting( 0 );
ini_set( 'display_errors', 'Off' );
}
//
// What should we do in case of error???
//
if( ! DEBUG ) {
//
// Redirect to the homepage only if in production
//
$f3->set(
'ONERROR',
function( $f3 ) {
//
// Reroute to the homepage if it's not an AJAX request
//
if( ! $f3->get( 'AJAX' ) ) {
$f3->reroute( '/' );
}
}
);
}
//
// Enable caching ONLY in production
//
$cache = \Cache::instance();
$isCacheActive = ( ! DEBUG ? true : false );
$cache->load( $isCacheActive );
//
// Let's begin the rock'n'roll
//
$f3->run();