owls

changeset 0:3021ce32ee14 owls-0.5

begin of using hg for owls
author "Meillo r e t u r n s <meillo@marmaro.de>"
date Sun, 03 Dec 2006 22:32:13 +0100
parents
children 6268cdb5fc0b
files .hgignore .htaccess Includes/Bbcodeparser.inc.php Includes/Footer.inc.php Includes/Header.inc.php Includes/Loginsys.class.php Includes/Nav.inc.php Owls.css.php Owls.php Setup.php
diffstat 10 files changed, 830 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgignore	Sun Dec 03 22:32:13 2006 +0100
     1.3 @@ -0,0 +1,12 @@
     1.4 +syntax: glob
     1.5 +
     1.6 +.*.swp
     1.7 +.*.swo
     1.8 +*~
     1.9 +
    1.10 +_Dev
    1.11 +
    1.12 +Banner.png
    1.13 +Smilies
    1.14 +favicon.ico
    1.15 +robots.txt
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/.htaccess	Sun Dec 03 22:32:13 2006 +0100
     2.3 @@ -0,0 +1,16 @@
     2.4 +RewriteEngine On
     2.5 +Options -MultiViews
     2.6 +DirectoryIndex Owls.php
     2.7 +#ErrorDocument 404 /Owls.php?error=404
     2.8 +
     2.9 +
    2.10 +# rules
    2.11 +
    2.12 +  RewriteRule ^([0-9]+)$ Owls.php?id=$1&action=show [NC]
    2.13 +  RewriteRule ^([0-9]+)n$ Owls.php?id=$1&action=new [NC]
    2.14 +  RewriteRule ^([0-9]+)e$ Owls.php?id=$1&action=edit [NC]
    2.15 +  RewriteRule ^([0-9]+)d$ Owls.php?id=$1&action=delete [NC]
    2.16 +
    2.17 +  RewriteRule ^([0-9]+)login$ Owls.php?id=$1&action=login [NC]
    2.18 +  RewriteRule ^([0-9]+)logout$ Owls.php?id=$1&action=logout [NC]
    2.19 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/Includes/Bbcodeparser.inc.php	Sun Dec 03 22:32:13 2006 +0100
     3.3 @@ -0,0 +1,94 @@
     3.4 +<?php
     3.5 +
     3.6 +/**
     3.7 + *
     3.8 + * BB-Code-Parser
     3.9 + *
    3.10 + * by Meillo  r e t u r n s
    3.11 + *
    3.12 + */
    3.13 +
    3.14 +
    3.15 +  function parse_quote1($textinput,$level = 1) {                  // ohne Quelle
    3.16 +    $pattern = '#\[quote\](((?R)|(.*))*)\[/quote\]#isUe';
    3.17 +    $replacement = "'<br />[nl]<span class=\"quote0\">Zitat:</span>[nl]<div class=\"quote1\">[nl]'.parse_quote1('$1',
    3.18 +                     ". ($level + 1) ."
    3.19 +                   ).'[nl]</div>[nl]'";
    3.20 +    return preg_replace($pattern, $replacement, $textinput);
    3.21 +  }
    3.22 +  function parse_quote2($textinput,$level = 1) {                   // mit Quelle
    3.23 +    $pattern = '#\[quote\=(.*)\](((?R)|(.*))*)\[/quote\]#isUe';
    3.24 +    $replacement = "'<br />[nl]<span class=\"quote0\">Zitat: ($1)</span>[nl]<div class=\"quote2\">[nl]'.parse_quote2('$2',
    3.25 +                     ". ($level + 1) ."
    3.26 +                   ).'[nl]</div>[nl]'";
    3.27 +    return preg_replace($pattern, $replacement, $textinput);
    3.28 +  }
    3.29 +
    3.30 +  function smilies($text) {
    3.31 +    $smilieDir = 'Pics/Smilies/';  // path to smilies
    3.32 +
    3.33 +    $smilies = array( ':-)'        => 'Smile.gif',
    3.34 +                      ':)'         => 'Smile.gif',
    3.35 +                      ';-)'        => 'Wink.gif',
    3.36 +                      ';)'         => 'Wink.gif',
    3.37 +                      ':-D'        => 'Biggrin.gif',
    3.38 +                      ':D'         => 'Biggrin.gif',
    3.39 +                      ':-('        => 'Sad.gif',
    3.40 +                      ':('         => 'Sad.gif',
    3.41 +                      ':-P'        => 'Lick.gif',
    3.42 +                      ':P'         => 'Lick.gif',
    3.43 +                      ':o'         => 'Talk.gif',
    3.44 +                      ':-S'        => 'Dontknow.gif',
    3.45 +                      ':dontknow:' => 'Dontknow.gif',
    3.46 +                      ':-@'        => 'Angry.gif',
    3.47 +                      ':cool:'        => 'Cool.gif',
    3.48 +                      '(H)'        => 'Cool.gif',
    3.49 +                      '%-)'        => 'Crosseyed.gif',
    3.50 +                      '%-('        => 'Crosseyed.gif',
    3.51 +                      ':rolleyes:' => 'Rolleyes.gif',
    3.52 +                      ':eek:'      => 'Shocked.gif');
    3.53 +    while(list($key, $val) = each($smilies)) {
    3.54 +      $text = str_replace($key,'[img]'.$smilieDir.$val.'[/img]',$text);
    3.55 +    }
    3.56 +    return $text;
    3.57 +  }
    3.58 +
    3.59 +
    3.60 +  function bbcode($text, $smilies = 0, $images = 0) {
    3.61 +
    3.62 +    // smilies
    3.63 +    if ($smilies == 1) {
    3.64 +      $text = smilies($text);
    3.65 +    }
    3.66 +
    3.67 +    // new-lines
    3.68 +    $text = preg_replace("#(\r\n)|(\r)#", "\n", $text);
    3.69 +    $text = str_replace("\n", '<br />[nl]', htmlentities($text));
    3.70 +
    3.71 +    // bold
    3.72 +    $text = preg_replace("#\[b\](.*?)\[/b\]#i", "<strong>$1</strong>", $text);
    3.73 +    // italic
    3.74 +    $text = preg_replace("#\[i\](.*?)\[/i\]#i", "<i>$1</i>", $text);
    3.75 +    // links
    3.76 +    $text = preg_replace("#\[url\](.*)\[/url\]#iU", "<a href=\"$1\">$1</a>", $text);
    3.77 +    $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU", "<a href=\"$1\">$2</a>", $text);
    3.78 +    // lists
    3.79 +      //$text = preg_replace("#\[list\]\<br /\>(.*)\[/list\]#iU", "<ul>$1</ul>", $text);
    3.80 +      //$text = preg_replace("#\[\*\](.*)\<br \/\>#iU", "<li>$1</li>", $text);
    3.81 +    // quotes
    3.82 +    $text = parse_quote1($text);
    3.83 +    $text = parse_quote2($text);
    3.84 +    // images
    3.85 +    if ($images == 1) {
    3.86 +      $text = preg_replace("#\[img\](.*?)\[/img\]#i", "<img src=\"$1\" alt=\"&lt;[Bild]&gt;\" />", $text);
    3.87 +    }
    3.88 +
    3.89 +    // remove backslashes
    3.90 +    $text = preg_replace("#\\\#is", "", $text);
    3.91 +    // new-lines
    3.92 +    $text = str_replace('[nl]', "\n", $text);
    3.93 +
    3.94 +    return $text;
    3.95 +  }
    3.96 +
    3.97 +?>
    3.98 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/Includes/Footer.inc.php	Sun Dec 03 22:32:13 2006 +0100
     4.3 @@ -0,0 +1,7 @@
     4.4 +  </div>
     4.5 +
     4.6 +
     4.7 +</div>
     4.8 +
     4.9 +</body>
    4.10 +</html>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/Includes/Header.inc.php	Sun Dec 03 22:32:13 2006 +0100
     5.3 @@ -0,0 +1,71 @@
     5.4 +<?php
     5.5 +
     5.6 +  define('DB_PREFIX', 'rem__1_');
     5.7 +  define('TITLE', 'Owls');
     5.8 +
     5.9 +  require_once '../Db.inc.php';
    5.10 +  require_once 'Includes/Loginsys.class.php';
    5.11 +  include_once 'Includes/Bbcodeparser.inc.php';
    5.12 +
    5.13 +  $lsys = &new Loginsys();
    5.14 +
    5.15 +?>
    5.16 +<!--
    5.17 +
    5.18 +                       `Owls' - some kind of wiki system
    5.19 +
    5.20 +
    5.21 +                (c) Copyright  2006 &>  by Meillo  r e t u r n s
    5.22 +
    5.23 +         This program is free software; you can redistribute it and/or
    5.24 +          modify it under the terms of the GNU General Public License
    5.25 +         as published by the Free Software Foundation; either version 2
    5.26 +             of the License, or (at your option) any later version.
    5.27 +
    5.28 +        This program is distributed in the hope that it will be useful,
    5.29 +         but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.30 +         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.31 +                  GNU General Public License for more details.
    5.32 +
    5.33 +
    5.34 +                          http://prog.marmaro.de/owls/
    5.35 +
    5.36 +-->
    5.37 +
    5.38 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    5.39 +
    5.40 +<html xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
    5.41 +<head>
    5.42 +  <title><?php echo htmlentities(TITLE); ?></title>
    5.43 +  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    5.44 +  <link rel="shortcut icon" href="favicon.ico" />
    5.45 +  <link rel="stylesheet" type="text/css" href="Owls.css.php" />
    5.46 +  <script type="text/javascript">
    5.47 +  <!--
    5.48 +    function sureToDelete(id) {
    5.49 +      if (window.prompt("Type 'delete' to delete","") == "delete") {
    5.50 +        location.href = id +"d";
    5.51 +      }
    5.52 +    }
    5.53 +
    5.54 +    
    5.55 +    function toggleVisibility(boxId) {
    5.56 +      if (document.getElementById('node'+ boxId).style.display == 'none') {
    5.57 +        document.getElementById('node'+ boxId).style.display = "";
    5.58 +        document.getElementById('ctrl'+ boxId).firstChild.nodeValue = "-";
    5.59 +      } else{
    5.60 +        document.getElementById('node'+ boxId).style.display = "none";
    5.61 +        document.getElementById('ctrl'+ boxId).firstChild.nodeValue = "+";
    5.62 +      }
    5.63 +    }
    5.64 +    
    5.65 +  //-->  
    5.66 +  </script>
    5.67 +</head>
    5.68 +
    5.69 +<body>
    5.70 +<div id="websiteContainer">
    5.71 +
    5.72 +  <!-- Banner -->
    5.73 +  <img src="Banner.png" id="banner" alt="<?php echo htmlentities(TITLE); ?>" />
    5.74 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/Includes/Loginsys.class.php	Sun Dec 03 22:32:13 2006 +0100
     6.3 @@ -0,0 +1,65 @@
     6.4 +<?php
     6.5 +
     6.6 +define('TIME_SESSION_EXPIRES', 1800);
     6.7 +
     6.8 +
     6.9 +class Loginsys {
    6.10 +
    6.11 +  // Constructors
    6.12 +
    6.13 +  public function __construct() {
    6.14 +    session_start();
    6.15 +    $this->heartbeat();
    6.16 +  }
    6.17 +
    6.18 +
    6.19 +
    6.20 +
    6.21 +  // Methods
    6.22 +
    6.23 +  public function login($loginname, $password_md5) {    // login ------------------------------------
    6.24 +    $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' "));
    6.25 +    if (mysql_affected_rows() == 1) {  // valid login
    6.26 +      $_SESSION[login][id] = $rowuser[id];
    6.27 +      $_SESSION[login][loginname] = $loginname;
    6.28 +      $_SESSION[login][logintime] = time();
    6.29 +    }
    6.30 +  }
    6.31 +
    6.32 +
    6.33 +
    6.34 +  public function logout() {    // logout ------------------------------------------------------------
    6.35 +    unset($_SESSION[login]);
    6.36 +  }
    6.37 +
    6.38 +
    6.39 +
    6.40 +  public function loggedIn() {    // return login-status ---------------------------------------------
    6.41 +    return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-TIME_SESSION_EXPIRES);
    6.42 +  }
    6.43 +
    6.44 +
    6.45 +
    6.46 +  public function heartbeat() {
    6.47 +    if ($this->loggedIn()) {
    6.48 +      $_SESSION[login][logintime] = time();
    6.49 +    }
    6.50 +  }
    6.51 +
    6.52 +
    6.53 +
    6.54 +  // Getter and Setter
    6.55 +
    6.56 +  public function getUserId() {
    6.57 +    return $_SESSION[login][id];
    6.58 +  }
    6.59 +
    6.60 +
    6.61 +  public function getLoginname() {
    6.62 +    return $_SESSION[login][loginname];
    6.63 +  }
    6.64 +
    6.65 +}
    6.66 +
    6.67 +
    6.68 +?>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/Includes/Nav.inc.php	Sun Dec 03 22:32:13 2006 +0100
     7.3 @@ -0,0 +1,86 @@
     7.4 +  <!-- Nav -->
     7.5 +  <ul id="nav">
     7.6 +
     7.7 +<?php
     7.8 +    // build nav tree
     7.9 +    echo '    '. navtree(0) ."\n";
    7.10 +
    7.11 +
    7.12 +    // find unmatched nodes (orphans)
    7.13 +    $sql = sprintf("
    7.14 +      select distinct
    7.15 +        idParent
    7.16 +      from %sOwls 
    7.17 +      where 
    7.18 +        idParent not in (select id from %sOwls) 
    7.19 +        and idParent != 0    -- not the real root
    7.20 +--        and idParent != id   -- avoid endless recursion
    7.21 +      order by name asc
    7.22 +      ",
    7.23 +      DB_PREFIX,
    7.24 +      DB_PREFIX
    7.25 +    );
    7.26 +    $result = mysql_query($sql) or die(mysql_error());
    7.27 +    unset($sql);
    7.28 +
    7.29 +    // output only if there are orphans
    7.30 +    if (mysql_num_rows($result)) {
    7.31 +      echo '    <li id="orphans">orphans<ul>';
    7.32 +      // output subtree for every orphan
    7.33 +      while($row = mysql_fetch_array($result)) {
    7.34 +        echo navtree($row['idParent']);
    7.35 +      }
    7.36 +      unset($row);
    7.37 +      mysql_free_result($result);
    7.38 +
    7.39 +      echo '</ul></li>';
    7.40 +    }
    7.41 +?>
    7.42 +
    7.43 +    <li id="login">
    7.44 +<?php
    7.45 +      if ($lsys->loggedIn()) {
    7.46 +        echo '    <a href="'. $_GET['id'] .'logout" style="color: #c00;">logout</a>';
    7.47 +      } else {
    7.48 +?>
    7.49 +      <form name="loginform" action="<?php echo $_GET['id']; ?>login" method="post" enctype="multipart/form-data">
    7.50 +        <input name="login_loginname" type="text" />
    7.51 +        <input name="login_password" type="password" />
    7.52 +        <input name="login" type="submit" value="login" style="padding: 0; cursor: pointer;" />
    7.53 +      </form>
    7.54 +<?php
    7.55 +      }
    7.56 +?>
    7.57 +    </li>
    7.58 +
    7.59 +  </ul>
    7.60 +
    7.61 +<?php
    7.62 +
    7.63 +    function navtree($root) {
    7.64 +      // fetch subcategories
    7.65 +      $result = mysql_query("select * from ". DB_PREFIX ."Owls where idParent = $root order by name asc");
    7.66 +
    7.67 +      $return = '';
    7.68 +      while($row = mysql_fetch_array($result)) {
    7.69 +        $return .= '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a>';
    7.70 +        if ($row['id'] != $row['idParent']) {
    7.71 +          $subtree = navtree($row['id']);
    7.72 +          if (!empty($subtree)) {
    7.73 +            $return .= '&nbsp;&nbsp;<a href="javascript:toggleVisibility(\''. $row[id] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>';
    7.74 +            $return .= '<ul id="node'. $row['id'] .'">'. $subtree .'</ul>';
    7.75 +          }
    7.76 +          unset($subtree);
    7.77 +        }
    7.78 +        $return .= '</li>';
    7.79 +      }
    7.80 +      unset($row);
    7.81 +      mysql_free_result($result);
    7.82 +
    7.83 +      // return
    7.84 +      return $return;
    7.85 +    }
    7.86 +
    7.87 +?>
    7.88 +
    7.89 +  <!-- Content -->
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/Owls.css.php	Sun Dec 03 22:32:13 2006 +0100
     8.3 @@ -0,0 +1,215 @@
     8.4 +<?php
     8.5 +  header('Content-Type: text/css; charset=utf8');
     8.6 +
     8.7 +  // Caching verhindern
     8.8 +  header('Expires: Thu, 05 Apr 1984 04:47:00 GMT');
     8.9 +  header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    8.10 +  header('Cache-Control: no-store');
    8.11 +  header('Pragma: no-cache');
    8.12 +  echo('/* Anti-Caching: '.microtime()." */\r\n");
    8.13 +
    8.14 +
    8.15 +  // colors
    8.16 +  $cProject           = '#96c';
    8.17 +
    8.18 +  $cBackgroundGlobal  = '#666';
    8.19 +  //$cBackgroundContent = '#666';  //eee
    8.20 +
    8.21 +  $cBorderGlobal      = '#000';
    8.22 +
    8.23 +  $cTextH1            = '#aaa';
    8.24 +
    8.25 +  $cLinkHover         = $cProject;
    8.26 +
    8.27 +  $cNav               = '#333';
    8.28 +
    8.29 +
    8.30 +  $mContentMinHeight  = '22em';
    8.31 +
    8.32 +  $mNavWidth          = '12em';
    8.33 +
    8.34 +
    8.35 +?>
    8.36 +
    8.37 +
    8.38 +
    8.39 +/*####  Standard  ############################################################*/
    8.40 +body {
    8.41 +  font-family: sans-serif;
    8.42 +  margin: 30px 0;
    8.43 +  text-align: center;
    8.44 +  background-color: <?php echo $cBackgroundGlobal ?>;
    8.45 +}
    8.46 +
    8.47 +
    8.48 +#websiteContainer {
    8.49 +  width: 760px;
    8.50 +  margin: 0 auto;
    8.51 +  text-align: left;
    8.52 +}
    8.53 +
    8.54 +#banner {
    8.55 +  display: block;
    8.56 +  border: 1px solid <?php echo $cBorderGlobal ?>;
    8.57 +}
    8.58 +
    8.59 +
    8.60 +#content {
    8.61 +  margin-left: <?php echo $mNavWidth; ?>;
    8.62 +  padding: 1em;
    8.63 +}
    8.64 +
    8.65 +
    8.66 +#edit input,
    8.67 +#edit select,
    8.68 +#edit textarea {
    8.69 +  font-family: sans-serif;
    8.70 +  font-size: 0.8em;
    8.71 +}
    8.72 +
    8.73 +
    8.74 +p {
    8.75 +  text-align: justify;
    8.76 +}
    8.77 +
    8.78 +
    8.79 +a {
    8.80 +  text-decoration: underline;
    8.81 +}
    8.82 +a:link {
    8.83 +  color: #000;
    8.84 +}
    8.85 +a:visited {
    8.86 +  color: #aaa;
    8.87 +}
    8.88 +a:active,
    8.89 +a:hover {
    8.90 +  color: <?php echo $cLinkHover; ?>;
    8.91 +}
    8.92 +
    8.93 +
    8.94 +img {
    8.95 +  border: none;
    8.96 +}
    8.97 +
    8.98 +.small {
    8.99 +  font-size: 0.8em;
   8.100 +}
   8.101 +
   8.102 +
   8.103 +
   8.104 +
   8.105 +
   8.106 +
   8.107 +
   8.108 +
   8.109 +
   8.110 +#nav {
   8.111 +  float: left;
   8.112 +  width: <?php echo $mNavWidth; ?>;
   8.113 +  padding: 0.5em 2em 1em 0.5em;
   8.114 +  margin: 2.5em 0 1em 0;
   8.115 +  font-size: 0.8em;
   8.116 +}
   8.117 +
   8.118 +#nav ul {
   8.119 +  padding-left: 1em;
   8.120 +/*  border: 1px solid #060; */
   8.121 +}
   8.122 +
   8.123 +#nav li {
   8.124 +  padding: 1px;
   8.125 +  margin: 0;
   8.126 +/*  border: 1px solid #006; */
   8.127 +}
   8.128 +
   8.129 +#nav a {
   8.130 +  text-decoration: none;
   8.131 +  color: <?php echo $cTextH1; ?>;
   8.132 +}
   8.133 +#nav a:link,
   8.134 +#nav a:visited {
   8.135 +  text-decoration: none;
   8.136 +}
   8.137 +#nav a:active,
   8.138 +#nav a:hover {
   8.139 +  color: <?php echo $cLinkHover; ?>;
   8.140 +  text-decoration: none;
   8.141 +}
   8.142 +
   8.143 +#selected:link,
   8.144 +#selected:visited {
   8.145 +  color: <?php echo $cBorderGlobal; ?>;
   8.146 +}
   8.147 +#nav #selected:hover {
   8.148 +  color: <?php echo $cLinkHover; ?>;
   8.149 +}
   8.150 +
   8.151 +
   8.152 +li#orphans {
   8.153 +  margin-top: 2em;
   8.154 +  font-style: italic;
   8.155 +  color: #aaa;
   8.156 +}
   8.157 +
   8.158 +li#login {
   8.159 +  margin-top: 3em;
   8.160 +}
   8.161 +#login input {
   8.162 +  background-color: transparent;
   8.163 +  border: none;
   8.164 +  border-left: #555 1px solid;
   8.165 +  display: block;
   8.166 +  font-size: 0.8em;
   8.167 +  margin-bottom: 2px;
   8.168 +  padding-left: 4px;
   8.169 +}
   8.170 +
   8.171 +
   8.172 +
   8.173 +
   8.174 +.ctrl {
   8.175 +  text-align: right;
   8.176 +  font-size: 0.8em;
   8.177 +}
   8.178 +.ctrl a {
   8.179 +  margin-left: 1em;
   8.180 +  color: #eee;
   8.181 +}
   8.182 +
   8.183 +
   8.184 +
   8.185 +
   8.186 +
   8.187 +
   8.188 +
   8.189 +
   8.190 +/*####  BBCode  ##############################################################*/
   8.191 +
   8.192 +.quote1 {
   8.193 +  border:1px solid #c0c0c0;
   8.194 +  margin:5px;
   8.195 +  padding:5px;
   8.196 +}
   8.197 +.quote2 {
   8.198 +  border:1px solid #c0c0c0;
   8.199 +  margin:5px;
   8.200 +  margin-bottom:0px;
   8.201 +  padding:5px;
   8.202 +}
   8.203 +.quote0 {
   8.204 +  color: #000;
   8.205 +  font-size: 0.8em;
   8.206 +}
   8.207 +
   8.208 +ul {
   8.209 +  list-style: none;
   8.210 +  margin-left: 0;
   8.211 +  padding-left: 1em;
   8.212 +}
   8.213 +li {
   8.214 +  margin-left: 1em;
   8.215 +  padding-left: 0;
   8.216 +  /*list-style-image: url(Pics/Bullet.gif);*/
   8.217 +}
   8.218 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/Owls.php	Sun Dec 03 22:32:13 2006 +0100
     9.3 @@ -0,0 +1,212 @@
     9.4 +<?php
     9.5 +  require_once 'Includes/Header.inc.php';
     9.6 +
     9.7 +
     9.8 +  if ($_GET['action'] == 'show') {    // show
     9.9 +    show($lsys);
    9.10 +
    9.11 +  } else if ($_GET['action'] == 'new' && $lsys->loggedIn()) {    // new
    9.12 +    create($lsys);
    9.13 +
    9.14 +  } else if ($_GET['action'] == 'edit' && $lsys->loggedIn()) {    // edit
    9.15 +    edit($lsys);
    9.16 +
    9.17 +  } else if ($_GET['action'] == 'delete' && $lsys->loggedIn()) {    // delete
    9.18 +    delete($lsys);
    9.19 +
    9.20 +  } else if ($_GET['action'] == 'login') {    // login
    9.21 +    $lsys->login($_POST['login_loginname'], md5($_POST['login_password']));
    9.22 +    show($lsys);
    9.23 +
    9.24 +  } else if ($_GET['action'] == 'logout') {    // logout
    9.25 +    $lsys->logout();
    9.26 +    show($lsys);
    9.27 +
    9.28 +  } else {    // startpage
    9.29 +    $_GET['id'] = 1;
    9.30 +    show($lsys);
    9.31 +
    9.32 +  }
    9.33 +
    9.34 +
    9.35 +  require_once 'Includes/Footer.inc.php';
    9.36 +
    9.37 +
    9.38 +
    9.39 +
    9.40 +
    9.41 +
    9.42 +
    9.43 +
    9.44 +
    9.45 +
    9.46 +
    9.47 +/*
    9.48 +    displays content of the node
    9.49 +    performs action 'edit'
    9.50 +    shows admincontrols if logged in
    9.51 +*/
    9.52 +function show($lsys) {
    9.53 +
    9.54 +  // perform action: write edited node to db
    9.55 +  if (isset($_POST['editDoc']) && $lsys->loggedIn()) {
    9.56 +    $_POST['editDoc_title'] = addslashes($_POST['editDoc_title']);
    9.57 +    $_POST['editDoc_text'] = addslashes($_POST['editDoc_text']);
    9.58 +    mysql_query("update ". DB_PREFIX ."Owls set
    9.59 +      name='$_POST[editDoc_title]',
    9.60 +      text='$_POST[editDoc_text]',
    9.61 +      idParent='$_POST[editDoc_idCategory]',
    9.62 +      date=". time() ."
    9.63 +    where id='$_GET[id]'") or die(mysql_error());
    9.64 +  }
    9.65 +
    9.66 +  // print nav
    9.67 +  include 'Includes/Nav.inc.php';
    9.68 +
    9.69 +
    9.70 +  // query data of the node
    9.71 +  $result = mysql_query("select * from ". DB_PREFIX ."Owls where id=$_GET[id]");
    9.72 +  
    9.73 +  // catch nodes that not exist
    9.74 +  if (!mysql_num_rows($result)) {
    9.75 +
    9.76 +    $fnord = array('',
    9.77 +      'Fnord is the space between the pixels on your screen.',
    9.78 +      'Fnord is the echo of silence.',
    9.79 +      'Fnord is evaporated herbal tea without the herbs.',
    9.80 +      'Fnord is what you see when you close your eyes.',
    9.81 +      'Fnord is the empty pages at the end of the book.',
    9.82 +      'Fnord is why ducks eat trees.',
    9.83 +      'Fnord is the bucket where they keep the unused serifs for H*lvetica.',
    9.84 +      'Fnord is the source of all the zero bits in your computer.'
    9.85 +    );
    9.86 +
    9.87 +?>
    9.88 +      <div id="content">
    9.89 +        <h2>Error 23 - fnord found</h2>
    9.90 +        <p>
    9.91 +          <?php echo $fnord[rand(0, sizeof($fnord)-1)]; ?>
    9.92 +        </p>
    9.93 +<?php
    9.94 +
    9.95 +  } else {
    9.96 +
    9.97 +    $row = mysql_fetch_array($result);
    9.98 +    echo '  <div id="content">'."\n";
    9.99 +
   9.100 +      // display admin controls if logged in
   9.101 +      if ($lsys->loggedIn()) {
   9.102 +?>
   9.103 +        <div class="ctrl" style="font-size: 0.8em;">
   9.104 +          <a href="<?php echo $row['id'] .'n'; ?>">new</a>
   9.105 +          <a href="<?php echo $row['id'] .'e'; ?>">edit</a>
   9.106 +<?php
   9.107 +          if ($row['id'] != 1) {
   9.108 +            echo '<a href="javascript:sureToDelete('. $row['id'] .')">delete</a>';
   9.109 +          }
   9.110 +?>
   9.111 +        </div>
   9.112 +<?php
   9.113 +      }
   9.114 +
   9.115 +    // print content of the node
   9.116 +    echo '    <h2>'.stripslashes($row['name']).'</h2>'."\n";
   9.117 +    if (!empty($row['text'])) {
   9.118 +      echo '    <p>'.bbcode(stripslashes($row['text']), 1, 1).'</p>';
   9.119 +    }
   9.120 +  }
   9.121 +  echo "\n\n";
   9.122 +
   9.123 +}
   9.124 +
   9.125 +
   9.126 +
   9.127 +
   9.128 +
   9.129 +/*
   9.130 +    displays edit form
   9.131 +*/
   9.132 +function edit($lsys) {
   9.133 +
   9.134 +    include 'Includes/Nav.inc.php';
   9.135 +
   9.136 +    $sql = "select * from ". DB_PREFIX ."Owls where id=$_GET[id]";
   9.137 +    $result = mysql_query($sql) or die(mysql_error());
   9.138 +    $row = mysql_fetch_array($result);
   9.139 +      echo '<div id="content">';
   9.140 +?>
   9.141 +<div id="edit">
   9.142 +  <form action="<?php echo $row['id']; ?>" method="post" enctype="multipart/form-data">
   9.143 +<?php
   9.144 +    if ($_GET['id'] != 1) {
   9.145 +?>
   9.146 +      <select name="editDoc_idCategory" style="width: 99%;">
   9.147 +<?php
   9.148 +      $result = mysql_query("select * from ". DB_PREFIX ."Owls order by name asc") or die(mysql_error());
   9.149 +      while($rowCats = mysql_fetch_array($result)) {
   9.150 +        echo '  <option value="'.$rowCats['id'].'"'. (($row['idParent'] == $rowCats['id']) ? ' selected="selected"' : '') .'>'.stripslashes($rowCats['name']).'</option>';
   9.151 +      }
   9.152 +?>
   9.153 +      </select><br /><br />
   9.154 +<?php
   9.155 +    }
   9.156 +?>
   9.157 +    <input name="editDoc_title" type="text" value="<?php echo stripslashes($row['name']); ?>" style="width: 99%;" /><br />
   9.158 +    <textarea name="editDoc_text" cols="60" rows="15" style="width: 99%; height: 30em;"><?php
   9.159 +      echo stripslashes($row['text']);
   9.160 +    ?></textarea><br /><br />
   9.161 +    <input name="editDoc" type="submit" value="edit" class="button" style="width: 99%;" />
   9.162 +  </form>
   9.163 +</div>
   9.164 +<?php
   9.165 +  unset($row);
   9.166 +  unset($result);
   9.167 +}
   9.168 +
   9.169 +
   9.170 +
   9.171 +
   9.172 +
   9.173 +
   9.174 +/*
   9.175 +    performs action 'new'
   9.176 +*/
   9.177 +function create($lsys) {
   9.178 +
   9.179 +  // perform action: new node
   9.180 +  mysql_query("
   9.181 +    insert into ". DB_PREFIX ."Owls
   9.182 +    (idParent, date)
   9.183 +    values('$_GET[id]',". time() .")
   9.184 +  ") or die(mysql_error());
   9.185 +
   9.186 +  // set node to jump to (new created node)
   9.187 +  $_GET['id'] = mysql_insert_id();
   9.188 +  edit($lsys);
   9.189 +}
   9.190 +
   9.191 +
   9.192 +
   9.193 +
   9.194 +
   9.195 +/*
   9.196 +    performs action 'delete'
   9.197 +*/
   9.198 +function delete($lsys) {
   9.199 +  // not allowed to delete the root
   9.200 +  if ($_GET['id'] != 1) {
   9.201 +    // TODO: get the parent of the one which is to delete
   9.202 +
   9.203 +    // delete
   9.204 +    mysql_query("delete from ". DB_PREFIX ."Owls where id='$_GET[id]'") or die(mysql_error());
   9.205 +  }
   9.206 +  // set node to jump to (TODO: parent from above)
   9.207 +  $_GET['id'] = 1;
   9.208 +  show($lsys);
   9.209 +}
   9.210 +
   9.211 +
   9.212 +
   9.213 +
   9.214 +?>
   9.215 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/Setup.php	Sun Dec 03 22:32:13 2006 +0100
    10.3 @@ -0,0 +1,52 @@
    10.4 +<?php
    10.5 +
    10.6 +// you can customize the config here
    10.7 +
    10.8 +$dbPrefix = 'rem__2_';    // the names of the db-tables will be prefixed with this string
    10.9 +
   10.10 +//$modifyProtected = true;    // are guests allowed to modify data? (true or false)
   10.11 +
   10.12 +$defaultUser = 'admin';    // useraccount if "modifyProtected = true" above
   10.13 +$defaultUserPassword = 'admin';    // password for useraccount if "modifyProtected = true" above
   10.14 +
   10.15 +
   10.16 +
   10.17 +// dont change anything form here on (except you know what you do)
   10.18 +//##################################################################
   10.19 +
   10.20 +  // write db-login-data to textfile
   10.21 +
   10.22 +
   10.23 +  // connect to db and create tables
   10.24 +  require('../Db.inc.php');
   10.25 +
   10.26 +
   10.27 +  // table 'Owls' for the content data
   10.28 +  mysql_query("
   10.29 +    CREATE TABLE IF NOT EXISTS `". $dbPrefix ."Owls` (
   10.30 +      `id` int(11) NOT NULL auto_increment,
   10.31 +      `idParent` int(11) default '0',
   10.32 +      `name` text NOT NULL,
   10.33 +      `text` longtext NOT NULL,
   10.34 +      `permission` tinyint(4) NOT NULL default '1',
   10.35 +      `date` int(11) NOT NULL default '0',
   10.36 +      PRIMARY KEY  (`id`)
   10.37 +    )
   10.38 +  ") or die(mysql_error());
   10.39 +
   10.40 +  // insert startup nodes
   10.41 +  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());
   10.42 +
   10.43 +
   10.44 +
   10.45 +  // login should be managed via text file in future
   10.46 +  mysql_query("CREATE TABLE IF NOT EXISTS `". $dbPrefix ."User` (
   10.47 +    `id` int(11) NOT NULL auto_increment,
   10.48 +    `loginname` tinytext NOT NULL,
   10.49 +    `password` tinytext NOT NULL,
   10.50 +    PRIMARY KEY  (`id`)
   10.51 +  )") or die(mysql_error());
   10.52 +
   10.53 +  mysql_query("INSERT INTO `". $dbPrefix ."User` VALUES (1, '". $defaultUser ."', '". md5($defaultUserPassword) ."')") or die(mysql_error());
   10.54 +
   10.55 +?>