* - $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 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'] = "

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(); ?>