From 60249457c632326d780ebba353e49faf4f6aef35 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Fri, 6 Oct 2006 23:37:11 +0000 Subject: [PATCH] some bug fixes and initial support for listing and viewing outgoing faxes --- interface/fax/fax_dispatch.php | 2 +- interface/fax/fax_view.php | 44 +++++++++- interface/fax/faxq.php | 179 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 198 insertions(+), 27 deletions(-) diff --git a/interface/fax/fax_dispatch.php b/interface/fax/fax_dispatch.php index afbdad716..a33052782 100644 --- a/interface/fax/fax_dispatch.php +++ b/interface/fax/fax_dispatch.php @@ -213,7 +213,7 @@ if ($tmp2) die("mkdir returned $tmp2: $tmp0"); $tmp0 = exec("cd '$faxcache'; tiffsplit '$filepath'", $tmp1, $tmp2); if ($tmp2) die("tiffsplit returned $tmp2: $tmp0"); - $tmp0 = exec("cd '$faxcache'; mogrify -resize 600x776 -format jpg *.tif", $tmp1, $tmp2); + $tmp0 = exec("cd '$faxcache'; mogrify -resize 750x970 -format jpg *.tif", $tmp1, $tmp2); if ($tmp2) die("mogrify returned $tmp2: $tmp0"); } diff --git a/interface/fax/fax_view.php b/interface/fax/fax_view.php index fcb0b19bd..fe893b76f 100644 --- a/interface/fax/fax_view.php +++ b/interface/fax/fax_view.php @@ -8,22 +8,58 @@ require_once("../globals.php"); - $ffname = $GLOBALS['hylafax_basedir'] . '/recvq/' . $_GET['file']; + $ffname = ''; + $jobid = $_GET['jid']; + if ($jobid) { + $jfname = $GLOBALS['hylafax_basedir'] . "/sendq/q$jobid"; + if (!file_exists($jfname)) + $jfname = $GLOBALS['hylafax_basedir'] . "/doneq/q$jobid"; + $jfhandle = fopen($jfname, 'r'); + if (!$jfhandle) { + echo "I am in these groups: "; + passthru("groups"); + echo "
"; + die(xl("Cannot open ") . $jfname); + } + while (!feof($jfhandle)) { + $line = trim(fgets($jfhandle)); + if (substr($line, 0, 12) == '!postscript:') { + $ffname = $GLOBALS['hylafax_basedir'] . '/' . + substr($line, strrpos($line, ':') + 1); + break; + } + } + fclose($jfhandle); + if (!$ffname) { + die(xl("Cannot find postscript document reference in ") . $jfname); + } + } + else { + $ffname = $GLOBALS['hylafax_basedir'] . '/recvq/' . $_GET['file']; + } if (!file_exists($ffname)) { - die(xl("Cannot access ") . $ffname); + die(xl("Cannot find ") . $ffname); + } + + if (!is_readable($ffname)) { + die(xl("I do not have permission to read ") . $ffname); } ob_start(); - passthru("tiff2pdf $ffname"); + $ext = substr($ffname, strrpos($ffname, '.')); + if ($ext == '.ps') + passthru("TMPDIR=/tmp ps2pdf $ffname -"); + else + passthru("tiff2pdf $ffname"); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/pdf"); header("Content-Length: " . ob_get_length()); - header("Content-Disposition: inline; filename=" . basename($ffname, '.tif') . '.pdf'); + header("Content-Disposition: inline; filename=" . basename($ffname, $ext) . '.pdf'); ob_end_flush(); diff --git a/interface/fax/faxq.php b/interface/fax/faxq.php index a3b2e8d83..6226f9d07 100644 --- a/interface/fax/faxq.php +++ b/interface/fax/faxq.php @@ -24,6 +24,25 @@ } ksort($mlines); + // Get the doneq entries, parse and sort by job ID + // + /* for example: + JID Pri S Owner Number Pages Dials TTS Status + 155 123 D nobody 6158898622 1:1 5:12 + 153 124 D nobody 6158896439 1:1 4:12 + 154 124 F nobody 6153551807 0:1 4:12 No carrier detected + */ + $donelines = array(); + exec("faxstat -s -d -l -h " . $GLOBALS['hylafax_server'], $donelines); + $dlines = array(); + foreach ($donelines as $line) { + // This gets jobid, priority, statchar, owner, phone, pages, dials and tts/status. + if (preg_match('/^(\d+)\s+(\d+)\s+(\S)\s+(\S+)\s+(\S+)\s+(\d+:\d+)\s+(\d+:\d+)(.*)$/', $line, $matches)) { + $dlines[$matches[1]] = $matches; + } + } + ksort($dlines); + // echo "\n"; // debugging ?> @@ -35,16 +54,54 @@ <? xl('Received Faxes','e'); ?> @@ -67,15 +131,31 @@ function domclick(ffname) { > -
- - - - - - - +
+ + + + + +
Faxes InFaxes OutScanner In
+ + + + + + + + + + \n"; - echo " \n"; + echo " \n"; // echo "$ffname\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; } ?> -
"; + echo "
"; echo "$ffbase"; + echo " "; echo "Dispatch" . htmlentities($matches[3]) . "" . htmlentities($matches[2]) . "" . htmlentities($matches[1]) . "
" . htmlentities($matches[3]) . "" . htmlentities($matches[2]) . "" . htmlentities($matches[1]) . "
+
+ + + + + + + + + + +\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } +?> + + + + + + + -
+ + + + + -- 2.11.4.GIT