summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php193
1 files changed, 99 insertions, 94 deletions
diff --git a/index.php b/index.php
index 3ee6317..5ef4c92 100644
--- a/index.php
+++ b/index.php
@@ -1,94 +1,99 @@
-<?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();
-?>
+<?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
+ * - appending markup to $hook[] cause it to be included in <head> section
+ * - to load plugins the code includes plugins/%dir/index.php files
+ * - new pages can be added by logging in, going to Settings, and adding new entry for Navigation
+ * - $rp variable aka router stands for page request and its slug is that of a fname, when set, it will be used to load content of a page from disk
+ *
+ */
+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();
+?>
+