diff options
author | Marcello Coutinho <marcellocoutinho@gmail.com> | 2012-03-14 00:52:44 -0300 |
---|---|---|
committer | marcelloc <marcellocoutinho@gmail.com> | 2012-03-14 00:52:44 -0300 |
commit | c202aa26324b7c99bde4ad8614a177e703633cba (patch) | |
tree | 6fec30a92e84a372fb2e405dab2e623935ce5bc8 | |
parent | b003bf9e166b04b1f72d43ce84311105b6b3de67 (diff) | |
download | pfsense-packages-c202aa26324b7c99bde4ad8614a177e703633cba.tar.gz pfsense-packages-c202aa26324b7c99bde4ad8614a177e703633cba.tar.bz2 pfsense-packages-c202aa26324b7c99bde4ad8614a177e703633cba.zip |
asterisk - first relase of asterisk package for pfsense
-rw-r--r-- | config/asterisk/asterisk.inc | 93 | ||||
-rw-r--r-- | config/asterisk/asterisk.xml | 103 | ||||
-rw-r--r-- | config/asterisk/asterisk_calls.php | 167 | ||||
-rw-r--r-- | config/asterisk/asterisk_cmd.php | 120 | ||||
-rw-r--r-- | config/asterisk/asterisk_edit_file.php | 246 | ||||
-rw-r--r-- | config/asterisk/asterisk_log.php | 130 | ||||
-rw-r--r-- | pkg_config.8.xml | 17 | ||||
-rw-r--r-- | pkg_config.8.xml.amd64 | 19 |
8 files changed, 894 insertions, 1 deletions
diff --git a/config/asterisk/asterisk.inc b/config/asterisk/asterisk.inc new file mode 100644 index 00000000..c4630114 --- /dev/null +++ b/config/asterisk/asterisk.inc @@ -0,0 +1,93 @@ +<?php
+/* ========================================================================== */
+/*
+ asterisk.inc
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2012 Marcello Coutinho
+ 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.
+ */
+/* ========================================================================== */
+
+
+function asterisk_install() {
+ sync_package_asterisk();
+}
+
+function asterisk_deinstall() {
+ $script='/usr/local/etc/rc.d/asterisk';
+ if (file_exists($script)){
+ mwexec("$script stop");
+ chmod ($script,0444);
+ }
+}
+
+function sync_package_asterisk() {
+ global $config, $g;
+
+ #mount filesystem writeable
+ conf_mount_rw();
+
+ #fix asterisk options for nanobsd
+ if ($g['platform'] == "nanobsd"){
+ $script='/usr/local/etc/asterisk/logger.conf';
+ if (file_exists($script)){
+ $script_file=file_get_contents($script);
+ $pattern[0]='/messages =/';
+ $replace[0]='/tmp/log_asterisk =';
+ $script_file=preg_replace($pattern,$replace,$script_file);
+ file_put_contents($script, $script_file, LOCK_EX);
+ }
+
+ $script='/usr/local/etc/asterisk/asterisk.conf';
+ if (file_exists($script)){
+ $script_file=file_get_contents($script);
+ $pattern[0]='@astdbdir => [a-z,A-Z,/]@';
+ $replace[0]='astdbdir => /tmp';
+ $pattern[1]='@astspooldir => [a-z,A-Z,/]@';
+ $replace[1]='astspooldir => /tmp';
+ $script_file=preg_replace($pattern,$replace,$script_file);
+ file_put_contents($script, $script_file, LOCK_EX);
+ }
+
+ }
+
+ $script='/usr/local/etc/rc.d/asterisk';
+ if (file_exists($script)){
+ $script_file=file_get_contents($script);
+ if (preg_match('/NO/',$script_file)){
+ $script_file=preg_replace("/NO/","YES",$script_file);
+ file_put_contents($script, $script_file, LOCK_EX);
+ }
+ chmod ($script,0755);
+ mwexec("$script stop");
+ mwexec_bg("$script start");
+ }
+ #mount filesystem readonly
+ conf_mount_ro();
+
+}
+
+?>
diff --git a/config/asterisk/asterisk.xml b/config/asterisk/asterisk.xml new file mode 100644 index 00000000..b179b887 --- /dev/null +++ b/config/asterisk/asterisk.xml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ +/* ========================================================================== */ +/* + asterisk.xml + part of pfSense (http://www.pfSense.com) + Copyright (C) 2012 Marcello Coutinho + 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. + */ +/* ========================================================================== */ + ]]> + </copyright> + <description>Asterisk status pacakge</description> + <requirements>Asterisk 1.8.x</requirements> + <faq>Currently there are no FAQ items provided.</faq> + <name>asterisk</name> + <version>0.1</version> + <title>asterisk</title> + <include_file>/usr/local/pkg/asterisk.inc</include_file> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/asterisk/asterisk.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/asterisk/asterisk_calls.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/asterisk/asterisk_file_edit.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/asterisk/asterisk_log.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/asterisk/asterisk_cmd.php</item> + </additional_files_needed> + <menu> + <name>asterisk</name> + <tooltiptext>Asterisk</tooltiptext> + <section>status</section> + <configfile>asterisk_cmd.php</configfile> + </menu> + <service> + <name>asterisk</name> + <rcfile>asterisk</rcfile> + <executable>asterisk</executable> + <description><![CDATA[Asterisk VoIP telephony]]></description> + </service> + <tabs> + </tabs> + <fields> + </fields> + <custom_php_install_command> + asterisk_install(); + </custom_php_install_command> + <custom_php_deinstall_command> + asterisk_deinstall(); + </custom_php_deinstall_command> + <custom_php_command_before_form> + </custom_php_command_before_form> + <custom_php_validation_command> + </custom_php_validation_command> + <custom_delete_php_command> + </custom_delete_php_command> + <custom_php_resync_config_command> + sync_package_asterisk(); + </custom_php_resync_config_command> +</packagegui>
\ No newline at end of file diff --git a/config/asterisk/asterisk_calls.php b/config/asterisk/asterisk_calls.php new file mode 100644 index 00000000..77131d8d --- /dev/null +++ b/config/asterisk/asterisk_calls.php @@ -0,0 +1,167 @@ +<?php +/* $Id$ */ +/* + status_asterisk_calls.php + part of pfSense + Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>. + Copyright (C) 2012 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) 2012 robreg@zsurob.hu + 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=status_asterisk_calls.php* +##|-PRIV + +require_once("guiconfig.inc"); + +$pgtitle = array(gettext("Status"),gettext("Asterisk Calls")); +include("head.inc"); + +/* Path to call log database */ +$callog = "/var/log/asterisk/cdr-csv/Master.csv"; + +/* Data input processing */ +$cmd = $_GET['cmd']; +//$cmd = str_replace("+", " ", $cmd); + +$file = $_SERVER["SCRIPT_NAME"]; +$break = Explode('/', $file); +$pfile = $break[count($break) - 1]; + +if (file_exists($callog)) + switch ($cmd){ + case "trim": + $trimres=shell_exec("tail -50 '$callog' > /tmp/trimmed.csv; rm '$callog'; mv /tmp/trimmed.csv '$callog'; chmod 666 '$callog'"); + break; + + case "clear": + $trimres=shell_exec("rm '$callog'; touch '$callog'; chmod 666 '$callog'"); + 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-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($callog)); + ob_clean(); + flush(); + readfile($callog); + exit; + break; + } +?> + + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> + <?php include("fbegin.inc"); ?> + <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 + //$trimres=shell_exec("tail -50 '$callog' > /tmp/trimmed.csv; rm '$callog'; mv /tmp/trimmed.csv '$callog'"); + //print $trimres . "Last 50 calls: <br>"; + 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'>" . 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/> + +<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("Trim keeps the last 50 entries.");?> +</span> + + +<?php include("fend.inc"); ?> +</body> diff --git a/config/asterisk/asterisk_cmd.php b/config/asterisk/asterisk_cmd.php new file mode 100644 index 00000000..504c3cd1 --- /dev/null +++ b/config/asterisk/asterisk_cmd.php @@ -0,0 +1,120 @@ +<?php +/* $Id$ */ +/* + status_asterisk.php + part of pfSense + Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>. + Copyright (C) 2012 robreg@zsurob.hu + All rights reserved. + + originally part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>. + 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 page +##|*DESCR=Allow access to the 'Status: Asterisk' page. +##|*MATCH=status_asterisk.php* +##|-PRIV + +require_once("guiconfig.inc"); + +$pgtitle = array(gettext("Status"),gettext("Asterisk")); +include("head.inc"); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> + +<?php +/* Data input processing */ +$cmd = $_GET['cmd']; +$cmd = str_replace("+", " ", $cmd); + +if ($cmd == "") { + $cmd = "core show settings"; +} + +$file = $_SERVER["SCRIPT_NAME"]; +$break = Explode('/', $file); +$pfile = $break[count($break) - 1]; + +?> + <table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td> + <?php + $tab_array = array(); + $tab_array[0] = array(gettext("Commands"), true, "asterisk_cmd.php"); + $tab_array[1] = array(gettext("Calls"), false, "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"> + <table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td class="listtopic"> + <?php + /* Print command buttons */ + echo "<a href='$pfile?cmd=sip+show+registry'><input type='button' name='command' value='SIP Registry' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=sip+show+peers'><input type='button' name='command' value='SIP Peers' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=sip+show+channels'><input type='button' name='command' value='SIP Channels' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=core+show+channels'><input type='button' name='command' value='Channels' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=core+show+codecs+audio'><input type='button' name='command' value='Codecs' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=core+show+translation+recalc+10'><input type='button' name='command' value='Translation' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=sip+show+settings'><input type='button' name='command' value='SIP Settings' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=sip+reload'><input type='button' name='command' value='!Reload SIP' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=core+reload'><input type='button' name='command' value='!Reload Core' class='formbtns'></a>"; + echo "<a href='$pfile?cmd=core+show+uptime'><input type='button' name='command' value='Uptime' class='formbtns'></a>"; + ?> + </td> + </tr> + <tr valign="top"> + <td class="listlr" nowrap> + <?php + /* Run commands and print results */ + $asterisk_command=shell_exec("asterisk -rx '$cmd'"); + echo "<pre style='font-size:11px; background:white'>"; + echo $asterisk_command; + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> + </table> +<?php include("fend.inc"); ?>
\ No newline at end of file diff --git a/config/asterisk/asterisk_edit_file.php b/config/asterisk/asterisk_edit_file.php new file mode 100644 index 00000000..50d00279 --- /dev/null +++ b/config/asterisk/asterisk_edit_file.php @@ -0,0 +1,246 @@ +<?php +/* + edit.php + Copyright (C) 2004, 2005 Scott Ullrich + Copyright (C) 2012 robreg@zsurob.hu + 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: shell +*/ + +##|+PRIV +##|*IDENT=page-status-asterisk +##|*NAME=Status: Asterisk config editor page +##|*DESCR=Allow access to the 'Status: Asterisk configuration files' page. +##|*MATCH=status_asterisk_edit.php* +##|-PRIV + +$pgtitle = array(gettext("Status"),gettext("Asterisk configuration files")); +require("guiconfig.inc"); + +if($_REQUEST['action']) { + switch($_REQUEST['action']) { + case 'load': + if(strlen($_REQUEST['file']) < 1) { + echo "|5|" . gettext("No file name specified") . ".|"; + } elseif(is_dir($_REQUEST['file'])) { + echo "|4|" . gettext("Loading a directory is not supported") . ".|"; + } elseif(! is_file($_REQUEST['file'])) { + echo "|3|" . gettext("File does not exist or is not a regular file") . ".|"; + } else { + $data = file_get_contents(urldecode($_REQUEST['file'])); + if($data === false) { + echo "|1|" . gettext("Failed to read file") . ".|"; + } else { + echo "|0|{$_REQUEST['file']}|{$data}|"; + } + } + exit; + case 'save': + if(strlen($_REQUEST['file']) < 1) { + echo "|" . gettext("No file name specified") . ".|"; + } else { + conf_mount_rw(); + $_REQUEST['data'] = str_replace("\r", "", base64_decode($_REQUEST['data'])); + $ret = file_put_contents($_REQUEST['file'], $_REQUEST['data']); + conf_mount_ro(); + if($_REQUEST['file'] == "/conf/config.xml" || $_REQUEST['file'] == "/cf/conf/config.xml") { + if(file_exists("/tmp/config.cache")) + unlink("/tmp/config.cache"); + disable_security_checks(); + } + if($ret === false) { + echo "|" . gettext("Failed to write file") . ".|"; + } elseif($ret <> strlen($_REQUEST['data'])) { + echo "|" . gettext("Error while writing file") . ".|"; + } else { + echo "|" . gettext("File successfully saved") . ".|"; + } + } + exit; + } + exit; +} + +require("head.inc"); +outputJavaScriptFileInline("filebrowser/browser.js"); +outputJavaScriptFileInline("javascript/base64.js"); + +?> + +<body link="#000000" vlink="#000000" alink="#000000"> +<?php include("fbegin.inc"); ?> + +<script type="text/javascript"> + function loadFile() { + $("fileStatus").innerHTML = "<?=gettext("Loading file"); ?> ..."; + Effect.Appear("fileStatusBox", { duration: 0.5 }); + + new Ajax.Request( + "<?=$_SERVER['SCRIPT_NAME'];?>", { + method: "post", + postBody: "action=load&file=" + $("fbTarget").value, + onComplete: loadComplete + } + ); + } + + function loadComplete(req) { + Element.show("fileContent") + var values = req.responseText.split("|"); + values.shift(); values.pop(); + + if(values.shift() == "0") { + var file = values.shift(); + $("fileStatus").innerHTML = "<?=gettext("File successfully loaded"); ?>."; + $("fileContent").value = values.join("|"); + + var lang = "none"; + if(file.indexOf(".php") > 0) lang = "php"; + else if(file.indexOf(".inc") > 0) lang = "php"; + else if(file.indexOf(".xml") > 0) lang = "xml"; + else if(file.indexOf(".js" ) > 0) lang = "js"; + else if(file.indexOf(".css") > 0) lang = "css"; + + } + else { + $("fileStatus").innerHTML = values[0]; + $("fileContent").value = ""; + } + new Effect.Appear("fileContent"); + } + + function saveFile(file) { + $("fileStatus").innerHTML = "<?=gettext("Saving file"); ?> ..."; + Effect.Appear("fileStatusBox", { duration: 0.5 }); + + var fileContent = Base64.encode($("fileContent").value); + fileContent = fileContent.replace(/\+/g,"%2B"); + + new Ajax.Request( + "<?=$_SERVER['SCRIPT_NAME'];?>", { + method: "post", + postBody: "action=save&file=" + $("fbTarget").value + + "&data=" + fileContent, + onComplete: function(req) { + var values = req.responseText.split("|"); + $("fileStatus").innerHTML = values[1]; + } + } + ); + } +</script> + + <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"), false, "asterisk_calls.php"); + $tab_array[2] = array(gettext("Log"), false, "asterisk_log.php"); + $tab_array[3] = array(gettext("Edit configuration"), true, "asterisk_edit_file.php"); + display_top_tabs($tab_array); + ?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + + <!-- file status box --> + <div style="display:none; background:#eeeeee;" id="fileStatusBox"> + <div class="vexpl" style="padding-left:15px;"> + <strong id="fileStatus"></strong> + </div> + </div> + + + <table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabcont" align="center"> + + <!-- controls --> + <table width="100%" cellpadding="9" cellspacing="9"> + <tr> + <td align="center" class="list"> + <?=gettext("Save / Load from path"); ?>: + <input type="text" class="formfld file" id="fbTarget" value="<?=gettext('/usr/local/etc/asterisk');?>" size="45" /> + <input type="button" class="formbtn" id="fbOpen" value="<?=gettext('Browse');?>" /> + <!-- <input type="button" class="formbtn" onclick="loadFile();" value="<?=gettext('Load');?>" /> --> + <input type="button" class="formbtn" onclick="saveFile();" value="<?=gettext('Save');?>" /> + <br /> + </td> + </tr> + </table> + + <!-- filebrowser --> + <div id="fbBrowser" style="display:none; border:1px dashed gray; width:98%;"></div> + + <!-- file viewer/editor --> + <table width="100%"> + <tr> + <td valign="top" class="label"> + <div style="background:#eeeeee;" id="fileOutput"> + <textarea id="fileContent" name="fileContent" style="width:100%;" rows="30" wrap="off"></textarea> + </div> + </td> + </tr> + </table> + + </td> + </tr> + </table> + + <script type="text/javascript"> + Event.observe( + window, "load", + function() { + $("fbTarget").focus(); + + NiftyCheck(); + Rounded("div#fileStatusBox", "all", "#ffffff", "#eeeeee", "smooth"); + } + ); + + <?php if($_GET['action'] == "load"): ?> + Event.observe( + window, "load", + function() { + $("fbTarget").value = "<?=$_GET['path'];?>"; + loadFile(); + } + ); + <?php endif; ?> + </script> + + </div> + </td> + </tr> + </table> + +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/asterisk/asterisk_log.php b/config/asterisk/asterisk_log.php new file mode 100644 index 00000000..7d1328ed --- /dev/null +++ b/config/asterisk/asterisk_log.php @@ -0,0 +1,130 @@ +<?php +/* $Id$ */ +/* + status_asterisk_log.php + part of pfSense + Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>. + Copyright (C) 2012 robreg@zsurob.hu + Copyright (C) 2012 Marcello Coutinho + All rights reserved. + + originally part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>. + 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 Log' page. +##|*MATCH=status_asterisk_log.php* +##|-PRIV + +require_once("guiconfig.inc"); + +$pgtitle = array(gettext("Status"),gettext("Asterisk Log")); +include("head.inc"); + +/* Path to Asterisk log file */ +if ($g['platform'] == "nanobsd") + $log = "/tmp/log_asterisk"; +else + $log = "/var/log/asterisk/messages"; + +?> + +<?php +/* Data input processing */ +$cmd = $_GET['cmd']; +//$cmd = str_replace("+", " ", $cmd); + +$file = $_SERVER["SCRIPT_NAME"]; +$break = Explode('/', $file); +$pfile = $break[count($break) - 1]; + +if ($cmd == "trim") { + $trimres=shell_exec("tail -50 '$log' > /tmp/trimmed.csv; rm '$log'; mv /tmp/trimmed.csv '$log'; chmod 666 '$log'"); +} + +if ($cmd == "clear") { + $trimres=shell_exec("rm '$log'; touch '$log'; chmod 666 '$log'"); +} + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> + <?php include("fbegin.inc"); ?> + <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"), false, "asterisk_calls.php"); + $tab_array[2] = array(gettext("Log"), true, "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"> + <table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" class="listtopic">Last 50 Asterisk log entries</td> + </tr> + + <tr valign="top"><td class="listlr" nowrap> + + <?php + $showlog_command=shell_exec("tail -50 '$log'"); + echo nl2br($showlog_command); + ?> + </td></tr> + <?php + echo "<tr><td colspan='6'><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/> + +<span class="vexpl"> + <span class="red"> + <strong><?=gettext("Note:");?><br /></strong> + </span> + <?=gettext("Trim keeps the last 50 lines of the log.");?> +</span> + +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index cd48e1c5..4dadf330 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -6,6 +6,23 @@ <copy_packages_to_folder_ssh>/usr/local/www/files/packages/8/All/</copy_packages_to_folder_ssh> <packages> <package> + <name>Asterisk</name> + <pkginfolink>http://forum.pfsense.org/index.php/topic,47210.0.html</pkginfolink> + <descr><![CDATA[Asterisk is an open source framework for building communications applications.<br>Asterisk turns an ordinary computer into a communications server.]]></descr> + <website>http://www.asterisk.org/</website> + <category>Services</category> + <version>1.8.8.1 pkg v 0.1</version> + <status>Beta</status> + <required_version>2.0</required_version> + <config_file>http://www.pfsense.com/packages/config/asterisk/asterisk.xml</config_file> + <depends_on_package_base_url>http://e-sac.siteseguro.ws/packages/8/All/</depends_on_package_base_url> + <depends_on_package>asterisk18-1.8.8.1.tbz</depends_on_package> + <depends_on_package>openldap-sasl-client-2.4.26.tbz</depends_on_package> + <maintainer>marcellocoutinho@gmail.com robreg@zsurob.hu</maintainer> + <configurationfile>asterisk.xml</configurationfile> + <after_install_info>Please visit the Asterisk tab on status menu.</after_install_info> + </package> + <package> <name>Filer</name> <website/> <descr>Allows you to create and overwrite files from the GUI.</descr> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index d6770740..9ee66667 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -6,6 +6,23 @@ <copy_packages_to_folder_ssh>/usr/local/www/files/packages/amd64/8/All/</copy_packages_to_folder_ssh> <packages> <package> + <name>Asterisk</name> + <pkginfolink>http://forum.pfsense.org/index.php/topic,47210.0.html</pkginfolink> + <descr><![CDATA[Asterisk is an open source framework for building communications applications.<br>Asterisk turns an ordinary computer into a communications server.]]></descr> + <website>http://www.asterisk.org/</website> + <category>Services</category> + <version>1.8.8.1 pkg v 0.1</version> + <status>Beta</status> + <required_version>2.0</required_version> + <config_file>http://www.pfsense.com/packages/config/asterisk/asterisk.xml</config_file> + <depends_on_package_base_url>http://e-sac.siteseguro.ws/packages/amd64/8/All/</depends_on_package_base_url> + <depends_on_package>asterisk18-1.8.8.1.tbz</depends_on_package> + <depends_on_package>openldap-sasl-client-2.4.26.tbz</depends_on_package> + <maintainer>marcellocoutinho@gmail.com robreg@zsurob.hu</maintainer> + <configurationfile>asterisk.xml</configurationfile> + <after_install_info>Please visit the Asterisk tab on status menu.</after_install_info> + </package> + <package> <name>Filer</name> <website/> <descr>Allows you to create and overwrite files from the GUI.</descr> @@ -214,7 +231,7 @@ <build_port_path>/usr/ports/net/haproxy</build_port_path> </package> <package> - <name>haproxy-legacy</name> + <name>haproxy-full</name> <pkginfolink>http://doc.pfsense.org/index.php/haproxy_package</pkginfolink> <descr><![CDATA[The Reliable, High Performance TCP/HTTP Load Balancer package<br> This package implements both TCP and HTTP balance features from Haproxy.]]></descr> |