Copyright (C) 2013 robi Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* pfSense_MODULE: asterisk */ ##|+PRIV ##|*IDENT=page-status-asterisk ##|*NAME=Status: Asterisk Calls page ##|*DESCR=Allow access to the 'Status: Asterisk Calls' page. ##|*MATCH=asterisk_calls.php* ##|-PRIV require_once("guiconfig.inc"); $pgtitle = array(gettext("Status"),gettext("Asterisk Calls")); $shortcut_section = "asterisk"; include("head.inc"); /* Path to call log database */ $callog = "/var/log/asterisk/cdr-csv/Master.csv"; /* Data input processing */ $cmd = $_GET['cmd']; $file = $_SERVER["SCRIPT_NAME"]; $break = explode('/', $file); $pfile = $break[count($break) - 1]; if (file_exists($callog)) { switch ($cmd) { case "trim": $trimres = shell_exec("/usr/bin/tail -n 50 '$callog' > /tmp/trimmed_asterisk.csv && /bin/rm '$callog' && /bin/mv /tmp/trimmed_asterisk.csv '$callog' && /usr/sbin/chown asterisk:asterisk '$callog' && /bin/chmod g+w '$callog'"); header('Location: asterisk_calls.php?savemsg=Calls+log+trimmed.'); break; case "clear": $trimres=shell_exec("/bin/rm '$callog' && /usr/bin/touch '$callog' && /usr/sbin/chown asterisk:asterisk '$callog' && /bin/chmod g+w '$callog'"); header('Location: asterisk_calls.php?savemsg=Calls+log+cleared.'); break; case "download": header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($callog)); header('Content-Transfer-Encoding: binary'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Length: ' . filesize($callog)); ob_clean(); flush(); readfile($callog); exit; break; } } ?>
" . $out; $out = "" . $out; $out = "" . $out; } } fclose($file_handle); } echo $out; echo ""; ?>
Last 50 Asterisk calls
" . utf8_decode(str_replace('"', '', $lin[4])) . "" . $lin[2] . "" . $lin[9] . "" . $lin[11] . "" . gmdate("G:i:s", $lin[12]) . "" . $lin[14] . "
"; echo ""; echo "




This log may be lost when rebooting the system."; } ?>