From f0de7af14312368a11014befa428ff91bbebff76 Mon Sep 17 00:00:00 2001 From: Kamil Kaminski Date: Sun, 14 Dec 2014 04:39:17 -0600 Subject: 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 --- index.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 index.php (limited to 'index.php') diff --git a/index.php b/index.php new file mode 100644 index 0000000..3ee6317 --- /dev/null +++ b/index.php @@ -0,0 +1,94 @@ + + * - $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'] = "

Congratulations! Your website is now powered by FracturedCMS.


\nLogin to the admin panel with the 'Login' link in the footer. The password is admin.
\nChange the password as soon as possible.

\n\nClick on the content to edit and click outside to save it."; +$d['page']['example'] = "This is an example page.

\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 " . str_replace('-', ' ', $rp) . " created.

\n\nClick here to start editing!"; +$d['new_page']['visitor'] = "Sorry, but " . str_replace('-', ' ', $rp) . " doesn't exist. :("; +$d['default']['content'] = "Click to edit!"; +$c['theme_name'] = "blue"; +$c['menu'] = "Home
\nExample"; +$c['title'] = 'Website title'; +$c['subside'] = "

ABOUT YOUR WEBSITE


\nYour photo, website description, contact information, mini map or anything else.

\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()) ? "Logout" : "Login"; + 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(); +?> -- cgit v1.2.3