Update v_xml_cdr_import.php

This commit is contained in:
FusionPBX 2019-10-07 14:55:20 -06:00 committed by GitHub
parent 3a3abc1c03
commit 37126500ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 16 deletions

View File

@ -42,7 +42,7 @@
//set debug
$debug = false; //true //false
if ($debug){
if ($debug) {
$time5 = microtime(true);
$insert_time=$insert_count=0;
}
@ -71,11 +71,11 @@
//define accept_b_leg function
function accept_b_leg($xml){
// if no filter set allow all for backward compatibility
if(empty($_SESSION['cdr']['b_leg'])){
if(empty($_SESSION['cdr']['b_leg'])) {
return true;
}
// filter out by call direction
if(in_array(@$xml->variables->call_direction, $_SESSION['cdr']['b_leg'])){
if(in_array(@$xml->variables->call_direction, $_SESSION['cdr']['b_leg'])) {
return true;
}
// Disable cdr write
@ -265,7 +265,6 @@
$sql .= "where domain_name = :domain_name ";
$parameters['domain_name'] = $domain_name;
}
$database = new database;
$domain_uuid = $database->select($sql, $parameters, 'column');
unset($parameters);
}
@ -312,24 +311,20 @@
$database->fields['xml'] = $xml_string;
}
//insert the $extension_uuid
//get the extension_uuid and then add it to the database fields array
if (strlen($xml->variables->extension_uuid) > 0) {
$database->fields['extension_uuid'] = urldecode($xml->variables->extension_uuid);
}
else {
$dialed_user = $xml->variables->dialed_user;
if (strlen($dialed_user) > 0 && is_numeric($dialed_user)) {
if (strlen($xml->variables->dialed_user) > 0) {
$sql = "select extension_uuid from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and (extension = :dialed_user or number_alias = :dialed_user) ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['dialed_user'] = $dialed_user;
$database = new database;
$parameters['dialed_user'] = $xml->variables->dialed_user;
$extension_uuid = $database->select($sql, $parameters, 'column');
$database->fields['extension_uuid'] = $extension_uuid;
unset($parameters);
if (is_uuid($extension_uuid)) {
$database->fields['extension_uuid'] = $extension_uuid;
}
}
}
@ -393,7 +388,8 @@
$record_path = $path;
$record_name = $bridge_uuid.'.wav';
$record_length = urldecode($xml->variables->duration);
} elseif (file_exists($path.'/'.$bridge_uuid.'.mp3')) {
}
elseif (file_exists($path.'/'.$bridge_uuid.'.mp3')) {
$record_path = $path;
$record_name = $bridge_uuid.'.mp3';
$record_length = urldecode($xml->variables->duration);
@ -405,7 +401,8 @@
$record_path = $path;
$record_name = $uuid.'.wav';
$record_length = urldecode($xml->variables->duration);
} elseif (file_exists($path.'/'.$uuid.'.mp3')) {
}
elseif (file_exists($path.'/'.$uuid.'.mp3')) {
$record_path = $path;
$record_name = $uuid.'.mp3';
$record_length = urldecode($xml->variables->duration);
@ -475,7 +472,7 @@
}
catch(PDOException $e) {
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/';
if(!file_exists($tmp_dir)) {
if (!file_exists($tmp_dir)) {
event_socket_mkdir($tmp_dir);
}
if ($_SESSION['cdr']['format']['text'] == "xml") {
@ -498,7 +495,7 @@
if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") {
if (strlen($uuid) > 0) {
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
if(!file_exists($tmp_dir)) {
if (!file_exists($tmp_dir)) {
event_socket_mkdir($tmp_dir);
}
if ($_SESSION['cdr']['format']['text'] == "xml") {