Commit
This commit is contained in:
parent
0eadd8977d
commit
d6baa603dc
14
example.php
14
example.php
@ -1,15 +1,17 @@
|
||||
<?php
|
||||
// This file should serve as an example showing all the current implemented features.
|
||||
// This file should serve as an example showing current implemented features
|
||||
|
||||
// Parameters that will be used in the template file
|
||||
$templateParameters["render"] = true; // Whether or not to render the template
|
||||
$templateParameters["title"] = "Eksempel side"; // Sets the page title
|
||||
// Parameters that will be used in the template files
|
||||
// For more options and explanations, check the 'templateParameters.php' file from the 'template' folder
|
||||
$templateParameters["title"] = "Eksempel side";
|
||||
|
||||
// Include the top of page
|
||||
include_once("template/_header.php");
|
||||
?>
|
||||
<h1>Eksempel side</h1>
|
||||
<p>Dette er en eksempel side</p>
|
||||
|
||||
<h1>Eksempel side.</h1>
|
||||
<p>Dette er en eksempel side</p>
|
||||
|
||||
<?php
|
||||
// Include the rest of the page
|
||||
include_once("template/_footer.php");
|
||||
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
// Parameters that will be used in the template file
|
||||
$templateParameters["title"] = "Forside";
|
||||
|
||||
// Include the top of page
|
||||
include_once("template/_header.php");
|
||||
?>
|
||||
|
||||
@ -12,6 +10,5 @@ include_once("template/_header.php");
|
||||
<a href="img/stafett.jpg"><img src="img/stafett-cropped.jpg" alt="Bilde av folk som løper på banen"></a>
|
||||
|
||||
<?php
|
||||
// Include the rest of the page
|
||||
include_once("template/_footer.php");
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
if ((isset($_POST['username'])) && (isset($_POST['password']))) {
|
||||
if (($_POST['username'] === 'VG3') && ($_POST['password'] === '3ELDEA')) {
|
||||
session_start();
|
||||
$_SESSION['logged_in'] = true;
|
||||
$_SESSION['logged_in'] = TRUE;
|
||||
$_SESSION['username'] = $_POST['username'];
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
@ -13,10 +13,8 @@ if ((isset($_POST['username'])) && (isset($_POST['password']))) {
|
||||
}
|
||||
}
|
||||
|
||||
// Parameters that will be used in the template file
|
||||
$templateParameters["title"] = "Logg inn"; // Sets the page title
|
||||
$templateParameters["title"] = "Logg inn";
|
||||
|
||||
// Include the top of page
|
||||
include_once("template/_header.php");
|
||||
?>
|
||||
<h1>Logg inn</h1>
|
||||
@ -27,7 +25,6 @@ include_once("template/_header.php");
|
||||
?>
|
||||
|
||||
<form method="post">
|
||||
<!-- Hvorfor bry seg om CSRF? -->
|
||||
<label for="username">Brukernavn:</label>
|
||||
<br>
|
||||
<input type="text" id="username" name="username">
|
||||
@ -41,6 +38,5 @@ include_once("template/_header.php");
|
||||
</form>
|
||||
|
||||
<?php
|
||||
// Include the rest of the page
|
||||
include_once("template/_footer.php");
|
||||
?>
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
if ($templateParameters["render"] === false) {
|
||||
if(!isset($_SESSION)) session_start();
|
||||
include_once("templateParameters.php");
|
||||
|
||||
if ($templateParameters["render"] === FALSE) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
if(!isset($_SESSION)) session_start();
|
||||
include_once("templateParameters.php");
|
||||
|
||||
// When including this template from other directories, using relative url paths is not sufficient. Therefore we use a prefix to ensure that the correct url path is given.
|
||||
// Typically we put this before any local urls, such as navigation, icons etc to ensure that they use the correct path.
|
||||
@ -8,7 +9,7 @@ if ((strlen($templateUrlPrefix) > 1)) {
|
||||
$templateUrlPrefix = htmlspecialchars($templateUrlPrefix . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if ($templateParameters["render"] === false) {
|
||||
if ($templateParameters["render"] === FALSE) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
@ -26,7 +27,6 @@ if ($templateParameters["render"] === false) {
|
||||
|
||||
<div class="navbar-top-head">
|
||||
<div class="navbar-top-inner">
|
||||
<!-- Jalla løsning -->
|
||||
<a href="<?=$templateUrlPrefix;?>" style="display: block; max-width: max-content;">
|
||||
<img style="display: block; height: 32px;" src="<?=$templateUrlPrefix;?>img/cropped-kf-propell-ikon-32x32.png" alt="">
|
||||
<div style="margin-left: 44px;">
|
||||
@ -37,13 +37,15 @@ if ($templateParameters["render"] === false) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($_SESSION['logged_in'] === true) : ?>
|
||||
<?php if ((isset($_SESSION['logged_in'])) && ($_SESSION['logged_in'] === TRUE)) : ?>
|
||||
|
||||
<div class="login-statusbar">
|
||||
<div class="login-statusbar-inner">
|
||||
<a href="<?=$templateUrlPrefix;?>logout.php" style="float: right;">Logg ut</a>
|
||||
<div>Inlogget som: <?=htmlspecialchars($_SESSION['username'])?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="grid-container">
|
||||
|
11
template/templateParameters.php
Normal file
11
template/templateParameters.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
// Default parameter values if none is defined
|
||||
$defaultTemplateParameters = [
|
||||
"title" => "Document", // Set page title
|
||||
"render" => TRUE, // Whether or not to render the template
|
||||
];
|
||||
|
||||
// Initialize default parameter values
|
||||
foreach(array_keys($defaultTemplateParameters) as $key) {
|
||||
if (!isset($templateParameters[$key])) $templateParameters[$key] = $defaultTemplateParameters[$key];
|
||||
}
|
Reference in New Issue
Block a user