Add a new xml_cdr_import.php and add limit and filter options to the xml_cdr.php class.
This commit is contained in:
parent
716762a58b
commit
0db8ddb949
|
|
@ -444,17 +444,49 @@ if (!class_exists('xml_cdr')) {
|
|||
$file_prefix = substr($file, 0, 1);
|
||||
}
|
||||
|
||||
//get the xml cdr string
|
||||
$xml_string = file_get_contents($xml_cdr_dir.'/'.$file);
|
||||
//set the limit
|
||||
if (isset($_SERVER["argv"][1]) && is_numeric($_SERVER["argv"][1])) {
|
||||
$limit = $_SERVER["argv"][1];
|
||||
}
|
||||
else {
|
||||
$limit = 1;
|
||||
}
|
||||
|
||||
//parse the xml and insert the data into the db
|
||||
$this->xml_array($x, $leg, $xml_string);
|
||||
//filter for specific files based on the file prefix
|
||||
if (isset($_SERVER["argv"][2])) {
|
||||
if (strpos($_SERVER["argv"][2], $file_prefix) !== FALSE) {
|
||||
$import = true;
|
||||
}
|
||||
else {
|
||||
$import = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$import = true;
|
||||
}
|
||||
|
||||
//delete the file after it has been imported
|
||||
unlink($xml_cdr_dir.'/'.$file);
|
||||
//import the call detail record
|
||||
if ($import) {
|
||||
//get the xml cdr string
|
||||
$xml_string = file_get_contents($xml_cdr_dir.'/'.$file);
|
||||
|
||||
//increment
|
||||
$x++;
|
||||
//parse the xml and insert the data into the db
|
||||
$this->xml_array($x, $leg, $xml_string);
|
||||
|
||||
//delete the file after it has been imported
|
||||
unlink($xml_cdr_dir.'/'.$file);
|
||||
}
|
||||
|
||||
//increment the value
|
||||
if ($import) {
|
||||
$x++;
|
||||
}
|
||||
|
||||
//if limit exceeded exit the loop
|
||||
if ($limit == $x) {
|
||||
//echo "limit: $limit count: $x if\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2016
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
//check the permission
|
||||
if(defined('STDIN')) {
|
||||
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
|
||||
preg_match("/^(.*)\/app\/.*$/", $document_root, $matches);
|
||||
$document_root = $matches[1];
|
||||
set_include_path($document_root);
|
||||
$_SERVER["DOCUMENT_ROOT"] = $document_root;
|
||||
require_once "resources/require.php";
|
||||
$display_type = 'text'; //html, text
|
||||
}
|
||||
else {
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/pdo.php";
|
||||
}
|
||||
|
||||
//increase limits
|
||||
set_time_limit(3600);
|
||||
ini_set('memory_limit', '256M');
|
||||
ini_set("precision", 6);
|
||||
|
||||
//import from the file system
|
||||
$cdr = new xml_cdr;
|
||||
$cdr->read_files();
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue