<?php
header("Content-Type: text/html; charset=utf-8");
include("includes/function.php");
if($allw_savealltafseer==1){
include("includes/ayat.php");

$sorax = intval($_GET['sora']);
$typex = intval($_GET['type']);

function select($sora,$type){
global $q,$quran_type_view,$htmlorphp,$QURAN,$Q_W,$siteurl;

$ayatnumbers = count($QURAN[$sora]);

if(!isset($type) OR $type == 0){
$type = 1;
}

if($type==3 OR $type == 4){
if($sora == 1 OR $sora == 2){
include(include_tafseerfilse($sora,1,$type));
include(include_tafseerfilse($sora,160,$type));
}else{
if(file_exists(include_tafseerfilse($sora,$aya,$type))){
include(include_tafseerfilse($sora,1,$type));
}else{
$err = $Q_W[34];
}
}
}else{
if(file_exists(include_tafseerfilse($sora,$aya,$type))){
include(include_tafseerfilse($sora,1,$type));
}else{
$err = $Q_W[34];
}
}

$s = '<br />';
for($i=1; $i<$ayatnumbers+1; ++$i){
$text_tafseer = $TAFSEER[$type][$sora][$i];
if($text_tafseer == ""){
$text = $Q_W[27];
}else{
$text = nl2br($text_tafseer);
}

$s .= '<div style="color:#CC0000;">'.$QURAN[$sora][$i].' ( '.$i.' )</div>';
$s .= '<div>'.$err.''.$text.'</div>';
$s .= '<div style="padding:30px 0 30px 0; text-align:center;"><br />- - - - - - - - - - - - - - - - - - - - - - - - - -<br /><br /></div>';
}

return $s;
}


if(isset($sorax) AND $sorax != 0){
if($sorax > 114){
$sora = 1;
}else{
$sora = $sorax;
}
$soratitle = '&raquo; '.$q[$sora].'';
}else{
$sora = 1;
$soratitle = '';
}


if(isset($typex) AND $typex != 0){
$type = $typex;
if($typex > count($tafseers)-1){
$type = 1;
}
$txt = select($sora,$type);
$soratitle = '&raquo; '.$tafseers[$type].'';
}else{
$type = 1;
$txt = select($sora,$type);
$soratitle = '&raquo; '.$tafseers[$type].'';
}

function save4doc_m($name,$content){
global $siteurl;

$dates = date("j/n/Y g:i:s",time());

$doc = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>'.$name.'</title>
</head>
<body>
<div style="width:800px; margin:0 auto; padding:20px; font:normal 12px tahoma; line-height:22px; direction: rtl;">

<h1 style="font:bold 30px arial; text-align:center; padding:20px 0 50px 0;">'.$name.'</h1>
<div style="font:bold 15px arial; padding:20px 0 20px 0; line-height:30px; text-align:right;">'.$content.'</div>
<div style="text-align:center; padding:50px 0 20px 0;">'.$dates.'</div>
<div style="text-align:center; padding:0 0 20px 0;"><a href="'.$siteurl.'">'.$siteurl.'</a></div>

</div>
</body>
</html>';
return $doc;
}

$titlepage = "".$tafseers[$type]." ".$Q_W[26]." ".$q[$sora]."";
$titlepage_en = "".$tafseers_en[$type]." Surat ".$q_english[$sora]."";
header('(anti-spam-(anti-spam-content-type:)) application/msword');
header('Content-Disposition: attachment; filename="'.$titlepage_en.'.doc"');
echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">';
echo save4doc_m($titlepage,$txt);
}else{
echo '<p align="center">not allow</p>';
}
?>