summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorKamil Kaminski <kylek389@gmail.com>2014-12-14 04:39:17 -0600
committerKamil Kaminski <kylek389@gmail.com>2014-12-14 04:43:57 -0600
commitf0de7af14312368a11014befa428ff91bbebff76 (patch)
tree72f0aeb507a8bb1a8721ed18906aefc723e811c9 /index.php
downloadfracturedcms-f0de7af14312368a11014befa428ff91bbebff76.tar.gz
fracturedcms-f0de7af14312368a11014befa428ff91bbebff76.tar.bz2
fracturedcms-f0de7af14312368a11014befa428ff91bbebff76.zip
fracturedcms, a flat file cms, fork of wondercms
- minor code refactoring - fix improper navigation/footer link generation when current page is ?login or ?logout - include local jquery
Diffstat (limited to 'index.php')
-rw-r--r--index.php94
1 files changed, 94 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..3ee6317
--- /dev/null
+++ b/index.php
@@ -0,0 +1,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'] = '&copy;' . 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();
+?>