aboutsummaryrefslogtreecommitdiffstats
path: root/config/asterisk
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-08-18 16:23:37 +0200
committerdoktornotor <notordoktor@gmail.com>2015-08-18 16:23:37 +0200
commit24d5c2b1e61a47520d884e53cf186ef40ca90e68 (patch)
tree73c7818d4cc86ae1f06395faf91a93b0c1662370 /config/asterisk
parent9953f02b27d8c441d2891cc352f2490c94844ffa (diff)
downloadpfsense-packages-24d5c2b1e61a47520d884e53cf186ef40ca90e68.tar.gz
pfsense-packages-24d5c2b1e61a47520d884e53cf186ef40ca90e68.tar.bz2
pfsense-packages-24d5c2b1e61a47520d884e53cf186ef40ca90e68.zip
asterisk - code style cleanup
- Fix copyright header - Code style and indentation fixes - XHTML validation fixes - Improve cache handling
Diffstat (limited to 'config/asterisk')
-rw-r--r--config/asterisk/asterisk_calls.php181
1 files changed, 86 insertions, 95 deletions
diff --git a/config/asterisk/asterisk_calls.php b/config/asterisk/asterisk_calls.php
index 75f24b2f..5150c95f 100644
--- a/config/asterisk/asterisk_calls.php
+++ b/config/asterisk/asterisk_calls.php
@@ -1,14 +1,10 @@
<?php
-/* $Id$ */
/*
- status_asterisk_calls.php
- part of pfSense
- Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
+ asterisk_calls.php
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2013 robi <robreg@zsurob.hu>
- All rights reserved.
-
- originally part of m0n0wall (http://m0n0.ch/wall)
- Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
+ Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -32,7 +28,7 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-/*
+/*
pfSense_MODULE: asterisk
*/
@@ -53,127 +49,122 @@ include("head.inc");
$callog = "/var/log/asterisk/cdr-csv/Master.csv";
/* Data input processing */
-$cmd = $_GET['cmd'];
+$cmd = $_GET['cmd'];
$file = $_SERVER["SCRIPT_NAME"];
-$break = Explode('/', $file);
-$pfile = $break[count($break) - 1];
+$break = explode('/', $file);
+$pfile = $break[count($break) - 1];
-if (file_exists($callog))
- switch ($cmd){
+if (file_exists($callog)) {
+ switch ($cmd) {
case "trim":
- $trimres=shell_exec("tail -50 '$callog' > /tmp/trimmed_asterisk.csv && rm '$callog' && mv /tmp/trimmed_asterisk.csv '$callog' && chown asterisk:asterisk '$callog' && chmod g+w '$callog'");
- header( 'Location: asterisk_calls.php?savemsg=Calls+log+trimmed.') ;
- break;
+ $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("rm '$callog' && touch '$callog' && chown asterisk:asterisk '$callog' && chmod g+w '$callog'");
- header( 'Location: asterisk_calls.php?savemsg=Calls+log+cleared.') ;
- break;
+ $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":
- // session_cache_limiter('none'); //*Use before session_start()
- // session_start();
-
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename='.basename($callog));
+ header('Content-Disposition: attachment; filename=' . basename($callog));
header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
+ 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;
+ break;
}
+}
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
- <?php include("fbegin.inc"); ?>
- <?php
+<?php include("fbegin.inc"); ?>
+<?php
$savemsg = $_GET["savemsg"];
if ($savemsg) {
- print_info_box($savemsg);
+ print_info_box($savemsg);
}
+?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td>
+ <?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Commands"), false, "asterisk_cmd.php");
+ $tab_array[1] = array(gettext("Calls"), true, "asterisk_calls.php");
+ $tab_array[2] = array(gettext("Log"), false, "asterisk_log.php");
+ $tab_array[3] = array(gettext("Edit configuration"), false, "asterisk_edit_file.php");
+ display_top_tabs($tab_array);
?>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td>
- <?php
- $tab_array = array();
- $tab_array[0] = array(gettext("Commands"), false, "asterisk_cmd.php");
- $tab_array[1] = array(gettext("Calls"), true, "asterisk_calls.php");
- $tab_array[2] = array(gettext("Log"), false, "asterisk_log.php");
- $tab_array[3] = array(gettext("Edit configuration"), false, "asterisk_edit_file.php");
- display_top_tabs($tab_array);
- ?>
- </td>
- </tr>
- <tr>
- <td>
- <div id="mainarea">
- <?php
- if (file_exists($callog))
- $file_handle = fopen($callog, "r");
- ?>
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td colspan="6" class="listtopic">Last 50 Asterisk calls</td>
- </tr>
- <tr>
- <td nowrap class="listhdrr"><?=gettext("From");?></td>
- <td nowrap class="listhdrr"><?=gettext("To");?></a></td>
- <td nowrap class="listhdrr"><?=gettext("Start");?></td>
- <td nowrap class="listhdrr"><?=gettext("End");?></a></td>
- <td nowrap class="listhdrr"><?=gettext("Duration");?></a></td>
- <td nowrap class="listhdrr"><?=gettext("Status");?></td>
- </tr>
- <?php
- $out = '';
- if (file_exists($callog)){
- while (!feof($file_handle) ) {
- $lin = fgetcsv($file_handle, 102400);
- if ($lin[12] != "") {
- $out = "<tr>" . $out;
- $out = "<td class='listlr'>" . utf8_decode(str_replace('"', '', $lin[4])) . "</td><td class='listlr'>" . $lin[2] . "</td><td class='listlr'>" . $lin[9] . "</td><td class='listlr'>" . $lin[11] . "</td><td class='listlr'>" . gmdate("G:i:s", $lin[12]) . "</td><td class='listlr'>" . $lin[14] . "</td>" . $out;
- $out = "</tr>" . $out;
- }
- }
- fclose($file_handle);
- }
- echo $out;
- echo "<tr><td colspan='6'><a href='$pfile?cmd=download'><input type='button' name='command' value='Download' class='formbtn'></a>";
- echo "<a href='$pfile?cmd=trim'><input type='button' name='command' value='Trim log' class='formbtn'></a>";
- echo "<a href='$pfile?cmd=clear'><input type='button' name='command' value='Clear log' class='formbtn'></a></td></tr>";
- ?>
- </table>
- </div>
- </td>
- </tr>
- </table>
-
-<p/>
+</td></tr>
+
+<tr><td>
+ <div id="mainarea">
+ <?php
+ if (file_exists($callog)) {
+ $file_handle = fopen($callog, "r");
+ }
+ ?>
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td colspan="6" class="listtopic">Last 50 Asterisk calls</td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap" class="listhdrr"><?=gettext("From");?></td>
+ <td nowrap="nowrap" class="listhdrr"><?=gettext("To");?></a></td>
+ <td nowrap="nowrap" class="listhdrr"><?=gettext("Start");?></td>
+ <td nowrap="nowrap" class="listhdrr"><?=gettext("End");?></a></td>
+ <td nowrap="nowrap" class="listhdrr"><?=gettext("Duration");?></a></td>
+ <td nowrap="nowrap" class="listhdrr"><?=gettext("Status");?></td>
+ </tr>
+ <?php
+ $out = '';
+ if (file_exists($callog)) {
+ while (!feof($file_handle)) {
+ $lin = fgetcsv($file_handle, 102400);
+ if ($lin[12] != "") {
+ $out = "<tr>" . $out;
+ $out = "<td class='listlr'>" . utf8_decode(str_replace('"', '', $lin[4])) . "</td><td class='listlr'>" . $lin[2] . "</td><td class='listlr'>" . $lin[9] . "</td><td class='listlr'>" . $lin[11] . "</td><td class='listlr'>" . gmdate("G:i:s", $lin[12]) . "</td><td class='listlr'>" . $lin[14] . "</td>" . $out;
+ $out = "</tr>" . $out;
+ }
+ }
+ fclose($file_handle);
+ }
+ echo $out;
+ echo "<tr><td colspan='6'><a href='$pfile?cmd=download'><input type='button' name='command' value='Download' class='formbtn'></a>";
+ echo "<a href='$pfile?cmd=trim'><input type='button' name='command' value='Trim log' class='formbtn' /></a>";
+ echo "<a href='$pfile?cmd=clear'><input type='button' name='command' value='Clear log' class='formbtn' /></a></td></tr>";
+ ?>
+ </table>
+ </div>
+</td></tr>
+</table>
+
+<br />
<span class="vexpl">
<span class="red">
<strong><?=gettext("Notes:");?><br /></strong>
</span>
- <?=gettext("Listed in reverse order (latest on top).");?> <br>
- <?=gettext("Duration includes ringing time.");?> <br>
+ <?=gettext("Listed in reverse order (latest on top).");?> <br />
+ <?=gettext("Duration includes ringing time.");?> <br />
<?=gettext("Trim keeps the last 50 entries.");?>
<?
-if ($g['platform'] == "nanobsd")
- echo "<br>This log may be lost when rebooting the system.";
+if ($g['platform'] == "nanobsd") {
+ echo "<br />This log may be lost when rebooting the system.";
+}
?>
-
-
</span>
-
<?php include("fend.inc"); ?>
</body>
+</html>