2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
12 $jobid = $_GET['jid'];
14 $jfname = $GLOBALS['hylafax_basedir'] . "/sendq/q$jobid";
15 if (!file_exists($jfname))
16 $jfname = $GLOBALS['hylafax_basedir'] . "/doneq/q$jobid";
17 $jfhandle = fopen($jfname, 'r');
19 echo "I am in these groups: ";
22 die(xl("Cannot open ") . $jfname);
24 while (!feof($jfhandle)) {
25 $line = trim(fgets($jfhandle));
26 if (substr($line, 0, 12) == '!postscript:') {
27 $ffname = $GLOBALS['hylafax_basedir'] . '/' .
28 substr($line, strrpos($line, ':') +
1);
34 die(xl("Cannot find postscript document reference in ") . $jfname);
38 $ffname = $GLOBALS['hylafax_basedir'] . '/recvq/' . $_GET['file'];
41 if (!file_exists($ffname)) {
42 die(xl("Cannot find ") . $ffname);
45 if (!is_readable($ffname)) {
46 die(xl("I do not have permission to read ") . $ffname);
51 $ext = substr($ffname, strrpos($ffname, '.'));
53 passthru("TMPDIR=/tmp ps2pdf $ffname -");
55 passthru("tiff2pdf $ffname");
57 header("Pragma: public");
59 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
60 header("Content-Type: application/pdf");
61 header("Content-Length: " . ob_get_length());
62 header("Content-Disposition: inline; filename=" . basename($ffname, $ext) . '.pdf');