From e8e6673be80bcd61ea3538ab35832605e7330dcb Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 10 Aug 2023 09:05:42 -0600 Subject: [PATCH] Remove some redudant code for finding record_path and record_name --- app/xml_cdr/resources/classes/xml_cdr.php | 49 +++++------------------ 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 55b122404b..d9767aced8 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -683,7 +683,7 @@ if (!class_exists('xml_cdr')) { } //get the recording details - if (isset($xml->variables->record_path)) { + if (isset($xml->variables->record_path) && isset($xml->variables->record_name)) { $record_path = urldecode($xml->variables->record_path); $record_name = urldecode($xml->variables->record_name); if (isset($xml->variables->record_seconds)) { @@ -693,31 +693,21 @@ if (!class_exists('xml_cdr')) { $record_length = urldecode($xml->variables->duration); } } + elseif (isset($xml->variables->cc_record_filename)) { + $record_path = dirname(urldecode($xml->variables->cc_record_filename)); + $record_name = basename(urldecode($xml->variables->cc_record_filename)); + $record_length = urldecode($xml->variables->record_seconds); + } elseif (!isset($record_path) && urldecode($xml->variables->last_app) == "record_session") { $record_path = dirname(urldecode($xml->variables->last_arg)); $record_name = basename(urldecode($xml->variables->last_arg)); $record_length = urldecode($xml->variables->record_seconds); } - elseif (isset($xml->variables->record_name)) { - if (isset($xml->variables->record_path)) { - $record_path = urldecode($xml->variables->record_path); - } - else { - $record_path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day; - } - $record_name = urldecode($xml->variables->record_name); - $record_length = urldecode($xml->variables->duration); - } elseif (!empty($xml->variables->sofia_record_file)) { $record_path = dirname(urldecode($xml->variables->sofia_record_file)); $record_name = basename(urldecode($xml->variables->sofia_record_file)); $record_length = urldecode($xml->variables->record_seconds); } - elseif (!empty($xml->variables->cc_record_filename)) { - $record_path = dirname(urldecode($xml->variables->cc_record_filename)); - $record_name = basename(urldecode($xml->variables->cc_record_filename)); - $record_length = urldecode($xml->variables->record_seconds); - } elseif (!empty($xml->variables->api_on_answer)) { $command = str_replace("\n", " ", urldecode($xml->variables->api_on_answer)); $parts = explode(" ", $command); @@ -751,19 +741,8 @@ if (!class_exists('xml_cdr')) { } } } - if (empty($record_name)) { - $bridge_uuid = urldecode($xml->variables->bridge_uuid) ?: $last_bridge; - $path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day; - if (file_exists($path.'/'.$bridge_uuid.'.wav')) { - $record_path = $path; - $record_name = $bridge_uuid.'.wav'; - $record_length = urldecode($xml->variables->duration); - } elseif (file_exists($path.'/'.$bridge_uuid.'.mp3')) { - $record_path = $path; - $record_name = $bridge_uuid.'.mp3'; - $record_length = urldecode($xml->variables->duration); - } - } + + //check to see if file exists with the default file name and path if (empty($record_name)) { $path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day; if (file_exists($path.'/'.$uuid.'.wav')) { @@ -777,9 +756,9 @@ if (!class_exists('xml_cdr')) { } } - //last check + //last check - check to see if file exists with the bridge_uuid for the file name and path if (empty($record_name)) { - $bridge_uuid = urldecode($xml->variables->bridge_uuid) ?: $last_bridge ; + $bridge_uuid = urldecode($xml->variables->bridge_uuid) ?: $last_bridge; $path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day; if (file_exists($path.'/'.$bridge_uuid.'.wav')) { $record_path = $path; @@ -789,14 +768,6 @@ if (!class_exists('xml_cdr')) { $record_path = $path; $record_name = $bridge_uuid.'.mp3'; $record_length = urldecode($xml->variables->duration); - } elseif (file_exists($path.'/'.$bridge_uuid.'.wav')) { - $record_path = $path; - $record_name = $bridge_uuid.'.wav'; - $record_length = urldecode($xml->variables->duration); - } elseif (file_exists($path.'/'.$bridge_uuid.'.mp3')) { - $record_path = $path; - $record_name = $bridge_uuid.'.mp3'; - $record_length = urldecode($xml->variables->duration); } }