personal-website/docs/common/header.php

85 lines
1.9 KiB
PHP
Executable file

<!DOCTYPE html>
<?php
// Include config file
include_once("config.php");
// Include utils to have access to custom classes
include_once("utils.php");
// Start session
session_start();
// PDO Mysql connection object
$conn = null;
attempt_sql_connect();
/** Attempt to connect to sql database
*/
function attempt_sql_connect() {
// access global $conn
global $conn;
// Load the global login constants
$sql_hostname = SQL_HOSTNAME;
$sql_database = SQL_DATABASE;
$sql_username = SQL_USERNAME;
$sql_password = SQL_PASSWORD;
try {
//Try connecting to the SQL database
$conn = new PDO("mysql:host=$sql_hostname;dbname=$sql_database",
$sql_username, $sql_password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
$conn = null;
return;
}
}
/**
* Start the html document, set headers, begin body and display the default
* navbar.
* <html><body> nad <main> tags will be left open, to close them
* in the default way include footer.php
* This should be the first function to write any text outside of debugging
* purposes.
*/
function display_header($pageTitle) {
printf("
<html lang=\"en\">
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
<link rel=\"icon\" href=\"http://www.zdenekborovec-dev.cz/favicon.ico\">
<link rel=\"stylesheet\"
href=\"http://assets.zdenekborovec-dev.cz/common/styles.css?TIMESTAMP\">
<title>%s</title>
</head>
<body>
<main>
<div id=\"header\">
<h1> Zdenek Borovec Home Page </h1>
<ul>
<li>
<a href=\"http://www.zdenekborovec-dev.cz\">
About
</a>
</li>
<li>
<a href=\"http://www.zdenekborovec-dev.cz/blog\">
Blog
</a>
</li>
<li>
Gallery
</li>
<li>
<a href=\"http://www.zdenekborovec-dev.cz/random\">
Random Tools
</a>
</li>
</ul>
</div>", $pageTitle);
}
?>