-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
85 lines (84 loc) · 2.8 KB
/
index.php
File metadata and controls
85 lines (84 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/* Page Name detection */
$pageName = 'index';
if (isset($_GET['page']) && strlen($_GET['page'])) {
$pageName=basename($_GET['page']);
}
/* Headers */
header('Content-Type: text/html; charset=utf-8');
/* Check For Page Existance */
$contentFile=dirname(__FILE__).'/content/'.$pageName;
$existsPHP = file_exists($contentFile.'.php');
$existsTxt = false;
if (!$existsPHP) {
$existsTxt = file_exists($contentFile.'.txt');
}
if (!$existsTxt && !$existsPHP) {
// 404
header('HTTP/1.1 404 Page Not Found');
include (dirname(__FILE__).'/errors/404.php');
die();
}
/* Grab Config */
$config = $headVariables = $pageMenu = array();
include (__DIR__.'/config.default.php');
if (file_exists(__DIR__.'/config.php')) {
include (__DIR__.'/config.php');
}
/* Grab Metas */
$metaFile=$contentFile.'.meta.php';
if ($existsPHP) {
$mode = 'PHP';
$contentFile .= '.php';
} else {
$mode = 'Markdown';
$contentFile .= '.txt';
}
if (file_exists($metaFile)) {
include($metaFile);
$lastModified = max (filemtime($metaFile), filemtime($contentFile));
} else {
$lastModified = filemtime($contentFile);
}
header('Last-Modified: '.date(DATE_RFC1123, $lastModified));
?>
<!DOCTYPE html>
<html lang="<?php echo $headVariables['lang'];?>">
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title><?php echo htmlentities( $headVariables['title'], ENT_QUOTES, 'UTF-8');?></title>
<!-- CSS / JS -->
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="css/<?php echo $config['stylesheet']; ?>.css" />
<!-- Metas -->
<meta name="description" content="<?php echo htmlentities( $headVariables['description'], ENT_QUOTES, 'UTF-8');?>">
<meta name="author" content="<?php echo htmlentities( $headVariables['author'], ENT_QUOTES, 'UTF-8');?>">
<meta name="keywords" content="<?php
$keywords=array();
foreach ($headVariables['keywords'] as $v) {
$keywords[]=htmlentities( $v, ENT_QUOTES, 'UTF-8');
}
echo implode(', ', $keywords);
?>">
<!-- Favicon, canonical, ... -->
<link rel="canonical" href="http://<?php echo $config['website']?>/<?php echo $pageName?>">
<link rel="icon" type="image/ico" href="/favicon.ico" />
</head>
<body>
<?php include(dirname(__FILE__).'/includes/header.php'); ?>
<div id="page">
<?php
if ($mode == 'PHP') {
include($contentFile);
} else {
include(__DIR__.'/libs/php-markdown/markdown.php');
echo Markdown(file_get_contents($contentFile));
}
?>
</div>
<?php include(dirname(__FILE__).'/includes/footer.php'); ?>
</body>
</html>