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

$id_subblok=$_REQUEST['id_subblok'];
$id_catalog=$_REQUEST['id_catalog'];

if(isset($_POST['MM_insert_rss'])) 
{
$rss = trim($_POST['rss']);
$kol_rss = $_POST['kol_rss'];
if(!$kol_rss) $kol_rss=10;
if(!$rss) $err="Укажите RSS-канал";

$r = mysql_query ("SELECT * FROM subblok WHERE id_subblok = '".$id_subblok."'") or die(mysql_error());
$rr = mysql_fetch_assoc($r);

if(!$err)
	{
	mysql_query("UPDATE subblok SET rss='".$rss."', kol_rss='".$kol_rss."' WHERE id_subblok = '".$id_subblok."'");  
				echo "<HTML><HEAD><meta http-equiv='Refresh' charset='utf-8' content='0; URL=catalog.php?id_catalog=".$id_catalog."'></HEAD></HTML>";
				exit();
	}

}


if($_GET['id_subblok']) $id_subblok=anti($_GET['id_subblok']);

$r = mysql_query ("SELECT * FROM subblok WHERE id_subblok = '".$id_subblok."'") or die(mysql_error());
$rr = mysql_fetch_assoc($r);

$titl="Редактирование RSS-канала";
require ('top.php'); 
if($err) echo '<p><font color=red>'.$err.'</font></p>';
?>

	<form enctype="multipart/form-data" name="form1" method="POST" action="">
      <table width="738" border="0" cellspacing="0" cellpadding="0" >
        <tr>
    		<td width="188">
		Адрес RSS-канала
		<td width="550">
		<input name="rss" type="text" size="50" value="<?  echo $rr['rss']; ?>">
	<tr>
		<td>
		Количество выводимых новостей
		<td>
		<input type="text" name="kol_rss" size="3" value="<?  echo $rr['kol_rss']; ?>">
      </table>
	  <input name="id_subblok" type="hidden" value="<? echo $id_subblok; ?>">
      <input type="hidden" name="id_catalog" value="<? echo $id_catalog; ?>">
      <input type="hidden" name="MM_insert_rss" value="form1">
	  <input class="submit" type="submit" name="submit" value="Изменить">
    </form>

	<? 
require ('bottom.php'); 
	?>