-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·62 lines (50 loc) · 1.78 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
<?php
// get config file
$config = parse_ini_file('conf/config.ini', TRUE);
// check for ssl
if($_SERVER['HTTPS'] != "on" && $config['ssl'] == 1){
$redirect = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
// remove trailing slash on end of url
if(preg_match('/\/$/',$_SERVER['REQUEST_URI']) && !$redirect){
$redirect = ($config['ssl'] == 1) ? "https://" : "http://";
$redirect .= $_SERVER['HTTP_HOST'].preg_replace('/\/$/', '', $_SERVER['REQUEST_URI']);
if($config['link'] == $redirect){
unset($redirect);
}
}
if($redirect){
header("HTTP/1.1 301 Moved Permanently");
header("Location: $redirect");
}
// build css if there is a newer less version
require "classes/less/lessc.inc.php";
$less = new lessc;
$less->setFormatter("compressed");
try {
$less->checkedCompile("css/less/wuza.less", "css/wuza.css");
} catch (exception $e) {
echo '<div class="text-danger bg-danger small-padding">fatal error: ' . $e->getMessage() . '</div>';
}
// allow GZIP Compression
ob_start("ob_gzhandler");
session_start();
// incude classes
include('classes/controller.php');
include('classes/model.php');
include('classes/view.php');
include('classes/uri.php');
// $_SESSION, $_GET and $_POST - no $_COOKIE but config values
$request = array_merge($_SESSION, $_GET, $_POST, $config);
// add values from fancy url
$url=new URI("wuza");
$request["view"] = $url->shouldShow404("view") ? "404" : strtolower($url->getVar("view"));
// allowed url slash vars - but prefer get params if there are some
foreach(array('file') as $vari) {
$request[$vari] = $request[$vari] ?: $url->getVar($vari);
}
// create controller
$controller = new Controller($request);
echo $controller->display();
$controller->update_session();
?>