Add a missing file sip_profile_copy.php to the dev branch.

This commit is contained in:
Mark Crane
2012-06-04 14:58:40 +00:00
commit af103e9c41
1240 changed files with 164946 additions and 0 deletions
+275
View File
@@ -0,0 +1,275 @@
<?php
//application details
$apps[$x]['name'] = "XML CDR";
$apps[$x]['uuid'] = '4a085c51-7635-ff03-f67b-86e834422848';
$apps[$x]['category'] = 'Switch';;
$apps[$x]['subcategory'] = '';
$apps[$x]['version'] = '';
$apps[$x]['license'] = 'Mozilla Public License 1.1';
$apps[$x]['url'] = 'http://www.fusionpbx.com';
$apps[$x]['description']['en'] = 'Call Detail Records with all information about the call.';
//menu details
$apps[$x]['menu'][0]['title']['en'] = 'Apps';
$apps[$x]['menu'][0]['uuid'] = 'fd29e39c-c936-f5fc-8e2b-611681b266b5';
$apps[$x]['menu'][0]['parent_uuid'] = '';
$apps[$x]['menu'][0]['category'] = 'internal';
$apps[$x]['menu'][0]['path'] = '/app/xml_cdr/xml_cdr.php';
$apps[$x]['menu'][0]['order'] = '20';
$apps[$x]['menu'][0]['groups'][] = 'user';
$apps[$x]['menu'][0]['groups'][] = 'admin';
$apps[$x]['menu'][0]['groups'][] = 'superadmin';
$apps[$x]['menu'][1]['title']['en'] = 'Call Detail Records';
$apps[$x]['menu'][1]['uuid'] = '8f80e71a-31a5-6432-47a0-7f5a7b271f05';
$apps[$x]['menu'][1]['parent_uuid'] = 'fd29e39c-c936-f5fc-8e2b-611681b266b5';
$apps[$x]['menu'][1]['category'] = 'internal';
$apps[$x]['menu'][1]['path'] = '/app/xml_cdr/xml_cdr.php';
$apps[$x]['menu'][1]['groups'][] = 'user';
$apps[$x]['menu'][1]['groups'][] = 'admin';
$apps[$x]['menu'][1]['groups'][] = 'superadmin';
//permission details
$apps[$x]['permissions'][0]['name'] = 'xml_cdr_view';
$apps[$x]['permissions'][0]['groups'][] = 'user';
$apps[$x]['permissions'][0]['groups'][] = 'admin';
$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
//schema details
$y = 0; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = 'v_xml_cdr';
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'id';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'xml_cdr_id';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'accountcode';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'direction';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'default_language';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'context';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'xml_cdr';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'caller_id_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'caller_id_number';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_number';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'start_epoch';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'bigint';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'start_stamp';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'answer_stamp';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'answer_epoch';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'bigint';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'end_epoch';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'bigint';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'end_stamp';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'duration';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'mduration';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'billsec';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'billmsec';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'bridge_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'read_codec';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'read_rate';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'write_codec';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'write_rate';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'remote_media_ip';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'network_addr';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'recording_file';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Indicates if a recording was made. If a recording exists set this value to true.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'leg';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'char(1)';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(1)';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'The leg of the call a or b.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'pdd_ms';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'smallint';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Post Dial Delay (PDD) in miliseconds. Divide by 1000 for seconds.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'last_app';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Save the last application in the leg.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'last_arg';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Save the last application data.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'cc_side';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Queue side is either member or agent';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'cc_member_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Unique member identifier';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'cc_queue_joined_epoch';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Epoch when caller joined the queue';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'cc_queue';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Queue';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'cc_member_session_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Unique session identifier';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'cc_agent';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'agent name';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'cc_agent_type';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'agent type';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'waitsec';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'wait seconds';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'conference_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'conference name';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'conference_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'conference unique identifier';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'conference_member_id';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'conference member id';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'digits_dialed';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'digits dialed';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hangup_cause';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hangup_cause_q850';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'sip_hangup_disposition';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Save who hung up or cancelled the leg.';
?>
+39
View File
@@ -0,0 +1,39 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//make sure that prefix-a-leg is set to true in the xml_cdr.conf.xml file
$file_contents = file_get_contents($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml");
$file_contents_new = str_replace("param name=\"prefix-a-leg\" value=\"false\"/", "param name=\"prefix-a-leg\" value=\"true\"/", $file_contents);
if ($file_contents != $file_contents_new) {
$fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml","w");
fwrite($fout, $file_contents_new);
fclose($fout);
if ($display_type == "text") {
echo " xml_cdr.conf.xml: updated\n";
}
}
?>
+50
View File
@@ -0,0 +1,50 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
// make sure the PATH_SEPARATOR is defined
if (!defined("PATH_SEPARATOR")) {
if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
}
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
// if the project directory exists then add it to the include path otherwise add the document root to the include path
if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
}
else {
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
}
?>
+359
View File
@@ -0,0 +1,359 @@
<?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) 2008-2012
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("/^(.*)\/mod\/.*$/", $document_root, $matches);
$document_root = $matches[1];
set_include_path($document_root);
$_SERVER["DOCUMENT_ROOT"] = $document_root;
require_once "includes/require.php";
$display_type = 'text'; //html, text
}
else {
include "root.php";
require_once "includes/require.php";
}
//set debug
$debug = false; //true //false
if($debug){
$time5 = microtime(true);
$insert_time=$insert_count=0;
}
//increase limits
set_time_limit(3600);
ini_set('memory_limit', '256M');
//set pdo attribute that enables exception handling
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
function process_xml_cdr($db, $leg, $xml_string) {
//set global variable
global $debug;
//parse the xml to get the call detail record info
try {
$xml = simplexml_load_string($xml_string);
}
catch(Exception $e) {
echo $e->getMessage();
}
//prepare the database object
require_once "includes/classes/database.php";
$database = new database;
$database->table = "v_xml_cdr";
//misc
$uuid = check_str(urldecode($xml->variables->uuid));
$database->fields['uuid'] = $uuid;
$database->fields['accountcode'] = check_str(urldecode($xml->variables->accountcode));
$database->fields['default_language'] = check_str(urldecode($xml->variables->default_language));
$database->fields['bridge_uuid'] = check_str(urldecode($xml->variables->bridge_uuid));
$database->fields['digits_dialed'] = check_str(urldecode($xml->variables->digits_dialed));
$database->fields['sip_hangup_disposition'] = check_str(urldecode($xml->variables->sip_hangup_disposition));
//time
$database->fields['start_epoch'] = check_str(urldecode($xml->variables->start_epoch));
$start_stamp = check_str(urldecode($xml->variables->start_stamp));
$database->fields['start_stamp'] = $start_stamp;
$database->fields['answer_stamp'] = check_str(urldecode($xml->variables->answer_stamp));
$database->fields['answer_epoch'] = check_str(urldecode($xml->variables->answer_epoch));
$database->fields['end_epoch'] = check_str(urldecode($xml->variables->end_epoch));
$database->fields['end_stamp'] = check_str(urldecode($xml->variables->end_stamp));
$database->fields['duration'] = check_str(urldecode($xml->variables->duration));
$database->fields['mduration'] = check_str(urldecode($xml->variables->mduration));
$database->fields['billsec'] = check_str(urldecode($xml->variables->billsec));
$database->fields['billmsec'] = check_str(urldecode($xml->variables->billmsec));
//codecs
$database->fields['read_codec'] = check_str(urldecode($xml->variables->read_codec));
$database->fields['read_rate'] = check_str(urldecode($xml->variables->read_rate));
$database->fields['write_codec'] = check_str(urldecode($xml->variables->write_codec));
$database->fields['write_rate'] = check_str(urldecode($xml->variables->write_rate));
$database->fields['remote_media_ip'] = check_str(urldecode($xml->variables->remote_media_ip));
$database->fields['hangup_cause'] = check_str(urldecode($xml->variables->hangup_cause));
$database->fields['hangup_cause_q850'] = check_str(urldecode($xml->variables->hangup_cause_q850));
//call center
$database->fields['cc_side'] = check_str(urldecode($xml->variables->cc_side));
$database->fields['cc_member_uuid'] = check_str(urldecode($xml->variables->cc_member_uuid));
$database->fields['cc_queue_joined_epoch'] = check_str(urldecode($xml->variables->cc_queue_joined_epoch));
$database->fields['cc_queue'] = check_str(urldecode($xml->variables->cc_queue));
$database->fields['cc_member_session_uuid'] = check_str(urldecode($xml->variables->cc_member_session_uuid));
$database->fields['cc_agent'] = check_str(urldecode($xml->variables->cc_agent));
$database->fields['cc_agent_type'] = check_str(urldecode($xml->variables->cc_agent_type));
$database->fields['waitsec'] = check_str(urldecode($xml->variables->waitsec));
//app info
$database->fields['last_app'] = check_str(urldecode($xml->variables->last_app));
$database->fields['last_arg'] = check_str(urldecode($xml->variables->last_arg));
//conference
$database->fields['conference_name'] = check_str(urldecode($xml->variables->conference_name));
$database->fields['conference_uuid'] = check_str(urldecode($xml->variables->conference_uuid));
$database->fields['conference_member_id'] = check_str(urldecode($xml->variables->conference_member_id));
//get the values from the callflow.
$x = 0;
foreach ($xml->callflow as $row) {
if ($x == 0) {
$context = check_str(urldecode($row->caller_profile->context));
$database->fields['destination_number'] = check_str(urldecode($row->caller_profile->destination_number));
$database->fields['context'] = $context;
$database->fields['network_addr'] = check_str(urldecode($row->caller_profile->network_addr));
}
$database->fields['caller_id_name'] = check_str(urldecode($row->caller_profile->caller_id_name));
$database->fields['caller_id_number'] = check_str(urldecode($row->caller_profile->caller_id_number));
$x++;
}
unset($x);
//store the call leg
$database->fields['leg'] = $leg;
//store the call direction.
$database->fields['direction'] = check_str(urldecode($xml->variables->call_direction));
//store post dial delay, in milliseconds.
$database->fields['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);
$tmp_year = date("Y", $tmp_time);
$tmp_month = date("M", $tmp_time);
$tmp_day = date("d", $tmp_time);
//find the domain_uuid by using the domain_name
$domain_name = check_str(urldecode($xml->variables->domain_name));
$sql = "select domain_uuid from v_domains ";
if (strlen($domain_name) == 0 && $context != 'public' && $context != 'default') {
$sql .= "where domain_name = '".$context."' ";
}
else {
$sql .= "where domain_name = '".$domain_name."' ";
}
$row = $db->query($sql)->fetch();
$domain_uuid = $row['domain_uuid'];
if (strlen($domain_uuid) == 0) {
$sql = "select domain_name, domain_uuid from v_domains ";
$row = $db->query($sql)->fetch();
$domain_uuid = $row['domain_uuid'];
if (strlen($domain_name) == 0) { $domain_name = $row['domain_name']; }
}
$database->domain_uuid = $domain_uuid;
$database->fields['domain_uuid'] = $domain_uuid;
$database->fields['domain_name'] = $domain_name;
//check whether a recording exists
$recording_relative_path = '/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
if (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.wav')) {
$recording_file = $recording_relative_path.'/'.$uuid.'.wav';
}
elseif (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.mp3')) {
$recording_file = $recording_relative_path.'/'.$uuid.'.mp3';
}
if(isset($recording_file) && !empty($recording_file)) {
$database->fields['recording_file'] = $recording_file;
}
//determine where the xml cdr will be archived
$sql = "select * from v_vars ";
$sql .= "where var_name = 'xml_cdr_archive' ";
$row = $db->query($sql)->fetch();
$var_value = trim($row["var_value"]);
switch ($var_value) {
case "dir":
$xml_cdr_archive = 'dir';
break;
case "db":
$xml_cdr_archive = 'db';
break;
case "none":
$xml_cdr_archive = 'none';
break;
default:
$xml_cdr_archive = 'dir';
break;
}
//if xml_cdr_archive is set to db then insert it.
if ($xml_cdr_archive == "db") {
$database->fields['xml_cdr'] = check_str($xml_string);
}
//insert xml_cdr into the db
$database->add();
if ($debug) {
echo $database->sql."\n";
}
//insert the values
if (strlen($uuid) > 0) {
if ($debug) {
$time5_insert = microtime(true);
//echo $sql."<br />\n";
}
try {
$error = "false";
//$db->exec(check_sql($sql));
}
catch(PDOException $e) {
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/';
if(!file_exists($tmp_dir)) {
mkdir($tmp_dir, 0777, true);
}
$tmp_file = $uuid.'.xml';
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
fwrite($fh, $xml_string);
fclose($fh);
if ($debug) {
echo $e->getMessage();
}
$error = "true";
}
//if xml_cdr_archive is set to dir, then store it.
if ($xml_cdr_archive == "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)) {
mkdir($tmp_dir, 0777, true);
}
$tmp_file = $uuid.'.xml';
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
fwrite($fh, $xml_string);
fclose($fh);
}
}
unset($error);
if ($debug) {
GLOBAL $insert_time,$insert_count;
$insert_time+=microtime(true)-$time5_insert;//add this current query.
$insert_count++;
}
}
unset($sql);
}
//get cdr details from the http post
if (strlen($_POST["cdr"]) > 0) {
//authentication for xml cdr http post
if (strlen($_SESSION["xml_cdr_username"]) == 0) {
//get the contents of xml_cdr.conf.xml
$conf_xml_string = file_get_contents($_SESSION['switch']['conf']['dir'].'/autoload_configs/xml_cdr.conf.xml');
//parse the xml to get the call detail record info
try {
$conf_xml = simplexml_load_string($conf_xml_string);
}
catch(Exception $e) {
echo $e->getMessage();
}
foreach ($conf_xml->settings->param as $row) {
if ($row->attributes()->name == "cred") {
$auth_array = explode(":", $row->attributes()->value);
$_SESSION["xml_cdr_username"] = $auth_array[0];
$_SESSION["xml_cdr_password"] = $auth_array[1];
//echo "username: ".$_SESSION["xml_cdr_username"]."<br />\n";
//echo "password: ".$_SESSION["xml_cdr_password"]."<br />\n";
}
}
}
//check for the correct username and password
if ($_SESSION["xml_cdr_username"] == $_SERVER["PHP_AUTH_USER"] && $_SESSION["xml_cdr_password"] == $_SERVER["PHP_AUTH_PW"]) {
//echo "access granted<br />\n";
}
else {
echo "access denied<br />\n";
return;
}
//loop through all attribues
//foreach($xml->settings->param[1]->attributes() as $a => $b) {
// echo $a,'="',$b,"\"<br />\n";
//}
//get the http post variable
$xml_string = trim($_POST["cdr"]);
//get the leg of the call
if (substr($_REQUEST['uuid'], 0, 2) == "a_") {
$leg = "a";
}
else {
$leg = "b";
}
//parse the xml and insert the data into the db
process_xml_cdr($db, $leg, $xml_string);
}
//check the filesystem for xml cdr records that were missed
$xml_cdr_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr';
$dir_handle = opendir($xml_cdr_dir);
$x = 0;
while($file=readdir($dir_handle)) {
if ($file != '.' && $file != '..') {
if ( !is_dir($xml_cdr_dir . '/' . $file) ) {
//get the leg of the call
if (substr($file, 0, 2) == "a_") {
$leg = "a";
}
else {
$leg = "b";
}
//get the xml cdr string
$xml_string = file_get_contents($xml_cdr_dir.'/'.$file);
//parse the xml and insert the data into the db
process_xml_cdr($db, $leg, $xml_string);
//delete the file after it has been imported
unlink($xml_cdr_dir.'/'.$file);
$x++;
}
}
}
closedir($dir_handle);
//debug true
if ($debug) {
$content = ob_get_contents(); //get the output from the buffer
ob_end_clean(); //clean the buffer
$time = "\n\n$insert_count inserts in: ".number_format($insert_time,5). " seconds.\n";
$time .= "Other processing time: ".number_format((microtime(true)-$time5-$insert_time),5). " seconds.\n";
$fp = fopen(sys_get_temp_dir().'/xml_cdr_post.log', 'w');
fwrite($fp, $content.$time);
fclose($fp);
}
?>
+427
View File
@@ -0,0 +1,427 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//import xml_cdr files
require_once "v_xml_cdr_import.php";
//additional includes
require_once "includes/header.php";
require_once "includes/paging.php";
//xml cdr include
require_once "xml_cdr_inc.php";
//page title and description
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left' width='50%' nowrap='nowrap'><b>Call Detail Records</b></td>\n";
echo "<td align='right' width='100%'>\n";
echo "<table>\n";
echo "<tr>\n";
echo "<td>\n";
echo " <input type='button' class='btn' value='Statistics' onclick=\"document.location.href='xml_cdr_statistics.php';\">\n";
echo "</td>\n";
echo "<form method='post' action='xml_cdr_csv.php'>";
echo "<td>\n";
echo " <input type='hidden' name='direction' value='$direction'>\n";
echo " <input type='hidden' name='caller_id_name' value='$caller_id_name'>\n";
echo " <input type='hidden' name='start_stamp' value='$start_stamp'>\n";
echo " <input type='hidden' name='hangup_cause' value='$hangup_cause'>\n";
echo " <input type='hidden' name='caller_id_number' value='$caller_id_number'>\n";
echo " <input type='hidden' name='destination_number' value='$destination_number'>\n";
echo " <input type='hidden' name='answer_stamp' value='$answer_stamp'>\n";
echo " <input type='hidden' name='end_stamp' value='$end_stamp'>\n";
echo " <input type='hidden' name='duration' value='$duration'>\n";
echo " <input type='hidden' name='billsec' value='$billsec'>\n";
echo " <input type='hidden' name='uuid' value='$uuid'>\n";
echo " <input type='hidden' name='bleg_uuid' value='$bleg_uuid'>\n";
echo " <input type='hidden' name='accountcode' value='$accountcode'>\n";
echo " <input type='hidden' name='read_codec' value='$read_codec'>\n";
echo " <input type='hidden' name='write_codec' value='$write_codec'>\n";
echo " <input type='hidden' name='remote_media_ip' value='$remote_media_ip'>\n";
echo " <input type='hidden' name='network_addr' value='$network_addr'>\n";
echo " <input type='submit' class='btn' name='submit' value=' csv '>\n";
echo "</td>\n";
echo " </form>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo "Call Detail Records (CDRs) are detailed information on the calls. \n";
echo "The information contains source, destination, duration, and other useful call details. \n";
echo "Use the fields to filter the information for the specific call records that are desired. \n";
echo "Then view the calls in the list or download them as comma seperated file by using the 'csv' button. \n";
//To do an advanced search of the call detail records click on the following advanced button.
echo "<br />\n";
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
//search the call detail records
if (if_group("admin") || if_group("superadmin")) {
echo "<form method='post' action=''>\n";
echo "<table width='95%' cellpadding='3' border='0'>\n";
echo "<tr>\n";
echo "<td width='33.3%'>\n";
echo "<table width='100%' border='0'>\n";
echo " <tr>\n";
echo " <td align='left' width='25%'>Direction:</td>\n";
echo " <td align='left' width='75%'>\n";
echo " <select name='direction' style='width:100%' class='formfld'>\n";
echo " <option value=''> </option>\n";
if ($direction == "inbound") {
echo " <option value='inbound' selected='selected'>inbound</option>\n";
}
else {
echo " <option value='inbound'>inbound</option>\n";
}
if ($direction == "outbound") {
echo " <option value='outbound' selected='selected'>outbound</option>\n";
}
else {
echo " <option value='outbound'>outbound</option>\n";
}
if ($direction == "local") {
echo " <option value='local' selected='selected'>local</option>\n";
}
else {
echo " <option value='local'>local</option>\n";
}
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align=\"left\">CID Name:</td>\n";
echo " <td align=\"left\"><input type='text' class='formfld' name='caller_id_name' style='width:100%' value='$caller_id_name'></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "<td width='33.3%'>\n";
echo "<table width='100%'>\n";
echo " <tr>\n";
echo " <td align='left' width='25%'>Source:</td>\n";
echo " <td align='left' width='75%'><input type='text' class='formfld' name='caller_id_number' style='width:100%' value='$caller_id_number'></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' width='25%'>Destination:</td>\n";
echo " <td align='left' width='75%'><input type='text' class='formfld' name='destination_number' style='width:100%' value='$destination_number'></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "<td width='33.3%'>\n";
echo "<table width='100%'>\n";
//echo " <tr>";
//echo " <td>Context:</td>";
//echo " <td><input type='text' class='formfld' name='context' style='width:100%' value='$context'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>Answer:</td>";
//echo " <td><input type='text' class='formfld' name='answer_stamp' style='width:100%' value='$answer_stamp'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>End:</td>";
//echo " <td><input type='text' class='formfld' name='end_stamp' style='width:100%' value='$end_stamp'></td>";
//echo " </tr>";
echo " <tr>\n";
echo " <td align='left' width='25%'>Start:</td>\n";
echo " <td align='left' width='75%'><input type='text' class='formfld' name='start_stamp' style='width:100%' value='$start_stamp'></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' width='25%'>Status:</td>\n";
echo " <td align='left' width='75%'>\n";
echo " <select name=\"hangup_cause\" style='width:100%' class='formfld'>\n";
echo " <option value='".$hangup_cause."' selected='selected'>".$hangup_cause."</option>\n";
if (strlen($hangup_cause) > 0) {
echo " <option value=''></option>\n";
}
echo " <option value='NORMAL_CLEARING'>NORMAL_CLEARING</option>\n";
echo " <option value='ORIGINATOR_CANCEL'>ORIGINATOR_CANCEL</option>\n";
echo " <option value='BLIND_TRANSFER'>BLIND_TRANSFER</option>\n";
echo " <option value='LOSE_RACE'>LOSE_RACE</option>\n";
echo " <option value='NO_ANSWER'>NO_ANSWER</option>\n";
echo " <option value='NORMAL_UNSPECIFIED'>NORMAL_UNSPECIFIED</option>\n";
echo " <option value='NO_USER_RESPONSE'>NO_USER_RESPONSE</option>\n";
echo " <option value='NO_ROUTE_DESTINATION'>NO_ROUTE_DESTINATION</option>\n";
echo " <option value='SUBSCRIBER_ABSENT'>SUBSCRIBER_ABSENT</option>\n";
echo " <option value='NORMAL_TEMPORARY_FAILURE'>NORMAL_TEMPORARY_FAILURE</option>\n";
echo " <option value='ATTENDED_TRANSFER'>ATTENDED_TRANSFER</option>\n";
echo " <option value='PICKED_OFF'>PICKED_OFF</option>\n";
echo " <option value='USER_BUSY'>USER_BUSY</option>\n";
echo " <option value='CALL_REJECTED'>CALL_REJECTED</option>\n";
echo " <option value='INVALID_NUMBER_FORMAT'>INVALID_NUMBER_FORMAT</option>\n";
echo " <option value='NETWORK_OUT_OF_ORDER'>NETWORK_OUT_OF_ORDER</option>\n";
echo " <option value='DESTINATION_OUT_OF_ORDER'>DESTINATION_OUT_OF_ORDER</option>\n";
echo " <option value='RECOVERY_ON_TIMER_EXPIRE'>RECOVERY_ON_TIMER_EXPIRE</option>\n";
echo " <option value='MANAGER_REQUEST'>MANAGER_REQUEST</option>\n";
echo " <option value='MEDIA_TIMEOUT'>MEDIA_TIMEOUT</option>\n";
echo " <option value='UNALLOCATED_NUMBER'>UNALLOCATED_NUMBER</option>\n";
echo " <option value='NONE'>NONE</option>\n";
echo " <option value='EXCHANGE_ROUTING_ERROR'>EXCHANGE_ROUTING_ERROR</option>\n";
echo " <option value='ALLOTTED_TIMEOUT'>ALLOTTED_TIMEOUT</option>\n";
echo " <option value='CHAN_NOT_IMPLEMENTED'>CHAN_NOT_IMPLEMENTED</option>\n";
echo " <option value='INCOMPATIBLE_DESTINATION'>INCOMPATIBLE_DESTINATION</option>\n";
echo " <option value='USER_NOT_REGISTERED'>USER_NOT_REGISTERED</option>\n";
echo " <option value='SYSTEM_SHUTDOWN'>SYSTEM_SHUTDOWN</option>\n";
echo " <option value='MANDATORY_IE_MISSING'>MANDATORY_IE_MISSING</option>\n";
/*
$sql = "";
$sql .= "select distinct(hangup_cause) from v_xml_cdr ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as &$row) {
if ($row["hangup_cause"] == $hangup_cause) {
echo " <option value='".$row["hangup_cause"]."' selected='selected'>".$row["hangup_cause"]."</option>\n";
}
else {
echo " <option value='".$row["hangup_cause"]."'>".$row["hangup_cause"]."</option>\n";
}
}
unset ($prep_statement);
*/
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
//echo " <tr>";
//echo " <td align='left' width='25%'>Duration:</td>";
//echo " <td align='left' width='75%'><input type='text' class='txt' name='duration' value='$duration'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td align='left' width='25%'>Bill:</td>";
//echo " <td align='left' width='75%'><input type='text' class='txt' name='billsec' value='$billsec'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>UUID:</td>";
//echo " <td><input type='text' class='txt' name='uuid' value='$uuid'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>Bridge UUID:</td>";
//echo " <td><input type='text' class='txt' name='bridge_uuid' value='$bridge_uuid'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>Account Code:</td>";
//echo " <td><input type='text' class='txt' name='accountcode' value='$accountcode'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>Read Codec:</td>";
//echo " <td><input type='text' class='txt' name='read_codec' value='$read_codec'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>Write Codec:</td>";
//echo " <td><input type='text' class='txt' name='write_codec' value='$write_codec'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>Remote Media IP:</td>";
//echo " <td><input type='text' class='txt' name='remote_media_ip' value='$remote_media_ip'></td>";
//echo " </tr>";
//echo " <tr>";
//echo " <td>Network Address:</td>";
//echo " <td><input type='text' class='txt' name='network_addr' value='$network_addr'></td>";
//echo " </tr>";
//echo " <tr>";
echo " </tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<tr>\n";
echo "<td colspan='2' align='right'>\n";
//echo " <input type='button' class='btn' name='' alt='view' onclick=\"window.location='v_cdr_search.php'\" value='advanced'>\n";
echo "</td>\n";
echo "<td colspan='1' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='view' onclick=\"window.location='xml_cdr_search.php'\" value='advanced'>&nbsp;\n";
echo " <input type='submit' class='btn' name='submit' value='filter'>\n";
echo "</td>\n";
echo "</tr>";
echo "</table>";
echo "</form>";
}
//show the results
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
//echo th_order_by('direction', 'Direction', $order_by, $order);
//echo th_order_by('default_language', 'Language', $order_by, $order);
//echo th_order_by('context', 'Context', $order_by, $order);
//echo th_order_by('leg', 'Leg', $order_by, $order);
echo th_order_by('caller_id_name', 'Name', $order_by, $order);
echo th_order_by('caller_id_number', 'Number', $order_by, $order);
echo th_order_by('destination_number', 'Destination', $order_by, $order);
echo th_order_by('start_stamp', 'Start', $order_by, $order);
//echo th_order_by('end_stamp', 'End', $order_by, $order);
echo th_order_by('duration', 'Length', $order_by, $order);
if (if_group("admin") || if_group("superadmin")) {
echo th_order_by('pdd_ms', 'PDD', $order_by, $order);
}
echo th_order_by('hangup_cause', 'Status', $order_by, $order);
echo "</tr>\n";
if ($result_count > 0) {
foreach($result as $row) {
$tmp_year = date("Y", strtotime($row['start_stamp']));
$tmp_month = date("M", strtotime($row['start_stamp']));
$tmp_day = date("d", strtotime($row['start_stamp']));
if (defined('TIME_24HR') && TIME_24HR == 1) {
$tmp_start_epoch = date("j M Y H:i:s", $row['start_epoch']);
} else {
$tmp_start_epoch = date("j M Y h:i:sa", $row['start_epoch']);
}
$hangup_cause = $row['hangup_cause'];
$hangup_cause = str_replace("_", " ", $hangup_cause);
$hangup_cause = strtolower($hangup_cause);
$hangup_cause = ucwords($hangup_cause);
echo "<tr >\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['direction']."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['default_language']."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['context']."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['leg']."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
$tmp_dir = $_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
$tmp_name = '';
if(!empty($row['recording_file']) && file_exists($row['recording_file'])){
$tmp_name=$row['recording_file'];
}
elseif (file_exists($tmp_dir.'/'.$row['uuid'].'.wav')) {
$tmp_name = $row['uuid'].".wav";
}
elseif (file_exists($tmp_dir.'/'.$row['uuid'].'_1.wav')) {
$tmp_name = $row['uuid']."_1.wav";
}
elseif (file_exists($tmp_dir.'/'.$row['uuid'].'.mp3')) {
$tmp_name = $row['uuid'].".mp3";
}
elseif (file_exists($tmp_dir.'/'.$row['uuid'].'_1.mp3')) {
$tmp_name = $row['uuid']."_1.mp3";
}
if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
echo " <a href=\"javascript:void(0);\" onclick=\"window.open('../recordings/v_recordings_play.php?a=download&type=moh&filename=".base64_encode('archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)."', 'play',' width=420,height=150,menubar=no,status=no,toolbar=no')\">\n";
echo $row['caller_id_name'].' ';
echo " </a>";
}
else {
echo $row['caller_id_name'].' ';
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
echo " <a href=\"../recordings/v_recordings.php?a=download&type=rec&t=bin&filename=".base64_encode("archive/".$tmp_year."/".$tmp_month."/".$tmp_day."/".$tmp_name)."\">\n";
if (is_numeric($row['caller_id_number'])) {
echo format_phone($row['caller_id_number']).' ';
}
else {
echo $row['caller_id_number'].' ';
}
echo " </a>";
}
else {
if (is_numeric($row['caller_id_number'])) {
echo format_phone($row['caller_id_number']).' ';
}
else {
echo $row['caller_id_number'].' ';
}
}
echo " </td>\n";
if (is_numeric($row['destination_number'])) {
echo " <td valign='top' class='".$row_style[$c]."'>".format_phone($row['destination_number'])."</td>\n";
}
else {
echo " <td valign='top' class='".$row_style[$c]."'>".$row['destination_number']."</td>\n";
}
echo " <td valign='top' class='".$row_style[$c]."'>".$tmp_start_epoch."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['end_stamp']."</td>\n";
//If they cancelled, show the ring time, not the bill time.
$seconds = ($row['hangup_cause']=="ORIGINATOR_CANCEL") ? $row['duration'] : $row['billsec'];
echo " <td valign='top' class='".$row_style[$c]."'>".gmdate("G:i:s", $seconds)."</td>\n";
if (if_group("admin") || if_group("superadmin")) {
echo " <td valign='top' class='".$row_style[$c]."'>".number_format($row['pdd_ms']/1000,2)."s</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='xml_cdr_details.php?uuid=".$row['uuid']."'>".$hangup_cause."</a></td>\n";
}
else {
echo " <td valign='top' class='".$row_style[$c]."'>".$hangup_cause."</td>\n";
}
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
} //end if results
echo "<tr>\n";
echo "<td colspan='11' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>";
echo "<br><br>";
echo "<br><br>";
//show the footer
require_once "includes/footer.php";
?>
+82
View File
@@ -0,0 +1,82 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//additional includes
require_once "xml_cdr_inc.php";
//set the http headers
header('Content-type: application/octet-binary');
header('Content-Disposition: attachment; filename=cdr.csv');
//set the csv headers
$z = 0;
foreach($result[0] as $key => $val) {
if ($key != "xml_cdr") {
if ($z == 0) {
echo '"'.$key.'"';
}
else {
echo ',"'.$key.'"';
}
}
$z++;
}
echo "\n";
//show the csv data
$x=0;
while(true) {
$z = 0;
foreach($result[0] as $key => $val) {
if ($key != "xml_cdr") {
if ($z == 0) {
echo '"'.$result[$x][$key].'"';
}
else {
echo ',"'.$result[$x][$key].'"';
}
}
$z++;
}
echo "\n";
++$x;
if ($x > ($result_count-1)) {
break;
}
//$row++;
}
?>
+508
View File
@@ -0,0 +1,508 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the http values and set them to a variable
if (strlen($_REQUEST["uuid"]) > 0) {
$uuid = trim($_REQUEST["uuid"]);
}
//get the xml cdr string from the database
$sql = "select * from v_xml_cdr ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and uuid = '$uuid' ";
$row = $db->query($sql)->fetch();
$start_stamp = trim($row["start_stamp"]);
$xml_string = trim($row["xml_cdr"]);
//print_r($row);
//get cdr from the file system
if (strlen($xml_string) == 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;
$tmp_file = $uuid.'.xml';
$xml_string = file_get_contents($tmp_dir.'/'.$tmp_file);
}
//parse the xml to get the call detail record info
try {
$xml = simplexml_load_string($xml_string);
}
catch(Exception $e) {
echo $e->getMessage();
}
//get the header
require_once "includes/header.php";
//page title and description
echo "<br>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' align='left' valign='top' nowrap='nowrap'><b>Call Details</b></td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='xml_cdr.php'\" value='Back'>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo "A detailed view of the call and all information regarding it. \n";
echo "The information contains caller id name and number, channel data, \n";
echo "call variables, call flow, timing information, and other useful call details. \n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<br />\n";
//detail summary
//get the variables from the xml
$uuid = check_str(urldecode($xml->variables->uuid));
$direction = check_str(urldecode($xml->channel_data->direction));
$language = check_str(urldecode($xml->variables->language));
$xml_string = check_str($xml_string);
$start_epoch = check_str(urldecode($xml->variables->start_epoch));
$start_stamp = check_str(urldecode($xml->variables->start_stamp));
$start_uepoch = check_str(urldecode($xml->variables->start_uepoch));
$answer_stamp = check_str(urldecode($xml->variables->answer_stamp));
$answer_epoch = check_str(urldecode($xml->variables->answer_epoch));
$answer_uepoch = check_str(urldecode($xml->variables->answer_uepoch));
$end_epoch = check_str(urldecode($xml->variables->end_epoch));
$end_uepoch = check_str(urldecode($xml->variables->end_uepoch));
$end_stamp = check_str(urldecode($xml->variables->end_stamp));
$duration = check_str(urldecode($xml->variables->duration));
$mduration = check_str(urldecode($xml->variables->mduration));
$billsec = check_str(urldecode($xml->variables->billsec));
$billmsec = check_str(urldecode($xml->variables->billmsec));
$bridge_uuid = check_str(urldecode($xml->variables->bridge_uuid));
$read_codec = check_str(urldecode($xml->variables->read_codec));
$write_codec = check_str(urldecode($xml->variables->write_codec));
$remote_media_ip = check_str(urldecode($xml->variables->remote_media_ip));
$hangup_cause = check_str(urldecode($xml->variables->hangup_cause));
$hangup_cause_q850 = check_str(urldecode($xml->variables->hangup_cause_q850));
$x = 0;
foreach ($xml->callflow as $row) {
if ($x == 0) {
$destination_number = check_str(urldecode($row->caller_profile->destination_number));
$context = check_str(urldecode($row->caller_profile->context));
$network_addr = check_str(urldecode($row->caller_profile->network_addr));
}
$caller_id_name = check_str(urldecode($row->caller_profile->caller_id_name));
$caller_id_number = check_str(urldecode($row->caller_profile->caller_id_number));
$x++;
}
unset($x);
$tmp_year = date("Y", strtotime($start_stamp));
$tmp_month = date("M", strtotime($start_stamp));
$tmp_day = date("d", strtotime($start_stamp));
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left'><b>Summary</b>&nbsp;</td>\n";
echo "<td></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>Direction</th>\n";
//echo "<th>Language</th>\n";
//echo "<th>Context</th>\n";
echo "<th>Name (play)</th>\n";
echo "<th>Number (download)</th>\n";
echo "<th>Destination</th>\n";
echo "<th>Start</th>\n";
echo "<th>End</th>\n";
echo "<th>Length</th>\n";
echo "<th>Status</th>\n";
echo "</tr>\n";
echo "<tr >\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='xml_cdr_details.php?uuid=".$uuid."'>".$direction."</a></td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$language."</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$context."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) {
//echo " <a href=\"../recordings/v_recordings.php?a=download&type=rec&t=bin&filename=".base64_encode('archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')."\">\n";
//echo " </a>";
echo " <a href=\"javascript:void(0);\" onclick=\"window.open('../recordings/v_recordings_play.php?a=download&type=moh&filename=".base64_encode('archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
//$tmp_file_array = explode("\.",$file);
echo $caller_id_name.' ';
echo " </a>";
}
else {
echo $caller_id_name.' ';
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) {
echo " <a href=\"../recordings/v_recordings.php?a=download&type=rec&t=bin&filename=".base64_encode('archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')."\">\n";
echo $caller_id_number.' ';
echo " </a>";
}
else {
echo $caller_id_number.' ';
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$destination_number."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$start_stamp."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$end_stamp."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$duration."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$hangup_cause."</td>\n";
echo "</table>";
echo "</div>";
//breaking space
echo "<br /><br />\n";
//channel data loop
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left'><b>Channel Data</b>&nbsp;</td>\n";
echo "<td></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>Name</th>\n";
echo "<th>Value</th>\n";
echo "</tr>\n";
foreach($xml->channel_data->children() as $child) {
$key = $child->getName();
$value = urldecode($child);
echo "<tr >\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$key."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($value,75,"<br />\n", TRUE)."&nbsp;</td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo "</table>";
echo "</div>";
//breaking space
echo "<br /><br />\n";
//variable loop
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td align='left'><b>Variables</b>&nbsp;</td>\n";
echo "<td></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>Name</th>\n";
echo "<th>Value</th>\n";
echo "</tr>\n";
foreach($xml->variables->children() as $child) {
$key = $child->getName();
$value = urldecode($child);
echo "<tr >\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$key."</td>\n";
if ($key == "bridge_uuid" || $key == "signal_bond") {
echo " <td valign='top' align='left' class='".$row_style[$c]."'>\n";
echo " <a href='xml_cdr_details.php?uuid=$value'>".$value."</a>&nbsp;\n";
$tmp_dir = $_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
$tmp_name = '';
if (file_exists($tmp_dir.'/'.$value.'.wav')) {
$tmp_name = $value.".wav";
}
elseif (file_exists($tmp_dir.'/'.$value.'_1.wav')) {
$tmp_name = $value."_1.wav";
}
elseif (file_exists($tmp_dir.'/'.$value.'.mp3')) {
$tmp_name = $value.".mp3";
}
elseif (file_exists($tmp_dir.'/'.$value.'_1.mp3')) {
$tmp_name = $value."_1.mp3";
}
if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
echo " <a href=\"javascript:void(0);\" onclick=\"window.open('../recordings/v_recordings_play.php?a=download&type=moh&filename=".base64_encode('archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)."', 'play',' width=420,height=150,menubar=no,status=no,toolbar=no')\">\n";
echo " play";
echo " </a>&nbsp;";
}
if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
echo " <a href=\"../recordings/v_recordings.php?a=download&type=rec&t=bin&filename=".base64_encode("archive/".$tmp_year."/".$tmp_month."/".$tmp_day."/".$tmp_name)."\">\n";
echo " download";
echo " </a>";
}
echo "</td>\n";
}
else {
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($value,75,"<br />\n", TRUE)."&nbsp;</td>\n";
}
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo "</table>";
echo "</div>";
//breaking space
echo "<br /><br />\n";
//app_log
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left'><b>Application Log</b>&nbsp;</td>\n";
echo "<td></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>Name</th>\n";
echo "<th>Data</th>\n";
echo "</tr>\n";
foreach ($xml->app_log->application as $row) {
$app_name = $row->attributes()->app_name;
$app_data = $row->attributes()->app_data;
echo "<tr >\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$app_name."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($app_data,75,"<br />\n", TRUE)."&nbsp;</td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo "</table>";
echo "</div>";
//breaking space
echo "<br /><br />\n";
//callflow
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
foreach ($xml->callflow as $row) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td align='left'>\n";
//attributes
echo " <table width='95%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td><b>Call Flow: Attributes</b>&nbsp;</td>\n";
echo " <td></td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <th>Name</th>\n";
echo " <th>Value</th>\n";
echo " </tr>\n";
foreach($row->attributes() as $key => $value) {
echo " <tr>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$key."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($value,75,"<br />\n", TRUE)."&nbsp;</td>\n";
echo " </tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo " <tr>\n";
echo " <td colspan='2'><br /><br /></td>\n";
echo " </tr>\n";
echo "</table>\n";
//extension->attributes
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td><b>Call Flow: Extension: Attributes</b>&nbsp;</td>\n";
echo " <td></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <th>Name</th>\n";
echo " <th>Value</th>\n";
echo " </tr>\n";
foreach($row->extension->attributes() as $key => $value) {
echo " <tr >\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$key."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($value,75,"<br />\n", TRUE)."&nbsp;</td>\n";
echo " </tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo " <tr>\n";
echo " <td colspan='2'><br /><br /></td>\n";
echo " </tr>\n";
echo "</table>\n";
//extension->application
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td><b>Call Flow: Extension: Application</b>&nbsp;</td>\n";
echo " <td></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <th>Name</th>\n";
echo " <th>Data</th>\n";
echo " </tr>\n";
foreach ($row->extension->application as $tmp_row) {
$app_name = $tmp_row->attributes()->app_name;
$app_data = $tmp_row->attributes()->app_data;
echo " <tr >\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$app_name."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($app_data,75,"<br />\n", TRUE)."&nbsp;</td>\n";
echo " </tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo " <tr>\n";
echo " <td colspan='2'><br /><br /></td>\n";
echo " </tr>\n";
echo "</table>\n";
//caller_profile
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td><b>Call Flow: Caller Profile</b>&nbsp;</td>\n";
echo " <td></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <th>Name</th>\n";
echo " <th>Value</th>\n";
echo " </tr>\n";
foreach($row->caller_profile->children() as $child) {
$key = $child->getName();
echo " <tr >\n";
if ($key != "originatee") {
$value = urldecode($child);
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$key."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($value,75,"<br />\n", TRUE)."&nbsp;</td>\n";
}
else {
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$key."</td>\n";
echo " <td>\n";
echo " <table width='100%'>\n";
foreach($child->originatee_caller_profile->children() as $tmp_child) {
//print_r($tmp_child);
$key = $tmp_child->getName();
$value = urldecode($tmp_child);
echo " <tr >\n";
echo " <td valign='top' align='left' width='20%' class='".$row_style[$c]."'>".$key."&nbsp;</td>\n";
if ($key != "uuid") {
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($value,75,"<br />\n", TRUE)."&nbsp;</td>\n";
}
else {
echo " <td valign='top' align='left' class='".$row_style[$c]."'><a href='xml_cdr_details.php?uuid=$value'>".$value."</a>&nbsp;</td>\n";
}
echo " </tr>\n";
}
echo " </table>\n";
echo " </td>\n";
}
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo " <tr>\n";
echo " <td colspan='2'><br /><br /></td>\n";
echo " </tr>\n";
echo "</table>\n";
//times
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td><b>Call Flow: Times</b>&nbsp;</td>\n";
echo " <td></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <th>Name</th>\n";
echo " <th>Value</th>\n";
echo " </tr>\n";
foreach($row->times->children() as $child) {
$key = $child->getName();
$value = urldecode($child);
echo " <tr >\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$key."&nbsp;</td>\n";
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".wordwrap($value,75,"<br />\n", TRUE)."&nbsp;</td>\n";
echo " </tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
}
echo " <tr>\n";
echo " <td colspan='2'><br /><br /></td>\n";
echo " </tr>\n";
echo " </table>";
echo " <br /><br />\n";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
//testing
//echo "<pre>\n";
//echo htmlentities($xml_string);
//print_r($xml);
//echo "</pre>\n";
//get the footer
require_once "includes/footer.php";
?>
+159
View File
@@ -0,0 +1,159 @@
<?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) 2008-2012
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("/^(.*)\/mod\/.*$/", $document_root, $matches);
$document_root = $matches[1];
set_include_path($document_root);
require_once "includes/require.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
}
else {
echo "access denied";
exit;
}
//determine where the xml cdr will be archived
$sql = "select * from v_vars ";
$sql .= "where domain_uuid = '1' ";
$sql .= "and var_name = 'xml_cdr_archive' ";
$row = $db->query($sql)->fetch();
$var_value = trim($row["var_value"]);
switch ($var_value) {
case "dir":
$xml_cdr_archive = 'dir';
break;
case "db":
$xml_cdr_archive = 'db';
break;
case "none":
$xml_cdr_archive = 'none';
break;
default:
$xml_cdr_archive = 'dir';
break;
}
//get the list of installed apps from the core and mod directories
if ($xml_cdr_archive == "db") {
//get the xml cdr list
$sql = "";
$sql .= "select xml_cdr, uuid from v_xml_cdr ";
$sql .= "where waitsec is null ";
//$sql .= "limit 5000 ";
//start the transaction
$db->beginTransaction();
//loop through the results
$x = 0;
foreach ($db->query($sql,PDO::FETCH_ASSOC) as $row) {
//get the values from the db
$uuid = $row['uuid'];
$xml_string = $row['xml_cdr'];
//save each set of records and begin a new transaction
if ($x > 5000) {
//save the transaction
$db->commit();
//start the transaction
$db->beginTransaction();
//reset the count
$x = 0;
}
//parse the xml to get the call detail record info
try {
$xml = simplexml_load_string($xml_string);
}
catch(Exception $e) {
echo $e->getMessage();
}
//get the values from the xml and set at variables
$uuid = urldecode($xml->variables->uuid);
$waitsec = urldecode($xml->variables->waitsec);
//update the database
if (strlen($waitsec) > 0) {
$sql = "";
$sql .= "update v_xml_cdr ";
$sql .= "set waitsec = '$waitsec' ";
$sql .= "where uuid = '$uuid' ";
echo $sql."\n";
$db->exec($sql);
$x++;
}
}
//save the transaction
$db->commit();
//echo finished
echo "completed\n";
}
if ($xml_cdr_archive == "dir") {
$xml_cdr_list = glob($_SESSION['switch']['log']['dir']."/xml_cdr/archive/*/*/*/*.xml");
echo "count: ".count($xml_cdr_list)."\n";
//print_r($xml_cdr_list);
$x = 0;
//start the transaction
$db->beginTransaction();
//loop through the xml cdr records
foreach ($xml_cdr_list as $xml_cdr) {
//save each set of records and begin a new transaction
if ($x > 5000) {
//save the transaction
$db->commit();
//start the transaction
$db->beginTransaction();
//reset the count
$x = 0;
}
//get the xml cdr string
$xml_string = file_get_contents($xml_cdr);
//parse the xml to get the call detail record info
try {
$xml = simplexml_load_string($xml_string);
}
catch(Exception $e) {
echo $e->getMessage();
}
//get the values from the xml and set at variables
$uuid = urldecode($xml->variables->uuid);
$waitsec = urldecode($xml->variables->waitsec);
//update the database
//if ($num_rows == "0" && strlen($waitsec) > 0) {
if (strlen($waitsec) > 0) {
$sql = "";
$sql .= "update v_xml_cdr ";
$sql .= "set waitsec = '$waitsec' ";
$sql .= "where uuid = '$uuid' ";
echo $sql."\n";
$db->exec($sql);
$x++;
}
}
//save the transaction
$db->commit();
//echo finished
echo "completed\n";
}
+203
View File
@@ -0,0 +1,203 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//import xml_cdr files
require_once "v_xml_cdr_import.php";
//additional includes
require_once "includes/paging.php";
//set 24hr or 12hr clock
define('TIME_24HR', 1);
//get post or get variables from http
if (count($_REQUEST)>0) {
$order_by = $_REQUEST["order_by"];
$order = $_REQUEST["order"];
$cdr_id = $_REQUEST["cdr_id"];
$direction = $_REQUEST["direction"];
$caller_id_name = $_REQUEST["caller_id_name"];
$caller_id_number = $_REQUEST["caller_id_number"];
$destination_number = $_REQUEST["destination_number"];
$context = $_REQUEST["context"];
$start_stamp = $_REQUEST["start_stamp"];
$answer_stamp = $_REQUEST["answer_stamp"];
$end_stamp = $_REQUEST["end_stamp"];
$duration = $_REQUEST["duration"];
$billsec = $_REQUEST["billsec"];
$hangup_cause = $_REQUEST["hangup_cause"];
$uuid = $_REQUEST["uuid"];
$bleg_uuid = $_REQUEST["bleg_uuid"];
$accountcode = $_REQUEST["accountcode"];
$read_codec = $_REQUEST["read_codec"];
$write_codec = $_REQUEST["write_codec"];
$remote_media_ip = $_REQUEST["remote_media_ip"];
$network_addr = $_REQUEST["network_addr"];
}
//build the sql where string
if (strlen($cdr_id) > 0) { $sql_where .= "and cdr_id like '%$cdr_id%' "; }
if (strlen($direction) > 0) { $sql_where .= "and direction like '%$direction%' "; }
if (strlen($caller_id_name) > 0) { $sql_where .= "and caller_id_name like '%$caller_id_name%' "; }
if (strlen($caller_id_number) > 0 && strlen($destination_number) > 0) {
$sql_where .= "and (";
$sql_where .= "caller_id_number = '$caller_id_number' ";
$sql_where .= "or destination_number = '$destination_number'";
$sql_where .= ") ";
}
else {
if (strlen($caller_id_number) > 0) { $sql_where .= "and caller_id_number like '%$caller_id_number%' "; }
if (strlen($destination_number) > 0) { $sql_where .= "and destination_number like '%$destination_number%' "; }
}
if (strlen($context) > 0) { $sql_where .= "and context like '%$context%' "; }
if ($db_type == "sqlite") {
if (strlen($start_stamp) > 0) { $sql_where .= "and start_stamp like '%$start_stamp%' "; }
if (strlen($end_stamp) > 0) { $sql_where .= "and end_stamp like '%$end_stamp%' "; }
}
if ($db_type == "pgsql" || $db_type == "mysql") {
if (strlen($start_stamp) > 0 && strlen($end_stamp) == 0) { $sql_where .= "and start_stamp between '$start_stamp 00:00:00' and '$start_stamp 23:59:59' "; }
if (strlen($start_stamp) > 0 && strlen($end_stamp) > 0) { $sql_where .= "and start_stamp between '$start_stamp 00:00:00' and '$end_stamp 23:59:59' "; }
}
if (strlen($answer_stamp) > 0) { $sql_where .= "and answer_stamp like '%$answer_stamp%' "; }
if (strlen($duration) > 0) { $sql_where .= "and duration like '%$duration%' "; }
if (strlen($billsec) > 0) { $sql_where .= "and billsec like '%$billsec%' "; }
if (strlen($hangup_cause) > 0) { $sql_where .= "and hangup_cause like '%$hangup_cause%' "; }
if (strlen($uuid) > 0) { $sql_where .= "and uuid = '$uuid' "; }
if (strlen($bleg_uuid) > 0) { $sql_where .= "and bleg_uuid = '$bleg_uuid' "; }
if (strlen($accountcode) > 0) { $sql_where .= "and accountcode = '$accountcode' "; }
if (strlen($read_codec) > 0) { $sql_where .= "and read_codec like '%$read_codec%' "; }
if (strlen($write_codec) > 0) { $sql_where .= "and write_codec like '%$write_codec%' "; }
if (strlen($remote_media_ip) > 0) { $sql_where .= "and remote_media_ip like '%$remote_media_ip%' "; }
if (strlen($network_addr) > 0) { $sql_where .= "and network_addr like '%$network_addr%' "; }
//example sql
// select caller_id_number, destination_number from v_xml_cdr where domain_uuid = ''
// and (caller_id_number = '1001' or destination_number = '1001' or destination_number = '*991001')
if (!if_group("admin") && !if_group("superadmin")) {
$sql_where = "where domain_uuid = '$domain_uuid' ";
$sql_where .= "and ( ";
if (count($_SESSION['user']['extension']) > 0) {
$x = 0;
foreach($_SESSION['user']['extension'] as $row) {
if ($x==0) {
if ($row['user'] > 0) { $sql_where .= "caller_id_number = '".$row['user']."' \n"; } //source
}
else {
if ($row['user'] > 0) { $sql_where .= "or caller_id_number = '".$row['user']."' \n"; } //source
}
if ($row['user'] > 0) { $sql_where .= "or destination_number = '".$row['user']."' \n"; } //destination
if ($row['user'] > 0) { $sql_where .= "or destination_number = '*99".$row['user']."' \n"; } //destination
$x++;
}
}
else {
$sql_where .= "destination_number = 'no extension assigned' \n"; //destination
}
$sql_where .= ") ";
}
else {
//superadmin or admin
$sql_where = "where domain_uuid = '$domain_uuid' ".$sql_where;
}
//$sql_where = str_replace ("where or", "where", $sql_where);
//$sql_where = str_replace ("where and", " and", $sql_where);
//set the param variable which is used with paging
$param = "";
$param .= "&caller_id_name=$caller_id_name";
$param .= "&start_stamp=$start_stamp";
$param .= "&hangup_cause=$hangup_cause";
$param .= "&caller_id_number=$caller_id_number";
$param .= "&destination_number=$destination_number";
$param .= "&context=$context";
$param .= "&answer_stamp=$answer_stamp";
$param .= "&end_stamp=$end_stamp";
$param .= "&duration=$duration";
$param .= "&billsec=$billsec";
$param .= "&uuid=$uuid";
$param .= "&bridge_uuid=$bridge_uuid";
$param .= "&accountcode=$accountcode";
$param .= "&read_codec=$read_codec";
$param .= "&write_codec=$write_codec";
$param .= "&remote_media_ip=$remote_media_ip";
$param .= "&network_addr=$network_addr";
//create the sql query to get the xml cdr records
if (strlen($order_by) == 0) { $order_by = "start_epoch"; }
if (strlen($order) == 0) { $order = "desc"; }
//set the default
$num_rows = '0';
//get the number of rows in the v_xml_cdr
$sql = "select count(*) as num_rows from v_xml_cdr ";
$sql .= $sql_where;
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows'];
}
else {
$num_rows = '0';
}
}
unset($prep_statement, $result);
//prepare to page the results
$rows_per_page = 150;
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
//get the results from the db
$sql = "select * from v_xml_cdr ";
$sql .= $sql_where;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= " limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
$result_count = count($result);
unset ($prep_statement, $sql);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
?>
+157
View File
@@ -0,0 +1,157 @@
<?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>
Copyright (C) 2008-2012
All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
if (count($_POST)>0) {
$cdr_id = $_POST["cdr_id"];
$caller_id_name = $_POST["caller_id_name"];
$caller_id_number = $_POST["caller_id_number"];
$destination_number = $_POST["destination_number"];
$context = $_POST["context"];
$start_stamp = $_POST["start_stamp"];
$answer_stamp = $_POST["answer_stamp"];
$end_stamp = $_POST["end_stamp"];
$duration = $_POST["duration"];
$billsec = $_POST["billsec"];
$hangup_cause = $_POST["hangup_cause"];
$uuid = $_POST["uuid"];
$bleg_uuid = $_POST["bleg_uuid"];
$accountcode = $_POST["accountcode"];
$read_codec = $_POST["read_codec"];
$write_codec = $_POST["write_codec"];
$remote_media_ip = $_POST["remote_media_ip"];
$network_addr = $_POST["network_addr"];
}
else {
require_once "includes/header.php";
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
echo "<tr class='border'>\n";
echo " <td align=\"left\">\n";
echo " <br>";
echo "<form method='post' action='xml_cdr.php'>\n";
echo "<table width='100%' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' nowrap valign='top'><b>Advanced Search</b></td>\n";
echo "<td width='70%' align='right' valign='top'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='xml_cdr.php'\" value='Back'><br /><br /></td>\n";
echo "</tr>\n";
echo " <tr>";
echo " <td class='vncell'>Source Name:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='caller_id_name' value='$caller_id_name'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Source Number:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='caller_id_number' value='$caller_id_number'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Destination Number:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='destination_number' value='$destination_number'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Context:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='context' value='$context'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Start:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='start_stamp' value='$start_stamp'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Answer:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='answer_stamp' value='$answer_stamp'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>End:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='end_stamp' value='$end_stamp'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Duration:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='duration' value='$duration'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Bill Sec:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='billsec' value='$billsec'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Status:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='hangup_cause' value='$hangup_cause'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>UUID:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='uuid' value='$uuid'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Bridge UUID:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='bleg_uuid' value='$bridge_uuid'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Account Code:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='accountcode' value='$accountcode'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Read Codec:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='read_codec' value='$read_codec'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Write Codec:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='write_codec' value='$write_codec'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Remote Media IP:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='remote_media_ip' value='$remote_media_ip'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Network Address:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='network_addr' value='$network_addr'></td>";
echo " </tr>";
echo " <tr>";
echo " <td colspan='2' align='right'><input type='submit' name='submit' class='btn' value='Search'></td>";
echo " </tr>";
echo "</table>";
echo "</form>";
echo " </td>";
echo " </tr>";
echo "</table>";
echo "</div>";
require_once "includes/footer.php";
} //end if not post
?>
+219
View File
@@ -0,0 +1,219 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//additional includes
require_once "xml_cdr_statistics_inc.php";
require_once "includes/header.php";
//page title and description
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td width='30%' align='left' valign='top' nowrap='nowrap'><b>Call Detail Record Statistics</b></td>\n";
echo " <td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' value='CSV' onclick=\"document.location.href='xml_cdr_statistics_csv.php';\">\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='xml_cdr.php'\" value='Back'>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " Call Detail Records Statics summarize the call information. \n";
echo " <br />\n";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
//set the style
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
?>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="/includes/jquery/flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="/includes/jquery/jquery-1.7.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/includes/jquery/flot/jquery.flot.js"></script>
<table>
<tr>
<td align='left'>
<div id="placeholder" style="width:700px;height:180px;"></div>
</td>
<td align='left' valign='top'>
<p id="choices"></p>
</td>
</tr>
</table>
<script type="text/javascript">
$(function () {
var datasets = {
"volume": {
label: "Volume",
data: <?php echo json_encode($graph['volume']); ?>
},
"minutes": {
label: "Minutes",
data: <?php echo json_encode($graph['minutes']); ?>
},
"call_per_min": {
label: "Calls Per Min",
data: <?php echo json_encode($graph['call_per_min']); ?>
},
"missed": {
label: "Missed",
data: <?php echo json_encode($graph['missed']); ?>
},
"asr": {
label: "ASR",
data: <?php echo json_encode($graph['asr']); ?>
},
"aloc": {
label: "ALOC",
data: <?php echo json_encode($graph['aloc']); ?>
},
};
// hard-code color indices to prevent them from shifting as
// countries are turned on/off
var i = 0;
$.each(datasets, function(key, val) {
val.color = i;
++i;
});
// insert checkboxes
var choiceContainer = $("#choices");
$.each(datasets, function(key, val) {
choiceContainer.append('<br /><input type="checkbox" name="' + key +
'" checked="checked" id="id' + key + '">' +
'<label for="id' + key + '">'
+ val.label + '</label>');
});
choiceContainer.find("input").click(plotAccordingToChoices);
function plotAccordingToChoices() {
var data = [];
choiceContainer.find("input:checked").each(function () {
var key = $(this).attr("name");
if (key && datasets[key])
data.push(datasets[key]);
});
if (data.length > 0)
$.plot($("#placeholder"), data, {
yaxis: { min: 0 },
xaxis: { tickDecimals: 0 }
});
}
plotAccordingToChoices();
});
</script>
<?php
//show the results
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <th>Hours</th>\n";
echo " <th>Date</th>\n";
echo " <th nowrap='nowrap'>Time</th>\n";
echo " <th>Volume</th>\n";
echo " <th>Minutes</th>\n";
echo " <th>Calls Per Min</th>\n";
echo " <th>Missed</th>\n";
echo " <th>ASR</th>\n";
echo " <th>ALOC</th>\n";
echo "</tr>\n";
$i = 0;
foreach ($stats as $row) {
echo "<tr >\n";
if ($i < 24) {
echo " <td valign='top' class='".$row_style[$c]."'>".($i+1)."</td>\n";
}
elseif ($i == 24) {
echo " <br /><br />\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>\n";
echo " <br /><br />\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th nowrap='nowrap'>Days</th>\n";
echo " <th nowrap='nowrap'>Date</th>\n";
echo " <th nowrap='nowrap'>Time</th>\n";
echo " <th>Volume</th>\n";
echo " <th>Minutes</th>\n";
echo " <th nowrap='nowrap'>Calls Per Min</th>\n";
echo " <th>Missed</th>\n";
echo " <th>ASR</th>\n";
echo " <th>ALOC</th>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td valign='top' class='".$row_style[$c]."'>1</td>\n";
}
elseif ($i == 25) {
echo "<tr>\n";
echo " <td valign='top' class='".$row_style[$c]."'>7</td>\n";
}
elseif ($i == 26) {
echo " <td valign='top' class='".$row_style[$c]."'>30</td>\n";
}
if ($i < 24) {
echo " <td valign='top' class='".$row_style[$c]."'>".date('j M', $row['start_epoch'])."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".date('H:i', $row['start_epoch'])." - ".date('H:i', $row['stop_epoch'])."&nbsp;</td>\n";
}
else {
echo " <td valign='top' class='".$row_style[$c]."'>".date('j M', $row['start_epoch'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".date('H:i', $row['start_epoch'])." - ".date('j M H:i', $row['stop_epoch'])."&nbsp;</td>\n";
}
echo " <td valign='top' class='".$row_style[$c]."'>".$row['volume']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".(round($row['minutes'],2))."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".(round($row['avg_min'],2))."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['missed']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".(round($row['asr'],2))."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".(round($row['aloc'],2))."&nbsp;</td>\n";
echo "</tr >\n";
if ($c==0) { $c=1; } else { $c=0; }
$i++;
}
echo "</table>\n";
//show the footer
require_once "includes/footer.php";
?>
+73
View File
@@ -0,0 +1,73 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//include the xml cdr statistics backend
require_once "xml_cdr_statistics_inc.php";
//set the http header
header('Content-type: application/octet-binary');
header('Content-Disposition: attachment; filename=cdr-statistics.csv');
//show the column names on the first line
$z = 0;
foreach($stats[1] as $key => $val) {
if ($z == 0) {
echo '"'.$key.'"';
}
else {
echo ',"'.$key.'"';
}
$z++;
}
echo "\n";
//add the values to the csv
$x = 0;
foreach($stats as $row) {
$z = 0;
foreach($row as $key => $val) {
if ($z == 0) {
echo '"'.$stats[$x][$key].'"';
}
else {
echo ',"'.$stats[$x][$key].'"';
}
$z++;
}
echo "\n";
$x++;
}
?>
+246
View File
@@ -0,0 +1,246 @@
<?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) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('xml_cdr_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//show all call detail records to admin and superadmin. for everyone else show only the call details for extensions assigned to them
if (!if_group("admin") && !if_group("superadmin")) {
// select caller_id_number, destination_number from v_xml_cdr where domain_uuid = ''
// and (caller_id_number = '1001' or destination_number = '1001' or destination_number = '*991001')
$sql_where = "where domain_uuid = '$domain_uuid' and ( ";
if (count($_SESSION['user']['extension']) > 0) {
$x = 0;
foreach($_SESSION['user']['extension'] as $row) {
if ($x==0) {
if ($row['user'] > 0) { $sql_where .= "caller_id_number = '".$row['user']."' \n"; } //source
}
else {
if ($row['user'] > 0) { $sql_where .= "or caller_id_number = '".$row['user']."' \n"; } //source
}
if ($row['user'] > 0) { $sql_where .= "or destination_number = '".$row['user']."' \n"; } //destination
if ($row['user'] > 0) { $sql_where .= "or destination_number = '*99".$row['user']."' \n"; } //destination
$x++;
}
}
$sql_where .= ") ";
}
else {
//superadmin or admin
$sql_where = "where domain_uuid = '$domain_uuid' ";
}
//create the sql query to get the xml cdr records
if (strlen($order_by) == 0) { $order_by = "start_epoch"; }
if (strlen($order) == 0) { $order = "desc"; }
//calculate the seconds in different time frames
$seconds_hour = 3600;
$seconds_day = $seconds_hour * 24;
$seconds_week = $seconds_day * 7;
$seconds_month = $seconds_day * 30;
//get the call volume between a start end end time in seconds
function get_call_volume_between($start, $end, $where) {
global $db;
if (strlen($where) == 0) {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
}
$sql = " select count(*) as count from v_xml_cdr ";
$sql .= $where;
$sql .= "and start_epoch BETWEEN ".$start." AND ".$end." ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset ($prep_statement, $sql);
if (count($result) > 0) {
foreach($result as $row) {
return $row['count'];
}
}
else {
return false;
}
unset($prep_statement, $result, $sql);
}
//get the call time in seconds between the start and end time in seconds
function get_call_seconds_between($start, $end, $where) {
global $db;
if (strlen($where) == 0) {
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
}
$sql = " select sum(billsec) as seconds from v_xml_cdr ";
$sql .= $where;
$sql .= "and start_epoch BETWEEN ".$start." AND ".$end." ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset ($prep_statement, $sql);
if (count($result) > 0) {
foreach($result as $row) {
$result = $row['seconds'];
if (strlen($result) == 0) {
return 0;
}
else {
return $row['seconds'];
}
}
}
else {
return false;
}
unset($prep_statement, $result, $sql);
}
//$call_seconds_1st_hour = get_call_seconds_between(3600, 0);
//if (strlen($call_seconds_1st_hour) == 0) { $call_seconds_1st_hour = 0; }
//round down to the nearest hour
$time = time() - time() % 3600;
//call info hour by hour
for ($i = 0; $i <= 23; $i++) {
$stats[$i]['start_epoch'] = $time - 3600*$i;
$stats[$i]['stop_epoch'] = $stats[$i]['start_epoch'] + 3600;
$stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['minutes'] = $stats[$i]['seconds'] / 60;
$stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume'];
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / 60;
//answer / seizure ratio
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$where .= "and billsec = '0' ";
$where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);
//average length of call
$stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']);
}
//call info for a day
$i = 24;
$stats[$i]['start_epoch'] = time() - $seconds_day;
$stats[$i]['stop_epoch'] = time();
$stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['minutes'] = $stats[$i]['seconds'] / 60;
$stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume'];
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24);
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$where .= "and billsec = '0' ";
$where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);
$stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']);
$i++;
//call info for a week
$stats[$i]['start_epoch'] = time() - $seconds_week;
$stats[$i]['stop_epoch'] = time();
$stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['minutes'] = $stats[$i]['seconds'] / 60;
$stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume'];
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*7);
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$where .= "and billsec = '0' ";
$where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);
$stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']);
$i++;
//call info for a month
$stats[$i]['start_epoch'] = time() - $seconds_month;
$stats[$i]['stop_epoch'] = time();
$stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], '');
$stats[$i]['minutes'] = $stats[$i]['seconds'] / 60;
$stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume'];
$stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*30);
$where = "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$where .= "and billsec = '0' ";
$where .= "and direction = 'inbound' ";
$stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where);
$stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100);
$stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']);
$i++;
//show the graph
$x = 0;
foreach ($stats as $row) {
$graph['volume'][$x][] = date('H', $row['start_epoch']);
$graph['volume'][$x][] = $row['volume']/1;
if ($x == 23) { break; }
$x++;
}
$x = 0;
foreach ($stats as $row) {
$graph['minutes'][$x][] = date('H', $row['start_epoch']);
$graph['minutes'][$x][] = round($row['minutes'],2);
if ($x == 23) { break; }
$x++;
}
$x = 0;
foreach ($stats as $row) {
$graph['call_per_min'][$x][] = date('H', $row['start_epoch']);
$graph['call_per_min'][$x][] = round($row['avg_min'],2);
if ($x == 23) { break; }
$x++;
}
$x = 0;
foreach ($stats as $row) {
$graph['missed'][$x][] = date('H', $row['start_epoch']);
$graph['missed'][$x][] = $row['missed']/1;
if ($x == 23) { break; }
$x++;
}
$x = 0;
foreach ($stats as $row) {
$graph['asr'][$x][] = date('H', $row['start_epoch']);
$graph['asr'][$x][] = round($row['asr'],2)/100;
if ($x == 23) { break; }
$x++;
}
$x = 0;
foreach ($stats as $row) {
$graph['aloc'][$x][] = date('H', $row['start_epoch']);
$graph['aloc'][$x][] = round($row['aloc'],2);
if ($x == 23) { break; }
$x++;
}
?>