<?
ob_start("ob_gzhandler");
include("./includes/config.php");
include("./includes/function.php");
include("./includes/bbcode.php");
include("./includes/inquiry.php");
$id= trim($_GET['poemid']);
$cleanid = strip_tags($id);

$selectpoem = mysql_db_query("$dbName", "SELECT * FROM `divan`  WHERE `divan_id` = '$cleanid'") ;
while ($pinfo =  @mysql_fetch_assoc($selectpoem)){
$poemname= $pinfo[divan_title];
$poemcontaining= $pinfo[divan_containing];
}


 $xmlpoem =  $poemcontaining;
 $xmlpoem = nl2br($xmlpoem);
 $xmlpoem =  str_replace("=","       ",$xmlpoem);

$thispoem= $poemcontaining;
$thispoem = nltobr($thispoem);
$thispoem = str_replace("=","&nbsp;&nbsp;&nbsp;&nbsp;",$thispoem);
//$delbbcode = strip_tags($delbbcode);

$cCharset = "windows-1256";
$sitename = $sitename;
 $type= trim($_GET['type']);
$cleantype = strip_tags($type);
 if(($cleantype)==('word')){
ExportToWord($thispoem,$poemname,$sitename,$sitelink,$cCharset);
  }elseif(($cleantype)==('html')){

  ExportToHtml($thispoem,$poemname,$sitename,$sitelink,$cCharset);
  }elseif(($cleantype)==('rss')){
   //export to xml file

header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="windows-1256" standalone="yes"?>';
ECHO '<rss version="2.0">'."\r\n";
ECHO "<channel>\r\n";
ECHO "\t\t<title>$sitename</title>\r\n";
ECHO "\t\t<description>$sitename</description>\r\n";
ECHO "\t\t<link>$sitelink</link>\r\n";
ECHO "\t<item>\r\n";
ECHO "\t\t<title>$poemname</title>\r\n";
ECHO "\t\t<description>$xmlpoem</description>\r\n";
ECHO "\t\t<link>$sitelink</link>\r\n";
ECHO "\t</item>\r\n";

ECHO "</channel>\r\n";
ECHO "</rss>";
 //header('Content-Disposition: attachment; filename="poem.xml"');

   //export to xml file
  }elseif(($cleantype)==('print')){

 echo "<html>";
 echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$cCharset."\">";
 echo "<body onload=window.print()>";
 echo"
 <SCRIPT LANGUAGE='JavaScript'>
function closeWin(){
        window.close()
}
function timer(){
        timerID = setTimeout(\"closeWin()\", 2000)
}

</SCRIPT>
<script>
timer();
</script>

 ";
 echo"<div align='center'>";
 echo "<table border=0><tr><td>";
echo  $thispoem ;
 echo "</td></tr></table>";
 echo"</div>";
 echo"<div align='center'>";
  echo "<table border=0><tr><td>";
echo  "<b>"."جميع الحقوق محفوظة ".$sitename."<b></td></tr>" ;
echo"<tr><td><br>$sitelink";
 echo "</td></tr></table>";
 echo"</div>";
 echo "</body>";
 echo "</html>";

  }


ob_end_flush();
?>