Mercurial > owls
changeset 17:081ba8764994 owls-2.0
The wiki-like system became a content-rendering system
This is a single changeset to include all the changes throughout
the last years. Owls no longer supports editing pages but only
renders them. Also, it no longer uses a database to store the
contents but reads the contents from the filesystem. All this
made owls simpler ... anyway, it just reflects my needs.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Sat, 23 Jul 2016 21:39:17 +0200 |
parents | 22243e7c7dc5 |
children | 98983ba58e2e |
files | Bbcodeparser.inc.php Config/Config.inc.php Config/Owls.css.php Config/Setup.php Loginsys.class.php Nav.inc.php Owls.php Owls.png bbcodeparser.inc.php data/text index.php nav.inc.php owls-banner.png owls.css.php smilies/Angry.gif smilies/Biggrin.gif smilies/Cool.gif smilies/Crosseyed.gif smilies/Dontknow.gif smilies/Faustball.gif smilies/Lick.gif smilies/Rolleyes.gif smilies/Sad.gif smilies/Shocked.gif smilies/Smile.gif smilies/Talk.gif smilies/Wink.gif |
diffstat | 27 files changed, 454 insertions(+), 998 deletions(-) [+] |
line wrap: on
line diff
--- a/Bbcodeparser.inc.php Sun May 27 14:06:42 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -<?php -/** - * BB-Code-Parser - * - * @author Meillo r e t u r n s <meillo@marmaro.de> - */ - - - /// path to smilies - define('SMILIE_DIR', 'Smilies/'); - - - - /** - * parses recursive quotes without a source mentioned - * - * @param $textinput the bbcode-text - * @param $level number of levels to go inside - * @return HTML-text - */ - function parse_quote1($textinput,$level = 1) { - $pattern = '#\[quote\](((?R)|(.*))*)\[/quote\]#isUe'; - $replacement = "'<br />[nl]<span class=\"quote0\">Zitat:</span>[nl]<div class=\"quote1\">[nl]'.parse_quote1('$1', - ". ($level + 1) ." - ).'[nl]</div>[nl]'"; - return preg_replace($pattern, $replacement, $textinput); - } - - /** - * parses recursive quotes with a source mentioned - * - * @param $textinput the bbcode-text - * @param $level number of levels to go inside - * @return HTML-text - */ - function parse_quote2($textinput,$level = 1) { - $pattern = '#\[quote\=(.*)\](((?R)|(.*))*)\[/quote\]#isUe'; - $replacement = "'<br />[nl]<span class=\"quote0\">Zitat: ($1)</span>[nl]<div class=\"quote2\">[nl]'.parse_quote2('$2', - ". ($level + 1) ." - ).'[nl]</div>[nl]'"; - return preg_replace($pattern, $replacement, $textinput); - } - - /** - * replaces smilies - * - * @param $text text with ASCII-smilies - * @return text with [img]-smilies - */ - function smilies($text) { - $smilies = array( ':-)' => 'Smile.gif', - ':)' => 'Smile.gif', - ';-)' => 'Wink.gif', - ';)' => 'Wink.gif', - ':-D' => 'Biggrin.gif', - ':D' => 'Biggrin.gif', - ':-(' => 'Sad.gif', - ':(' => 'Sad.gif', - ':-P' => 'Lick.gif', - ':P' => 'Lick.gif', - ':o' => 'Talk.gif', - ':-S' => 'Dontknow.gif', - ':dontknow:' => 'Dontknow.gif', - ':-@' => 'Angry.gif', - ':cool:' => 'Cool.gif', - 'B-)' => 'Cool.gif', - '%-)' => 'Crosseyed.gif', - '%-(' => 'Crosseyed.gif', - ':rolleyes:' => 'Rolleyes.gif', - ':eek:' => 'Shocked.gif'); - while(list($key, $val) = each($smilies)) { - $text = str_replace($key,'[img]'. SMILIE_DIR . $val .'[/img]', $text); - } - return $text; - } - - - /** - * turns bbcode in HTML - * - * @param $text the text with bbcode inside - * @param $smilies set to 1 causes smilies to be replaced with pics - * @param $images set to 1 causes images to be displayed ([img]-tag) - * @return text with HTML-code - */ - function bbcode($text, $smilies = 0, $images = 0) { - - // smilies - if ($smilies == 1) { - $text = smilies($text); - } - - // new-lines - $text = preg_replace("#(\r\n)|(\r)#", "\n", $text); - $text = str_replace("\n", '<br />[nl]', htmlentities($text)); - - // bold - $text = preg_replace("#\[b\](.*?)\[/b\]#i", "<strong>$1</strong>", $text); - // italic - $text = preg_replace("#\[i\](.*?)\[/i\]#i", "<i>$1</i>", $text); - // links - $text = preg_replace("#\[url\](.*)\[/url\]#iU", "<a href=\"$1\">$1</a>", $text); - $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU", "<a href=\"$1\">$2</a>", $text); - // lists - //$text = preg_replace("#\[list\]\<br /\>(.*)\[/list\]#iU", "<ul>$1</ul>", $text); - //$text = preg_replace("#\[\*\](.*)\<br \/\>#iU", "<li>$1</li>", $text); - // quotes - $text = parse_quote1($text); - $text = parse_quote2($text); - // images - if ($images == 1) { - $text = preg_replace("#\[img\](.*?)\[/img\]#i", "<img src=\"$1\" alt=\"<[Bild]>\" />", $text); - } - - // remove backslashes - $text = preg_replace("#\\\#is", "", $text); - // new-lines - $text = str_replace('[nl]', "\n", $text); - - return $text; - } - -?>
--- a/Config/Config.inc.php Sun May 27 14:06:42 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -<?php - -// Prefix for database tables (default: 'rem__') -$db_prefix = 'rem__1_'; - -// Title of the website (default: 'Owls') -$title = 'Owls'; - -// Location of the database connection script to include -$db_connect = '../../Db.inc.php'; - -// Name of the banner pic -$banner = 'Owls.png'; - -?>
--- a/Config/Owls.css.php Sun May 27 14:06:42 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -<?php -/*######################################################## -###### to modify the look of owls, edit below ###### -########################################################*/ - - -/* - color setup - use color values according to http://www.w3.org/TR/CSS21/syndata.html#color-units - you can assign the set variables too -*/ - - $c_Text = '#000'; - $c_Background = '#999'; - - $c_Border = $c_Text; - - $c_Link = $c_Text; - $c_LinkHover = '#ff8040'; - $c_LinkVisited = '#666'; - - $c_Nav = $c_Link; - $c_NavHover = $c_LinkHover; - $c_NavSelected = '#eee'; - - $c_Login = $c_LinkVisited; - $c_Admin = '#ffff80'; - - -/* - width of the menu area - the unit 'em' is relative to the font-size - see: http://www.w3.org/TR/CSS21/syndata.html#length-units -*/ - - $m_NavWidth = '10em'; - - -/*######################################################## -############# noobs, stop editing here ############# -########################################################*/ - - - - - - - header('Content-Type: text/css; charset=utf8'); - - // avoid caching TODO: think about removing, cause it's just for dev - header('Expires: Thu, 05 Apr 1984 04:47:00 GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - header('Cache-Control: no-store'); - header('Pragma: no-cache'); - echo('/* Anti-Caching: '.microtime()." */\r\n"); - -?> - - - -body { - font-family: sans-serif; - margin: 30px 0; - text-align: center; - color: <?php echo $c_Text; ?>; - background-color: <?php echo $c_Background; ?>; -} - - -#websiteContainer { - width: 760px; - margin: 0 auto; - text-align: justify; -} - -#banner { - display: block; - margin: 0 auto; -} - -#content { - position: relative; - margin-left: <?php echo $m_NavWidth; ?>; - padding: 1em; -} - - - -/* uhhh?? is this not needed anymore? are there no borders drawn by default? -img { - border: none; -} -*/ - - - - - - -/* links */ -a:link { - color: <?php echo $c_Link; ?>; -} -a:visited { - color: <?php echo $c_LinkVisited;?>; -} -a:active, -a:hover { - color: <?php echo $c_LinkHover; ?>; -} - - - - - - -/* nav */ -#nav { - list-style: none; - float: left; - width: <?php echo $m_NavWidth; ?>; - padding: 0.5em 2em 1em 0.5em; - margin: 2.5em 0 1em 0; - font-size: 0.8em; -} - -#nav ul { - list-style: none; - margin-left: 0; - padding-left: 1em; -/* border: 1px solid #060; */ -} -#nav li { - padding: 1px; - margin: 0; -/* border: 1px solid #006; */ -} - -#nav a { - display: block; - text-decoration: none; - color: <?php echo $c_Nav; ?>; -} -#nav a:link, -#nav a:visited { - text-decoration: none; -} -#nav a:active, -#nav a:hover { - color: <?php echo $c_NavHover; ?>; - text-decoration: none; -} - -#selected:link, -#selected:visited { - color: <?php echo $c_NavSelected; ?>; -} -#nav #selected:hover { - color: <?php echo $c_NavHover; ?>; -} - - - - -/* orphans and broken */ -li#orphans, -li#broken { - margin-top: 3em; - font-style: italic; - color: <?php echo $c_Admin; ?>; -} - - - - -/* login */ -#loginform input { - background-color: transparent; - border: none; - border-bottom: <?php echo $c_Login; ?> 1px solid; /* TODO: think about other color */ - font-size: 0.8em; - width: 8em; -} - - - - - - -/* admin controls */ -.ctrl { - position: absolute; - right: 0; - text-align: right; - font-size: 0.8em; - color: <?php echo $c_Login; ?>; -} -.ctrl a, -.ctrl a:visited, -.ctrl a:hover { - margin-left: 1em; - color: <?php echo $c_Admin; ?>; -} - - - - - - -/* edit form */ -#edit { - margin-top: 1.5em; -} -#edit input, -#edit select, -#edit textarea { - font-family: sans-serif; - font-size: 0.8em; - border: <?php echo $c_Border; ?> 1px solid; -} -
--- a/Config/Setup.php Sun May 27 14:06:42 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -<?php - -// you can customize the config here - -$dbPrefix = 'rem__2_'; // the names of the db-tables will be prefixed with this string - -//$modifyProtected = true; // are guests allowed to modify data? (true or false) - -$defaultUser = 'admin'; // useraccount if "modifyProtected = true" above -$defaultUserPassword = 'admin'; // password for useraccount if "modifyProtected = true" above - - - -// dont change anything form here on (except you know what you do) -//################################################################## - - // write db-login-data to textfile - - - // connect to db and create tables - require('../Db.inc.php'); - - - // table 'Owls' for the content data - mysql_query(" - CREATE TABLE IF NOT EXISTS `". $dbPrefix ."Owls` ( - `id` int(11) NOT NULL auto_increment, - `idParent` int(11) default '0', - `name` text NOT NULL, - `text` longtext NOT NULL, - `permission` tinyint(4) NOT NULL default '1', - `date` int(11) NOT NULL default '0', - PRIMARY KEY (`id`) - ) - ") or die(mysql_error()); - - // insert startup nodes - mysql_query("INSERT INTO `". $dbPrefix ."Owls` VALUES (1, 0, 'Index', 'Thanks for using [url=http://prog.marmaro.de/owls/]Owls[/url]!', 0, now())") or die(mysql_error()); - - - - // login should be managed via text file in future - mysql_query("CREATE TABLE IF NOT EXISTS `". $dbPrefix ."User` ( - `id` int(11) NOT NULL auto_increment, - `loginname` tinytext NOT NULL, - `password` tinytext NOT NULL, - PRIMARY KEY (`id`) - )") or die(mysql_error()); - - mysql_query("INSERT INTO `". $dbPrefix ."User` VALUES (1, '". $defaultUser ."', '". md5($defaultUserPassword) ."')") or die(mysql_error()); - -?>
--- a/Loginsys.class.php Sun May 27 14:06:42 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -<?php -/** - * simple loginsystem for owls - * - * @brief simple loginsystem for owls - * @author Meillo r e t u r n s <meillo@marmaro.de> - */ -class Loginsys { - - /// Consts - - /** - * time in seconds till the session expires - */ - const TIME_SESSION_EXPIRES = 1800; - - - - /// Constructors - - /** - * starts the session - * and puts an activity timestamp in it - */ - public function __construct() { - session_start(); - $this->heartbeat(); - } - - - - - /// Methods - - - /** - * trys to log in with the given login data - * - * @param $loginname username - * @param $password_md5 md5 password hash - */ - public function login($loginname, $password_md5) { // login ------------------------------------ - $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' ")); - if (mysql_affected_rows() == 1) { // valid login - $_SESSION[login][id] = $rowuser[id]; - $_SESSION[login][loginname] = $loginname; - $_SESSION[login][logintime] = time(); - } - } - - - /** - * logs the user out - */ - public function logout() { // logout ------------------------------------------------------------ - unset($_SESSION[login]); - } - - - /** - * proves if the user is logged in and if he wan't to long inactive - * - * @return bool 'true' if user is logged in, else 'false' - */ - public function loggedIn() { // return login-status --------------------------------------------- - return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-self::TIME_SESSION_EXPIRES); - } - - - /** - * writes the current timestamp into the session - * this is relevant for the time of inactivity - */ - public function heartbeat() { - if ($this->loggedIn()) { - $_SESSION[login][logintime] = time(); - } - } - - - - /// Getter and Setter - - - /** - * @return user id - */ - public function getUserId() { - return $_SESSION[login][id]; - } - - /** - * @return user name - */ - public function getLoginname() { - return $_SESSION[login][loginname]; - } - -} - - -?>
--- a/Nav.inc.php Sun May 27 14:06:42 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ - <!-- Nav --> - <ul id="nav"> - -<?php - // all nodes that are displayed in the nav - global $nodesDisplayed; - $nodesDisplayed = ''; - - - // build nav tree - echo ' '. navtree(0) ."\n"; - - - // find nodes without existing parent (orphans) - $sql = sprintf(" - select distinct - idParent - from %sOwls - where - idParent not in (select id from %sOwls) - and idParent != 0 -- not the real root - order by name asc - ", - DB_PREFIX, - DB_PREFIX - ); - $result = mysql_query($sql) or die(mysql_error()); - unset($sql); - - // output only if there are orphans - if (mysql_num_rows($result)) { - echo ' <li id="orphans">orphans<ul>'; - // output subtree for every orphan - while($row = mysql_fetch_array($result)) { - echo navtree($row['idParent']); - } - unset($row); - mysql_free_result($result); - - echo '</ul></li>'."\n"; - } - - - - // find broken nodes - nodes not displayed in nav or orphans (i.e. rings) - $sql = sprintf(" - select - id, name - from %sOwls - where - id not in ( %s ) - order by name asc - ", - DB_PREFIX, - substr($nodesDisplayed, 2) - ); - $result = mysql_query($sql) or die(mysql_error()); - unset($sql); - - // output only if there are broken nodes - if (mysql_num_rows($result)) { - echo ' <li id="broken">broken<ul>'; - // output list of nodes (no tree, cause there may be rings!) - while($row = mysql_fetch_array($result)) { - echo '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a></li>'; - } - unset($row); - mysql_free_result($result); - - echo '</ul></li>'."\n"; - } - -?> - - - </ul> - -<?php - - - /** - * recursive function creates the output for the nav tree - * - * @param $root the id of the parent of the root node - * @return string HTML output that shows the nav tree - */ - function navtree($root) { - // fetch subcategories - $sql = sprintf(" - select - id, idParent, name - from %sOwls - where - idParent = $root - order by name asc - ", - DB_PREFIX - ); - $result = mysql_query($sql) or die(mysql_error()); - unset($sql); - - $return = ''; - while($row = mysql_fetch_array($result)) { - // add to list of displayed nodes - global $nodesDisplayed; - $nodesDisplayed .= ', '. $row['id']; - - $return .= '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a>'; - if ($row['id'] != $row['idParent']) { - $subtree = navtree($row['id']); - if (!empty($subtree)) { - #$return .= ' <a href="javascript:toggleVisibility(\''. $row['id'] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>'; - $return .= '<ul id="node'. $row['id'] .'">'. $subtree .'</ul>'; - } - unset($subtree); - } - $return .= '</li>'; - } - unset($row); - mysql_free_result($result); - - // return - return $return; - } - -?> - - <!-- Content -->
--- a/Owls.php Sun May 27 14:06:42 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,357 +0,0 @@ -<?php - - require_once 'Config/Config.inc.php'; - - define('DB_PREFIX', $db_prefix); - define('TITLE', $title); - - require_once $db_connect; - require_once 'Loginsys.class.php'; - include_once 'Bbcodeparser.inc.php'; - - $lsys = &new Loginsys(); - -?> -<!-- - - `Owls' - some kind of wiki system - - - (c) Copyright 2006 &> by Meillo r e t u r n s - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - - http://prog.marmaro.de/owls/ - ---> - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> - -<html xml:lang="de" xmlns="http://www.w3.org/1999/xhtml"> -<head> - <title><?php echo htmlentities(TITLE); ?></title> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> - <link rel="shortcut icon" href="favicon.ico" /> - <link rel="stylesheet" type="text/css" href="Config/Owls.css.php" /> - <script type="text/javascript"> - <!-- - function sureToDelete(id) { - if (window.prompt("Type 'delete' to delete","") == "delete") { - location.href = id +"d"; - } - } - -/* I want to use this function later ... perhaps - function toggleVisibility(boxId) { - if (document.getElementById('node'+ boxId).style.display == 'none') { - document.getElementById('node'+ boxId).style.display = ""; - document.getElementById('ctrl'+ boxId).firstChild.nodeValue = "-"; - } else{ - document.getElementById('node'+ boxId).style.display = "none"; - document.getElementById('ctrl'+ boxId).firstChild.nodeValue = "+"; - } - } -*/ - //--> - </script> -</head> - -<body> -<div id="websiteContainer"> - - <!-- Banner --> - <img src="<?php echo $banner; ?>" id="banner" alt="<?php echo htmlentities(TITLE); ?>" /> - -<?php - - - if ($_GET['action'] == 'show') { // show - show($lsys); - - } else if ($_GET['action'] == 'new' && $lsys->loggedIn()) { // new - create($lsys); - - } else if ($_GET['action'] == 'edit' && $lsys->loggedIn()) { // edit - edit($lsys); - - } else if ($_GET['action'] == 'delete' && $lsys->loggedIn()) { // delete - delete($lsys); - - } else if ($_GET['action'] == 'login') { // login - $lsys->login($_POST['login_loginname'], md5($_POST['login_password'])); - show($lsys); - - } else if ($_GET['action'] == 'logout') { // logout - $lsys->logout(); - show($lsys); - - } else { // startpage - $_GET['id'] = 1; - show($lsys); - - } - - - - - -?> - - </div> - - -</div> - -</body> -</html> -<?php - - - - - - - - -/* - displays content of the node - performs action 'edit' - shows admincontrols if logged in -*/ -function show($lsys) { - - - // perform action: write edited node to db - if (isset($_POST['editDoc']) && $lsys->loggedIn()) { - $_POST['editDoc_title'] = addslashes($_POST['editDoc_title']); - $_POST['editDoc_text'] = addslashes($_POST['editDoc_text']); - mysql_query("update ". DB_PREFIX ."Owls set - name='$_POST[editDoc_title]', - text='$_POST[editDoc_text]', - idParent='$_POST[editDoc_idCategory]', - date=". time() ." - where id='$_GET[id]'") or die(mysql_error()); - } - - // print nav - include 'Nav.inc.php'; - - - - - // query data of the node - $result = mysql_query("select * from ". DB_PREFIX ."Owls where id=$_GET[id]"); - - // catch nodes that not exist - if (!mysql_num_rows($result)) { - - $fnord = array('', - 'Fnord is the space between the pixels on your screen.', - 'Fnord is the echo of silence.', - 'Fnord is evaporated herbal tea without the herbs.', - 'Fnord is what you see when you close your eyes.', - 'Fnord is the empty pages at the end of the book.', - 'Fnord is why ducks eat trees.', - 'Fnord is the bucket where they keep the unused serifs for H*lvetica.', - 'Fnord is the source of all the zero bits in your computer.' - ); - -?> - <div id="content"> - <h2>Error 23 - fnord found</h2> - <p> - <?php echo $fnord[rand(0, sizeof($fnord)-1)]; ?> - </p> -<?php - - } else { - - $row = mysql_fetch_array($result); - echo ' <div id="content">'."\n"; - - // display admin controls or login form -?> - <div class="ctrl"> -<?php - // display last update - if ($_GET['id'] == 1) { - // root node displays date of last modification of any node - $sql = sprintf(" - select - max(date) - from %sOwls - ", - DB_PREFIX - ); - } else { - $sql = sprintf(" - select - date - from %sOwls - where - id = ". $_GET['id'] ." - ", - DB_PREFIX - ); - } - $result = mysql_query($sql) or die(mysql_error()); - unset($sql); - - $rowUpdate = mysql_fetch_row($result); - $lastUpdate = $rowUpdate[0]; -?> - <span style="font-size: 0.8em;"> - last update: <?php echo date('d.m.Y H:i', $lastUpdate); ?> - </span> - -<?php - if ($lsys->loggedIn()) { -?> - <a href="<?php echo $row['id'] .'n'; ?>">new</a> - <a href="<?php echo $row['id'] .'e'; ?>">edit</a> -<?php - if ($row['id'] != 1) { - echo '<a href="javascript:sureToDelete('. $row['id'] .')">delete</a>'; - } - echo ' <a href="'. $_GET['id'] .'logout" style="color: #c00;">logout</a>'; - } else { -?> - <form name="loginform" id="loginform" action="<?php echo $_GET['id']; ?>login" method="post" enctype="multipart/form-data" style="display: inline;"> - <input name="login_loginname" type="text" /> - <input name="login_password" type="password" /> - <input name="login" type="submit" value="login" style="padding: 0; cursor: pointer; width: 5em;" /> - </form> -<?php - } -?> - </div> -<?php - - // print content of the node - echo ' <h2>'.stripslashes($row['name']).'</h2>'."\n"; - if (!empty($row['text'])) { - echo ' <p>'.bbcode(stripslashes($row['text']), 1, 1).'</p>'; - } - } - echo "\n\n"; - -} - - - - - -/* - displays edit form -*/ -function edit($lsys) { - - include 'Nav.inc.php'; - - $sql = "select * from ". DB_PREFIX ."Owls where id=$_GET[id]"; - $result = mysql_query($sql) or die(mysql_error()); - $row = mysql_fetch_array($result); - echo '<div id="content">'; -?> -<div id="edit" style="position: relative; width: 99%"> - <form action="<?php echo $row['id']; ?>" method="post" enctype="multipart/form-data"> -<?php - if ($_GET['id'] != 1) { -?> - <select name="editDoc_idCategory" style="width: 99%;"> -<?php - $sql = sprintf(" - select - * - from %sOwls - where - id != %d - and idParent != %d --- not in ( --- select idParent from %sOwls --- ) - order by name asc - ", - DB_PREFIX, - $row['id'], - $row['id'], - DB_PREFIX - ); - $result = mysql_query($sql) or die(mysql_error()); - unset($sql); - while($rowCats = mysql_fetch_array($result)) { - echo ' <option value="'.$rowCats['id'].'"'. (($row['idParent'] == $rowCats['id']) ? ' selected="selected" style="font-weight: bold;"' : '') .'>'.stripslashes($rowCats['name']).'</option>'; - } -?> - </select><br /><br /> -<?php - } -?> - <input name="editDoc_title" type="text" value="<?php echo stripslashes($row['name']); ?>" style="width: 99%; font-weight: bold;" /><br /> - <textarea name="editDoc_text" cols="60" rows="15" style="width: 99%; height: 30em;"><?php - echo stripslashes($row['text']); - ?></textarea><br /><br /> - <input name="editDoc" type="submit" value="edit" class="button" style="width: 99%;" /> - </form> -</div> -<?php - unset($row); - unset($result); -} - - - - - - -/* - performs action 'new' -*/ -function create($lsys) { - - // perform action: new node - mysql_query(" - insert into ". DB_PREFIX ."Owls - (idParent, date) - values('$_GET[id]',". time() .") - ") or die(mysql_error()); - - // set node to jump to (new created node) - $_GET['id'] = mysql_insert_id(); - edit($lsys); -} - - - - - -/* - performs action 'delete' -*/ -function delete($lsys) { - // not allowed to delete the root - if ($_GET['id'] != 1) { - // TODO: get the parent of the one which is to delete - - // delete - mysql_query("delete from ". DB_PREFIX ."Owls where id='$_GET[id]'") or die(mysql_error()); - } - // set node to jump to (TODO: parent from above) - $_GET['id'] = 1; - show($lsys); -} - - - - -?> -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bbcodeparser.inc.php Sat Jul 23 21:39:17 2016 +0200 @@ -0,0 +1,158 @@ +<?php +/** + * BB-Code-Parser + * + * @author Meillo r e t u r n s <meillo@marmaro.de> + */ + + + /// path to smilies + define('SMILIE_DIR', 'smilies/'); + + + + /** + * parses recursive quotes without a source mentioned + * + * @param $textinput the bbcode-text + * @param $level number of levels to go inside + * @return HTML-text + */ + function parse_quote1($textinput,$level = 1) { + $pattern = '#\[quote\](((?R)|(.*))*)\[/quote\]#isUe'; + $replacement = "'<br />[nl]<span class=\"quote0\">Zitat:</span>[nl]<div class=\"quote1\">[nl]'.parse_quote1('$1', + ". ($level + 1) ." + ).'[nl]</div>[nl]'"; + return preg_replace($pattern, $replacement, $textinput); + } + + /** + * parses recursive quotes with a source mentioned + * + * @param $textinput the bbcode-text + * @param $level number of levels to go inside + * @return HTML-text + */ + function parse_quote2($textinput,$level = 1) { + $pattern = '#\[quote\=(.*)\](((?R)|(.*))*)\[/quote\]#isUe'; + $replacement = "'<br />[nl]<span class=\"quote0\">Zitat: ($1)</span>[nl]<div class=\"quote2\">[nl]'.parse_quote2('$2', + ". ($level + 1) ." + ).'[nl]</div>[nl]'"; + return preg_replace($pattern, $replacement, $textinput); + } + + /** + * replaces smilies + * + * @param $text text with ASCII-smilies + * @return text with [img]-smilies + */ + function smilies($text) { + $smilies = array( ':-?\)' => 'Smile.gif', + ';-?\)' => 'Wink.gif', + ':-?D' => 'Biggrin.gif', + ':-?\(' => 'Sad.gif', + ':-?P' => 'Lick.gif', + ':o' => 'Talk.gif', + ':-S' => 'Dontknow.gif', + ':dontknow:' => 'Dontknow.gif', + ':-@' => 'Angry.gif', + ':cool:' => 'Cool.gif', + 'B-\)' => 'Cool.gif', + '%-\)' => 'Crosseyed.gif', + '%-\(' => 'Crosseyed.gif', + ':rolleyes:' => 'Rolleyes.gif', + ':eek:' => 'Shocked.gif'); + while(list($key, $val) = each($smilies)) { + $key = '/(\s|^)'.$key.'(\s|$)/'; + $text = preg_replace($key, '$1[img]'. SMILIE_DIR . $val .'[/img]$2', $text); + } + return $text; + } + + + /** + * turns bbcode in HTML + * + * @param $text the text with bbcode inside + * @param $smilies set to 1 causes smilies to be replaced with pics + * @param $images set to 1 causes images to be displayed ([img]-tag) + * @return text with HTML-code + */ + function bbcode($text, $smilies = 0, $images = 0) { + + // line breaks and special chars + $text = preg_replace("#(\r\n)|(\r)#", "\n", htmlentities($text, ENT_COMPAT, 'UTF-8')); + $text = preg_replace("#(\n){3,}#", "\n\n", $text); + + // smilies + if ($smilies == 1) { + $text = smilies($text); + } + + /* + // new-lines + $text = preg_replace("#(\r\n)|(\r)#", "\n", $text); + $text = str_replace("\n", '<br />[nl]', htmlentities($text, ENT_COMPAT, 'UTF-8')); + + // bold + $text = preg_replace("#\[b\](.*?)\[/b\]#i", "<strong>$1</strong>", $text); + // italic + $text = preg_replace("#\[i\](.*?)\[/i\]#i", "<i>$1</i>", $text); + // links + $text = preg_replace("#\[url\](.*)\[/url\]#iU", "<a href=\"$1\">$1</a>", $text); + $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU", "<a href=\"$1\">$2</a>", $text); + // lists + //$text = preg_replace("#\[list\]\<br /\>(.*)\[/list\]#iU", "<ul>$1</ul>", $text); + //$text = preg_replace("#\[\*\](.*)\<br \/\>#iU", "<li>$1</li>", $text); + // quotes + */ + $text = parse_quote1($text); + $text = parse_quote2($text); + // images + if ($images == 1) { + $text = preg_replace("#\[img\](.*?)\[/img\]#i", "<img src=\"$1\" alt=\"<[Bild]>\" />", $text); + } + + /* + // remove backslashes + $text = preg_replace("#\\\#is", "", $text); + // new-lines + $text = str_replace('[nl]', "\n", $text); + */ + + + // inline + $text = preg_replace('#\[b\](.*)\[/b\]#iU', '<strong>$1</strong>', $text); + $text = preg_replace('#\*(.*)\*#iU', '<strong>$1</strong>', $text); + $text = preg_replace('#\[i\](.*)\[/i\]#iU', '<i>$1</i>', $text); + $text = preg_replace('#[^A-Za-z0-9]_(.*)_[^A-Za-z0-9]#iU', '<em>$1</em>', $text); + $text = preg_replace('#{{{(.*)}}}#iUs', '<tt>$1</tt>', $text); + $text = preg_replace("#\[url\](.*)\[/url\]#iU","<a href=\"$1\">$1</a>",$text); + $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU","<a href=\"$1\">$2</a>",$text); + $text = preg_replace("#\[img\](.*)\[/img\]#iU","<img src=\"$1\" alt=\"[Bild]\" />", $text); + $text = preg_replace("#^-{3,}$#iUm","<hr />", $text); + + // Listen +# $text = preg_replace("#\[list\](.*)\[/list\]#i","<ul>$1</ul>", $text); + $text = preg_replace("#^\s*\*(.*)\n#imU", "<li>$1</li>", $text); + $text = preg_replace("#^((\s*\<li\>(.*)\</li\>\s*)+)$#im", "<ul>$1</ul>", $text); + + + + + // boxes + + + $text = preg_replace('#^(.+)$#mU', "<p>\n $1\n</p>", $text); + + # nicht wenn <h_> oder <ul> enthalten sind + $text = preg_replace("#\<p\>\n \[h([1-6]{1})\](.*)\[/h[1-6]{1}\]\n\</p\>#iU", "\n<h$1>$2</h$1>", $text); + $text = preg_replace("#\<p\>\n ===(.*)\n\</p\>#iU", "\n<h3>$1</h3>", $text); + $text = preg_replace("#\<p\>\n ==(.*)\n\</p\>#iU", "\n<h2>$1</h2>", $text); + + $text = preg_replace("#\<p\>\n \<ul\>(.*)\</ul\>\n\</p\>#iU", "<ul>\n $1\n</ul>", $text); + return $text; + } + +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/text Sat Jul 23 21:39:17 2016 +0200 @@ -0,0 +1,3 @@ +Welcome to the Owls content rendering system. + +Put more files and directory structures into the data directory.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.php Sat Jul 23 21:39:17 2016 +0200 @@ -0,0 +1,41 @@ +<?php + error_reporting(E_ALL); + include_once 'bbcodeparser.inc.php'; +?> +<html> +<head> + <title>Owls - content-rendering system</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <link rel="shortcut icon" href="favicon.ico" /> + <link rel="stylesheet" type="text/css" href="owls.css.php" /> +</head> + +<body> +<div id="websiteContainer"> + <a href="/"> + <img src="owls-banner.png" id="banner" /> + </a> + +<?php + include 'nav.inc.php'; + + if (!isset($_GET['path'])) { + $_GET['path'] = '/'; + } + echo ' <div id="content">'."\n"; + echo " <h2>". preg_replace('/.*\//', '', $_GET['path']) ."</h2>\n"; + $file = 'data/'. $_GET['path'].'/text'; + if (is_file($file)) { + $text = file_get_contents($file); + } else { + $text = 'file not found'; + } + echo ' <p>'.bbcode($text, 1, 1).'</p>'; + echo ' </div>'; + echo "\n\n"; +?> + +</div> + +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nav.inc.php Sat Jul 23 21:39:17 2016 +0200 @@ -0,0 +1,42 @@ + <ul id="nav"> + +<?php + + define('BASE', 'data/'); + + echo ' <li><a href="."'. (empty($_GET['path']) ? ' id="selected"' : '') .">Home</a></li>"; + // build nav tree + echo ' '. navtree("") ."\n"; +?> + + + </ul> + +<?php + + + +/* recursive function creates the output for the nav tree */ +function navtree($root) { + + if (!empty($root)) { + $root .= '/'; + } + $files = scandir(BASE."$root"); + $return = ''; + foreach ($files as $f) { + if (!is_dir(BASE."$root$f") || substr($f, 0, 1) == '.') { + continue; + } + $return .= "<li><a href=\"?path=$root$f\"". ((isset($_GET['path']) && $_GET['path'] == "$root$f") ? ' id="selected"' : '') .">$f</a>"; + $subtree = navtree("$root$f"); + if (!empty($subtree)) { + $return .= "<ul>$subtree</ul>"; + } + unset($subtree); + } + $return .= '</li>'; + return $return; +} + +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/owls.css.php Sat Jul 23 21:39:17 2016 +0200 @@ -0,0 +1,210 @@ +<?php +/*######################################################## +###### to modify the look of owls, edit below ###### +########################################################*/ + + +/* + color setup + use color values according to http://www.w3.org/TR/CSS21/syndata.html#color-units + you can assign the set variables too +*/ + + $c_Text = '#ccc'; + $c_Background = '#333'; + + $c_Border = $c_Text; + + $c_Link = $c_Text; + $c_LinkHover = '#6af'; // ff8040 + $c_LinkVisited = '#666'; + + $c_Nav = $c_Link; + $c_NavHover = $c_LinkHover; + $c_NavSelected = '#06f'; + + $c_Login = '#000'; + $c_Admin = '#ffff80'; //ffff80 + + +/* + width of the menu area + the unit 'em' is relative to the font-size + see: http://www.w3.org/TR/CSS21/syndata.html#length-units +*/ + + $m_NavWidth = '10em'; + + +/*######################################################## +################# stop editing here ################ +########################################################*/ + + + + + + + header('Content-Type: text/css; charset=utf8'); + + // avoid caching TODO: think about removing, cause it's just for dev + header('Expires: Thu, 05 Apr 1984 04:47:00 GMT'); + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + header('Cache-Control: no-store'); + header('Pragma: no-cache'); + echo('/* Anti-Caching: '.microtime()." */\r\n"); + +?> + + + +body { + font-family: sans-serif; + margin: 30px 0; + text-align: center; + color: <?php echo $c_Text; ?>; + background-color: <?php echo $c_Background; ?>; +} + + +#websiteContainer { + width: 760px; + margin: 0 auto; + text-align: justify; +} + +#banner { + display: block; + margin: 0 auto; + border: none; +} + +#content { + position: relative; + margin-left: <?php echo $m_NavWidth; ?>; + padding: 1em; +} + + + + + +/* links */ +a:link { + color: <?php echo $c_Link; ?>; +} +a:visited { + color: <?php echo $c_LinkVisited;?>; +} +a:active, +a:hover { + color: <?php echo $c_LinkHover; ?>; +} + + + + + + +/* nav */ +#nav { + list-style: none; + float: left; + width: <?php echo $m_NavWidth; ?>; + padding: 0.5em 2em 1em 0.5em; + margin: 2.5em 0 1em 0; + font-size: 0.8em; +} + +#nav ul { + list-style: none; + margin-left: 0; + padding-left: 1em; +} +#nav li { + padding: 1px; + margin: 0; +} + +#nav a { + display: block; + text-decoration: none; + color: <?php echo $c_Nav; ?>; +} +#nav a:link, +#nav a:visited { + text-decoration: none; +} +#nav a:active, +#nav a:hover { + color: <?php echo $c_NavHover; ?>; + text-decoration: none; +} + +#selected:link, +#selected:visited { + color: <?php echo $c_NavSelected; ?>; +} +#nav #selected:hover { + color: <?php echo $c_NavHover; ?>; +} + + + + +/* orphans and broken */ +li#orphans, +li#broken { + margin-top: 3em; + font-style: italic; + color: <?php echo $c_Admin; ?>; +} + + + + +/* login */ +#loginform input { + background-color: transparent; + border: <?php echo $c_Login; ?> 1px solid; + font-size: 0.8em; + width: 8em; +} + + + + + + +/* admin controls */ +.ctrl { + position: absolute; + right: 0; + text-align: right; + font-size: 0.8em; + color: <?php echo $c_Login; ?>; +} +.ctrl a, +.ctrl a:visited, +.ctrl a:hover { + margin-left: 1em; + color: <?php echo $c_Admin; ?>; +} + + + + + + +/* edit form */ +#edit { + margin-top: 1.5em; +} +#edit input, +#edit select, +#edit textarea { + font-family: sans-serif; + font-size: 0.8em; + border: <?php echo $c_Border; ?> 1px solid; +} +