text:
<repo_name>Loopshape/WebCommunity<file_sep>/app/Http/Middleware/forum/mod_user.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_User extends Eloquent {

	public function __construct( ) {

		parent::__construct( );

		$this -> classStats = new Mod_Statistics;

	}

	public function getUsername( $catID, $topicID, $itemID, $userID = 0 ) {

		return $this -> readUsername( $catID, $topicID, $itemID, $userID );

	}

	public function userLogin( $userEmail, $userPass ) {

		return $this -> doLogin( $userEmail, $userPass );

	}

	public function userRights( $userEmail, $userPass ) {

		return $this -> checkRights( $userEmail, $userPass );

	}

	public function userRegister( $userName, $userEmail, $userPass, $adminMailSender = '', $adminMailReceiver = '' ) {

		return $this -> createUser( $userName, $userEmail, $userPass, $adminMailSender, $adminMailReceiver );

	}

	private function doLogin( $userEmail, $userPass ) {

		$query = DB::select( '
			SELECT *
			FROM `forum_users`
			WHERE `email` = "' . $userEmail . '"
			AND `password` = "' . md5( $<PASSWORD> ) . '"
			ORDER BY `email` ASC
			LIMIT 0,1;
		' );

		$result = $query;

		if( isset( $query[0] -> id ) ) {

			$this -> classStats -> setLogin( $query[0] -> id );

			Session::put('chatName', $query[0] -> name );
			Session::put('chatEmail', $query[0] -> email );

		}

		return array(
			'userName'			=>			( $result ) ? $result[0] -> name : 'Noname',
			'userEmail'			=>			( $result ) ? $result[0] -> email : '<EMAIL>',
			'userPass'			=>			( $result ) ? $result[0] -> password : '',
			'userID'			=>			( $result ) ? $result[0] -> id : null,
			'is_group'			=>			( $result ) ? $result[0] -> group : 3,
			'is_user'			=>			( $result ) ? true : false,
			'is_admin'			=>			( $result ) ? ( ( $result[0] -> group == 1 ) ? true : false ) : false,
		);

	}

	private function readUsername( $catID, $topicID, $itemID, $userID ) {

		$context = '';

		if( $userID == 0 ) {

			$query = DB::select( '
				SELECT user_id
				FROM `forum_posts`
				WHERE `id` = ' . $itemID . '
			' );
			$result = $query;

			if( $result ) {

				$userID = $result[0] -> user_id;

				$query1 = DB::select( '
					SELECT name
					FROM `forum_users`
					WHERE `id` = ' . $userID . '
				' );
				$result1 = $query1;

			}

		} else {

			$query1 = DB::select( '
				SELECT name
				FROM `forum_users`
				WHERE `id` = ' . $userID . '
			' );
			$result1 = $query1;

		}

		return ( $result1 ) ? $result1[0] -> name : 'User' ;

	}

	private function checkRights( $userEmail, $userPass ) {

		$status = false;

		$query = DB::select( '
			SELECT *
			FROM `forum_users`
			WHERE `email` = "' . $userEmail . '"
			AND `password` = "' . $userPass . '"
		' );

		$result = $query;

		if( $result ) $status = true;

		return $status;

	}

	private function createUser( $userName, $userEmail, $userPass, $adminMailSender, $adminMailReceiver ) {

		$queryx = DB::select( '
			SELECT `email`
			FROM `forum_users`
			WHERE `email` = "' . $userEmail . '"
		' );
		$resultx = $queryx;

		if( !$resultx ) {

			$query = DB::insert( '
				INSERT INTO `forum_users` (
					`id`,
					`name`,
					`email`,
					`password`,
					`group`,
					`crdate`,
					`hidden`
				) VALUES (
					null,
					"' . $userName . '",
					"' . $userEmail . '",
					"' . md5( $userPass ) . '",
					3,
					CURRENT_TIMESTAMP,
					"0"
				);
			' );

			if( $query ) {

				$to = '';

				// admin sender email
				$from = $adminMailSender;
				// BCC email to
				$copy = $adminMailReceiver;

				$subject = "Webforum Registration - http://" . $_SERVER['HTTP_HOST'] . "/";

				$message = '';
				$message .= '';
				$message .= '<meta charset="utf-8" />';
				$message .= '';
				$message .= '
Webforum Registration
';

				$message .= 'Dear ' . $userName . ',

				thank you for registering with the eMail: ' . $userEmail . ' !

				You are a member now.

				You can proceed to the login-page with this URL:

				http://' . $_SERVER['HTTP_HOST'] . '/community/

				Greetings from

				Arjuna aka the Webmaster
';

				$message .= '
';

				$message .= '';

				$headers  = "From: $from\r\n";
				$headers .= "To: " . $userEmail . "\r\n";
				$headers .= "BCC: $copy\r\n";
				$headers .= "MIME-Version: 1.0\r\n";
				$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

				mail($to,$subject,$message,$headers);

			}

		}

		return;

	}

}<file_sep>/public/lib/css/color.css
@charset "utf-8";

#page #container * {
	color: #334455 !important;
}

#page #flowmenu {
	background-color: #334455 !important;
}
#page #flowmenu .items li {
	background-color: #334455 !important;
	border-top-color: #445566 !important;
	border-bottom-color: #223344 !important;
}
#page #flowmenu .items li:hover:not(.headline) {
	background-color: #445566 !important;
}

#page #flowmenu .items li .sideItem {
	background-color: #334455 !important;
}

#page #flowmenu .items li .sideItem .arrow {
	border-right-color: #334455;
}

#page #infobar {
	background-color: #334455 !important;
}

#page #navi,
#page #footer {
background: -moz-linear-gradient(left, rgba(156,171,188,1) 0%, rgba(238,238,238,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(156,171,188,1)), color-stop(100%,rgba(238,238,238,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(156,171,188,1) 0%,rgba(238,238,238,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(156,171,188,1) 0%,rgba(238,238,238,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(156,171,188,1) 0%,rgba(238,238,238,0) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(156,171,188,1) 0%,rgba(238,238,238,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9cabbc', endColorstr='#00eeeeee',GradientType=1 ); /* IE6-9 */
}

#page #navi ul li {
	border-right-color: #99aabb !important;
}

#page input[type="submit"] {
	background-color: #99aabb !important;
}

#page .lightboxOverlay {
	background-color: rgba(0,16,32,0.8) !important;
}
<file_sep>/resources/views/impressum.blade.php
@extends('layout')

@section('impressum')

Impressum

§

					Verantwortlich für den Inhalt auf dieser Internetpräsenz:

<NAME>

					Anschrift:

					Holsteiner Chaussee 23

					22523 Hamburg

					GERMANY

					Phone: +49 (0)176 95749832

					E-Mail: <a href="mailto:<EMAIL>" title=""><EMAIL>

Haftungsausschluss

						Haftung für Inhalte

						Die Inhalte unserer Seiten wurden mit größter Sorgfalt erstellt. Für die Richtigkeit, Vollständigkeit und Aktualität der Inhalte können wir jedoch keine Gewähr übernehmen. Als Diensteanbieter sind wir gemäß § 7 Abs.1 TMG für eigene Inhalte auf diesen Seiten nach den allgemeinen Gesetzen verantwortlich. Nach §§ 8 bis 10 TMG sind wir als Diensteanbieter jedoch nicht verpflichtet, übermittelte oder gespeicherte fremde Informationen zu überwachen oder nach Umständen zu forschen, die auf eine rechtswidrige Tätigkeit hinweisen. Verpflichtungen zur Entfernung oder Sperrung der Nutzung von Informationen nach den allgemeinen Gesetzen bleiben hiervon unberührt. Eine diesbezügliche Haftung ist jedoch erst ab dem Zeitpunkt der Kenntnis einer konkreten Rechtsverletzung möglich. Bei Bekanntwerden von entsprechenden Rechtsverletzungen werden wir diese Inhalte umgehend entfernen.

						Haftung für Links

						Unser Angebot enthält Links zu externen Webseiten Dritter, auf deren Inhalte wir keinen Einfluss haben. Deshalb können wir für diese fremden Inhalte auch keine Gewähr übernehmen. Für die Inhalte der verlinkten Seiten ist stets der jeweilige Anbieter oder Betreiber der Seiten verantwortlich. Die verlinkten Seiten wurden zum Zeitpunkt der Verlinkung auf mögliche Rechtsverstöße überprüft. Rechtswidrige Inhalte waren zum Zeitpunkt der Verlinkung nicht erkennbar. Eine permanente inhaltliche Kontrolle der verlinkten Seiten ist jedoch ohne konkrete Anhaltspunkte einer Rechtsverletzung nicht zumutbar. Bei Bekanntwerden von Rechtsverletzungen werden wir derartige Links umgehend entfernen.

						Urheberrecht

						Die durch die Seitenbetreiber erstellten Inhalte und Werke auf diesen Seiten unterliegen dem deutschen Urheberrecht. Die Vervielfältigung, Bearbeitung, Verbreitung und jede Art der Verwertung außerhalb der Grenzen des Urheberrechtes bedürfen der schriftlichen Zustimmung des jeweiligen Autors bzw. Erstellers. Downloads und Kopien dieser Seite sind nur für den privaten, nicht kommerziellen Gebrauch gestattet. Soweit die Inhalte auf dieser Seite nicht vom Betreiber erstellt wurden, werden die Urheberrechte Dritter beachtet. Insbesondere werden Inhalte Dritter als solche gekennzeichnet. Sollten Sie trotzdem auf eine Urheberrechtsverletzung aufmerksam werden, bitten wir um einen entsprechenden Hinweis. Bei Bekanntwerden von Rechtsverletzungen werden wir derartige Inhalte umgehend entfernen.

						Datenschutz

						Die Nutzung unserer Webseite ist in der Regel ohne Angabe personenbezogener Daten möglich. Soweit auf unseren Seiten personenbezogene Daten (beispielsweise Name, Anschrift oder eMail-Adressen) erhoben werden, erfolgt dies, soweit möglich, stets auf freiwilliger Basis. Diese Daten werden ohne Ihre ausdrückliche Zustimmung nicht an Dritte weitergegeben.

						Wir weisen darauf hin, dass die Datenübertragung im Internet (z.B. bei der Kommunikation per E-Mail) Sicherheitslücken aufweisen kann. Ein lückenloser Schutz der Daten vor dem Zugriff durch Dritte ist nicht möglich.

						Der Nutzung von im Rahmen der Impressumspflicht veröffentlichten Kontaktdaten durch Dritte zur Übersendung von nicht ausdrücklich angeforderter Werbung und Informationsmaterialien wird hiermit ausdrücklich widersprochen. Die Betreiber der Seiten behalten sich ausdrücklich rechtliche Schritte im Falle der unverlangten Zusendung von Werbeinformationen, etwa durch Spam-Mails, vor.

						Quellverweis: eRecht24 Disclaimer

@stop

@section('header')

TECHCOMMUNITY

	<form action="" method="post">

			Account:

		<input class="memberName" type="text" name="memberEmail" value="eMail" />
		<input class="memberPass" type="password" name="memberPass" value="<PASSWORD>" />
		<input class="memberSubmit" name="memberSubmit" type="submit" value="Login">
	</form>

@stop

@section('worldmap')
@stop

@section('contentArea')

	@yield('header')

		@yield('impressum')

@stop

@section('content')

@yield('contentArea')

@stop<file_sep>/app/Http/Middleware/forum/mod_geolocation.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Geolocation extends Eloquent {

	public function __construct( ) {

		parent::__construct( );

		include_once (app_path( ) . "/third_party/phpwebyip2country/ip2country.php");

	}

	public function template( ) {
		return $this -> main( );
	}

	private function main( ) {

		$context = '';
		$ip2c = new ip2country( );
		$ip2c -> mysql_host = 'localhost';
		$ip2c -> db_user = 'root';
		$ip2c -> db_pass = '<PASSWORD>';
		$ip2c -> db_name = 'forum_database';
		$ip2c -> table_name = 'ip2c';
		$context .= 'Your country name is ' . $ip2c -> get_country_name( ) . '
';
		$context .= 'Your country code is ' . $ip2c -> get_country_code( );

		return $context;
	}

}
<file_sep>/resources/views/geolocation.blade.php

You've been successfully located.
<file_sep>/app/Http/Middleware/forum/mod_blogcore.php
<?php

class Mod_BlogCore extends Eloquent {

	public function __construct() {

	}

	public function readBlog( $userID = 0, $year = 0, $month = 0, $day = 0 ) {

		return $this -> getItems( $userID, $year, $month, $day );

	}

	public function searchBlog($searchString) {

		return $this -> searchString($searchString);

	}

	private function getItems( $userID, $year, $month, $day ) {

		$title = array();
		$date = array();
		$content = array();
		$postID = array();
		$max = 0;

		if( $userID == 0 ) {
			$query = DB::select( '
				SELECT *
				FROM `forum_posts`
				WHERE `user_id` != "0"
				AND `parent_id` = "0"
				AND `hidden` = "0"
				ORDER BY `update` DESC
			' );
		} else {
			$query = DB::select( '
				SELECT *
				FROM `forum_posts`
				WHERE `user_id` = "' . $userID . '"
				AND `parent_id` = "0"
				AND `hidden` = "0"
				ORDER BY `update` DESC
			' );
		}
		$result = $query;

		$i = 0;
		$ai = 0;
		foreach ( $result as $post ) {

			if ( $post -> hidden == 0 && $post -> parent_id == 0 ) {
				$postID[$ai] = $post -> id;
				$title[$ai] = $post -> title;
				$date[$ai] = $post -> update;
				$content[$ai] = $post -> subject;
				$ai++;
			}

			$i++;
		}
		$max = $ai - 1;

		return array($title, $date, $content, $postID, $max);

	}

	private function searchString($searchString) {

		$postID = array();
		$title = array();
		$date = array();
		$content = array();

		$query = DB::select('
			SELECT *
			FROM `forum_posts`
			WHERE `title` LIKE "%'.htmlspecialchars($searchString).'%"
			OR `subject` LIKE "%'.htmlspecialchars($searchString).'%"
		;');

		$i = 0;
		$ai = 0;
		foreach ($query->result() as $row) {
			if ($row -> post_status == 'publish') {

				$postID[$ai] = $row -> ID;
				$title[$ai] = $row -> post_title;
				$date[$ai] = $row -> post_date;
				$content[$ai] = $row -> post_content;

				$ai++;
			}
			$i++;
		}
		$max = $ai - 1;

		return array($title, $date, $content, $postID, $max);

	}

}
<file_sep>/app/Http/Middleware/forum/mod_post.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Post extends Eloquent {

	private $catID = 0;
	private $topicID = 0;
	private $itemID = 0;
	private $userID = 0;

	public function __construct( ) {

		parent::__construct( );

	}

	public function template( $catID, $topicID, $itemID, $userID ) {
		return $this -> main( $catID, $topicID, $itemID, $userID );
	}

	private function main( $catID, $topicID, $itemID, $userID ) {

		$context = '';

		if( $userID != 0 ) {

			$query = DB::select( '
				SELECT *
				FROM `forum_users`
				WHERE `id` = ' . $userID . '
			' );

			$result = $query;

			if( $result ) {

				$userArr = $result[0];

				$context .= '

';

				$context .= '
Member Settings
';

				$context .= '
';

				$context .= '<form action="" method="post">';

				$context .= 'picture:';
				$context .= '';

				$context .= 'real name:';
				$context .= '<input name="profileRealname" class="profileRealname" value="" />';

				$context .= 'birthday:';
				$context .= '<input name="profileBirthday" class="profileBirthday" value="" />';

				$context .= 'address:';
				$context .= '<textarea name="profileAddress" class="profileAddress"></textarea>';

				$context .= '</form>';

				$context .= '
';

				$context .= '

';

			}

		}

		return $context;
	}

}<file_sep>/app/Http/Middleware/forum/mod_pages.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Pages extends Eloquent {

	public function __construct( ) {

		parent::__construct( );

	}

	public function template( ) {
		return $this -> main();
	}

	private function main( ) {

		$context = '';

		$context .= View::make('showscreen');

		return $context;
	}

}<file_sep>/app/Http/Middleware/forum/mod_message.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Message extends Eloquent {

	public function __construct( ) {

		parent::__construct( );

	}

	public function start( ) {

		return;
	}

}<file_sep>/app/Http/Middleware/forum/mod_timetable.php
<?php

class Mod_Timetable extends Eloquent {

	public function __construct() {

		$this -> blog = new Mod_BlogCore;

		$this -> relMonth = 0;

		if ( Input::has('relMonth') ) {

			$this -> relMonth = htmlspecialchars( Input::get('relMonth') );

		} else {

			$this -> relMonth = 0;

		}

	}

	public function monthName($index) {

		$months = array('January', 'February', 'Märch', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'Dezember');

		return $months[$index - 1];

	}

	public function outputTimetable( $userID = 0, $year = 0, $month = 0, $day = 0, $single = false ) {

		if( !$single ) {
			$field = $this -> blog -> readBlog( 0, $year, $month, $day );
		} else {
			$field = $this -> blog -> readBlog( $userID, $year, $month, $day );
		}

		$firstRun = false;

		$eventArr = array();
		$this -> title = '';
		$this -> titleArr = array();
		$row = 0;
		$this -> fix = false;
		$save = array();

		$this -> subContent = '';

		$hour = (int)0;
		$minute = (int)0;
		$second = (int)0;

		$year = (int) date('Y', time());

		$month = (int)(date('m', time()) + $this -> relMonth);
		if ($month < 1) {
			$month = 12;
			$year--;
		}
		if ($month > 12) {
			$month = 1;
			$year++;
		}
		$month = ($month < 10) ? '0' . $month : $month;
		$day = (int) date('d', time());

		$weekName = 0;

		$context = '
' . $this -> monthName($month) . ' ' . $year . '

';

		$context .= '

';

		$context .= '
';

		$maxDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);

		$context .= '
';

		for ($i = 1; $i <= $maxDays; $i++) {

			$timestamp = (int) mktime($hour, $minute, $second, $month, $i, $year);

			$timeDay = ($i < 10) ? '0' . $i : $i;
			$timeMonth = (int) date('m', $timestamp);
			$timeMonth = ($timeMonth < 10) ? '0' . $timeMonth : $timeMonth;
			$timeYear = (int) date('Y', $timestamp);

			$weekName = date('w', $timestamp);
			if ($row > 6) {
				$row = 0;
			}

			$context .= '
';

			$countItem = 0;
			$this -> fix = false;
			$this -> title = '';

			foreach ($field[1] as $item) {

				$eventArr['item'] = substr($item, 0, 10);

				$event = $timeYear . '-' . $timeMonth . '-' . $timeDay;

				if (substr($eventArr['item'], 0, 4) == $timeYear && substr($eventArr['item'], 5, 2) == $timeMonth && substr($eventArr['item'], 8, 10) == $i) {

					$this -> fix = true;

					if (substr($eventArr['item'], 0, 4) == substr($eventBuffer, 0, 4) && substr($eventArr['item'], 5, 2) == substr($eventBuffer, 5, 2) && substr($eventArr['item'], 8, 10) == substr($eventBuffer, 8, 10)) {

						$this -> title .= '

	' . $field[0][$countItem] . '

';

					} else {

						$this -> title = '

	' . $field[0][$countItem] . '

';

					}

				}

				$eventBuffer = $eventArr['item'];

				$countItem++;

			}

			if ($i == date('d', time()) && $timeMonth == date('m', time()) && $timeYear == date('Y', time())) {

				$context .= ($this -> fix) ? ' title . '" class="hastip" target="_self">' . $i . '' : '' . $i . '';

			} else {

				$context .= ($this -> fix) ? ' title . '" class="hastip" target="_self">' . $i . '' : '' . $i . '';

			}

			switch( $weekName ) {
				case 1 :
					$context .= 'Mon';
					break;
				case 2 :
					$context .= 'Tue';
					break;
				case 3 :
					$context .= 'Wed';
					break;
				case 4 :
					$context .= 'Thu';
					break;
				case 5 :
					$context .= 'Fri';
					break;
				case 6 :
					$context .= 'Sat';
					break;
				case 0 :
					$context .= 'Sun';
					break;
			}

			if( $single && $userID != 0 ) {

				$query = DB::select('
					SELECT COUNT(*) AS `cnt`
					FROM `forum_posts`
					WHERE `user_id` = "' . $userID . '"
					AND `update` >= "' . $timeYear . '-' . $timeMonth . '-' . $timeDay . ' 00:00:00"
					AND `update` <= "' . $timeYear . '-' . $timeMonth . '-' . $timeDay . ' 23:59:59"
					AND `parent_id` = "0"
					AND `hidden` = "0"
				');
				$context .= 'You: ' . $query[0] -> cnt . '';

				$query = DB::select('
					SELECT COUNT(*) AS `cnt`
					FROM `forum_posts`
					WHERE `user_id` != "' . $userID . '"
					AND `update` >= "' . $timeYear . '-' . $timeMonth . '-' . $timeDay . ' 00:00:00"
					AND `update` <= "' . $timeYear . '-' . $timeMonth . '-' . $timeDay . ' 23:59:59"
					AND `parent_id` = "0"
					AND `hidden` = "0"
				');
				$context .= 'Other: ' . $query[0] -> cnt . '';

				$query = DB::select('
					SELECT COUNT(*) AS `cnt`
					FROM `forum_posts`
					WHERE `update` >= "' . $timeYear . '-' . $timeMonth . '-' . $timeDay . ' 00:00:00"
					AND `update` <= "' . $timeYear . '-' . $timeMonth . '-' . $timeDay . ' 23:59:59"
					AND `parent_id` = "0"
					AND `hidden` = "0"
				');
				$context .= 'All: ' . $query[0] -> cnt . '';

			}

			$row++;

			$context .= '
';

		}
		$context .= '
';

		$context .= '
';

		return $context;
	}

}
<file_sep>/public/lib/js/ajax.js
$(document).ready(function() {

	var showScreen = $('#showScreen');

	var delay = 1000;

	function doRequest( ) {

		$.post( BASE + 'show_screen', {},
		function(data) {
			showScreen.html(data);
		});

	}

});
<file_sep>/resources/views/ajax.blade.php

Ya're AJAX NOW
<file_sep>/resources/views/template.blade.php
@extends('layout')

@section('header')

TECHCOMMUNITY

	<form action="" method="post">

			Account:

		<input class="memberName" type="text" name="memberEmail" value="eMail" />
		<input class="memberPass" type="password" name="memberPass" value="<PASSWORD>" />
		<input class="memberSubmit" name="memberSubmit" type="submit" value="Login">
	</form>

@stop

@section('worldmap')
@stop

@section('contentArea')
{{ $contentData }}
@stop

@section('content')

	@yield('contentArea')

@stop<file_sep>/public/lib/js/motion.js
$(document).ready(function() {

	var page = $('#page > .wrapper');

	var delay = 1000;

	var screenHeight = $(document).height();

	$('#page > .wrapper').css('opacity', '0.99');
	$('#page #pageLoader').fadeOut(delay);

	$('#page a').each(function() {
		$(this).addClass('clickLoader');
	});

	$('.clickLoader').on(multitouch, function() {
		$('#page #pageLoader').show();
	});

	var worldMap = $('#worldCanvas');

	var xPos = 0;
	var yPos = $(window).height()/8;

	$('body').mousemove(function(e) {
		xPos = e.pageX;
		yPos = e.pageY;
		worldMap.css({
			'left': $(this).width/2 + xPos,
			'top': $(this).height/2 + yPos
		});
	});

	worldMap.css({
		'position': 'fixed',
		'opacity': '0.1',
'-moz-transform': 'scale(2) rotate(0deg) translateX(' + xPos + 'px) translateY(' + yPos + 'px) skewX(0deg) skewY(0deg)',
'-webkit-transform': 'scale(2) rotate(0deg) translateX(' + xPos + 'px) translateY(' + yPos + 'px) skewX(0deg) skewY(0deg)',
'-o-transform': 'scale(2) rotate(0deg) translateX(' + xPos + 'px) translateY(' + yPos + 'px) skewX(0deg) skewY(0deg)',
'-ms-transform': 'scale(2) rotate(0deg) translateX(' + xPos + 'px) translateY(' + yPos + 'px) skewX(0deg) skewY(0deg)',
'transform': 'scale(2) rotate(0deg) translateX(' + xPos + 'px) translateY(' + yPos + 'px) skewX(0deg) skewY(0deg)'
	});

});<file_sep>/app/Http/Middleware/forum/mod_profile.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Profile extends Eloquent {

	public function __construct( ) {

		parent::__construct( );

		$this -> classTimetable = new Mod_Timetable;

	}

	public function template( $userID ) {
		return $this -> main( $userID );
	}

	private function main( $userID ) {

		$context = '';

		if( $userID != 0 ) {

			$query = DB::select( '
				SELECT *
				FROM `forum_users`
				WHERE `id` = ' . $userID . '
			' );

			$result = $query;

			if( $result ) {

				$userArr = $result[0];

				$context .= '

';

				$context .= '
';

				$context .= '

';

				$context .= '
UserProfile
';

				$context .= '<form action="" method="post">';

				$context .= 'picture:';
				$context .= '';

				$context .= 'real name:';
				$context .= '<input name="profileRealname" class="profileRealname" value="" />';

				$context .= 'birthday:';
				$context .= '<input name="profileBirthday" class="profileBirthday" value="" />';

				$context .= 'address:';
				$context .= '<textarea name="profileAddress" class="profileAddress"></textarea>';

				$context .= 'website:';
				$context .= '<input name="profileWebsite" class="profileWebsite" value="" />';

				$context .= '</form>';

				$context .= $this -> classTimetable -> outputTimetable( $userID, 0, 0, 0, 1 );

				$context .= '
';

			}

		}

		return $context;
	}

}<file_sep>/app/Http/Middleware/forum/mod_chat.php
<?php

class Mod_Chat extends ChatBase {

	private $userName = '';
	private $userEmail = '';
	private $userPass = '';
	private $userID = null;
	private $user = false;
	private $group = 3;
	private $admin = false;
	private $groupAdmin = 1;

	public static function __construct( ) {

		parent::__construct( );

		// check if session available
		if( $this -> session -> userdata( 'userName' ) ) {
			if( $this -> session -> userdata( 'userName' ) ) $this -> userName = $this -> session -> userdata( 'userName' );
			if( $this -> session -> userdata( 'userEmail' ) ) $this -> userEmail = $this -> session -> userdata( 'userEmail' );
			if( $this -> session -> userdata( 'userPass' ) ) $this -> userPass = $this -> session -> userdata( 'userPass' );
			if( $this -> session -> userdata( 'userID' ) ) $this -> userID = $this -> session -> userdata( 'userID' );
			if( $this -> session -> userdata( 'is_user' ) ) $this -> user = $this -> session -> userdata( 'is_user' );
			if( $this -> session -> userdata( 'is_group' ) ) $this -> group = $this -> session -> userdata( 'is_group' );
			if( $this -> user != 0 && $this -> group == $this -> groupAdmin ) $this -> admin = $this -> session -> userdata( 'is_admin' );
		}

	}

	public function chatMain( ) {
	}

	public function chatSide( ) {
	}

	public function chatActive( ) {

		return $this -> user;

	}

}
<file_sep>/app/Http/Controllers/SystemController.php
<?php

class SystemController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> forumList();
		return View::make('template')->with('contentData', $view);
	}

	public function showScreen()
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Pages;
		$view = $core -> template();
		return $view;
	}

	public function admin()
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> administration();
		return View::make('template')->with('contentData', $view);
	}

	public function showPostList( $catID = 0, $topicID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> showPostList( $catID, $topicID );
		return View::make('template')->with('contentData', $view);
	}

	public function showPostDetail( $catID = 0, $topicID = 0, $itemID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> showPostDetail( $catID, $topicID, $itemID );
		return View::make('template')->with('contentData', $view);
	}

	public function show_date( $year = 0, $month = 0, $day = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> forumList( $year, $month, $day );
		return View::make('template')->with('contentData', $view);
	}

	public function create_post( $catID = 0, $topicID = 0, $itemID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> createPost( $catID, $topicID );
		return View::make('template')->with('contentData', $view);
	}

	public function edit_post( $catID = 0, $topicID = 0, $itemID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> editPost( $catID, $topicID, $itemID );
		return View::make('template')->with('contentData', $view);
	}

	public function delete_post( $catID = 0, $topicID = 0, $itemID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> deletePost( $catID, $topicID, $itemID );
		return View::make('template')->with('contentData', $view);
	}

	public function answer_post( $catID = 0, $topicID = 0, $itemID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> answerPost( $catID, $topicID, $itemID );
		return View::make('template')->with('contentData', $view);
	}

	public function manage_answers( $catID = 0, $topicID = 0, $itemID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> manageAnswers( $catID, $topicID, $itemID );
		return View::make('template')->with('contentData', $view);
	}

	public function edit_answer( $catID = 0, $topicID = 0, $itemID = 0, $answerID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> editAnswer( $catID, $topicID, $itemID, $answerID );
		return View::make('template')->with('contentData', $view);
	}

	public function delete_answer( $catID = 0, $topicID = 0, $itemID = 0, $answerID = 0 )
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> deleteAnswer( $catID, $topicID, $itemID, $answerID );
		return View::make('template')->with('contentData', $view);
	}

	public function createAccount()
	{
		require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> createAccount();
		return View::make('template')->with('contentData', $view);
	}

	public function showImpressum()
	{
		return View::make('impressum')->with('contentData', '');
	}

/*
 * STANDARD MISSING CONTROLLER FUNCTION
 * ------------------------------------------------------------------------------------------
 */

	public function missingMethod($parameters)
	{
	    require app_path() . '/models/forum/mod_forum.php';
		$core = new Mod_Forum;
		$view = $core -> forumList();
		return View::make('template')->with('contentData', $view);
	}

}<file_sep>/resources/views/layout.blade.php
<!DOCTYPE html>

		<meta charset="utf-8">

		<base href="http://<?php echo $_SERVER['HTTP_HOST'] ?>/community/">
		<title>TechCommunity • A System for the good things</title>

		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=yes">
		<meta name="format-detection" content="telephone=no" />

		<link href="/lib/css/reset.css" rel="stylesheet" />
		<link href="/lib/css/style_blue.css" rel="stylesheet" />
		<link href="/lib/js/stroll.js-master/css/stroll.min.css" rel="stylesheet" />
		<link href="/lib/css/ajax-chat/css/chat.css" rel="stylesheet" />
		<link href="/lib/css/forum_blue.css" rel="stylesheet" />
		<link href="/lib/css/deco_blue.css" rel="stylesheet" />
		<link href="/lib/css/timetable.css" rel="stylesheet" />

		<link href="../assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
		<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
		<link rel="icon" href="../favicon.ico" type="image/x-icon">

		<meta property="og:title" content="TechCommunity • An Archive for the Good Things..." />
		<meta property="og:description" content="Interactive User-Content Webforum/Archive" />
		<meta property="og:type" content="article" />
		<meta property="og:image" content="http://showcase.loopshape.com/assets/screeny.png" />
		<meta property="og:url" content="http://showcase.loopshape.com/community/" />

						@yield('content')

							§ Impressum

							Forum coded by <NAME> - http://loopshape.com/

							Powered by Laravel

							Editor by TinyMCE

							WorldMap by Wikimedia Commons

							Charts by Chart.js

							Font by FontAwesome

<?php
	if( preg_match('/^webforum\.awebgo\.net/', $_SERVER['HTTP_HOST']) ) {
?>

<?php
	}
?>

<file_sep>/routes/routes.php
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::post('/show_screen',	 																'SystemController@showScreen');

Route::resource('/community/forum/impressum',												'SystemController@showImpressum');
Route::resource('/community/forum/register',												'SystemController@createAccount');

Route::resource('/community/forum/edit',													'SystemController@admin');
Route::resource('/community/forum/save',													'SystemController@index');

Route::resource('/community/forum/create_category',											'SystemController@create_cat');
Route::resource('/community/forum/delete_category/{catID}/',								'SystemController@delete_cat');

Route::resource('/community/forum/create_topic',											'SystemController@create_cat');
Route::resource('/community/forum/delete_topic/{catID}/{topicID}/',							'SystemController@delete_cat');

Route::resource('/community/forum/create_post/{catID}/{topicID}/{itemID}/',					'SystemController@create_post');

Route::resource('/community/forum/answer_post/{catID}/{topicID}/{itemID}/',					'SystemController@answer_post');
Route::resource('/community/forum/edit_post/{catID}/{topicID}/{itemID}/',					'SystemController@edit_post');
Route::resource('/community/forum/delete_post/{catID}/{topicID}/{itemID}/',					'SystemController@delete_post');

Route::resource('/community/forum/manage_answers/{catID}/{topicID}/{itemID}/',				'SystemController@manage_answers');
Route::resource('/community/forum/answer_edit/{catID}/{topicID}/{itemID}/{answerID}/',		'SystemController@edit_answer');
Route::resource('/community/forum/answer_remove/{catID}/{topicID}/{itemID}/{answerID}/',	'SystemController@delete_answer');

Route::resource('/community/forum/topic/{catID}/{topicID}/',								'SystemController@showPostList');
Route::resource('/community/forum/detail/{catID}/{topicID}/{itemID}/',						'SystemController@showPostDetail');
Route::resource('/community/forum/date/{year}/{month}/{day}/',								'SystemController@show_date');

Route::resource('/community/forum',															'SystemController@index');
Route::resource('/community', 																'SystemController@index');
Route::resource('/', 																		'SystemController@index');

/*

$route['forum']										= "forum/cnt_forum";

$route['forum/date/(:num)/(:any)']					= "forum/cnt_forum/goto_date/$1/$2/$3";

$route['forum/impressum']							= "forum/cnt_forum/impressum";

$route['forum/register']							= "forum/cnt_forum/register";

$route['forum/edit']								= "forum/cnt_forum/edit";
$route['forum/save']								= "forum/cnt_forum/save";

$route['forum/create_category']						= "forum/cnt_forum/create_cat";
$route['forum/delete_category/(:num)']				= "forum/cnt_forum/delete_cat/$1";

$route['forum/create_topic/(:num)']					= "forum/cnt_forum/create_topic/$1";
$route['forum/delete_topic/(:num)/(:any)']			= "forum/cnt_forum/delete_topic/$1/$2";

$route['forum/create_post/(:num)/(:any)']			= "forum/cnt_forum/create_post/$1/$2";

$route['forum/answer_post/(:num)/(:any)']			= "forum/cnt_forum/answer_post/$1/$2/$3";
$route['forum/edit_post/(:num)/(:any)']				= "forum/cnt_forum/edit_post/$1/$2/$3";
$route['forum/delete_post/(:num)/(:any)']			= "forum/cnt_forum/delete_post/$1/$2/$3";

$route['forum/manage_answers/(:num)/(:any)']		= "forum/cnt_forum/manage_answers/$1/$2/$3";
$route['forum/answer_edit/(:num)/(:any)']			= "forum/cnt_forum/answer_edit/$1/$2/$3/$4";
$route['forum/answer_remove/(:num)/(:any)']			= "forum/cnt_forum/answer_remove/$1/$2/$3/$4";

$route['forum/topic/(:num)/(:any)']					= "forum/cnt_forum/topic/$1/$2";
$route['forum/detail/(:num)/(:any)']				= "forum/cnt_forum/detail/$1/$2";

*/

<file_sep>/public/lib/js/timetable.js
//<![CDATA[

/*
 * LOOPSHAPE JS
 *
 * by <NAME>
 * (c)2013 loopshape.com
 *
 */

$( document ).ready( function( ) {

	var delay = 500;
	var relMonth = 0;

	// Read a page's GET URL variables and return them as an associative array.
	// http://jquery-howto.blogspot.de/2009/09/get-url-parameters-values-with-jquery.html
	function getUrlVars( ) {
		var vars = [], hash;
		var hashes = window.location.href.slice( window.location.href.indexOf( '?' ) + 1 ).split( '&' );
		for( var i = 0; i < hashes.length; i++ ) {
			hash = hashes[i].split( '=' );
			vars.push( hash[0] );
			vars[hash[0]] = hash[1];
		}
		return vars;
	}

	var ttNavi = $( 'div.navigator ul' );

	ttNavi.children( 'li.left' ).on( 'click touchend', function( ) {

		var newDate = new Date( );
		var thisMonth = newDate.getMonth( );

		$urlParam = getUrlVars( );
		relMonth = parseInt( $urlParam.relMonth ) - 1;
		if( !relMonth )
			relMonth = -1;

		if( Math.abs( relMonth ) > thisMonth ) {
			relMonth += 1;
		}

		setTimeout( function( ) {
			window.location.replace( "/community/forum/?relMonth=" + relMonth );
		}, delay );

	} );

	ttNavi.children( 'li.right' ).on( 'click touchend', function( ) {

		$urlParam = getUrlVars( );
		relMonth = parseInt( $urlParam.relMonth ) + 1;
		if( !relMonth )
			relMonth = 0;

		if( relMonth <= 0 ) {

			setTimeout( function( ) {
				window.location.replace( "/community/forum/?relMonth=" + relMonth );
			}, delay );

		}

	} );

	$( 'div.timetable div.timeline > p > span.live' ).parent( ).addClass( 'today' );

	// SEARCH FIELD for BLOG
	var searchBuffer
	$( 'input.searchField' ).css( 'color', '#aaa' );
	$( 'input.searchField' ).focus( function( ) {
		searchBuffer = $( this ).prop( 'value' );
		$( this ).prop( 'value', '' ).css( 'color', '#222' );
	} ).blur( function( ) {
		if( $( this ).prop( 'value' ) != '' )
			searchBuffer = $( this ).prop( 'value' );
		$( this ).prop( 'value', searchBuffer ).css( 'color', '#aaa' );
	} );

} );

//]]><file_sep>/app/Http/Middleware/forum/mod_forum.php
<?php

require "mod_user.php";
require "mod_profile.php";
require "mod_message.php";
require "mod_blogcore.php";
require "mod_timetable.php";
require "mod_chart.php";
require "mod_statistics.php";
require "mod_teaser.php";
require "mod_pages.php";
require app_path() . "/third_party/mobiledetect/Mobile_Detect.php";

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Forum extends Eloquent {

	/*
	 * global forum variables
	 */

	private $forumTitle = 'TECH';

	// email settings for forum messages (FROM) :: sender / receiver for user registrations (BCC)
	private $adminMailSender = '<EMAIL>';
	private $adminMailReceiver = '<EMAIL>';

	private $firstLogin = false;

	// the admin group flag
	private $groupAdmin = 1;
	// the admin group flag
	private $groupMod = 2;
	// the admin group flag
	private $groupMember = 3;

	// detail-flag for single view
	private $details = false;
	// counter for all posts of a thread
	private $postCounter = 0;
	// posts per page
	private $showPostsCount = 100;
	// show latest posts on main view
	private $showLatestPosts = true;
	// delay latest posts in hours
	private $showLatestPostsDelay = 72;
	// delay fresh posts in hours
	private $fresh = 24;

	// flag for user has a memberstatus = true
	private $user = false;

	// vars for a "routed" post
	private $catID = 0;
	private $topicID = 0;
	private $itemID = 0;
	private $answerID = 0;
	private $genreID = 0;

	// user login credentials
	private $userName = '';
	private $userEmail = '';
	private $userPass = '';
	// the id of the user
	private $userID = 0;
	private $userIP = '';
	private $isLoggedIn = false;

	// the group flag of the user: 1 = admin; 2 = moderator; 3 = member
	private $group = 3;
	// flag for checking if user is owner of a post
	private $owner = false;
	// flag for setting user with admin rights
	private $admin = false;

	// flag for edit-mode: on = true; off = false;
	private $edit = false;

	private $post = array( );
	private $get = array( );

	// flag for post has answers
	private $answers = false;

	// var for order count
	private $order = 1;

	// forum vars
	private $maxCats = 1;
	private $maxTopics = 1;
	private $maxItems = 1;

	private $showDate = false;
	private $showDateUser = false;

	// search vars
	private $searchString = '';
	private $search = false;

	// user settings
	private $profile = true;

	// application message vars
	private $message = 0;

	// flag for mobile device
	private $mobile = false;

	private $inlineFooter = false;

	private $impressum = false;

	private $publish = false;
	private $teaser = true;
	private $statistics = false;

	private $network = false;

	/**
	 * the constructor :: init function
	 * sets the owner of a post flag to false
	 * sets the ID for an answer to 0
	 *
	 * @access public
	 */
	public function __construct( ) {

		parent::__construct( );

		$this -> owner = false;

		$this -> answerID = 0;

		$this -> classUser = new Mod_User;
		$this -> classProfile = new Mod_Profile;
		$this -> classMessage = new Mod_Message;
		$this -> classTimetable = new Mod_Timetable;
		$this -> classChart = new Mod_Chart;
		$this -> classStats = new Mod_Statistics;
		$this -> classTeaser = new Mod_Teaser;

		$userIP = $this -> userIP;
		if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
		    $this -> userIP = $_SERVER['HTTP_CLIENT_IP'];
		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
		    $this -> userIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
		} else {
		    $this -> userIP = $_SERVER['REMOTE_ADDR'];
		}

		if( $userIP != $this -> userIP ) $this -> classStats -> setGuest( array( "ip" => $this -> userIP ) );

		$detect = new Mobile_Detect;
		if( $detect -> isMobile( ) ) {
			$this -> mobile = true;
		}

		// check if session available
		if( Session::has( 'userName' ) ) {
			//if( Session::has( 'userName' ) )
			$this -> userName = Session::get( 'userName' );
			if( Session::has( 'userEmail' ) )
				$this -> userEmail = Session::get( 'userEmail' );
			if( Session::has( 'userPass' ) )
				$this -> userPass = Session::get( 'userPass' );
			if( Session::has( 'userID' ) )
				$this -> userID = Session::get( 'userID' );
			if( Session::has( 'is_user' ) ) {
				$this -> user = Session::get( 'is_user' );
			}
			if( Session::has( 'is_group' ) )
				$this -> group = Session::get( 'is_group' );
			if( $this -> user != 0 && $this -> group == $this -> groupAdmin )
				$this -> admin = Session::get( 'is_admin' );
		}

	}

	/**
	 * the destructor
	 *
	 * @access public
	 */
	public function __destruct( ) {

		$this -> post = array( );

	}

	/**
	 * main forum administration
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function administration( ) {

		$context = '';

		if( $this -> group != 0 && $this -> group <= $this -> groupMod ) {

			$this -> edit = true;

			$this -> details = false;

			$this -> getMaxForums( );

			$this -> checkRequestArr( );

			$context = '';

			// headline
			$context .= '';
			$context .= '
' . $this -> forumTitle . ' :: Admin
';
			$context .= '';

			$context .= $this -> clearer( );

			$context .= '

';
			$context .= '

';

			$context .= '<form action="/community/forum" method="post">';

			$context .= $this -> getForumList( );

			$context .= '
';

			$context .= '<input type="submit" name="formSave" class="save" value="Update forum" />';

			$context .= $this -> getMainOptions( );

			$context .= '
';

			$context .= '<input type="hidden" name="act" value="editForum" />';

			$context .= '</form>';

			$context = ($this -> admin) ? '
' . $context . '
' : '
' . $context . '
';

		}

		return $context;

	}

	/**
	 * get all forum topics
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function forumList( $year = 0, $month = 0, $day = 0 ) {

		if( $year != 0 && $month != 0 && $day != 0 ) {
			$this -> showDate = true;
		} else {
			$this -> showDate = false;
		}

		$this -> edit = false;

		$this -> details = false;

		$this -> getMaxForums( );

		$this -> checkRequestArr( );

		$context = '';

		// headline
		$context .= '';
		$context .= '
' . $this -> forumTitle . '
';
		$context .= '';

		$context .= $this -> memberLogin( );

		$context .= $this -> clearer( );

		//$context .= '

';

		if( $this -> teaser ) $context .= $this -> classTeaser -> template( $this -> userID, $this -> user );

		if( $this -> user || $this -> publish ) {

			$context .= '
';

		}

		if( !$this -> user && !$this -> publish ) {

			$context .= $this -> clearer( );

			$context .= '
';

			$context .= '

A Community for the good Things

			';

			$context .= '

';

			if( !$this -> impressum )
				$context .= '

This is a public archive for webtips and good links:

			';
			if( !$this -> impressum )
				$context .= '

Webdevelopment / Graphic Design / Multimedia

			';

			if( !$this -> impressum )
				$context .= '

Click here to register a new account.

			';

			if( !$this -> impressum )
				$context .= '
';

			$context .= '
';

			$context .= $this -> clearer( );

		}

		if( $this -> message != 0 )
			$context .= $this -> msg( );

		if( $this -> user || $this -> publish ) {

			$context .= $this -> forumSearch( );

			$context .= $this -> clearer( );

			if( $this -> user && !$this -> search ) {

				$context .= '
';

				$context .= '<form action="/community" method="post">';

				$context .= '
';

				$context .= '
';

				$context .= 'Title';
				$context .= '<input name="quickPostTitle" class="quickPostTitle" value="" />';

				$context .= $this -> optionGenres( );

				$context .= $this -> optionKeyword( $this -> catID, $this -> topicID, $this -> itemID );

				$context .= '
';

				$context .= '
';

				$context .= 'Message';
				$context .= '<textarea name="quickPostMessage" class="quickPostMessage"></textarea>';

				$context .= '
';

				$context .= '
';

				$query = DB::select( '
					SELECT *
					FROM `forum_topics`
					WHERE `hidden` = 0
					ORDER BY `name` ASC
				' );

				$result = $query;

				if( $result ) {

					$context .= 'Category';
					$context .= '<select name="quickPostCat" class="quickPostCat">';

					foreach( $result as $rx ) {
						if( $rx -> name == 'SMALLTALK' ) {
							$context .= '<option value="' . $rx -> name . '" selected="selected">' . $rx -> name . '</option>';
						} else {
							$context .= '<option value="' . $rx -> name . '">' . $rx -> name . '</option>';
						}
					}

					$context .= '</select>';

				}

				$context .= '<input class="quickPost" name="quickPost" type="submit" value="Submit" />';

				$context .= '
';

				$context .= '
';

				$context .= '</form>';

				$context .= '
';

				$context .= $this -> clearer( );

				$context .= '

Goto Archive

';
				$context .= '

Quick Post

';
				$context .= '

Topics

';
				//$context .= '

Activate Chat

';
				$context .= '

Set Fullscreen

';

			}

			if( $this -> search )
				return '
' . $context . '
';

			if( !$this -> mobile )
				$context .= $this -> latestPosts( $year, $month, $day );

			$context .= '
';
			$context .= $this -> classTimetable -> outputTimetable( $this -> userID, $year, $month, $day, $this -> showDateUser );
			$context .= '
';

			//$context .= $this -> clearer( );

			//$context .= $this -> spacer( );

			$context .= '
';

			if( $this -> user && !$this -> search || $this -> publish ) {
				$context .= $this -> showTheTopics( );
			}

			$context .= '
';

			$context .= $this -> clearer( );

			$context .= '
';

			$context .= '

The Archive

';
			//$context .= '

Your Profile

';

			$context .= '
';

			$context .= '
';

			// list categories
			$context .= $this -> getForumList( );

			if( $this -> admin ) {

				$context .= '
';
				$context .= 'Edit forum';
				$context .= '
';

			}

			$context .= '
';

			$context .= '
';

		}

		if( $this -> statistics ) $context .= $this -> classChart -> template( $this -> userID, $this -> user );

		//$context .= '

';

		if( $this -> inlineFooter )
			$context .= '

					Impressum

					Forum coded by <NAME> - http://loopshape.com/

					Editor by TinyMCE

					Font by FontAwesome

		';

		$context .= $this -> clearer( );

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * show all posts of a category
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function showPostList( $catID, $topicID, $itemID = 0 ) {

		$this -> checkRequestArr( );

		$this -> details = true;

		$context = '';

		$context .= '';
		$context .= '
' . $this -> forumTitle . ' :: List
';
		$context .= '';

		$context .= $this -> memberLogin( );

		$context .= $this -> clearer( );

		$context .= '

';

		if( $this -> user || $this -> publish ) {

			$context .= $this -> forumSearch( );

			$context .= $this -> clearer( );

			$context .= '

' . $this -> getForum( $catID ) . '

';

			$context .= '

' . $this -> getTopic( $catID, $topicID ) . '

';

			if( $this -> user && $this -> group != 0 && $this -> group <= $this -> groupMember ) {

				$context .= '
';

				$context .= '
Create post
';

				$context .= '
';

			}

			//$context .= '

';

		}

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * post single view
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function showPostDetail( $forumID, $topicID, $itemID = 0 ) {

		$this -> checkRequestArr( );

		$this -> details = true;

		$context = '';

		$context .= '';
		$context .= '
' . $this -> forumTitle . ' :: Post
';
		$context .= '';

		$context .= $this -> memberLogin( );

		if( !$this -> user ) {

			$context .= '

';

		}

		if( $this -> user || $this -> publish ) {

			$context .= '

' . $this -> getForum( $forumID ) . '

';

			$context .= '

' . $this -> getPost( $forumID, $topicID, $itemID ) . '

';

		}

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * create category
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function createCat( ) {

		$context = '';

		$context .= '';
		$context .= '
Create :: Category
';
		$context .= '';

		$context .= '

';

		$context .= '<form action="/community/forum" method="post">';

		$context .= '
Create new category:

';

		$context .= 'Label:';
		$context .= '<input type="text" name="forumName" value="" />';

		$context .= '

';

		$context .= '<input type="submit" value="Create" />';

		$context .= '

';

		$context .= '<input class="setFocus" type="hidden" name="act" value="createCat" />';

		$context .= '</form>';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * delete category
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function deleteCat( $catID ) {

		$context = '';

		$context .= '';
		$context .= '
Delete :: Category
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		$context .= '<form action="/community/forum" method="post">';

		$context .= 'Delete category???';

		$context .= '<input type="submit" value="Yes" />';

		$context .= 'No';

		$context .= '

';

		$context .= '<input type="hidden" name="act" value="deleteCat" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';

		$context .= '</form>';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * create topic
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function createTopic( $catID ) {

		$context = '';

		$context .= '';
		$context .= '
Create :: Category
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		$context .= '<form action="/community/forum" method="post">';

		$context .= '
Create new category:

';

		$context .= 'Label:';
		$context .= '<input class="postTitleField setFocus" type="text" name="forumName" value="" />';

		$context .= $this -> getTopicList( $catID );

		$context .= '

';

		$context .= '<input type="submit" value="Create" />';

		$context .= '

';

		$context .= '<input type="hidden" name="act" value="createTopic" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';

		$context .= '</form>';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * delete topic
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function deleteTopic( $catID, $topicID ) {

		$context = '';

		$context .= '';
		$context .= '
Delete :: Topic
';
		$context .= '';

		$context .= '
' . $this -> getTopicName( $catID, $topicID ) . '
';

		$context .= '

';

		$context .= '<form action="/community/forum" method="post">';

		$context .= 'Delete topic???';

		$context .= '<input type="submit" value="Yes" />';

		$context .= 'No';

		$context .= '

';

		$context .= '<input type="hidden" name="act" value="deleteTopic" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';
		$context .= '<input type="hidden" name="topicID" value="' . $topicID . '" />';

		$context .= '</form>';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * create post
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function createPost( $catID, $topicID, $itemID = 0 ) {

		$this -> details = true;

		$context = '';

		$context .= '';
		$context .= '
Create :: Post
';
		$context .= '';

		$context .= '

';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		$context .= '
Category: ”' . $this -> getTopicName( $catID, $topicID ) . '”
';

		$context .= $this -> clearer( );

		$context .= '<form action="/community/forum/topic/' . $catID . '/' . $topicID . '" method="post">';

		$context .= 'Title:';
		$context .= '<input class="postTitleField setFocus" type="text" name="postTitle" value="" />';

		$context .= $this -> optionGenres( );

		$context .= $this -> optionKeyword( $this -> catID, $this -> topicID, $this -> itemID );

		$context .= $this -> clearer( );

		$context .= '

';

		//$context .= 'Nachricht:';
		$context .= '<textarea class="postMessageArea" name="postMessage"></textarea>';

		$context .= $this -> clearer( );

		$context .= '

';

		$context .= '<input type="submit" value="Create" />';

		$context .= 'Cancel';

		$context .= '<input type="hidden" name="act" value="createPost" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';
		$context .= '<input type="hidden" name="topicID" value="' . $topicID . '" />';
		$context .= '<input type="hidden" name="itemID" value="' . $itemID . '" />';

		$context .= '</form>';

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * answer post
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function answerPost( $catID, $topicID, $itemID ) {

		$this -> details = true;

		$context = '';

		$context .= '';
		$context .= '
Post :: Reply
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		$context .= $this -> getPost( $catID, $topicID, $itemID, true );

		$context .= '<form action="/community/forum/detail/' . $catID . '/' . $topicID . '/' . $itemID . '" method="post">';

		$context .= 'Title:';
		$context .= '<input class="postTitleField setFocus" type="text" name="postTitle" value="" />';

		$context .= '

';

		//$context .= 'Nachricht:';
		$context .= '<textarea name="postMessage" class="quickPostMessage"></textarea>';

		$context .= $this -> clearer( );

		$context .= '

';

		$context .= '<input type="submit" value="Create" />';

		$context .= 'Cancel';

		$context .= '<input type="hidden" name="act" value="answerPost" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';
		$context .= '<input type="hidden" name="topicID" value="' . $topicID . '" />';
		$context .= '<input type="hidden" name="itemID" value="' . $itemID . '" />';

		$context .= '</form>';

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * edit post
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function editPost( $catID, $topicID, $itemID ) {

		$this -> details = true;

		$context = '';

		$context .= '';
		$context .= '
Post :: Edit
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		$context .= '
Category: ”' . $this -> getTopicName( $catID, $topicID ) . '”
';

		$context .= $this -> clearer( );

		$context .= '<form action="/community/forum/detail/' . $catID . '/' . $topicID . '/' . $itemID . '" method="post">';

		$context .= 'Title:';
		$context .= '<input class="postTitleField setFocus" type="text" name="postTitle" value="' . $this -> getPostName( $catID, $topicID, $itemID ) . '" />';

		$queryx = DB::select( '
			SELECT *
			FROM `forum_topics`
			WHERE `hidden` = 0
			ORDER BY `name` ASC
		' );

		$resultx = $queryx;

		if( $resultx ) {

			$context .= 'Category:';
			$context .= '<select name="topicID" class="topicID">';

			foreach( $resultx as $rx ) {
				if( $rx -> name == $this -> getTopicName( $catID, $topicID ) ) {
					$context .= '<option value="' . $rx -> id . '" selected="selected">' . $rx -> name . '</option>';
				} else {
					$context .= '<option value="' . $rx -> id . '">' . $rx -> name . '</option>';
				}
			}

			$context .= '</select>';

		}

		$context .= $this -> getPostGenre( $catID, $topicID, $itemID );

		$context .= $this -> optionKeyword( $catID, $topicID, $itemID );

		//$context .= 'Nachricht:';
		$context .= '<textarea name="postMessage" class="quickPostMessage">' . $this -> getPostMsg( $catID, $topicID, $itemID ) . '</textarea>';

		$context .= $this -> clearer( );

		$context .= '

';

		$context .= '<input type="submit" value="Update" />';

		$context .= 'Cancel';

		$context .= '<input type="hidden" name="act" value="updatePost" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';
		//$context .= '<input type="hidden" name="topicID" value="' . $topicID . '" />';
		$context .= '<input type="hidden" name="itemID" value="' . $itemID . '" />';

		$context .= '</form>';

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * delete post
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function deletePost( $catID, $topicID, $itemID ) {

		$this -> details = true;

		$context = '';

		$context .= '';
		$context .= '
Post :: Delete
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		$context .= '
Post ”' . $this -> getPostName( $catID, $topicID, $itemID ) . '” Delete?
';

		$context .= $this -> clearer( );

		$context .= '
';

		$context .= '

';

		$context .= '<form action="/community/forum" method="post">';

		$context .= $this -> clearer( );

		$context .= '<input type="submit" value="Delete" />';

		$context .= 'Cancel';

		$context .= '<input type="hidden" name="act" value="removePost" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';
		$context .= '<input type="hidden" name="topicID" value="' . $topicID . '" />';
		$context .= '<input type="hidden" name="itemID" value="' . $itemID . '" />';

		$context .= '</form>';

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * manage answers / administration view
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function manageAnswers( $catID, $topicID, $itemID ) {

		$this -> details = true;

		$context = '';

		$replys = $this -> checkReplys( $catID, $topicID, $itemID );

		$context .= '';
		$context .= '
Reply :: Manage
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID, (!empty( $replys )) ) . '

';

		$context .= '

';

		$context .= '
Post ”' . $this -> getPostName( $catID, $topicID, $itemID ) . '”
';

		$context .= $this -> clearer( );

		$context .= '
';

		if( $replys ) {

			$context .= '
';

			$rc = 0;
			foreach( $replys as $reply ) {

				$context .= '

';

				$context .= '

';

				$context .= '
' . ucfirst( $this -> getUsername( $catID, $topicID, $itemID, $reply -> user_id ) ) . ' replies:
';

				$context .= '
”' . $reply -> title . '”
';

				$context .= '
' . date( 'H:i - m/d/Y', strtotime( $reply -> crdate ) ) . '
';

				$context .= '
' . htmlspecialchars_decode( $reply -> subject ) . '
';

				$rc++;
			}

			$context .= '
';

			$context .= '
';

			$context .= 'Cancel';

		}

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * edit answer
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function editAnswer( $catID, $topicID, $itemID, $answerID = 0 ) {

		$this -> details = true;

		$context = '';

		$replys = $this -> checkReplys( $catID, $topicID, $itemID );

		$context .= '';
		$context .= '
Answer :: Edit
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		if( $replys ) {

			$context .= '
';

			$rc = 0;
			foreach( $replys as $reply ) {

				$replyArr[$rc] = $reply;

				$context .= '
' . ucfirst( $this -> getUsername( $catID, $topicID, $itemID, $reply -> user_id ) ) . ' replies:
';

				$context .= '
”' . $reply -> title . '”
';

				$context .= '
' . date( 'H:i - m/d/Y', strtotime( $reply -> crdate ) ) . '
';

				$context .= '
' . htmlspecialchars_decode( $reply -> subject ) . '
';

				$rc++;
			}

			$context .= '
';

		}

		$context .= '<form action="/community/forum/detail/' . $catID . '/' . $topicID . '/' . $itemID . '" method="post">';

		$context .= 'Title:';
		$context .= '<input type="text" name="answerTitle" value="' . $replyArr[$answerID] -> title . '" />';

		$context .= '

';

		//$context .= 'Nachricht:';
		$context .= '<textarea name="answerMessage">' . $replyArr[$answerID] -> subject . '</textarea>';

		$context .= $this -> clearer( );

		$context .= '<input type="submit" value="Update" />';

		$context .= 'Cancel';

		$context .= '<input type="hidden" name="act" value="updateAnswer" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';
		$context .= '<input type="hidden" name="topicID" value="' . $topicID . '" />';
		$context .= '<input type="hidden" name="itemID" value="' . $replyArr[$answerID] -> id . '" />';
		$context .= '<input type="hidden" name="answerID" value="' . $answerID . '" />';

		$context .= '</form>';

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * delete answer
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function deleteAnswer( $catID, $topicID, $itemID, $answerID = 0 ) {

		$this -> details = true;

		$context = '';

		$replys = $this -> checkReplys( $catID, $topicID, $itemID );

		$context .= '';
		$context .= '
Answer :: Delete
';
		$context .= '';

		$context .= '

' . $this -> getForum( $catID ) . '

';

		$context .= '

';

		$context .= '
Delete post ”' . $this -> getPostName( $catID, $topicID, $itemID ) . '” ?
';

		$context .= $this -> clearer( );

		$context .= '
';

		$context .= '

';

		if( $replys ) {
			$rc = 0;
			foreach( $replys as $reply ) {
				$replyArr[$rc] = $reply;
				$rc++;
			}
		} else {
			$context .= '
Error... No replies found!
';
		}

		$context .= '
';

		$context .= '
' . ucfirst( $this -> getUsername( $catID, $topicID, $itemID, $replyArr[$answerID] -> user_id ) ) . ' replies:
';

		$context .= '
”' . $replyArr[$answerID] -> title . '”
';

		$context .= '
' . date( 'H:i - m/d/Y', strtotime( $replyArr[$answerID] -> crdate ) ) . '
';

		$context .= '
' . htmlspecialchars_decode( $replyArr[$answerID] -> subject ) . '
';

		$context .= '
';

		$context .= '<form action="/community/forum/detail/' . $catID . '/' . $topicID . '/' . $itemID . '" method="post">';

		$context .= $this -> clearer( );

		$context .= '<input type="submit" value="Delete" />';

		$context .= 'Cancel';

		$context .= '<input type="hidden" name="act" value="removeAnswer" />';
		$context .= '<input type="hidden" name="catID" value="' . $catID . '" />';
		$context .= '<input type="hidden" name="topicID" value="' . $topicID . '" />';
		$context .= '<input type="hidden" name="itemID" value="' . $replyArr[$answerID] -> id . '" />';
		$context .= '<input type="hidden" name="answerID" value="' . $answerID . '" />';

		$context .= '</form>';

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * side content
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function sideContent( ) {

		$context = '';

		$context .= '
New posts in the last 7 days:
';

		$context .= '
';

		$context .= $this -> latestPosts( );

		return $context;
	}

	/**
	 * create account
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function createAccount( ) {

		$this -> checkRequestArr( );

		$context = '';

		// headline
		$context .= '';
		$context .= '
' . $this -> forumTitle . ' :: Create account
';
		$context .= '';

		$context .= '
';

		if( $this -> message != 0 ) {
			$context .= $this -> msg( ) . '

';
		}

/*
		$context .= Form::open( array('url' => '/community/forum') );

		$context .= Form::label('memberNameField', 'Username: ', array('class' => 'memberNameField'));
		$context .= Form::text('memberNameField');

		$context .= Form::label('memberEmailField', 'eMail: ', array('class' => 'memberEmailField'));
		$context .= Form::text('memberEmailField');

		$context .= Form::label('memberPassField', 'Password: ', array('class' => 'memberPassField'));
		$context .= Form::text('memberPassField');

		$context .= $this -> clearer( );

		$context .= Form::submit('Register', array('class' => 'memberAccountSubmit'));

		$context .= Form::close();
*/

		$context .= '<form action="" method="post">';

		$context .= 'Username: ';
		$context .= '<input class="memberNameField" type="text" name="memberNameField" value="" />';

		$context .= 'eMail: ';
		$context .= '<input class="memberEmailField" type="text" name="memberEmailField" value="" />';

		$context .= 'Password: ';
		$context .= '<input class="memberPassField" type="text" name="memberPassField" value="" />';

		$context .= $this -> clearer( );

		$context .= '<input class="memberAccountSubmit" type="submit" name="memberAccountSubmit" value="Register" />';

		$context .= '</form>';

		$context .= '
';

		$context .= $this -> clearer( );

		$context .= '

';

		$context = '
' . $context . '
';

		return $context;

	}

	/**
	 * create account
	 *
	 * @access	public
	 * @param  string
	 * @return  string
	 */
	public function showImpressum( ) {

		$context = '';

		return $context;

	}

	/**
	 * check if post array has content
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function checkRequestArr( ) {

		// clean up post array
		$this -> post = array( '' );
		if( Input::all() ) {
			$this -> post = Input::all(); //array_map( 'mysql_real_escape_string', Input::all() );
			$this -> get = $this -> post;
		}

		if( isset( $this -> get['genre'] ) ) {
			$this -> genreID = htmlspecialchars( $this -> get['genre'] );
		} else {
			$this -> genreID = 0;
		}

		if( isset( $this -> post['quickPost'] ) ) {

			$postTitle = '';
			$postMessage = '';
			$postKeyword = '';
			if( $this -> post['quickPostTitle'] )
				$postTitle = htmlspecialchars( $this -> post['quickPostTitle'] );
			if( $this -> post['genreID'] )
				$genreID = htmlspecialchars( $this -> post['genreID'] );
			if( $this -> post['quickPostMessage'] ) {
				$postMessage = htmlspecialchars( $this -> post['quickPostMessage'] );
			} else {
				$postMessage = '';
			}
			if( $this -> post['quickPostKeyword'] ) {
				$postKeyword = htmlspecialchars( $this -> post['quickPostKeyword'] );
			}

			if( $postTitle == '' || preg_match('/Enter a title/', $postTitle) ) {
				$postTitle = htmlspecialchars_decode(strip_tags(htmlspecialchars_decode($postMessage)));
				$postMessage = '';
			}

			if( $this -> post['quickPostCat'] )
				$postCat = htmlspecialchars( $this -> post['quickPostCat'] );

			$xquery = DB::select( '
				SELECT *
				FROM `forum_topics`
				WHERE `name` LIKE "%' . $postCat . '%"
			' );

			$xresult = $xquery;

			if( $xresult ) {

				$catID = $xresult[0] -> cat_id;
				$topicID = $xresult[0] -> id;
				$itemID = null;

			}

			if( !empty( $postTitle ) ) {
				$this -> owner = true;
				$this -> newPost( $catID, $topicID, $itemID, $postTitle, $postMessage, $genreID, $postKeyword );
			}
		}

		// check if account has been created
		if( isset( $this -> post['memberAccountSubmit'] ) ) {

			if( isset( $this -> post['memberNameField'] ) )
				$userName = htmlspecialchars( $this -> post['memberNameField'] );
			if( isset( $this -> post['memberEmailField'] ) )
				$userEmail = htmlspecialchars( $this -> post['memberEmailField'] );
			if( isset( $this -> post['memberPassField'] ) )
				$userPass = htmlspecialchars( $this -> post['memberPassField'] );

			if( !empty( $userName ) && !empty( $userEmail ) && !empty( $userPass ) ) {
				if( $this -> classUser -> userRegister( $userName, $userEmail, $userPass, $this -> adminMailSender, $this -> adminMailReceiver ) ) {
					$this -> message = 1;
				}
				header( 'Location: /community' );
			} else {
				$this -> message = 13;
			}

		}

		// logout from session
		if( isset( $this -> post['memberLogout'] ) ) {

			$this -> userID = 0;
			$this -> user = false;

			Session::flush();

			header( 'Location: /community' );

		}

		// check if login credentials ok
		$memberEmail = array( );
		$memberPass = '';
		if( isset( $this -> post['memberSubmit'] ) ) {

			preg_match( '/((.+)@(.+)\.(.+))/', htmlspecialchars( $this -> post['memberEmail'] ), $memberEmail );
			$memberPass = htmlspecialchars( $this -> post['memberPass'] );

			if( isset( $memberEmail[1] ) ) {

				$this -> userEmail = $memberEmail[1];
				$this -> userPass = $<PASSWORD>;

				if( !empty( $this -> userEmail ) && !empty( $this -> userPass ) ) {

					$userArr = $this -> classUser -> userLogin( $this -> userEmail, $this -> userPass );

					$this -> user = $userArr['is_user'];

					if( $userArr['is_admin'] && $userArr['is_group'] == 1 ) {
						$this -> admin = true;
					}

					if( $this -> user ) {

						$this -> userName = $userArr['userName'];

						$newdata = array( 'userName' => $userArr['userName'], 'userEmail' => $userArr['userEmail'], 'userPass' => $<PASSWORD>['<PASSWORD>'], 'userID' => $userArr['userID'], 'is_group' => $userArr['is_group'], 'is_user' => $userArr['is_user'], 'is_admin' => $userArr['is_admin'], );
						Session::put( 'userName', $newdata['userName'] );
						Session::put( 'userEmail', $newdata['userEmail'] );
						Session::put( 'userPass', $newdata['<PASSWORD>'] );
						Session::put( 'userID', $newdata['userID'] );
						Session::put( 'is_group', $newdata['is_group'] );
						Session::put( 'is_user', $newdata['is_user'] );
						Session::put( 'is_admin', $newdata['is_admin'] );

					}

					$this -> isLoggedIn = true;

				}

			}

		}

		$act = '';
		if( isset( $this -> post['act'] ) && $this -> classUser -> userRights( Session::get( 'userEmail' ), Session::get( 'userPass' ) ) ) {

			$act = $this -> post['act'];

			if( isset( $this -> post['catID'] ) )
				$catID = (int)$this -> post['catID'];
			if( isset( $this -> post['topicID'] ) )
				$topicID = (int)$this -> post['topicID'];
			if( isset( $this -> post['itemID'] ) )
				$itemID = (int)$this -> post['itemID'];

			if( isset( $this -> post['answerID'] ) )
				$answerID = (int)$this -> post['answerID'];

			if( isset( $catID ) && isset( $topicID ) && isset( $itemID ) ) {
				$this -> checkOwner( $catID, $topicID, $itemID );
			}

			if( isset( $this -> post['forumSearchField'] ) ) {
				$this -> searchString = htmlspecialchars( $this -> post['forumSearchField'] );
			}

			switch( $act ) {

				case 'editForum':
					if( $this -> group <= $this -> groupMod )
						$this -> updateForum( $this -> post );
					break;

				case 'createCat':
					if( $this -> group <= $this -> groupMod )
						$this -> newCat( htmlspecialchars( $this -> post['forumName'], $this -> post['newForumOrder'] ) );
					break;

				case 'deleteCat':
					if( $this -> group <= $this -> groupMod )
						$this -> removeCat( $catID );
					break;

				case 'createTopic':
					if( $this -> group <= $this -> groupMod )
						$this -> newTopic( $catID, htmlspecialchars( $this -> post['forumName'] ), htmlspecialchars( $this -> post['newForumOrder'] ) );
					break;

				case 'deleteTopic':
					if( $this -> group <= $this -> groupMod )
						$this -> removeTopic( $topicID );
					break;

				case 'createPost':
					$postTitle = '';
					$postMessage = '';
					$postKeyword = '';
					if( $this -> post['postTitle'] )
						$postTitle = htmlspecialchars( $this -> post['postTitle'] );
					if( $this -> post['genreID'] )
						$genreID = htmlspecialchars( $this -> post['genreID'] );
					if( $this -> post['postMessage'] )
						$postMessage = htmlspecialchars( $this -> post['postMessage'] );
					if( $this -> post['quickPostKeyword'] ) {
						$postKeyword = htmlspecialchars( $this -> post['quickPostKeyword'] );
					}
					if( !empty( $postTitle ) ) {
						$this -> owner = true;
						$this -> newPost( $catID, $topicID, $itemID, $postTitle, $postMessage, $genreID, $postKeyword );
					}
					break;

				case 'updatePost':
					$postTitle = '';
					$postMessage = '';
					$postKeyword = '';
					if( $this -> post['postTitle'] )
						$postTitle = htmlspecialchars( $this -> post['postTitle'] );
					if( $this -> post['genreID'] )
						$genreID = htmlspecialchars( $this -> post['genreID'] );
					if( $this -> post['quickPostKeyword'] ) {
						$postKeyword = htmlspecialchars( $this -> post['quickPostKeyword'] );
					}
					if( $this -> post['postMessage'] )
						$postMessage = htmlspecialchars( $this -> post['postMessage'] );

					if( !empty( $postTitle ) && !empty( $postMessage ) && $this -> owner ) {
						if( $this -> owner )
							$this -> updatePost( $catID, $topicID, $itemID, $postTitle, $postMessage, $genreID, $postKeyword );
					}
					break;

				case 'answerPost':
					$postTitle = '';
					$postMessage = '';
					if( $this -> post['postTitle'] )
						$postTitle = htmlspecialchars( $this -> post['postTitle'] );
					if( $this -> post['postMessage'] ) {
						$postMessage = htmlspecialchars( $this -> post['postMessage'] );
					} else {
						$postMessage = '';
					}
					if( !empty( $postTitle ) ) {
						if( $this -> user && $this -> group <= $this -> groupMember )
							$this -> replyPost( $catID, $topicID, $itemID, $postTitle, $postMessage );
					}
					break;

				case 'removePost':
					if( $this -> owner )
						$this -> removePost( $catID, $topicID, $itemID );
					break;

				case 'updateAnswer':
					$answerTitle = '';
					$answerMessage = '';
					if( $this -> post['answerTitle'] )
						$answerTitle = htmlspecialchars( $this -> post['answerTitle'] );
					if( $this -> post['answerMessage'] )
						$answerMessage = htmlspecialchars( $this -> post['answerMessage'] );
					if( !empty( $answerTitle ) && !empty( $answerMessage ) && $this -> owner ) {
						if( $this -> owner )
							$this -> updateAnswer( $catID, $topicID, $itemID, $answerTitle, $answerMessage );
					}
					break;

				case 'removeAnswer':
					if( $this -> owner || $this -> user && $this -> group <= $this -> groupMod ) {
						$this -> removeAnswer( $catID, $topicID, $itemID, $answerID );
					}
					break;
			}

		}

		return;

	}

	/**
	 * get main forum options HTML
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getMainOptions( ) {

		$context = '';

		if( $this -> admin )
			$context .= '
Category
';

		return $context;
	}

	/**
	 * get specific forum options HTML
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getForumOptions( $catID ) {

		$context = '';

		if( $this -> admin && $this -> edit ) {
			$context .= '
';
			$context .= '

';
			$context .= '

';
			$context .= '
';
		}

		return $context;
	}

	/**
	 * get topic options HTML
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getTopicOptions( $catID, $topicID ) {

		$context = '';

		if( $this -> admin || $this -> owner )
			$context .= '

';

		return $context;
	}

	/**
	 * count all categories
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getMaxForums( ) {

		$query = DB::select( '
			SELECT count(*) AS cnt
			FROM forum_cats
			WHERE hidden = 0
		' );

		$result = $query;
		if( !isset( $this -> maxCats ) )
			$this -> maxCats = $result[0] -> cnt;

		return $this -> maxCats;

	}

	/**
	 * read database :: get forum list
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getForumList( ) {

		$context = '';

		$query = DB::select( '
			SELECT count(*) AS cnt
			FROM `forum_cats`
			WHERE `hidden` = 0
		' );
		$result = $query;
		$this -> maxCats = $result[0] -> cnt + 1;

		$query = DB::select( '
			SELECT *
			FROM `forum_cats`
			WHERE `hidden` = 0
			ORDER BY `order` ASC
		' );
		$result = $query;

		$fc = 0;
		foreach( $result as $forum ) {

			if( $this -> edit ) {

				$context .= '

';
				$context .= '';
				$context .= '<input class="catName" type="text" name="catName_' . $forum -> id . '_' . $fc . '" value="' . $forum -> name . '">';
				$context .= $this -> getForumOptions( $forum -> id );
				$context .= '

';

				$context .= '

';
				$context .= $this -> getTopic( $forum -> id );
				$context .= '

';

			} else {

				$context .= '

' . $forum -> name . '

';

				$context .= '

';
				$context .= $this -> getTopic( $forum -> id );
				$context .= '

';

			}

			$fc++;

		}

		if( $fc == 0 ) {

			$context .= '
No categories
';

		}

		return $context;

	}

	/**
	 * read database :: get category titles
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getForum( $catID, $replys = false ) {

		$context = '';

		$query = DB::select( '
			SELECT *
			FROM forum_cats
			WHERE id = ' . $catID . '
			AND hidden = 0
			ORDER BY `order` ASC
		' );
		$result = $query;

		$cc = 0;
		foreach( $result as $cat ) {

			if( $this -> edit )
				$context .= '';

			$context .= ($this -> edit) ? '<input type="text" name="forum_' . $cc . '" value="' . $cat -> name . '">' : '
' . $cat -> name . '
';

			$context .= $this -> getForumOptions( $cat -> id, $replys );

			$cc++;
		}

		return $context;

	}

	/**
	 * read database :: get category single title
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getForumName( $catID ) {

		$context = '';

		$query = DB::select( '
			SELECT name
			FROM forum_cats
			WHERE id = ' . $catID . '
			AND hidden = 0
		' );
		$result = $query;

		if( $result )
			$context .= $result[0] -> name;

		return $context;

	}

	/**
	 * write database :: update forum entries from form
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function updateForum( $postArr ) {

		$catArr = array( );
		$topicArr = array( );

		// get each post item from form
		$ac = 0;
		foreach( $postArr as $postItem => $postVal ) {

			if( preg_match( '/catName_(.+)_(.+)/', $postItem, $itemVal ) ) {
				$catArr[$ac][0] = $itemVal[1];
				$catArr[$ac][1] = $itemVal[2];
				$catArr[$ac][2] = $postVal;
			}

			if( preg_match( '/topic_(.+)_(.+)/', $postItem, $itemVal ) ) {
				$topicArr[$ac][0] = $itemVal[1];
				$topicArr[$ac][1] = $itemVal[2];
				$topicArr[$ac][2] = $postVal;
			}

			$ac++;

		}

		// make for-loop till all post items are done
		// without other params from form, which are not needed ( subtract two counted params )
		for( $ii = 0; $ii < ($ac - 2); $ii++ ) {

			if( isset( $catArr[$ii] ) ) {
				$catID = $catArr[$ii][0];
				$topicID = $catArr[$ii][1];
				$itemName = $catArr[$ii][2];
				$this -> forumCatUpdate( $catID, $topicID, $itemName );
			}

			if( isset( $topicArr[$ii] ) ) {
				$catID = $topicArr[$ii][0];
				$topicID = $topicArr[$ii][1];
				$itemName = $topicArr[$ii][2];
				$this -> forumTopicUpdate( $catID, $topicID, $itemName );
			}

		}

		return;
	}

	/**
	 * write database :: update categories
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function forumCatUpdate( $catID, $topicID, $itemName ) {

		if( $this -> group != 0 && $this -> group <= $this -> groupMod ) {

			DB::update( '
				UPDATE `forum_cats`
				SET
					`name` = "' . $itemName . '"
				WHERE `id` = "' . $catID . '"
			' );

		}

		return;

	}

	/**
	 * write database :: update topics
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function forumTopicUpdate( $catID, $topicID, $itemName ) {

		if( $this -> group != 0 && $this -> group <= $this -> groupMod ) {

			DB::update( '
				UPDATE `forum_topics`
				SET
					`name` = "' . $itemName . '"
				WHERE `id` = "' . $topicID . '"
			' );

		}

		return;

	}

	/**
	 * read database :: get single topics for category list
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getTopic( $catID = 0, $topicID = 0, $itemID = 0 ) {

		$context = '';
		$fixTopic = '';

		$this -> get = Input::all( );

		if( isset( $this -> get['page'] ) && !empty( $this -> get['page'] ) ) {
			$ic = (int)$this -> get['page'];
		} else {
			$ic = 1;
		}

		switch( $this -> details ) {

			case true:
				$query = DB::select( '
					SELECT *
					FROM `forum_topics`
					WHERE `id` = ' . $topicID . '
					AND `hidden` = 0
					ORDER BY `order` ASC
				' );
				$result = $query;

				if( $result ) {

					$context .= '';
					$context .= '' . $result[0] -> name;
					$context .= '';

					$context .= '
';
					$context .= $this -> getPostAmount( $result[0] -> cat_id, $result[0] -> id );
					$context .= '
';

					$context .= '
';

					$context .= $this -> getPostList( $result[0] -> cat_id, $result[0] -> id );

				}

				break;

			case false:
				$query = DB::select( '
					SELECT *
					FROM `forum_topics`
					WHERE `hidden` = 0
					ORDER BY `order` ASC
				' );

				$result = $query;

				$ti = 0;
				foreach( $result as $topic ) {
					$topicArr[$ti] = $topic;
					$ti++;
				}

				for( $ct = 0; $ct < $ti; $ct++ ) {
					if( $topicArr[$ct] -> cat_id == $catID ) {

						if( $this -> edit ) {

							$context .= '
';
							$context .= '<input type="text" name="topic_' . $catID . '_' . $topicArr[$ct] -> id . '" value="' . $topicArr[$ct] -> name . '" />';
							$context .= $this -> getTopicOptions( $catID, $topicArr[$ct] -> id );
							$context .= '
';

						} else {

							$context .= ' id . '/" target="_self">';
							$context .= '' . $topicArr[$ct] -> name;
							$context .= '';

							$context .= '
';
							$context .= $this -> getPostAmount( $catID, $topicArr[$ct] -> id );
							$context .= '
';

							$context .= ' id . '/" target="_self">';
							$query = DB::select('
								SELECT `name`
								FROM `forum_users`
								WHERE `id` = (
									SELECT `user_id`
									FROM `forum_posts`
									WHERE `topic_id` = ' . $topicArr[$ct] -> id . '
									AND `hidden` = 0
									ORDER BY `update` DESC
									LIMIT 0,1
								)
							');
							if( $query ) {

								$context .= $query[0] -> name;

							}
							$context .= '';

							$context .= ' id . '/" target="_self">';
							$query = DB::select('
								SELECT *
								FROM `forum_posts`
								WHERE `topic_id` = '. $topicArr[$ct] -> id .'
								ORDER BY `update` DESC
								LIMIT 0,1
							');
							if( $query ) {

								$context .= $query[0] -> title;

							}
							$context .= '';

						}

					}
				}

				break;
		}

		return $context;

	}

	/**
	 * read database :: get posts list
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getPostList( $catID, $topicID, $ic = 0, $genreID = 0 ) {

		$this -> get = Input::all();

		if( Input::has('page') ) {
			$ic = (int) Input::get('page');
		} else {
			$ic = 1;
		}

		$context = '';

		$indexStart = $this -> showPostsCount * ($ic - 1);

		if( $this -> genreID == 0 ) {

			$query = DB::select( '
				SELECT *
				FROM `forum_posts`
				WHERE `topic_id` = ' . $topicID . '
				AND `parent_id` = 0
				ORDER BY `update` DESC
				LIMIT ' . $indexStart . ', ' . $this -> showPostsCount . ';
			' );

			$result = $query;

		} else {

			$query = DB::select( '
				SELECT *
				FROM `forum_posts`
				WHERE `topic_id` = ' . $topicID . '
				AND `parent_id` = 0
				AND `genre` = ' . $this -> genreID . '
				ORDER BY `update` DESC
				LIMIT ' . $indexStart . ', ' . $this -> showPostsCount . ';
			' );

			$result = $query;

		}

		if( $result ) {

			$context .= '
';

			$pi = 0;
			foreach( $result as $post ) {
				$postArr[$pi] = $post;
				$pi++;
			}

			for( $pc = 0; $pc < $pi; $pc++ ) {

				$context .= '
';

				$forumIndex = $pc + $indexStart + 1;
				$forumIndex = (strlen( $forumIndex ) == 1) ? '00' . $forumIndex : $forumIndex;
				$forumIndex = (strlen( $forumIndex ) == 2) ? '0' . $forumIndex : $forumIndex;

				$context .= '
';
				$context .= ' topic_id . '/' . $postArr[$pc] -> id . '/?page=' . $ic . '&index=' . $forumIndex . '" target="_self">';
				$context .= '' . $forumIndex . ': ' . $postArr[$pc] -> title . '(' . $postArr[$pc] -> hits . ' hits)';
				$context .= '';
				$context .= '
';

				$context .= '
';
				$context .= ' topic_id . '/' . $postArr[$pc] -> id . '/?page=' . $ic . '&index=' . $forumIndex . '" target="_self">';
				$context .= ($postArr[$pc] -> update != 0) ? '' . date( 'H:i - m/d/Y', strtotime( $postArr[$pc] -> update ) ) : 'no date available...';
				$context .= '';
				$context .= '
';

				$context .= '
';
				$context .= ' topic_id . '/' . $postArr[$pc] -> id . '/?page=' . $ic . '&index=' . $forumIndex . '" target="_self">';
				$context .= '' . $this -> getUsername( $catID, $postArr[$pc] -> topic_id, $postArr[$pc] -> id, $postArr[$pc] -> user_id );
				$context .= '';
				$context .= '
';

				$context .= '
';
				$context .= ' topic_id . '/?genre=' . $postArr[$pc] -> genre . '" target="_self">';
				$context .= '' . $this -> getGenre( $catID, $postArr[$pc] -> topic_id, $postArr[$pc] -> id );
				$context .= '';
				$context .= '
';

				$context .= '
';

			}

			$context .= '
';

		} else {

			$context .= 'No posts written';

		}

		$maxCats = $this -> getMaxCats( $catID, $topicID );

		if( $result && $maxCats > $this -> showPostsCount && $this -> genreID == 0 ) {

			$context .= $this -> clearer( );

			$context .= '
';

			$context .= '
';

			$context .= '
Page:
';

			$context .= '';
			$context .= '';
			$context .= '';

			if( $ic >= 2 ) {

				$context .= '';
				$context .= '';
				$context .= '';

			} else {

				$context .= '
';
				$context .= '';
				$context .= '
';

			}

			$indexPointer = 1;
			for( $page = 0; $page < $maxCats; $page++ ) {

				if( ($page / $this -> showPostsCount) == (int)($page / $this -> showPostsCount) ) {

					if( $indexPointer == $ic ) {

						$context .= '
';
						$context .= $indexPointer . ' ';
						$context .= '
';

					} else {

						$context .= '';
						$context .= $indexPointer . ' ';
						$context .= '';

					}

					$indexPointer++;

				}

			}

			if( $ic < ($maxCats / $this -> showPostsCount) ) {

				$context .= '';
				$context .= '';
				$context .= '';

			} else {

				$context .= '
';
				$context .= '';
				$context .= '
';

			}

			$context .= '';
			$context .= '';
			$context .= '';

			$context .= '
';

			$context .= $this -> clearer( );

		}

		return $context;
	}

	/**
	 * read database :: get single post
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getPost( $catID, $topicID, $itemID, $answer = false ) {

		$context = '';

		$fixTopic = '';
		$fixItem = 0;

		$query = DB::select( '
					SELECT *
					FROM `forum_topics`
					WHERE id = ' . $topicID . '
					AND `hidden` = 0
				' );
		$result = $query;

		if( $result ) {

			$context .= ' id . '/" target="_self">';
			$context .= '' . $result[0] -> name;
			$context .= '';

		}

		$context .= '
';

		if( $result )
			$context .= $this -> getDetails( $catID, $topicID, $itemID, $answer );

		return $context;

	}

	/**
	 * read database :: count posts
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getPostAmount( $catID, $topicID ) {

		$query = DB::select( '
			SELECT count(*) AS cnt
			FROM forum_posts
			WHERE topic_id = ' . $topicID . '
			AND `parent_id` = 0
		' );
		$result = $query;

		return ($result[0] -> cnt != 0) ? ($result[0] -> cnt == 1) ? $result[0] -> cnt . ' post' : $result[0] -> cnt . ' posts' : 'empty';
	}

	/**
	 * read database :: get single post list
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getItems( $forumID, $topicID, $itemID = 0 ) {

		$context = '';
		$fixPost = 0;
		$fixCount = 0;

		$query = DB::select( '
			SELECT *
			FROM forum_topic
			WHERE cat_id = ' . ($topicID + 1) . '
		' );
		$result = $query;

		$pi = 0;
		foreach( $result as $post ) {
			$postArr[$pi] = $post;
			$pi++;
		}

		if( $pi != 0 ) {

			for( $pc = 0; $pc < $pi; $pc++ ) {

				$context .= ' id . '/' . $pc . '/" target="_self">';
				$context .= '' . $postArr[$pc] -> title . '';
				$context .= '';

				$context .= ' id . '/' . $pc . '/" target="_self">';
				$context .= '
' . date( 'H:i - m/d/Y', strtotime( $postArr[$pc] -> crdate ) ) . '
';
				$context .= '';

			}

		} else {

			$context .= 'No posts in this category';

		}

		return $context;

	}

	/**
	 * read database :: get single post
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getDetails( $catID, $topicID, $itemID, $answer = false ) {

		$context = '';
		$userName = '';
		$postArr = array( );

		$this -> get = Input::all();

		if( isset( $this -> get['page'] ) && !empty( $this -> get['page'] ) ) {
			$ic = (int)$this -> get['page'];
		} else {
			$ic = 1;
		}

		if( isset( $this -> get['index'] ) && !empty( $this -> get['index'] ) ) {
			$fi = (int)$this -> get['index'];
		} else {
			$fi = 1;
		}

		$replys = $this -> checkReplys( $catID, $topicID, $itemID );

		$query = DB::select( '
			SELECT *
			FROM `forum_posts`
			WHERE `id` = ' . $itemID . '
		' );
		$result = $query;

		$this -> checkOwner( $catID, $topicID, $itemID );
		if( !$this -> owner && $this -> user ) {
			DB::update( '
				UPDATE `forum_posts` SET `rank` = `rank` + 1 WHERE `id` = ' . $itemID . '
			' );
		}

		DB::update( '
			UPDATE `forum_posts`
			SET
				`hits` = `hits` + 1,
				`clicked` = "' . time() . '"
			WHERE `id` = "' . $itemID . '"
		' );

		$pi = 0;
		foreach( $result as $post ) {
			$postArr[$pi] = $post;
			$pi++;
		}

		if( isset( $postArr ) && !empty( $postArr ) ) {

			if( $postArr[0] -> user_id == $this -> userID )
				$this -> owner = true;

			$fi = (strlen( $fi ) == 1) ? '00' . $fi : $fi;
			$fi = (strlen( $fi ) == 2) ? '0' . $fi : $fi;

			$context .= '
"' . $this -> getUsername( $catID, $topicID, $itemID, $postArr[0] -> user_id ) . '" says:
';

			$context .= '
Genre: "' . $this -> getGenre( $catID, $topicID, $itemID ) . '"
';

			$context .= ' topic_id . '/?page=' . $ic . '" target="_self">';
			$context .= '' . $fi . ': ' . $postArr[0] -> title . '(' . $postArr[0] -> hits . ' hits)';
			$context .= '';

			$context .= ' topic_id . '/?page=' . $ic . '" target="_self">';
			$context .= ($postArr[0] -> update != 0) ? '
' . date( 'H:i - m/d/Y', strtotime( $postArr[0] -> crdate ) ) . ' ' : '
no date
';
			if( $postArr[0] -> update != 0 )
				$context .= '(updated: ' . date( 'H:i - m/d/Y', strtotime( $postArr[0] -> update ) ) . ')
';
			$context .= '';

			if( !empty($postArr[0] -> subject) ) {
				$context .= '

';
				$context .= htmlspecialchars_decode( $postArr[0] -> subject );
				$context .= '

';
			}

			$context .= $this -> clearer( );

			$keywords = '';

			$query = DB::select('
				SELECT `keyword`
				FROM `forum_posts`
				WHERE `id` = ' . $postArr[0] -> id . '
			');

			if( $query ) {

				$keywords = explode(',', $query[0] -> keyword);

				if( $query[0] -> keyword != '' ) {
					$context .= '
';
					foreach( $keywords as $keyword ) {
						$context .= '#' . $keyword . ' ';
					}
					$context .= '
';
				}
			}

		}

		$context .= $this -> clearer( );

		if( !empty( $postArr ) && $this -> user && $this -> group != 0 && $this -> group <= $this -> groupMember && !$answer ) {

			$context .= '
';

			$context .= '
 topic_id . '_' . $itemID . '">Reply
';

			if( $this -> admin || $this -> owner ) {

				$context .= '
 topic_id . '_' . $itemID . '">Edit
';
				$context .= '
 topic_id . '_' . $itemID . '">Delete
';

				if( $this -> answers ) {

					$context .= '
 topic_id . '_' . $itemID . '">Manage replies
';

				}

			}

			$context .= '
';

		}

		$replys = $this -> checkReplys( $catID, $topicID, $itemID );

		if( $replys ) {

			$context .= '
';

			$rc = 0;
			foreach( $replys as $reply ) {

				$context .= '
' . ucfirst( $this -> getUsername( $catID, $topicID, $itemID, $reply -> user_id ) ) . ' answers:
';

				$context .= '
”' . $reply -> title . '”
';

				$context .= ($reply -> update != 0) ? '
' . date( 'H:i - m/d/Y', strtotime( $reply -> update ) ) . '
' : '
no date
';

				if( !empty( $reply -> subject ) ) $context .= '
' . htmlspecialchars_decode( $reply -> subject ) . '
';

				$rc++;
			}

			$context .= '
';

		}

		return $context;

	}

	/**
	 * read database :: count all topics of a category
	 *
	 * @access	private
	 * @param  string
	 * @return  integer
	 */
	private function getMaxCats( $catID, $topicID ) {

		$query = DB::select( '
			SELECT count(*) AS `cnt`
			FROM `forum_posts`
			WHERE `topic_id` = ' . $topicID . '
			AND `parent_id` = 0
			ORDER BY `crdate` DESC
		' );

		$result = $query;

		return ($result) ? $result[0] -> cnt : 0;

	}

	/**
	 * read database :: get topic list
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getTopicList( $catID ) {

		$context = '';

		$query = DB::select( '
			SELECT *
			FROM `forum_topics`
			WHERE `cat_id` = ' . $catID . '
			AND hidden = 0
		' );
		$result = $query;

		if( $result ) {

			$context .= '

';

			$context .= 'Order after:';
			$context .= '<select name="newForumOrder">';

			$context .= '<option value="0">As first entry</option>';

			$tc = 1;
			foreach( $result as $topic ) {
				$context .= '<option value="' . $tc . '">' . $this -> getTopicName( $catID, $topic -> id ) . '</option>';
				$tc++;
			}

			$context .= '<option value="' . $tc . '" selected="selected">As last entry</option>';

			$context .= '</select>';

			$context .= $this -> clearer( );

		} else {

			$context .= '<input type="hidden" name="newForumOrder" value="0" />';

		}

		return $context;

	}

	/**
	 * read database :: get topic title
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getTopicName( $catID, $topicID ) {

		$topicName = '';

		$query = DB::select( '
			SELECT *
			FROM `forum_topics`
			WHERE `cat_id` = ' . $catID . '
			AND `id` = ' . $topicID . '
			AND `hidden` = 0
		' );
		$result = $query;

		if( $result ) {
			$topicName = $result[0] -> name;
		}

		return $topicName;
	}

	/**
	 * write database :: new category
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function newCat( $catName, $topicOrder = 0 ) {

		$catName = strtoupper( $catName );

		if( $this -> group != 0 && $this -> group <= $this -> groupMod ) {

			if( !empty( $catName ) ) {

				$query = DB::insert( '
					INSERT INTO `forum_cats` (
					`id` ,
					`name` ,
					`order` ,
					`hidden`
					)
					VALUES (
					null, "' . $catName . '", ' . $this -> maxCats . ', 0
					);
				' );
			}

		}

		return;
	}

	/**
	 * write database :: new topic
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function newTopic( $forumID, $topicName, $topicOrder ) {

		if( !empty( $topicName ) && $this -> user && $this -> group != 0 && $this -> group <= $this -> groupMod ) {

			$topicName = strtoupper( $topicName );

			if( $this -> group != 0 && $this -> group <= $this -> groupMod ) {

				$query = DB::insert( '
					INSERT INTO `forum_topics` (
					`id` ,
					`name` ,
					`order` ,
					`hidden` ,
					`cat_id`
					)
					VALUES (
					null, "' . $topicName . '", ' . $this -> maxTopics . ', 0, ' . $forumID . '
					);
				' );

			}

		}

		return;
	}

	/**
	 * write database :: delete category
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function removeCat( $catID ) {

		if( $this -> user && $this -> group != 0 && $this -> group <= $this -> groupMod ) {

			$query = DB::select( '
				SELECT *
				FROM `forum_topics`
				WHERE `cat_id` = ' . $catID . '
			' );
			$result = $query;

			if( $result ) {

				foreach( $result as $topic ) {
					DB::delete( '
						DELETE FROM `forum_posts` WHERE `topic_id` = "' . $topic -> id . '";
					' );
				}

			}

			$query = DB::select( '
				SELECT count(*) AS cnt
				FROM `forum_topics`
				WHERE `cat_id` = ' . $catID . '
			' );
			$result = $query;

			if( $result ) {

				DB::delete( '
					DELETE FROM `forum_topics` WHERE `cat_id` = "' . $catID . '";
				' );

			}

			DB::delete( '
				DELETE FROM `forum_cats` WHERE `id` = "' . $catID . '";
			' );

		}

		return;

	}

	/**
	 * write database :: delete topic
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function removeTopic( $topicID ) {

		if( $this -> user && $this -> group != 0 && $this -> group <= $this -> groupMod ) {

			$query = DB::select( '
				SELECT count(*) AS cnt
				FROM `forum_posts`
				WHERE `topic_id` = ' . $topicID . '
			' );
			$result = $query;

			if( $result ) {

				DB::delete( '
					DELETE FROM `forum_posts` WHERE `topic_id` = "' . $topicID . '";
				' );

			}

			DB::delete( '
				DELETE FROM `forum_topics` WHERE `id` = "' . $topicID . '";
			' );

		}

		return;

	}

	/**
	 * read database :: get post title
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getPostName( $catID, $topicID, $itemID ) {

		$postName = 'No label';

		$query = DB::select( '
			SELECT title
			FROM `forum_posts`
			WHERE `id` = ' . $itemID . '
		' );
		foreach( $query as $post ) {
			$postName = $post -> title;
		}

		return $postName;
	}

	/**
	 * read database :: get post message
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getPostMsg( $catID, $topicID, $itemID ) {

		$postName = '';

		$query = DB::select( '
			SELECT subject
			FROM `forum_posts`
			WHERE `id` = ' . $itemID . '
		' );
		foreach( $query as $post ) {
			$postName = $post -> subject;
		}

		return $postName;
	}

	/**
	 * write database :: write post
	 *
	 * @access	private
	 * @param  string
	 */
	private function newPost( $catID, $topicID, $itemID = 0, $postTitle = '', $postMessage = '', $genreID = 0, $postKeyword = '' ) {

		if( !empty( $postTitle ) && $this -> group != 0 && $this -> group <= $this -> groupMember ) {

			$nowTime = date( 'Y-m-d H:i:s', time( ) );

			DB::insert( '
				INSERT INTO `forum_posts` (
				`id` ,
				`rank` ,
				`hits` ,
				`title` ,
				`genre` ,
				`subject` ,
				`keyword` ,
				`crdate` ,
				`update` ,
				`clicked`,
				`hidden` ,
				`user_id` ,
				`topic_id`,
				`parent_id`
				)
				VALUES (
				NULL , "1", "0", "' . $postTitle . '", "' . $genreID . '", "' . $postMessage . '", "' . $postKeyword . '", "' . $nowTime . '", "' . $nowTime . '", "' . $nowTime . '", "0", "' . $this -> userID . '", "' . $topicID . '", "' . $itemID . '"
				);
			' );

		}

		return;
	}

	/**
	 * write database :: update post
	 *
	 * @access	private
	 * @param  string
	 */
	private function updatePost( $catID, $topicID, $itemID = 0, $postTitle = '', $postMessage = '', $genreID = 0, $postKeyword = '' ) {

		$nowTime = date( 'Y-m-d H:i:s', time( ) );

		if( !empty( $postTitle ) && !empty( $postMessage ) && $this -> group != 0 && $this -> group <= $this -> groupMember || $this -> user && $this -> group <= $this -> groupMod ) {

			DB::update( '
				UPDATE `forum_posts`
				SET
					`title` = "' . $postTitle . '",
					`genre` = "' . $genreID . '",
					`subject` = "' . $postMessage . '",
					`keyword` = "' . $postKeyword . '",
					`update` = "' . $nowTime . '",
					`topic_id` = "' . $topicID . '"
				WHERE `id` = "' . $itemID . '"
			' );

			DB::update( '
				UPDATE `forum_posts`
				SET
					`topic_id` = "' . $topicID . '"
				WHERE `parent_id` = "' . $itemID . '"
			' );

		}

		return;
	}

	/**
	 * write database :: write answer
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function replyPost( $catID, $topicID, $itemID, $postTitle, $postMessage = '' ) {

		$nowTime = date( 'Y-m-d H:i:s', time( ) );

		if( $this -> group != 0 && $this -> group <= $this -> groupMember ) {

			DB::update( '
				UPDATE `forum_posts`
				SET
					`update` = "' . $nowTime . '"
				WHERE `id` = "' . $itemID . '"
			' );

			$queryx = DB::update( '
				UPDATE `forum_posts`
				SET `rank` = `rank` + 1
				WHERE `id` = ' . $itemID . '
			' );

			DB::insert( '
				INSERT INTO `forum_posts` (
				`id` ,
				`title` ,
				`genre` ,
				`subject` ,
				`keyword` ,
				`crdate` ,
				`update` ,
				`clicked` ,
				`hidden` ,
				`user_id` ,
				`topic_id`,
				`parent_id`
				)
				VALUES (
				NULL , "' . $postTitle . '", "0", "' . $postMessage . '", "", "' . $nowTime . '", "' . $nowTime . '", "' . $nowTime . '", "0", "' . $this -> userID . '", "' . $topicID . '", "' . $itemID . '"
				);
			' );

		}

		return;
	}

	/**
	 * write database :: delete post
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function removePost( $catID, $topicID, $itemID ) {

		if( $this -> group <= $this -> groupMember && $this -> owner || $this -> user && $this -> group <= $this -> groupMod ) {

			DB::delete( '
				DELETE FROM `forum_posts`
				WHERE `id` = ' . $itemID . '
				OR `parent_id` = ' . $itemID . '
			' );

		}

		return;
	}

	/**
	 * read database :: get latest posts
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function latestPosts( $year = 0, $month = 0, $day = 0 ) {

		$context = '';

		if( $this -> showLatestPosts ) {

			// SELECT `rank`,`hits` FROM (SELECT `rank`, `hits` FROM `forum_posts` ORDER BY `hits`) AS `matches` GROUP BY `rank`;
			/*
			 $query = DB::select( '
			 SELECT *
			 FROM `forum_posts`
			 WHERE `update` > SUBTIME(NOW(), "' . $this -> showLatestPostsDelay . ':0:0")
			 AND `parent_id` = 0
			 ORDER BY `update` DESC
			 ' );
			 $result = $query;
			*/

			if( !$this -> showDate ) {

				$query = DB::select( '
					SELECT *
					FROM (
						SELECT *
						FROM (
							SELECT *
							FROM (
								SELECT *
								FROM (
									SELECT *
									FROM (
										SELECT *
										FROM `forum_posts`
										WHERE `update` > SUBTIME(NOW(), "' . $this -> showLatestPostsDelay . ':0:0")
										AND `parent_id` = 0
										ORDER BY `crdate` DESC
									) AS `matches`
									ORDER BY `hits` DESC
								) AS `score`
								ORDER BY `rank` DESC
							) AS `reorder`
							ORDER BY `clicked` DESC
						) AS `latest`
						ORDER BY `update` DESC
					) AS `interact`
				' );
				$result = $query;

			} else {

				$query = DB::select( '
					SELECT *
					FROM (
						SELECT *
						FROM (
							SELECT *
							FROM (
								SELECT *
								FROM (
									SELECT *
									FROM (
										SELECT *
										FROM `forum_posts`
										WHERE `update` >= "' . $year . '-' . $month . '-' . $day . ' 00:00:00"
										AND `update` <= "' . $year . '-' . $month . '-' . $day . ' 23:59:59"
										AND `parent_id` = 0
										ORDER BY `crdate` DESC
									) AS `matches`
									ORDER BY `hits` DESC
								) AS `score`
								ORDER BY `rank` DESC
							) AS `reorder`
							ORDER BY `clicked` DESC
						) AS `latest`
						ORDER BY `update` DESC
					) AS `interact`
				' );
				$result = $query;

			}

			if( $result ) {

				$context .= '

';
				//$context .= ( $this -> showLatestPostsDelay > 24 ) ? '
Latest posts of the last ' . ( (int) $this -> showLatestPostsDelay / 24 ) . ' days
' : '
Latest posts of the last ' . $this -> showLatestPostsDelay . ' hours
' ;
				$context .= '
The Stream
';

				$context .= '
';

				foreach( $result as $post ) {

					$query = DB::select( '
						SELECT *
						FROM `forum_topics`
						WHERE `id` = ' . $post -> topic_id . '
					' );
					$fetch = $query;

					if( $fetch ) {

						$context .= '
';

						$postDate = strtotime( $post -> crdate );
						$nowTime = time();

						if( (($nowTime - $postDate)/3600) < $this -> fresh ) {
							$new = true;
						} else {
							$new = false;
						}

						$context .= '
';
						$context .= ' cat_id . '/' . $fetch[0] -> id . '/?genre=' . $post -> genre . '" target="_self">';
						$context .= '' . $this -> getGenre( $fetch[0] -> cat_id, $fetch[0] -> id, $post -> id, $post -> user_id );
						$context .= '';
						$context .= '
';

						$context .= '
 cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '">
';

						$context .= '
';
						if( $new ) {
							$context .= ' cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '" title="" target="_self">' . $post -> title . '(' . $post -> hits . ' hits)' . '';
						} else {
							$context .= ' cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '" title="" target="_self">' . $post -> title . '(' . $post -> hits . ' hits)' . '';
						}
						$context .= '
';

						$context .= '
';
						$context .= ' cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '/" target="_self">';
						$context .= '' . date( 'H:i - m/d/Y', strtotime( $post -> update ) );
						$context .= '';
						$context .= '
';

						$context .= '
';
						$context .= ' cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '/" target="_self">';
						$context .= '' . $this -> getUsername( $fetch[0] -> cat_id, $fetch[0] -> id, $post -> id, $post -> user_id );
						$context .= '';
						$context .= '
';

						$context .= '
';

						$queryx = DB::select( '
							SELECT *
							FROM `forum_posts`
							WHERE `parent_id` = ' . $post -> id . '
							ORDER BY `crdate` ASC
						' );
						$resultx = $queryx;

						if( $resultx ) {

							foreach( $resultx as $rx ) {

								$context .= '
';

								$context .= '

';

								$context .= '
';
								$context .= ' cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '" title="" target="_self">' . $rx -> title . '';
								$context .= '
';

								$context .= '
';
								$context .= ' cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '/" target="_self">';
								$context .= '' . date( 'H:i - m/d/Y', strtotime( $rx -> update ) );
								$context .= '';
								$context .= '
';

								$context .= '
';
								$context .= ' cat_id . '/' . $fetch[0] -> id . '/' . $post -> id . '/" target="_self">';
								$context .= '' . $this -> getUsername( $fetch[0] -> cat_id, $fetch[0] -> id, $rx -> id, $rx -> user_id );
								$context .= '';
								$context .= '
';

								$context .= '
';

							}

						}

					}

				}

				$context .= '
';

				$context .= '

';

			}

		}

		return $context;
	}

	/**
	 * read database :: check if post has replies
	 *
	 * @access	private
	 * @param  string
	 * @return  array
	 */
	private function checkReplys( $catID, $topicID, $itemID ) {

		$context = '';

		$postArr = array( );

		$query = DB::select( '
			SELECT *
			FROM `forum_posts`
			WHERE `topic_id` = ' . $topicID . '
			AND `parent_id` = ' . $itemID . '
			AND `hidden` = 0
		' );

		$pc = 0;
		foreach( $query as $post ) {
			$postArr[$pc] = $post;
			$pc++;
		}

		if( !empty( $postArr ) )
			$this -> answers = true;

		return $postArr;
	}

	/**
	 * read database :: get answers list
	 *
	 * @access	private
	 * @param  string
	 * @return  array
	 */
	private function manageReplys( $catID, $topicID, $itemID ) {

		$context = '';

		$postArr = array( );

		$query = DB::select( '
			SELECT *
			FROM `forum_posts`
			WHERE `topic_id` = ' . $topicID . '
			AND `parent_id` = ' . $itemID . '
			AND `hidden` = 0
		' );

		$pc = 0;
		foreach( $query -> result( ) as $post ) {
			$postArr[$pc] = $post;
			$pc++;
		}

		return $postArr;
	}

	/**
	 * write database :: update answer
	 *
	 * @access	private
	 * @param  string
	 */
	private function updateAnswer( $catID, $topicID, $itemID = 0, $answerTitle = '', $answerMessage = '' ) {

		$nowTime = date( 'Y-m-d H:i:s', time( ) );

		if( $this -> owner && $this -> group != 0 && $this -> group <= 3 || $this -> user && $this -> group <= 2 ) {

			DB::update( '
				UPDATE `forum_posts`
				SET
					`title` = "' . $answerTitle . '",
					`subject` = "' . $answerMessage . '",
					`user_id` = "' . $this -> userID . '",
					`crdate` = "' . $nowTime . '"
				WHERE `id` = "' . $itemID . '"
			' );

		}

		return;
	}

	/**
	 * write database :: delete answer
	 *
	 * @access	private
	 * @param  string
	 */
	private function removeAnswer( $catID, $topicID, $itemID = 0, $answerID = 0 ) {

		$nowTime = date( 'Y-m-d H:i:s', time( ) );

		if( $this -> owner && $this -> group != 0 && $this -> group <= 3 || $this -> user && $this -> group <= 2 ) {

			DB::delete( '
				DELETE FROM `forum_posts`
				WHERE `id` = ' . $itemID . '
			' );

		}

		return;
	}

	/**
	 * read database :: get username
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getUsername( $catID, $topicID, $itemID, $userID = 0 ) {

		return $this -> classUser -> getUsername( $catID, $topicID, $itemID, $userID );

	}

	/**
	 * read database :: get genre
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function getGenre( $catID, $topicID, $itemID ) {

		$query = DB::select( '
			SELECT `genre`
			FROM `forum_posts`
			WHERE `hidden` = "0"
			AND `id` = "' . $itemID . '"
		' );
		$result = $query;

		if( $result ) {

			$queryx = DB::select( '
				SELECT *
				FROM `forum_genres`
				WHERE `hidden` = "0"
				AND `id` = "' . $result[0] -> genre . '"
			' );
			$resultx = $queryx;

		}

		if( $resultx ) {
			return $resultx[0] -> name;
		} else {
			return 'Main';
		}

	}

	/**
	 * read database :: check if user is owner of post
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function checkOwner( $catID, $topicID, $itemID ) {

		$this -> owner = false;

		$query = DB::select( '
			SELECT `user_id`
			FROM `forum_posts`
			WHERE `id` = ' . $itemID . '
		' );
		$result = $query;

		if( $result ) {

			$this -> owner = ($this -> user && $this -> group <= 2 || $result[0] -> user_id == $this -> userID) ? true : false;

		}

		return;
	}

	/**
	 * read database :: search posts for string
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function forumSearch( ) {

		$context = '';

		//$context .= '

';

		$context .= '

';

		$context .= '<form action="/community/forum" method="post">';

		$context .= '';

		$context .= ( isset( $this -> post['forumSearchField'] )) ? '<input class="forumSearchField setFocus" name="forumSearchField" value="' . $this -> post['forumSearchField'] . '" />' : '<input class="forumSearchField setFocus" name="forumSearchField" value="Enter searchpattern..." />';

		$context .= '</form>';

		if( isset( $this -> post['forumSearchField'] ) && !empty( $this -> post['forumSearchField'] ) ) {

			if( strlen( $this -> post['forumSearchField'] ) < 3 ) {

				$context .= '

';
				$context .= '
Please enter more than 2 chars!
';
				$context .= '

';

				$context .= '
';

				return $context;

			}

			$searchString = htmlspecialchars( $this -> post['forumSearchField'] );

			$search = DB::select( '
				SELECT `id`
				FROM `forum_users`
				WHERE `name` LIKE "%' . $searchString . '%"
			' );
			$id = $search;
			if( $id ) {

				$userID = $id[0] -> id;

			} else {

				$userID = 0;

			}

			$query = DB::select( '
			SELECT *
			FROM (
				SELECT *
				FROM (
					SELECT *
					FROM `forum_posts`
					WHERE `title` LIKE "%' . $searchString . '%"
					AND `parent_id` = "0"
					AND `hidden` = "0"
					OR `subject` LIKE "%' . $searchString . '%"
					AND `parent_id` = "0"
					AND `hidden` = "0"
					OR `genre` = (
						SELECT `id`
						FROM `forum_genres`
						WHERE `name` LIKE "%' . $searchString . '%"
					)
					AND `parent_id` = "0"
					AND `hidden` = "0"
					OR `keyword` LIKE "%' . $searchString . '%"
					AND `parent_id` = "0"
					AND `hidden` = "0"
					OR `user_id` = "' . $userID . '"
					AND `parent_id` = "0"
					AND `hidden` = "0"
					ORDER BY `update` DESC
				) AS `matches`
				ORDER BY `hits` DESC
			) AS `reorder`
			ORDER BY `rank` DESC
			' );
			$result = $query;

			if( $result ) {

				$context .= '

';

				$context .= '
';

				$this -> search = true;

				$resultIndex = 0;
				foreach( $result as $post ) {

					$query1 = DB::select( '
						SELECT `cat_id`
						FROM `forum_topics`
						WHERE `id` = ' . $post -> topic_id . '
					' );
					$result1 = $query1;

					if( $result1 ) {

						$catID = $result1[0] -> cat_id;

						$resultNr = $resultIndex + 1;
						$resultNr = (strlen( $resultNr ) == 1) ? '00' . $resultNr : $resultNr;
						$resultNr = (strlen( $resultNr ) == 2) ? '0' . $resultNr : $resultNr;

						$context .= '
';

						$context .= '
';
						$context .= ' topic_id . '/' . $post -> id . '" target="_self">';
						$context .= '' . $resultNr . ': ' . $post -> title . '';
						$context .= '';
						$context .= '
';

						$context .= '
';
						$context .= ' topic_id . '/' . $post -> id . '" target="_self">';
						$context .= ($post -> update != 0) ? '' . date( 'H:i - m/d/Y', strtotime( $post -> update ) ) : 'no date available...';
						$context .= '';
						$context .= '
';

						$context .= '
';
						$context .= ' topic_id . '/' . $post -> id . '" target="_self">';
						$context .= '' . $this -> getUsername( $catID, $post -> topic_id, $post -> id, $post -> user_id );
						$context .= '';
						$context .= '
';

						$context .= '
';

					}

					$resultIndex++;

				}

				$context .= '
';

			}

			$context .= $this -> clearer( );

		}

		$context .= '

';

		return $context;

	}

	private function memberLogin( $catID = 1, $topicID = 1, $itemID = 1, $userID = 0 ) {

		$context = '';

		if( !$this -> user ) {

			$context .= '
';

			$context .= '<form action="/community" method="post">';

			$context .= '
Account:
';

			$context .= '<input class="memberName" type="text" name="memberEmail" value="eMail" />';

			$context .= '<input class="memberPass" type="<PASSWORD>" name="memberPass" value="<PASSWORD>" />';

			$context .= '<input class="memberSubmit" name="memberSubmit" type="submit" value="Login">';

			$context .= '</form>';

			if( $this -> message != 0 )
				$context .= $this -> msg( );

			$context .= '
';

		} else {

			$context .= '
';

			$context .= '<form action="/community" method="post">';

			$context .= '
Hello ' . $this -> userName . ' (' . $this -> userEmail . ') !
';

			$context .= '<input class="memberLogout" name="memberLogout" type="submit" value="Logout">';

			$context .= '</form>';

			$context .= '
';

			$context .= $this -> classProfile -> template( $this -> userID );

			$context .= $this -> clearer( );

			$this -> statistics = true;

		}

		return $context;

	}

	private function msg( ) {

		$msg = '';

		$msg .= '
';

		$msg .= '
';

		switch( $this -> message ) {

			case 1:
				$msg .= 'All Ok.';
				break;

			case 4:
				$msg .= '404 error! File or pathname is wrong!';
				break;

			case 10:
				$msg .= 'Login error! Account not found.';
				break;

			case 11:
				$msg .= 'Account has been created...';
				break;

			case 12:
				$msg .= 'Create account failed! Already registered???';
				break;

			case 13:
				$msg .= 'Please fill out all fields!';
				break;
		}

		$msg .= '
';

		$msg .= '
';

		$msg .= $this -> clearer( );

		return $msg;

	}

	private function showTheTopics( ) {

		$context = '';

		$query = DB::select( '
			SELECT *
			FROM `forum_topics`
			WHERE `hidden` = 0
			ORDER BY `name` ASC
		' );
		$result = $query;

		if( $result ) {

			$context .= '

';

			$context .= '
The Topics
';

			$context .= '
';

			foreach( $result as $topic ) {

				$context .= '
';
				$context .= ' cat_id . '/' . $topic -> id . '/" title="">' . $topic -> name . '';

				$queryx = DB::select( '
					SELECT t.`genre`, g.`id`, g.`name`
					FROM `forum_genres` AS g
					LEFT JOIN `forum_posts` AS t
					ON g.`id` = t.`genre`
					WHERE t.`topic_id` = ' . $topic -> id . '
					GROUP BY t.`genre`
				' );
				$resultx = $queryx;

				if( $resultx ) {

					$context .= '
';

					foreach( $resultx as $rx ) {

						if( $rx -> id != 0 ) {

							$context .= '
';
							$context .= ' cat_id . '/' . $topic -> id . '/?genre=' . $rx -> genre . '" title="">' . $rx -> name . '';
							$context .= '
';

						}

					}

					$context .= '
';

				}

				$context .= '
';

			}

			$context .= '
';

			$context .= '

';

		}

		return $context;
	}

	private function optionGenres( ) {

		$context = '';

		$query = DB::select( '
			SELECT *
			FROM `forum_genres`
			WHERE `hidden` = "0"
			ORDER BY `name` ASC
		' );
		$result = $query;

		if( $result ) {

			$context .= 'Genre:';
			$context .= '<select name="genreID">';

			foreach( $result as $genre ) {
				if( $genre -> id == 1 ) {
					$context .= '<option value="' . $genre -> id . '" selected="selected">' . $genre -> name . '</option>';
				} else {
					$context .= '<option value="' . $genre -> id . '">' . $genre -> name . '</option>';
				}
			}
			$context .= '</select>';

		} else {

			$context .= '<input type="hidden" name="genreID" value="1" />';

		}

		return $context;
	}

	private function optionKeyword( $catID = 0, $topicID = 0, $itemID = 0 ) {

		$context = '';

		$context .= 'Keywords:';
		$context .= '<textarea class="quickPostKeyword" name="quickPostKeyword">' . $this -> getPostKeywords( $catID, $topicID, $itemID ) .'</textarea>';

		return $context;
	}

	private function getPostGenre( $catID = 0, $topicID = 0, $itemID = 0 ) {

		$context = '';

		$query = DB::select( '
			SELECT *
			FROM `forum_genres`
			WHERE `hidden` = "0"
			ORDER BY `name` ASC
		' );
		$result = $query;

		if( $result ) {

			$queryx = DB::select( '
				SELECT `genre`
				FROM `forum_posts`
				WHERE `id` = ' . $itemID . '
				AND `hidden` = 0
			' );
			$resultx = $queryx;

			$context .= 'Genre:';
			$context .= '<select name="genreID">';

			foreach( $result as $genre ) {
				if( $resultx[0] -> genre != 0 ) {

					if( $genre -> id == $resultx[0] -> genre ) {
						$context .= '<option value="' . $genre -> id . '" selected="selected">' . $genre -> name . '</option>';
					} else {
						$context .= '<option value="' . $genre -> id . '">' . $genre -> name . '</option>';
					}

				} else {

					if( $genre -> name == 'Main' ) {
						$context .= '<option value="' . $genre -> id . '" selected="selected">' . $genre -> name . '</option>';
					} else {
						$context .= '<option value="' . $genre -> id . '">' . $genre -> name . '</option>';
					}

				}
			}

			$context .= '</select>';

		} else {

			$context .= '<input type="hidden" name="genreID" value="1" />';

		}

		return $context;
	}

	/**
	 * template :: clearfix
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function clearer( ) {

		return '

';

	}

	/**
	 * template :: clearfix
	 *
	 * @access	private
	 * @param  string
	 * @return  string
	 */
	private function spacer( ) {

		return '

';

	}

	private function getPostKeywords( $catID, $topicID, $itemID ) {

		$context = '';

		$query = DB::select('
			SELECT `keyword`
			FROM `forum_posts`
			WHERE `id` = ' . $itemID . '
		');

		if( $query ) {
			$context .= $query[0] -> keyword;
		}

		return $context;
	}

}
<file_sep>/app/Http/Middleware/forum/mod_chart.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Chart extends Eloquent {

	public function __construct( ) {

		parent::__construct( );

		$this -> classStats = new Mod_Statistics;

		$this -> chartHeight = 100;

	}

	public function template( $userID, $isUser = false, $show = false ) {
		return $this -> main( $userID, $isUser );
	}

	private function main( $userID, $isUser ) {

		$chartArr = array();

		$context = '';

		$loopMonth = (int) date('m', time());
		$loopMonth = ( $loopMonth < 10 ) ? '0' . $loopMonth : $loopMonth ;

		$loopYear = (int) date('Y', time());

		$loopDays = cal_days_in_month( CAL_GREGORIAN, $loopMonth, $loopYear ) + 1;

		$context .= '

';

		$context .= '

';

		$context .= '
';

		$context .= '

';

		$context .= '
VisitCounter (Logins per Day)
';

		$context .= '<canvas id="visitChart" width="1215" height="' . $this -> chartHeight . '"></canvas>';

		$context .= '
';

		$context .= '';

		$context .= '

';

		$context .= '

';

		$context .= '
';

		$context .= '

';

		$context .= '
GuestCounter (Guests per Day)
';

		$context .= '<canvas id="guestChart" width="1215" height="' . $this -> chartHeight . '"></canvas>';

		$context .= '
';

		$context .= '';

		$context .= '

';

		$context .= '

';

		$context .= '
';

		$context .= '

';

		$context .= '
Workflow (Posts per Day)
';

		$context .= '<canvas id="myChart" width="1215" height="' . $this -> chartHeight . '"></canvas>';

		$context .= '
';

		$context .= '';

		$context .= '

';

		$context .= '

';

		$context .= '
';

		$context .= '

';

		$context .= '
HitCounter (Clicks per Day)
';

		$context .= '<canvas id="hitChart" width="1215" height="' . $this -> chartHeight . '"></canvas>';

		$context .= '
';

		$context .= '';

		return $context;
	}

}<file_sep>/app/Http/Middleware/forum/mod_statistics.php
<?php

/**
 * MOD Forum
 * This module coordinates the controller instructions
 * and defines the HTML for each function
 *
 * @package  Forum
 * @subpackage  Code Igniter Forum
 * @category  Application
 * @author  <NAME>
 * @link  http://loopshape.com/
 */
class Mod_Statistics extends Eloquent {

	public function __construct( ) {
		parent::__construct( );
	}

	public function getCountVisits( $loopDay = 0, $loopMonth = 0, $loopYear = 0 ) {
		return $this -> countVisits( $loopDay, $loopMonth, $loopYear );
	}

	public function getCountLogins( $loopDay = 0, $loopMonth = 0, $loopYear = 0 ) {
		return $this -> countLogins( $loopDay, $loopMonth, $loopYear );
	}

	public function setGuest( $guestArr = array() ) {
		return $this -> writeGuestData( $guestArr );
	}

	public function setLogin( $userID = 0 ) {
		return $this -> writeLoginData( $userID );
	}

	private function countVisits( $loopDay, $loopMonth, $loopYear ) {

		$count = 0;

		$dbDateStart = $loopYear . '-' . $loopMonth . '-' . $loopDay . ' 00:00:00';
		$dbDateStop = $loopYear . '-' . $loopMonth . '-' . $loopDay . ' 23:59:59';

		$query = DB::select( '
			SELECT COUNT(`loginuser`) AS `lcount`
			FROM `forum_counts`
			WHERE `logindate` >= "' . $dbDateStart . '"
			AND `logindate` <= "' . $dbDateStop . '"
			AND `loginuser` = "0"
			ORDER BY `logindate` ASC
		' );
		$result = $query;

		if( $result ) {

			$count = $result[0] -> lcount;

		}

		return $count;
	}

	private function countLogins( $loopDay, $loopMonth, $loopYear ) {

		$count = 0;

		$dbDateStart = $loopYear . '-' . $loopMonth . '-' . $loopDay . ' 00:00:00';
		$dbDateStop = $loopYear . '-' . $loopMonth . '-' . $loopDay . ' 23:59:59';

		$query = DB::select( '
			SELECT COUNT(`loginuser`) AS `lcount`
			FROM `forum_counts`
			WHERE `logindate` >= "' . $dbDateStart . '"
			AND `logindate` <= "' . $dbDateStop . '"
			AND `loginuser` != "0"
			ORDER BY `logindate` ASC
		' );
		$result = $query;

		if( $result ) {

			$count = $result[0] -> lcount;

		}

		return $count;
	}

	private function writeLoginData( $userID ) {

		if( $userID != 0 ) {

			if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
			    $userIP = $_SERVER['HTTP_CLIENT_IP'];
			} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
			    $userIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
			} else {
			    $userIP = $_SERVER['REMOTE_ADDR'];
			}

			DB::insert( '
				INSERT INTO `forum_counts` (
				`id` ,
				`loginuser` ,
				`logindate` ,
				`loginip`
				)
				VALUES (
				NULL , "' . $userID . '",
				CURRENT_TIMESTAMP , "' . $userIP . '"
				);
			' );

		}

		return;
	}

	private function writeGuestData( $guestArr ) {

		$dbDateStart = date('Y-m-d 00:00:00', time());
		$dbDateStop = date('Y-m-d 23:59:59', time());

		if( !preg_match('/^::1/', $guestArr['ip']) ) {

			$query = DB::select( '
				SELECT `loginip`
				FROM `forum_counts`
				WHERE `logindate` >= "' . $dbDateStart . '"
				AND `logindate` <= "' . $dbDateStop . '"
				AND `loginip` = "' . $guestArr['ip'] . '"
				ORDER BY `logindate` DESC
			' );
			$result = $query;

			if( !$result ) {

				if( !empty($guestArr['ip']) ) {

					DB::insert( '
						INSERT INTO `forum_counts` (
						`id` ,
						`loginuser` ,
						`logindate` ,
						`loginip`
						)
						VALUES (
						NULL , "0",
						CURRENT_TIMESTAMP , "' . $guestArr['ip'] . '"
						);
					' );

				}

			}

		}

		return;

	}

}<file_sep>/resources/views/showscreen.blade.php

WELCOME TO THE TECH COMMUNITY!

Click on Account: to register an username

<file_sep>/public/lib/css/style_black.css
@charset 'utf-8';

/*
 * LOOPSHAPE FORUM CSS
 * by <NAME>
 * http://loopshape.com/
 */

/* LAYOUT RESET */
* {
	padding: 0;
	margin: 0;
	border: none;
	border-collapse: collapse;
	outline: none !important;
	-webkit-text-size-adjust: none;
}
*:hover, *:focus {
	outline: none !important;
}

/* TYPOGRAPHY */
h1, h2, h3, h4, h5, h6 { position: relative; z-index: 1000; }
h1 { font-size: 3em; }
h2,
.mega { font-size: 2em; line-height: 120%; margin-bottom: 18px; }
h3 { font-size: 1.6em; }
h4 { font-size: 1.2em; }
h5 { font-size: 1em; }
h6 { font-size: 0.9em; }
.mega { font-weight: bold; }

p, a {
	color: #444;
}

a {
	text-decoration: none;
}
a:hover {
	color: #888 !important;
}

div.postDetails a,
div.replySubject a {
	border-bottom: 1px dotted #888 !important;
}

.dummy,
.halfDummy {
	display: block;
	width: 100%;
	height: 16px;
}
.halfDummy {
	height: 1.64em;
}
.fixDummy {
	margin-top: -4px;
}

.hlPos {
	position: relative;
	top: -4px;
}
.hl {
	position: relative;
	top: -5px;
	font-size: 2em;
	display: inline-block;
	margin: 0 -4px;
}
.hlDesc {
	position: relative;
	top: 5px;
	left: 2px;
	font-weight: bold;
}
@-moz-document url-prefix() {
	.dummy {
		display: none;
	}
	.halfDummy {
		height: 2.30em;
	}
	.fixDummy {
		margin-top: -4px;
	}
	.hl {
		top: 16px;
	}
}

sup, sub {
	font-size: 0.80em;
}

.biggerFont {
	position: relative;
	top: 32px;
	left: -4px;
	float: left;
	margin-bottom: -20px;
	font-size: 7em;
}

.leftSpace {
	padding-left: 33px;
}
@-moz-document url-prefix() {
	.leftSpace {
		padding-left: 35px;
	}
}

.setFont {
	font-weight: bolder;
}

ul li {
	list-style: square;
	margin-left: 14px;
}

a.internal { border: none !important; }
a.internal,
a.external,
ul li a {
	/* border-bottom: 1px dotted #666;
	margin-bottom: -1px; */
}

i {
	padding-right: 0.32em;
}

hr {
	position: relative;
	display: block;
	width: 100%;
	height: 1px;
	border-color: #aaa;
	clear: both;
}
section#secHeader hr {
	margin-top: 20px;
	margin-bottom: 18px;
}

/* LAYOUT */
html, body {
	position: relative;
	width: 100%;
	height: 100%;
}
html {
	font-size: 100.1%;
	line-height: 100%;
	overflow-x: hidden;
}

body {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 62.5%;
	color: #444;
	background-color: #FDFDFD;
	overflow-x: hidden;
	overflow-y: auto;
}

#whiteBlock {
	position: absolute;
	top: 0;
	left: 50%;
	width: 1600px;
	height: 100%;
	margin-left: -800px;
	background-color: #FDFDFD;
	z-index: -1;
}

#background {
	position: fixed;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
	#background img {
		position: absolute;
		top: 50%;
		left: 50%;
		margin-top: -600px;
		margin-left: -1000px;
		width: 2000px;
		min-height: 100%;
		z-index: -1;
	}

	#topBlock {
		position: absolute;
		width: 100%;
		height: 10px;
		top: 43px;
		background-color: #555;
	}
	#topBlock {
		position: absolute;
		width: 100%;
		height: 10px;
		top: 0;
		background-color: #555;
	}

#intro,
#page {
	position: relative;
	display: block;
	float: left;
	width: 100%;
	height: auto;
	min-height: 100%;
	font-size: 1.4em;
	line-height: 1.4em;

-webkit-box-shadow: inset 0px 0px 60px 0px rgba(0, 0, 0, 0.25);
box-shadow: inset 0px 0px 60px 0px rgba(0, 0, 0, 0.25);
	z-index: 1;
	overflow: hidden;
}

	#page .wrapper {
		position: relative;
		width: 100% !important;
		margin: 0 auto;
	}

#upperBar {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 5px;
	background-color: #222;
-webkit-box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 1);
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 1);

}

#clickHeader {
	display: block;
	margin-bottom: 0px;
	line-height: 150%;
}
#clickHeader:hover,
#glossarHeader:hover,
.back { cursor: pointer; }

	#page > .wrapper {
		position: relative;
		display: block;
		min-width: 316px;
		max-width: 1260px;
		height: auto;
		padding: 0;
		text-align: left;
	}

#webOptions li {
	clear: both;
	float: left;
	width: 95%;
	list-style: none;
	margin-left: 0;
	margin-bottom: 1.38em;
}
@-moz-document url-prefix() {
	#webOptions li { margin-bottom: 1.4em; }
}
#webOptions li a {
	display: inline-block;
	border: none;
}
#webOptions li a,
#webOptions li a:hover,
section.block a.buttonBack { text-decoration: none; }

section.block img {
	margin: 1em 0;
}

/* CLASSES */
.big {
	font-weight: bold;
}

.italic {
	font-style: italic;
}

.underline {
	border-bottom: 1px solid #222;
	margin-bottom: -1px;
}

.small {
	font-size: 0.8em !important;
	line-height: 130%;
}

.row,
.col,
.block {
	position: relative;
}

.row {
	display: inline-block;
	width: 100%;
	vertical-align: top;
}

.col {
	display: inline-block;
	width: 24.75%;
	min-width: 308.75px;
	vertical-align: top;
}

.block {
	display: inline-block;
	width: auto;
	min-width: 308.75px;
	max-width: 49.5%;
	vertical-align: top;
}

.inner {
	padding: 35px 20px 45px;
}
#mainframe .inner {
	max-width: 269px;
}

.leftWall {
	border-left: 5px solid #222;
	padding-left: 10px;
}

.lineHeightFix {
	display: block;
	margin-top: -0.4em;
}

.blackBar {
	position: relative;
	display: block;
	width: 100%;
	height: 10px;
	background-color: #000;
}

.button {
	float: left;
}

.desktop {
	display: block;
	line-height: 147% !important;
}
.noMobile {
	display: inline-block;
}

.high {
	position: relative;
	top: -2px;
}

.noHeights {
	padding-top: 0 !important;
	padding-bottom: 0 !important;
}

.grey { color: #888 !important; }

.notice,
.notice * { color: #444 !important; }

.error {
	z-index: 3000;
	color: #822 !important;
}

img#portfolio {
	border: 1px solid #888;
}

/* TYPO3 RTE CSS */
.align-right {
	float: right;
}

.csc-textpic-caption {
	position: relative;
	float: left;
	width: 100%;
	height: auto;
	color: #ddd;
	background-color: #222;
	text-align: left;
	margin-top: -1px;
	padding: 5px 10px;
	overflow: hidden;
}

.horizLine {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 4%;
	margin-left: -2%;
	height: 1px;
	background-color: #fff;
}
.verticLine {
	position: absolute;
	top: -25px;
	left: 50%;
	width: 1px;
	height: 50px;
	background-color: #fff;
}
.horizLine, .verticLine {
-webkit-box-shadow: 0px 0px 2px 0px rgba(255,255,255, 1);
box-shadow: 0px 0px 2px 0px rgba(255,255,255, 1);
}

#secPanel .horizLine {
	margin-left: -37%;
}
#secPanel .horizLine + .horizLine {
	margin-left: -2%;
}
#secPanel .horizLine + .horizLine + .horizLine {
	margin-left: 33%;
}

#secPanel .verticLine {
	margin-left: -35%;
}
#secPanel .verticLine + .verticLine {
	margin-left: 0;
}
#secPanel .verticLine + .verticLine + .verticLine {
	margin-left: 35%;
}

#secPanel .horizLine.borderUp,
#secPanel .verticLine.borderUp {
	margin-top: -12%;
}
#secPanel .horizLine.borderDown,
#secPanel .verticLine.borderDown {
	margin-top: 12%;
}

#board .right {
	display: block;
}

#board .infos {
	display: block;
	position: absolute;
	left: 50%;
	margin-left: -140px;
	width: 220px;
	top: 175px;
	background-color: rgba(0,0,0,0.5);
	text-align: center;
	padding: 5px 10px;
	opacity: 0.5;
}
	#board .infos * {
		color: #fff;
	}

<file_sep>/public/lib/js/chat.js
var multitouch = 'click touchend';

var delay = 1000;

function soundNewLine( ) {
	soundManager.setup( {
		url : '../../lib/js/soundmanager/swf/',
		flashVersion : 9,
		preferFlash: true,
		onready : function( ) {
			var mySound = soundManager.createSound( {
				id : 'aSound',
				url : '../../assets/audio/wav/knockbass.wav'
			} );
			mySound.play( );
		},
		ontimeout : function( ) {
		}
	} );
}

function stringUppercase( str ) {
	str = str.toLowerCase( ).replace( /\b[a-z]/g, function( letter ) {
		return letter.toUpperCase( );
	} );
	return str;
}

var firstRun = false;

var soundrun = false;

var name = '';
var gravatar = '';

/**
 * Retrieves either a single cookie or the entire set of cookies. The array
 * is indexed by the cookie name.
 * @param cookie - name of the cookie you are interested in; can be null
 * @return - associative array of the cookies, or a string if you asked for a specific one
 *
 **/
function cookieCutter( cookie ) {
	var rawcookie = unescape( document.cookie.replace( /\+/g, '%20' ) );
	var elems = rawcookie.split( '=' );
	var cookies = {};
	for( var i = 0; i < elems.length; i++ ) {
		cookies[elems[i]] = elems[i + 1];
		i++;
	}
	if( null != cookie ) {
		return ( cookies[cookie] );
	}
	return ( cookies );
}

/**
 * Given a string that represents the contents of a server-side serialized PHP object, this
 * method will parse it out and return the appropriate object.
 * @param str - the serialized string
 * @return love and goodness of name=value pairs as an associative array for each item in the object
 *
 **/
function parseSerializedPHP( str ) {
	switch(str[0]) {
		case 'a':
			var retArray = {};
			var matches = str.match( /a:(\d+):(\{.*\})/ );
			var count = parseInt( matches[1] ) * 2;
			var subElems = matches[2].match( /((s:\d+:"[^"]*";)|([b|i|f]:\d+))/g );
			for( var i = 0; i < subElems.length; i++ ) {
				key = parseSerializedPHP( subElems[i] );
				retArray[key] = parseSerializedPHP( subElems[i + 1] );
				i++;
			}
			return ( retArray );
			break;

		case 's':
			return ( str.split('"')[1] );
			break;

		case 'i':
			return ( parseInt( str.match( /\d+/ ) ) );
			break;

		case 'b':
			return ( parseInt( str.match( /\d+/ ) ) ? true : false );
			break;
	}
	return ( null );
}

$( document ).ready( function( ) {

	if( $('#chatContainer').length ) {
		chat.init( );
		$('#chatContainer').hide();
	}

	function openChat() {
		$('.activateChat').on( multitouch, function() {

			$(this).off();

			if( !firstRun ) {

				firstRun = true;

				if( $.cookie( 'ci_session' ) ) {

					cookieData = parseSerializedPHP( $.cookie( 'ci_session' ) );

					name = cookieData.userName;
					gravatar = cookieData.userEmail;

					chat.login( name, gravatar );

				}

			} else {

				chat.login( name, gravatar );

			}

			$('#chatContainer').slideDown(delay);
			$('.activateChat').on( multitouch, function() {
				$(this).off();
				chat.logout();
				$('#chatContainer').slideUp(delay);
				openChat();
			});
		});
	}
	openChat();

} );

var chat = {

	// data holds variables for use in the class:

	data : {
		lastID : 0,
		noActivity : 0
	},

	// Init binds event listeners and sets up timers:

	init : function( ) {

		// Using the defaultText jQuery plugin, included at the bottom:
		$( '#name' ).defaultText( 'Benutzername' );
		$( '#email' ).defaultText( 'E-Mail (Gravatare sind aktiviert)' );

		// Converting the #chatLineHolder div into a jScrollPane,
		// and saving the plugin's API in chat.data:

		chat.data.jspAPI = $( '#chatLineHolder' ).jScrollPane( {
			verticalDragMinHeight : 12,
			verticalDragMaxHeight : 12
		} ).data( 'jsp' );

		// We use the working variable to prevent
		// multiple form submissions:

		var working = false;

		// Submitting a new chat entry:

		$( '#submitForm' ).submit( function( ) {

			var text = $( '#chatText' ).val( );

			if( text.length == 0 ) {
				return false;
			}

			if( working )
				return false;
			working = true;

			// Assigning a temporary ID to the chat:
			var tempID = 't' + Math.round( Math.random( ) * 1000000 ), params = {
				id : tempID,
				author : chat.data.name,
				gravatar : chat.data.gravatar,
				text : text.replace( /</g, '<' ).replace( />/g, '>' )
			};

			// Using our addChatLine method to add the chat
			// to the screen immediately, without waiting for
			// the AJAX request to complete:

			chat.addChatLine( $.extend( {}, params ) );

			// Using our tzPOST wrapper method to send the chat
			// via a POST AJAX request:

			$.tzPOST( 'submitChat', $( this ).serialize( ), function( r ) {
				working = false;

				$( '#chatText' ).val( '' );
				$( 'div.chat-' + tempID ).remove( );

				params['id'] = r.insertID;
				chat.addChatLine( $.extend( {}, params ) );
			} );

			return false;
		} );

		// Logging the user out:

		$( 'a.logoutButton' ).on( 'click', function( ) {

			$( '#chatTopBar > span' ).fadeOut( function( ) {
				$( this ).remove( );
			} );

			$( '#submitForm' ).fadeOut( function( ) {
				$( '#loginForm' ).fadeIn( );
			} );

			$.tzPOST( 'logout' );

			return false;
		} );

		// Checking whether the user is already logged (browser refresh)

		$.tzGET( 'checkLogged', function( r ) {
			if( r.logged && $('#chatContainer').css('display') != 'none' ) {
				chat.login( r.loggedAs.name, r.loggedAs.gravatar );
			}
		} );

		// Self executing timeout functions

		( function getChatsTimeoutFunction( ) {
			chat.getChats( getChatsTimeoutFunction );
		} )( );

		( function getUsersTimeoutFunction( ) {
			chat.getUsers( getUsersTimeoutFunction );
		} )( );

	},

	// The login method hides displays the
	// user's login data and shows the submit form

	login : function( name, gravatar ) {

		chat.data.name = name;
		chat.data.gravatar = gravatar;
		$( '#chatTopBar' ).html( chat.render( 'loginTopBar', chat.data ) );

		$( '#loginForm' ).fadeOut( function( ) {
			$( '#submitForm' ).fadeIn( );
			$( '#chatText' ).focus( );
		} );

	},

	// The logout method

	logout : function( name, gravatar ) {

		$.tzPOST( 'logout' );

	},

	// The render method generates the HTML markup
	// that is needed by the other methods:

	render : function( template, params ) {

		var arr = [];
		switch(template) {
			case 'loginTopBar':
				arr = ['', '', stringUppercase( params.name ), ''];
				break;

			case 'chatLine':
				arr = ['
', '', stringUppercase( params.author ), ':', params.text, '', params.time, '
'];
				break;

			case 'user':
				arr = ['

'];
				break;
		}

		// A single array join is faster than
		// multiple concatenations

		return arr.join( '' );

	},

	// The addChatLine method ads a chat entry to the page

	addChatLine : function( params ) {

		// All times are displayed in the user's timezone

		var d = new Date( );
		if( params.time ) {

			// PHP returns the time in UTC (GMT). We use it to feed the date
			// object and later output it in the user's timezone. JavaScript
			// internally converts it for us.

			d.setUTCHours( params.time.hours, params.time.minutes );
		}

		params.time = ( d.getHours( ) < 10 ? '0' : '' ) + d.getHours( ) + ':' + ( d.getMinutes( ) < 10 ? '0' : '' ) + d.getMinutes( );

		var markup = chat.render( 'chatLine', params ), exists = $( '#chatLineHolder .chat-' + params.id );

		if( exists.length ) {
			exists.remove( );
		}

		if( !chat.data.lastID ) {
			// If this is the first chat, remove the
			// paragraph saying there aren't any:

			$( '#chatLineHolder p' ).remove( );
		}

		// If this isn't a temporary chat:
		if( params.id.toString( ).charAt( 0 ) != 't' ) {
			var previous = $( '#chatLineHolder .chat-' + ( +params.id - 1 ) );
			if( previous.length ) {
				previous.after( markup );
			} else
				chat.data.jspAPI.getContentPane( ).append( markup );
		} else
			chat.data.jspAPI.getContentPane( ).append( markup );

		// As we added new content, we need to
		// reinitialise the jScrollPane plugin:

		chat.data.jspAPI.reinitialise( );
		chat.data.jspAPI.scrollToBottom( true );

	},

	// This method requests the latest chats
	// (since lastID), and adds them to the page.

	getChats : function( callback ) {

		$.tzGET( 'getChats', {
			lastID : chat.data.lastID
		}, function( r ) {

			for( var i = 0; i < r.chats.length; i++ ) {
				chat.addChatLine( r.chats[i] );
			}

			if( r.chats.length ) {
				if( $('#chatContainer').css('display') != 'none' ) soundNewLine( );
				chat.data.noActivity = 0;
				chat.data.lastID = r.chats[i - 1].id;
			} else {
				// If no chats were received, increment
				// the noActivity counter.

				chat.data.noActivity++;
			}

			if( !chat.data.lastID ) {
				chat.data.jspAPI.getContentPane( ).html( '
Keine Nachrichten vorhanden
' );
			}

			// Setting a timeout for the next request,
			// depending on the chat activity:

			var nextRequest = 1000;

			// 2 seconds
			if( chat.data.noActivity > 3 ) {
				nextRequest = 2000;
			}

			if( chat.data.noActivity > 10 ) {
				nextRequest = 5000;
			}

			// 15 seconds
			if( chat.data.noActivity > 20 ) {
				nextRequest = 15000;
			}

			setTimeout( callback, nextRequest );

		} );
	},

	// Requesting a list with all the users.

	getUsers : function( callback ) {
		$.tzGET( 'getUsers', function( r ) {

			var users = [];

			for( var i = 0; i < r.users.length; i++ ) {
				if( r.users[i] ) {
					users.push( chat.render( 'user', r.users[i] ) );
				}
			}

			var message = '';

			if( r.total < 1 ) {
				message = 'Niemand ist online';
			} else {
				message = r.total + ' ' + ( r.total == 1 ? 'Person' : 'Personen' ) + ' online';
			}

			users.push( '
' + message + '
' );

			$( '#chatUsers' ).html( users.join( '' ) );

			setTimeout( callback, 15000 );
		} );
	},

	// This method displays an error message on the top of the page:

	displayError : function( msg ) {
		var elem = $( '
', {
			id : 'chatErrorMessage',
			html : msg
		} );

		elem.click( function( ) {
			$( this ).fadeOut( function( ) {
				$( this ).remove( );
			} );
		} );

		setTimeout( function( ) {
			elem.click( );
		}, 5000 );

		elem.hide( ).appendTo( 'body' ).slideDown( );
	}
};

// Custom GET & POST wrappers:

$.tzPOST = function( action, data, callback ) {
	$.post( '/public/chat/ajax.php?action=' + action, data, callback, 'json' );
}

$.tzGET = function( action, data, callback ) {
	$.get( '/public/chat/ajax.php?action=' + action, data, callback, 'json' );
}
// A custom jQuery method for placeholder text:

$.fn.defaultText = function( value ) {

	var element = this.eq( 0 );
	element.data( 'defaultText', value );

	element.focus( function( ) {
		if( element.val( ) == value ) {
			element.val( '' ).removeClass( 'defaultText' );
		}
	} ).blur( function( ) {
		if( element.val( ) == '' || element.val( ) == value ) {
			element.addClass( 'defaultText' ).val( value );
		}
	} );

	return element.blur( );
}

languages: CSS JavaScript Blade PHP

repo_language: CSS

repo_name: Loopshape/WebCommunity