-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
76 lines (59 loc) · 1.82 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
<?php
include('init.php');
// Initialize silex
$app = new Silex\Application();
// Debugging settings
$debug_remotehosts = array(
"/^192\.168\.42\./"
);
foreach($debug_remotehosts as $host)
{
if(preg_match($host, $_SERVER['REMOTE_ADDR'])===1)
{
$app['debug'] = true;
break;
}
}
// Populate global settings
$settings = \JsonConfig::instance()->getSettings();
$uitheme = "-".$settings['uitheme'];
if($uitheme=="-classic")
{
$uitheme = "";
}
$search = array("\"", "\n", "\r");
$replace = array("\\\"", "\\n", "\\r");
$varlist = array();
foreach($settings as $key => $value) {
if(is_bool($value)) {
$varlist[] = " '".$key."': ".($value ? "true" : "false");
} elseif(is_int($value)) {
$varlist[] = " '".$key."': ".$value;
} else {
$varlist[] = " '".$key."': \"".str_replace($search, $replace, $value)."\"";
}
}
$jssettings = "var Settings = {\n".implode(",\n", $varlist)."\n };\n";
$app['webshelf'] = array(
"extjslib" => "ext/ext-all".($app['debug']===true ? "-debug" : "").".js",
"dirseparator" => addslashes(DIRECTORY_SEPARATOR),
"uitheme" => $uitheme,
"jssettings" => $jssettings,
"release_version" => WEBSHELF_VERSION,
"release_date" => WEBSHELF_DATE,
);
unset($settings, $uitheme, $search, $replace, $varlist, $jssettings);
// Load template engine
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => ROOT.'views',
));
// Template functions
$app['twig']->addFunction('baseFolder', new Twig_Function_Function('\FsTools\getBaseFolder'));
$app['twig']->addFunction('getSetting', new Twig_Function_Function('\JsonConfig::instance()->getSetting'));
// Load routing files
$routes = glob(ROOT."routes/route.*.php");
foreach($routes as $route) {
include($route);
}
// Run application
$app->run();