Update xml_cdr.php
This commit is contained in:
parent
3ef183169d
commit
3f2615431c
|
|
@ -193,13 +193,13 @@ if (!class_exists('xml_cdr')) {
|
||||||
$f = 1;
|
$f = 1;
|
||||||
if (isset($this->fields)) {
|
if (isset($this->fields)) {
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
$field = preg_replace('#[^a-zA-Z0-9_\-]#', '', $field);
|
//$field = preg_replace('#[^a-zA-Z0-9_\-]#', '', $field);
|
||||||
if (isset($row[$field]) && strlen($row[$field]) > 0) {
|
if (isset($row[$field]) && strlen($row[$field]) > 0) {
|
||||||
$sql .= ":".$field." \n";
|
$sql .= ":".$field." \n";
|
||||||
$parameters[$field] = $row[$field];
|
$parameters[$field] = $row[$field];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql .= "null";
|
$sql .= "null\n";
|
||||||
}
|
}
|
||||||
if ($field_count != $f) {
|
if ($field_count != $f) {
|
||||||
$sql .= ",";
|
$sql .= ",";
|
||||||
|
|
@ -256,29 +256,21 @@ if (!class_exists('xml_cdr')) {
|
||||||
$duplicate_uuid = false;
|
$duplicate_uuid = false;
|
||||||
$uuid = urldecode($xml->variables->uuid);
|
$uuid = urldecode($xml->variables->uuid);
|
||||||
if($uuid != null && is_uuid($uuid)) {
|
if($uuid != null && is_uuid($uuid)) {
|
||||||
//Check in the database
|
$sql = "select count(xml_cdr_uuid) ";
|
||||||
$sql = "select count(xml_cdr_uuid) ";
|
$sql .= "from v_xml_cdr ";
|
||||||
$sql .= "from v_xml_cdr ";
|
$sql .= "where xml_cdr_uuid = :xml_cdr_uuid ";
|
||||||
$sql .= "where xml_cdr_uuid = :xml_cdr_uuid ";
|
$parameters['xml_cdr_uuid'] = $uuid;
|
||||||
$parameters['xml_cdr_uuid'] = $uuid;
|
$database = new database;
|
||||||
$database = new database;
|
$count = $database->select($sql, $parameters, 'column');
|
||||||
$count = $database->select($sql, $parameters, 'column');
|
if ($count > 0) {
|
||||||
unset($parameters);
|
$duplicate_uuid = true;
|
||||||
if ($count > 0) {
|
}
|
||||||
$duplicate_uuid = true;
|
unset($sql, $parameters);
|
||||||
}
|
|
||||||
unset($database);
|
|
||||||
//Check in the array
|
|
||||||
if (isset($this->array)) {
|
|
||||||
foreach ($this->array as $row) {
|
|
||||||
if (in_array($uuid,$row,true))
|
|
||||||
$duplicate_uuid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//process data if the call detail record is not a duplicate
|
//process data if the call detail record is not a duplicate
|
||||||
if ($duplicate_uuid == false && $uuid != null) {
|
if ($duplicate_uuid == false && is_uuid($uuid)) {
|
||||||
|
|
||||||
//get the destination number
|
//get the destination number
|
||||||
if ($xml->variables->current_application == "bridge") {
|
if ($xml->variables->current_application == "bridge") {
|
||||||
$current_application_data = urldecode($xml->variables->current_application_data);
|
$current_application_data = urldecode($xml->variables->current_application_data);
|
||||||
|
|
@ -541,7 +533,7 @@ if (!class_exists('xml_cdr')) {
|
||||||
$record_length = urldecode($xml->variables->duration);
|
$record_length = urldecode($xml->variables->duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last check
|
// Last check
|
||||||
if (!isset($record_name) || is_null ($record_name) || (strlen($record_name) == 0)) {
|
if (!isset($record_name) || is_null ($record_name) || (strlen($record_name) == 0)) {
|
||||||
$bridge_uuid = urldecode($xml->variables->bridge_uuid);
|
$bridge_uuid = urldecode($xml->variables->bridge_uuid);
|
||||||
|
|
@ -564,7 +556,7 @@ if (!class_exists('xml_cdr')) {
|
||||||
$record_length = urldecode($xml->variables->duration);
|
$record_length = urldecode($xml->variables->duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//add the call recording
|
//add the call recording
|
||||||
if (isset($record_path) && isset($record_name) && file_exists($record_path.'/'.$record_name) && $record_length > 0) {
|
if (isset($record_path) && isset($record_name) && file_exists($record_path.'/'.$record_name) && $record_length > 0) {
|
||||||
//add to the xml cdr table
|
//add to the xml cdr table
|
||||||
|
|
@ -619,17 +611,43 @@ if (!class_exists('xml_cdr')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//insert the values
|
//insert the values
|
||||||
if (strlen($uuid) > 0) {
|
if ($this->debug) {
|
||||||
|
//$time5_insert = microtime(true);
|
||||||
|
//echo $sql."<br />\n";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$error = "false";
|
||||||
|
//$this->db->exec($sql);
|
||||||
|
}
|
||||||
|
catch(PDOException $e) {
|
||||||
|
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/';
|
||||||
|
if(!file_exists($tmp_dir)) {
|
||||||
|
event_socket_mkdir($tmp_dir);
|
||||||
|
}
|
||||||
|
if ($_SESSION['cdr']['format']['text'] == "xml") {
|
||||||
|
$tmp_file = $uuid.'.xml';
|
||||||
|
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
|
||||||
|
fwrite($fh, $xml_string);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$tmp_file = $uuid.'.json';
|
||||||
|
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
|
||||||
|
fwrite($fh, json_encode($xml));
|
||||||
|
}
|
||||||
|
fclose($fh);
|
||||||
if ($this->debug) {
|
if ($this->debug) {
|
||||||
//$time5_insert = microtime(true);
|
echo $e->getMessage();
|
||||||
//echo $sql."<br />\n";
|
|
||||||
}
|
}
|
||||||
try {
|
$error = "true";
|
||||||
$error = "false";
|
}
|
||||||
//$this->db->exec(check_sql($sql));
|
|
||||||
}
|
if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") {
|
||||||
catch(PDOException $e) {
|
if (strlen($uuid) > 0) {
|
||||||
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/';
|
$tmp_time = strtotime($start_stamp);
|
||||||
|
$tmp_year = date("Y", $tmp_time);
|
||||||
|
$tmp_month = date("M", $tmp_time);
|
||||||
|
$tmp_day = date("d", $tmp_time);
|
||||||
|
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
|
||||||
if(!file_exists($tmp_dir)) {
|
if(!file_exists($tmp_dir)) {
|
||||||
event_socket_mkdir($tmp_dir);
|
event_socket_mkdir($tmp_dir);
|
||||||
}
|
}
|
||||||
|
|
@ -644,44 +662,16 @@ if (!class_exists('xml_cdr')) {
|
||||||
fwrite($fh, json_encode($xml));
|
fwrite($fh, json_encode($xml));
|
||||||
}
|
}
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
if ($this->debug) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
$error = "true";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") {
|
|
||||||
if (strlen($uuid) > 0) {
|
|
||||||
$tmp_time = strtotime($start_stamp);
|
|
||||||
$tmp_year = date("Y", $tmp_time);
|
|
||||||
$tmp_month = date("M", $tmp_time);
|
|
||||||
$tmp_day = date("d", $tmp_time);
|
|
||||||
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
|
|
||||||
if(!file_exists($tmp_dir)) {
|
|
||||||
event_socket_mkdir($tmp_dir);
|
|
||||||
}
|
|
||||||
if ($_SESSION['cdr']['format']['text'] == "xml") {
|
|
||||||
$tmp_file = $uuid.'.xml';
|
|
||||||
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
|
|
||||||
fwrite($fh, $xml_string);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$tmp_file = $uuid.'.json';
|
|
||||||
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
|
|
||||||
fwrite($fh, json_encode($xml));
|
|
||||||
}
|
|
||||||
fclose($fh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($error);
|
|
||||||
|
|
||||||
//if ($this->debug) {
|
|
||||||
//GLOBAL $insert_time,$insert_count;
|
|
||||||
//$insert_time+=microtime(true)-$time5_insert; //add this current query.
|
|
||||||
//$insert_count++;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
unset($sql);
|
unset($error);
|
||||||
|
|
||||||
|
//if ($this->debug) {
|
||||||
|
//GLOBAL $insert_time,$insert_count;
|
||||||
|
//$insert_time+=microtime(true)-$time5_insert; //add this current query.
|
||||||
|
//$insert_count++;
|
||||||
|
//}
|
||||||
|
|
||||||
} //if ($duplicate_uuid == false)
|
} //if ($duplicate_uuid == false)
|
||||||
} //function xml_array
|
} //function xml_array
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue