From 6551b9519c0251f9b073c03235355047f23a893d Mon Sep 17 00:00:00 2001 From: katagia Date: Sun, 28 Sep 2003 16:38:54 +0000 Subject: [PATCH] PDFs should work now with Internet Explorer and Konqueror --- lam/lib/pdf.inc | 52 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/lam/lib/pdf.inc b/lam/lib/pdf.inc index c578f5d9..d5a5e4fa 100644 --- a/lam/lib/pdf.inc +++ b/lam/lib/pdf.inc @@ -27,13 +27,16 @@ define('FPDF_FONTPATH', 'font/'); include_once("fpdf.php"); function createUserPDF($accounts) { + // Check if all submitted accounts are user accounts for($i=0;$itype <> "user") { - return 2; // 2 means non user account submitted for createUserPDF() - } +// if($account->type <> "user") { +// return 2; // 2 means non user account submitted for createUserPDF() +// } } + + // Start PDF file $pdfFile = new lamPDF(); $pdfFile->Open(); @@ -236,8 +239,49 @@ function createUserPDF($accounts) { $pdfFile->setFont("arial","B",12); } // Close document and send it to the browser +// $pdfFile->Close(); +// $pdfFile->Output(); + + + // Delete old PDF older than 3 min + $relpath = $_SESSION['lampath'].'tmp/'; + + $t=time(); + $h=opendir("$relpath"); + while ($file=readdir($h)) { + if (substr($file, -4)=='.pdf') { + $path = $relpath.$file; + if ($t-filemtime($path)>180) + @unlink($path); + } + } + closedir($h); + + // Close PDF $pdfFile->Close(); - $pdfFile->Output(); + // use timestamp as filename so it should be unique. + $time = time(); + $filename = $relpath. $time .'.pdf'; + $fileurl = $_SESSION['lamurl'].'templates/getpdf.php?&f='.$_SESSION['lampath'] .'tmp/'. $time .'.pdf'; + // Save PDF + $pdfFile->Output($filename); + + // Create redirector page + + + echo $_SESSION['header']; + echo ""; + echo _("PDF File"); + echo "\n". + "\n". + "\n". + "\n". + "\n". + "\n". + ""; + echo _('Please press here if meta-refresh didn\'t work.'); + echo ""; + return 0; // 0 means everything successful; page(s) printed }