# HG changeset patch # User meillo@marmaro.de # Date 1180226275 -7200 # Node ID 3e3fa7725abb044e5ef884a066cf4114c44c550c # Parent 682b4a24469c0ea8a41e709ba131c36ea106f0fc reorganized filesystem strukture diff -r 682b4a24469c -r 3e3fa7725abb Bbcodeparser.inc.php --- /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 @@ + + */ + + + /// 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 = "'
[nl]Zitat:[nl]
[nl]'.parse_quote1('$1', + ". ($level + 1) ." + ).'[nl]
[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 = "'
[nl]Zitat: ($1)[nl]
[nl]'.parse_quote2('$2', + ". ($level + 1) ." + ).'[nl]
[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", '
[nl]', htmlentities($text)); + + // bold + $text = preg_replace("#\[b\](.*?)\[/b\]#i", "$1", $text); + // italic + $text = preg_replace("#\[i\](.*?)\[/i\]#i", "$1", $text); + // links + $text = preg_replace("#\[url\](.*)\[/url\]#iU", "$1", $text); + $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU", "$2", $text); + // lists + //$text = preg_replace("#\[list\]\
(.*)\[/list\]#iU", "", $text); + //$text = preg_replace("#\[\*\](.*)\
#iU", "
  • $1
  • ", $text); + // quotes + $text = parse_quote1($text); + $text = parse_quote2($text); + // images + if ($images == 1) { + $text = preg_replace("#\[img\](.*?)\[/img\]#i", "\"<[Bild]>\"", $text); + } + + // remove backslashes + $text = preg_replace("#\\\#is", "", $text); + // new-lines + $text = str_replace('[nl]', "\n", $text); + + return $text; + } + +?> diff -r 682b4a24469c -r 3e3fa7725abb Config.inc.php --- 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 @@ - diff -r 682b4a24469c -r 3e3fa7725abb Config/Config.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 @@ + diff -r 682b4a24469c -r 3e3fa7725abb Includes/Bbcodeparser.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 @@ - - */ - - - /// 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 = "'
    [nl]Zitat:[nl]
    [nl]'.parse_quote1('$1', - ". ($level + 1) ." - ).'[nl]
    [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 = "'
    [nl]Zitat: ($1)[nl]
    [nl]'.parse_quote2('$2', - ". ($level + 1) ." - ).'[nl]
    [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", '
    [nl]', htmlentities($text)); - - // bold - $text = preg_replace("#\[b\](.*?)\[/b\]#i", "$1", $text); - // italic - $text = preg_replace("#\[i\](.*?)\[/i\]#i", "$1", $text); - // links - $text = preg_replace("#\[url\](.*)\[/url\]#iU", "$1", $text); - $text = preg_replace("#\[url=(.*)\](.*)\[/url\]#iU", "$2", $text); - // lists - //$text = preg_replace("#\[list\]\
    (.*)\[/list\]#iU", "", $text); - //$text = preg_replace("#\[\*\](.*)\
    #iU", "
  • $1
  • ", $text); - // quotes - $text = parse_quote1($text); - $text = parse_quote2($text); - // images - if ($images == 1) { - $text = preg_replace("#\[img\](.*?)\[/img\]#i", "\"<[Bild]>\"", $text); - } - - // remove backslashes - $text = preg_replace("#\\\#is", "", $text); - // new-lines - $text = str_replace('[nl]', "\n", $text); - - return $text; - } - -?> diff -r 682b4a24469c -r 3e3fa7725abb Includes/Loginsys.class.php --- 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 @@ - - */ -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]; - } - -} - - -?> diff -r 682b4a24469c -r 3e3fa7725abb Includes/Nav.inc.php --- 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 @@ - - - -'. $row['name'] .''; - if ($row['id'] != $row['idParent']) { - $subtree = navtree($row['id']); - if (!empty($subtree)) { - #$return .= '  '; - $return .= ''; - } - unset($subtree); - } - $return .= ''; - } - unset($row); - mysql_free_result($result); - - // return - return $return; - } - -?> - - diff -r 682b4a24469c -r 3e3fa7725abb Loginsys.class.php --- /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 @@ + + */ +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]; + } + +} + + +?> diff -r 682b4a24469c -r 3e3fa7725abb Nav.inc.php --- /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 @@ + + + +'. $row['name'] .''; + if ($row['id'] != $row['idParent']) { + $subtree = navtree($row['id']); + if (!empty($subtree)) { + #$return .= '  '; + $return .= ''; + } + unset($subtree); + } + $return .= ''; + } + unset($row); + mysql_free_result($result); + + // return + return $return; + } + +?> + + diff -r 682b4a24469c -r 3e3fa7725abb Owls.php --- 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());