0
0
This repository has been archived on 2020-08-03. You can view files and clone it, but cannot push or open issues or pull requests.
bryanpedini.it_old/index.php
Bryan Pedini 0f24e8322b
Improved speed and comprehensiveness
Edited templates location, removed unnecessary CSS and JS files, moved the onePageApp style and scripts into respective files, modified variable names for better comprehension.
TODO next: add comments to the code.
2019-01-17 13:26:20 +01:00

113 lines
5.5 KiB
PHP

<?php
$session_timeout_days = 1;
$session_timeout_hours = 0;
$session_timeout_minutes = 0;
$session_timeout_seconds = 0;
$session_timeout = ($session_timeout_days*86400)+($session_timeout_hours*3600)+($session_timeout_minutes*60)+$session_timeout_seconds;
session_set_cookie_params ( $session_timeout, "/" );
session_start ();
$section_page_titles = [
0 => '',
1 => 'Home',
2 => 'About myself',
3 => 'What I\'ve done so far',
4 => 'Who I would like to be',
5 => 'Webform contact'
];
if ( ! isset ( $_POST ['section'] ) ) {
$requested_section_title = 'Home';
}
else {
if ( ! in_array ( $_POST ['section'], array_keys( $section_page_titles ) ) ) {
$page_content_array = [
'status' => 400,
'errorCode' => 'Bad Request',
'errorText' => 'Requested section \'' . $_POST [ 'section' ] . '\' does not exist: do not attempt to compromise the website.',
];
$page_content_json = json_encode ( $page_content_array );
header('Content-Type: application/json');
echo $page_content_json;
exit;
}
$requested_section = $_POST ['section'];
if ( $requested_section == 0 ) {
if ( isset ( $_SESSION [ 'section' ] ) ) {
$requested_section = $_SESSION [ 'section' ];
}
else {
$requested_section = 1;
}
}
$_SESSION [ 'section' ] = $requested_section;
$requested_section_title = $section_page_titles [ $requested_section ];
$section_templates = [
1 => file_get_contents ( 'templates/home.phtml' ),
2 => file_get_contents ( 'templates/description.phtml' ),
3 => file_get_contents ( 'templates/projects.phtml' ),
4 => file_get_contents ( 'templates/ideas.phtml' ),
5 => file_get_contents ( 'templates/contact-form.phtml' ),
];
$page_content_array = [
'status' => 200,
'pageTitle' => $requested_section_title,
'html' => $section_templates [ $requested_section ]
];
$page_content_json = json_encode($page_content_array);
header('Content-Type: application/json');
echo $page_content_json;
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title id="page-title"><?=$requested_section_title?> | Bryan Pedini</title>
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<link href="css/clean-blog.min.css" rel="stylesheet">
<link href="css/hidden-scrollbar-GUI.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand" href="#" id="navbar-home">Bryan Pedini</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu <i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">About me</a>
<ul class="dropdown-menu">
<li class="dropdown-item"><a href="#" id="navbar-description">A brief description</a></li>
<li class="dropdown-divider"></li>
<li class="dropdown-item"><a href="#" id="navbar-work">My current projects</a></li>
<li class="dropdown-item"><a href="#" id="navbar-ideas">My future ideas</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Contact me</a>
<div class="dropdown-menu">
<a href="#" class="dropdown-item" id="navbar-contact-form">Web form</a>
<a href="#" class="dropdown-item" id="navbar-contact-email">Email</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
<div id="user-content">
</div>
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="js/clean-blog.min.js"></script>
<script src="js/onePageApp-sections-control.js"></script>
</body>
</html>