fetchByAssoc($GLOBALS[db]->query("select type,document_no from ecmreceipts where id='".$_GET['record']."'")); if($r['type']=="correct")$xml=createCorrectInvoiceXml($_GET['record']); else $xml=createInvoiceXml($_GET['record']); file_put_contents($file,$xml); chmod($file,0777); //header("Location: ".$file); if($_REQUEST['duplicate']){ $r['document_no']=str_replace("FV","FVDUP",$r['document_no']); } header("Pragma: public"); header("Cache-Control: maxage=1, post-check=0, pre-check=0"); header("Content-type: application/force-download"); header("Content-Length: " . filesize($file)); header("Content-disposition: attachment; filename=\"".str_replace(" ","",str_replace("/","",$r['document_no'])).".xml\";"); header("Expires: 0"); set_time_limit(0); @ob_end_clean(); ob_start(); echo file_get_contents($file); @ob_flush(); ?>