-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
67 lines (55 loc) · 1.7 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
<?php
header("Access-Control-Allow-Origin: *");
session_start();
require_once 'lib/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
require_once 'lib/Smarty/Smarty.class.php';
require_once 'lib/Slim-Views/Smarty.php';
require_once 'lib/rb.php';
require_once 'config.php';
require_once 'lib/db_func.php';
require_once 'lib/departures.php';
require_once 'lib/func.php';
$lang = isset($_COOKIE['lang'])?$_COOKIE['lang']:'en';
$lang_file = "lang/lang.$lang.php";
if(file_exists($lang_file)) {
require_once $lang_file;
} else {
require_once "lang/lang.en.php";
}
// application configuration
$app = new \Slim\Slim(array(
'view' => new \Slim\Views\Smarty(),
'debug' => true,
'templates.path' => './templates'
));
date_default_timezone_set(TIMEZONE);
$req = $app->getInstance()->request();
$app->baseUrl = $req->getUrl() . $req->getRootUri();
unset($req);
$app->lang = check_cookie('lang','pl');
$app->style = check_cookie('style','2');
// templates engine configuration
$view = $app->view();
$view->parserDirectory = dirname(__FILE__) . '/templates';
$view->parserCompileDirectory = $view->parserDirectory . '/compile';
$view->parserCacheDirectory = $view->parserDirectory . '/cache';
$view->parserExtensions = array(
dirname(__FILE__) . '/lib/Slim-Views/SmartyPlugins'
);
// database connection configuration
switch(DB_TYPE) {
case 'sqlite':
$file_path = dirname(__FILE__).'/db/'.DB_FILE;
if(!file_exists($file_path)) {
touch($file_path);
}
R::setup('sqlite:'.$file_path);
break;
case 'mysql':
default:
R::setup('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS);
break;
}
require_once 'router/Init.php';
$app->run();