Update fax_send.php

This commit is contained in:
FusionPBX 2018-09-19 23:34:20 -04:00 committed by GitHub
parent a278c1c64e
commit 7169201a95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 32 deletions

View File

@ -33,16 +33,19 @@ if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false;
if (!$included) { if (!$included) {
include "root.php"; //includes
require_once "resources/require.php"; include "root.php";
require_once "resources/check_auth.php"; require_once "resources/require.php";
if (permission_exists('fax_send')) { require_once "resources/check_auth.php";
//access granted
} //check permissions
else { if (permission_exists('fax_send')) {
echo "access denied"; //access granted
exit; }
} else {
echo "access denied";
exit;
}
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
@ -110,11 +113,11 @@ if (!$included) {
// set fax cover font to generate pdf // set fax cover font to generate pdf
$fax_cover_font = $_SESSION['fax']['cover_font']['text']; $fax_cover_font = $_SESSION['fax']['cover_font']['text'];
} }
else{ else {
require_once "resources/classes/event_socket.php"; require_once "resources/classes/event_socket.php";
} }
if(!function_exists('correct_path')) { if (!function_exists('correct_path')) {
function correct_path($p) { function correct_path($p) {
global $IS_WINDOWS; global $IS_WINDOWS;
if ($IS_WINDOWS) { if ($IS_WINDOWS) {
@ -124,7 +127,7 @@ if(!function_exists('correct_path')) {
} }
} }
if(!function_exists('gs_cmd')) { if (!function_exists('gs_cmd')) {
function gs_cmd($args) { function gs_cmd($args) {
global $IS_WINDOWS; global $IS_WINDOWS;
if ($IS_WINDOWS) { if ($IS_WINDOWS) {
@ -134,7 +137,7 @@ if(!function_exists('gs_cmd')) {
} }
} }
if(!function_exists('fax_enqueue')) { if (!function_exists('fax_enqueue')) {
function fax_enqueue($fax_uuid, $fax_file, $wav_file, $reply_address, $fax_uri, $fax_dtmf, $dial_string){ function fax_enqueue($fax_uuid, $fax_file, $wav_file, $reply_address, $fax_uri, $fax_dtmf, $dial_string){
global $db, $db_type; global $db, $db_type;
@ -186,16 +189,16 @@ HERE;
} }
} }
if(!function_exists('fax_split_dtmf')) { if (!function_exists('fax_split_dtmf')) {
function fax_split_dtmf(&$fax_number, &$fax_dtmf){ function fax_split_dtmf(&$fax_number, &$fax_dtmf){
$tmp = array(); $tmp = array();
$fax_dtmf = ''; $fax_dtmf = '';
if(preg_match('/^\s*(.*?)\s*\((.*)\)\s*$/', $fax_number, $tmp)){ if(preg_match('/^\s*(.*?)\s*\((.*)\)\s*$/', $fax_number, $tmp)){
$fax_number = $tmp[1]; $fax_number = $tmp[1];
$fax_dtmf = $tmp[2]; $fax_dtmf = $tmp[2];
}
} }
} }
}
//get the fax extension //get the fax extension
if (strlen($fax_extension) > 0) { if (strlen($fax_extension) > 0) {
@ -347,7 +350,6 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){
$fax_name = str_replace("+", "_", $fax_name); $fax_name = str_replace("+", "_", $fax_name);
$fax_name = str_replace("=", "_", $fax_name); $fax_name = str_replace("=", "_", $fax_name);
$attachment_file_name = $_files['name'][$index]; $attachment_file_name = $_files['name'][$index];
rename($dir_fax_temp.'/'.$attachment_file_name, $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension); rename($dir_fax_temp.'/'.$attachment_file_name, $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension);
unset($attachment_file_name); unset($attachment_file_name);
@ -960,11 +962,10 @@ if (!$included) {
$sql .= ") \n"; $sql .= ") \n";
} }
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement -> execute(); $prep_statement->execute();
$result = $prep_statement -> fetchAll(PDO::FETCH_NAMED); $contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result); if (is_array($contacts)) {
if ($result_count > 0) { foreach ($contacts as &$row) {
foreach ($result as &$row) {
if ($row['contact_organization'] != '') { if ($row['contact_organization'] != '') {
$contact_option_label = $row['contact_organization']; $contact_option_label = $row['contact_organization'];
} }
@ -976,7 +977,7 @@ if (!$included) {
} }
$contact_option_value_recipient = $contact_option_label; $contact_option_value_recipient = $contact_option_label;
$contact_option_value_faxnumber = $row['phone_number']; $contact_option_value_faxnumber = $row['phone_number'];
$contact_option_label .= ":  ".format_phone($row['phone_number']); $contact_option_label .= ":  ".escape(format_phone($row['phone_number']));
$contact_labels[] = $contact_option_label; $contact_labels[] = $contact_option_label;
$contact_values[] = $contact_option_value_faxnumber."|".$contact_option_value_recipient; $contact_values[] = $contact_option_value_faxnumber."|".$contact_option_value_recipient;
unset($contact_option_label); unset($contact_option_label);
@ -985,13 +986,13 @@ if (!$included) {
echo " <select class='formfld' style='display: none;' id='fax_recipient_select' onchange='contact_load(this);'>\n"; echo " <select class='formfld' style='display: none;' id='fax_recipient_select' onchange='contact_load(this);'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
foreach ($contact_labels as $index => $contact_label) { foreach ($contact_labels as $index => $contact_label) {
echo " <option value=\"".escape($contact_values[$index])."\">".escape($contact_label)."</option>\n"; echo " <option value=\"".escape($contact_values[$index])."\">".$contact_label."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
} }
unset ($prep_statement); unset($prep_statement);
echo " <input type='text' name='fax_recipient' id='fax_recipient' class='formfld' style='max-width: 250px;' value=''>\n"; echo " <input type='text' name='fax_recipient' id='fax_recipient' class='formfld' style='max-width: 250px;' value=''>\n";
if ($result_count > 0) { if (is_array($contacts)) {
echo " <input type='button' id='btn_toggle_recipient' class='btn' name='' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle('fax_recipient');\">\n"; echo " <input type='button' id='btn_toggle_recipient' class='btn' name='' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle('fax_recipient');\">\n";
} }
echo " <br />\n"; echo " <br />\n";