Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('xml_cdr_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //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 "resources/header.php"; //page title and description echo "
"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['title2']."\n"; echo " \n"; echo "
\n"; echo "".$text['description-5']." \n"; echo "".$text['description-6']." \n"; echo "".$text['description-7']." \n"; echo "
\n"; echo "
\n"; echo "
\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 "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-summary']." 
\n"; echo "\n"; echo "\n"; echo "\n"; //echo "\n"; //echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; //echo " \n"; //echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['table-direction']."LanguageContext".$text['table-name']."".$text['table-download']."".$text['label-destination']."".$text['label-start']."".$text['table-end']."".$text['label-length']."".$text['label-status']."
".$direction."".$language."".$context.""; if (file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { //echo " \n"; //echo " "; echo " \n"; //$tmp_file_array = explode("\.",$file); echo $caller_id_name.' '; echo " "; } else { echo $caller_id_name.' '; } echo " "; if (file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { echo " \n"; echo $caller_id_number.' '; echo " "; } else { echo $caller_id_number.' '; } echo " ".$destination_number."".$start_stamp."".$end_stamp."".$duration."".$hangup_cause."
"; echo "
"; //breaking space echo "

\n"; //channel data loop $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-channel']." 
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; foreach($xml->channel_data->children() as $child) { $key = $child->getName(); $value = urldecode($child); echo "\n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } echo "
NameValue
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
"; echo "
"; //breaking space echo "

\n"; //variable loop $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo "
Variables 
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; foreach($xml->variables->children() as $child) { $key = $child->getName(); $value = urldecode($child); if ($key != "digits_dialed" && $key != "dsn") { echo "\n"; echo " \n"; if ($key == "bridge_uuid" || $key == "signal_bond") { echo " \n"; } else { echo " \n"; } echo "\n"; } if ($c==0) { $c=1; } else { $c=0; } } echo "
".$text['label-name']."".$text['label-value']."
".$key."\n"; echo " ".$value." \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 " \n"; echo " play"; echo "  "; } if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { echo " \n"; echo " download"; echo " "; } echo "".wordwrap($value,75,"
\n", TRUE)." 
"; echo "
"; //breaking space echo "

\n"; //app_log $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-application-log']." 
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; foreach ($xml->app_log->application as $row) { $app_name = $row->attributes()->app_name; $app_data = $row->attributes()->app_data; echo "\n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } echo "
".$text['label-name']."".$text['label-data']."
".$app_name." ".wordwrap($app_data,75,"
\n", TRUE)." 
"; echo "
"; //breaking space echo "

\n"; //callflow $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; foreach ($xml->callflow as $row) { echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo "
\n"; //attributes echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-call-flow']." 
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; foreach($row->attributes() as $key => $value) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($c==0) { $c=1; } else { $c=0; } } echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-name']."".$text['label-value']."
".$key." ".wordwrap($value,75,"
\n", TRUE)." 


\n"; //extension->attributes echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-call-flow-2']." 
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; foreach($row->extension->attributes() as $key => $value) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($c==0) { $c=1; } else { $c=0; } } echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-name']."".$text['label-value']."
".$key." ".wordwrap($value,75,"
\n", TRUE)." 


\n"; //extension->application echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-call-flow-3']." 
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; foreach ($row->extension->application as $tmp_row) { $app_name = $tmp_row->attributes()->app_name; $app_data = $tmp_row->attributes()->app_data; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($c==0) { $c=1; } else { $c=0; } } echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-name']."".$text['label-data']."
".$app_name." ".wordwrap($app_data,75,"
\n", TRUE)." 


\n"; //caller_profile echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-call-flow-4']." 
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; foreach($row->caller_profile->children() as $child) { $key = $child->getName(); echo " \n"; if ($key != "originatee") { $value = urldecode($child); echo " \n"; echo " \n"; } else { echo " \n"; echo " \n"; } echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-name']."".$text['label-value']."
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
".$key."\n"; echo " \n"; foreach($child->originatee_caller_profile->children() as $tmp_child) { //print_r($tmp_child); $key = $tmp_child->getName(); $value = urldecode($tmp_child); echo " \n"; echo " \n"; if ($key != "uuid") { echo " \n"; } else { echo " \n"; } echo " \n"; } echo "
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
".$value." 
\n"; echo "


\n"; //times echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; foreach($row->times->children() as $child) { $key = $child->getName(); $value = urldecode($child); echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($c==0) { $c=1; } else { $c=0; } } echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-call-flow-5']." 
".$text['label-name']."".$text['label-value']."
".$key." ".wordwrap($value,75,"
\n", TRUE)." 


"; echo "

\n"; } echo "
"; //testing //echo "
\n";
	//echo htmlentities($xml_string);
	//print_r($xml);
	//echo "
\n"; //get the footer require_once "resources/footer.php"; ?>