Update xml_cdr.php

In the xml_cdr class change method xml_array from $row to $key. Key is more descriptive and should prevent bugs in the future.
This commit is contained in:
FusionPBX
2016-06-11 16:17:35 -06:00
committed by GitHub
parent 6bd0fc573a
commit e9ce02147a

View File

@@ -199,7 +199,7 @@ if (!class_exists('xml_cdr')) {
/**
* process method converts the xml cdr and adds it to the database
*/
public function xml_array($row, $leg, $xml_string) {
public function xml_array($key, $leg, $xml_string) {
//fix the xml by escaping the contents of <sip_full_XXX>
if(defined('STDIN')) {
@@ -255,70 +255,70 @@ if (!class_exists('xml_cdr')) {
//misc
$uuid = check_str(urldecode($xml->variables->uuid));
$this->array[$row]['uuid'] = $uuid;
$this->array[$row]['destination_number'] = check_str($destination_number);
$this->array[$row]['source_number'] = check_str(urldecode($xml->variables->effective_caller_id_number));
$this->array[$row]['user_context'] = check_str(urldecode($xml->variables->user_context));
$this->array[$row]['network_addr'] = check_str(urldecode($xml->variables->sip_network_ip));
$this->array[$row]['caller_id_name'] = check_str($caller_id_name);
$this->array[$row]['caller_id_number'] = check_str($caller_id_number);
$this->array[$key]['uuid'] = $uuid;
$this->array[$key]['destination_number'] = check_str($destination_number);
$this->array[$key]['source_number'] = check_str(urldecode($xml->variables->effective_caller_id_number));
$this->array[$key]['user_context'] = check_str(urldecode($xml->variables->user_context));
$this->array[$key]['network_addr'] = check_str(urldecode($xml->variables->sip_network_ip));
$this->array[$key]['caller_id_name'] = check_str($caller_id_name);
$this->array[$key]['caller_id_number'] = check_str($caller_id_number);
$this->array[$row]['accountcode'] = check_str(urldecode($xml->variables->accountcode));
$this->array[$row]['default_language'] = check_str(urldecode($xml->variables->default_language));
$this->array[$row]['bridge_uuid'] = check_str(urldecode($xml->variables->bridge_uuid));
//$this->array[$row]['digits_dialed'] = check_str(urldecode($xml->variables->digits_dialed));
$this->array[$row]['sip_hangup_disposition'] = check_str(urldecode($xml->variables->sip_hangup_disposition));
$this->array[$row]['pin_number'] = check_str(urldecode($xml->variables->pin_number));
$this->array[$key]['accountcode'] = check_str(urldecode($xml->variables->accountcode));
$this->array[$key]['default_language'] = check_str(urldecode($xml->variables->default_language));
$this->array[$key]['bridge_uuid'] = check_str(urldecode($xml->variables->bridge_uuid));
//$this->array[$key]['digits_dialed'] = check_str(urldecode($xml->variables->digits_dialed));
$this->array[$key]['sip_hangup_disposition'] = check_str(urldecode($xml->variables->sip_hangup_disposition));
$this->array[$key]['pin_number'] = check_str(urldecode($xml->variables->pin_number));
//time
$this->array[$row]['start_epoch'] = check_str(urldecode($xml->variables->start_epoch));
$this->array[$key]['start_epoch'] = check_str(urldecode($xml->variables->start_epoch));
$start_stamp = check_str(urldecode($xml->variables->start_stamp));
$this->array[$row]['start_stamp'] = $start_stamp;
$this->array[$row]['answer_stamp'] = check_str(urldecode($xml->variables->answer_stamp));
$this->array[$row]['answer_epoch'] = check_str(urldecode($xml->variables->answer_epoch));
$this->array[$row]['end_epoch'] = check_str(urldecode($xml->variables->end_epoch));
$this->array[$row]['end_stamp'] = check_str(urldecode($xml->variables->end_stamp));
$this->array[$row]['duration'] = check_str(urldecode($xml->variables->duration));
$this->array[$row]['mduration'] = check_str(urldecode($xml->variables->mduration));
$this->array[$row]['billsec'] = check_str(urldecode($xml->variables->billsec));
$this->array[$row]['billmsec'] = check_str(urldecode($xml->variables->billmsec));
$this->array[$key]['start_stamp'] = $start_stamp;
$this->array[$key]['answer_stamp'] = check_str(urldecode($xml->variables->answer_stamp));
$this->array[$key]['answer_epoch'] = check_str(urldecode($xml->variables->answer_epoch));
$this->array[$key]['end_epoch'] = check_str(urldecode($xml->variables->end_epoch));
$this->array[$key]['end_stamp'] = check_str(urldecode($xml->variables->end_stamp));
$this->array[$key]['duration'] = check_str(urldecode($xml->variables->duration));
$this->array[$key]['mduration'] = check_str(urldecode($xml->variables->mduration));
$this->array[$key]['billsec'] = check_str(urldecode($xml->variables->billsec));
$this->array[$key]['billmsec'] = check_str(urldecode($xml->variables->billmsec));
//codecs
$this->array[$row]['read_codec'] = check_str(urldecode($xml->variables->read_codec));
$this->array[$row]['read_rate'] = check_str(urldecode($xml->variables->read_rate));
$this->array[$row]['write_codec'] = check_str(urldecode($xml->variables->write_codec));
$this->array[$row]['write_rate'] = check_str(urldecode($xml->variables->write_rate));
$this->array[$row]['remote_media_ip'] = check_str(urldecode($xml->variables->remote_media_ip));
$this->array[$row]['hangup_cause'] = check_str(urldecode($xml->variables->hangup_cause));
$this->array[$row]['hangup_cause_q850'] = check_str(urldecode($xml->variables->hangup_cause_q850));
$this->array[$key]['read_codec'] = check_str(urldecode($xml->variables->read_codec));
$this->array[$key]['read_rate'] = check_str(urldecode($xml->variables->read_rate));
$this->array[$key]['write_codec'] = check_str(urldecode($xml->variables->write_codec));
$this->array[$key]['write_rate'] = check_str(urldecode($xml->variables->write_rate));
$this->array[$key]['remote_media_ip'] = check_str(urldecode($xml->variables->remote_media_ip));
$this->array[$key]['hangup_cause'] = check_str(urldecode($xml->variables->hangup_cause));
$this->array[$key]['hangup_cause_q850'] = check_str(urldecode($xml->variables->hangup_cause_q850));
//call center
$this->array[$row]['cc_side'] = check_str(urldecode($xml->variables->cc_side));
$this->array[$row]['cc_member_uuid'] = check_str(urldecode($xml->variables->cc_member_uuid));
$this->array[$row]['cc_queue_joined_epoch'] = check_str(urldecode($xml->variables->cc_queue_joined_epoch));
$this->array[$row]['cc_queue'] = check_str(urldecode($xml->variables->cc_queue));
$this->array[$row]['cc_member_session_uuid'] = check_str(urldecode($xml->variables->cc_member_session_uuid));
$this->array[$row]['cc_agent'] = check_str(urldecode($xml->variables->cc_agent));
$this->array[$row]['cc_agent_type'] = check_str(urldecode($xml->variables->cc_agent_type));
$this->array[$row]['waitsec'] = check_str(urldecode($xml->variables->waitsec));
$this->array[$key]['cc_side'] = check_str(urldecode($xml->variables->cc_side));
$this->array[$key]['cc_member_uuid'] = check_str(urldecode($xml->variables->cc_member_uuid));
$this->array[$key]['cc_queue_joined_epoch'] = check_str(urldecode($xml->variables->cc_queue_joined_epoch));
$this->array[$key]['cc_queue'] = check_str(urldecode($xml->variables->cc_queue));
$this->array[$key]['cc_member_session_uuid'] = check_str(urldecode($xml->variables->cc_member_session_uuid));
$this->array[$key]['cc_agent'] = check_str(urldecode($xml->variables->cc_agent));
$this->array[$key]['cc_agent_type'] = check_str(urldecode($xml->variables->cc_agent_type));
$this->array[$key]['waitsec'] = check_str(urldecode($xml->variables->waitsec));
//app info
$this->array[$row]['last_app'] = check_str(urldecode($xml->variables->last_app));
$this->array[$row]['last_arg'] = check_str(urldecode($xml->variables->last_arg));
$this->array[$key]['last_app'] = check_str(urldecode($xml->variables->last_app));
$this->array[$key]['last_arg'] = check_str(urldecode($xml->variables->last_arg));
//conference
$this->array[$row]['conference_name'] = check_str(urldecode($xml->variables->conference_name));
$this->array[$row]['conference_uuid'] = check_str(urldecode($xml->variables->conference_uuid));
$this->array[$row]['conference_member_id'] = check_str(urldecode($xml->variables->conference_member_id));
$this->array[$key]['conference_name'] = check_str(urldecode($xml->variables->conference_name));
$this->array[$key]['conference_uuid'] = check_str(urldecode($xml->variables->conference_uuid));
$this->array[$key]['conference_member_id'] = check_str(urldecode($xml->variables->conference_member_id));
//call quality
$rtp_audio_in_mos = check_str(urldecode($xml->variables->rtp_audio_in_mos));
if (strlen($rtp_audio_in_mos) > 0) {
$this->array[$row]['rtp_audio_in_mos'] = $rtp_audio_in_mos;
$this->array[$key]['rtp_audio_in_mos'] = $rtp_audio_in_mos;
}
//store the call leg
$this->array[$row]['leg'] = $leg;
$this->array[$key]['leg'] = $leg;
//store the call direction
$this->array[$row]['direction'] = check_str(urldecode($xml->variables->call_direction));
$this->array[$key]['direction'] = check_str(urldecode($xml->variables->call_direction));
//store post dial delay, in milliseconds
$this->array[$row]['pdd_ms'] = check_str(urldecode($xml->variables->progress_mediamsec) + urldecode($xml->variables->progressmsec));
$this->array[$key]['pdd_ms'] = check_str(urldecode($xml->variables->progress_mediamsec) + urldecode($xml->variables->progressmsec));
//get break down the date to year, month and day
$tmp_time = strtotime($start_stamp);
@@ -353,10 +353,10 @@ if (!class_exists('xml_cdr')) {
//set values in the database
if (strlen($domain_uuid) > 0) {
$this->array[$row]['domain_uuid'] = $domain_uuid;
$this->array[$key]['domain_uuid'] = $domain_uuid;
}
if (strlen($domain_name) > 0) {
$this->array[$row]['domain_name'] = $domain_name;
$this->array[$key]['domain_name'] = $domain_name;
}
//check whether a recording exists
@@ -368,22 +368,22 @@ if (!class_exists('xml_cdr')) {
$recording_file = $recording_relative_path.'/'.$uuid.'.mp3';
}
if(isset($recording_file) && !empty($recording_file)) {
$this->array[$row]['recording_file'] = $recording_file;
$this->array[$key]['recording_file'] = $recording_file;
}
//save to the database in xml format
if ($_SESSION['cdr']['format']['text'] == "xml" && $_SESSION['cdr']['storage']['text'] == "db") {
$this->array[$row]['xml'] = check_str($xml_string);
$this->array[$key]['xml'] = check_str($xml_string);
}
//save to the database in json format
if ($_SESSION['cdr']['format']['text'] == "json" && $_SESSION['cdr']['storage']['text'] == "db") {
$this->array[$row]['json'] = check_str(json_encode($xml));
$this->array[$key]['json'] = check_str(json_encode($xml));
}
//insert the check_str($extension_uuid)
if (strlen($xml->variables->extension_uuid) > 0) {
$this->array[$row]['extension_uuid'] = check_str(urldecode($xml->variables->extension_uuid));
$this->array[$key]['extension_uuid'] = check_str(urldecode($xml->variables->extension_uuid));
}
//insert the values