<?php

	error_reporting(E_ALL);
	session_start();
	
	require_once('conf/definitions.php');
	require_once('conf/modules.php');
	require_once('conf/objs.php');
	require_once('conf/functions.php');
	
	$dba = new db;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta name="description" content="4mobile.sk - Pozadia, melódie, hry a videá pre Váš mobil zadarmo! Stiahnite si do svojho mobilu niektoré z tisícok pozadí, melódií, hier alebo videí!" />
<meta name="keywords" content="pozadia, obrázky, tapety, melódie, videá, hry, pozadia zdarma, obrázky zdarma, tapety zdarma, melódie zdarma, videá zdarma, hry zdarma, pozadia zdarma, obrázky zdarma, tapety zdarma, melódie zdarma, videá zdarma, hry zdarma, pozadia zadarmo, obrázky zadarmo, tapety zadarmo, melódie zadarmo, videá zadarmo, hry zadarmo, pozadia na mobil, obrázky na mobil, tapety na mobil, melódie na mobil, videá na mobil, hry na mobil, sťahovanie do mobilu, sťahovanie na mobil" />
<meta name="Robots" content="index,follow" />
<meta name="GOOGLEBOT" content="index, follow" />
<meta name="verify-v1" content="kc0uB6UN61PtI3gxs4a+K52kQwyZgb2AhHl4nBN2/rA=" />
<meta http-equiv="refresh" content="13" />
<!-- This page contains information about: pozadia, obrázky, tapety, melódie, videá, hry, zdarma -->
<link rel="icon" type="image/png" href="icon.png" />
<link rel="shortcut icon" type="image/png" href="icon.png" />
<title><?php echo $title; ?></title>
<style>
body{
	background-color: #414040;
	color: #fff;
	font-family: Verdana, Tahoma;
	font-size: 9px;
	padding: 1px;
	margin: 1px;
	width: 82px;
}
</style>
</head>
<body <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { echo "onload=\"parent.document.getElementById('chat_input').value='';\""; } ?>>
<div style='width: 97px;'>
<?php

	function formatTime($time)
	{
		list($date, $cas) = split(" ", $time);
		return $cas;
	}
	
	if(!isset($_SESSION['last_message']))
	{
		$_SESSION['last_message'] = '';
	}
	
	if(isset($_SESSION['mobile_logged_in']) && $_SESSION['mobile_logged_in'])
	{

		if($_SERVER['REQUEST_METHOD'] == 'POST' && trim($_POST['message'] != ''))
		{
			$message = addslashes(htmlspecialchars(fnCutLong(strip_tags(fnSmileys($_POST['message'])), 13)));
			if($_SESSION['last_message'] != $message)
			{
				$query = "INSERT INTO mobile_chat VALUES (null, '".$_SESSION['log']."', NOW() , '".$message."')"; 		
				$dba->ExecuteQuery($query);
				$_SESSION['last_message'] = $message;
			}
		}
	
		$query = "
			SELECT 
				* 
			FROM 
				mobile_chat
			ORDER BY 
				ID DESC
			limit 
				0, 15";
		$data = $dba->GetArray($query);
		if(is_array($data))
		{
			foreach ($data as $line)
			{
				echo "<b>".$line['nick']."</b> <span style='font-family: Tahoma; font-size: 7pt;'>".formatTime($line['datum'])."</span><br/>";
				echo fnSmile(fnCutLong($line['text'], 14))."<br/><br/>";
			}
		}
		//	dump($data, 'data');
	}

?>
</div>
</body>
</html>