-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
74 lines (55 loc) · 1.58 KB
/
Copy pathindex.php
File metadata and controls
74 lines (55 loc) · 1.58 KB
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
<?php
/**
* Created by PhpStorm.
* User: vincent
* Date: 15/10/2015
* Time: 15:38
*/
error_reporting(E_ALL);
ini_set("display errors",1);
//require_once('tools/autoloader.php');
require_once('vendor/autoload.php');
$sitePrefix = '/Ex2/';
Authenticator::check();
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem(__DIR__.'/templates');
$twigConfig = array(
'cache' => false, /*__DIR__.'/cache',*/
'debug' => true,
);
$twig = new Twig_Environment($loader, $twigConfig);
$twig->addExtension(new Twig_Extension_Debug());
$req = str_replace($sitePrefix, '', $_SERVER['REQUEST_URI']);
if($req==""){
$req="home";
}
$req = $req . '.twig';
$template = $twig->loadTemplate($req);
Registrator::check();
$data = Authenticator::getUserData();
$data = Registrator::getRegData();
$data['blogposts'] = BlogPostReader::ReadPosts();
$data += ContactInfo::getInfo();
if (!Authenticator::isAuthenticated() and !Registrator::isRegistered()) {
$data = array_merge($data, [
'fullName' => 'Anonymous',
'loginLink' => 'login',
'loginLabel' => 'Login',
"currentYear" => date("Y"),
]);
} elseif (!Authenticator::isAuthenticated() and Registrator::isRegistered()) {
$data = array_merge($data, [
'fullName' => 'Anonymous',
'loginLink' => 'login',
'loginLabel' => 'Login',
"currentYear" => date("Y"),
]);
} else {
$data = array_merge($data, [
'loginLink' => 'logout',
'loginLabel' => 'Logout',
"currentYear" => date("Y"),
]);
}
$output = $template->render($data);
print $output;