<?php
	
	require_once("mysqlconnect.php");
	require_once("global/functions.php");
	require_once("global/constants.php");
	session_start();
	
	$u=$_GET['u'];

	$block_file = '../conf/bfile.dat';
	
	if($u<>$uhash || $_SESSION['mobile_admin_logged_in']==false)
	{
		header("location: index.php");
	}
	
	$action=$_GET['action'];
	
	if(!$action) 
	{
		header('location: '.$HTTP_REFERER);
		die();
	}
	
	if($action=='submit')
	{
		$buffer = implode('#', $_POST['data']);
		$fp = fopen($block_file, 'w');
		fputs($fp, $buffer);
		fclose($fp);
		$action = 'form';
	}
	
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>4mobile - backoffice</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link rel="stylesheet" href="style.css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<script language="JavaScript" src="script.js"></script>
</head>
<body bgcolor="#000000" align=center>
	
<?php
	
	include('menu.php');
	
	if($action=='form')
	{		
		$bl = array
		(
			0 => 'povolené',
			1 => 'blokované',
		);
		
		$bl_title = array
		(
			0 => 'Pozadia',
			1 => 'Melódie',
			2 => 'Hry',
			3 => 'Videá'
		);
			
		if(file_exists($block_file))
		{
			$fp = fopen($block_file, 'r');
			$data = fread($fp, filesize($block_file));
			$tmp = explode('#' ,$data);
			foreach($tmp as $k => $v)
			{
				$blocked_dloads[$k] = $v;
			}
		}
		else 
		{
			$fp = fopen($block_file, 'w');
			fputs($fp, '1#1#1#1');
			fclose($fp);
			
			$blocked_dloads = array
			(
				0 => 1,
				1 => 1,
				2 => 1,
				3 => 1,
			);
		}
		
		echo "<div align=center><br /><br />\n";
		echo "<form name=edit action=block.php?u=$u&action=submit method=POST>\n";
		echo "<table width=400 cellspacing=1 cellpadding=1 border=0>\n";
		
		foreach($blocked_dloads as $k => $v)
		{
				echo "<tr>\n";
				echo "<td align=right class=field_identifier>".$bl_title[$k].": </td>\n";
				echo "<td align=left><select name='data[$k]' class=field>";
				foreach($bl as $k2 => $v2)
				{
					echo "<option value='$k2'";
					if($k2 == $v)
					{
						echo " selected";
					}
					echo ">$v2</option>";
				}
				echo "</select></td></tr>\n";
		}
		echo "<tr>";
		echo "<td class=field_identifier align=right>&nbsp;</td>";
		echo "<td align=left><input type=submit class=button name=Submit value='Uloľ'></td>
			  </tr>\n";
		
		echo "</table></form></div>";
	}

?>

</body>
</html>
<?php
	mysql_close($link);
?>