From 43092f4479e905fd0235fc093441f4e118f3cc70 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 15:24:09 +0200 Subject: asterisk - code style cleanup - Fix copyright header - Fix file permissions - Remove unused tags - Rename the rc script to match pretty much any other package out there --- config/asterisk/asterisk.xml | 87 ++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 51 deletions(-) (limited to 'config') diff --git a/config/asterisk/asterisk.xml b/config/asterisk/asterisk.xml index d5fb3161..2eef359f 100644 --- a/config/asterisk/asterisk.xml +++ b/config/asterisk/asterisk.xml @@ -2,76 +2,71 @@ - - + - - Asterisk status pacakge - Asterisk 1.8.x - Currently there are no FAQ items provided. + 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. +*/ +/* ====================================================================================== */ + ]]> + asterisk - 0.3.1 + 0.3.2 asterisk /usr/local/pkg/asterisk.inc /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/asterisk/asterisk.inc /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/asterisk/asterisk_calls.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/asterisk/asterisk_edit_file.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/asterisk/asterisk_log.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/asterisk/asterisk_cmd.php /usr/local/www/shortcuts/ - 0755 https://packages.pfsense.org/packages/config/asterisk/pkg_asterisk.inc @@ -82,26 +77,16 @@ asterisk - asterisk + asterisk.sh asterisk - + Asterisk VoIP Telephony - - - - asterisk_install(); asterisk_deinstall(); - - - - - - sync_package_asterisk(); -- cgit v1.2.3 From 9953f02b27d8c441d2891cc352f2490c94844ffa Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 15:37:00 +0200 Subject: asterisk - code style cleanup - Fix copyright header - Code style and indentation fixes - Rename the rc script to asterisk.sh; use write_rcfile() to create the script, instead of the messy preg_replace() stuff. This also should hopefully fix Bug #4717 for some users. - Use stop_service()/restart_service() instead of calling the script via exec() - Stop the service and actually remove the rc script on uninstall, instead of making it non-executable --- config/asterisk/asterisk.inc | 286 +++++++++++++++++++++---------------------- 1 file changed, 139 insertions(+), 147 deletions(-) (limited to 'config') diff --git a/config/asterisk/asterisk.inc b/config/asterisk/asterisk.inc index 9a89d885..22a7b96c 100644 --- a/config/asterisk/asterisk.inc +++ b/config/asterisk/asterisk.inc @@ -1,118 +1,109 @@ - All rights reserved. - */ -/* ========================================================================== */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012-2013 Marcello Coutinho + Copyright (C) 2012-2013 robi + Copyright (C) 2015 ESF, LLC + All rights reserved. - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - 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. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 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. - */ -/* ========================================================================== */ + 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. +*/ define('ASTERISK_CONF_DIR', '/conf/asterisk'); -//Check pfsense version -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version == "2.1" || $pf_version == "2.2") +$pf_version=substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pf_version == "2.1" || $pf_version == "2.2") { define('ASTERISK_LOCALBASE', '/usr/pbi/asterisk-' . php_uname("m")); -else +} else { define('ASTERISK_LOCALBASE','/usr/local'); +} function asterisk_install() { + // Remove rc script from previous package versions + unlink_if_exists("/usr/local/etc/rc.d/asterisk"); sync_package_asterisk(); } function asterisk_deinstall() { - $script='/usr/local/etc/rc.d/asterisk'; - if (file_exists($script)){ - mwexec("$script stop"); - chmod ($script,0444); - } + stop_service("asterisk"); + unlink_if_exists("/usr/local/etc/rc.d/asterisk.sh"); } function sync_package_asterisk() { - global $config, $g; - - #mount filesystem writeable conf_mount_rw(); - - //for NanoBSD compatibility, move the /etc/asterisk configuration directory to /conf, and symlink it back - $dist_dir=ASTERISK_CONF_DIR ."/dist"; - if (!is_dir($dist_dir)) - mkdir($dist_dir,0755,TRUE); - if(file_exists (ASTERISK_LOCALBASE."/etc/asterisk") && !is_link(ASTERISK_LOCALBASE."/etc/asterisk")){ - $dist_files= scandir(ASTERISK_LOCALBASE."/etc/asterisk"); - foreach ($dist_files as $dist){ - if (preg_match("/-dist/",$dist)) - rename (ASTERISK_LOCALBASE."/etc/asterisk"."/$dist", "$dist_dir/$dist"); - elseif (preg_match("/\w+/",$dist)) - rename (ASTERISK_LOCALBASE."/etc/asterisk"."/$dist", ASTERISK_CONF_DIR."/$dist"); - } - rmdir(ASTERISK_LOCALBASE. "/etc/asterisk"); - symlink (ASTERISK_CONF_DIR , ASTERISK_LOCALBASE. "/etc/asterisk"); - } - - //fix asterisk options for nanobsd: logging, db and calls log in /tmp - // if ($g['platform'] == "nanobsd"){ - $script='/conf/asterisk/logger.conf'; - if (file_exists($script)){ - $script_file=file_get_contents($script); - $pattern[0]='@;rotatestrategy@'; - $replace[0]='rotatestrategy = rotate ;by pfSense ;'; - $script_file=preg_replace($pattern,$replace,$script_file); - file_put_contents($script, $script_file, LOCK_EX); - } - - $script='/conf/asterisk/asterisk.conf'; - if (file_exists($script)){ - //point to the /var subdirs in the writable area in RAM - $script_file=file_get_contents($script); - $pattern[0]='/(\Wdirectories\W)\S+/'; - $replace[0]='$1'; - $pattern[1]='/astetcdir => \S+/'; - $replace[1]='astetcdir => /conf/asterisk'; - $pattern[2]='/astdbdir => \S+/'; - $replace[2]='astdbdir => /var/db/asterisk'; - $pattern[3]='/astspooldir => \S+/'; - $replace[3]='astspooldir => /var/spool/asterisk'; - $pattern[4]='/astrundir => \S+/'; - $replace[4]='astrundir => /var/run/asterisk'; - $pattern[5]='/astlogdir => \S+/'; - $replace[5]='astlogdir => /var/log/asterisk'; - $script_file=preg_replace($pattern,$replace,$script_file); - file_put_contents($script, $script_file, LOCK_EX); + // For NanoBSD compatibility, move the /etc/asterisk configuration directory to /conf, and symlink it back + $dist_dir = ASTERISK_CONF_DIR . "/dist"; + safe_mkdir($dist_dir, 0755); + + if (file_exists (ASTERISK_LOCALBASE . "/etc/asterisk") && !is_link(ASTERISK_LOCALBASE . "/etc/asterisk")) { + $dist_files = scandir(ASTERISK_LOCALBASE . "/etc/asterisk"); + foreach ($dist_files as $dist) { + if (preg_match("/-dist/", $dist)) { + rename (ASTERISK_LOCALBASE . "/etc/asterisk" . "/$dist", "$dist_dir/$dist"); + } elseif (preg_match("/\w+/", $dist)) { + rename (ASTERISK_LOCALBASE . "/etc/asterisk" . "/$dist", ASTERISK_CONF_DIR . "/$dist"); + } } -// } + rmdir(ASTERISK_LOCALBASE . "/etc/asterisk"); + symlink(ASTERISK_CONF_DIR, ASTERISK_LOCALBASE . "/etc/asterisk"); + } - //add modules settings, for disabling those not required on pfSense - $script='/conf/asterisk/modules.conf'; - if (file_exists($script)){ - $script_file=file_get_contents($script); - if (strpos($script_file,'pfSense') === false) { //first check if already added... - $add_modules_settings=<< chan_h323.so noload => res_config_odbc.so EOF; - $script_file .= $add_modules_settings; - file_put_contents($script, $script_file, LOCK_EX); - } + $script_file .= $add_modules_settings; + file_put_contents($script, $script_file, LOCK_EX); } + } + + // Replace general SIP settings as a newbie hint to start configuration + $script = '/conf/asterisk/sip.conf'; + if (file_exists($script)) { + $script_file = file_get_contents($script); + // Strenghten a couple of security settings, and predefine codecs in the default SIP configuration + // First check if already added... + if (strpos($script_file, 'pfSense') === false) { + $pattern[0] = '/;allowguest\S+/'; + $replace[0] = 'allowguest=no ;by pfSense ;'; + $pattern[1] = '/;alwaysauthreject/'; + $replace[1] = 'alwaysauthreject=yes ;by pfSense ;'; + $pattern[2] = '/; jbenable/'; + $replace[2] = 'jbenable=yes ;by pfSense ;'; + $pattern[3] = '/(First disallow all codecs)/'; + $replace[3] = "$1\n;The following general settings usually work on pfSense boxes (note: please do not remove this comment line).\ndisallow=all ;by pfSense\nallow=g729\nallow=gsm\nallow=ulaw\nallow=alaw\n\n"; + $script_file = preg_replace($pattern, $replace, $script_file); + file_put_contents($script, $script_file, LOCK_EX); + } + + // First check if already added... + if (strpos($script_file, 'demo extension for pfSense') === false) { + $add_demo_extension = << 'asterisk.sh', + 'start' => $start, + 'stop' => $stop )); + + restart_service("asterisk"); + + // Prepare backup for factory defaults restoring feature if (!file_exists("/conf.default/asterisk_factory_defaults_config.tgz")) { - system("cd /conf/asterisk/ && tar czf /conf.default/asterisk_factory_defaults_config.tgz *"); + system("cd /conf/asterisk/ && /usr/bin/tar czf /conf.default/asterisk_factory_defaults_config.tgz *"); } - - //mount filesystem readonly + conf_mount_ro(); } -- cgit v1.2.3 From 24d5c2b1e61a47520d884e53cf186ef40ca90e68 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 16:23:37 +0200 Subject: asterisk - code style cleanup - Fix copyright header - Code style and indentation fixes - XHTML validation fixes - Improve cache handling --- config/asterisk/asterisk_calls.php | 181 ++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 95 deletions(-) (limited to 'config') 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 @@ . + asterisk_calls.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Scott Ullrich Copyright (C) 2013 robi - All rights reserved. - - originally part of m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2005 Manuel Kasper . + 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; } +} ?> - - + + + + + +
+ - - - - - - - -
- -
-
- - - - - - - - - - - - - - " . $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 "
-
-
- -

+

+
+ + + + + + + + + + + + + + " . $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."; +if ($g['platform'] == "nanobsd") { + echo "
This log may be lost when rebooting the system."; +} ?> - -
- + -- cgit v1.2.3 From 4956a4e77d3b0bba09163b68df067174997c6233 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 16:40:04 +0200 Subject: asterisk - code style cleanup - Fix copyright header - Code style and indentation fixes - XHTML validation fixes --- config/asterisk/asterisk_cmd.php | 132 +++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 67 deletions(-) (limited to 'config') diff --git a/config/asterisk/asterisk_cmd.php b/config/asterisk/asterisk_cmd.php index da684cde..5ba1b460 100644 --- a/config/asterisk/asterisk_cmd.php +++ b/config/asterisk/asterisk_cmd.php @@ -1,14 +1,10 @@ . + asterisk_cmd.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Scott Ullrich Copyright (C) 2013 robi - All rights reserved. - - originally part of m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2005 Manuel Kasper . + 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 */ @@ -56,73 +52,75 @@ include("head.inc"); - - - +
+ + + + +
+ +
+
+ + + + - - - -
+ + + "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + ?> + + + "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + ?> + +
+
"; + echo $asterisk_command; + echo ""; ?>
-
- - - - - - - -
- - "; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - //echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - ?> -
-
- "; - echo $asterisk_command; - echo ""; - ?> -
-
-
+
+ +
+ + + -- cgit v1.2.3 From 1c9925ffd3a3d41f81efc088918857a73dccb6ea Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 18:22:14 +0200 Subject: asterisk - code style cleanup A couple of missed XHTML fixes. --- config/asterisk/asterisk_calls.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/asterisk/asterisk_calls.php b/config/asterisk/asterisk_calls.php index 5150c95f..791b6d85 100644 --- a/config/asterisk/asterisk_calls.php +++ b/config/asterisk/asterisk_calls.php @@ -119,10 +119,10 @@ if (file_exists($callog)) { - + - - + + "; + echo ""; echo ""; echo ""; ?> -- cgit v1.2.3 From 8c46f64b8a9835973e592d4b0a5c7fe91cef3dbd Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 19:13:56 +0200 Subject: asterisk - code style cleanup - Fix copyright header - Code style and indentation fixes - XHTML validation --- config/asterisk/asterisk_edit_file.php | 425 ++++++++++++++++----------------- 1 file changed, 212 insertions(+), 213 deletions(-) (limited to 'config') diff --git a/config/asterisk/asterisk_edit_file.php b/config/asterisk/asterisk_edit_file.php index 1c992d26..353ecd07 100644 --- a/config/asterisk/asterisk_edit_file.php +++ b/config/asterisk/asterisk_edit_file.php @@ -1,8 +1,10 @@ Copyright (C) 2013 robi + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,7 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. */ /* - pfSense_MODULE: shell + pfSense_MODULE: asterisk */ ##|+PRIV @@ -37,21 +39,19 @@ ##|*MATCH=asterisk_edit_file.php* ##|-PRIV -$pgtitle = array(gettext("Status"),gettext("Asterisk configuration files")); require("guiconfig.inc"); - $backup_dir = "/conf"; $backup_filename = "asterisk_config.bak.tgz"; $backup_path = "{$backup_dir}/{$backup_filename}"; $files_dir = "/conf/asterisk"; $host = "{$config['system']['hostname']}.{$config['system']['domain']}"; -$downname = "asterisk-config-{$host}-".date("YmdHis").".bak.tgz"; //put the date in the filename +// Put the date in the filename +$downname = "asterisk-config-{$host}-" . date("YmdHis") . ".bak.tgz"; if (($_GET['a'] == "download") && $_GET['t'] == "backup") { conf_mount_rw(); -// system("cd {$files_dir} && tar czf {$backup_path} *"); - system("cd {$files_dir} && tar czf {$backup_path} --exclude 'dist/*' --exclude dist *"); + system("cd {$files_dir} && /usr/bin/tar czf {$backup_path} --exclude 'dist/*' --exclude dist *"); conf_mount_ro(); } @@ -63,8 +63,8 @@ if (($_GET['a'] == "download") && file_exists("{$backup_path}")) { header("Content-Type: application/download"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=\"{$downname}\""); - header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 - header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past + header("Cache-Control: no-cache, must-revalidate"); + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header("Content-Length: " . filesize("{$backup_path}")); fpassthru($fd); exit; @@ -72,40 +72,38 @@ if (($_GET['a'] == "download") && file_exists("{$backup_path}")) { if ($_GET['a'] == "other") { if ($_GET['t'] == "restore") { - //extract files to $files_dir (/conf/asterisk) + // Extract files to $files_dir (/conf/asterisk) if (file_exists($backup_path)) { - //echo "The file $filename exists"; conf_mount_rw(); - exec("tar -xzC {$files_dir} -f {$backup_path} 2>&1", $sysretval); + exec("/usr/bin/tar -xzC {$files_dir} -f {$backup_path} 2>&1", $sysretval); $savemsg = "Backup has been restored, please restart Asterisk now " . $sysretval[1]; - system("chmod -R 644 {$files_dir}/*"); - header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ; + system("/bin/chmod -R 644 {$files_dir}/*"); + header('Location: asterisk_edit_file.php?savemsg=' . $savemsg); conf_mount_ro(); } else { - header( 'Location: asterisk_edit_file.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; + header('Location: asterisk_edit_file.php?savemsg=Restore+failed.+Backup+file+not+found.'); } exit; } if ($_GET['t'] == "factrest") { - //extract files to $files_dir (/conf/asterisk) + // Extract files to $files_dir (/conf/asterisk) if (file_exists('/conf.default/asterisk_factory_defaults_config.tgz')) { - //echo "The file $filename exists"; conf_mount_rw(); - exec("tar -xzC {$files_dir} -f /conf.default/asterisk_factory_defaults_config.tgz 2>&1", $sysretval); + exec("/usr/bin/tar -xzC {$files_dir} -f /conf.default/asterisk_factory_defaults_config.tgz 2>&1", $sysretval); $savemsg = "Factory configuration restored, please restart Asterisk now " . $sysretval[1]; - system("chmod -R 644 {$files_dir}/*"); - header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ; + system("/bin/chmod -R 644 {$files_dir}/*"); + header('Location: asterisk_edit_file.php?savemsg=' . $savemsg); conf_mount_ro(); } exit; } if ($_GET['t'] == "deldist") { - //delete dist directory from $files_dir/dist (/conf/asterisk/dist) + // Delete dist directory from $files_dir/dist (/conf/asterisk/dist) if (file_exists($files_dir . "/dist")) { conf_mount_rw(); - exec("rm -r {$files_dir}/dist 2>&1", $sysretval); + exec("/bin/rm -r {$files_dir}/dist 2>&1", $sysretval); $savemsg = "Deleted dist files " . $sysretval[1]; - header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ; + header('Location: asterisk_edit_file.php?savemsg=' . $savemsg); conf_mount_ro(); } exit; @@ -114,53 +112,55 @@ if ($_GET['a'] == "other") { if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { $upfilnam = $_FILES['ulfile']['name']; - $upfiltim = strtotime(str_replace(".bak.tgz","",end(explode("-",$upfilnam)))); + $upfiltim = strtotime(str_replace(".bak.tgz", "", end(explode("-", $upfilnam)))); conf_mount_rw(); move_uploaded_file($_FILES['ulfile']['tmp_name'], "{$backup_path}"); - $savemsg = "Uploaded ". htmlentities($_FILES['ulfile']['name']) . " file as " . $backup_path . "." ; - system('chmod -R 644 {$backup_path}'); - if ($upfiltim) { //take the date from the filename and update modified time accordingly + $savemsg = "Uploaded " . htmlentities($_FILES['ulfile']['name']) . " file as " . $backup_path . "."; + system("/bin/chmod -R 644 {$backup_path}"); + // Take the date from the filename and update modified time accordingly + if ($upfiltim) { touch($backup_path, $upfiltim); } unset($_POST['txtCommand']); conf_mount_ro(); - header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ; + header('Location: asterisk_edit_file.php?savemsg=' . $savemsg); } -if($_REQUEST['action']) { +if ($_REQUEST['action']) { switch($_REQUEST['action']) { case 'load': - if(strlen($_REQUEST['file']) < 1) { + if (strlen($_REQUEST['file']) < 1) { echo "|5|" . gettext("No file name specified") . ".|"; - } elseif(is_dir($_REQUEST['file'])) { + } elseif (is_dir($_REQUEST['file'])) { echo "|4|" . gettext("Loading a directory is not supported") . ".|"; - } elseif(! is_file($_REQUEST['file'])) { + } 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) { + if ($data === false) { echo "|1|" . gettext("Failed to read file") . ".|"; } else { - echo "|0|{$_REQUEST['file']}|{$data}|"; + echo "|0|{$_REQUEST['file']}|{$data}|"; } } exit; case 'save': - if(strlen($_REQUEST['file']) < 1) { + 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")) + 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) { + if ($ret === false) { echo "|" . gettext("Failed to write file") . ".|"; - } elseif($ret <> strlen($_REQUEST['data'])) { + } elseif ($ret <> strlen($_REQUEST['data'])) { echo "|" . gettext("Error while writing file") . ".|"; } else { echo "|" . gettext("File successfully saved") . ".|"; @@ -170,10 +170,10 @@ if($_REQUEST['action']) { } exit; } + $shortcut_section = "asterisk"; +$pgtitle = array(gettext("Status"), gettext("Asterisk configuration files")); require("head.inc"); -outputJavaScriptFileInline("filebrowser/browser.js"); -outputJavaScriptFileInline("javascript/base64.js"); ?> @@ -181,21 +181,34 @@ outputJavaScriptFileInline("javascript/base64.js"); - + + + + - - - - - - +
- -
-
- - -
-
-
- - - - +
- Backup / Restore - The 'Backup' button will tar gzip asterisk configuration files to it then offers it to download.
- The 'Restore' button will be visible only if the backup file exists.
- You can upload a backup file to the system, if one already exists at , it will be overwritten. -
-
+ + + + + +
+ +
+
+ +
+

+ + + + -
+ Backup / Restore + The 'Backup' button will tar gzip asterisk configuration files to it then offers it to download.
+ The 'Restore' button will be visible only if the backup file exists.
+ You can upload a backup file to the system, if one already exists at , it will be overwritten.
+
\n"; - if (file_exists($backup_path)) { - echo " \n"; - } + echo "\n"; + if (file_exists($backup_path)) { + echo "\n"; + } ?> -

- - - + +
+
+
+ + + - + - -
" . date ("Y F d H:i:s.", filemtime($backup_path)); + echo $backup_filename . " date:
" . date ("Y F d H:i:s.", filemtime($backup_path)); } ?> -
-
+
+ Upload backup file: - - + + -

-
-
- - - - - - - -
- - - - - - -
- : - - - - -
-
- - - - - - - - - - - - - - - -
-
- -
-
- -
- - - - -
-
- - - - -

- enable   \n"; - } - if (file_exists("/conf.default/asterisk_factory_defaults_config.tgz")) { - echo "enable \n"; - } - ?> -

-
-
- - +
+
+ + + + + - -
+ + + + + +
+ : + + + +
+
+ + +
+ -

+ +

+ + + + + + +
+
+ +
+
+
+ + + +
+
+ + + + +

+ enable   \n"; + } + if (file_exists("/conf.default/asterisk_factory_defaults_config.tgz")) { + echo "enable \n"; + } + ?> +
+
+
+
+
+
+
+ +

-
+

-
- + -- cgit v1.2.3 From 9bda6218ad5ed9389bfde4fa79a2944e0f271b9c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 19:33:24 +0200 Subject: asterisk - code style cleanup - Fix copyright header - Code style and indentation fixes - XHTML validation --- config/asterisk/asterisk_log.php | 110 +++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 62 deletions(-) (limited to 'config') diff --git a/config/asterisk/asterisk_log.php b/config/asterisk/asterisk_log.php index f4a752d2..44ba8acf 100644 --- a/config/asterisk/asterisk_log.php +++ b/config/asterisk/asterisk_log.php @@ -1,15 +1,11 @@ . - Copyright (C) 2012 robi + asterisk_log.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2012 robi Copyright (C) 2012 Marcello Coutinho - All rights reserved. - - originally part of m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2005 Manuel Kasper . + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,7 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: asterisk */ @@ -51,94 +47,84 @@ $shortcut_section = "asterisk"; include("head.inc"); /* Path to Asterisk log file */ -//if ($g['platform'] == "nanobsd") -// $log = "/tmp/asterisk.log"; -//else $log = "/var/log/asterisk/messages"; ?> /tmp/trimmed_asterisk.log && rm '$log' && mv /tmp/trimmed_asterisk.log '$log' && chown asterisk:asterisk '$log' && chmod g+w '$log'"); - header( 'Location: asterisk_log.php?savemsg=Log+trimmed.') ; + $trimres = shell_exec("/usr/bin/tail -n 50 '$log' > /tmp/trimmed_asterisk.log && /bin/rm '$log' && /bin/mv /tmp/trimmed_asterisk.log '$log' && /usr/sbin/chown asterisk:asterisk '$log' && /bin/chmod g+w '$log'"); + header('Location: asterisk_log.php?savemsg=Log+trimmed.'); } if ($cmd == "clear") { - $trimres=shell_exec("rm '$log' && touch '$log' && chown asterisk:asterisk '$log' && chmod g+w '$log'"); - header( 'Location: asterisk_log.php?savemsg=Log+cleared.') ; + $trimres = shell_exec("/bin/rm '$log' && /usr/bin/touch '$log' && /usr/sbin/chown asterisk:asterisk '$log' && /bin/chmod g+w '$log'"); + header('Location: asterisk_log.php?savemsg=Log+cleared.'); } } ?> - - + + + +
+ - - - - - -
- -
-
- - - - - - + - -
Last 50 Asterisk log entries
- +
+
+ + + + + + "; + echo ""; ?> -
Last 50 Asterisk log entries
-
"; - echo "
"; + echo "
-
-
+
+ +
-

+

-This log may be lost when rebooting the system."; -?> - - + This log may be lost when rebooting the system."; + } + ?>
-- cgit v1.2.3 From 8b2aba56e93b619841a5424d3820ca1cf42e1adb Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 18 Aug 2015 20:43:42 +0200 Subject: EOL at EOF --- config/asterisk/pkg_asterisk.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/asterisk/pkg_asterisk.inc b/config/asterisk/pkg_asterisk.inc index 129313c4..ad26ee80 100644 --- a/config/asterisk/pkg_asterisk.inc +++ b/config/asterisk/pkg_asterisk.inc @@ -8,4 +8,4 @@ $shortcuts['asterisk']['log'] = "asterisk_log.php"; $shortcuts['asterisk']['status'] = "asterisk_cmd.php"; $shortcuts['asterisk']['service'] = "asterisk"; -?> \ No newline at end of file +?> -- cgit v1.2.3