From 112ae1132843413f92a44dff75c41c039bd65fed Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 3 Sep 2019 08:29:44 -0600 Subject: [PATCH] CDR: Database class integration. --- app/xml_cdr/download.php | 2 +- app/xml_cdr/report.php | 273 ++++++------ app/xml_cdr/xml_cdr.php | 24 +- app/xml_cdr/xml_cdr_archive.php | 8 +- app/xml_cdr/xml_cdr_delete.php | 61 +-- app/xml_cdr/xml_cdr_details.php | 497 ++++++++++++---------- app/xml_cdr/xml_cdr_export.php | 16 +- app/xml_cdr/xml_cdr_extension_summary.php | 15 +- app/xml_cdr/xml_cdr_import.php | 2 +- app/xml_cdr/xml_cdr_inc.php | 42 +- app/xml_cdr/xml_cdr_search.php | 27 +- app/xml_cdr/xml_cdr_statistics.php | 22 +- app/xml_cdr/xml_cdr_statistics_csv.php | 6 +- app/xml_cdr/xml_cdr_statistics_inc.php | 326 +++++++++----- 14 files changed, 707 insertions(+), 614 deletions(-) diff --git a/app/xml_cdr/download.php b/app/xml_cdr/download.php index 42f926f4d5..4781cda42e 100644 --- a/app/xml_cdr/download.php +++ b/app/xml_cdr/download.php @@ -42,4 +42,4 @@ $obj = new xml_cdr; $obj->download(); -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/report.php b/app/xml_cdr/report.php index c3b769074a..44e689d014 100644 --- a/app/xml_cdr/report.php +++ b/app/xml_cdr/report.php @@ -29,8 +29,6 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; - require_once "resources/header.php"; - //require_once "xml_cdr_statistics_inc.php"; //check permissions if (permission_exists('xml_cdr_view')) { @@ -42,175 +40,154 @@ } //additional includes - //require_once "xml_cdr_statistics_inc.php"; require_once "resources/header.php"; -global $db; - $dom = date('m'); $year = date('Y'); -if (strlen($where) == 0) { - $duuid = "domain_uuid = '".$_SESSION['domain_uuid']."' "; -} +for ($y = 0; $y < 4; $y++) { + $fileheader = array('month', 'total calls', 'total seconds', 'total minutes', 'total hours', 'billing periods', 'rate', 'approx cost'); -for ($y=0; $y<4; $y++) { - $fileheader = array( 'month', 'total calls' , 'total seconds' , 'total minutes' , 'total hours' , 'billing periods', 'rate', 'approx cost'); + if ($y == 0) { + $table_name = "Previous 12 Months Inbound Call Summary
"; + $sql_begin = "select billsec as seconds from v_xml_cdr where (domain_uuid = :domain_uuid and direction = 'inbound') "; + $rate = 0.012; + $bill_period = 60; + } + else if ($y == 1) { + $table_name = "Previous 12 Months Outbound Metered Call Summary
"; + $sql_begin = "select billsec as seconds from v_xml_cdr where (domain_uuid = :domain_uuid and direction = 'outbound') "; + $sql_end = "and destination_number not like '%800_______' and destination_number not like '%888_______' and destination_number not like '%877_______' and destination_number not like '%866_______' and destination_number not like '%855_______' "; + $rate = 0.0098; + $rate = $rate / 10; + $bill_period = 6; + } + else if ($y == 2) { + $table_name = "Previous 12 Months Toll Free Call Summary
"; + $sql_begin = "select billsec as seconds from v_xml_cdr where (domain_uuid = :domain_uuid and direction = 'outbound') "; + $sql_end = "and (destination_number like '%800_______' or destination_number like '%888_______' or destination_number like '%877_______' or destination_number like '%866_______' or destination_number like '%855_______') "; + $rate = 0; + $bill_period = 6; + } + else if ($y == 3) { + $table_name = "Previous 12 Months Local Free Call Summary
"; + $sql_begin = "select billsec as seconds from v_xml_cdr where (domain_uuid = :domain_uuid and direction = 'local') "; + $rate = 0; + $bill_period = 6; + } + //set the style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; - if ( $y == 0) { - $tablename = "Previous 12 Months Inbound Call Summary
"; - $sql1 = "select billsec as seconds from v_xml_cdr where (".$duuid."and direction='inbound') "; - $sql3 = ";"; - //really we should set rate in domain settings or something and pull it from the php session. - $rate=0.012; - $bill_period=60; - } - elseif ($y == 1) { - $tablename = "Previous 12 Months Outbound Metered Call Summary
"; - $sql1 = "select billsec as seconds from v_xml_cdr where (".$duuid."and direction='outbound') "; - $sql3 = "and destination_number not like '%800_______' and destination_number not like '%888_______' and destination_number not like '%877_______' and destination_number not like '%866_______' and destination_number not like '%855_______' ;"; - $rate=0.0098; - $rate=$rate/10; - $bill_period=6; - } - elseif ($y == 2) { - $tablename = "Previous 12 Months Toll Free Call Summary
"; - $sql1 = "select billsec as seconds from v_xml_cdr where (".$duuid."and direction='outbound') "; - $sql3 = "and (destination_number like '%800_______' or destination_number like '%888_______' or destination_number like '%877_______' or destination_number like '%866_______' or destination_number like '%855_______');"; - $rate=0; - $bill_period=6; - } - elseif ($y == 3) { - $tablename = "Previous 12 Months Local Free Call Summary
"; - $sql1 = "select billsec as seconds from v_xml_cdr where (".$duuid."and direction='local') "; - $sql3 = ";"; - $rate=0; - $bill_period=6; - } - else { - echo "whoops
"; - } + echo ""; + $dom = date('m'); + $year = date('Y'); + $lyear = $year; + $last_month = $year."-".$dolm."-01"; + $this_month = $year."-".$dom."-01"; -//set the style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; + echo $table_name; - echo "
"; + foreach ($fileheader as $tr) { + echo ""; + } - $dom = date('m'); - $year = date('Y'); - $lyear=$year; - $lastmonth = $year."-".$dolm."-01"; - $thismonth = $year."-".$dom."-01"; + for ($x = 0; $x < 12; $x++) { + if ($dom == 1) { + $dom = 12; + $year = $year - 1; + } + else if ($x == 0) { + $dom = $dom; + } + else { + $dom = $dom - 1; + } + if ($dom == 1) { + $dolm = 12; + $lyear = $lyear - 1; + } + else { + $dolm = $dom - 1; + } - echo $tablename; + //convert to int + $dom = $dom * 1; + $dolm = $dolm * 1; - foreach ($fileheader as $tr){ - echo ""; - } + //back to string, prepend 0) + if ( $dolm < 10 ) { + $dolm = "0".$dolm; + } + if ( $dom < 10 ) { + $dom = "0".$dom; + } + $last_month = $lyear."-".$dolm."-01"; + $this_month = $year."-".$dom."-01"; - for ($x=0; $x < 12; $x++) - { - if ($dom == 1){ - $dom=12; - $year=$year-1; - } - elseif ($x == 0){ - $dom=$dom; - } - else { - $dom=$dom-1; - } - if ($dom == 1) { - $dolm=12; - $lyear=$lyear-1; - } - else { - $dolm=$dom-1; - } + $sql = $sql_begin." and (start_stamp >= :last_month and start_stamp < :this_month) ".$sql_end; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['last_month'] = $last_month; + $parameters['this_month'] = $this_month; + $database = new database; + $result = $database->select($sql, $parameters, 'all'); + unset($sql); + $max = sizeof($result) - 1; - //convert to int - $dom=$dom*1; - $dolm=$dolm*1; + $i = 0; - //back to string, prepend 0) - if ( $dolm < 10 ) { - $dolm = "0".$dolm; - } - if ( $dom < 10 ) { - $dom = "0".$dom; - } - $lastmonth = $lyear."-".$dolm."-01"; - $thismonth = $year."-".$dom."-01"; - - $sql2 = "and (start_stamp >= '" . $lastmonth . "' AND start_stamp < '" . $thismonth. "') "; - - $sql = $sql1; - $sql .= $sql2; - $sql .= $sql3; - $sql .= $callsort; - //echo "
" . $sql . "
"; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); - unset ($prep_statement, $sql); - $max = sizeof($result) -1; - - $i=0; - - - echo ""; + echo ""; //echo " \n"; - if ( $max > 0 ) { - foreach($result as $row) { - $result = $row['seconds']; - $billtime_1 = intval($result/$bill_period); - $billtime_2 = $result%$bill_period; + if ($max > 0) { + foreach ($result as $row) { + $result = $row['seconds']; + $billtime_1 = intval($result / $bill_period); + $billtime_2 = $result % $bill_period; - if (($result%$bill_period) != 0 ) { - //need to round up for billing period - $billtime = $billtime + intval($result/$bill_period) + 1; - //echo " mod worked "; - } - else { - //no need to round up for billing period - $billtime = $billtime + intval($result/$bill_period); - } - $tottime = $tottime + $result; - } + if (($result % $bill_period) != 0) { + //need to round up for billing period + $billtime = $billtime + intval($result / $bill_period) + 1; + //echo " mod worked "; + } + else { + //no need to round up for billing period + $billtime = $billtime + intval($result / $bill_period); + } + $tottime = $tottime + $result; + } - echo ""; - echo ""; - echo ""; - $mintime = $tottime/$bill_period; - echo ""; - $hourtime = $tottime/3600; - echo ""; - $tot_cost = $rate * $billtime ; - echo ""; - echo ""; - echo ""; + echo " "; + echo " "; + echo " "; + $mintime = $tottime / $bill_period; + echo " "; + $hourtime = $tottime / 3600; + echo " "; + $tot_cost = $rate * $billtime ; + echo " "; + echo " "; + echo " "; - if ($c==0) { $c=1; } else { $c=0; } + $c = $c ? 0 : 1; + } + echo ""; - - } - echo ""; - $max=0; - $tottime=0; - $hourtime=0; - $billtime=0; - $tot_cost=0; - $mintime=0; - } - echo "
".$tr."" . $tr . "
".($i+1)."".$dolm."/".$lyear."".$max."".$tottime."".round($mintime,1)."".round($hourtime,1)."".$billtime."".$rate."$".round($tot_cost,2)."".$dolm."/".$lyear."".$max."".$tottime."".round($mintime,1)."".round($hourtime,1)."".$billtime."".$rate."$".round($tot_cost,2)."
"; - echo "
"; + $max = 0; + $tottime = 0; + $hourtime = 0; + $billtime = 0; + $tot_cost = 0; + $mintime = 0; + } + echo ""; + echo "
"; } //show the footer - require_once "resources/footer.php"; -?> + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index a5b9d0c488..d01eb9c862 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -152,15 +152,13 @@ echo " \n"; } echo " \n"; - echo " \n"; - echo " "; - echo " "; echo " \n"; - echo " \n"; + echo " \n"; + echo " "; echo " ".$paging_controls_mini."\n"; echo " \n"; echo " \n"; @@ -449,8 +447,8 @@ file_exists($theme_image_path."icon_cdr_local_failed.png") ) ? true : false; - // loop through the results - foreach($result as $index => $row) { + //loop through the results + foreach ($result as $index => $row) { //get the date and time $tmp_year = date("Y", strtotime($row['start_stamp'])); $tmp_month = date("M", strtotime($row['start_stamp'])); @@ -464,7 +462,7 @@ $hangup_cause = ucwords($hangup_cause); //if call cancelled, show the ring time, not the bill time. - $seconds = ($row['hangup_cause']=="ORIGINATOR_CANCEL") ? $row['duration'] : round(($row['billmsec'] / 1000), 0, PHP_ROUND_HALF_UP); + $seconds = $row['hangup_cause'] == "ORIGINATOR_CANCEL" ? $row['duration'] : round(($row['billmsec'] / 1000), 0, PHP_ROUND_HALF_UP); //determine recording properties if (permission_exists('recording_play') || permission_exists('recording_download')) { @@ -685,16 +683,16 @@ if ($row['leg'] == 'a') { echo $content; } - elseif ($row['leg'] == 'b' && permission_exists('xml_cdr_b_leg')) { + else if ($row['leg'] == 'b' && permission_exists('xml_cdr_b_leg')) { echo $content; } unset($content); //toggle the color - $c = ($c) ? 0 : 1; - } //end foreach - unset($sql, $result, $row_count); - } //end foreach + $c = $c ? 0 : 1; + } //foreach + } //if + unset($sql, $result, $row_count); //paging controls echo "\n"; @@ -721,4 +719,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_archive.php b/app/xml_cdr/xml_cdr_archive.php index 2d56c487c5..f0f8709d70 100644 --- a/app/xml_cdr/xml_cdr_archive.php +++ b/app/xml_cdr/xml_cdr_archive.php @@ -131,6 +131,7 @@ echo " \n"; echo " \n"; echo " "; - echo " \n"; + echo " "; echo " \n"; echo " \n"; echo "
\n"; + echo " "; if (permission_exists('xml_cdr_all')) { if ($_REQUEST['show'] != 'alll') { echo " \n"; @@ -148,15 +149,12 @@ } // echo " \n"; echo " \n"; - echo " "; - echo " "; echo " \n"; - echo " ".$paging_controls_mini."
\n"; @@ -724,4 +722,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_delete.php b/app/xml_cdr/xml_cdr_delete.php index 390846fa6d..f4167b26bc 100644 --- a/app/xml_cdr/xml_cdr_delete.php +++ b/app/xml_cdr/xml_cdr_delete.php @@ -42,21 +42,13 @@ $language = new text; $text = $language->get(); -//get posted values, if any - if (sizeof($_REQUEST) > 0) { - $xml_cdr_uuids = $_REQUEST["id"]; - if (sizeof($xml_cdr_uuids) > 0) { - foreach ($xml_cdr_uuids as $index => $xml_cdr_uuid) { - if (is_uuid($xml_cdr_uuid)) { - // delete record from v_xml_cdr - $sql = "delete from v_xml_cdr "; - $sql .= "where xml_cdr_uuid = :xml_cdr_uuid "; - $parameters['xml_cdr_uuid'] = $xml_cdr_uuid; - $database = new database; - $database->execute($sql, $parameters); - unset($sql, $parameters); - - //get the call recordings +//get posted values + $xml_cdr_uuids = $_REQUEST["id"]; + if (is_array($xml_cdr_uuids) && @sizeof($xml_cdr_uuids) != 0) { + $records_deleted = 0; + foreach ($xml_cdr_uuids as $x => $xml_cdr_uuid) { + if (is_uuid($xml_cdr_uuid)) { + //get the call recordings $sql = "select * from v_call_recordings "; $sql .= "where call_recording_uuid = :xml_cdr_uuid "; $parameters['xml_cdr_uuid'] = $xml_cdr_uuid; @@ -64,28 +56,41 @@ $row = $database->select($sql, $parameters, 'row'); unset($sql, $parameters); - //delete the call recording + //delete the call recording $call_recording_path = realpath($row['call_recording_path']); $call_recording_name = $row['call_recording_name']; if (file_exists($call_recording_path.'/'.$call_recording_name)) { @unlink($call_recording_path.'/'.$call_recording_name); } - //delete the call recording meta data - $sql = "delete from v_call_recordings "; - $sql .= "where call_recording_uuid = :xml_cdr_uuid "; - $parameters['xml_cdr_uuid'] = $xml_cdr_uuid; - $database = new database; - $database->execute($sql, $parameters); - unset($sql, $parameters); - - } + //build cdr delete array + $array['xml_cdr'][$x]['xml_cdr_uuid'] = $xml_cdr_uuid; + //build call recording delete array + $array['call_recordings'][$x]['call_recording_uuid'] = $xml_cdr_uuid; + //increment counter + $records_deleted++; } } + if (is_array($array) && @sizeof($array) != 0) { + //grant temporary permissions + $p = new permissions; + $p->add('xml_cdr_delete', 'temp'); + $p->add('call_recording_delete', 'temp'); + //execute delete + $database = new database; + $database->app_name = 'xml_cdr'; + $database->app_uuid = '4a085c51-7635-ff03-f67b-86e834422848'; + $database->delete($array); + unset($array); + //revoke temporary permissions + $p->delete('xml_cdr_delete', 'temp'); + $p->delete('call_recording_delete', 'temp'); + //set message + $_SESSION["message"] = $text['message-delete'].": ".$records_deleted; + } } -//set message and redirect the user - $_SESSION["message"] = $text['message-delete'].": ".sizeof($xml_cdr_uuids); +//redirect header("Location: xml_cdr.php"); -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php index 3cf10ca9c8..d6678691c5 100644 --- a/app/xml_cdr/xml_cdr_details.php +++ b/app/xml_cdr/xml_cdr_details.php @@ -43,22 +43,29 @@ $text = $language->get(); //get the http values and set them to a variable - if (strlen($_REQUEST["id"]) > 0) { - $uuid = trim($_REQUEST["id"]); + if (is_uuid($_REQUEST["id"])) { + $uuid = $_REQUEST["id"]; } //get the cdr string from the database $sql = "select * from v_xml_cdr "; if (permission_exists('xml_cdr_all')) { - $sql .= "where xml_cdr_uuid = '$uuid' "; - } else { - $sql .= "where xml_cdr_uuid = '$uuid' and domain_uuid = '$domain_uuid' "; + $sql .= "where xml_cdr_uuid = :xml_cdr_uuid "; } - $row = $db->query($sql)->fetch(); - $start_stamp = trim($row["start_stamp"]); - $xml_string = trim($row["xml"]); - $json_string = trim($row["json"]); - //print_r($row); + else { + $sql .= "where xml_cdr_uuid = :xml_cdr_uuid "; + $sql .= "and domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $domain_uuid; + } + $parameters['xml_cdr_uuid'] = $uuid; + $database = new database; + $row = $database->select($sql, $parameters, 'row'); + if (is_array($row) && @sizeof($row) != 0) { + $start_stamp = trim($row["start_stamp"]); + $xml_string = trim($row["xml"]); + $json_string = trim($row["json"]); + } + unset($sql, $parameters, $row); //get the format if (strlen($xml_string) > 0) { @@ -89,7 +96,7 @@ try { if ($format == 'json') { $array = json_decode($json_string,true); - if (is_null($array)){ + if (is_null($array)) { $j = stripslashes($json_string); $array = json_decode($j,true); } @@ -98,7 +105,7 @@ $array = json_decode(json_encode((array)simplexml_load_string($xml_string)),true); } } - catch(Exception $e) { + catch (Exception $e) { echo $e->getMessage(); } @@ -126,28 +133,28 @@ //detail summary //get the variables - $xml_cdr_uuid = check_str(urldecode($array["variables"]["uuid"])); - $direction = check_str(urldecode($array["channel_data"]["direction"])); - $language = check_str(urldecode($array["variables"]["language"])); - $start_epoch = check_str(urldecode($array["variables"]["start_epoch"])); - $start_stamp = check_str(urldecode($array["variables"]["start_stamp"])); - $start_uepoch = check_str(urldecode($array["variables"]["start_uepoch"])); - $answer_stamp = check_str(urldecode($array["variables"]["answer_stamp"])); - $answer_epoch = check_str(urldecode($array["variables"]["answer_epoch"])); - $answer_uepoch = check_str(urldecode($array["variables"]["answer_uepoch"])); - $end_epoch = check_str(urldecode($array["variables"]["end_epoch"])); - $end_uepoch = check_str(urldecode($array["variables"]["end_uepoch"])); - $end_stamp = check_str(urldecode($array["variables"]["end_stamp"])); - $duration = check_str(urldecode($array["variables"]["duration"])); - $mduration = check_str(urldecode($array["variables"]["mduration"])); - $billsec = check_str(urldecode($array["variables"]["billsec"])); - $billmsec = check_str(urldecode($array["variables"]["billmsec"])); - $bridge_uuid = check_str(urldecode($array["variables"]["bridge_uuid"])); - $read_codec = check_str(urldecode($array["variables"]["read_codec"])); - $write_codec = check_str(urldecode($array["variables"]["write_codec"])); - $remote_media_ip = check_str(urldecode($array["variables"]["remote_media_ip"])); - $hangup_cause = check_str(urldecode($array["variables"]["hangup_cause"])); - $hangup_cause_q850 = check_str(urldecode($array["variables"]["hangup_cause_q850"])); + $xml_cdr_uuid = urldecode($array["variables"]["uuid"]); + $direction = urldecode($array["channel_data"]["direction"]); + $language = urldecode($array["variables"]["language"]); + $start_epoch = urldecode($array["variables"]["start_epoch"]); + $start_stamp = urldecode($array["variables"]["start_stamp"]); + $start_uepoch = urldecode($array["variables"]["start_uepoch"]); + $answer_stamp = urldecode($array["variables"]["answer_stamp"]); + $answer_epoch = urldecode($array["variables"]["answer_epoch"]); + $answer_uepoch = urldecode($array["variables"]["answer_uepoch"]); + $end_epoch = urldecode($array["variables"]["end_epoch"]); + $end_uepoch = urldecode($array["variables"]["end_uepoch"]); + $end_stamp = urldecode($array["variables"]["end_stamp"]); + $duration = urldecode($array["variables"]["duration"]); + $mduration = urldecode($array["variables"]["mduration"]); + $billsec = urldecode($array["variables"]["billsec"]); + $billmsec = urldecode($array["variables"]["billmsec"]); + $bridge_uuid = urldecode($array["variables"]["bridge_uuid"]); + $read_codec = urldecode($array["variables"]["read_codec"]); + $write_codec = urldecode($array["variables"]["write_codec"]); + $remote_media_ip = urldecode($array["variables"]["remote_media_ip"]); + $hangup_cause = urldecode($array["variables"]["hangup_cause"]); + $hangup_cause_q850 = urldecode($array["variables"]["hangup_cause_q850"]); if (!isset($array["callflow"][0])) { $tmp = $array["callflow"]; unset($array["callflow"]); @@ -156,12 +163,12 @@ $x = 0; if (is_array($array["callflow"])) foreach ($array["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"])); + $destination_number = urldecode($row["caller_profile"]["destination_number"]); + $context = urldecode($row["caller_profile"]["context"]); + $network_addr = 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"])); + $caller_id_name = urldecode($row["caller_profile"]["caller_id_name"]); + $caller_id_number = urldecode($row["caller_profile"]["caller_id_number"]); $x++; } unset($x); @@ -253,7 +260,7 @@ echo " ".$key." \n"; echo " ".wordwrap($value,75,"
\n", TRUE)." \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + $c = $c ? 0 : 1; } echo ""; echo "

\n"; @@ -274,47 +281,49 @@ echo "".$text['label-name']."\n"; echo "".$text['label-value']."\n"; echo "\n"; - if (is_array($array["variables"])) foreach($array["variables"] as $key => $value) { - if (is_array($value)) { $value = implode($value); } - $value = urldecode($value); - if ($key != "digits_dialed" && $key != "dsn") { - echo "\n"; - echo " ".$key."\n"; - if ($key == "bridge_uuid" || $key == "signal_bond") { - echo " \n"; - echo " ".$value." \n"; - $tmp_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; - $tmp_name = ''; - if (file_exists($tmp_dir.'/'.$value.'.wav')) { - $tmp_name = $value.".wav"; + if (is_array($array["variables"])) { + foreach($array["variables"] as $key => $value) { + if (is_array($value)) { $value = implode($value); } + $value = urldecode($value); + if ($key != "digits_dialed" && $key != "dsn") { + echo "\n"; + echo " ".$key."\n"; + if ($key == "bridge_uuid" || $key == "signal_bond") { + echo " \n"; + echo " ".$value." \n"; + $tmp_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + $tmp_name = ''; + if (file_exists($tmp_dir.'/'.$value.'.wav')) { + $tmp_name = $value.".wav"; + } + else if (file_exists($tmp_dir.'/'.$value.'_1.wav')) { + $tmp_name = $value."_1.wav"; + } + else if (file_exists($tmp_dir.'/'.$value.'.mp3')) { + $tmp_name = $value.".mp3"; + } + else if (file_exists($tmp_dir.'/'.$value.'_1.mp3')) { + $tmp_name = $value."_1.mp3"; + } + if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/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'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + echo " \n"; + echo " download"; + echo " "; + } + echo "\n"; } - elseif (file_exists($tmp_dir.'/'.$value.'_1.wav')) { - $tmp_name = $value."_1.wav"; + else { + echo " ".wordwrap($value,75,"
\n", true)." \n"; } - 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'].'/'.$_SESSION['domain_name'].'/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'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { - echo " \n"; - echo " download"; - echo " "; - } - echo "\n"; + echo "\n"; } - else { - echo " ".wordwrap($value,75,"
\n", TRUE)." \n"; - } - echo "\n"; + $c = $c ? 0 : 1; } - if ($c==0) { $c=1; } else { $c=0; } } echo ""; echo "

\n"; @@ -337,14 +346,16 @@ echo "\n"; //foreach($array["variables"] as $key => $value) { - if (is_array($array["app_log"]["application"])) foreach ($array["app_log"]["application"] as $row) { - $app_name = $row["@attributes"]["app_name"]; - $app_data = urldecode($row["@attributes"]["app_data"]); - echo "\n"; - echo " ".$app_name." \n"; - echo " ".wordwrap($app_data,75,"
\n", TRUE)." \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + if (is_array($array["app_log"]["application"])) { + foreach ($array["app_log"]["application"] as $row) { + $app_name = $row["@attributes"]["app_name"]; + $app_data = urldecode($row["@attributes"]["app_data"]); + echo "\n"; + echo " ".$app_name." \n"; + echo " ".wordwrap($app_data,75,"
\n", true)." \n"; + echo "\n"; + $c = $c ? 0 : 1; + } } echo ""; echo "

\n"; @@ -353,173 +364,187 @@ $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - if (is_array($array["callflow"])) foreach ($array["callflow"] as $row) { - - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; + //times + echo "
\n"; - - //attributes - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['label-call-flow']."  
\n"; - + if (is_array($array["callflow"])) { + foreach ($array["callflow"] as $row) { echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (is_array($row["@attributes"])) foreach($row["@attributes"] as $key => $value) { - $value = urldecode($value); + echo "\n"; + echo "
".$text['label-name']."".$text['label-value']."
\n"; + + //attributes + echo " \n"; echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; - if ($c==0) { $c=1; } else { $c=0; } - } - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
".$text['label-call-flow']."  


\n"; + echo "
\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"; - if (is_array($row["extension"]["@attributes"])) foreach($row["extension"]["@attributes"] as $key => $value) { - $value = urldecode($value); - echo " \n"; - echo " \n"; - echo " \n"; + echo "
".$text['label-name']."".$text['label-value']."
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
\n"; + 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']."


\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"; - if (is_array($row["extension"]["application"])) foreach ($row["extension"]["application"] as $tmp_row) { - $app_name = $tmp_row["@attributes"]["app_name"]; - $app_data = urldecode($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"; - if (is_array($row["caller_profile"])) foreach($row["caller_profile"] as $key => $value) { - if (is_array($value)) { $value = implode($value); } - $value = urldecode($value); - echo " \n"; - if ($key != "originatee") { - if (is_array($value)) { $value = implode($value); } - $value = urldecode($value); - echo " \n"; - echo " \n"; + if (is_array($row["@attributes"])) { + foreach($row["@attributes"] as $key => $value) { + $value = urldecode($value); + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + $c = $c ? 0 : 1; + } } - 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." ".wordwrap($value,75,"
\n", true)." 
".$key." \n"; - echo " \n"; - if (isset($child["originatee_caller_profile"])) foreach($child["originatee_caller_profile"] as $key => $value) { - //print_r($tmp_child); - echo " \n"; - echo " \n"; - if ($key != "uuid") { - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$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"; + if (is_array($row["extension"]["@attributes"])) { + foreach($row["extension"]["@attributes"] as $key => $value) { + $value = urldecode($value); + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + $c = $c ? 0 : 1; + } + } + 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"; + if (is_array($row["extension"]["application"])) { + foreach ($row["extension"]["application"] as $tmp_row) { + $app_name = $tmp_row["@attributes"]["app_name"]; + $app_data = urldecode($tmp_row["@attributes"]["app_data"]); + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + $c = $c ? 0 : 1; + } + } + 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"; + if (is_array($row["caller_profile"])) { + foreach($row["caller_profile"] as $key => $value) { + if (is_array($value)) { $value = implode($value); } + $value = urldecode($value); + echo " \n"; + if ($key != "originatee") { + if (is_array($value)) { $value = implode($value); } + $value = urldecode($value); + echo " \n"; + echo " \n"; } else { - echo " \n"; + echo " \n"; + echo " \n"; } - echo " \n"; + echo "\n"; + $c = $c ? 0 : 1; } - echo "
".$text['label-name']."".$text['label-value']."
".$key." ".wordwrap($value,75,"
\n", true)." 
".$value." ".$key." \n"; + echo " \n"; + if (isset($child["originatee_caller_profile"])) { + foreach($child["originatee_caller_profile"] as $key => $value) { + //print_r($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"; - echo "


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


\n"; - echo "


\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; - echo "
".$text['label-call-flow-5']." 
"; - echo "

\n"; + echo " \n"; + echo " ".$text['label-name']."\n"; + echo " ".$text['label-value']."\n"; + echo " \n"; + if (is_array($row["times"])) { + foreach($row["times"] as $key => $value) { + $value = urldecode($value); + echo " \n"; + echo " ".$key." \n"; + echo " ".wordwrap($value,75,"
\n", true)." \n"; + echo " \n"; + $c = $c ? 0 : 1; + } + } - echo "\n"; - echo "\n"; - echo ""; + echo " \n"; + echo "

\n"; + echo " \n"; + + echo " "; + echo "

\n"; + + echo "\n"; + echo "\n"; + echo ""; + } } //get the footer require_once "resources/footer.php"; -?> + +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_export.php b/app/xml_cdr/xml_cdr_export.php index 0d4f66f5e1..b78a86d7b4 100644 --- a/app/xml_cdr/xml_cdr_export.php +++ b/app/xml_cdr/xml_cdr_export.php @@ -47,10 +47,10 @@ require_once "xml_cdr_inc.php"; //get the format - $export_format = check_str($_REQUEST['export_format']); + $export_format = $_REQUEST['export_format']; //get the format - $showall = check_str($_REQUEST['showall']); + $showall = $_REQUEST['showall']; //exprot the csv if ($export_format == 'csv') { @@ -69,7 +69,7 @@ //set the csv headers $z = 0; - foreach($result[0] as $key => $val) { + foreach ($result[0] as $key => $val) { if ($key != "xml" && $key != "json") { if ($z == 0) { echo '"'.$key.'"'; @@ -84,9 +84,9 @@ //show the csv data $x=0; - while(true) { + while (true) { $z = 0; - foreach($result[0] as $key => $val) { + foreach ($result[0] as $key => $val) { if ($key != "xml" && $key != "json") { if ($z == 0) { echo '"'.$result[$x][$key].'"'; @@ -109,8 +109,8 @@ if ($export_format == 'pdf') { //load pdf libraries - require_once("resources/tcpdf/tcpdf.php"); - require_once("resources/fpdi/fpdi.php"); + require_once "resources/tcpdf/tcpdf.php"; + require_once "resources/fpdi/fpdi.php"; //determine page size switch ($_SESSION['fax']['page_size']['text']) { @@ -318,4 +318,4 @@ } -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_extension_summary.php b/app/xml_cdr/xml_cdr_extension_summary.php index 8018c41a21..b285aa8350 100644 --- a/app/xml_cdr/xml_cdr_extension_summary.php +++ b/app/xml_cdr/xml_cdr_extension_summary.php @@ -47,11 +47,11 @@ require_once "resources/header.php"; //retrieve submitted data - $quick_select = check_str($_REQUEST['quick_select']); - $start_stamp_begin = check_str($_REQUEST['start_stamp_begin']); - $start_stamp_end = check_str($_REQUEST['start_stamp_end']); - $include_internal = check_str($_REQUEST['include_internal']); - $quick_select = (sizeof($_REQUEST) == 0) ? 3 : $quick_select; //set default + $quick_select = $_REQUEST['quick_select']; + $start_stamp_begin = $_REQUEST['start_stamp_begin']; + $start_stamp_end = $_REQUEST['start_stamp_end']; + $include_internal = $_REQUEST['include_internal']; + $quick_select = sizeof($_REQUEST) == 0 ? 3 : $quick_select; //set default //get the summary $cdr = new xml_cdr; @@ -112,7 +112,8 @@ echo "onclick=\"window.location='xml_cdr_extension_summary.php?"; if (strlen($_SERVER["QUERY_STRING"]) > 0) { echo $_SERVER["QUERY_STRING"]."&type=csv';\">\n"; - } else { + } + else { echo "type=csv';\">\n"; } @@ -257,4 +258,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_import.php b/app/xml_cdr/xml_cdr_import.php index ee70d8fb42..3c80c55cf0 100644 --- a/app/xml_cdr/xml_cdr_import.php +++ b/app/xml_cdr/xml_cdr_import.php @@ -48,4 +48,4 @@ $cdr = new xml_cdr; $cdr->read_files(); -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index fe0fc5fbf7..a71086fbc0 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -95,7 +95,8 @@ case 'equal': $mos_comparison = "<"; break; case 'notequal': $mos_comparison = "<>"; break; } - } else { + } + else { $mos_comparison = ''; } //$mos_comparison = $_REQUEST["mos_comparison"]; @@ -193,20 +194,13 @@ //count the records in the database /* if ($_SESSION['cdr']['limit']['numeric'] == 0) { - $sql = "select count(xml_cdr_uuid) as num_rows from v_xml_cdr "; - $sql .= "where domain_uuid = '".$domain_uuid."' ".$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); + $sql = "select count(*) from v_xml_cdr "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= ".$sql_where; + $parameters['domain_uuid'] = $domain_uuid; + $database = new database; + $num_rows = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); } */ @@ -246,7 +240,7 @@ $sql .= "c.source_number, \n"; $sql .= "c.destination_number, \n"; $sql .= "c.leg, \n"; - $sql .= "(c.xml IS NOT NULL OR c.json IS NOT NULL) AS raw_data_exists, \n"; + $sql .= "(c.xml is not null or c.json is not null) as raw_data_exists, \n"; $sql .= "c.json, \n"; if (is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { @@ -277,8 +271,9 @@ $sql .= "left join v_extensions as e on e.extension_uuid = c.extension_uuid \n"; $sql .= "inner join v_domains as d on d.domain_uuid = c.domain_uuid \n"; if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { - $sql .= "where 1 = 1 "; - } else { + $sql .= "where true "; + } + else { $sql .= "where c.domain_uuid = :domain_uuid \n"; $parameters['domain_uuid'] = $domain_uuid; } @@ -290,7 +285,7 @@ $sql .= "and missed_call = 1 \n"; } if (strlen($start_epoch) > 0 && strlen($stop_epoch) > 0) { - $sql .= "and start_epoch BETWEEN :start_epoch AND :stop_epoch \n"; + $sql .= "and start_epoch between :start_epoch and :stop_epoch \n"; $parameters['start_epoch'] = $start_epoch; $parameters['stop_epoch'] = $stop_epoch; } @@ -355,7 +350,7 @@ } if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { - $sql .= "and start_stamp BETWEEN :start_stamp_begin AND :start_stamp_end "; + $sql .= "and start_stamp between :start_stamp_begin and :start_stamp_end "; $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; } @@ -370,7 +365,7 @@ } } if (strlen($answer_stamp_begin) > 0 && strlen($answer_stamp_end) > 0) { - $sql .= "and answer_stamp BETWEEN :answer_stamp_begin AND :answer_stamp_end "; + $sql .= "and answer_stamp between :answer_stamp_begin and :answer_stamp_end "; $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; } @@ -385,7 +380,7 @@ } } if (strlen($end_stamp_begin) > 0 && strlen($end_stamp_end) > 0) { - $sql .= "and end_stamp BETWEEN :end_stamp_begin AND :end_stamp_end "; + $sql .= "and end_stamp between :end_stamp_begin and :end_stamp_end "; $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; } @@ -501,7 +496,6 @@ } } $sql = str_replace(" ", " ", $sql); - //$sql= str_replace("where and", "where", $sql); $database = new database; if ($archive_request == 'true') { if ($_SESSION['cdr']['archive_database']['boolean'] == 'true') { @@ -527,4 +521,4 @@ $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_search.php b/app/xml_cdr/xml_cdr_search.php index 23a7a63282..aa8c5b7dd3 100644 --- a/app/xml_cdr/xml_cdr_search.php +++ b/app/xml_cdr/xml_cdr_search.php @@ -61,7 +61,8 @@ //start the html form if (strlen(check_str($_GET['redirect'])) > 0) { echo "
\n"; - } else { + } + else { echo "\n"; } @@ -129,18 +130,18 @@ echo " \n"; echo " \n"; echo " \n"; @@ -293,4 +294,4 @@ //include footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_statistics.php b/app/xml_cdr/xml_cdr_statistics.php index acfdf1f258..0b851cd3e6 100644 --- a/app/xml_cdr/xml_cdr_statistics.php +++ b/app/xml_cdr/xml_cdr_statistics.php @@ -247,13 +247,15 @@ }, yaxis: { min: 0 }, 48 && $hours < 168) { - echo "xaxis: {mode: \"time\",timeformat: \"%m:%d\",minTickSize: [1, \"day\"]}"; - } else { - echo "xaxis: {mode: \"time\",timeformat: \"%m:%d\",minTickSize: [1, \"month\"]}"; - } + if ($hours <= 48) { + echo "xaxis: {mode: \"time\",timeformat: \"%d:%H\",minTickSize: [1, \"hour\"]}"; + } + else if ($hours > 48 && $hours < 168) { + echo "xaxis: {mode: \"time\",timeformat: \"%m:%d\",minTickSize: [1, \"day\"]}"; + } + else { + echo "xaxis: {mode: \"time\",timeformat: \"%m:%d\",minTickSize: [1, \"month\"]}"; + } ?> }); } @@ -283,7 +285,7 @@ if ($i <= $hours) { echo " ".($i+1)."\n"; } - elseif ($i == $hours+1) { + else if ($i == $hours+1) { echo "

\n"; echo "\n"; echo "\n"; @@ -322,7 +324,7 @@ echo " ".(round(escape($row['asr']),2))." \n"; echo " ".(round(escape($row['aloc']),2))." \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + $c = $c ? 0 : 1; $i++; } echo "\n"; @@ -331,4 +333,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_statistics_csv.php b/app/xml_cdr/xml_cdr_statistics_csv.php index d3d7501613..ee040f48ec 100644 --- a/app/xml_cdr/xml_cdr_statistics_csv.php +++ b/app/xml_cdr/xml_cdr_statistics_csv.php @@ -43,7 +43,7 @@ else { //show the column names on the first line $z = 0; - foreach($stats[1] as $key => $val) { + foreach ($stats[1] as $key => $val) { if ($z == 0) { echo '"'.$key.'"'; } @@ -56,9 +56,9 @@ else { //add the values to the csv $x = 0; - foreach($stats as $row) { + foreach ($stats as $row) { $z = 0; - foreach($row as $key => $val) { + foreach ($row as $key => $val) { if ($z == 0) { echo '"'.$stats[$x][$key].'"'; } diff --git a/app/xml_cdr/xml_cdr_statistics_inc.php b/app/xml_cdr/xml_cdr_statistics_inc.php index fc3446ae3b..9ed34f027a 100644 --- a/app/xml_cdr/xml_cdr_statistics_inc.php +++ b/app/xml_cdr/xml_cdr_statistics_inc.php @@ -76,37 +76,37 @@ //get post or get variables from http if (count($_REQUEST) > 0) { - $cdr_id = check_str($_REQUEST["cdr_id"]); - $missed = check_str($_REQUEST["missed"]); - $direction = check_str($_REQUEST["direction"]); - $caller_id_name = check_str($_REQUEST["caller_id_name"]); - $caller_id_number = check_str($_REQUEST["caller_id_number"]); - $caller_extension_uuid = check_str($_REQUEST["caller_extension_uuid"]); - $destination_number = check_str($_REQUEST["destination_number"]); - $context = check_str($_REQUEST["context"]); - $start_stamp_begin = check_str($_REQUEST["start_stamp_begin"]); - $start_stamp_end = check_str($_REQUEST["start_stamp_end"]); - $answer_stamp_begin = check_str($_REQUEST["answer_stamp_begin"]); - $answer_stamp_end = check_str($_REQUEST["answer_stamp_end"]); - $end_stamp_begin = check_str($_REQUEST["end_stamp_begin"]); - $end_stamp_end = check_str($_REQUEST["end_stamp_end"]); - $start_epoch = check_str($_REQUEST["start_epoch"]); - $stop_epoch = check_str($_REQUEST["stop_epoch"]); - $duration = check_str($_REQUEST["duration"]); - $billsec = check_str($_REQUEST["billsec"]); - $hangup_cause = check_str($_REQUEST["hangup_cause"]); - $uuid = check_str($_REQUEST["uuid"]); - $bleg_uuid = check_str($_REQUEST["bleg_uuid"]); - $accountcode = check_str($_REQUEST["accountcode"]); - $read_codec = check_str($_REQUEST["read_codec"]); - $write_codec = check_str($_REQUEST["write_codec"]); - $remote_media_ip = check_str($_REQUEST["remote_media_ip"]); - $network_addr = check_str($_REQUEST["network_addr"]); - $bridge_uuid = check_str($_REQUEST["network_addr"]); - $order_by = check_str($_REQUEST["order_by"]); - $order = check_str($_REQUEST["order"]); - if (strlen(check_str($_REQUEST["mos_comparison"])) > 0) { - switch(check_str($_REQUEST["mos_comparison"])) { + $cdr_id = $_REQUEST["cdr_id"]; + $missed = $_REQUEST["missed"]; + $direction = $_REQUEST["direction"]; + $caller_id_name = $_REQUEST["caller_id_name"]; + $caller_id_number = $_REQUEST["caller_id_number"]; + $caller_extension_uuid = $_REQUEST["caller_extension_uuid"]; + $destination_number = $_REQUEST["destination_number"]; + $context = $_REQUEST["context"]; + $start_stamp_begin = $_REQUEST["start_stamp_begin"]; + $start_stamp_end = $_REQUEST["start_stamp_end"]; + $answer_stamp_begin = $_REQUEST["answer_stamp_begin"]; + $answer_stamp_end = $_REQUEST["answer_stamp_end"]; + $end_stamp_begin = $_REQUEST["end_stamp_begin"]; + $end_stamp_end = $_REQUEST["end_stamp_end"]; + $start_epoch = $_REQUEST["start_epoch"]; + $stop_epoch = $_REQUEST["stop_epoch"]; + $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"]; + $bridge_uuid = $_REQUEST["network_addr"]; + $order_by = $_REQUEST["order_by"]; + $order = $_REQUEST["order"]; + if (strlen($_REQUEST["mos_comparison"]) > 0) { + switch($_REQUEST["mos_comparison"]) { case 'less': $mos_comparison = "<"; break; @@ -126,13 +126,14 @@ $mos_comparison = "<>"; break; } - } else { - $mos_comparison = ''; } - //$mos_comparison = check_str($_REQUEST["mos_comparison"]); - $mos_score = check_str($_REQUEST["mos_score"]); - if(permission_exists('xml_cdr_b_leg')){ - $leg = check_str($_REQUEST["leg"]); + else { + unset($mos_comparison); + } + //$mos_comparison = $_REQUEST["mos_comparison"]; + $mos_score = $_REQUEST["mos_score"]; + if (permission_exists('xml_cdr_b_leg')) { + $leg = $_REQUEST["leg"]; } $show_all = permission_exists('xml_cdr_all') && ($_REQUEST['showall'] == 'true'); } @@ -142,65 +143,151 @@ } //if we do not see b-leg then use only a-leg to generate statistics - if(!permission_exists('xml_cdr_b_leg')){ + if (!permission_exists('xml_cdr_b_leg')) { $leg = 'a'; } //build the sql where string if (!$show_all) { - $sql_where_ands[] = "domain_uuid = '".$_SESSION['domain_uuid']."'"; + $sql_where_ands[] = "domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; } if ($missed == true) { $sql_where_ands[] = "billsec = '0'"; } if (strlen($start_epoch) > 0 && strlen($stop_epoch) > 0) { - $sql_where_ands[] = "start_epoch BETWEEN ".$start_epoch." AND ".$stop_epoch." "; + $sql_where_ands[] = "start_epoch between :start_epoch and :stop_epoch"; + $parameters['start_epoch'] = $start_epoch; + $parameters['stop_epoch'] = $stop_epoch; + } + if (strlen($cdr_id) > 0) { + $sql_where_ands[] = "cdr_id like :cdr_id"; + $parameters['cdr_id'] = '%'.$cdr_id.'%'; + } + if (strlen($direction) > 0) { + $sql_where_ands[] = "direction = :direction"; + $parameters['direction'] = $direction; } - if (strlen($cdr_id) > 0) { $sql_where_ands[] = "cdr_id like '%".$cdr_id."%'"; } - if (strlen($direction) > 0) { $sql_where_ands[] = "direction = '".$direction."'"; } if (strlen($caller_id_name) > 0) { $mod_caller_id_name = str_replace("*", "%", $caller_id_name); - $sql_where_ands[] = "caller_id_name like '".$mod_caller_id_name."'"; + $sql_where_ands[] = "caller_id_name like :mod_caller_id_name"; + $parameters['mod_caller_id_name'] = $mod_caller_id_name; } if (strlen($caller_extension_uuid) > 0) { - $sql_where_ands[] = "extension_uuid = '".$caller_extension_uuid."'"; + $sql_where_ands[] = "extension_uuid = :caller_extension_uuid"; + $parameters['caller_extension_uuid'] = $caller_extension_uuid; } if (strlen($caller_id_number) > 0) { $mod_caller_id_number = str_replace("*", "%", $caller_id_number); - $sql_where_ands[] = "caller_id_number like '".$mod_caller_id_number."'"; + $sql_where_ands[] = "caller_id_number like :mod_caller_id_number"; + $parameters['mod_caller_id_number'] = $mod_caller_id_number; } if (strlen($destination_number) > 0) { $mod_destination_number = str_replace("*", "%", $destination_number); - $sql_where_ands[] = "destination_number like '".$mod_destination_number."'"; + $sql_where_ands[] = "destination_number like :mod_destination_number"; + $parameters['mod_destination_number'] = $mod_destination_number; + } + if (strlen($context) > 0) { + $sql_where_ands[] = "context like :context"; + $parameters['context'] = '%'.$context.'%'; + } + /* + if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { + $sql_where_ands[] = "start_stamp between :start_stamp_begin and :start_stamp_end"; + $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; + $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; + } + else if (strlen($start_stamp_begin) > 0) { + $sql_where_ands[] = "start_stamp >= :start_stamp_begin"; + $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; + } + else if (strlen($start_stamp_end) > 0) { + $sql_where_ands[] = "start_stamp <= :start_stamp_end"; + $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; + } + */ + if (strlen($answer_stamp_begin) > 0 && strlen($answer_stamp_end) > 0) { + $sql_where_ands[] = "answer_stamp between :answer_stamp_begin and :answer_stamp_end"; + $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; + $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; + } + else if (strlen($answer_stamp_begin) > 0) { + $sql_where_ands[] = "answer_stamp >= :answer_stamp_begin"; + $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; + } + else if (strlen($answer_stamp_end) > 0) { + $sql_where_ands[] = "answer_stamp <= :answer_stamp_end"; + $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; + } + if (strlen($end_stamp_begin) > 0 && strlen($end_stamp_end) > 0) { + $sql_where_ands[] = "end_stamp between :end_stamp_begin and :end_stamp_end"; + $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; + $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; + } + else if (strlen($end_stamp_begin) > 0) { + $sql_where_ands[] = "end_stamp >= :end_stamp_begin"; + $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; + } + else if (strlen($end_stamp_end) > 0) { + $sql_where_ands[] = "end_stamp <= :end_stamp_end"; + $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; + } + if (strlen($duration) > 0) { + $sql_where_ands[] = "duration like :duration"; + $parameters['duration'] = '%'.$duration.'%'; + } + if (strlen($billsec) > 0) { + $sql_where_ands[] = "billsec like :billsec"; + $parameters['billsec'] = '%'.$billsec.'%'; + } + if (strlen($hangup_cause) > 0) { + $sql_where_ands[] = "hangup_cause like :hangup_cause"; + $parameters['hangup_cause'] = '%'.$hangup_cause.'%'; + } + if (is_uuid($uuid)) { + $sql_where_ands[] = "uuid = :uuid"; + $parameters['uuid'] = $uuid; + } + if (is_uuid($bleg_uuid)) { + $sql_where_ands[] = "bleg_uuid = :bleg_uuid"; + $parameters['bleg_uuid'] = $bleg_uuid; + } + if (strlen($accountcode) > 0) { + $sql_where_ands[] = "accountcode = :accountcode"; + $parameters['accountcode'] = $accountcode; + } + if (strlen($read_codec) > 0) { + $sql_where_ands[] = "read_codec like :read_codec"; + $parameters['read_codec'] = '%'.$read_codec.'%'; + } + if (strlen($write_codec) > 0) { + $sql_where_ands[] = "write_codec like :write_codec"; + $parameters['write_codec'] = '%'.$write_codec.'%'; + } + if (strlen($remote_media_ip) > 0) { + $sql_where_ands[] = "remote_media_ip like :remote_media_ip"; + $parameters['remote_media_ip'] = '%'.$remote_media_ip.'%'; + } + if (strlen($network_addr) > 0) { + $sql_where_ands[] = "network_addr like :network_addr"; + $parameters['network_addr'] = '%'.$network_addr.'%'; + } + if (strlen($mos_comparison) > 0 && strlen($mos_score) > 0 ) { + $sql_where_ands[] = "rtp_audio_in_mos ".$mos_comparison." :mos_score"; + $parameters['mos_score'] = $mos_score; + } + if (strlen($leg) > 0) { + $sql_where_ands[] = "leg = :leg"; + $parameters['leg'] = $leg; } - if (strlen($context) > 0) { $sql_where_ands[] = "context like '%".$context."%'"; } - // if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { $sql_where_ands[] = "start_stamp BETWEEN '".$start_stamp_begin.":00.000' AND '".$start_stamp_end.":59.999'"; } - // else if (strlen($start_stamp_begin) > 0) { $sql_where_ands[] = "start_stamp >= '".$start_stamp_begin.":00.000'"; } - // else if (strlen($start_stamp_end) > 0) { $sql_where_ands[] = "start_stamp <= '".$start_stamp_end.":59.999'"; } - if (strlen($answer_stamp_begin) > 0 && strlen($answer_stamp_end) > 0) { $sql_where_ands[] = "answer_stamp BETWEEN '".$answer_stamp_begin.":00.000' AND '".$answer_stamp_end.":59.999'"; } - else if (strlen($answer_stamp_begin) > 0) { $sql_where_ands[] = "answer_stamp >= '".$answer_stamp_begin.":00.000'"; } - else if (strlen($answer_stamp_end) > 0) { $sql_where_ands[] = "answer_stamp <= '".$answer_stamp_end.":59.999'"; } - if (strlen($end_stamp_begin) > 0 && strlen($end_stamp_end) > 0) { $sql_where_ands[] = "end_stamp BETWEEN '".$end_stamp_begin.":00.000' AND '".$end_stamp_end.":59.999'"; } - else if (strlen($end_stamp_begin) > 0) { $sql_where_ands[] = "end_stamp >= '".$end_stamp_begin.":00.000'"; } - else if (strlen($end_stamp_end) > 0) { $sql_where_ands[] = "end_stamp <= '".$end_stamp_end.":59.999'"; } - if (strlen($duration) > 0) { $sql_where_ands[] = "duration like '%".$duration."%'"; } - if (strlen($billsec) > 0) { $sql_where_ands[] = "billsec like '%".$billsec."%'"; } - if (strlen($hangup_cause) > 0) { $sql_where_ands[] = "hangup_cause like '%".$hangup_cause."%'"; } - if (strlen($uuid) > 0) { $sql_where_ands[] = "uuid = '".$uuid."'"; } - if (strlen($bleg_uuid) > 0) { $sql_where_ands[] = "bleg_uuid = '".$bleg_uuid."'"; } - if (strlen($accountcode) > 0) { $sql_where_ands[] = "accountcode = '".$accountcode."'"; } - if (strlen($read_codec) > 0) { $sql_where_ands[] = "read_codec like '%".$read_codec."%'"; } - if (strlen($write_codec) > 0) { $sql_where_ands[] = "write_codec like '%".$write_codec."%'"; } - if (strlen($remote_media_ip) > 0) { $sql_where_ands[] = "remote_media_ip like '%".$remote_media_ip."%'"; } - if (strlen($network_addr) > 0) { $sql_where_ands[] = "network_addr like '%".$network_addr."%'"; } - if (strlen($mos_comparison) > 0 && strlen($mos_score) > 0 ) { $sql_where_ands[] = "rtp_audio_in_mos " . $mos_comparison . " ".$mos_score.""; } - if (strlen($leg) > 0) { $sql_where_ands[] = "leg='$leg'"; } //if not admin or superadmin, only show own calls if (!permission_exists('xml_cdr_domain')) { if (count($_SESSION['user']['extension']) > 0) { // extensions are assigned to this user // create simple user extension array - foreach ($_SESSION['user']['extension'] as $row) { $user_extensions[] = $row['user']; } + foreach ($_SESSION['user']['extension'] as $row) { + $user_extensions[] = $row['user']; + } // if both a source and destination are submitted, but neither are an assigned extension, restrict results if ( $caller_id_number != '' && @@ -208,22 +295,29 @@ array_search($caller_id_number, $user_extensions) === false && array_search($destination_number, $user_extensions) === false ) { - $sql_where_ors[] = "caller_id_number like '".$user_extension."'"; - $sql_where_ors[] = "destination_number like '".$user_extension."'"; - $sql_where_ors[] = "destination_number like '*99".$user_extension."'"; + $sql_where_ors[] = "caller_id_number like :user_extension"; + $sql_where_ors[] = "destination_number like :user_extension"; + $sql_where_ors[] = "destination_number like :star_99_user_extension"; + $parameters['user_extension'] = $user_extension; + $parameters['star_99_user_extension'] = '*99'.$user_extension; } // if source submitted is blank, implement restriction for assigned extension(s) if ($caller_id_number == '') { // if source criteria is blank, then restrict to assigned ext foreach ($user_extensions as $user_extension) { - if (strlen($user_extension) > 0) { $sql_where_ors[] = "caller_id_number like '".$user_extension."'"; } + if (strlen($user_extension) > 0) { + $sql_where_ors[] = "caller_id_number like :user_extension"; + $parameters['user_extension'] = $user_extension; + } } } // if destination submitted is blank, implement restriction for assigned extension(s) if ($destination_number == '') { foreach ($user_extensions as $user_extension) { if (strlen($user_extension) > 0) { - $sql_where_ors[] = "destination_number like '".$user_extension."'"; - $sql_where_ors[] = "destination_number like '*99".$user_extension."'"; + $sql_where_ors[] = "destination_number like :user_extension"; + $sql_where_ors[] = "destination_number like :star_99_user_extension"; + $parameters['user_extension'] = $user_extension; + $parameters['star_99_user_extension'] = '*99'.$user_extension; } } } @@ -250,28 +344,25 @@ $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; + function get_call_volume_between($start, $end, $where, $parameters) { $sql = "select count(*) as count, sum(billsec) as seconds from v_xml_cdr "; - $sql .= $where; - $sql .= " 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 array( - 'volume' => $row['count'], 'seconds' => $row['seconds'], - ); - } + $sql .= $where." "; + $sql .= "start_epoch between :start and :end "; + $parameters['start'] = $start; + $parameters['end'] = $end; + $database = new database; + $row = $database->select($sql, $parameters, 'row'); + if (is_array($row) && @sizeof($row) != 0) { + return array( + 'volume' => $row['count'], + 'seconds' => $row['seconds'], + ); } return false; } - function append_stats(&$stats, $hours, $start_epoch, $stop_epoch){ - global $db, $sql_where, $missed; + function append_stats(&$stats, $hours, $start_epoch, $stop_epoch) { + global $sql_where, $parameters, $missed; $i = count($stats); @@ -280,45 +371,46 @@ $stats[$i]['stop_stamp'] = date('Y-m-d h:n:s', $stop_epoch); $stats[$i]['start_epoch'] = $start_epoch; $stats[$i]['stop_epoch'] = $stop_epoch; - $stat_range = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $sql_where); + $stat_range = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $sql_where, $parameters); $stats[$i]['volume'] = $stat_range ? $stat_range['volume'] : 0; $stats[$i]['seconds'] = $stat_range ? $stat_range['seconds'] : 0; $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; - $stats[$i]['avg_sec'] = ($stats[$i]['volume']==0) ? 0 : $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_sec'] = $stats[$i]['volume'] == 0 ? 0 : $stats[$i]['seconds'] / $stats[$i]['volume']; - if($missed) { - // we select only missed calls at first plase. so there no reasons to select it again. + if ($missed) { + //we select only missed calls at first place - no reasons to select it again $stats[$i]['missed'] = $stats[$i]['volume']; } else { - $where = $sql_where . "billsec = '0' and "; - $stat_range = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); + $where = $sql_where."billsec = '0' and "; + $stat_range = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where, $parameters); $stats[$i]['missed'] = $stat_range ? $stat_range['volume'] : 0; } $delta_min = ($stop_epoch - $start_epoch) / 60; - $success_volume = ($stats[$i]['volume']==0) ? 0 : ($stats[$i]['volume'] - $stats[$i]['missed']); + $success_volume = $stats[$i]['volume'] == 0 ? 0 : ($stats[$i]['volume'] - $stats[$i]['missed']); - // Calls per minute (answered) + //calls per minute (answered) $stats[$i]['cpm_ans'] = $success_volume / $delta_min; - // Calls per minute + //calls per minute $stats[$i]['avg_min'] = $stats[$i]['volume'] / $delta_min; //answer / seizure ratio - $stats[$i]['asr'] = ($stats[$i]['volume']==0) ? 0 : ($success_volume / $stats[$i]['volume'] * 100); + $stats[$i]['asr'] = $stats[$i]['volume'] == 0 ? 0 : ($success_volume / $stats[$i]['volume'] * 100); //average length of call - $stats[$i]['aloc'] = ($success_volume==0) ? 0 : $stats[$i]['minutes'] / $success_volume; + $stats[$i]['aloc'] = $success_volume == 0 ? 0 : $stats[$i]['minutes'] / $success_volume; } - if (strlen(check_str($_GET['start_stamp_begin'])) > 0 && strlen(check_str($_GET['start_stamp_end'])) > 0 ) { - $start_date = new DateTime(check_str($_GET['start_stamp_begin'])); - $end_date = new DateTime(check_str($_GET['start_stamp_end'])); + if (strlen($_GET['start_stamp_begin']) > 0 && strlen($_GET['start_stamp_end']) > 0 ) { + $start_date = new DateTime($_GET['start_stamp_begin']); + $end_date = new DateTime($_GET['start_stamp_end']); $time = $end_date->getTimestamp(); $time = $time - $time % 3600; $hours = floor(($end_date->getTimestamp() - $start_date->getTimestamp()) / 3600); - } else { + } + else { //round down to the nearest hour $time = time() - time() % 3600; $hours = 23; @@ -342,25 +434,24 @@ } //call info for entire period - if (strlen(check_str($_GET['start_stamp_begin'])) > 0 && strlen(check_str($_GET['start_stamp_end'])) > 0 ) { - $start_epoch = new DateTime(check_str($_GET['start_stamp_begin'])); - $stop_epoch = new DateTime(check_str($_GET['start_stamp_end'])); + if (strlen($_GET['start_stamp_begin']) > 0 && strlen($_GET['start_stamp_end']) > 0 ) { + $start_epoch = new DateTime($_GET['start_stamp_begin']); + $stop_epoch = new DateTime($_GET['start_stamp_end']); $days = $start_epoch->diff($stop_epoch)->d; append_stats($stats, 24 * $days, $start_epoch->getTimestamp(), $stop_epoch->getTimestamp() ); } else { $stop_epoch = time(); - append_stats($stats, 24, $stop_epoch - $seconds_day, $stop_epoch ); - append_stats($stats, 24 * 7, $stop_epoch - $seconds_week, $stop_epoch ); + append_stats($stats, 24, $stop_epoch - $seconds_day, $stop_epoch ); + append_stats($stats, 24 * 7, $stop_epoch - $seconds_week, $stop_epoch ); append_stats($stats, 24 * 30, $stop_epoch - $seconds_month, $stop_epoch ); } //show the graph - $x = 0; foreach ($stats as $row) { $graph['volume'][$x][] = $row['start_epoch'] * 1000; - $graph['volume'][$x][] = $row['volume']/1; + $graph['volume'][$x][] = $row['volume'] / 1; if ($x == $hours) { break; } $x++; } @@ -381,14 +472,14 @@ $x = 0; foreach ($stats as $row) { $graph['missed'][$x][] = $row['start_epoch'] * 1000; - $graph['missed'][$x][] = $row['missed']/1; + $graph['missed'][$x][] = $row['missed'] / 1; if ($x == $hours) { break; } $x++; } $x = 0; foreach ($stats as $row) { $graph['asr'][$x][] = $row['start_epoch'] * 1000; - $graph['asr'][$x][] = round($row['asr'],2)/100; + $graph['asr'][$x][] = round($row['asr'],2) / 100; if ($x == $hours) { break; } $x++; } @@ -399,4 +490,5 @@ if ($x == $hours) { break; } $x++; } -?> + +?> \ No newline at end of file