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);
37 else if ($_GET['scan']) {
38 $ffname = $GLOBALS['scanner_output_directory'] . '/' . $_GET['scan'];
41 $ffname = $GLOBALS['hylafax_basedir'] . '/recvq/' . $_GET['file'];
44 if (!file_exists($ffname)) {
45 die(xl("Cannot find ") . $ffname);
48 if (!is_readable($ffname)) {
49 die(xl("I do not have permission to read ") . $ffname);
54 $ext = substr($ffname, strrpos($ffname, '.'));
56 passthru("TMPDIR=/tmp ps2pdf '$ffname' -");
57 else if ($ext == '.pdf' ||
$ext == '.PDF')
60 passthru("tiff2pdf '$ffname'");
62 header("Pragma: public");
64 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
65 header("Content-Type: application/pdf");
66 header("Content-Length: " . ob_get_length());
67 header("Content-Disposition: inline; filename=" . basename($ffname, $ext) . '.pdf');