«Допиливаем» Asterisk CDR Viewer под себя (2023)

j3st3r

17 мин

61K

Asterisk *Разработка систем связи *

«Допиливаем» Asterisk CDR Viewer под себя (1)

«Я профессионал, потому что не ленюсь искать информацию в google» — сказал мне однажды коллега.

А я поленился и начал «допиливать» CDR Viewer под себя, даже не посмотрев хотя бы вот это.
А может и не в лени дело, просто было интересно… в общем, что из этого вышло можно посмотреть под катом:)

Споры о том, что лучше использовать в качестве офисной АТС — asterisk (с веб-интерфейсом или без, хотя это отдельная тема для споров) или какую-то коробку типа Panasonic, которых на рынок выкинуто немеренное количество — не утихают до сих пор, но топик не об этом, лично для себя я уже давно определился. Хотелось бы поделиться с сообществом своим вариантом придания интерфейсу просмотра статистики дополнительного фунционала.

В качестве «подопытного» я использовал FreePBX Distro (FreePBX 2.11, Asterisk 11, CentOS 6.5), скачанный с официального сайта проекта. Выбор был продиктован тем, что разработчики FreePBX уже позаботились о прикручивании БД к Asterisk и структура хранения записей в общем-то меня устраивает. Хотя процедура «прикручивания» MySQL или какой-либо другой базы к Asterisk была описана ни раз и ни два, о чем можно почитать например здесь, все же в целях экономии времени я решил этого не делать.

За основу был взят Asterisk CDR Viewer (если не нужно каких-то сверхмудреных отчетов — то вполне себе пригодная и простенькая статистика), скачать можно тут.

Установка CDR Viewer не представляется какой-то нетривиальной задачей.

Переходим в нужную нам директорию, качаем архив, извлекаем файлы из архива:

cd /var/wwwwget https://asterisk-cdr-viewer.googlecode.com/files/asterisk-cdr-viewer-1.0.2.tgztar -xzvf asterisk-cdr-viewer-1.0.2.tgz

Переносим файлик алиаса в папку с apache2:

cp /var/www/html/asterisk-cdr-viewer/contrib/httpd/asterisk-cdr-viewer.conf /etc/apache2/conf.d/asterisk-cdr-viewer.conf

Изменяем настройки подключения к БД для Asterisk-CDR-viewer

cd /var/www/asterisk-cdr-viewer/include/vim config.inc.php

Нужно поменять параметры в соответствии с текущей конфигурацией вашей базы:

$db_user = '[MySQL пользователь]';
$db_pass = '[MySQL пароль]';
$db_name = '[Имя базы]';

Делаем рестарт веб-сервера:

service apache2 restart

Теперь в браузере набирая [адрес asteridk-сервера]/acdr/ попадаем на страницу статистики.

Первое, что мне захотелось сделать — прикрутить авторизацию для просмотра этой самой статистики, для этого воспользуемся htpasswd.
Если не установлена —

aptitude install apache2-utils

Переходим в /etc/apache2 и созадем юзер/пароль для статистики:

htpasswd -c passwordfile username

Вводим пароль в диалоге, который предлагает htpasswd и получаем файл «passwordfile» с юзером «username» и сгенерированным зашифрованным паролем.

Далее в /etc/apache2/conf.d изменяем asterisk-cdr-viewer.conf, раскомментрировав строки авторизации, в результате получаем:

Alias /acdr/ "/var/www/asterisk-cdr-viewer/"

<Location "/acdr/">
<------>AuthName «Asterisk-CDR-Stat»
<------>AuthType Basic
<------>AuthUserFile /etc/apache2/passwordfile
<------>AuthGroupFile /dev/null
<------>require valid-user

Рестартуем apache2 и при входе на страницу видим окно авторизации:

«Допиливаем» Asterisk CDR Viewer под себя (2)

Следующее, что был сделано — это прослушивание разговоров из веб-интерфейса.

1) Для прослушивания звонков добавляем две иконки в каталог /var/www/asterisk-cdr-viewer/templates/images (play и stop)

2) Добавляем в /var/www/asterisk-cdr-viewer/templates/header.tpl.php объявление js-функции для оптимизации производительности;

В результате получаем:


<head><title>Asterisk Call Detail Records</title><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /><link rel="stylesheet" href="style/screen.css" type="text/css" media="screen" /><link rel="shortcut icon" href="templates/images/favicon.ico" /><script type="text/javascript"/>function audioPreview(e,cnc) { var uri = e.attributes.getNamedItem('data-uri').value; var audioElement; // 1 if not exists audio control, then create it: if (!(audioElement = document.getElementById('au_preview'))) { audioElement = document.createElement('audio'); audioElement.id = 'au_preview'; audioElement.controls = true; audioElement.style.display = 'none'; document.body.appendChild(audioElement); } else { // 2 need to stop and hide if playing: var prevIcon = audioElement.parentNode.previousSibling; prevIcon.src = 'templates/images/play.png'; prevIcon.onclick = function(){ return audioPreview(prevIcon,false);}; } if (('undefined'===typeof cnc)||(!cnc)) { //1. to show e.nextSibling.appendChild(audioElement); audioElement.src = uri; audioElement.style.display = 'block'; audioElement.play(); e.onclick = function(){ return audioPreview(e,true); }; e.src = 'templates/images/stop.png'; } else { //2. to hide audioElement.pause(); audioElement.style.display = 'none'; e.onclick = function(){ return audioPreview(e,false); }; e.src = 'templates/images/play.png'; }}</script></head><body><table id="header"><tr><td id="header_logo" rowspan="2" align="left"><a href="/" title="Home"><img src="" alt="Asterisk CDR Viewer" /></a></td><td id="header_title">Asterisk CDR Viewer</td><td align='right'><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=XVUVZY5D922JJ&lc=RU&item_name=i%2eo%2e&item_number=asterisk%2dcdr&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"><img src="http://habrastorage.org/getpro/habr/post_images/92a/7cd/b91/92a7cdb914a8e942ca23d0ec49367cc3.gif" align="center"/></a></td></tr><tr><td id="header_subtitle"></td><td align='right'><?phpif ( strlen(getenv('REMOTE_USER')) ) {echo "<a href='/acdr/index.php?action=logout'>logout: ". getenv('REMOTE_USER') ."</a>";}?></td></tr></table>

3)

Изменяем /var/www/asterisk-cdr-viewer/include/functions.inc.php, модифицируя конструкции echo: к иконке динамика добавляем небольшой кусочек необходимой разметки

<head><title>Asterisk Call Detail Records</title><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /><link rel="stylesheet" href="style/screen.css" type="text/css" media="screen" /><link rel="shortcut icon" href="templates/images/favicon.ico" /><script type="text/javascript"/>function audioPreview(e,cnc) { var uri = e.attributes.getNamedItem('data-uri').value; var audioElement; // 1 if not exists audio control, then create it: if (!(audioElement = document.getElementById('au_preview'))) { audioElement = document.createElement('audio'); audioElement.id = 'au_preview'; audioElement.controls = true; audioElement.style.display = 'none'; document.body.appendChild(audioElement); } else { // 2 need to stop and hide if playing: var prevIcon = audioElement.parentNode.previousSibling; prevIcon.src = 'templates/images/play.png'; prevIcon.onclick = function(){ return audioPreview(prevIcon,false);}; } if (('undefined'===typeof cnc)||(!cnc)) { //1. to show e.nextSibling.appendChild(audioElement); audioElement.src = uri; audioElement.style.display = 'block'; audioElement.play(); e.onclick = function(){ return audioPreview(e,true); }; e.src = 'templates/images/stop.png'; } else { //2. to hide audioElement.pause(); audioElement.style.display = 'none'; e.onclick = function(){ return audioPreview(e,false); }; e.src = 'templates/images/play.png'; }}</script></head><body><table id="header"><tr><td id="header_logo" rowspan="2" align="left"><a href="/" title="Home"><img src="" alt="Asterisk CDR Viewer" /></a></td><td id="header_title">Asterisk CDR Viewer</td><td align='right'><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=XVUVZY5D922JJ&lc=RU&item_name=i%2eo%2e&item_number=asterisk%2dcdr&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"><img src="" align="center"/></a></td></tr><tr><td id="header_subtitle"></td><td align='right'><?phpif ( strlen(getenv('REMOTE_USER')) ) {echo "<a href='/acdr/index.php?action=logout'>logout: ". getenv('REMOTE_USER') ."</a>";}?></td></tr></table>root@sip:/var/www/asterisk-cdr-viewer/templates# root@sip:/var/www/asterisk-cdr-viewer/include# cat functions.inc.php<?php/* Recorded file */function formatFiles($row) {global $system_monitor_dir, $system_fax_archive_dir, $system_audio_format, $system_arch_audio_format;/* File name formats, please specify: *//* caller-called-timestamp.wav *//* $recorded_file = $row['src'] .'-'. $row['dst'] .'-'. $row['call_timestamp']*//* ============================================================================ *//* ends at the uniqueid.wav, for example: date-time-uniqueid.wav thanks to Beto Reyes*//*$recorded_file = glob($system_monitor_dir . '/*' . $row['uniqueid'] . '.' . $system_audio_format);if (count($recorded_file)>0) {$recorded_file = basename($recorded_file[0],".$system_audio_format");} else {$recorded_file = $row['uniqueid'];}*//* ============================================================================ *//* This example for multi-directory archive without uniqueid, named by format:<date>/<time>_<caller>-<destination>.<filetype>example: (tree /var/spool/asterisk/monitor)|-- 2012.09.12| |-- 10-37_4952704601-763245.ogg| `-- 10-43_106-79236522173.ogg`-- 2012.09.13|-- 11-42_101-79016410692.ogg|-- 12-43_104-671554.ogg`-- 15-49_109-279710.oggAdded by BAXMAH (pcm@ritm.omsk.ru)*//* $record_datetime = DateTime::createFromFormat('Y-m-d G:i:s', $row['calldate']); $recorded_file = date_format($record_datetime, 'Y.m.d/G-i') .'_'. $row['src'] .'-'. $row['dst'];*//* ============================================================================ *//*This is a multi-dir search script for filenames like "/var/spool/asterisk/monitor/dir1/dir2/dir3/*uniqueid*.*"Doesn't matter, WAV, MP3 or other file format, only UNIQID is required at the end of the filename ;--------------------------------------------------------------------------- example: (tree /var/spool/asterisk/monitor) |-- in | |-- 4951234567 | | `-- 20120101_234231_4956401234_to_74951234567_1307542950.0.wav | `-- 4997654321 | `-- 20120202_234231_4956401234_to_74997654321_1303542950.0.wav `-- out |-- msk | `-- 20120125_211231_4956401234_to_74951234567_1307542950.0.wav `-- region `-- 20120112_211231_4956405570_to_74952210533_1307542950.0.wav 6 directories, 4 files;---------------------------------------------------------------------------- added by Dein admin@sadmin.ru *///************ Get a list of subdirectories as array to search by glob function **************if (!function_exists('get_dir_list')) {function get_dir_list($dir){global $dirlist;$dirlist=array();if (!function_exists('find_dirs_recursive')) {function find_dirs_recursive($sdir) {global $dirlist;foreach(glob($sdir) as $filename) {//echo $filename;if(is_dir($filename)) {$dirlist[]=$filename;find_dirs_recursive($filename."/*");};//endif};//endforeach}; //endfunc };//endif existsfind_dirs_recursive($dir."/*");};//endfunc}//*************** Main function ************if (!function_exists('find_record_by_uniqid')) {function find_record_by_uniqid($path,$uniqid){global $dirlist;if (sizeof($dirlist) == 0 ){get_dir_list($path);};//endif size==0if (sizeof($dirlist) == 0 ) {return "SOME ERROR, dirlist is empty";};$found = "NOTHING FOUND";foreach ($dirlist as $curdir) {$res=glob($curdir."/*".$uniqid.".*");if ($res) {$found=$res[0]; break;};};//endforeach$res=str_replace($path,"",$found);//cut $path from full filename return $res;//to be compartable with func. formatFiles($row)};//endfunc}$recorded_file = find_record_by_uniqid($system_monitor_dir,$row['uniqueid']);/* ============================================================================ *//* uniqueid.wav *///$recorded_file = $row['filename'];/* ============================================================================ */if (file_exists("$system_monitor_dir/$recorded_file.$system_audio_format")) {// insert here:echo " <td class=\"record_col\"><div class=\"record_ctrl\"><a href=\"download.php?audio=$recorded_file.$system_audio_format\" title=\"Listen to call recording\"><img src= recording\" /></a><img class=\"record_preview_icon\" src= onclick=\"audioPreview(this,false);\"/><div class=\"record_preview_lt\"></div></div></td>\n";} elseif ( isset($system_arch_audio_format) and file_exists("$system_monitor_dir/$recorded_file.$system_audio_format.$system_arch_audio_format")) {echo " <td class=\"record_col\"><a href=\"download.php?arch=$recorded_file.$system_audio_format.$system_arch_audio_format\" title=\"Download archive\"><img src= recording\" /></a></td>\n";} elseif (file_exists("$system_fax_archive_dir/$recorded_file.tif")) {echo " <td class=\"record_col\"><a href=\"download.php?fax=$recorded_file.tif\" title=\"View FAX image\"><img src= image\" /></a></td>\n";} elseif (file_exists("$system_monitor_dir/$recorded_file")) {// insert here:echo " <td class=\"record_col\"><div class=\"record_ctrl\"><a href=\"download.php?audio=$recorded_file\" title=\"Listen to call recording\"><img src= recording\" /></a><img class=\"record_preview_icon\" src= onclick=\"audioPreview(this,false);\"/><div class=\"record_preview_lt\"></div></div></td>\n";} else {echo " <td class=\"record_col\"></td>\n";}}/* CDR Table Display Functions */function formatCallDate($calldate,$uniqueid) {echo " <td class=\"record_col\"><abbr title=\"UniqueID: $uniqueid\">$calldate</abbr></td>\n";}function formatChannel($channel) {$trunk_name = preg_replace('/(.*)-[^-]+$/','$1',$channel);echo " <td class=\"record_col\"><abbr title=\"Channel: $channel\">$trunk_name</abbr></td>\n";}function formatClid($clid) {$clid_only = explode(' <', $clid, 2);$clid = htmlspecialchars($clid_only[0]);echo " <td class=\"record_col\">$clid</td>\n";}function formatSrc($src,$clid) {if (empty($src)) {echo " <td class=\"record_col\">UNKNOWN</td>\n";} else {$src = htmlspecialchars($src);$clid = htmlspecialchars($clid);echo " <td class=\"record_col\"><abbr title=\"Caller*ID: $clid\">$src</abbr></td>\n";}}function formatApp($app, $lastdata) {echo " <td class=\"record_col\"><abbr title=\"Application: $app($lastdata)\">$app</abbr></td>\n";}function formatDst($dst, $dcontext) {global $rev_lookup_url;if (strlen($dst) == 11 and strlen($rev_lookup_url) > 0 ) {$rev = str_replace('%n', $dst, $rev_lookup_url);echo " <td class=\"record_col\"><abbr title=\"Destination Context: $dcontext\"><a href=\"$rev\" target=\"reverse\">$dst</a></abbr></td>\n";} else {echo " <td class=\"record_col\"><abbr title=\"Destination Context: $dcontext\">$dst</abbr></td>\n";}}function formatDisposition($disposition, $amaflags) {switch ($amaflags) {case 0:$amaflags = 'DOCUMENTATION';break;case 1:$amaflags = 'IGNORE';break;case 2:$amaflags = 'BILLING';break;case 3:default:$amaflags = 'DEFAULT';}echo " <td class=\"record_col\"><abbr title=\"AMA Flag: $amaflags\">$disposition</abbr></td>\n";}function formatDuration($duration, $billsec) {$duration = sprintf('%02d', intval($duration/60)).':'.sprintf('%02d', intval($duration%60));$billduration = sprintf('%02d', intval($billsec/60)).':'.sprintf('%02d', intval($billsec%60));echo " <td class=\"record_col\"><abbr title=\"Billing Duration: $billduration\">$duration</abbr></td>\n";}function formatUserField($userfield) {echo " <td class=\"record_col\">$userfield</td>\n";}function formatAccountCode($accountcode) {echo " <td class=\"record_col\">$accountcode</td>\n";}/* Asterisk RegExp parser */function asteriskregexp2sqllike( $source_data, $user_num ) {$number = $user_num;if ( strlen($number) < 1 ) {$number = $_REQUEST[$source_data];}if ( '__' == substr($number,0,2) ) {$number = substr($number,1);} elseif ( '_' == substr($number,0,1) ) {$number_chars = preg_split('//', substr($number,1), -1, PREG_SPLIT_NO_EMPTY);$number = '';foreach ($number_chars as $chr) {if ( $chr == 'X' ) {$number .= '[0-9]';} elseif ( $chr == 'Z' ) {$number .= '[1-9]';} elseif ( $chr == 'N' ) {$number .= '[2-9]';} elseif ( $chr == '.' ) {$number .= '.+';} elseif ( $chr == '!' ) {$_REQUEST[ $source_data .'_neg' ] = 'true';} else {$number .= $chr;}}$_REQUEST[ $source_data .'_mod' ] = 'asterisk-regexp';}return $number;}/* empty() wrapper. Thanks to Mikael Carlsson. */function is_blank($value) {return empty($value) && !is_numeric($value);}/* Money formatthanks to Shiena Tadeo*/ function formatMoney($number, $cents = 2) { // cents: 0=never, 1=if needed, 2=alwaysglobal $callrate_currency;if (is_numeric($number)) { // a numberif (!$number) { // zero$money = ($cents == 2 ? '0.00' : '0'); // output zero} else { // valueif (floor($number) == $number) { // whole number$money = number_format($number, ($cents == 2 ? 2 : 0)); // format} else { // cents$money = number_format(round($number, 2), ($cents == 0 ? 0 : 2)); // format} // integer or decimal} // valueecho "<td class=\"chart_data\">$callrate_currency<span>$money</span></td>\n";} else {echo "<td class=\"chart_data\"></td>\n";}} // formatMoney/* CallRatereturn callrate array [ areacode, rate, description, bill type, total_rate] */function callrates($dst,$duration,$file) {global $callrate_csv_file, $callrate_cache;if ( strlen($file) == 0 ) {$file = $callrate_csv_file;if ( strlen($file) == 0 ) {return array('','','','','');}}if ( ! array_key_exists( $file, $callrate_cache ) ) {$callrate_cache[$file] = array();$fr = fopen($file, "r") or die("Can not open callrate file ($file).");while(($fr_data = fgetcsv($fr, 1000, ",")) !== false) {$callrate_cache[$file]["$fr_data[0]"] = array( $fr_data[1], $fr_data[2], $fr_data[3] );}fclose($fr);}for ( $i = strlen($dst); $i > 0; $i-- ) {if ( array_key_exists( substr($dst,0,$i), $callrate_cache[$file] ) ) {$call_rate = 0;if ( $callrate_cache[$file][substr($dst,0,$i)][2] == 's' ) {// per second$call_rate = $duration * ($callrate_cache[$file][substr($dst,0,$i)][0] / 60);} elseif ( $callrate_cache[$file][substr($dst,0,$i)][2] == 'c' ) {// per call$call_rate = $callrate_cache[$file][substr($dst,0,$i)][0];} elseif ( $callrate_cache[$file][substr($dst,0,$i)][2] == '1m+s' ) {// 1 minute + per secondif ( $duration < 60) {$call_rate = $callrate_cache[$file][substr($dst,0,$i)][0];} else {$call_rate = $callrate_cache[$file][substr($dst,0,$i)][0] + ( ($duration-60) * ($callrate_cache[$file][substr($dst,0,$i)][0] / 60) );}} else {//( $callrate_cache[substr($dst,0,$i)][2] == 'm' ) {// per minute$call_rate = intval($duration/60);if ( $duration%60 > 0 ) {$call_rate++;}$call_rate = $call_rate*$callrate_cache[$file][substr($dst,0,$i)][0];}return array(substr($dst,0,$i),$callrate_cache[$file][substr($dst,0,$i)][0],$callrate_cache[$file][substr($dst,0,$i)][1],$callrate_cache[$file][substr($dst,0,$i)][2],$call_rate);}}return array (0,0,'unknown','unknown',0);}?>

4)

Дополняем файл стилей /var/www/asterisk-cdr-viewer/style/screen.css


/* HTML tag styles */a {cursor : pointer;}abbr[title] {border-style : none none dashed;border-width : medium medium 1px;border-bottom-color : #000000;cursor : help; white-space : nowrap;}body {background-color : #fff;/* Fix for M$ IE < 7 CSS hover */ behavior : url('style/csshover.htc');color : #000;font : 65% Verdana, Arial, Helvetica, sans-serif;margin : 0;padding : 0;}img {border-width : 0;}/* ID styles */#header {background-image : url('../templates/images/header_gradient.png');background-repeat : repeat-x;margin : 0;padding-left : 5%;padding-right : 10%;position : fixed;width : 100%;z-index : 50;}#header_logo {height: 105px;width: 121px;vertical-align: top;}#header_title {color: #000000;font-family: serif;font-size: 32pt;font-variant: small-caps;font-weight: bold;height: 60px;}#header_subtitle {color: #68878a;font-family: Verdana,Arial,'Bitstream Vera Sans',Helvetica,sans-serif;font-size: 12pt;font-weight: bold;height: 60px;padding-left: 10px;vertical-align: top;}#main {margin : 0;padding-top : 115px;}#footer {padding : 5px;border-width : 0;text-align : center;}/* Class styles */.bar_calls {background-color : #aaf5d0;float : none;padding : 0 0 0 2px;}.bar_duration {background-color : #e5edf9;float : none;padding : 0 0 0 2px;}.cdr {margin : 0 2%;border-width : 0;white-space : nowrap;width : 96%;}.cdr th {background-color : #5ebeff;border-color : #000;border-width : 2px;text-align : center;}.cdr .center_col {width : 78%;padding : 2px;}.cdr .end_col {width : 11%;padding : 1px;}.cdr .chart_data {padding : 0px;text-align : right;}.cdr .img_col {width : 16px;height : 16px;}.form legend, .title, .title a {color: #777;font-size: 2em;font-weight: bold;}.record {background-color : #fff;empty-cells : hide;}.record:hover {background : #ffdca8;color : #000;empty-cells : hide;}.record_col {padding-left : 2px;padding-right : 2px;border-width : 0;}.center {text-align : center;}.right {padding-right : 80px;text-align : right;font-size: 9pt;}.record_ctrl {position:relative}.record_preview_icon {width:16px;height:16px;cursor:pointer;margin-left:3px;}.record_preview_lt {position:absolute;top:0;left:38px;z-index:99;}

5)

Дополняем файл /var/www/asterisk-cdr-viewer/download.php (обработка range-запросов для аудио-файлов)

<?phprequire_once 'include/config.inc.php';header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');header('Pragma: no-cache');function partial_download($range_header, $request_file, $mime) {$file_size = filesize($request_file);list($b, $range) = explode('=', $range_header);list($first_range) = explode(',', $range);list($part_start,$part_end) = explode('-', $first_range);$start = intval($part_start);if ($part_end)$end = intval($part_end);else$end = $file_size - 1;$chunksize = ($end-$start)+1;header('HTTP/1.1 206 Partial Content');header("Content-Type: $mime"); header('Content-Transfer-Encoding: binary');header("Content-Range: bytes $start-$end/$file_size"); header('Content-Length: '.$chunksize);# header("Content-Disposition: attachment; filename=\"$_REQUEST[audio]\"");$fp = fopen($request_file, 'r');fseek($fp, $start, SEEK_SET);echo fread($fp, $chunksize);fclose($fp);}if (isset($_REQUEST['audio'])) {$extension = strtolower(substr(strrchr($_REQUEST['audio'],"."),1));$ctype ='';switch( $extension ) {case "wav16":$ctype="audio/x-wav";break;case "wav":$ctype="audio/x-wav";break;case "ulaw":$ctype="audio/basic";break;case "alaw":$ctype="audio/x-alaw-basic";break;case "sln":$ctype="audio/x-wav";break;case "gsm":$ctype="audio/x-gsm";break;case "g729":$ctype="audio/x-g729";break;default: $ctype="application/$system_audio_format";break ;}header("Accept-Ranges: bytes");if (!isset($_SERVER['HTTP_RANGE'])) {header("Content-Type: $ctype");header('Content-Transfer-Encoding: binary');header('Content-Length: '.filesize("$system_monitor_dir/$_REQUEST[audio]"));header("Content-Disposition: attachment; filename=\"$_REQUEST[audio]\"");readfile("$system_monitor_dir/$_REQUEST[audio]");}else {partial_download($_SERVER['HTTP_RANGE'], "$system_monitor_dir/$_REQUEST[audio]", $ctype);}} elseif (isset($_REQUEST['fax'])) {header('Content-Type: image/tiff');header('Content-Transfer-Encoding: binary');header('Content-Length: '.filesize("$system_fax_archive_dir/$_REQUEST[fax]"));header("Content-Disposition: attachment; filename=\"$_REQUEST[fax]\"");readfile("$system_fax_archive_dir/$_REQUEST[fax]");} elseif (isset($_REQUEST['csv'])) {header('Content-Type: text/csv');header('Content-Transfer-Encoding: binary');header('Content-Length: '.filesize("/tmp/$_REQUEST[csv]"));header("Content-Disposition: attachment; filename=\"$_REQUEST[csv]\"");readfile("$system_tmp_dir/$_REQUEST[csv]");} elseif (isset($_REQUEST['arch'])) {header('Content-Type: application/x-download');header('Content-Transfer-Encoding: binary');header('Content-Length: '.filesize("$system_monitor_dir/$_REQUEST[arch]"));header("Content-Disposition: attachment; filename=\"$_REQUEST[arch]\"");readfile("$system_monitor_dir/$_REQUEST[arch]");}exit();?>

В результате получаем возможность прослушивания разговоров в веб-интерфейсе (мотать по бегунку прокрутки можно)

«Допиливаем» Asterisk CDR Viewer под себя (3)

Надеюсь кому-нибудь пригодится:)

FAQs

What is CDR for Asterisk? ›

Fundamentally, a CDR represents a path of communication between a channel and Asterisk or between two channels communicating through Asterisk. Those relationships can be broken down into the following states: Single - a channel is executing dialplan in Asterisk or otherwise has no relationship with any other channel.

How to check CDR in Asterisk? ›

All fields of the CDR record can be accessed in the Asterisk dialplan by using the CDR() function. The CDR() function is also used to set the fields of the CDR that are user-defined.

Where are asterisk call recordings stored? ›

Where are Call Recordings saved? The files are stored in /var/spool/asterisk/monitor by default.

Why do I keep getting calls from asterisk? ›

Asterisk is an open-source framework used for building VoIP applications. So my guess would be that someone is contacting you from a VoIP device. That could be legit, such as a friend calling you from a VoIP app similar to Hangouts, or it could be spam.

How do I see active calls in Asterisk? ›

  1. Watch number of active channels. watch "asterisk -vvvvvrx 'core show channels' | grep channels"
  2. Watch number of active calls. watch "asterisk -vvvvvrx 'core show channels' | grep calls"
  3. Watch active channels. watch "asterisk -vvvvvrx 'core show channels verbose'"
  4. Watch active channels in Asterisk 1.8.
Apr 3, 2015

How do I monitor Asterisk calls? ›

The asterisk manager API (AMI) can be used to monitor calls realtime. You will have to write an AMI script that will connect to asterisk and subscribe for events. When a call comes in, your script will receive events, and your script should then act on the events.

How do I find the IP address of Asterisk? ›

On a typical system, running ifconfig, as root, will tell you the addresses of your interfaces on the machine running the Asterisk daemon. However, if you need to do this, there has almost certainly been an error in the network design process.

How do I find a recorded call on my phone? ›

Find a recorded call
  1. Open the Phone app .
  2. Tap Recents .
  3. Tap on the caller that you recorded. If you recorded the most recent call: Go to the player in the 'Recents' screen. If you recorded a previous call: Tap History. ...
  4. Tap Play .
  5. Optional: To share a recorded call, tap Share .

Where do deleted call recordings go? ›

Open Android phone > Open local or cloud backup drive > Select and download deleted call recordings on your phone. Contact the call recording app service provider > Or visit the call recording cloud drive > Find and restore the deleted recordings to your phone.

Does asterisk support video calls? ›

Use your favourite text editor to open /etc/asterisk/sip. conf for editing. Add the following line in the [general] section: videosupport=yes This will enable Video support for your Asterisk.

What is the asterisk * used for? ›

a small starlike symbol (*), used in writing and printing as a reference mark or to indicate omission, doubtful matter, etc. Linguistics. the figure of a star (*) used to mark an utterance that would be considered ungrammatical or otherwise unacceptable by native speakers of a language, as in * I enjoy to ski.

What is an asterisk used for? ›

An asterisk is a star-shaped symbol (*) that has a few uses in writing. It is most commonly used to signal a footnote, but it is sometimes also used to clarify a statement or to censor inappropriate language.

What is an asterisk phone call? ›

Asterisk is a powerful tool for building call center systems and solutions. With support support for call queues, IVRs, outbound dialing, recording, live monitoring and reporting, Asterisk includes virtually everything you need to create a working call center.

How can I check my unknown call history? ›

Steps to Check Recent Call History of any Number on Android Devices
  1. Step 1) First, Launch the App of Your phone.
  2. Step 2) Open the “Recent” tab by clicking the icon at the bottom of the screen.
  3. Step 3) View the list to see all incoming, outgoing, and missed phone calls.
Feb 24, 2023

What does Asterisk mean in VoIP? ›

Asterisk is an open-source platform for building real-time communications applications. It is an extremely powerful tool. You can build a simple office network with a few phones, or you can create rich applications that perform external database lookups and make intelligent call routing decisions.

How can I see a list of my calls? ›

Open your device's Phone app . Tap Recents .
...
You'll see one or more of these icons next to each call in your list:
  1. Missed calls (incoming)
  2. Calls you answered (incoming)
  3. Calls you made (outgoing)

What is * 31 *# code for? ›

Hide Caller ID: *31#

If you want to hide the caller ID dial *31# and press call button.

What does * 74 do on a phone? ›

Speed Dialing

Establish a short list of up to eight numbers, or a longer list of up to 30 numbers. To program your Speed Calling 8 list, dial *74. Listen for the dialtone, then dial the one-digit number (2 through 9) you would like to use to dial a frequently called number.

How do I stop Asterisk service? ›

  1. To shut down Asterisk, issue core stop gracefully : asterisk-server*CLI> core stop gracefully Disconnected from Asterisk server Asterisk cleanly ending (0). ...
  2. You can start Asterisk in the foreground, with an attached root console, using the -c option: # asterisk -c Asterisk 11.9.0, Copyright (C) 1999 - 2014 Digium, Inc.
Jun 23, 2021

What is the meaning of * IP? ›

IP stands for "Internet Protocol," which is the set of rules governing the format of data sent via the internet or local network. In essence, IP addresses are the identifier that allows information to be sent between devices on a network: they contain location information and make devices accessible for communication.

What is asterisk in address? ›

The asterix indicates that the service is listening for traffic on ALL available addresses. Localhost and the machines defined ip-address. If the system has multiple ip-interfaces (and thus multiple ip-addresses), all of those are included.

What is the RTP range for asterisk? ›

Asterisk. Forward ports 10000 to 20000 UDP for RTP (Voice) to your Asterisk server.

How to record a call in asterisk? ›

Asterisk Call Recording
  1. Record VoIP SIP sessions by passively listening to network packets. Both sides of a conversation are mixed together and each call is logged as a separate audio file.
  2. Oreka GPL call recording software can record all Asterisk voice calls using free codecs such as G. 711, iLBC, GSM or G.

How to disable CDR in asterisk? ›

If you want to totally disable, remove all of the modules (usually at /usr/lib/asterisk/modules) or go to the /etc/asterisk/modules. conf and disable them using noload. If you want to enable it or change parameters, best to start with cdr. conf.

What is the default RTP range for asterisk? ›

By default any Asterisk/Switchvox is setup with RTP port range between 10000 and 20000.

How do you read a RTP slot? ›

What does RTP stand for? RTP stands for “Return to Player”. Expressed as a percentage, this figure simply represents the amount of money a player can expect to win from their bets in casino slots or other games. If you play a game with an RTP of 95%, then for every $1 you bet you can expect to receive $0.95 back.

What is the average RTP for casinos? ›

What is the RTP on Casino Slots? An average RTP for slots would be around 96-97%. You can look for a slot RTP in the game's paytable or by searching online. Popular games like NetEnt's Starburst have a decent RTP, paying out little amounts often, so players feel like they are getting a winning experience.

What is an Asterisk phone call? ›

Asterisk is a powerful tool for building call center systems and solutions. With support support for call queues, IVRs, outbound dialing, recording, live monitoring and reporting, Asterisk includes virtually everything you need to create a working call center.

What audio format does Asterisk use? ›

Asterisk support compressed wav format WAV, same as above, but compressed with GSM codec(should be capital extension). Any other wav format will not be played. Asterisk is PBX, not media center. You can easy test your file using soxi utility(sox package) or using asterisk itself.

How to check call logs in Asterisk? ›

You can find the call detail record logs by inspecting the files /etc/asterisk/cdr. conf and /etc/asterisk/cdr_custom. conf (and any local files which they include) to determine where the log files are, or whether they're enabled. You can then view the call detail records.

How do I delete a CDR record? ›

On the Call Detail Recording tab, select the collection (or collections) of CDR settings to be removed. To select multiple collections, click the first collection, hold down the Ctrl key, and click additional collections. Click Edit, and then click Delete.

How to hide caller ID in Asterisk? ›

extensions_custom.

Calls starting with *67 or from extensions with context set to “hide-callerid” now show up as Private Number and dialing *69 returns a prompt saying last caller unknown. And this works for both internal calls and outbound trunk calls.

What is AGI file in Asterisk? ›

The Asterisk Gateway Interface, or AGI, provides a standard interface by which external programs may control the Asterisk dialplan. Usually, AGI scripts are used to do advanced logic, communicate with relational databases (such as PostgreSQL or MySQL), and access other external resources.

Is Asterisk a VoIP server? ›

Asterisk Gateway

Gateways are VoIP systems that allow you to bridge the gap between analog and digital data so that you can integrate analog phones into your office VoIP system.

What ports need to be open for Asterisk? ›

Asterisk by default use 5060 as its SIP signaling port. It is a good idea to change the default SIP port as most of the SIP vulnerable attacks occurs on it's default port 5060.

Top Articles
Latest Posts
Article information

Author: Nicola Considine CPA

Last Updated: 05/11/2023

Views: 6213

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Nicola Considine CPA

Birthday: 1993-02-26

Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

Phone: +2681424145499

Job: Government Technician

Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.