simple_blog/common/header.php

49 lines
2.1 KiB
PHP

<!DOCTYPE html>
<html lang="en-US">
<?php
//Sets the page title based on the name of the current directory
function Title() {//Needs cleanup.
//~ $new_title = $_SERVER['REQUEST_URI'];
//~ $new_title = preg_replace("/^^\//i", "", $new_title);
//~ $new_title = preg_replace("/\//i", "", $new_title);
//~ $page_title = $_SERVER['REQUEST_URI'];
//~ $page_title = preg_replace("/^(.*)\//i", "", $page_title);
$page_title = basename($_SERVER['SCRIPT_FILENAME'], '.php');
//~ echo($page_title);
if(strtolower($page_title) == 'index'){
parse_str($_SERVER['REQUEST_URI'], $page_uri);
$page_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
//~ echo($page_path);
//~ $folder_name = sizeof($page_path);
$folder_name = explode("/", trim($page_path, "/"));
$page_title = $folder_name[(sizeof($folder_name) - 1)];
} elseif(strtolower($page_title) == 'homepage'){
$page_title = 'Homepage';
}
$page_title = str_replace('_', ' ', $page_title);
$page_title = ucwords($page_title);
return $page_title;
}
?>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<?php//If a tags file is present parse it and add any tags found to the renderd page's metadata.
if(file_exists('tags')){
$tag_data_raw = fopen('tags',"r");
$tag_data = fread($tag_data_raw, filesize('tags'));
$tag_data = str_replace("\n", "", $tag_data);
echo "<meta name=\"keywords\" content=\"" . $tag_data . "\"/>\n";
fclose($tag_data_raw);
}
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title><?php $title = Title(); echo $title;?></title>
<link href="/common/styles.css?v=<?php echo date('his'); ?>" type="text/css" rel="stylesheet"/>
<link href="/common/jmenu.css?v=<?php echo date('his'); ?>" type="text/css" rel="stylesheet"/>
<link href="/common/print.css?v=<?php echo date('his'); ?>" type="text/css" media="print" rel="stylesheet"/>
<script type="text/javascript" src="/common/js/page_format.js?v=<?php echo date('his'); ?>"></script>
</head>
<body lang="en-US">
<div class="body" id="body">