From 378a5043f9f5d20d4c79727d3ea9306c57817dd4 Mon Sep 17 00:00:00 2001 From: MCohenAuravox <92817493+MCohenAuravox@users.noreply.github.com> Date: Mon, 6 Dec 2021 11:25:57 -0600 Subject: [PATCH] Create fax_outbox.php (#6068) New Outbox feature page --- app/fax/fax_outbox.php | 203 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 app/fax/fax_outbox.php diff --git a/app/fax/fax_outbox.php b/app/fax/fax_outbox.php new file mode 100644 index 0000000000..ef82c092f0 --- /dev/null +++ b/app/fax/fax_outbox.php @@ -0,0 +1,203 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2021 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + include "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + require_once "resources/paging.php"; + +//check permissions + if (permission_exists('fax_extension_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); + +//additional includes + $document['title'] = 'Fax Outbox'; + require_once "resources/header.php"; + +//show the content + echo "
\n"; + echo "
Fax Outbox
\n"; + echo "
\n"; + echo "
\n"; + + echo "This is the Fax Outbox\n"; + echo "

\n"; + + //echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo ""; + + echo "\n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo "\n"; + + + //get fax extension + if (is_uuid($_REQUEST["id"])) { + $fax_uuid = $_REQUEST["id"]; + if (permission_exists('fax_extension_view_domain')) { + //show all fax extensions + $sql = "select fax_name, fax_extension from v_fax "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and fax_uuid = :fax_uuid "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['fax_uuid'] = $fax_uuid; + } + else { + //show only assigned fax extensions + $sql = "select fax_name, fax_extension from v_fax as f, v_fax_users as u "; + $sql .= "where f.fax_uuid = u.fax_uuid "; + $sql .= "and f.domain_uuid = :domain_uuid "; + $sql .= "and f.fax_uuid = :fax_uuid "; + $sql .= "and u.user_uuid = :user_uuid "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['fax_uuid'] = $fax_uuid; + $parameters['user_uuid'] = $_SESSION['user_uuid']; + } + $database = new database; + $row = $database->select($sql, $parameters, 'row'); + if (is_array($row) && @sizeof($row) != 0) { + //set database fields as variables + $fax_name = $row["fax_name"]; + $faxext = $row["fax_extension"]; + } + else { + if (!permission_exists('fax_extension_view_domain')) { + echo "access denied"; + exit; + } + } + unset($sql, $parameters, $row); + } + + + + $myId = $_SESSION['/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$faxext.'/temp']; + + $sql = "select * from v_fax_files "; + $sql .= "where fax_uuid = :fax_uuid "; + $sql .= "and domain_uuid = :domain_uuid "; + $sql .= "and fax_mode = 'tx' "; + $parameters['fax_uuid'] = $_REQUEST["id"]; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $database = new database; + $fax_files = $database->select($sql, $parameters, 'all'); + unset($sql, $parameters); + + +//Test if currently sending: +//set the command + $switch_cmd = 'show channels as json'; + +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +//send the event socket command and get the array + if ($fp) { + $json = trim(event_socket_request($fp, 'api '.$switch_cmd)); + + $results = json_decode($json, "true"); + } + +if (isset($results["rows"])) { + + if (is_array($results["rows"]) && @sizeof($results["rows"]) != 0) { + $x = 0; + foreach ($results["rows"] as $row) { + + $file = basename($row['application_data']); + if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") { + $file_name = substr($file, 0, (strlen($file) -4)); + } + + + if (strlen($row['fax_base64']) <= 0) { + echo "\n"; + + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + } + $x++; + } + } +} + + echo "
DestinationStatusPreviewPath
".$row['dest']."Sending...Fax PDF - ".$file_name."".$row['application_data']."
\n"; + echo "
\n"; + + echo "\n"; + + echo "
\n"; + + + echo "\n"; + echo "\n"; + + + if (file_exists('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$faxext.'/temp/'.$myId.'.tif')) { + rename('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$faxext.'/temp/'.$myId.'.tif', '/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$faxext.'/sent/'.$myId.'.tif'); + } + + if (file_exists('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$faxext.'/temp/'.$myId.'.pdf')) { + rename('/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$faxext.'/temp/'.$myId.'.pdf', '/var/lib/freeswitch/storage/fax/'.$_SESSION['domain_name'].'/'.$faxext.'/sent/'.$myId.'.pdf'); + } + + + +//include the footer + require_once "resources/footer.php"; + +?>