<?php
function bar($home,$cat,$text,$others)
{
global $folder;

$home = stripslashes($home);
$cat = stripslashes($cat);
$text = stripslashes($text);
$others = stripslashes($others);
$bar = "<p class='navigation'>$home $cat $text $others</p><br />";
echo $bar;
}


//template header
function tpl_header($title)
{
global $folder,$textheader,$m1,$m2,$t_lan,$name_site,$js;
$title = stripslashes($title);

if(!file_exists($folder)){echo "FOLDER TEMPLATES <b>$folder</b> NOT FOUND"; exit;}
$openfile = "".$folder."/header.htm";
if (!file_exists($openfile))
{
echo "<p align='center'>FILE TEMPLATE header.htm NOT FOUND INSIDE FOLDER ".$folder."</p>";
exit;
}else{
if($m1 == ""){
$f1 = $title;
}else{
$f1 = $m1;
}

if($m2 == ""){
$f2 = str_replace(" ",",",$title);
}else{
$f2 = $m2;
}

if($js==""){
$jsx="";
}else{
$jsx=$js;
}

$writefile = fopen($openfile,"r");
$read = fread($writefile,filesize($openfile));
$read = str_replace("{title}",$title,$read);
$read = str_replace("{titlesite}",$name_site,$read);
$read = str_replace("{description}",$f1,$read);
$read = str_replace("{keywords}",$f2,$read);
$read = str_replace("{style}",$folder,$read);
$read = str_replace("{date}",datex($t_lan),$read);
$read = str_replace("{navbar}",navbar(),$read);
$read = str_replace("{js}",$jsx,$read);

echo $read;
echo $textheader;
echo ads(2);
fclose ($writefile);
}
}


//template footer
function tpl_footer()
{
global $copyrights,$folder,$menustyle,$textfooter;

if($menustyle==1){
//changestyle();
}

if(empty($copyrights)){
$cc = "";
}else{
$cc = "<div>$copyrights</div>";
}

$openfile = "".$folder."/footer.htm";
if (!file_exists($openfile))
{
echo "<p align='center'>FILE TEMPLATE footer.htm NOT FOUND INSIDE FOLDER ".$folder."</p>";
}else{
$copyrighttext = "<div class='copyrightfppter'>".$cc."Powered by: Islamec magazine V6 <a target='_blank' href='http://www.bwady.com'>bwady.com</a> - <a target='_blank' href='http://www.nwahy.com'>nwahy.com</a></div>";

$writefile=@fopen($openfile,"r");
$read = "<div style='clear:both;'></div>";
$read .= @fread($writefile,filesize($openfile));
$read = str_replace("{style}",$folder,$read);
$read = str_replace("{copyright}",$copyrighttext,$read);
echo ads(3);

echo $textfooter;
echo $read;
@fclose ($writefile);
}
}



//template frame
function tpl_table($frame_title,$frame_rows)
{
global $folder;

$frame_title = stripslashes($frame_title);

$openfile = "".$folder."/table.htm";
if (!file_exists($openfile))
{
echo "<p align='center'>FILE TEMPLATE table.htm NOT FOUND INSIDE FOLDER ".$folder."</p>";
}else{
$writefile=@fopen($openfile,"r");
$read = @fread($writefile,filesize($openfile));
$read = str_replace("{title}","$frame_title",$read);
$read = str_replace("{text}","$frame_rows",$read);
echo $read;
@fclose ($writefile);
}
}


//template menu
function tpl_menu($menu_title,$menu_rows)
{
global $folder;
$menu_title = stripslashes($menu_title);

$openfile = "".$folder."/menu.htm";
if (!file_exists($openfile))
{
echo "<p align='center'>FILE TEMPLATE menu.htm NOT FOUND INSIDE FOLDER ".$folder."</p>";
}else{
$writefile=@fopen($openfile,"r");
$read = @fread($writefile,filesize($openfile));
$read = str_replace("{title}","$menu_title",$read);
$read = str_replace("{text}","$menu_rows",$read);
echo $read;
@fclose ($writefile);
}
}
?>