📄 callmonitor.module
字号:
<?php/** * @file * Functions for the interface to the call monitor recordings *//** * Class for Callmonitor */class Callmonitor { /* * rank (for prioritizing modules) */ function rank() { $rank = 2; return $rank; } /* * init */ function init() { } /* * Adds menu item to nav menu * * @param $args * Common arguments */ function navMenu($args) { $ret .= " <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Callmonitor&f=display'>" . _("Call Monitor") . "</a></small></small></p>"; return $ret; } /* * Acts on the selected call monitor recordings in the method indicated by the action and updates page * * @param $args * Common arguments */ function recAction($args) { // args $m = getArgument($args,'m'); $a = getArgument($args,'a'); $q = getArgument($args,'q'); $start = getArgument($args,'start'); $span = getArgument($args,'span'); $order = getArgument($args,'order'); $sort = getArgument($args,'sort'); $duration_filter = getArgument($args,'duration_filter'); // get files $files = array(); foreach($_REQUEST as $key => $value) { if (preg_match('/selected/',$key)) { array_push($files, $value); } } if ($a=='delete') { $this->deleteRecData($files); } if ($a=='ignore') { $start = 0; setcookie("ari_duration_filter", $duration_filter, time()+365*24*60*60); } // redirect to see updated page $ret .= " <head> <script> <!-- window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "&q=" . $q . "&start=" . $start . "&span=" . $span . "&order=" . $order . "&sort=" . $sort . "&duration_filter=" . $duration_filter . "\" // --> </script> </head>"; return $ret; } /* * Displays stats page * * @param $args * Common arguments */ function display($args) { global $ASTERISK_CALLMONITOR_PATH; global $CALLMONITOR_ALLOW_DELETE; global $AJAX_PAGE_REFRESH_ENABLE; $display = new DisplaySearch(); // get the search string $m = getArgument($args,'m'); $f = getArgument($args,'f'); $q = getArgument($args,'q'); $start = getArgument($args,'start'); $span = getArgument($args,'span'); $order = getArgument($args,'order'); $sort = getArgument($args,'sort'); $duration_filter = getArgument($args,'duration_filter'); $start = $start=='' ? 0 : $start; $span = $span=='' ? 15 : $span; $order = $order=='' ? 'calldate' : $order; $sort = $sort=='' ? 'desc' : $sort; $displayname = $_SESSION['ari_user']['displayname']; $extension = $_SESSION['ari_user']['extension']; // get data $record_count = $this->getCdrCount($q,$duration_filter); $data = $this->getCdrData($q,$duration_filter,$start,$span,$order,$sort); // get the call monitor recording files $paths = split(';',$ASTERISK_CALLMONITOR_PATH); foreach($paths as $key => $path) { if (!is_dir($path)) { $_SESSION['ari_error'] .= sprintf(_("Path is not a directory: %s"),$path) . "<br>"; } } $recordings = $this->getRecordings($ASTERISK_CALLMONITOR_PATH,$data); // build controls if ($CALLMONITOR_ALLOW_DELETE) { $controls .= " <button class='infobar' type='submit' onclick=\"document.callmonitor_form.a.value='delete'\"> " . _("delete") . " </button> "; } $controls .= " <small>" . _("duration") . "</small> <input name='duration_filter' type='text' size=4 maxlength=8 value='" . $_COOKIE['ari_duration_filter'] . "'> <button class='infobar' type='submit' onclick=\"document.callmonitor_form.a.value='ignore'\"> " . _("ignore") . " </button>"; // table header if ($CALLMONITOR_ALLOW_DELETE) { $recording_delete_header = "<th></th>"; } $fields[0]['field'] = "calldate"; $fields[0]['text'] = _("Date"); $fields[1]['field'] = "calldate"; $fields[1]['text'] = _("Time"); $fields[2]['field'] = "clid"; $fields[2]['text'] = _("Caller ID"); $fields[3]['field'] = "src"; $fields[3]['text'] = _("Source"); $fields[4]['field'] = "dst"; $fields[4]['text'] = _("Destination"); $fields[5]['field'] = "dcontext"; $fields[5]['text'] = _("Context"); $fields[6]['field'] = "duration"; $fields[6]['text'] = _("Duration"); $i = 0; while ($fields[$i]) { $field = $fields[$i]['field']; $text = $fields[$i]['text']; if ($order==$field) { if ($sort=='asc') { $currentSort = 'desc'; $arrowImg = "<img src='theme/images/arrow-asc.gif' alt='sort'>"; } else { $currentSort = 'asc'; $arrowImg = "<img src='theme/images/arrow-desc.gif' alt='sort'>"; } if ($i==1) { $arrowImg = ''; } } else { $arrowImg = ''; $currentSort = 'desc'; } $unicode_q = urlencode($q); $recording_header .= "<th><a href=" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "&f=" . $f . "&q=" . $unicode_q . "&order=" . $field . "&sort=" . $currentSort . ">" . $text . $arrowImg . "</a></th>"; $i++; } $recording_header .= "<th>" . _("Monitor") . "</th>"; // table body foreach($data as $key=>$value) { // recording file $recording = $recordings[$value['uniqueid'] . $value['calldate']]; // date and time $buf = split(' ', $value[calldate]); $date = $buf[0]; $time = $buf[1]; // recording delete checkbox if ($CALLMONITOR_ALLOW_DELETE) { $recording_delete_checkbox = "<td class='checkbox'><input type=checkbox name='selected" . ++$i . "' value=" . $recording . "></td>"; } $recordingLink = ''; if (is_file($recordings[$value['uniqueid'] . $value['calldate']])) { $recordingLink = "<a href='#' onClick=\"javascript:popUp('misc/recording_popup.php?recording=" . $recording . "&date=" . $date . "&time=" . $time . "'); return false;\">" . _("play") . "</a>"; } $recording_body .= "<tr> " . $recording_delete_checkbox . " <td width=70>" . $date . "</td> <td>" . $time . "</td> <td>" . $value[clid] . "</td> <td>" . $value[src] . "</td> <td>" . $value[dst] . "</td> <td>" . $value[dcontext] . "</td> <td width=90>" . $value[duration] . " sec</td> <td>" . $recordingLink . "</td> </tr>"; } if (!count($data)) { $recording_body .= "<tr></tr>"; } // options $url_opts = array(); $url_opts['sort'] = $sort; $url_opts['order'] = $order; $url_opts['duration_filter'] = $duration_filter; // build page content $ret .= checkErrorMessage(); // ajax page refresh script if ($AJAX_PAGE_REFRESH_ENABLE) { $ret .= ajaxRefreshScript($args); } // header if ($_SESSION['ari_user']['admin_callmonitor']) { $header_text = _("Call Monitor"); } else { $header_text = sprintf(_("Call Monitor for %s (%s)"),$displayname,$extension); } $ret .= $display->displayHeaderText($header_text); $ret .= $display->displaySearchBlock('left',$m,$q,$url_opts,true); // start form if ($CALLMONITOR_ALLOW_DELETE) { $ret .= " <form name='callmonitor_form' action='" . $_SESSION['ARI_ROOT'] . "' method='GET'> <input type=hidden name=m value=" . $m . "> <input type=hidden name=f value=recAction> <input type=hidden name=a value=''> <input type=hidden name=q value=" . $q . "> <input type=hidden name=start value=" . $start . "> <input type=hidden name=span value=" . $span . "> <input type=hidden name=order value=" . $order . "> <input type=hidden name=sort value=" . $sort . ">"; } $ret .= $display->displayInfoBarBlock($controls,$q,$start,$span,$record_count); // javascript for popup and message actions $ret .= " <SCRIPT LANGUAGE='JavaScript'> <!-- Begin function popUp(URL) { eval(\"page = window.open(URL, 'play', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=324,height=110');\"); } function checkAll(form,set) { var elem = 0; var i = 0; while (elem = form.elements[i]) { if (set) { elem.checked = true; } else { elem.checked = false; } i++; } return true; } // End --> </script>"; // call monitor delete recording controls if ($CALLMONITOR_ALLOW_DELETE) { $ret .= " <table> <tr> <td> <small>" . _("select") . ": </small> <small><a href='' OnClick=\"checkAll(document.callmonitor_form,true); return false;\">" . _("all") . "</a></small> <small><a href='' OnClick=\"checkAll(document.callmonitor_form,false); return false;\">" . _("none") . "</a></small> </td> </tr> </table>"; } else { $ret .= "<br>"; } // table $ret .= " <table class='callmonitor'> <tr> " . $recording_delete_header . " " . $recording_header . " </tr> " . $recording_body . " </table>"; $start = getArgument($args,'start'); $span = getArgument($args,'span'); $order = getArgument($args,'order'); $sort = getArgument($args,'sort');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -