owls

changeset 13:3e3fa7725abb

reorganized filesystem strukture
author meillo@marmaro.de
date Sun, 27 May 2007 02:37:55 +0200
parents 682b4a24469c
children cebc198276eb
files Bbcodeparser.inc.php Config.inc.php Config/Config.inc.php Includes/Bbcodeparser.inc.php Includes/Loginsys.class.php Includes/Nav.inc.php Loginsys.class.php Nav.inc.php Owls.php
diffstat 9 files changed, 369 insertions(+), 369 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Bbcodeparser.inc.php	Sun May 27 02:37:55 2007 +0200
     1.3 @@ -0,0 +1,123 @@
     1.4 +<?php
     1.5 +/**
     1.6 + * BB-Code-Parser
     1.7 + *
     1.8 + * @author Meillo  r e t u r n s <meillo@marmaro.de>
     1.9 + */
    1.10 +
    1.11 +
    1.12 +  /// path to smilies
    1.13 +  define('SMILIE_DIR', 'Smilies/');
    1.14 +
    1.15 +
    1.16 +
    1.17 +  /**
    1.18 +   * parses recursive quotes without a source mentioned
    1.19 +   *
    1.20 +   * @param $textinput the bbcode-text
    1.21 +   * @param $level number of levels to go inside
    1.22 +   * @return HTML-text
    1.23 +   */
    1.24 +  function parse_quote1($textinput,$level = 1) {
    1.25 +    $pattern = '#\[quote\](((?R)|(.*))*)\[/quote\]#isUe';
    1.26 +    $replacement = "'<br />[nl]<span class=\"quote0\">Zitat:</span>[nl]<div class=\"quote1\">[nl]'.parse_quote1('$1',
    1.27 +                     ". ($level + 1) ."
    1.28 +                   ).'[nl]</div>[nl]'";
    1.29 +    return preg_replace($pattern, $replacement, $textinput);
    1.30 +  }
    1.31 +
    1.32 +  /**
    1.33 +   * parses recursive quotes with a source mentioned
    1.34 +   *
    1.35 +   * @param $textinput the bbcode-text
    1.36 +   * @param $level number of levels to go inside
    1.37 +   * @return HTML-text
    1.38 +   */
    1.39 +  function parse_quote2($textinput,$level = 1) {
    1.40 +    $pattern = '#\[quote\=(.*)\](((?R)|(.*))*)\[/quote\]#isUe';
    1.41 +    $replacement = "'<br />[nl]<span class=\"quote0\">Zitat: ($1)</span>[nl]<div class=\"quote2\">[nl]'.parse_quote2('$2',
    1.42 +                     ". ($level + 1) ."
    1.43 +                   ).'[nl]</div>[nl]'";
    1.44 +    return preg_replace($pattern, $replacement, $textinput);
    1.45 +  }
    1.46 +
    1.47 +  /**
    1.48 +   * replaces smilies
    1.49 +   *
    1.50 +   * @param $text text with ASCII-smilies
    1.51 +   * @return text with [img]-smilies
    1.52 +   */
    1.53 +  function smilies($text) {
    1.54 +    $smilies = array( ':-)'        => 'Smile.gif',
    1.55 +                      ':)'         => 'Smile.gif',
    1.56 +                      ';-)'        => 'Wink.gif',
    1.57 +                      ';)'         => 'Wink.gif',
    1.58 +                      ':-D'        => 'Biggrin.gif',
    1.59 +                      ':D'         => 'Biggrin.gif',
    1.60 +                      ':-('        => 'Sad.gif',
    1.61 +                      ':('         => 'Sad.gif',
    1.62 +                      ':-P'        => 'Lick.gif',
    1.63 +                      ':P'         => 'Lick.gif',
    1.64 +                      ':o'         => 'Talk.gif',
    1.65 +                      ':-S'        => 'Dontknow.gif',
    1.66 +                      ':dontknow:' => 'Dontknow.gif',
    1.67 +                      ':-@'        => 'Angry.gif',
    1.68 +                      ':cool:'     => 'Cool.gif',
    1.69 +                      'B-)'        => 'Cool.gif',
    1.70 +                      '%-)'        => 'Crosseyed.gif',
    1.71 +                      '%-('        => 'Crosseyed.gif',
    1.72 +                      ':rolleyes:' => 'Rolleyes.gif',
    1.73 +                      ':eek:'      => 'Shocked.gif');
    1.74 +    while(list($key, $val) = each($smilies)) {
    1.75 +      $text = str_replace($key,'[img]'. SMILIE_DIR . $val .'[/img]', $text);
    1.76 +    }
    1.77 +    return $text;
    1.78 +  }
    1.79 +
    1.80 +
    1.81 +  /**
    1.82 +   * turns bbcode in HTML
    1.83 +   *
    1.84 +   * @param $text the text with bbcode inside
    1.85 +   * @param $smilies set to 1 causes smilies to be replaced with pics
    1.86 +   * @param $images set to 1 causes images to be displayed ([img]-tag)
    1.87 +   * @return text with HTML-code
    1.88 +   */
    1.89 +  function bbcode($text, $smilies = 0, $images = 0) {
    1.90 +
    1.91 +    // smilies
    1.92 +    if ($smilies == 1) {
    1.93 +      $text = smilies($text);
    1.94 +    }
    1.95 +
    1.96 +    // new-lines
    1.97 +    $text = preg_replace("#(\r\n)|(\r)#", "\n", $text);
    1.98 +    $text = str_replace("\n", '<br />[nl]', htmlentities($text));
    1.99 +
   1.100 +    // bold
   1.101 +    $text = preg_replace("#\[b\](.*?)\[/b\]#i", "<strong>$1</strong>", $text);
   1.102 +    // italic
   1.103 +    $text = preg_replace("#\[i\](.*?)\[/i\]#i", "<i>$1</i>", $text);
   1.104 +    // links
   1.105 +    $text = preg_replace("#\[url\](.*)\[/url\]#iU", "<a href=\"$1\">$1</a>", $text);
   1.106 +    $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU", "<a href=\"$1\">$2</a>", $text);
   1.107 +    // lists
   1.108 +      //$text = preg_replace("#\[list\]\<br /\>(.*)\[/list\]#iU", "<ul>$1</ul>", $text);
   1.109 +      //$text = preg_replace("#\[\*\](.*)\<br \/\>#iU", "<li>$1</li>", $text);
   1.110 +    // quotes
   1.111 +    $text = parse_quote1($text);
   1.112 +    $text = parse_quote2($text);
   1.113 +    // images
   1.114 +    if ($images == 1) {
   1.115 +      $text = preg_replace("#\[img\](.*?)\[/img\]#i", "<img src=\"$1\" alt=\"&lt;[Bild]&gt;\" />", $text);
   1.116 +    }
   1.117 +
   1.118 +    // remove backslashes
   1.119 +    $text = preg_replace("#\\\#is", "", $text);
   1.120 +    // new-lines
   1.121 +    $text = str_replace('[nl]', "\n", $text);
   1.122 +
   1.123 +    return $text;
   1.124 +  }
   1.125 +
   1.126 +?>
     2.1 --- a/Config.inc.php	Sun May 27 02:28:20 2007 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,12 +0,0 @@
     2.4 -<?php
     2.5 -
     2.6 -// Prefix for database tables (default: 'rem__')
     2.7 -$db_prefix = 'rem__1_';
     2.8 -
     2.9 -// Title of the website (default: 'Owls')
    2.10 -$title = 'Owls';
    2.11 -
    2.12 -// Location of the database connection script to include
    2.13 -$db_connect = '../../Db.inc.php';
    2.14 -
    2.15 -?>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/Config/Config.inc.php	Sun May 27 02:37:55 2007 +0200
     3.3 @@ -0,0 +1,12 @@
     3.4 +<?php
     3.5 +
     3.6 +// Prefix for database tables (default: 'rem__')
     3.7 +$db_prefix = 'rem__1_';
     3.8 +
     3.9 +// Title of the website (default: 'Owls')
    3.10 +$title = 'Owls';
    3.11 +
    3.12 +// Location of the database connection script to include
    3.13 +$db_connect = '../../Db.inc.php';
    3.14 +
    3.15 +?>
     4.1 --- a/Includes/Bbcodeparser.inc.php	Sun May 27 02:28:20 2007 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,123 +0,0 @@
     4.4 -<?php
     4.5 -/**
     4.6 - * BB-Code-Parser
     4.7 - *
     4.8 - * @author Meillo  r e t u r n s <meillo@marmaro.de>
     4.9 - */
    4.10 -
    4.11 -
    4.12 -  /// path to smilies
    4.13 -  define('SMILIE_DIR', 'Smilies/');
    4.14 -
    4.15 -
    4.16 -
    4.17 -  /**
    4.18 -   * parses recursive quotes without a source mentioned
    4.19 -   *
    4.20 -   * @param $textinput the bbcode-text
    4.21 -   * @param $level number of levels to go inside
    4.22 -   * @return HTML-text
    4.23 -   */
    4.24 -  function parse_quote1($textinput,$level = 1) {
    4.25 -    $pattern = '#\[quote\](((?R)|(.*))*)\[/quote\]#isUe';
    4.26 -    $replacement = "'<br />[nl]<span class=\"quote0\">Zitat:</span>[nl]<div class=\"quote1\">[nl]'.parse_quote1('$1',
    4.27 -                     ". ($level + 1) ."
    4.28 -                   ).'[nl]</div>[nl]'";
    4.29 -    return preg_replace($pattern, $replacement, $textinput);
    4.30 -  }
    4.31 -
    4.32 -  /**
    4.33 -   * parses recursive quotes with a source mentioned
    4.34 -   *
    4.35 -   * @param $textinput the bbcode-text
    4.36 -   * @param $level number of levels to go inside
    4.37 -   * @return HTML-text
    4.38 -   */
    4.39 -  function parse_quote2($textinput,$level = 1) {
    4.40 -    $pattern = '#\[quote\=(.*)\](((?R)|(.*))*)\[/quote\]#isUe';
    4.41 -    $replacement = "'<br />[nl]<span class=\"quote0\">Zitat: ($1)</span>[nl]<div class=\"quote2\">[nl]'.parse_quote2('$2',
    4.42 -                     ". ($level + 1) ."
    4.43 -                   ).'[nl]</div>[nl]'";
    4.44 -    return preg_replace($pattern, $replacement, $textinput);
    4.45 -  }
    4.46 -
    4.47 -  /**
    4.48 -   * replaces smilies
    4.49 -   *
    4.50 -   * @param $text text with ASCII-smilies
    4.51 -   * @return text with [img]-smilies
    4.52 -   */
    4.53 -  function smilies($text) {
    4.54 -    $smilies = array( ':-)'        => 'Smile.gif',
    4.55 -                      ':)'         => 'Smile.gif',
    4.56 -                      ';-)'        => 'Wink.gif',
    4.57 -                      ';)'         => 'Wink.gif',
    4.58 -                      ':-D'        => 'Biggrin.gif',
    4.59 -                      ':D'         => 'Biggrin.gif',
    4.60 -                      ':-('        => 'Sad.gif',
    4.61 -                      ':('         => 'Sad.gif',
    4.62 -                      ':-P'        => 'Lick.gif',
    4.63 -                      ':P'         => 'Lick.gif',
    4.64 -                      ':o'         => 'Talk.gif',
    4.65 -                      ':-S'        => 'Dontknow.gif',
    4.66 -                      ':dontknow:' => 'Dontknow.gif',
    4.67 -                      ':-@'        => 'Angry.gif',
    4.68 -                      ':cool:'     => 'Cool.gif',
    4.69 -                      'B-)'        => 'Cool.gif',
    4.70 -                      '%-)'        => 'Crosseyed.gif',
    4.71 -                      '%-('        => 'Crosseyed.gif',
    4.72 -                      ':rolleyes:' => 'Rolleyes.gif',
    4.73 -                      ':eek:'      => 'Shocked.gif');
    4.74 -    while(list($key, $val) = each($smilies)) {
    4.75 -      $text = str_replace($key,'[img]'. SMILIE_DIR . $val .'[/img]', $text);
    4.76 -    }
    4.77 -    return $text;
    4.78 -  }
    4.79 -
    4.80 -
    4.81 -  /**
    4.82 -   * turns bbcode in HTML
    4.83 -   *
    4.84 -   * @param $text the text with bbcode inside
    4.85 -   * @param $smilies set to 1 causes smilies to be replaced with pics
    4.86 -   * @param $images set to 1 causes images to be displayed ([img]-tag)
    4.87 -   * @return text with HTML-code
    4.88 -   */
    4.89 -  function bbcode($text, $smilies = 0, $images = 0) {
    4.90 -
    4.91 -    // smilies
    4.92 -    if ($smilies == 1) {
    4.93 -      $text = smilies($text);
    4.94 -    }
    4.95 -
    4.96 -    // new-lines
    4.97 -    $text = preg_replace("#(\r\n)|(\r)#", "\n", $text);
    4.98 -    $text = str_replace("\n", '<br />[nl]', htmlentities($text));
    4.99 -
   4.100 -    // bold
   4.101 -    $text = preg_replace("#\[b\](.*?)\[/b\]#i", "<strong>$1</strong>", $text);
   4.102 -    // italic
   4.103 -    $text = preg_replace("#\[i\](.*?)\[/i\]#i", "<i>$1</i>", $text);
   4.104 -    // links
   4.105 -    $text = preg_replace("#\[url\](.*)\[/url\]#iU", "<a href=\"$1\">$1</a>", $text);
   4.106 -    $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU", "<a href=\"$1\">$2</a>", $text);
   4.107 -    // lists
   4.108 -      //$text = preg_replace("#\[list\]\<br /\>(.*)\[/list\]#iU", "<ul>$1</ul>", $text);
   4.109 -      //$text = preg_replace("#\[\*\](.*)\<br \/\>#iU", "<li>$1</li>", $text);
   4.110 -    // quotes
   4.111 -    $text = parse_quote1($text);
   4.112 -    $text = parse_quote2($text);
   4.113 -    // images
   4.114 -    if ($images == 1) {
   4.115 -      $text = preg_replace("#\[img\](.*?)\[/img\]#i", "<img src=\"$1\" alt=\"&lt;[Bild]&gt;\" />", $text);
   4.116 -    }
   4.117 -
   4.118 -    // remove backslashes
   4.119 -    $text = preg_replace("#\\\#is", "", $text);
   4.120 -    // new-lines
   4.121 -    $text = str_replace('[nl]', "\n", $text);
   4.122 -
   4.123 -    return $text;
   4.124 -  }
   4.125 -
   4.126 -?>
     5.1 --- a/Includes/Loginsys.class.php	Sun May 27 02:28:20 2007 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,102 +0,0 @@
     5.4 -<?php
     5.5 -/**
     5.6 - * simple loginsystem for owls
     5.7 - *
     5.8 - * @brief simple loginsystem for owls
     5.9 - * @author Meillo  r e t u r n s <meillo@marmaro.de>
    5.10 - */
    5.11 -class Loginsys {
    5.12 -
    5.13 -  /// Consts
    5.14 -
    5.15 -  /**
    5.16 -   * time in seconds till the session expires
    5.17 -   */
    5.18 -  const TIME_SESSION_EXPIRES = 1800;
    5.19 -
    5.20 -
    5.21 -
    5.22 -  /// Constructors
    5.23 -
    5.24 -  /**
    5.25 -   * starts the session
    5.26 -   * and puts an activity timestamp in it
    5.27 -   */
    5.28 -  public function __construct() {
    5.29 -    session_start();
    5.30 -    $this->heartbeat();
    5.31 -  }
    5.32 -
    5.33 -
    5.34 -
    5.35 -
    5.36 -  /// Methods
    5.37 -
    5.38 -
    5.39 -  /**
    5.40 -   * trys to log in with the given login data
    5.41 -   *
    5.42 -   * @param $loginname username
    5.43 -   * @param $password_md5 md5 password hash
    5.44 -   */
    5.45 -  public function login($loginname, $password_md5) {    // login ------------------------------------
    5.46 -    $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' "));
    5.47 -    if (mysql_affected_rows() == 1) {  // valid login
    5.48 -      $_SESSION[login][id] = $rowuser[id];
    5.49 -      $_SESSION[login][loginname] = $loginname;
    5.50 -      $_SESSION[login][logintime] = time();
    5.51 -    }
    5.52 -  }
    5.53 -
    5.54 -
    5.55 -  /**
    5.56 -   * logs the user out
    5.57 -   */
    5.58 -  public function logout() {    // logout ------------------------------------------------------------
    5.59 -    unset($_SESSION[login]);
    5.60 -  }
    5.61 -
    5.62 -
    5.63 -  /**
    5.64 -   * proves if the user is logged in and if he wan't to long inactive
    5.65 -   *
    5.66 -   * @return bool 'true' if user is logged in, else 'false'
    5.67 -   */
    5.68 -  public function loggedIn() {    // return login-status ---------------------------------------------
    5.69 -    return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-self::TIME_SESSION_EXPIRES);
    5.70 -  }
    5.71 -
    5.72 -
    5.73 -  /**
    5.74 -   * writes the current timestamp into the session
    5.75 -   * this is relevant for the time of inactivity
    5.76 -   */
    5.77 -  public function heartbeat() {
    5.78 -    if ($this->loggedIn()) {
    5.79 -      $_SESSION[login][logintime] = time();
    5.80 -    }
    5.81 -  }
    5.82 -
    5.83 -
    5.84 -
    5.85 -  /// Getter and Setter
    5.86 -
    5.87 -
    5.88 -  /**
    5.89 -   * @return user id
    5.90 -   */
    5.91 -  public function getUserId() {
    5.92 -    return $_SESSION[login][id];
    5.93 -  }
    5.94 -
    5.95 -  /**
    5.96 -   * @return user name
    5.97 -   */
    5.98 -  public function getLoginname() {
    5.99 -    return $_SESSION[login][loginname];
   5.100 -  }
   5.101 -
   5.102 -}
   5.103 -
   5.104 -
   5.105 -?>
     6.1 --- a/Includes/Nav.inc.php	Sun May 27 02:28:20 2007 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,128 +0,0 @@
     6.4 -  <!-- Nav -->
     6.5 -  <ul id="nav">
     6.6 -
     6.7 -<?php
     6.8 -    // all nodes that are displayed in the nav
     6.9 -    global $nodesDisplayed;
    6.10 -    $nodesDisplayed = '';
    6.11 -
    6.12 -
    6.13 -    // build nav tree
    6.14 -    echo '    '. navtree(0) ."\n";
    6.15 -
    6.16 -
    6.17 -    // find nodes without existing parent (orphans)
    6.18 -    $sql = sprintf("
    6.19 -      select distinct
    6.20 -        idParent
    6.21 -      from %sOwls 
    6.22 -      where 
    6.23 -        idParent not in (select id from %sOwls) 
    6.24 -        and idParent != 0    -- not the real root
    6.25 -      order by name asc
    6.26 -      ",
    6.27 -      DB_PREFIX,
    6.28 -      DB_PREFIX
    6.29 -    );
    6.30 -    $result = mysql_query($sql) or die(mysql_error());
    6.31 -    unset($sql);
    6.32 -
    6.33 -    // output only if there are orphans
    6.34 -    if (mysql_num_rows($result)) {
    6.35 -      echo '    <li id="orphans">orphans<ul>';
    6.36 -      // output subtree for every orphan
    6.37 -      while($row = mysql_fetch_array($result)) {
    6.38 -        echo navtree($row['idParent']);
    6.39 -      }
    6.40 -      unset($row);
    6.41 -      mysql_free_result($result);
    6.42 -
    6.43 -      echo '</ul></li>'."\n";
    6.44 -    }
    6.45 -
    6.46 -
    6.47 -
    6.48 -    // find broken nodes - nodes not displayed in nav or orphans (i.e. rings)
    6.49 -    $sql = sprintf("
    6.50 -      select
    6.51 -        id, name
    6.52 -      from %sOwls 
    6.53 -      where 
    6.54 -        id not in ( %s )
    6.55 -      order by name asc
    6.56 -      ",
    6.57 -      DB_PREFIX,
    6.58 -      substr($nodesDisplayed, 2)
    6.59 -    );
    6.60 -    $result = mysql_query($sql) or die(mysql_error());
    6.61 -    unset($sql);
    6.62 -
    6.63 -    // output only if there are broken nodes
    6.64 -    if (mysql_num_rows($result)) {
    6.65 -      echo '    <li id="broken">broken<ul>';
    6.66 -      // output list of nodes (no tree, cause there may be rings!)
    6.67 -      while($row = mysql_fetch_array($result)) {
    6.68 -        echo '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a></li>';
    6.69 -      }
    6.70 -      unset($row);
    6.71 -      mysql_free_result($result);
    6.72 -
    6.73 -      echo '</ul></li>'."\n";
    6.74 -    }
    6.75 -
    6.76 -?>
    6.77 -
    6.78 -
    6.79 -  </ul>
    6.80 -
    6.81 -<?php
    6.82 -
    6.83 -
    6.84 -    /**
    6.85 -     * recursive function creates the output for the nav tree
    6.86 -     *
    6.87 -     * @param $root the id of the parent of the root node
    6.88 -     * @return string HTML output that shows the nav tree
    6.89 -     */
    6.90 -    function navtree($root) {
    6.91 -      // fetch subcategories
    6.92 -      $sql = sprintf("
    6.93 -        select
    6.94 -          id, idParent, name
    6.95 -        from %sOwls
    6.96 -        where
    6.97 -          idParent = $root
    6.98 -        order by name asc
    6.99 -        ",
   6.100 -        DB_PREFIX
   6.101 -      );
   6.102 -      $result = mysql_query($sql) or die(mysql_error());
   6.103 -      unset($sql);
   6.104 -
   6.105 -      $return = '';
   6.106 -      while($row = mysql_fetch_array($result)) {
   6.107 -        // add to list of displayed nodes
   6.108 -        global $nodesDisplayed;
   6.109 -        $nodesDisplayed .= ', '. $row['id'];
   6.110 -
   6.111 -        $return .= '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a>';
   6.112 -        if ($row['id'] != $row['idParent']) {
   6.113 -          $subtree = navtree($row['id']);
   6.114 -          if (!empty($subtree)) {
   6.115 -            #$return .= '&nbsp;&nbsp;<a href="javascript:toggleVisibility(\''. $row['id'] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>';
   6.116 -            $return .= '<ul id="node'. $row['id'] .'">'. $subtree .'</ul>';
   6.117 -          }
   6.118 -          unset($subtree);
   6.119 -        }
   6.120 -        $return .= '</li>';
   6.121 -      }
   6.122 -      unset($row);
   6.123 -      mysql_free_result($result);
   6.124 -
   6.125 -      // return
   6.126 -      return $return;
   6.127 -    }
   6.128 -
   6.129 -?>
   6.130 -
   6.131 -  <!-- Content -->
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/Loginsys.class.php	Sun May 27 02:37:55 2007 +0200
     7.3 @@ -0,0 +1,102 @@
     7.4 +<?php
     7.5 +/**
     7.6 + * simple loginsystem for owls
     7.7 + *
     7.8 + * @brief simple loginsystem for owls
     7.9 + * @author Meillo  r e t u r n s <meillo@marmaro.de>
    7.10 + */
    7.11 +class Loginsys {
    7.12 +
    7.13 +  /// Consts
    7.14 +
    7.15 +  /**
    7.16 +   * time in seconds till the session expires
    7.17 +   */
    7.18 +  const TIME_SESSION_EXPIRES = 1800;
    7.19 +
    7.20 +
    7.21 +
    7.22 +  /// Constructors
    7.23 +
    7.24 +  /**
    7.25 +   * starts the session
    7.26 +   * and puts an activity timestamp in it
    7.27 +   */
    7.28 +  public function __construct() {
    7.29 +    session_start();
    7.30 +    $this->heartbeat();
    7.31 +  }
    7.32 +
    7.33 +
    7.34 +
    7.35 +
    7.36 +  /// Methods
    7.37 +
    7.38 +
    7.39 +  /**
    7.40 +   * trys to log in with the given login data
    7.41 +   *
    7.42 +   * @param $loginname username
    7.43 +   * @param $password_md5 md5 password hash
    7.44 +   */
    7.45 +  public function login($loginname, $password_md5) {    // login ------------------------------------
    7.46 +    $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' "));
    7.47 +    if (mysql_affected_rows() == 1) {  // valid login
    7.48 +      $_SESSION[login][id] = $rowuser[id];
    7.49 +      $_SESSION[login][loginname] = $loginname;
    7.50 +      $_SESSION[login][logintime] = time();
    7.51 +    }
    7.52 +  }
    7.53 +
    7.54 +
    7.55 +  /**
    7.56 +   * logs the user out
    7.57 +   */
    7.58 +  public function logout() {    // logout ------------------------------------------------------------
    7.59 +    unset($_SESSION[login]);
    7.60 +  }
    7.61 +
    7.62 +
    7.63 +  /**
    7.64 +   * proves if the user is logged in and if he wan't to long inactive
    7.65 +   *
    7.66 +   * @return bool 'true' if user is logged in, else 'false'
    7.67 +   */
    7.68 +  public function loggedIn() {    // return login-status ---------------------------------------------
    7.69 +    return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-self::TIME_SESSION_EXPIRES);
    7.70 +  }
    7.71 +
    7.72 +
    7.73 +  /**
    7.74 +   * writes the current timestamp into the session
    7.75 +   * this is relevant for the time of inactivity
    7.76 +   */
    7.77 +  public function heartbeat() {
    7.78 +    if ($this->loggedIn()) {
    7.79 +      $_SESSION[login][logintime] = time();
    7.80 +    }
    7.81 +  }
    7.82 +
    7.83 +
    7.84 +
    7.85 +  /// Getter and Setter
    7.86 +
    7.87 +
    7.88 +  /**
    7.89 +   * @return user id
    7.90 +   */
    7.91 +  public function getUserId() {
    7.92 +    return $_SESSION[login][id];
    7.93 +  }
    7.94 +
    7.95 +  /**
    7.96 +   * @return user name
    7.97 +   */
    7.98 +  public function getLoginname() {
    7.99 +    return $_SESSION[login][loginname];
   7.100 +  }
   7.101 +
   7.102 +}
   7.103 +
   7.104 +
   7.105 +?>
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/Nav.inc.php	Sun May 27 02:37:55 2007 +0200
     8.3 @@ -0,0 +1,128 @@
     8.4 +  <!-- Nav -->
     8.5 +  <ul id="nav">
     8.6 +
     8.7 +<?php
     8.8 +    // all nodes that are displayed in the nav
     8.9 +    global $nodesDisplayed;
    8.10 +    $nodesDisplayed = '';
    8.11 +
    8.12 +
    8.13 +    // build nav tree
    8.14 +    echo '    '. navtree(0) ."\n";
    8.15 +
    8.16 +
    8.17 +    // find nodes without existing parent (orphans)
    8.18 +    $sql = sprintf("
    8.19 +      select distinct
    8.20 +        idParent
    8.21 +      from %sOwls 
    8.22 +      where 
    8.23 +        idParent not in (select id from %sOwls) 
    8.24 +        and idParent != 0    -- not the real root
    8.25 +      order by name asc
    8.26 +      ",
    8.27 +      DB_PREFIX,
    8.28 +      DB_PREFIX
    8.29 +    );
    8.30 +    $result = mysql_query($sql) or die(mysql_error());
    8.31 +    unset($sql);
    8.32 +
    8.33 +    // output only if there are orphans
    8.34 +    if (mysql_num_rows($result)) {
    8.35 +      echo '    <li id="orphans">orphans<ul>';
    8.36 +      // output subtree for every orphan
    8.37 +      while($row = mysql_fetch_array($result)) {
    8.38 +        echo navtree($row['idParent']);
    8.39 +      }
    8.40 +      unset($row);
    8.41 +      mysql_free_result($result);
    8.42 +
    8.43 +      echo '</ul></li>'."\n";
    8.44 +    }
    8.45 +
    8.46 +
    8.47 +
    8.48 +    // find broken nodes - nodes not displayed in nav or orphans (i.e. rings)
    8.49 +    $sql = sprintf("
    8.50 +      select
    8.51 +        id, name
    8.52 +      from %sOwls 
    8.53 +      where 
    8.54 +        id not in ( %s )
    8.55 +      order by name asc
    8.56 +      ",
    8.57 +      DB_PREFIX,
    8.58 +      substr($nodesDisplayed, 2)
    8.59 +    );
    8.60 +    $result = mysql_query($sql) or die(mysql_error());
    8.61 +    unset($sql);
    8.62 +
    8.63 +    // output only if there are broken nodes
    8.64 +    if (mysql_num_rows($result)) {
    8.65 +      echo '    <li id="broken">broken<ul>';
    8.66 +      // output list of nodes (no tree, cause there may be rings!)
    8.67 +      while($row = mysql_fetch_array($result)) {
    8.68 +        echo '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a></li>';
    8.69 +      }
    8.70 +      unset($row);
    8.71 +      mysql_free_result($result);
    8.72 +
    8.73 +      echo '</ul></li>'."\n";
    8.74 +    }
    8.75 +
    8.76 +?>
    8.77 +
    8.78 +
    8.79 +  </ul>
    8.80 +
    8.81 +<?php
    8.82 +
    8.83 +
    8.84 +    /**
    8.85 +     * recursive function creates the output for the nav tree
    8.86 +     *
    8.87 +     * @param $root the id of the parent of the root node
    8.88 +     * @return string HTML output that shows the nav tree
    8.89 +     */
    8.90 +    function navtree($root) {
    8.91 +      // fetch subcategories
    8.92 +      $sql = sprintf("
    8.93 +        select
    8.94 +          id, idParent, name
    8.95 +        from %sOwls
    8.96 +        where
    8.97 +          idParent = $root
    8.98 +        order by name asc
    8.99 +        ",
   8.100 +        DB_PREFIX
   8.101 +      );
   8.102 +      $result = mysql_query($sql) or die(mysql_error());
   8.103 +      unset($sql);
   8.104 +
   8.105 +      $return = '';
   8.106 +      while($row = mysql_fetch_array($result)) {
   8.107 +        // add to list of displayed nodes
   8.108 +        global $nodesDisplayed;
   8.109 +        $nodesDisplayed .= ', '. $row['id'];
   8.110 +
   8.111 +        $return .= '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a>';
   8.112 +        if ($row['id'] != $row['idParent']) {
   8.113 +          $subtree = navtree($row['id']);
   8.114 +          if (!empty($subtree)) {
   8.115 +            #$return .= '&nbsp;&nbsp;<a href="javascript:toggleVisibility(\''. $row['id'] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>';
   8.116 +            $return .= '<ul id="node'. $row['id'] .'">'. $subtree .'</ul>';
   8.117 +          }
   8.118 +          unset($subtree);
   8.119 +        }
   8.120 +        $return .= '</li>';
   8.121 +      }
   8.122 +      unset($row);
   8.123 +      mysql_free_result($result);
   8.124 +
   8.125 +      // return
   8.126 +      return $return;
   8.127 +    }
   8.128 +
   8.129 +?>
   8.130 +
   8.131 +  <!-- Content -->
     9.1 --- a/Owls.php	Sun May 27 02:28:20 2007 +0200
     9.2 +++ b/Owls.php	Sun May 27 02:37:55 2007 +0200
     9.3 @@ -6,8 +6,8 @@
     9.4    define('TITLE', $title);
     9.5  
     9.6    require_once $db_connect;
     9.7 -  require_once 'Includes/Loginsys.class.php';
     9.8 -  include_once 'Includes/Bbcodeparser.inc.php';
     9.9 +  require_once 'Loginsys.class.php';
    9.10 +  include_once 'Bbcodeparser.inc.php';
    9.11  
    9.12    $lsys = &new Loginsys();
    9.13  
    9.14 @@ -143,7 +143,7 @@
    9.15    }
    9.16  
    9.17    // print nav
    9.18 -  include 'Includes/Nav.inc.php';
    9.19 +  include 'Nav.inc.php';
    9.20  
    9.21  
    9.22  
    9.23 @@ -255,7 +255,7 @@
    9.24  */
    9.25  function edit($lsys) {
    9.26  
    9.27 -    include 'Includes/Nav.inc.php';
    9.28 +    include 'Nav.inc.php';
    9.29  
    9.30      $sql = "select * from ". DB_PREFIX ."Owls where id=$_GET[id]";
    9.31      $result = mysql_query($sql) or die(mysql_error());