<?php 
	require_once("mysqlconnect.php");
	require_once("global/functions.php");
	require_once("global/constants.php");
	require_once("../conf/definitions.php");
	session_start();
	
	$u=$_GET['u'];
	
	if(!$_SESSION["mobile_admin_logged_in"] || $u<>$uhash) header('location: index.php');
	
	$action=$_GET["action"];
	
		
	if($action=='add')
	{
		$cat = intval($_POST['cat']);
		$text = trim(addslashes($_POST['text']));
		if($cat != 0 && $text != '')
		{
			$query = "INSERT INTO mobile_sms (pridal, time, text, cat) VALUES (-1, NOW(), '$text', $cat)";
			if (mysql_query($query, $link))
			{
				$err='SMS vyhovuje kritáriám a bola pridaná';
			}
			else 
			{
				$err = 'Nieco sa posralo';
			}
			//header("location: melody_add.php?u=$u&action=form&err=$err");
		}
		else 
		{
			if(!file_exists($file_tmp) && $action=='add_file')$err='Zadaný súbor neexistuje';
		}
	}	

	?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//SK" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>4mobile - všetko pre Váš mobil</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link rel="stylesheet" href="style.css">
<style type="text/css">
<!--
.form_name {  font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #666666; text-decoration: none; text-align: left;}
.form_tlac {  font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #666666; background-color: #FFFFFF; border: 1px solid #CCCCCC}
.form_text { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; color: #666666; text-decoration: none ; text-align: justify; background-color: #FFFFFF; border: #CCCCCC; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
.form_text2 { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #666666; text-decoration: none ; text-align: justify }
.msg { font-family: Verdana; font-size: 7pt; color:#999999; }
.field1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #CC0000; background-color: #CCCCCC; border: #000000; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}

-->
</style>
</head>

<body bgcolor="black">
<? include('menu.php'); ?>
<div align='center'>
<? 
	$action=$_GET["action"];
		echo"<div width=100%>
		<form ENCTYPE=\"multipart/form-data\" name=\"q\" action=\"sms_add.php?u=$u&action=add\" method=POST>
			<table width=400 border=0 align=center cellspacing=1>
				<tr bgcolor=#222222>
					<td class=form_name>&nbsp;Text:</td>
					<td class=form_name><textarea rows=6 cols=30 name='text' style=\"scrolling:auto; scrollbar-face-color: #CCCCCC; scrollbar-shadow-color:#CCCCCC;
	  					scrollbar-highlight-color:#CCCCCC ; 
	  					scrollbar-3dlight-color: #CCCCCC;
	  					scrollbar-darkshadow-color: #CCCCCC; 
	  					scrollbar-track-color: #cccccc;
	  					scrollbar-arrow-color: #CC0000;\" class=field1></textarea></td>
				</tr>
				<tr bgcolor=#222222>
					<td class=form_name>&nbsp;Kategoria:</td>
					<td class=form_name><select name='cat' class='field1'>";
					foreach ($sms_cats as $kg => $g_name)
					{
						echo "<option value='$kg'>$g_name</option>";
					}
				echo "</select>
				</tr>	
				<tr bgcolor=#222222>
					<td colspan=2 align=center><input type=submit value=OK class=form_tlac style=\"cursor:hand\";>  
          				<input type=reset value=Vymazať class=form_tlac style=\"cursor:hand\";></td>
					
				</tr>
			</table>
		</form></div>
		";
echo"<div align=center class=msg><b>".$err."</b></div>";		
echo"<div align=center class=msg><b>".$_FILES['the_file']['type']."</b></div>";		
			
	
	
	?>

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