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
86
87
88
89
90
91
92
93
94
|
<?php
/**
* FracturedCMS, fork of WonderCMS
*
* - $c[] is the main config array
* - master foreach loop this array and use its key name to load a file at files/<key>
* - $d[] array is used to save a copy of default values from $c[]
* - files/menu file is used nav list, each entry in there should match to that of slug
* - when ?login is called, the 'case 'loggedin':' calls login_form() and prints out a form
* - .htaccess rewrites urls in such way that /foo will get called as ?page=foo with exepction of ?login and ?logout
*
*/
require 'lib/fraktured.php';
ob_start();
session_start();
$rp = isset($_REQUEST['page']) ? $_REQUEST['page'] : ''; /* request page e.g. ?page=hello */
$hostname = '//' . $_SERVER['HTTP_HOST'] . str_replace($rp, '', $_SERVER['REQUEST_URI']); /* strchr($hostname, '?', TRUE) might be needed in other parts of code that generate links */
$c['password'] = 'admin';
$c['loggedin'] = false;
$c['page'] = 'home';
$d['page']['home'] = "<h3>Congratulations! Your website is now powered by FracturedCMS.</h3><br />\nLogin to the admin panel with the 'Login' link in the footer. The password is admin.<br />\nChange the password as soon as possible.<br /><br />\n\nClick on the content to edit and click outside to save it.";
$d['page']['example'] = "This is an example page.<br /><br />\n\nTo add a new one, click on the existing pages (in the admin panel) and enter a new one below the others.";
$d['new_page']['admin'] = "Page <b>" . str_replace('-', ' ', $rp) . "</b> created.<br /><br />\n\nClick here to start editing!";
$d['new_page']['visitor'] = "Sorry, but <b>" . str_replace('-', ' ', $rp) . "</b> doesn't exist. :(";
$d['default']['content'] = "Click to edit!";
$c['theme_name'] = "blue";
$c['menu'] = "Home<br />\nExample";
$c['title'] = 'Website title';
$c['subside'] = "<h3>ABOUT YOUR WEBSITE</h3><br />\nYour photo, website description, contact information, mini map or anything else.<br /><br />\n\n This content is static and is visible on all pages.";
$c['description'] = 'Your website description.';
$c['keywords'] = 'enter, your website, keywords';
$c['copyright'] = '©' . date('Y') . ' Foobar';
$sig = "Powered by FracturedCMS";
$hook['admin-richText'] = "rte.php";
foreach ($c as $key => $val) {
if ($key == 'content')
continue;
$fval = @file_get_contents('files/' . $key); /* for each key attempt to load associated file */
$d['default'][$key] = $c[$key]; /* save a copy of default values */
if ($fval)
$c[$key] = $fval; /* if file exists at files/*, use that instead of predefined default above */
switch ($key) {
case 'password':
if (!$fval)
$c[$key] = save_password($val); /* will save md5'ed 'admin' files/password, will happen initially */
break;
case 'loggedin':
if (isset($_SESSION['l']) and $_SESSION['l'] == $c['password'])
$c[$key] = true;
if (isset($_REQUEST['logout'])) {
session_destroy();
header('Location: ./');
exit;
}
if (isset($_REQUEST['login'])) {
if (is_loggedin())
header('Location: ./');
login_form();
}
$lstatus = (is_loggedin()) ? "<a href='" . strchr($hostname, '?', TRUE) . "?logout'>Logout</a>" : "<a href='" . strchr($hostname, '?', TRUE) . "?login'>Login</a>";
break;
case 'page':
if ($rp) /* if there's a request page e.g. ?page=hello */
$c[$key] = $rp;
$c[$key] = get_slug($c[$key]);
if (isset($_REQUEST['login']))
continue;
$c['content'] = @file_get_contents("files/" . $c[$key]);
if (!$c['content']) {
if (!isset($d['page'][$c[$key]])) {
header('HTTP/1.1 404 Not Found');
$c['content'] = (is_loggedin()) ? $d['new_page']['admin'] : $c['content'] = $d['new_page']['visitor'];
} else {
$c['content'] = $d['page'][$c[$key]];
}
}
break;
default:
break;
}
}
load_plugins();
require("themes/" . $c['theme_name'] . "/theme.php");
ob_end_flush();
?>
|