diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index b55b1ee6f7..1eb6886643 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -1341,7 +1341,7 @@ if (!class_exists('xml_cdr')) { //$parameters['domain_uuid'] = $domain_uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); - if (is_array($row)) { + if (!empty($row) && is_array($row)) { $record_name = $row['record_name']; $record_path = $row['record_path']; } else { @@ -1354,24 +1354,20 @@ if (!class_exists('xml_cdr')) { $record_file = $record_path.'/'.$record_name; //download the file - if (!file_exists($record_file)) { + if (!file_exists($record_file) || $record_file == '/') { echo "recording not found"; return; } - //content-range - if (isset($_SERVER['HTTP_RANGE']) && $_GET['t'] != "bin") { - $this->range_download($record_file); - } - - ob_clean(); + //ob_clean(); $fd = fopen($record_file, "rb"); if ($_GET['t'] == "bin") { header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); - } else { + } + else { $file_ext = pathinfo($record_name, PATHINFO_EXTENSION); switch ($file_ext) { case "wav" : header("Content-Type: audio/x-wav"); break; @@ -1386,8 +1382,13 @@ if (!class_exists('xml_cdr')) { if ($_GET['t'] == "bin") { header("Content-Length: ".filesize($record_file)); } - ob_clean(); - fpassthru($fd); + //ob_clean(); + //fpassthru($fd); + + //content-range + if (isset($_SERVER['HTTP_RANGE']) && $_GET['t'] != "bin") { + $this->range_download($record_file); + } } //end download method @@ -1488,7 +1489,7 @@ if (!class_exists('xml_cdr')) { * delete records */ public function delete($records) { - if (permission_exists($this->permission_prefix.'delete')) { + if (!permission_exists($this->permission_prefix.'delete')) { return false; } @@ -1512,7 +1513,7 @@ if (!class_exists('xml_cdr')) { //loop through records foreach($records as $x => $record) { - if ($record['checked'] != 'true' || !is_uuid($record['uuid'])) { + if (empty($record['checked']) || $record['checked'] != 'true' || !is_uuid($record['uuid'])) { continue; } diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index ce15083cc7..8b6536e84b 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -255,8 +255,8 @@ if (permission_exists('xml_cdr_b_leg')){ echo " \n"; } echo " \n"; @@ -480,7 +480,7 @@ echo " \n"; } if (permission_exists('xml_cdr_custom_fields')) { - if (is_array($_SESSION['cdr']['field'])) { + if (!empty($_SESSION['cdr']['field']) && is_array($_SESSION['cdr']['field'])) { echo " \n"; echo " \n"; foreach ($_SESSION['cdr']['field'] as $field) { @@ -535,7 +535,7 @@ $col_count = 0; if (!$archive_request && permission_exists('xml_cdr_delete')) { echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; $col_count++; } @@ -644,6 +644,9 @@ $x = 0; foreach ($result as $index => $row) { + //clear previous variables + unset($record_path, $record_name); + //get the hangup cause $hangup_cause = $row['hangup_cause']; $hangup_cause = str_replace("_", " ", $hangup_cause); @@ -654,7 +657,7 @@ $seconds = $row['hangup_cause'] == "ORIGINATOR_CANCEL" ? $row['duration'] : round(($row['billmsec'] / 1000), 0, PHP_ROUND_HALF_UP); //determine recording properties - if (permission_exists('xml_cdr_recording_play') || permission_exists('xml_cdr_recording_download')) { + if (!empty($row['record_path']) && !empty($row['record_name']) && permission_exists('xml_cdr_recording') && (permission_exists('xml_cdr_recording_play') || permission_exists('xml_cdr_recording_download'))) { $record_path = $row['record_path']; $record_name = $row['record_name']; //$record_name = strtolower(pathinfo($tmp_name, PATHINFO_BASENAME)); @@ -670,7 +673,7 @@ $content = ''; //recording playback - if (permission_exists('xml_cdr_recording_play') && $record_path != '') { + if (permission_exists('xml_cdr_recording_play')) { $content .= "\n"; $content .= "\n"; // dummy row to maintain alternating background color } @@ -743,10 +746,10 @@ $content .= " "; $content .= " \n"; if (is_numeric($row['caller_destination'])) { - $content .= " ".format_phone(escape(substr($row['caller_destination'], 0, 20))).' '; + $content .= " ".escape(format_phone(substr($row['caller_destination'], 0, 20))).' '; } else { - $content .= " ".escape(substr($row['caller_destination'], 0, 20)).' '; + $content .= " ".escape(substr($row['caller_destination'] ?? '', 0, 20)).' '; } $content .= " "; $content .= " \n"; @@ -756,7 +759,7 @@ $content .= " "; $content .= " \n"; if (is_numeric($row['destination_number'])) { - $content .= format_phone(escape(substr($row['destination_number'], 0, 20)))."\n"; + $content .= escape(format_phone(substr($row['destination_number'], 0, 20)))."\n"; } else { $content .= escape(substr($row['destination_number'], 0, 20))."\n"; @@ -766,7 +769,7 @@ } //recording if (permission_exists('xml_cdr_recording') && (permission_exists('xml_cdr_recording_play') || permission_exists('xml_cdr_recording_download'))) { - if ($record_path != '') { + if (!empty($record_path) || !empty($record_name)) { $content .= " "; if (permission_exists('xml_cdr_recording_play')) { $content .= ""; @@ -783,7 +786,7 @@ } //custom cdr fields if (permission_exists('xml_cdr_custom_fields')) { - if (is_array($_SESSION['cdr']['field'])) { + if (!empty($_SESSION['cdr']['field']) && is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { $array = explode(",", $field); $field_name = $array[count($array) - 1]; @@ -800,7 +803,7 @@ } //tta (time to answer) if (permission_exists('xml_cdr_tta')) { - $content .= " ".(($row['tta'] >= 0) ? $row['tta']."s" : " ")."\n"; + $content .= " ".(!empty($row['tta']) && $row['tta'] >= 0 ? $row['tta']."s" : " ")."\n"; } //duration if (permission_exists('xml_cdr_duration')) { @@ -816,7 +819,7 @@ $title = " title='".$text['label-mos_score-'.round($row['rtp_audio_in_mos'])]."'"; $value = $row['rtp_audio_in_mos']; } - $content .= " ".$value."\n"; + $content .= " ".($value ?? '')."\n"; } //call result/status if (permission_exists("xml_cdr_status")) { diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php index 1ba37cfe15..368ed41ee3 100644 --- a/app/xml_cdr/xml_cdr_details.php +++ b/app/xml_cdr/xml_cdr_details.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2019 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -63,9 +63,9 @@ $parameters['xml_cdr_uuid'] = $uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); - if (is_array($row) && @sizeof($row) != 0) { + if (!empty($row) && is_array($row) && @sizeof($row) != 0) { $start_stamp = trim($row["start_stamp"]); - $xml_string = trim($row["xml"]); + $xml_string = trim($row["xml"] ?? ''); $json_string = trim($row["json"]); } unset($sql, $parameters, $row); @@ -136,11 +136,11 @@ //get the variables $xml_cdr_uuid = urldecode($array["variables"]["uuid"]); $direction = urldecode($array["variables"]["call_direction"]); - $language = urldecode($array["variables"]["language"]); + $language = urldecode($array["variables"]["language"] ?? ''); $start_epoch = urldecode($array["variables"]["start_epoch"]); $start_stamp = urldecode($array["variables"]["start_stamp"]); $start_uepoch = urldecode($array["variables"]["start_uepoch"]); - $answer_stamp = urldecode($array["variables"]["answer_stamp"]); + $answer_stamp = urldecode($array["variables"]["answer_stamp"] ?? ''); $answer_epoch = urldecode($array["variables"]["answer_epoch"]); $answer_uepoch = urldecode($array["variables"]["answer_uepoch"]); $end_epoch = urldecode($array["variables"]["end_epoch"]); @@ -150,10 +150,10 @@ $mduration = urldecode($array["variables"]["mduration"]); $billsec = urldecode($array["variables"]["billsec"]); $billmsec = urldecode($array["variables"]["billmsec"]); - $bridge_uuid = urldecode($array["variables"]["bridge_uuid"]); - $read_codec = urldecode($array["variables"]["read_codec"]); - $write_codec = urldecode($array["variables"]["write_codec"]); - $remote_media_ip = urldecode($array["variables"]["remote_media_ip"]); + $bridge_uuid = urldecode($array["variables"]["bridge_uuid"] ?? ''); + $read_codec = urldecode($array["variables"]["read_codec"] ?? ''); + $write_codec = urldecode($array["variables"]["write_codec"] ?? ''); + $remote_media_ip = urldecode($array["variables"]["remote_media_ip"] ?? ''); $hangup_cause = urldecode($array["variables"]["hangup_cause"]); $hangup_cause_q850 = urldecode($array["variables"]["hangup_cause_q850"]); if (!isset($array["callflow"][0])) { @@ -179,9 +179,9 @@ else { $tmp_end_stamp = urldecode($row["times"]["transfer_time"]) / 1000000; } - $call_flow_summary[$x]["start_stamp"] = date("Y-m-d H:i:s", $tmp_start_stamp); - $call_flow_summary[$x]["end_stamp"] = date("Y-m-d H:i:s", $tmp_end_stamp); - $call_flow_summary[$x]["duration"] = gmdate("G:i:s", $tmp_end_stamp - $tmp_start_stamp); + $call_flow_summary[$x]["start_stamp"] = date("Y-m-d H:i:s", (int) $tmp_start_stamp); + $call_flow_summary[$x]["end_stamp"] = date("Y-m-d H:i:s", (int) $tmp_end_stamp); + $call_flow_summary[$x]["duration"] = gmdate("G:i:s", (int) $tmp_end_stamp - (int) $tmp_start_stamp); $x++; } unset($x); @@ -283,9 +283,9 @@ $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - if (is_array($array["call-stats"])) { - if (is_array($array["call-stats"]['audio'])) { - foreach($array["call-stats"]['audio'] as $audio_direction => $stat) { + if (!empty($array["call-stats"]) && is_array($array["call-stats"])) { + if (!empty($array["call-stats"]['audio']) && is_array($array["call-stats"]['audio'])) { + foreach ($array["call-stats"]['audio'] as $audio_direction => $stat) { echo " \n"; echo " \n"; echo " \n"; @@ -298,7 +298,7 @@ echo " \n"; echo " \n"; echo " \n"; - foreach($stat as $key => $value) { + foreach ($stat as $key => $value) { $value = urldecode($value); echo "\n"; echo " \n"; @@ -519,16 +519,21 @@ echo " \n"; echo " \n"; echo "
".$text['label-call-stats'].": ".$audio_direction." ".$text['label-name']."".$text['label-value']."
".escape($key)." 
\n"; - echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if (is_array($row["extension"]["application"])) { - foreach ($row["extension"]["application"] as $tmp_row) { - $app_name = $tmp_row["@attributes"]["app_name"]; - $app_data = urldecode($tmp_row["@attributes"]["app_data"]); + foreach ($row["extension"]["application"] as $key => $tmp_row) { + if (!is_numeric($key)) { + $app_name = $tmp_row["app_name"] ?? ''; + $app_data = urldecode($tmp_row["app_data"] ?? ''); + } + else { + $app_name = $tmp_row["@attributes"]["app_name"] ?? ''; + $app_data = urldecode($tmp_row["@attributes"]["app_data"] ?? ''); + } echo " \n"; echo " \n"; echo " \n"; @@ -555,36 +560,63 @@ echo " \n"; echo " \n"; if (is_array($row["caller_profile"])) { - foreach($row["caller_profile"] as $key => $value) { - if (is_array($value)) { $value = implode($value); } - $value = urldecode($value); - echo " \n"; - if ($key != "originatee") { - if (is_array($value)) { $value = implode($value); } - $value = urldecode($value); + foreach ($row["caller_profile"] as $key => $value) { + echo " \n"; + if ($key != "originatee" && $key != "origination") { + if (is_array($value)) { + $value = implode('', $value); + } + else { + $value = urldecode($value); + } echo " \n"; - echo " \n"; + if ($key == "uuid") { + echo " \n"; + } + else { + echo " \n"; + } } else { echo " \n"; echo " \n"; } - echo "
".$text['label-name']."".$text['label-data']."
".escape($app_name)." ".escape(wordwrap($app_data,75,"\n", true))." ".$text['label-value']."
".escape($key)." ".escape(wordwrap($value,75,"\n", true))." ".escape($value)." ".escape(wordwrap($value,75,"\n", true))." ".escape($key)." \n"; - echo " \n"; - if (isset($child["originatee_caller_profile"])) { - foreach($child["originatee_caller_profile"] as $key => $value) { - //print_r($tmp_child); - echo " \n"; - echo " \n"; - if ($key != "uuid") { - echo " \n"; + if (isset($value[$key."_caller_profile"]) && is_array($value[$key."_caller_profile"])) { + echo "
".escape($key)." ".escape(wordwrap($value,75,"\n", true))." 
\n"; + foreach ($value[$key."_caller_profile"] as $key_2 => $value_2) { + if (is_numeric($key_2)) { + $group_output = false; + foreach ($value_2 as $key_3 => $value_3) { + echo " \n"; + if ($group_output == false) { + echo " \n"; + $group_output = true; + } + echo " \n"; + if (is_array($value_3)) { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + } } else { - echo " \n"; + echo " \n"; + echo " \n"; + if (is_array($value_2)) { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; } - echo " \n"; } + unset($key_2, $value_2); + echo "
".escape($key_2)." ".escape($key_3)." ".escape(implode('', $value_3))." ".escape(wordwrap($value_3,75,"\n", true))." 
".escape($value)." 
".escape($key_2)." ".escape(implode('', $value_2))." ".escape(wordwrap($value_2,75,"\n", true))." 
\n"; + echo "
\n"; - echo " \n"; } echo "\n"; $c = $c ? 0 : 1; diff --git a/app/xml_cdr/xml_cdr_export.php b/app/xml_cdr/xml_cdr_export.php index cf82e2a954..b924a2fa37 100644 --- a/app/xml_cdr/xml_cdr_export.php +++ b/app/xml_cdr/xml_cdr_export.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2020 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -47,7 +47,7 @@ //additional includes $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $archive_request = $_POST['archive_request'] == 'true' ? true : false; + $archive_request = isset($_POST['archive_request']) && $_POST['archive_request'] == 'true' ? true : false; require_once "xml_cdr_inc.php"; //get the format @@ -159,7 +159,7 @@ $data_head .= ''.$text['label-billsec'].''; $data_head .= ''."PDD".''; $data_head .= ''."MOS".''; - if (is_array($_SESSION['cdr']['field'])) { + if (!empty($_SESSION['cdr']['field']) && is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { $array = explode(",", $field); $field_name = end($array); @@ -188,7 +188,7 @@ $p = 0; // per page counter if (sizeof($result) > 0) { foreach ($result as $cdr_num => $fields) { - $data_body[$p] .= ''; + $data_body[$p] = ''; $data_body[$p] .= ''.$text['label-'.$fields['direction']].''; $data_body[$p] .= ''.$fields['caller_id_name'].''; $data_body[$p] .= ''.$fields['caller_id_number'].''; @@ -214,7 +214,7 @@ } $data_body[$p] .= ''; - if (is_array($_SESSION['cdr']['field'])) { + if (!empty($_SESSION['cdr']['field']) && is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { $array = explode(",", $field); $field_name = end($array); @@ -278,7 +278,7 @@ $data_footer .= ''.$text['label-average'].''; $data_footer .= ''; $data_footer .= ''.round(($total['tta'] / $z), 1).''; - $data_footer .= ''.gmdate("G:i:s", ($total['duration'] / $z)).''; + $data_footer .= ''.gmdate("G:i:s", floor($total['duration'] / $z)).''; $data_footer .= ''.gmdate("G:i:s", round($total['billmsec'] / $z / 1000, 0)).''; $data_footer .= ''.number_format(round(($total['pdd_ms'] / $z / 1000), 2), 2).'s'; $data_footer .= ''.round(($total['rtp_audio_in_mos'] / $z), 2).''; diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index 5906da17b3..d79c01ef91 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -294,13 +294,13 @@ $sql .= "c.rtp_audio_in_mos, \n"; } $sql .= "(c.answer_epoch - c.start_epoch) as tta "; - if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { + if (!empty($_REQUEST['show']) && $_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { $sql .= ", c.domain_name \n"; } $sql .= "from v_xml_cdr as c \n"; $sql .= "left join v_extensions as e on e.extension_uuid = c.extension_uuid \n"; $sql .= "inner join v_domains as d on d.domain_uuid = c.domain_uuid \n"; - if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { + if (!empty($_REQUEST['show']) && $_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { $sql .= "where true \n"; } else { diff --git a/app/xml_cdr/xml_cdr_search.php b/app/xml_cdr/xml_cdr_search.php index a59ea89055..254e1961be 100644 --- a/app/xml_cdr/xml_cdr_search.php +++ b/app/xml_cdr/xml_cdr_search.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2008-2018 + Copyright (C) 2008-2023 All Rights Reserved. Contributor(s): @@ -164,7 +164,7 @@ $result_e = $database->select($sql, $parameters, 'all'); if (is_array($result_e) && @sizeof($result_e) != 0) { foreach ($result_e as &$row) { - $selected = ($row['extension_uuid'] == $caller_extension_uuid) ? "selected" : null; + $selected = (!empty($caller_extension_uuid) && $row['extension_uuid'] == $caller_extension_uuid) ? "selected" : null; echo " "; } }