|
|
@@ -17,25 +17,26 @@ require __DIR__ . '/../vendor/autoload.php'; |
|
|
|
|
|
|
|
$twig = new Twig('../templates'); |
|
|
|
|
|
|
|
|
|
|
|
addNavbar(); |
|
|
|
|
|
|
|
$app = AppFactory::create(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//$db = new DB(); |
|
|
|
ini_set('display_errors', 'Off'); |
|
|
|
function addNavbar($response) |
|
|
|
function addNavbar() |
|
|
|
{ |
|
|
|
global $twig; |
|
|
|
|
|
|
|
$response->getBody()->write("<html><head></head><body>"); |
|
|
|
if (isset($_SESSION['username'])) { |
|
|
|
$response->getBody()->write('<div><a href="/">Index</a> | <a href="/blog/create">Create Blog</a> | <a href="/logout">Logout</a></div>'); |
|
|
|
} else { |
|
|
|
$response->getBody()->write('<div><a href="/">Index</a> | <a href="/login">Login</a></div>'); |
|
|
|
} |
|
|
|
return; |
|
|
|
$urls = [ |
|
|
|
["link" => "https://www.google.be", "name" => "Google"], |
|
|
|
["link" => "https://www.facebook.com", "name" => "Facebook"], |
|
|
|
["link" => "https://www.twiter.com", "name" => "Twitter"] |
|
|
|
]; |
|
|
|
$twig->addBlockVariable('navbar', ['urls' => $urls]); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addFooter($response) |
|
|
|
{ |
|
|
|
$response->getBody()->write('<div>Privacy statement | Cookie Policy | Contact</div>'); |
|
|
@@ -60,7 +61,9 @@ $app->get('/', function (Request $request, Response $response, array $args) { |
|
|
|
"key" => "value", |
|
|
|
'key2' => ["val1", "val2", "val3"], |
|
|
|
"key3" => ["x1" => "y1", "x2" => "y2"], |
|
|
|
"loggedIn" => isset($_SESSION['username']) |
|
|
|
"loggedIn" => isset($_SESSION['username']), |
|
|
|
"content" => "Dit is de main body met info" |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
global $twig; |