Mercurial > owls
changeset 13:3e3fa7725abb
reorganized filesystem strukture
author | meillo@marmaro.de |
---|---|
date | Sun, 27 May 2007 02:37:55 +0200 (2007-05-27) |
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 wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Bbcodeparser.inc.php Sun May 27 02:37:55 2007 +0200 @@ -0,0 +1,123 @@ +<?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.inc.php Sun May 27 02:28:20 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +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'; - -?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Config/Config.inc.php Sun May 27 02:37:55 2007 +0200 @@ -0,0 +1,12 @@ +<?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'; + +?>
--- a/Includes/Bbcodeparser.inc.php Sun May 27 02:28:20 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/Includes/Loginsys.class.php Sun May 27 02:28:20 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/Includes/Nav.inc.php Sun May 27 02:28:20 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 -->
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Loginsys.class.php Sun May 27 02:37:55 2007 +0200 @@ -0,0 +1,102 @@ +<?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]; + } + +} + + +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Nav.inc.php Sun May 27 02:37:55 2007 +0200 @@ -0,0 +1,128 @@ + <!-- 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 02:28:20 2007 +0200 +++ b/Owls.php Sun May 27 02:37:55 2007 +0200 @@ -6,8 +6,8 @@ define('TITLE', $title); require_once $db_connect; - require_once 'Includes/Loginsys.class.php'; - include_once 'Includes/Bbcodeparser.inc.php'; + require_once 'Loginsys.class.php'; + include_once 'Bbcodeparser.inc.php'; $lsys = &new Loginsys(); @@ -143,7 +143,7 @@ } // print nav - include 'Includes/Nav.inc.php'; + include 'Nav.inc.php'; @@ -255,7 +255,7 @@ */ function edit($lsys) { - include 'Includes/Nav.inc.php'; + include 'Nav.inc.php'; $sql = "select * from ". DB_PREFIX ."Owls where id=$_GET[id]"; $result = mysql_query($sql) or die(mysql_error());