@@ -277,6 +277,14 @@
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_send_greeting";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_send_channels";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||
$z++;
|
||||
//$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "fax_keep_local";
|
||||
//$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "fax_local";
|
||||
//$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
@@ -499,4 +507,75 @@
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||
|
||||
$y = 4; //table array index
|
||||
$z = 0; //field array index
|
||||
$apps[$x]['db'][$y]['table'] = 'v_fax_tasks';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_uuid';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_uuid';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_fax';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'fax_uuid';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'FAX server primary key';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_next_time';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'timestamp';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_lock_time';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'timestamp';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_fax_file';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_wav_file';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_uri';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_dial_string';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_dtmf';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_interrupted';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_status';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_no_answer_counter';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_no_answer_retry_counter';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_retry_counter';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_description';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
?>
|
||||
@@ -12,6 +12,13 @@ if ($domains_processed == 1) {
|
||||
$array[$x]['default_setting_description'] = 'Path to image/logo file displayed in the header of the cover sheet.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_font';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'times';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = 'Font used to generate cover page. Can be full path to .ttf file or font name alredy installed.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'cover_footer';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = "The information contained in this facsimile is intended for the sole confidential use of the recipient(s) designated above, and may contain confidential and legally privileged information. If you are not the intended recipient, you are hereby notified that the review, disclosure, dissemination, distribution, copying, duplication in any form, and taking of any action in regards to the contents of this document - except with respect to its direct delivery to the intended recipient - is strictly prohibited. Please notify the sender immediately and destroy this cover sheet and all attachments. If stored or viewed electronically, please permanently delete it from your system.";
|
||||
@@ -60,6 +67,55 @@ if ($domains_processed == 1) {
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Keep the file after sending or receiving the fax.';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_mode';
|
||||
$array[$x]['default_setting_name'] = 'text';
|
||||
$array[$x]['default_setting_value'] = 'queue';
|
||||
$array[$x]['default_setting_enabled'] = 'false';
|
||||
$array[$x]['default_setting_description'] = '';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_retry_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '5';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Number of attempts to send fax (count only calls with answer)';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_retry_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '15';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before we make next call after answered call';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_retry_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '3';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Number of unanswered attempts in sequence';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_retry_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '30';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before we make next call after no answered call';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_limit';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '3';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Giveup reach the destination after this number of sequences';
|
||||
$x++;
|
||||
$array[$x]['default_setting_category'] = 'fax';
|
||||
$array[$x]['default_setting_subcategory'] = 'send_no_answer_interval';
|
||||
$array[$x]['default_setting_name'] = 'numeric';
|
||||
$array[$x]['default_setting_value'] = '300';
|
||||
$array[$x]['default_setting_enabled'] = 'true';
|
||||
$array[$x]['default_setting_description'] = 'Delay before next call sequence';
|
||||
$x++;
|
||||
//get an array of the default settings
|
||||
$sql = "select * from v_default_settings ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
|
||||
@@ -1111,6 +1111,10 @@ $text['label-accountcode']['de-at'] = "Account Code";
|
||||
$text['label-accountcode']['ro'] = "Cod cont";
|
||||
$text['label-accountcode']['he'] = "קוד חשבון";
|
||||
|
||||
$text['label-fax_send_greeting']['en-us'] = "Greeting";
|
||||
|
||||
$text['label-fax_send_channels']['en-us'] = "Number of channels";
|
||||
|
||||
$text['header-sent']['en-us'] = "Sent Faxes";
|
||||
$text['header-sent']['es-cl'] = "Los Faxes Enviados";
|
||||
$text['header-sent']['pt-pt'] = "Faxes Enviados";
|
||||
|
||||
+42
-2
@@ -135,8 +135,10 @@ else {
|
||||
} else {
|
||||
$forward_prefix = $forward_prefix.$fax_forward_number.'#'; //found
|
||||
}
|
||||
$fax_local = check_str($_POST["fax_local"]);
|
||||
$fax_local = check_str($_POST["fax_local"]); //! @todo check in database
|
||||
$fax_description = check_str($_POST["fax_description"]);
|
||||
$fax_send_greeting = check_str($_POST["fax_send_greeting"]);
|
||||
$fax_send_channels = check_str($_POST["fax_send_channels"]);
|
||||
}
|
||||
|
||||
//delete the user from the fax users
|
||||
@@ -274,6 +276,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
if (strlen($fax_forward_number) > 0) {
|
||||
$sql .= "fax_forward_number, ";
|
||||
}
|
||||
$sql .= "fax_send_greeting,";
|
||||
$sql .= "fax_send_channels,";
|
||||
$sql .= "fax_description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
@@ -305,6 +309,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
if (strlen($fax_forward_number) > 0) {
|
||||
$sql .= "'$fax_forward_number', ";
|
||||
}
|
||||
$sql .= (strlen($fax_send_greeting)==0?'NULL':"'$fax_send_greeting'") . ",";
|
||||
$sql .= (strlen($fax_send_channels)==0?'NULL':"'$fax_send_channels'") . ",";
|
||||
|
||||
$sql .= "'$fax_description' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
@@ -345,9 +352,16 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
else {
|
||||
$sql .= "fax_forward_number = null, ";
|
||||
}
|
||||
$tmp = strlen($fax_send_greeting)==0?'NULL':"'$fax_send_greeting'";
|
||||
$sql .= "fax_send_greeting = $tmp,";
|
||||
$tmp = strlen($fax_send_channels)==0?'NULL':"'$fax_send_channels'";
|
||||
$sql .= "fax_send_channels = $tmp,";
|
||||
|
||||
$sql .= "fax_description = '$fax_description' ";
|
||||
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and fax_uuid = '$fax_uuid' ";
|
||||
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
@@ -426,9 +440,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
$fax_caller_id_number = $row["fax_caller_id_number"];
|
||||
$fax_forward_number = $row["fax_forward_number"];
|
||||
$fax_description = $row["fax_description"];
|
||||
$fax_send_greeting = $row["fax_send_greeting"];
|
||||
$fax_send_channels = $row["fax_send_channels"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
else{
|
||||
$fax_send_channels = 10;
|
||||
}
|
||||
|
||||
//replace the dash with a space
|
||||
$fax_name = str_replace("-", " ", $fax_name);
|
||||
@@ -667,6 +686,28 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
}
|
||||
}
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-fax_send_greeting']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='fax_send_greeting' maxlength='255' value=\"$fax_send_greeting\">\n";
|
||||
echo "<br />\n";
|
||||
echo " ".$text['description-fax_send_greeting']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-fax_send_channels']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='fax_send_channels' maxlength='255' value=\"$fax_send_channels\">\n";
|
||||
echo "<br />\n";
|
||||
echo " ".$text['description-fax_send_channels']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-description']."\n";
|
||||
@@ -677,7 +718,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo "".$text['description-info']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
}
|
||||
|
||||
echo " <tr>\n";
|
||||
|
||||
+24
-10
@@ -29,6 +29,7 @@ include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/functions/object_to_array.php";
|
||||
require_once "resources/functions/parse_attachments.php";
|
||||
require_once "resources/functions/parse_message.php";
|
||||
require_once "resources/classes/text.php";
|
||||
|
||||
//get accounts to monitor
|
||||
@@ -55,6 +56,12 @@ if (sizeof($result) != 0) {
|
||||
$event_socket['password'] = $record['event_socket_password'];
|
||||
unset($sql, $prep_statement, $record);
|
||||
|
||||
$fax_send_mode_default = $_SESSION['fax']['send_mode']['text'];
|
||||
if(strlen($fax_send_mode_default) == 0){
|
||||
$fax_send_mode_default = 'direct';
|
||||
}
|
||||
$fax_cover_font_default = $_SESSION['fax']['cover_font']['text'];
|
||||
|
||||
foreach ($result as $row) {
|
||||
//get fax server and account connection details
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
@@ -74,12 +81,23 @@ if (sizeof($result) != 0) {
|
||||
$fax_email_connection_mailbox = $row["fax_email_connection_mailbox"];
|
||||
$fax_email_outbound_subject_tag = $row["fax_email_outbound_subject_tag"];
|
||||
$fax_email_outbound_authorized_senders = $row["fax_email_outbound_authorized_senders"];
|
||||
$fax_send_greeting = $row["fax_send_greeting"];
|
||||
|
||||
//load default settings, then domain settings over top
|
||||
unset($_SESSION);
|
||||
$_SESSION = $default_settings;
|
||||
load_domain_settings($domain_uuid);
|
||||
|
||||
$fax_send_mode = $_SESSION['fax']['send_mode']['text'];
|
||||
if(strlen($fax_send_mode) == 0){
|
||||
$fax_send_mode = $fax_send_mode_default;
|
||||
}
|
||||
|
||||
$fax_cover_font = $_SESSION['fax']['cover_font']['text'];
|
||||
if(strlen($fax_cover_font) == 0){
|
||||
$fax_cover_font = $fax_cover_font_default;
|
||||
}
|
||||
|
||||
//load event socket connection parameters
|
||||
$_SESSION['event_socket_ip_address'] = $event_socket['ip_address'];
|
||||
$_SESSION['event_socket_port'] = $event_socket['port'];
|
||||
@@ -159,22 +177,14 @@ if (sizeof($result) != 0) {
|
||||
else {
|
||||
$fax_numbers[] = $tmp;
|
||||
}
|
||||
foreach ($fax_numbers as $index => $fax_number) {
|
||||
$fax_numbers[$index] = preg_replace("~[^0-9]~", "", $fax_number);
|
||||
if ($fax_numbers[$index] == '') { unset($fax_numbers[$index]); }
|
||||
}
|
||||
unset($fax_subject); //clear so not on cover page
|
||||
|
||||
//get email body (if any) for cover page
|
||||
$fax_message = imap_fetchbody($connection, $email_id, '1.1', FT_UID);
|
||||
$fax_message = strip_tags($fax_message);
|
||||
$fax_message = trim($fax_message);
|
||||
$fax_message = parse_message($connection, $email_id, FT_UID);
|
||||
if ($fax_message == '') {
|
||||
$fax_message = imap_fetchbody($connection, $email_id, '1', FT_UID);
|
||||
$fax_message = strip_tags($fax_message);
|
||||
$fax_message = trim($fax_message);
|
||||
$fax_message = str_replace("\r\n\r\n","\r\n", $fax_message);
|
||||
}
|
||||
$fax_message = str_replace("\r\n\r\n","\r\n", $fax_message);
|
||||
|
||||
// set fax directory (used for pdf creation - cover and/or attachments)
|
||||
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.(($domain_name != '') ? '/'.$domain_name : null);
|
||||
@@ -200,8 +210,12 @@ if (sizeof($result) != 0) {
|
||||
}
|
||||
|
||||
//send fax
|
||||
$cwd = getcwd();
|
||||
$included = true;
|
||||
require("fax_send.php");
|
||||
if($cwd){
|
||||
chdir($cwd);
|
||||
}
|
||||
|
||||
//reset variables
|
||||
unset($fax_numbers);
|
||||
|
||||
+162
-38
@@ -84,21 +84,29 @@ if (!$included) {
|
||||
}
|
||||
foreach ($result as &$row) {
|
||||
//set database fields as variables
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$fax_caller_id_name = $row["fax_caller_id_name"];
|
||||
$fax_caller_id_number = $row["fax_caller_id_number"];
|
||||
$fax_accountcode = $row["accountcode"];
|
||||
$fax_send_greeting = $row["fax_send_greeting"];
|
||||
//limit to one row
|
||||
break;
|
||||
}
|
||||
unset ($prep_statement);
|
||||
$fax_send_mode = $_SESSION['fax']['send_mode']['text'];
|
||||
if(strlen($fax_send_mode) == 0){
|
||||
$fax_send_mode = 'direct';
|
||||
}
|
||||
}
|
||||
|
||||
//set the fax directory
|
||||
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null);
|
||||
|
||||
// set fax cover font to generate pdf
|
||||
$fax_cover_font = $_SESSION['fax']['cover_font']['text'];
|
||||
}
|
||||
else {
|
||||
else{
|
||||
require_once "resources/classes/EventSocket.php";
|
||||
}
|
||||
|
||||
@@ -122,6 +130,68 @@ if(!function_exists('gs_cmd')) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('fax_enqueue')) {
|
||||
function fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string){
|
||||
global $db, $db_type;
|
||||
|
||||
$task_uuid = uuid();
|
||||
$dial_string .= "task_uuid='" . $task_uuid . "',";
|
||||
$description = ''; //! @todo add description
|
||||
if ($db_type == "pgsql") {
|
||||
$date_utc_now_sql = "NOW() at time zone 'utc'";
|
||||
}
|
||||
if ($db_type == "mysql") {
|
||||
$date_utc_now_sql = "UTC_TIMESTAMP()";
|
||||
}
|
||||
if ($db_type == "sqlite") {
|
||||
$date_utc_now_sql = "datetime('now')";
|
||||
}
|
||||
$sql = <<<HERE
|
||||
INSERT INTO v_fax_tasks( task_uuid, fax_uuid,
|
||||
task_next_time, task_lock_time,
|
||||
task_fax_file, task_wav_file, task_uri, task_dial_string, task_dtmf,
|
||||
task_interrupted, task_status, task_no_answer_counter, task_no_answer_retry_counter, task_retry_counter,
|
||||
task_description)
|
||||
VALUES (?, ?,
|
||||
$date_utc_now_sql, NULL,
|
||||
?, ?, ?, ?, ?,
|
||||
'false', 0, 0, 0, 0,
|
||||
?);
|
||||
HERE;
|
||||
$stmt = $db->prepare($sql);
|
||||
$i = 0;
|
||||
$stmt->bindValue(++$i, $task_uuid);
|
||||
$stmt->bindValue(++$i, $fax_uuid);
|
||||
$stmt->bindValue(++$i, $fax_file);
|
||||
$stmt->bindValue(++$i, $wav_file);
|
||||
$stmt->bindValue(++$i, $fax_uri);
|
||||
$stmt->bindValue(++$i, $dial_string);
|
||||
$stmt->bindValue(++$i, $fax_dtmf);
|
||||
$stmt->bindValue(++$i, $description);
|
||||
if ($stmt->execute()) {
|
||||
$response = 'Enqueued';
|
||||
}
|
||||
else{
|
||||
//! @todo log error
|
||||
$response = 'Fail enqueue';
|
||||
var_dump($db->errorInfo());
|
||||
}
|
||||
unset($stmt);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('fax_split_dtmf')) {
|
||||
function fax_split_dtmf(&$fax_number, &$fax_dtmf){
|
||||
$tmp = array();
|
||||
$fax_dtmf = '';
|
||||
if(preg_match('/^\s*(.*?)\s*\((.*)\)\s*$/', $fax_number, $tmp)){
|
||||
$fax_number = $tmp[1];
|
||||
$fax_dtmf = $tmp[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get the fax extension
|
||||
if (strlen($fax_extension) > 0) {
|
||||
//set the fax directories. example /usr/local/freeswitch/storage/fax/329/inbox
|
||||
@@ -171,14 +241,6 @@ if(!function_exists('gs_cmd')) {
|
||||
if (($_POST['action'] == "send")) {
|
||||
|
||||
$fax_numbers = $_POST['fax_numbers'];
|
||||
if (sizeof($fax_numbers) > 0) {
|
||||
foreach ($fax_numbers as $index => $fax_number) {
|
||||
$fax_numbers[$index] = preg_replace("~[^0-9]~", "", $fax_number);
|
||||
if ($fax_numbers[$index] == '') { unset($fax_numbers[$index]); }
|
||||
}
|
||||
sort($fax_numbers);
|
||||
}
|
||||
|
||||
$fax_uuid = check_str($_POST["id"]);
|
||||
$fax_caller_id_name = check_str($_POST['fax_caller_id_name']);
|
||||
$fax_caller_id_number = check_str($_POST['fax_caller_id_number']);
|
||||
@@ -200,6 +262,23 @@ if(!function_exists('gs_cmd')) {
|
||||
$continue = true;
|
||||
}
|
||||
|
||||
// cleanup numbers
|
||||
if (isset($fax_numbers)) {
|
||||
foreach ($fax_numbers as $index => $fax_number) {
|
||||
fax_split_dtmf($fax_number, $fax_dtmf);
|
||||
$fax_number = preg_replace("~[^0-9]~", "", $fax_number);
|
||||
$fax_dtmf = preg_replace("~[^0-9Pp*#]~", "", $fax_dtmf);
|
||||
if ($fax_number != ''){
|
||||
if ($fax_dtmf != '') {$fax_number .= " (" . $fax_dtmf . ")";}
|
||||
$fax_numbers[$index] = $fax_number;
|
||||
}
|
||||
else{
|
||||
unset($fax_numbers[$index]);
|
||||
}
|
||||
}
|
||||
sort($fax_numbers);
|
||||
}
|
||||
|
||||
if ($continue) {
|
||||
//determine page size
|
||||
switch ($fax_page_size) {
|
||||
@@ -322,6 +401,19 @@ if(!function_exists('gs_cmd')) {
|
||||
$pdf -> setPrintFooter(false);
|
||||
$pdf -> SetMargins(0, 0, 0, true);
|
||||
|
||||
if(strlen($fax_cover_font) > 0){
|
||||
if(substr($fax_cover_font, -4) == '.ttf'){
|
||||
$pdf_font = TCPDF_FONTS::addTTFfont($fax_cover_font);
|
||||
}
|
||||
else{
|
||||
$pdf_font = $fax_cover_font;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$pdf_font){
|
||||
$pdf_font = 'times';
|
||||
}
|
||||
|
||||
//add blank page
|
||||
$pdf -> AddPage('P', array($page_width, $page_height));
|
||||
|
||||
@@ -329,9 +421,6 @@ if(!function_exists('gs_cmd')) {
|
||||
$x = 0;
|
||||
$y = 0;
|
||||
|
||||
// output grid
|
||||
//showgrid($pdf);
|
||||
|
||||
//logo
|
||||
$display_logo = false;
|
||||
if (!isset($_SESSION['fax']['cover_logo']['text'])) {
|
||||
@@ -375,23 +464,23 @@ if(!function_exists('gs_cmd')) {
|
||||
//header
|
||||
if ($fax_header != '') {
|
||||
$pdf -> SetLeftMargin(0.5);
|
||||
$pdf -> SetFont("times", "", 10);
|
||||
$pdf -> SetFont($pdf_font, "", 10);
|
||||
$pdf -> Write(0.3, $fax_header);
|
||||
}
|
||||
|
||||
//fax, cover sheet
|
||||
$pdf -> SetTextColor(0,0,0);
|
||||
$pdf -> SetFont("times", "B", 55);
|
||||
$pdf -> SetFont($pdf_font, "B", 55);
|
||||
$pdf -> SetXY($x + 4.55, $y + 0.25);
|
||||
$pdf -> Cell($x + 3.50, $y + 0.4, $text['label-fax-fax'], 0, 0, 'R', false, null, 0, false, 'T', 'T');
|
||||
$pdf -> SetFont("times", "", 12);
|
||||
$pdf -> SetFont($pdf_font, "", 12);
|
||||
$pdf -> SetFontSpacing(0.0425);
|
||||
$pdf -> SetXY($x + 4.55, $y + 1.0);
|
||||
$pdf -> Cell($x + 3.50, $y + 0.4, $text['label-fax-cover-sheet'], 0, 0, 'R', false, null, 0, false, 'T', 'T');
|
||||
$pdf -> SetFontSpacing(0);
|
||||
|
||||
//field labels
|
||||
$pdf -> SetFont("times", "B", 12);
|
||||
$pdf -> SetFont($pdf_font, "B", 12);
|
||||
if ($fax_recipient != '' || sizeof($fax_numbers) > 0) {
|
||||
$pdf -> Text($x + 0.5, $y + 2.0, strtoupper($text['label-fax-recipient']).":");
|
||||
}
|
||||
@@ -406,7 +495,7 @@ if(!function_exists('gs_cmd')) {
|
||||
}
|
||||
|
||||
//field values
|
||||
$pdf -> SetFont("times", "", 12);
|
||||
$pdf -> SetFont($pdf_font, "", 12);
|
||||
$pdf -> SetXY($x + 2.0, $y + 1.95);
|
||||
if ($fax_recipient != '') {
|
||||
$pdf -> Write(0.3, $fax_recipient);
|
||||
@@ -446,7 +535,7 @@ if(!function_exists('gs_cmd')) {
|
||||
//message
|
||||
$pdf -> Rect($x + 0.5, $y + 3.4, 7.5, 6.25, 'D');
|
||||
if ($fax_message != '') {
|
||||
$pdf -> SetFont("times", "", 12);
|
||||
$pdf -> SetFont($pdf_font, "", 12);
|
||||
$pdf -> SetXY($x + 0.75, $y + 3.65);
|
||||
$pdf -> MultiCell(7, 5.75, $fax_message, 0, 'L', false);
|
||||
}
|
||||
@@ -534,7 +623,7 @@ if(!function_exists('gs_cmd')) {
|
||||
}
|
||||
|
||||
//preview, if requested
|
||||
if ($_REQUEST['submit'] == $text['button-preview']) {
|
||||
if (($_REQUEST['submit'] != '') && ($_REQUEST['submit'] == $text['button-preview'])) {
|
||||
unset($file_type);
|
||||
if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf')) {
|
||||
$file_type = 'pdf';
|
||||
@@ -599,29 +688,64 @@ if(!function_exists('gs_cmd')) {
|
||||
}
|
||||
|
||||
//send the fax
|
||||
$fax_file = $dir_fax_temp."/".$fax_instance_uuid.".tif";
|
||||
$common_dial_string = "for_fax=1,";
|
||||
$common_dial_string .= "accountcode='" . $fax_accountcode . "',";
|
||||
$common_dial_string .= "sip_h_X-accountcode='" . $fax_accountcode . "',";
|
||||
$common_dial_string .= "domain_uuid=" . $_SESSION["domain_uuid"] . ",";
|
||||
$common_dial_string .= "domain_name=" . $_SESSION["domain_name"] . ",";
|
||||
$common_dial_string .= "mailto_address='" . $mailto_address . "',";
|
||||
$common_dial_string .= "mailfrom_address='" . $mailfrom_address . "',";
|
||||
$common_dial_string .= "origination_caller_id_name='" . $fax_caller_id_name . "',";
|
||||
$common_dial_string .= "origination_caller_id_number='" . $fax_caller_id_number . "',";
|
||||
$common_dial_string .= "fax_ident='" . $fax_caller_id_number . "',";
|
||||
$common_dial_string .= "fax_header='" . $fax_caller_id_name . "',";
|
||||
$common_dial_string .= "fax_file='" . $fax_file . "',";
|
||||
|
||||
foreach ($fax_numbers as $fax_number) {
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
//prepare the fax command
|
||||
$route_array = outbound_route_to_bridge($_SESSION['domain_uuid'], $fax_prefix.$fax_number);
|
||||
$fax_file = $dir_fax_temp."/".$fax_instance_uuid.".tif";
|
||||
if (count($route_array) == 0) {
|
||||
//send the internal call to the registered extension
|
||||
$fax_uri = "user/".$fax_number."@".$_SESSION['domain_name'];
|
||||
$t38 = "";
|
||||
$dial_string = $common_dial_string;
|
||||
fax_split_dtmf($fax_number, $fax_dtmf);
|
||||
|
||||
//prepare the fax command
|
||||
$route_array = outbound_route_to_bridge($_SESSION['domain_uuid'], $fax_prefix . $fax_number);
|
||||
|
||||
if (count($route_array) == 0) {
|
||||
//send the internal call to the registered extension
|
||||
$fax_uri = "user/".$fax_number."@".$_SESSION['domain_name'];
|
||||
$t38 = "";
|
||||
}
|
||||
else {
|
||||
//send the external call
|
||||
$fax_uri = $route_array[0];
|
||||
$t38 = "fax_enable_t38=true,fax_enable_t38_request=true,";
|
||||
}
|
||||
|
||||
if ($fax_send_mode != 'queue') {
|
||||
$dial_string .= $t38;
|
||||
$dial_string .= "fax_uri=" . $fax_uri . ",";
|
||||
$dial_string .= "fax_retry_attempts=1" . ",";
|
||||
$dial_string .= "fax_retry_limit=20" . ",";
|
||||
$dial_string .= "fax_retry_sleep=180" . ",";
|
||||
$dial_string .= "fax_verbose=true" . ",";
|
||||
$dial_string .= "fax_use_ecm=off" . ",";
|
||||
$dial_string .= "api_hangup_hook='lua fax_retry.lua'";
|
||||
$dial_string = "{" . $dial_string . "}" . $fax_uri." &txfax('".$fax_file."')";
|
||||
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$cmd = "api originate " . $dial_string;
|
||||
// echo($cmd . "<br/>\n");
|
||||
//send the command to event socket
|
||||
$response = event_socket_request($fp, $cmd);
|
||||
$response = str_replace("\n", "", $response);
|
||||
$uuid = str_replace("+OK ", "", $response);
|
||||
}
|
||||
else {
|
||||
//send the external call
|
||||
$fax_uri = $route_array[0];
|
||||
$t38 = "fax_enable_t38=true,fax_enable_t38_request=true,";
|
||||
}
|
||||
$cmd = "api originate {for_fax=1,accountcode='".$fax_accountcode."',sip_h_X-accountcode='".$fax_accountcode."',domain_uuid=".$_SESSION["domain_uuid"].",domain_name=".$_SESSION["domain_name"].",mailto_address='".$mailto_address."',mailfrom_address='".$mailfrom_address."',origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')";
|
||||
//send the command to event socket
|
||||
$response = event_socket_request($fp, $cmd);
|
||||
$response = str_replace("\n", "", $response);
|
||||
$uuid = str_replace("+OK ", "", $response);
|
||||
fclose($fp);
|
||||
}
|
||||
else{ // enqueue
|
||||
$wav_file = ''; //! @todo add custom message
|
||||
$response = fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string);
|
||||
}
|
||||
}
|
||||
|
||||
//wait for a few seconds
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
function parse_message($connection, $message_number, $option = '', $to_charset = 'UTF-8') {
|
||||
$structure = imap_fetchstructure($connection, $message_number, $option);
|
||||
if(isset($structure->parts) && count($structure->parts)) {
|
||||
for($i = 0; $i < count($structure->parts); $i++) {
|
||||
$msg = '';
|
||||
$part = $structure->parts[$i];
|
||||
if($part->type == TYPETEXT){
|
||||
$msg = imap_fetchbody($connection, $message_number, $i+1, $option);
|
||||
if($part->encoding == ENCBASE64){
|
||||
$msg = base64_decode($msg);
|
||||
}
|
||||
else if($part->encoding == ENCQUOTEDPRINTABLE){
|
||||
$msg = quoted_printable_decode($msg);
|
||||
}
|
||||
if($msg && $to_charset){
|
||||
$charset = '';
|
||||
if(isset($part->parameters) && count($part->parameters)) {
|
||||
foreach($part->parameters as &$parameter){
|
||||
if($parameter->attribute == 'CHARSET') {
|
||||
$charset = $parameter->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($charset){
|
||||
$msg = mb_convert_encoding($msg, $to_charset, $charset);
|
||||
}
|
||||
}
|
||||
|
||||
if($msg){
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user