summaryrefslogtreecommitdiffstats
path: root/lib/fraktured.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fraktured.php')
-rw-r--r--lib/fraktured.php127
1 files changed, 127 insertions, 0 deletions
diff --git a/lib/fraktured.php b/lib/fraktured.php
new file mode 100644
index 0000000..40a8af5
--- /dev/null
+++ b/lib/fraktured.php
@@ -0,0 +1,127 @@
+<?php
+
+function load_plugins()
+{
+ global $hook, $c;
+ $cwd = getcwd();
+ if (chdir("./plugins/")) {
+ $dirs = glob('*', GLOB_ONLYDIR);
+ if (is_array($dirs))
+ foreach ($dirs as $dir) {
+ require_once($cwd . '/plugins/' . $dir . '/index.php');
+ }
+ }
+ chdir($cwd);
+ $hook['admin-head'][] = "<script type='text/javascript' src='./js/editinplace.php?hook=" . $hook['admin-richText'] . "'></script>";
+}
+
+function get_slug($p)
+{
+ $p = strip_tags($p);
+ preg_match_all('/([a-z0-9A-Z-_]+)/', $p, $matches);
+ $matches = array_map('strtolower', $matches[0]);
+ $slug = implode('-', $matches);
+ return $slug;
+}
+
+function is_loggedin()
+{
+ global $c;
+ return $c['loggedin'];
+}
+
+function edit_tags()
+{
+ global $hook;
+ if (!is_loggedin() && !isset($_REQUEST['login']))
+ return;
+ foreach ($hook['admin-head'] as $o) {
+ echo "\t" . $o . "\n";
+ }
+}
+
+function content($id, $content)
+{
+ global $d;
+ echo (is_loggedin()) ? "<span title='" . $d['default']['content'] . "' id='" . $id . "' class='editText richText'>" . $content . "</span>" : $content;
+}
+
+function menu($stags, $etags)
+{
+ global $c, $hostname;
+ $mlist = explode('<br />', $c['menu']);
+ for ($i = 0; $i < count($mlist); $i++) {
+ $page = get_slug($mlist[$i]);
+ if (!$page)
+ continue;
+ echo $stags . " href='" . strchr($hostname, '?', TRUE) . $page . "'>" . str_replace('-', ' ', $page) . " " . $etags . " \n";
+ }
+}
+
+function login_form()
+{
+ global $c, $msg;
+ $msg = '';
+ if (isset($_POST['sub'])) login();
+ $c['content'] = "<form action='' method='POST'>
+ Password <input type='password' name='password'>
+ <input type='submit' name='login' value='Login'> $msg
+ <br /><br /><b class='toggle'>Change password</b>
+ <div class='hide'><br />Type your old password above and your new one below.<br />
+ New Password <input type='password' name='new'>
+ <input type='submit' name='login' value='Change'>
+ <input type='hidden' name='sub' value='sub'>
+ </div>
+ </form>";
+}
+
+function login()
+{
+ global $c, $msg;
+ if (md5($_POST['password']) <> $c['password']) {
+ $msg = "Wrong Password";
+ return;
+ }
+ if ($_POST['new']) {
+ save_password($_POST['new']);
+ $msg = 'Password changed';
+ return;
+ }
+ $_SESSION['l'] = $c['password'];
+ header('Location: ./');
+ exit;
+}
+
+function save_password($p)
+{
+ $file = @fopen('files/password', 'w');
+ if (!$file) {
+ echo "Error opening password. Set correct permissions (644) to the password file.";
+ exit;
+ }
+ fwrite($file, md5($p));
+ fclose($file);
+ return md5($p);
+}
+
+function settings()
+{
+ global $c, $d;
+ echo "<div class='settings'>
+ <h3 class='toggle'>↕ Settings ↕</h3>
+ <div class='hide'>
+ <div class='change border'><b>Theme</b>&nbsp;<span id='theme_name'><select name='theme_name' onchange='fieldSave(\"theme_name\",this.value);'>";
+ if (chdir("./themes/")) {
+ $dirs = glob('*', GLOB_ONLYDIR);
+ foreach ($dirs as $val) {
+ $select = ($val == $c['theme_name']) ? ' selected' : '';
+ echo '<option value="' . $val . '"' . $select . '>' . $val . "</option>\n";
+ }
+ }
+ echo "</select></span></div>
+ <div class='change border'><b>Navigation <small>(hint: add your page below and <a href='javascript:location.reload(true);'>click here to refresh</a>)</small></b><br /><span id='menu' title='Home' class='editText'>" . $c['menu'] . "</span></div>";
+ foreach (array('title', 'description', 'keywords', 'copyright') as $key) {
+ echo "<div class='change border'><span title='" . $d['default'][$key] . "' id='" . $key . "' class='editText'>" . $c[$key] . "</span></div>";
+ }
+ echo "</div></div>";
+}