src/Neuron/GameServer/Windows/OldChat.php
private function postMessage ($msg)
	{		
		// Fetch the prefix
		$group = self::CHAT_GROUP_ALL;
		$mtype = self::CHAT_CLASS_REGULAR;
		
		$id = $this->channel;
		
		$msg = trim ($msg);
		
		$shortcuts = array
		(
			'#' => '/clan ',
			'@' => '/msg '
		);
		
		foreach ($shortcuts as $k => $v)
		{
			if (substr ($msg, 0, 1) == $k)
			{
				$msg = $v . substr ($msg, 1);
			}
		}

		if (substr ($msg, 0, 1) == '/')
		{
			$params = explode (' ', substr ($msg, 1));
			$length = strlen ($params[0]) + 1;
			
			switch (strtolower ($params[0]))
			{
				case 'join':
					$channel = isset ($params[1]) ? $params[1] : false;
					
					if ($channel)
					{
						$this->switchChannel ($channel);
					}
					
					return;
				break;
			
				case 'msg':
					// Fetch the user
					$username = isset ($params[1]) ? $params[1] : false;
					$objUser  = isset ($params[1]) ? Dolumar_Players_Player::getFromName ($params[1]) : false;
					
					if ($username && $objUser)
					{
						$length += strlen ($username) + 2;
						
						$group = self::CHAT_GROUP_USER;
						$id = $objUser->getId ();
					}
					
				break;
				
				case 'clan':
					$clan = $this->user->getMainClan ();
					if ($clan)
					{
						$group = self::CHAT_GROUP_CLAN;
						$id = $clan->getId ();
					} 
				break;
				
				case 'me':
					$msg = Neuron_Core_Tools::output_varchar ($this->user->getNickname ()).' '.substr ($msg, $length);
					$length = 0;
					
					$mtype = self::CHAT_CLASS_ME;
				break;
			}
			
			if ($length > 0)
			{
				$msg = substr ($msg, $length);
			}
		}
		
		if (!empty ($msg))
		{
			$mtype = intval ($mtype);
		
			$db = Neuron_DB_Database::getInstance ();
			$biggest = $db->query
			("
				INSERT INTO
					chat
				SET
					msg = '{$db->escape($msg)}',
					datum = '".time()."',
					plid = {$this->user->getId()},
					target_group = '{$db->escape ($group)}',
					target_id = '{$db->escape ($id)}',
					mtype = $mtype
			");
			
			/*
			$biggest = $db->insert
			(
				'chat',
				array
				(
					'msg' => $msg,
					'datum' => time (),
					'plid' => $this->user->getId (),
					'target_group' => $group,
					'target_id' => $id
				)
			);
			*/
			
			$this->objCache->setCache ($this->sCacheKey, $biggest);
		}
	}
private function postMessage ($msg)
	{		
		// Fetch the prefix
		$group = self::CHAT_GROUP_ALL;
		$mtype = self::CHAT_CLASS_REGULAR;
		
		$id = $this->channel;
		
		$msg = trim ($msg);
		
		$shortcuts = array
		(
			'#' => '/clan ',
			'@' => '/msg '
		);
		
		foreach ($shortcuts as $k => $v)
		{
			if (substr ($msg, 0, 1) == $k)
			{
				$msg = $v . substr ($msg, 1);
			}
		}

		if (substr ($msg, 0, 1) == '/')
		{
			$params = explode (' ', substr ($msg, 1));
			$length = strlen ($params[0]) + 1;
			
			switch (strtolower ($params[0]))
			{
				case 'join':
					$channel = isset ($params[1]) ? $params[1] : false;
					
					if ($channel)
					{
						$this->switchChannel ($channel);
					}
					
					return;
				break;
			
				case 'msg':
					// Fetch the user
					$username = isset ($params[1]) ? $params[1] : false;
					$objUser  = isset ($params[1]) ? Dolumar_Players_Player::getFromName ($params[1]) : false;
					
					if ($username && $objUser)
					{
						$length += strlen ($username) + 2;
						
						$group = self::CHAT_GROUP_USER;
						$id = $objUser->getId ();
					}
					
				break;
				
				case 'clan':
					$clan = $this->user->getMainClan ();
					if ($clan)
					{
						$group = self::CHAT_GROUP_CLAN;
						$id = $clan->getId ();
					} 
				break;
				
				case 'me':
					$msg = Neuron_Core_Tools::output_varchar ($this->user->getNickname ()).' '.substr ($msg, $length);
					$length = 0;
					
					$mtype = self::CHAT_CLASS_ME;
				break;
			}
			
			if ($length > 0)
			{
				$msg = substr ($msg, $length);
			}
		}
		
		if (!empty ($msg))
		{
			$mtype = intval ($mtype);
		
			$db = Neuron_DB_Database::getInstance ();
			$biggest = $db->query
			("
				INSERT INTO
					chat
				SET
					msg = '{$db->escape($msg)}',
					datum = '".time()."',
					plid = {$this->user->getId()},
					target_group = '{$db->escape ($group)}',
					target_id = '{$db->escape ($id)}',
					mtype = $mtype
			");
			
			/*
			$biggest = $db->insert
			(
				'chat',
				array
				(
					'msg' => $msg,
					'datum' => time (),
					'plid' => $this->user->getId (),
					'target_group' => $group,
					'target_id' => $id
				)
			);
			*/
			
			$this->objCache->setCache ($this->sCacheKey, $biggest);
		}
	}
/*
Post the message