<?php
include("connect.php");
include("includes/func_fatawa.php");
$folder=$folderfatawa;
$action = $_GET['action'];
if(!isset($action)) $action = "home";

IF ($action=="home"){
$m1=$d7;
$m2=$k7;
tpl_header($LANGAUGE[55]);
bar($namelinks1,$LANGAUGE[55],"","");

table($LANGAUGE[55],fatawa_cats(),1);

tpl_footer();

}ELSEIF ($action=="fatawa"){
$id = intval($_GET["id"]);

$sql = @mysql_query("select * from fatawa_cat where id='$id' AND active='1'");
$Row = @mysql_fetch_array($sql);
if (!$Row)
{
error();
exit;
}

$names_cats = text(3,$Row['name_cat']);

tpl_header($names_cats);
bar($namelinks1,$namelinks1a,$names_cats,"");

table($names_cats,fatawa(),1);

tpl_footer();

}ELSEIF ($action=="fatawa_show"){
$id = intval($_GET["id"]);

$sql = @mysql_query("select * from fatawa where id='$id' AND active='1'");
$Row = @mysql_fetch_array($sql);
if (!$Row)
{
error();
exit;
}
$sql3 = @mysql_query("update fatawa set vis=vis+1 where id='$id'") or die ("Query failed");

include('includes/bbcode.php');

$nameftwa   = text(3,$Row['name']);
$soundftwa  = text(3,$Row['sound']);
$mftiftwa   = text(3,$Row['name_mfti']);
$urlftwa    = text(3,$Row['url']);
$visftwa    = $Row['vis'];
$catftwa    = $Row['cat'];
$cut = substr($nameftwa,0,70);

$Row['title'] = text(3,$Row['title']);
$Row['answer'] = text(3,$Row['answer']);
$text = Replace($Row['answer']);
$text = str_replace("[LIST]","<ul>",$text);
$text = str_replace("[/LIST]","</ul>",$text);
$text = str_replace("[LIST1]","<ol>",$text);
$text = str_replace("[/LIST1]","</ol>",$text);
$text = str_replace("[*]","<li>",$text);


//$t = preg_replace("/\(( [0-9]+ )\)/","(<a href=\"link.php?id=$1\">$1</a>)",$text);


$sql2 = @mysql_query("SELECT * FROM fatawa_cat where id='$catftwa'")  or die ("Query failed");
$cats = @mysql_fetch_array($sql2);
$catnameftwa = text(3,$cats['name_cat']);

if ($htmlorphp=="1"){
$ccc = "fatawa_cat-$catftwa.html";
}else{
$ccc = "fatawa.php?action=fatawa&id=$catftwa";
}

if ($soundftwa){
$soundftwaok = " <div align='center'>".$LANGAUGE[113]."<br />".embed($soundftwa,300,60)."</div>";
$imdo = "<a href='".$soundftwa."'>".typefile($soundftwa,$LANGAUGE[89])."</a>";
}else{
$soundftwaok = "";
$imdo = "";
}

if ($urlftwa){
$urlftwaok = "<a target='_blank' href='$urlftwa'><img src='$folder/icons/web.png' alt='$urlftwa' border='0' /></a>";
}else{
$urlftwaok = "";
}

$qus = "<div class='fatwaq'>".$nameftwa."</div><br />";
$qui = "<div class='fatwai'><a href='$ccc'><img src='$folder/icons/books.gif' alt='$catnameftwa' border='0' /></a> ".$urlftwaok." ".$imdo."</div>";

$S = "<br />".$soundftwaok."<br /><div class='fatwaf'>".$LANGAUGE[116]." : ".$mftiftwa." - ".$LANGAUGE[84]." : ".$visftwa."</div>";

tpl_header($Row['title']);
bar($namelinks1,$namelinks1a,"<a href='$ccc'>$catnameftwa</a>",$cut);
table($Row['title'],$qus.$qui.$text.$S,1);
tpl_footer();
}
?>