<?
session_start();
require_once('../connect/connect.php'); 
include_once('../lib/lib.php');
require('pdk.php');

$id_rec=intval($_REQUEST['id_rec']);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) 
	{
	$err="";
	$rec_img=$_POST['rec_img'];
	$opl_data=$_POST['opl_data'];
	$prim =_pre($_POST['prim']);

	if(!$opl_data) $err .= 'Укажите, до какой даты оплачен блок<br>';
	if(!intval($_POST['banner_s'])) $err .= "Вы не указали ширину баннера<br>";
	if(!intval($_POST['banner_v'])) $err .= "Вы не указали высоту баннера<br>";
	
	$banner=intval($_POST['banner_s']).'_'.intval($_POST['banner_v']);

	if (!$err && $_FILES['fil']['tmp_name'])
		{
  		$ext = strtolower(strrchr ($_FILES['fil']['name'], "."));
  		if ($ext != ".swf") 
  		$err .= "Недопустимый формат файла. Допускаются только файлы в формате SWF<br>";
		if ($_FILES['fil']['tmp_name']) copy($_FILES['fil']['tmp_name'], $base_path.$rec_img);
			{
			$rec_img = 'banner/'.$id_rec.$ext;
			}
		} 
	
	if ($err=="")
		{
		$rec_cont=dir_top().$rec_img;
		mysql_query("UPDATE rec SET 
		rec_img='".$rec_img."',
		banner='".$banner."',
		rec_cont='".$rec_cont."',
		opl_data='".$opl_data."',
		opl='1',
		prim='".$prim."'
		WHERE id_rec='".$id_rec."'");
		
		include('_svod_rec.php');
		echo "<HTML><HEAD><meta http-equiv='Refresh' content='0; URL=refresh.php?i=all_rec_user.php'></HEAD></HTML>";
		exit();
		} 
	}

$r2 = mysql_query ("SELECT * FROM rec WHERE id_rec = '".$id_rec."'") or die(mysql_error());
$rr2 = mysql_fetch_array($r2);

if(!$banner) 
$banner=$rr2['banner'];
$arr_b=explode("_",$banner); 
  
$opl_data=$rr2['opl_data'];
$prim=$rr2['prim'];

$titl="Флеш баннер SWF";
require ('top.php'); 
if($err) echo "<p><font color=red>".$err."</font></p>";

?>
<form enctype="multipart/form-data" name="form" method="post" action="">
<table width="598">
<tr>
  <td>FILE</td>
  <td><input  type="file" name="fil" size="50"></td>
</tr>

<tr>
  <td>Ширина</td>
  <td><input name="banner_s" size="5" value="<?=$arr_b[0]?>"></td>
</tr>

<tr>
  <td>Высота</td>
  <td><input name="banner_v" size="5" value="<?=$arr_b[1]?>"></td>
</tr>

<tr>
	<td>Разместить до</td>
	<td><input readonly="readonly" value="<?=$opl_data?>" name="opl_data" class="date-pick dp-applied"></td>
</tr>

<tr>
	<td>Пометки администратора</td>
	<td><textarea name="prim" rows="5" cols="60"><?=stripslashes(htmlspecialchars_decode($prim))?></textarea></td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>

<tr>
<td>  <input type="submit"  class="submit" name="Submit" value="Изменить"></td>
<td>
<input type="hidden" name="MM_insert" value="form">
<input type="hidden" name="id_rec" value="<?=$_REQUEST['id_rec']?>">
<input type="hidden" name="rec_img" value="<?=$rr2['rec_img']?>">

</td>
</tr>
</table>
</form>
<?
require('bottom.php');
?>