├── img ├── image6.png ├── image7.jpg ├── image8.jpg └── image9.png ├── templates ├── images │ ├── sound.png │ ├── text.png │ ├── asterisk.gif │ ├── favicon.ico │ ├── compressed.png │ └── header_gradient.png ├── footer.tpl.php ├── header.tpl.php └── form.tpl.php ├── asterisk-cdr-viewer-latest.tgz ├── include ├── plugins │ ├── au_callrates.csv │ └── au_callrates.inc.php ├── config.inc.php └── functions.inc.php ├── callrates.csv ├── contrib ├── httpd │ └── asterisk-cdr-viewer.conf └── Readme ├── README.md ├── download.php ├── style ├── screen.css └── csshover.htc └── index.php /img/image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/img/image6.png -------------------------------------------------------------------------------- /img/image7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/img/image7.jpg -------------------------------------------------------------------------------- /img/image8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/img/image8.jpg -------------------------------------------------------------------------------- /img/image9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/img/image9.png -------------------------------------------------------------------------------- /templates/images/sound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/templates/images/sound.png -------------------------------------------------------------------------------- /templates/images/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/templates/images/text.png -------------------------------------------------------------------------------- /templates/images/asterisk.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/templates/images/asterisk.gif -------------------------------------------------------------------------------- /templates/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/templates/images/favicon.ico -------------------------------------------------------------------------------- /asterisk-cdr-viewer-latest.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/asterisk-cdr-viewer-latest.tgz -------------------------------------------------------------------------------- /templates/images/compressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/templates/images/compressed.png -------------------------------------------------------------------------------- /templates/images/header_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g613/asterisk-cdr-viewer/HEAD/templates/images/header_gradient.png -------------------------------------------------------------------------------- /include/plugins/au_callrates.csv: -------------------------------------------------------------------------------- 1 | 3,0.11,Local,c 2 | 7,0.11,Local,c 3 | 07,0.11,Local,c 4 | 02,0.11,Local,c 5 | 03,0.11,Local,c 6 | 08,0.11,Local,c 7 | 04,0.22,Mobile,1m+s 8 | 13,0.33,one3Call,c 9 | 001,1.2974962,Intr,s 10 | -------------------------------------------------------------------------------- /templates/footer.tpl.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /callrates.csv: -------------------------------------------------------------------------------- 1 | 011,0,Intr,m 2 | 012,0,Intr,m 3 | 013,0,Intr,m 4 | 014,0,Intr,m 5 | 015,0,Intr,m 6 | 1800,0,Toll Free,m 7 | 1855,0,Toll Free,m 8 | 1866,0,Toll Free,m 9 | 1877,0,Toll Free,m 10 | 1888,0,Toll Free,m 11 | 1,0,US,m 12 | 2,0,Office,m 13 | +,0.10,Skype,30s+6s 14 | -------------------------------------------------------------------------------- /contrib/httpd/asterisk-cdr-viewer.conf: -------------------------------------------------------------------------------- 1 | Alias /acdr/ "/var/www/asterisk-cdr-viewer/" 2 | 3 | # 4 | # AuthName "Asterisk-CDR-Stat" 5 | # AuthType Basic 6 | # AuthUserFile /var/www/asterisk-cdr-viewer/.htpasswd 7 | # AuthGroupFile /dev/null 8 | # require valid-user 9 | # 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Simple and fast viewer for asterisk CDRs / recordings. ( 1.0.14, Oct 7 2017 ) 2 | 3 | Asterisk regexp support ( like _XNZ. ) for source / destination / DID numbers. 4 | 5 | PHP without any additional dependencies. 6 | 7 | Easy to install and use. 8 | 9 | CSS based. 10 | 11 | User / Admin mode 12 | 13 | Plugins support for custom reports. 14 | 15 | ASR report 16 | 17 | ![Html results](img/image6.png "html results") 18 | 19 | ![ASR/ACD results](img/image9.png "ASR/ACD results") 20 | 21 | ![Minutes report](img/image8.jpg "Minutes report") 22 | 23 | ![Plugins results](img/image7.jpg "Plugins results") 24 | 25 | 26 | ( from http://code.google.com/p/asterisk-cdr-viewer ) 27 | -------------------------------------------------------------------------------- /download.php: -------------------------------------------------------------------------------- 1 | 69 | -------------------------------------------------------------------------------- /include/plugins/au_callrates.inc.php: -------------------------------------------------------------------------------- 1 | "(dst LIKE '4%' OR dst LIKE '07%' OR dst LIKE '02%' OR dst LIKE '03%' OR dst LIKE '08%' OR dst LIKE '3%')", 9 | "Mobile" => "(dst LIKE '04%')", 10 | "one3Call" => "(dst LIKE '13%')", 11 | "Int'l" => "(dst LIKE '001%')" 12 | ); 13 | 14 | $au_callrates_csv_file = '/var/www/asterisk-cdr-viewer/include/plugins/au_callrates.csv'; 15 | 16 | /****************************************************************************************/ 17 | $au_bill_tototal_q = "SELECT $group_by_field AS group_by_field FROM $db_table_name $where GROUP BY group_by_field ORDER BY group_by_field ASC LIMIT $result_limit"; 18 | 19 | 20 | $au_callrates_total = array(); 21 | foreach ( array_keys($au_call_rates) as $key ) { 22 | $au_call_rates_total["$key"] = 0; 23 | } 24 | $au_call_rates_total["summ"] = 0; 25 | 26 | echo '

Australia rates ( plugin example )

27 | 28 | 29 | 30 | 31 | '; 32 | 33 | foreach ( array_keys($au_call_rates) as $key ) { 34 | echo ""; 35 | } 36 | 37 | echo ""; 38 | 39 | try { 40 | $sth = $dbh->query($au_bill_tototal_q); 41 | if (!$sth) { 42 | echo "\nPDO::errorInfo():\n"; 43 | print_r($dbh->errorInfo()); 44 | } 45 | 46 | $result = $sth->fetchAll(PDO::FETCH_NUM); 47 | 48 | $sth = NULL; 49 | 50 | foreach ( $result as $row ) { 51 | $summ = 0; 52 | echo ""; 53 | echo ""; 54 | foreach ( array_keys($au_call_rates) as $key ) { 55 | $au_bill_ch_q = "SELECT dst, billsec FROM $db_table_name $where and $group_by_field = '". $row[0] ."' and " . $au_call_rates["$key"]; 56 | $summ_local = 0; 57 | 58 | $sth2 = $dbh->query($au_bill_ch_q); 59 | if (!$sth2) { 60 | echo "\nPDO::errorInfo():\n"; 61 | print_r($dbh->errorInfo()); 62 | } 63 | 64 | while ($bill_row = $sth2->fetch(PDO::FETCH_NUM)) { 65 | $rates = callrates( $bill_row[0], $bill_row[1], $au_callrates_csv_file ); 66 | $summ_local += $rates[4]; 67 | } 68 | $sth2 = NULL; 69 | 70 | $au_call_rates_total["$key"] += $summ_local; 71 | $summ += $summ_local; 72 | formatMoney($summ_local); 73 | } 74 | $au_call_rates_total["summ"] += $summ; 75 | formatMoney($summ); 76 | echo ""; 77 | 78 | } 79 | } 80 | catch (PDOException $e) { 81 | print $e->getMessage(); 82 | } 83 | 84 | echo ""; 85 | echo ""; 86 | foreach ( array_keys($au_call_rates_total) as $key ) { 87 | formatMoney($au_call_rates_total["$key"]); 88 | } 89 | echo ""; 90 | 91 | echo "
'.$graph_col_title.'CALLS TO
 $keyTOTAL
(inc GST)
". $row[0] ."
Total
"; 92 | } 93 | 94 | ?> 95 | -------------------------------------------------------------------------------- /include/config.inc.php: -------------------------------------------------------------------------------- 1 | "SET NAMES utf8"); */ 12 | 13 | /* auth require, set to 0 if cdr-viewer shall to work without Basic-auth */ 14 | $system_auth_require = 1; 15 | 16 | /* Admin users. for multiple user access */ 17 | /* $admin_user_names = 'iokunev,admin2,admin3'; */ 18 | $admin_user_names = '*'; 19 | 20 | /* $db_result_limit is the 'LIMIT' appended to the query */ 21 | $db_result_limit = '100'; 22 | 23 | /* step */ 24 | $h_step = 30; 25 | 26 | /* $system_monitor_dir is the directory where call recordings are stored */ 27 | $system_monitor_dir = '/var/spool/asterisk/monitor'; 28 | 29 | /* $system_fax_archive_dir is the directory where sent/received fax images are stored */ 30 | $system_fax_archive_dir = '/var/spool/asterisk/fax-gw/archive'; 31 | 32 | /* system tmp */ 33 | $system_tmp_dir = '/tmp'; 34 | 35 | /* audio file format */ 36 | $system_audio_format = 'wav'; 37 | /* arch audio format bz2 || gz, uncomment it if you pack files after some time */ 38 | /* 39 | $system_arch_audio_format = 'bz2'; 40 | */ 41 | 42 | /* Plugins */ 43 | $plugins = array( 'au_callrates' ); 44 | 45 | /* Call rates */ 46 | //$callrate_csv_file = '/var/www/asterisk-cdr-viewer/callrates.csv'; 47 | $callrate_csv_file = ''; 48 | $callrate_currency = '$'; 49 | $callrate_cache = array(); 50 | 51 | /* Suppress download links */ 52 | $cdr_suppress_download_links = 0; 53 | 54 | /* Reverse lookup URL where "%n" is replace with the destination number */ 55 | /* $rev_lookup_url = 'http://www.whitepages.com/search/ReversePhone?full_phone=%n'; */ 56 | /* $rev_lookup_url = 'http://mrnumber.com/%n'; */ 57 | $rev_lookup_url = ''; 58 | 59 | /* enable / disabe column */ 60 | $display_column = array(); 61 | $display_column['clid'] = 0; 62 | $display_column['accountcode'] = 1; 63 | $display_column['extension'] = 0; 64 | $display_column['billsec'] = 1; 65 | $display_column['file'] = 1; 66 | $display_column['channel'] = 1; 67 | $display_column['dstchannel'] = 1; 68 | $display_column['lastapp'] = 1; 69 | $display_column['userfield'] = 1; 70 | 71 | 72 | /* User name */ 73 | $cdr_user_name = getenv('REMOTE_USER'); 74 | 75 | if ( strlen($cdr_user_name) > 0 ) { 76 | $is_admin = strpos(",$admin_user_names,", ",$cdr_user_name,"); 77 | if ( $admin_user_names == '*' ) { 78 | $cdr_user_name = ''; 79 | } elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'logout' ) { 80 | header('Status: 401 Unauthorized'); 81 | header('WWW-Authenticate: Basic realm="Asterisk-CDR-Stat"'); 82 | exit; 83 | } elseif ( $is_admin !== false ) { 84 | $cdr_user_name = ''; 85 | } 86 | } 87 | 88 | if ( $system_auth_require ) { 89 | if ( $_SERVER['AUTH_TYPE'] != 'Basic' ) { 90 | die("HTTP Auth required, please configure WEB server !"); 91 | } 92 | } 93 | 94 | /* load Plugins */ 95 | foreach ( $plugins as &$p_key ) { 96 | require_once "include/plugins/$p_key.inc.php"; 97 | } 98 | 99 | ?> 100 | -------------------------------------------------------------------------------- /style/screen.css: -------------------------------------------------------------------------------- 1 | /* HTML tag styles */ 2 | a { 3 | cursor : pointer; 4 | } 5 | 6 | abbr[title] { 7 | border-style : none none dashed; 8 | border-width : medium medium 1px; 9 | border-bottom-color : #000000; 10 | cursor : help; 11 | white-space : nowrap; 12 | } 13 | 14 | body { 15 | /* Fix for M$ IE < 7 CSS hover */ behavior : url('style/csshover.htc'); 16 | color : #000; 17 | font-family:Time New Roman; 18 | margin : 0; 19 | padding : 0; 20 | } 21 | 22 | img { 23 | border-width : 0; 24 | } 25 | 26 | input, select { 27 | border-radius: 3px; 28 | border: 1px solid #BBB7B7; 29 | } 30 | 31 | input[type=submit] { 32 | background: #5ebeff; 33 | padding:8px 18px 8px 18px; 34 | border-radius:5px; 35 | -moz-border-radius:5px; 36 | color:#ffffff; 37 | font-weight:bold; 38 | text-decoration:none; 39 | margin:10px 10px 0 0; 40 | border:none; 41 | outline:0; 42 | font-family: inherit; 43 | font-size: inherit; 44 | } 45 | 46 | input[type=submit]:hover {background:#7edeff;} 47 | input[type=submit]:active {background:#2222aa;} 48 | 49 | /* ID styles */ 50 | #header { 51 | background-image : url('../templates/images/header_gradient.png'); 52 | background-repeat : repeat-x; 53 | margin : 0; 54 | padding-left : 5%; 55 | padding-right : 10%; 56 | position : fixed; 57 | width : 100%; 58 | z-index : 50; 59 | } 60 | 61 | #header_logo { 62 | height: 105px; 63 | width: 121px; 64 | vertical-align: top; 65 | } 66 | 67 | #header_title { 68 | color: #000000; 69 | font-family: serif; 70 | font-size: 32pt; 71 | font-variant: small-caps; 72 | font-weight: bold; 73 | height: 60px; 74 | } 75 | 76 | #header_subtitle { 77 | color: #68878a; 78 | font-size: 12pt; 79 | font-weight: bold; 80 | height: 60px; 81 | padding-left: 10px; 82 | vertical-align: top; 83 | } 84 | 85 | #main { 86 | margin : 0; 87 | padding-top : 115px; 88 | } 89 | 90 | #footer { 91 | padding : 5px; 92 | border-width : 0; 93 | text-align : center; 94 | } 95 | 96 | 97 | /* Class styles */ 98 | .bar_calls { 99 | background-color : #aaf5d0; 100 | float : none; 101 | padding : 0 0 0 2px; 102 | } 103 | 104 | 105 | .bar_duration { 106 | background-color : #e5edf9; 107 | float : none; 108 | padding : 0 0 0 2px; 109 | } 110 | 111 | .cdr { 112 | margin:0 auto; 113 | border-width:0; 114 | width: 96%; 115 | font-size: 0.9em; 116 | } 117 | 118 | 119 | .cdr th { 120 | background-color : #5ebeff; 121 | border-color : #000; 122 | border-width : 2px; 123 | text-align : center; 124 | padding: 4px 4px 3px; 125 | } 126 | 127 | 128 | .cdr .center_col { 129 | width : 78%; 130 | padding : 2px; 131 | } 132 | 133 | 134 | .cdr .end_col { 135 | width : 11%; 136 | padding : 1px; 137 | } 138 | 139 | .cdr .chart_data { 140 | padding : 0px; 141 | text-align : right; 142 | } 143 | 144 | 145 | .cdr .img_col { 146 | width : 16px; 147 | height : 16px; 148 | } 149 | 150 | .form legend, .title, .title a { 151 | background-color:#ffffcc 152 | color: #777; 153 | font-size: 2em; 154 | font-weight: bold; 155 | } 156 | 157 | 158 | .record { 159 | background-color : #fff; 160 | empty-cells : hide; 161 | } 162 | 163 | 164 | .record:hover { 165 | background : #ffdca8; 166 | color : #000; 167 | empty-cells : hide; 168 | } 169 | 170 | 171 | .record_col { 172 | padding: 4px 4px 5px; 173 | border-width : 0; 174 | } 175 | 176 | 177 | .center { 178 | text-align : center; 179 | } 180 | 181 | .right { 182 | padding-right : 80px; 183 | text-align : right; 184 | font-size: 9pt; 185 | } 186 | 187 | span.green { 188 | color:green; 189 | } 190 | 191 | span.red { 192 | color:red; 193 | } 194 | -------------------------------------------------------------------------------- /templates/header.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | Asterisk Call Detail Records 3 | 4 | 5 | 6 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 80 | 81 | 82 | 83 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /contrib/Readme: -------------------------------------------------------------------------------- 1 | Install: 2 | 3 | cd /var/www 4 | 5 | tar -xzvf asterisk-cdr-viewer.tgz OR svn checkout http://asterisk-cdr-viewer.googlecode.com/svn/trunk/ asterisk-cdr-viewer 6 | 7 | cp asterisk-cdr-viewer/contrib/httpd/asterisk-cdr-viewer.conf /etc/httpd/conf.d/ 8 | 9 | service httpd restart 10 | 11 | change settings in /var/www/asterisk-cdr-viewer/include/config.inc.php 12 | 13 | open browser with url http://your_ip/acdr/ 14 | 15 | Recording interface 16 | 17 | To display the links to the recorded files: 18 | 19 | * change the following settings in configuration file ( config.inc.php ): 20 | 1. $system_monitor_dir = '/var/spool/asterisk/monitor'; - is the directory where call recordings are stored 21 | 2. $system_audio_format = 'wav'; - audio file format 22 | * Use like this command to start recording ( in asterisk dialplan ): 23 | 24 | [macro-monitor] 25 | exten => s,1,Set(MONITOR_FILE=/var/spool/asterisk/monitor/${UNIQUEID}) 26 | exten => s,n,MixMonitor(${MONITOR_FILE}.wav,b) 27 | 28 | !!! if you use a different file format, see more examples in functions.inc.php ( function formatFiles) !!! 29 | 30 | 31 | Regular expressions 32 | 33 | If an Source / Destination number is prefixed by a '_' 34 | character, it is interpreted as a pattern rather than a 35 | literal. In patterns, some characters have special meanings: 36 | 37 | X - any digit from 0-9 38 | Z - any digit from 1-9 39 | N - any digit from 2-9 40 | [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9) 41 | . - wildcard, matches anything remaining (e.g. _9011. matches 42 | anything starting with 9011 excluding 9011 itself) 43 | 44 | For example, the Source/Destination _NXXXXXX would match 7 digit numbers, 45 | while _1NXXNXXXXXX would represent an area code plus phone number 46 | preceded by a one. 47 | 48 | 49 | This cdr-viewer supports the processing of multiple regular expressions in the 50 | Source/Destination name separated by a comma. 51 | 52 | For example: 53 | 54 | * Source = '_2XXN, _562., _.0075' - src is any of these numbers 55 | 56 | 57 | Multiple user access 58 | 59 | uncomment following section in http.conf file: 60 | 61 | 62 | AuthName "Asterisk-CDR-Stat" 63 | AuthType Basic 64 | AuthUserFile /var/www/asterisk-cdr-viewer/.htpasswd 65 | AuthGroupFile /dev/null 66 | require valid-user 67 | 68 | 69 | 70 | * add admin user, for example (iokunev) : 71 | htpasswd -c /var/www/asterisk-cdr-viewer/.htpasswd iokunev 72 | 73 | * added admin name to include/config.inc.php: $admin_user_names = "admin1,admin2,iokunev" 74 | 75 | !!! $admin_user_names = '*' - all registered users are administrators. !!! 76 | 77 | access for all CDRs: http://your_ip/acdr/ - with login iokunev 78 | 79 | * add user 2280: 80 | htpasswd /var/www/asterisk-cdr-viewer/.htpasswd 2280 test 81 | 82 | access for incomming/outgoing (cid or did=2280) calls for this user: http://your_ip/acdr/ - with login 2280 83 | 84 | 85 | Optional CDR columns 86 | 87 | `clid` and `accountcode` optional column. to enable/disable it please change following variables in config file: 88 | /* enable / disabe column */ 89 | $display_column = array(); 90 | $display_column['clid'] = 0; /* disabled */ 91 | $display_column['accountcode'] = 1; /* enabled */ 92 | 93 | 94 | CallRates Support 95 | 96 | * upload csv file to server and add path to the '$callrate_csv_file' variable in config file. 97 | 98 | callrates file format: 99 | areacode,callrate_per_minute[,Destination[,rate_type]] 100 | 101 | for example: 102 | 011,0.12,Intr,m 103 | 104 | supported rate_type: 105 | * s - per second tarification 106 | * c - per call tarification 107 | * m - per minute tarification ( default ) 108 | * 1m+s - combi 109 | * 30s+s - combi 2 110 | * 30s+6s - combi 3 111 | 112 | Plugins support 113 | 114 | * Plug-in file name should be in the format: plugin_name.inc.php 115 | 116 | * Plug-in must contain function `plugin_name`. 117 | 118 | * Copy your plugin to the directory include/plugins/ 119 | 120 | * Add plugin name to include/config.inc.php, to $plugins() variable 121 | 122 | * Please see au_callrates.inc.php plugin for more details. 123 | 124 | Postgres 125 | 126 | to use this software with postgres DB, add follow function to DB: 127 | 128 | CREATE FUNCTION unix_timestamp(TIMESTAMP) RETURNS INTEGER AS ' 129 | SELECT date_part(''epoch'', $1)::INTEGER AS RESULT 130 | ' LANGUAGE sql; 131 | CREATE FUNCTION 132 | -------------------------------------------------------------------------------- /style/csshover.htc: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /include/functions.inc.php: -------------------------------------------------------------------------------- 1 | 0) { 26 | $recorded_file = basename($recorded_file[0],".$system_audio_format"); 27 | } else { 28 | $recorded_file = $row['uniqueid']; 29 | } 30 | */ 31 | /* ============================================================================ */ 32 | 33 | /* This example for multi-directory archive without uniqueid, named by format: 34 | /