-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·46 lines (33 loc) · 958 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
define( 'DEVEL', isset( $_ENV['dev'] ) );
ini_set( 'display_errors', DEVEL );
define( 'REQUEST_URI', parse_url( $_SERVER['REQUEST_URI'] )['path'] );
define( 'BASEDIR', __DIR__ );
define( 'AJAX', isset( $_GET['ajax'] ) );
ob_start();
require 'lib/lang.php';
global $lang;
$lang = new Lang;
// Load lanaguage info from file
$langs = parse_ini_file( 'lang.ini', true );
foreach ( $langs as $k => $val ) {
is_array( $val )? Lang::add( $k, $val ) : Lang::addGlobal( $k, $val );
}
require 'lib/router.php';
global $router;
$router = new Router;
// Example to change language - all URLs beggining with /pt are set to portuguese
$router->use( '/pt*', function() {
global $lang;
$lang( 'pt' );
} );
require 'routes.php';
// Catch all requests to handle 404
$router->use( function() {
http_response_code( 404 );
global $lang;
define( 'PAGE_TITLE' , $lang->e404Title );
require 'views/404.php';
} );
$router->respond();
ob_end_flush();