diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index 9c6b59e9f7..64f34ca18f 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -36,7 +36,7 @@ if (defined('STDIN')) { //add multi-lingual support $language = new text; - $text = $language->get($setting->get('domain','language','en-us'), 'app/fax'); + $text = $language->get($settings->get('domain','language','en-us'), 'app/fax'); } //executed via browser @@ -47,13 +47,23 @@ else { require_once "resources/check_auth.php"; //set the domain_uuid and domain_name - $domain_uuid = $_SESSION['domain_uuid']; - $domain_name = $_SESSION['domain_name']; - $user_uuid = $_SESSION['user_uuid']; + $domain_uuid = $_SESSION['domain_uuid'] ?? ''; + $domain_name = $_SESSION['domain_name'] ?? ''; + $user_uuid = $_SESSION['user_uuid'] ?? ''; + + //initialize the config object + if (empty($config)) { + $config = config::load(); + } + + //initialize the database object + if (empty($database)) { + $database = database::new(['config' => $config]); + } //initialize the settings object if (empty($settings)) { - $setting = new settings(["domain_uuid" => $domain_uuid]); + $settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]); } //check permissions @@ -100,7 +110,6 @@ else { $parameters['fax_uuid'] = $fax_uuid; $parameters['user_uuid'] = $user_uuid; } - $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { //set database fields as variables @@ -121,12 +130,12 @@ else { } //set the fax directory - if (!empty($setting->get('switch','storage'))) { - $fax_dir = $setting->get('switch','storage').'/fax/'.$domain_name; + if (!empty($settings->get('switch','storage'))) { + $fax_dir = $settings->get('switch','storage').'/fax/'.$domain_name; } //set fax cover font to generate pdf - $fax_cover_font = $setting->get('fax','cover_font') ?? null; + $fax_cover_font = $settings->get('fax','cover_font') ?? null; } //define function correct_path @@ -171,14 +180,14 @@ if (!function_exists('fax_split_dtmf')) { $dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp'; //make sure the directories exist - if (!empty($setting->get('switch','storage')) && !is_dir($setting->get('switch','storage'))) { - mkdir($setting->get('switch','storage'), 0770); + if (!empty($settings->get('switch','storage')) && !is_dir($settings->get('switch','storage'))) { + mkdir($settings->get('switch','storage'), 0770); } - if (!empty($setting->get('switch','storage')) && !is_dir($setting->get('switch','storage').'/fax')) { - mkdir($setting->get('switch','storage').'/fax', 0770); + if (!empty($settings->get('switch','storage')) && !is_dir($settings->get('switch','storage').'/fax')) { + mkdir($settings->get('switch','storage').'/fax', 0770); } - if (!empty($setting->get('switch','storage')) && !is_dir($setting->get('switch','storage').'/fax/'.$domain_name)) { - mkdir($setting->get('switch','storage').'/fax/'.$domain_name, 0770); + if (!empty($settings->get('switch','storage')) && !is_dir($settings->get('switch','storage').'/fax/'.$domain_name)) { + mkdir($settings->get('switch','storage').'/fax/'.$domain_name, 0770); } if (!is_dir($fax_dir.'/'.$fax_extension)) { mkdir($fax_dir.'/'.$fax_extension, 0770); @@ -197,7 +206,6 @@ if (!function_exists('fax_split_dtmf')) { //check if the domain is enabled $sql = "select domain_enabled::text from v_domains where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; - $database = new database; $row = $database->select($sql, $parameters, 'row'); if ($row['domain_enabled'] == "true") { $domain_enabled = true; @@ -301,7 +309,7 @@ if (!function_exists('fax_split_dtmf')) { } //un/authorized file extensions - $allowed_file_extensions = $setting->get('fax','allowed_extension'); + $allowed_file_extensions = $settings->get('fax','allowed_extension'); $disallowed_file_extensions = explode(',','sh,ssh,so,dll,exe,bat,vbs,zip,rar,z,tar,tbz,tgz,gz'); //process uploaded or emailed files (if any) @@ -410,19 +418,19 @@ if (!function_exists('fax_split_dtmf')) { //logo $display_logo = false; - if (empty($setting->get('fax','cover_logo'))) { + if (empty($settings->get('fax','cover_logo'))) { $logo = ''; //explicitly empty } - else if ($setting->get('fax','cover_logo') != '') { - if (substr($setting->get('fax','cover_logo'), 0, 4) == 'http') { - $logo = $setting->get('fax','cover_logo'); + else if ($settings->get('fax','cover_logo') != '') { + if (substr($settings->get('fax','cover_logo'), 0, 4) == 'http') { + $logo = $settings->get('fax','cover_logo'); } - else if (substr($setting->get('fax','cover_logo'), 0, 1) == '/') { - if (substr($setting->get('fax','cover_logo'), 0, strlen($_SERVER['DOCUMENT_ROOT'])) != $_SERVER['DOCUMENT_ROOT']) { - $logo = $_SERVER['DOCUMENT_ROOT'].$setting->get('fax','cover_logo'); + else if (substr($settings->get('fax','cover_logo'), 0, 1) == '/') { + if (substr($settings->get('fax','cover_logo'), 0, strlen($_SERVER['DOCUMENT_ROOT'])) != $_SERVER['DOCUMENT_ROOT']) { + $logo = $_SERVER['DOCUMENT_ROOT'].$settings->get('fax','cover_logo'); } else { - $logo = $setting->get('fax','cover_logo'); + $logo = $settings->get('fax','cover_logo'); } } } @@ -497,7 +505,7 @@ if (!function_exists('fax_split_dtmf')) { $pdf->SetFont($pdf_font, "", 12); $pdf->SetXY($x + 2.0, $y + 1.65); if (defined('STDIN') || ($_REQUEST['submit'] != '' && $_REQUEST['submit'] != 'preview')) { - $date = new DateTime('now', new DateTimeZone( $setting->get('domain','time_zone', date_default_timezone_get() ) )); + $date = new DateTime('now', new DateTimeZone( $settings->get('domain','time_zone', date_default_timezone_get() ) )); $pdf->Write(0.3, $date->format('d M Y @ h:i:s A')); } $pdf->SetXY($x + 2.0, $y + 1.95); @@ -569,7 +577,7 @@ if (!function_exists('fax_split_dtmf')) { } else { //determine cover message box height, and difference, to adjust footer position accordingly - $cover_message_height = $setting->get('fax','cover_message_height'); + $cover_message_height = $settings->get('fax','cover_message_height'); $cover_message_height = (float) ($cover_message_height ?? 6.15); $height_difference = 6.15 - $cover_message_height; @@ -677,12 +685,11 @@ if (!function_exists('fax_split_dtmf')) { } //prepare variables send the fax - $mail_from_address = (!empty($setting->get('fax','smtp_from'))) ? $setting->get('fax','smtp_from') : $setting->get('email','smtp_from'); + $mail_from_address = (!empty($settings->get('fax','smtp_from'))) ? $settings->get('fax','smtp_from') : $settings->get('email','smtp_from'); //get the fax mail to address and fax prefix $sql = "select * from v_fax where fax_uuid = :fax_uuid "; $parameters['fax_uuid'] = $fax_uuid; - $database = new database; $row = $database->select($sql, $parameters, 'row'); //$mail_to_address = $row["fax_email"]; $fax_prefix = $row["fax_prefix"]; @@ -694,7 +701,6 @@ if (!function_exists('fax_split_dtmf')) { } else { $sql = "select user_email from v_users where user_uuid = :user_uuid "; $parameters['user_uuid'] = $user_uuid; - $database = new database; $user_settings = $database->select($sql, $parameters, 'row'); $mail_to_address = $user_settings["user_email"]; @@ -737,7 +743,6 @@ if (!function_exists('fax_split_dtmf')) { $sql .= "and dialplan_detail_data like 'provider_prefix%' "; $sql .= "and dialplan_detail_enabled = 'true' "; $parameters['domain_uuid'] = $domain_uuid; - $database = new database; $row = $database->select($sql, $parameters, 'row'); $dialplan_detail_data = $row["dialplan_detail_data"]; unset($sql, $parameters, $row); @@ -805,7 +810,7 @@ if (!function_exists('fax_split_dtmf')) { //send the external call $fax_variables = ''; - foreach($setting->get('fax','variable') as $variable) { + foreach($settings->get('fax','variable') as $variable) { $fax_variables .= $variable.","; } } @@ -848,7 +853,6 @@ if (!function_exists('fax_split_dtmf')) { $p->add('fax_queue_add', 'temp'); //save the data - $database = new database; $database->app_name = 'fax queue'; $database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4'; $database->save($array); @@ -897,7 +901,7 @@ if (!defined('STDIN')) { $sql .= "and cp.phone_type_fax = 1 "; $sql .= "and cp.phone_number is not null "; $sql .= "and cp.phone_number <> '' "; - if ($setting->get('contact','permissions', false)) { + if ($settings->get('contact','permissions', false)) { if (is_array($user_group_uuids) && @sizeof($user_group_uuids) != 0) { //only show contacts assigned to current user's group(s) and those not assigned to any group $sql .= "and ("; @@ -923,7 +927,6 @@ if (!defined('STDIN')) { } } $parameters['domain_uuid'] = $domain_uuid; - $database = new database; $contacts = $database->select($sql, $parameters, 'all'); unset($sql, $parameters, $row); @@ -1013,7 +1016,7 @@ if (!defined('STDIN')) { echo "
\n"; echo "
".$text['header-new_fax']."
\n"; echo "
\n"; - echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$setting->get('theme','button_icon_back'),'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'fax.php']); + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme','button_icon_back'),'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'fax.php']); if ($domain_enabled == true) { echo button::create(['type'=>'submit','label'=>$text['button-preview'],'icon'=>'eye','name'=>'submit','value'=>'preview']); echo button::create(['type'=>'submit','label'=>$text['button-send'],'icon'=>'paper-plane','id'=>'btn_save','name'=>'submit','value'=>'send','style'=>'margin-left: 15px;']); @@ -1036,7 +1039,7 @@ if (!defined('STDIN')) { echo " ".$text['label-fax-header']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo " ".$text['description-fax-header']."\n"; echo "\n"; @@ -1104,7 +1107,7 @@ if (!defined('STDIN')) { for ($f = 1; $f <= 3; $f++) { echo " 1) ? "style='display: none;'" : null).">"; echo " "; - echo button::create(['type'=>'button','label'=>$text['button-clear'],'icon'=>$setting->get('theme','button_icon_reset'),'onclick'=>"reset_file_input('fax_files_".$f."'); document.getElementById('file_list_".$f."').innerHTML='';"]); + echo button::create(['type'=>'button','label'=>$text['button-clear'],'icon'=>$settings->get('theme','button_icon_reset'),'onclick'=>"reset_file_input('fax_files_".$f."'); document.getElementById('file_list_".$f."').innerHTML='';"]); echo "
"; echo " "; echo "
\n"; @@ -1119,9 +1122,9 @@ if (!defined('STDIN')) { echo "\n"; echo "\n"; echo " \n"; echo "
\n"; echo " ".$text['description-fax-resolution']."\n"; @@ -1134,9 +1137,9 @@ if (!defined('STDIN')) { echo "\n"; echo "\n"; echo " \n"; echo "
\n"; echo " ".$text['description-fax-page-size']."\n"; @@ -1144,7 +1147,7 @@ if (!defined('STDIN')) { echo "\n"; if (permission_exists('fax_subject')) { - $cover_subject_required = $setting->get('fax','cover_subject_required') ?? ''; + $cover_subject_required = $settings->get('fax','cover_subject_required') ?? ''; $class = ($cover_subject_required == 'true') ? 'vncellreq' : 'vncell'; $required = ($cover_subject_required == 'true') ? 'required' : ''; echo "\n"; @@ -1160,7 +1163,7 @@ if (!defined('STDIN')) { } if (permission_exists('fax_message')) { - $cover_message_required = $setting->get('fax','cover_message_required') ?? ''; + $cover_message_required = $settings->get('fax','cover_message_required') ?? ''; $class = ($cover_message_required == 'true') ? 'vncellreq' : 'vncell'; $required = ($cover_message_required == 'true') ? 'required' : ''; echo "\n"; @@ -1168,7 +1171,7 @@ if (!defined('STDIN')) { echo " ".$text['label-fax-message']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo " ".$text['description-fax-message']."\n"; echo "\n"; @@ -1181,7 +1184,7 @@ if (!defined('STDIN')) { echo " ".$text['label-fax-footer']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo " ".$text['description-fax-footer']."\n"; echo "\n"; @@ -1228,4 +1231,3 @@ function showgrid($pdf) { } } */ -?> \ No newline at end of file