<?php
//<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
//sigurnost:
if (!defined('SIGURICA')) die('Nedozvoljen pristup!');
if ($prava_pristup_sadrzaj!=1) die('Nedozvoljen pristup!');

$id_rubrika = $_GET[id_rubrika];

//ucitaj slike za obrisati
$sql = "select ikona,thumb_ime,big_ime from b7_paragraf_slike where id_rubrika='$id_rubrika'";
$rez = mysql_query($sql, $conn);
if ($rez) $num99=mysql_num_rows($rez);
if ($num99>0) {
	$cur99=1;
	while ($num99>=$cur99) {
		$row99=mysql_fetch_array($rez);
		$ikona=	$row99['ikona'];
		$thumb_ime=	$row99['thumb_ime'];
		$big_ime=	$row99['big_ime'];
		//obriši ih
		@unlink($parametar_slike_direktorij . $ikona);
		@unlink($parametar_slike_direktorij . $thumb_ime);
		@unlink($parametar_slike_direktorij . $big_ime);
		$cur99++;
	}
}
//ucitaj fajlove za obrisati
$sql = "select naslov from b7_paragraf_upload where id_rubrika='$id_rubrika'";
$rez = mysql_query($sql, $conn);
if ($rez) $num99=mysql_num_rows($rez);
if ($num99>0) {
	$cur99=1;
	while ($num99>=$cur99) {
		$row99=mysql_fetch_array($rez);
		$naslov = $row99['naslov'];
		//obriši ih
		@unlink($parametar_upload_direktorij . $naslov);
		$cur99++;
	}
}
//ucitaj tekst za obrisati
$sql = "select fajl from b7_paragraf where id_rubrika='$id_rubrika'";
$rez = mysql_query($sql, $conn);
if ($rez) $num99=mysql_num_rows($rez);
if ($num99>0) {
	$cur99=1;
	while ($num99>=$cur99) {
		$row99=mysql_fetch_array($rez);
		$fajl = $row99['fajl'];
		//obriši ih
		@unlink($parametar_tekst_direktorij . $fajl);
		$cur99++;
	}
}

//brisanje iz baze	
$sql="delete from b7_paragraf where id_rubrika='$id_rubrika'";
$result=mysql_query($sql,$conn);		
$sql="delete from b7_paragraf_slike where id_rubrika='$id_rubrika'";
$result=mysql_query($sql,$conn);
$sql="delete from b7_paragraf_tekst where id_rubrika='$id_rubrika'";
$result=mysql_query($sql,$conn);
$sql="delete from b7_paragraf_upload where id_rubrika='$id_rubrika'";
$result=mysql_query($sql,$conn);
$sql="delete from b7_sadrzaj where id_rubrika='$id_rubrika'";
$result=mysql_query($sql,$conn);
$sql="delete from b7_kategorija where id_rubrika='$id_rubrika'";
$result=mysql_query($sql,$conn);
$sql="delete from b7_rubrika where id_rubrika='$id_rubrika'";
$result=mysql_query($sql,$conn);

//uredi nove pozicije
$sql = "select id_rubrika from b7_rubrika order by pozicija asc";
$rez = mysql_query($sql, $conn);
if ($rez) $num = mysql_num_rows($rez);
if ($num > 0) {
	$cur=1;
	while ($num>=$cur) {
		$row99=mysql_fetch_array($rez);	
		$id_rubrika=$row99[0];
		$result = mysql_query("update b7_rubrika set  
				pozicija='$cur'
				where id_rubrika='$id_rubrika'");
		$cur++;
	}
}
						

?>