diff options
Diffstat (limited to 'config')
145 files changed, 7958 insertions, 13044 deletions
diff --git a/config/arpwatch/arpwatch.xml b/config/arpwatch/arpwatch.xml index a40422d4..aa6a9ae8 100644 --- a/config/arpwatch/arpwatch.xml +++ b/config/arpwatch/arpwatch.xml @@ -1,28 +1,30 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> <![CDATA[ -/* ========================================================================== +/* $Id$ */ +/* ====================================================================================== */ /* arpwatch.xml - part of pfSense (https://www.pfsense.org) - Copyright (C) 2007-2014 Electric Sheep Fencing LP + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2015 Electric Sheep Fencing LP 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. + 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 @@ -34,15 +36,13 @@ 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>ARP Monitoring Daemon</description> - <requirements>None</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>arpwatch</name> - <version>2.1.a14 pkg v1.1.1</version> + <version>1.1.2</version> <title>arpwatch: Settings</title> <aftersaveredirect>pkg_edit.php?xml=arpwatch.xml&id=0</aftersaveredirect> <menu> @@ -71,12 +71,12 @@ <configpath>installedpackages->package->$packagename->configuration->settings</configpath> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>a+rx</chmod> + <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/arpwatch/arpwatch_reports.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/sbin/</prefix> - <chmod>a+rx</chmod> + <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/arpwatch/sm.php</item> </additional_files_needed> <fields> @@ -90,33 +90,44 @@ <fielddescr>Enable E-mail Notifications</fielddescr> <fieldname>enable_email</fieldname> <type>checkbox</type> - <description>Sends an E-mail notification for each new station and ARP change as they are seen <strong>instead of</strong> local reports.<br/>NOTE: Only works on pfSense 2.1 or later. <br/>NOTE 2: Disables local reports which rely on arpwatch debug mode, which does not work with e-mail notifications.<br/>Configure SMTP and address settings in System > Advanced on the Notifications tab</description> + <description> + <![CDATA[ + Sends an E-mail notification for each new station and ARP change as they are seen <strong>, instead of</strong> local reports.<br /> + NOTE: Disables local reports which rely on arpwatch debug mode, which does not work with e-mail notifications.<br /> + Configure SMTP and address settings in System - Advanced on the Notifications tab. + ]]> + </description> </field> </fields> <custom_php_global_functions> <![CDATA[ function sync_package_arpwatch() { global $config; - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); conf_mount_rw(); - config_lock(); $log_file = "/var/log/arp.dat"; - if($_POST['interface'] != "") { - $int = $_POST['interface']; - } else { - $int = $config['installedpackages']['arpwatch']['config'][0]['interface']; - } + + /* E-mail notifications setup */ $mail = ""; $debug = ""; - if(($pf_version > 2.0) && (isset($_POST['enable_email']) || ($config['installedpackages']['arpwatch']['config'][0]['enable_email'] == "on"))) { - if (!empty($config['notifications']['smtp']['notifyemailaddress'])) + if (isset($_POST['enable_email']) || ($config['installedpackages']['arpwatch']['config'][0]['enable_email'] == "on")) { + if (!empty($config['notifications']['smtp']['notifyemailaddress'])) { $mail = " -m \"{$config['notifications']['smtp']['notifyemailaddress']}\""; + } } else { $debug = "-d"; } + + /* Listening interface setup */ + if ($_POST['interface'] != "") { + $int = $_POST['interface']; + } else { + $int = $config['installedpackages']['arpwatch']['config'][0]['interface']; + } $int = convert_friendly_interface_to_real_interface_name($int); - $start = "touch {$log_file}\n"; - $start .= "/usr/local/sbin/arpwatch {$debug} -f {$log_file} {$mail} -i {$int} > /var/log/arpwatch.reports 2>&1 &"; + + /* Create init script */ + $start = "/usr/bin/touch {$log_file}\n"; + $start .= "/usr/local/sbin/arpwatch {$debug} -f {$log_file} {$mail} -i {$int} > /var/log/arpwatch.reports 2>&1 &"; $stop = "/usr/bin/killall arpwatch"; write_rcfile(array( "file" => "arpwatch.sh", @@ -124,9 +135,9 @@ "stop" => $stop ) ); + restart_service("arpwatch"); conf_mount_ro(); - config_unlock(); } ]]> </custom_php_global_functions> @@ -141,4 +152,9 @@ @link("/usr/sbin/sm.php", "/usr/sbin/sendmail"); ]]> </custom_php_install_command> + <custom_php_resync_config_command> + <![CDATA[ + sync_package_arpwatch(); + ]]> + </custom_php_resync_config_command> </packagegui> diff --git a/config/arpwatch/arpwatch_reports.php b/config/arpwatch/arpwatch_reports.php index 9b3b1c6c..c1ab376f 100755 --- a/config/arpwatch/arpwatch_reports.php +++ b/config/arpwatch/arpwatch_reports.php @@ -1,61 +1,65 @@ #!/usr/local/bin/php <?php /* - $Id$ + arpwatch_reports.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2005 Colin Smith + Copyright (C) 2007-2015 ESF, LLC + All rights reserved. - arpwatch_reports.php - Copyright (C) 2005 Colin Smith - All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - 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. - 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. - 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. + 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. */ - require_once("guiconfig.inc"); require_once("service-utils.inc"); $logfile = "/var/log/arp.dat"; if ($_POST['clear']) { - stop_service("arpwatch"); + conf_mount_rw(); + stop_service("arpwatch"); unlink_if_exists($logfile); touch($logfile); start_service("arpwatch"); + conf_mount_ro(); } -if(file_exists($logfile)) { +if (file_exists($logfile)) { $rawrep = file($logfile); - foreach($rawrep as $line) { - $todo = preg_split('/\s/', $line); + foreach ($rawrep as $line) { + $todo = preg_split('/\s/', $line); $rawmac = explode(":", trim($todo[0])); - foreach($rawmac as $set) $mac[] = str_pad($set, 2, "0", STR_PAD_LEFT); + foreach ($rawmac as $set) { + $mac[] = str_pad($set, 2, "0", STR_PAD_LEFT); + } $newmac = implode(":", $mac); - $report[$todo[1]][] = array( - "mac" => $newmac, - "timestamp" => trim($todo[2]), - "hostname" => trim($todo[3]) ? trim($todo[3]) : "Unknown" - ); + $report[$todo[1]][] = array( + "mac" => $newmac, + "timestamp" => trim($todo[2]), + "hostname" => trim($todo[3]) ? trim($todo[3]) : "Unknown" + ); unset($mac); } } + $pgtitle = "arpwatch: Reports"; include("head.inc"); @@ -64,23 +68,23 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td> + <tr> + <td> <?php - $tab_array = array(); - $tab_array[] = array("Settings", false, "pkg_edit.php?xml=arpwatch.xml&id=0"); + $tab_array = array(); + $tab_array[] = array("Settings", false, "pkg_edit.php?xml=arpwatch.xml&id=0"); $tab_array[] = array("Reports", true, "arpwatch_reports.php"); display_top_tabs($tab_array); ?> - </td> - </tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0"> - <tr> - <td colspan="4" class="listtopic">arp.dat entries</td> - </tr> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td colspan="4" class="listtopic">arp.dat entries</td> + </tr> <tr> <td width="15%" class="listhdrr">IP</td> <td width="25%" class="listhdrr">Timestamp</td> @@ -88,14 +92,14 @@ include("head.inc"); <td width="45%" class="listhdrr">Hostname</td> </tr> <?php - if($report) - foreach($report as $ip => $rawentries) { + if ($report) { + foreach ($report as $ip => $rawentries) { $printip = true; $entries = $rawentries; sort($entries); - foreach($entries as $entry) { + foreach ($entries as $entry) { echo '<tr>'; - if($printip) { + if ($printip) { echo '<td class="listlr">' . $ip . '</td>'; $stampclass = "listr"; $printip = false; @@ -111,17 +115,21 @@ include("head.inc"); echo '</tr>'; } } + } ?> - <tr> - <td> - <br> - <form action="arpwatch_reports.php" method="post"> - <input name="clear" type="submit" class="formbtn" value="Clear log"> - </form> - </td> - </tr> - </table> - </div> - </td> - </tr> + <tr> + <td> + <br /> + <form action="arpwatch_reports.php" method="post"> + <input name="clear" type="submit" class="formbtn" value="Clear log" /> + </form> + </td> + </tr> + </table> + </div> + </td> + </tr> </table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/arpwatch/sm.php b/config/arpwatch/sm.php index 2e1cc4a0..4df6cead 100644 --- a/config/arpwatch/sm.php +++ b/config/arpwatch/sm.php @@ -1,33 +1,49 @@ #!/usr/local/bin/php -q <?php +/* + sm.php + part of pfSense (https://www.pfSense.org/) + 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. +*/ require_once("config.inc"); require_once("globals.inc"); require_once("notices.inc"); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if (($pf_version < 2.1)) { - $error = "Sending e-mail on this version of pfSense is not supported. Please use pfSense 2.1 or later"; - log_error($error); - echo "{$error}\n"; - return; -} - $options = getopt("s::"); - $message = ""; -if($options['s'] <> "") { +if ($options['s'] <> "") { $subject = $options['s']; } - $in = file("php://stdin"); -foreach($in as $line){ +foreach ($in as $line) { $line = trim($line); - if ( (substr($line, 0, 6) == "From: ") - || (substr($line, 0, 6) == "Date: ") - || (substr($line, 0, 4) == "To: ")) + if ((substr($line, 0, 6) == "From: ") || (substr($line, 0, 6) == "Date: ") || (substr($line, 0, 4) == "To: ")) { continue; + } if (empty($subject) && (substr($line, 0, 9) == "Subject: ")) { $subject = substr($line, 9); continue; @@ -35,8 +51,10 @@ foreach($in as $line){ $message .= "$line\n"; } -if (!empty($subject)) +if (!empty($subject)) { send_smtp_message($message, $subject); -else +} else { send_smtp_message($message); -?>
\ No newline at end of file +} + +?> diff --git a/config/autoconfigbackup/autoconfigbackup.inc b/config/autoconfigbackup/autoconfigbackup.inc index 2511a2a1..7050aab6 100644 --- a/config/autoconfigbackup/autoconfigbackup.inc +++ b/config/autoconfigbackup/autoconfigbackup.inc @@ -188,8 +188,6 @@ function upload_config($reasonm = "") { // Mount RW (if needed) conf_mount_rw(); - // Lock config - config_lock(); $notice_text = "Beginning https://portal.pfsense.org configuration backup."; log_error($notice_text); @@ -254,8 +252,6 @@ function upload_config($reasonm = "") { update_filter_reload_status($notice_text); } - // Unlock config - config_unlock(); // Mount image RO (if needed) conf_mount_ro(); diff --git a/config/bacula-client/bacula-client.inc b/config/bacula-client/bacula-client.inc index 8a04d55b..07be3067 100644 --- a/config/bacula-client/bacula-client.inc +++ b/config/bacula-client/bacula-client.inc @@ -1,128 +1,118 @@ <?php - -/* ========================================================================== */ -/* - bacula-client.inc - part of pfSense (http://www.pfSense.com) - Copyright (C) 2012 Marcio Carlos Braga Antao - Copyright (C) 2012-2013 Marcello Coutinho - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 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. - */ -/* ========================================================================== */ - require_once("config.inc"); - require_once("util.inc"); - - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version > 2.0) + bacula-client.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Marcio Carlos Braga Antao + Copyright (C) 2012-2013 Marcello Coutinho + 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. +*/ +require_once("config.inc"); +require_once("util.inc"); + +$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pf_version == "2.1" || $pf_version == "2.2") { define('BACULA_LOCALBASE', '/usr/pbi/bacula-' . php_uname("m")); -else +} else { define('BACULA_LOCALBASE','/usr/local'); - +} define('BACULA_STARTUP_SCRIPT', '/usr/local/etc/rc.d/bacula-fd.sh'); -function baculaclient_custom_php_install_command(){ - global $g, $config; +function baculaclient_custom_php_install_command() { baculaclient_custom_php_write_config(); } function baculaclient_custom_php_deinstall_command(){ - global $g, $config; - conf_mount_rw(); - // 1. Delete our config file - unlink_if_exists(BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf"); + // Delete our config file + unlink_if_exists(BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf"); + // Stop service and delete our rc file + stop_service("bacula-client"); + unlink_if_exists(BACULA_STARTUP_SCRIPT); - // 2. Re-run sshd config generation script - exec(BACULA_STARTUP_SCRIPT . " stop"); conf_mount_ro(); } function baculaclient_custom_php_write_config(){ - global $g, $config; + global $config, $LocalDirector; conf_mount_rw(); - //check config_file - $startup_file=BACULA_LOCALBASE . "/etc/rc.d/bacula-fd"; - if (file_exists($startup_file)){ - $startup_script=file_get_contents($startup_file); - $startup_script=preg_replace("/NO/","YES",$startup_script); - $startup_script=preg_replace("@/usr/local/etc/bacula-fd.conf@",BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf",$startup_script); - $startup_script=preg_replace("@/usr/local/etc/bacula/bacula-fd.conf@",BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf",$startup_script); - file_put_contents(BACULA_STARTUP_SCRIPT,$startup_script,LOCK_EX); - // Ensure bacula-fd has a+rx - exec("chmod a+rx " . BACULA_STARTUP_SCRIPT); - } - //check config - if (is_array($config['installedpackages']['baculaclient']['config'])){ + // Check config_file + $startup_file = BACULA_LOCALBASE . "/etc/rc.d/bacula-fd"; + if (file_exists($startup_file)) { + $startup_script = file_get_contents($startup_file); + $startup_script = preg_replace("/NO/","YES", $startup_script); + $startup_script = preg_replace("@/usr/local/etc/bacula-fd.conf@", BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf", $startup_script); + $startup_script = preg_replace("@/usr/local/etc/bacula/bacula-fd.conf@", BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf", $startup_script); + file_put_contents(BACULA_STARTUP_SCRIPT, $startup_script, LOCK_EX); + // Ensure bacula-fd is executable + chmod(BACULA_STARTUP_SCRIPT, 0755); + } + + // Check config + if (is_array($config['installedpackages']['baculaclient']['config'])) { $baculaclient_conf=""; foreach ($config['installedpackages']['baculaclient']['config'] as $bc) { - // create Director - switch ($bc['type']){ - case "Director": - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; - Break; - case "Monitor": - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; - break; - case "Local": - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; - $LocalDirector = $bc['director']; - } - + // Create Director + switch ($bc['type']) { + case "Director": + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; + break; + case "Monitor": + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; + break; + case "Local": + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; + $LocalDirector = $bc['director']; } - // create Messages + } + + // Create Messages if (!empty($LocalDirector)) { $baculaclient_conf .= "Messages { \n\tName = Standard \n\tdirector = {$LocalDirector}-dir = all, !skipped, !restored\n}\n"; } - // create FielDaemon - - if (is_array($config['installedpackages']['baculaclientfd']['config'])){ - $port = $config['installedpackages']['baculaclientfd']['config'][0]['port']; - $jobs = $config['installedpackages']['baculaclientfd']['config'][0]['jobs']; - } - else{ - $port="9102"; - $jobs="20"; - } + // Create FileDaemon + if (is_array($config['installedpackages']['baculaclientfd']['config'])) { + $port = $config['installedpackages']['baculaclientfd']['config'][0]['port'] ?: '9102'; + $jobs = $config['installedpackages']['baculaclientfd']['config'][0]['jobs'] ?: '20'; + } if (!empty($LocalDirector)) { $baculaclient_conf .= "FileDaemon { \n\tName = {$LocalDirector}-fd #\n\tFDport = {$port}\n\tWorkingDirectory = /var/db/bacula\n\tPid Directory = /var/run\n\tMaximum Concurrent Jobs = {$jobs}\n}\n"; } - file_put_contents(BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf",$baculaclient_conf,LOCK_EX); - exec(BACULA_STARTUP_SCRIPT . " restart"); - // Mount Read-only - conf_mount_ro(); + // Write config file and start service + file_put_contents(BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf", $baculaclient_conf, LOCK_EX); + if (!empty($LocalDirector)) { + restart_service("bacula-client"); + } else { + log_error("[bacula-client] You need at least one local Director in order to run bacula-client."); } - } - ?> + conf_mount_ro(); + } +} +?> diff --git a/config/bacula-client/bacula-client.xml b/config/bacula-client/bacula-client.xml index 65b5231e..ce07e77e 100644 --- a/config/bacula-client/bacula-client.xml +++ b/config/bacula-client/bacula-client.xml @@ -1,81 +1,77 @@ <?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[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - bacula-client.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) Marcio Carlos Braga Antao - Copyright (C) 2012 Marcello Coutinho - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + bacula-client.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) Marcio Carlos Braga Antao + Copyright (C) 2012 Marcello Coutinho + 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: + 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. - 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. - 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>Client Install for Bacula 5.2.6 Backup</description> - <requirements>Bacula Server Installed in or network</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> + <requirements>Bacula Server Installed on your network.</requirements> <name>baculaclient</name> - <version>5.2.6</version> - <title>Bacula-Client: Setting</title> - <aftersaveredirect>/pkg.php?xml=bacula-client.xml</aftersaveredirect> + <version>1.0.8</version> + <title>Bacula Client: Settings</title> + <aftersaveredirect>/pkg.php?xml=bacula-client.xml</aftersaveredirect> <include_file>/usr/local/pkg/bacula-client.inc</include_file> <configpath>installedpackages->package->baculaclient</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/bacula-client/bacula-client.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/bacula-client/bacula-client_fd.xml</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/bacula-client/bacula-client_view_config.php</item> </additional_files_needed> <menu> - <name>Bacula-client</name> - <tooltiptext>bacula backup client</tooltiptext> + <name>Bacula Client</name> + <tooltiptext>Bacula Backup Client</tooltiptext> <section>Services</section> <configfile>bacula-client.xml</configfile> </menu> <service> <rcfile>bacula-fd.sh</rcfile> - <name>Bacula-client</name> + <name>bacula-client</name> <executable>bacula-fd</executable> - <description>bacula backup client</description> + <description>Bacula Backup Client</description> </service> <tabs> <tab> @@ -104,20 +100,20 @@ <columnitem> <fielddescr>Description</fielddescr> <fieldname>description</fieldname> - </columnitem> + </columnitem> </adddeleteeditpagefields> <fields> <field> <type>listtopic</type> <fieldname>directors</fieldname> <name>Directors</name> - </field> + </field> <field> <fielddescr>Director Name</fielddescr> <fieldname>director</fieldname> <type>input</type> <size>60</size> - <description>Name of director</description> + <description>Enter name for the Director.</description> <required/> </field> <field> @@ -132,7 +128,7 @@ <fieldname>password</fieldname> <type>password</type> <size>30</size> - <description><![CDATA[Enter password for Director use to Access.]]></description> + <description>Enter password used for Director access.</description> </field> <field> <fielddescr>Director type</fielddescr> @@ -143,20 +139,17 @@ <option><name>Local</name><value>Local</value></option> <option><name>Monitor</name><value>Monitor</value></option> </options> - <description>Director Type. You need at least one local director.</description> + <description> + <![CDATA[ + Select director type.<br /> + <strong>NOTE: You need at least one local Director.</strong> + ]]> + </description> </field> </fields> <custom_php_install_command> baculaclient_custom_php_install_command(); </custom_php_install_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_add_php_command> - </custom_add_php_command> <custom_php_resync_config_command> baculaclient_custom_php_write_config(); </custom_php_resync_config_command> diff --git a/config/bacula-client/bacula-client_fd.xml b/config/bacula-client/bacula-client_fd.xml index 08a64ea1..aed6d7b6 100644 --- a/config/bacula-client/bacula-client_fd.xml +++ b/config/bacula-client/bacula-client_fd.xml @@ -1,53 +1,52 @@ <?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[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - bacula-client_df.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2012 Marcio Carlos Braga Antao - Copyright (C) 2012 Marcello Coutinho - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + bacula-client.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) Marcio Carlos Braga Antao + Copyright (C) 2012 Marcello Coutinho + 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: + 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. - 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. - 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>Client Install for Bacula 5.2.6 Backup</description> - <requirements>Bacula Server Installed in or network</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> + <requirements>Bacula Server Installed on your network.</requirements> <name>baculaclientfd</name> - <version>5.2.6</version> - <title>Bacula-Client: FileDaemon Setting</title> - <aftersaveredirect>/pkg_edit.php?xml=bacula-client_fd.xml</aftersaveredirect> + <version>1.0.8</version> + <title>Bacula Client: FileDaemon Settings</title> + <aftersaveredirect>/pkg_edit.php?xml=bacula-client_fd.xml</aftersaveredirect> <include_file>/usr/local/pkg/bacula-client.inc</include_file> <configpath>installedpackages->package->baculaclient</configpath> <tabs> @@ -76,7 +75,7 @@ <fieldname>port</fieldname> <type>input</type> <size>4</size> - <description>Port for a File Daemon. Default : 9102 </description> + <description>Port for a File Daemon. (Default: 9102)</description> <required/> </field> <field> @@ -85,23 +84,14 @@ <type>input</type> <size>3</size> <required/> - <description>Maximum Concurrent Jobs. Default : 20</description> + <description>Maximum Concurrent Jobs. (Default: 20)</description> </field> </fields> - <custom_php_install_command> baculaclient_custom_php_install_command(); </custom_php_install_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_add_php_command> - </custom_add_php_command> <custom_php_resync_config_command> - baculaclient_custom_php_write_config(); + baculaclient_custom_php_write_config(); </custom_php_resync_config_command> </packagegui> diff --git a/config/bacula-client/bacula-client_view_config.php b/config/bacula-client/bacula-client_view_config.php index 28098965..c10a0cda 100644 --- a/config/bacula-client/bacula-client_view_config.php +++ b/config/bacula-client/bacula-client_view_config.php @@ -1,9 +1,9 @@ <?php /* bacula-client_view_config.php - part of pfSense (https://www.pfsense.org/) - Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com> - Copyright (C) 2012 M�rcio Carlos Ant�o + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Marcio Carlos Braga Antao + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,33 +27,26 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version < 2.0) - $one_two = true; - -if ($pf_version > 2.0) +$$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pf_version == "2.1" || $pf_version == "2.2") { define('BACULA_LOCALBASE', '/usr/pbi/bacula-' . php_uname("m")); -else +} else { define('BACULA_LOCALBASE','/usr/local'); +} $pgtitle = "Bacula-Client: View Configuration"; include("head.inc"); ?> + <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> -<?php if($one_two): ?> -<p class="pgtitle"><?=$pgtitle?></font></p> -<?php endif; ?> - <?php if ($savemsg) print_info_box($savemsg); ?> <form action="bacula-client_view_config.php" method="post"> - <div id="mainlevel"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> @@ -65,27 +58,24 @@ include("head.inc"); display_top_tabs($tab_array); ?> </td></tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td class="tabcont" > - <textarea id="varnishlogs" rows="50" cols="87%"> -<?php - $config_file = file_get_contents(BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf"); - echo $config_file; -?> - </textarea> - </td> - </tr> - </table> - </div> - </td> - </tr> + <tr><td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td class="tabcont"> + <textarea id="varnishlogs" rows="50" cols="87%"> + <?php + $config_file = file_get_contents(BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf"); + echo $config_file; + ?> + </textarea> + </td></tr> + </table> + </div> + </td></tr> </table> </div> </form> + <?php include("fend.inc"); ?> </body> -</html>
\ No newline at end of file +</html> diff --git a/config/bandwidthd/bandwidthd.inc b/config/bandwidthd/bandwidthd.inc index ac5cc116..9364cbbc 100644 --- a/config/bandwidthd/bandwidthd.inc +++ b/config/bandwidthd/bandwidthd.inc @@ -1,9 +1,11 @@ <?php -/* $Id$ */ /* bandwidthd.inc + part of pfSense (https://www.pfSense.org/) Copyright (C) 2006 Scott Ullrich - part of pfSense + Copyright (C) 2009 Bill Marquette + Copyright (C) 2012-2013 Phil Davis + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,184 +29,92 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -// Check pfSense version -$pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); +$pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); switch ($pfs_version) { - case "2.1": - define('PKG_BANDWIDTHD_BASE', '/usr/pbi/bandwidthd-' . php_uname("m") . '/bandwidthd'); - define('PKG_BANDWIDTHD_RUNTIME_LIBRARY_ENV', ''); - break; - case "2.2": - define('PKG_BANDWIDTHD_BASE', '/usr/pbi/bandwidthd-' . php_uname("m") . '/local/bandwidthd'); - define('PKG_BANDWIDTHD_RUNTIME_LIBRARY_ENV', 'LD_LIBRARY_PATH=/usr/pbi/bandwidthd-' . php_uname("m") . '/local/lib'); - break; - default: - define('PKG_BANDWIDTHD_BASE', '/usr/local/bandwidthd'); - define('PKG_BANDWIDTHD_RUNTIME_LIBRARY_ENV', ''); - } -// End: Check pfSense version - -function is_blank($value) { - return empty($value) && !is_numeric($value); + case "2.1": + define('PKG_BANDWIDTHD_BASE', '/usr/pbi/bandwidthd-' . php_uname("m") . '/bandwidthd'); + define('PKG_BANDWIDTHD_RUNTIME_LIBRARY_ENV', ''); + break; + case "2.2": + define('PKG_BANDWIDTHD_BASE', '/usr/pbi/bandwidthd-' . php_uname("m") . '/local/bandwidthd'); + define('PKG_BANDWIDTHD_RUNTIME_LIBRARY_ENV', 'LD_LIBRARY_PATH=/usr/pbi/bandwidthd-' . php_uname("m") . '/local/lib'); + break; + default: + define('PKG_BANDWIDTHD_BASE', '/usr/local/bandwidthd'); + define('PKG_BANDWIDTHD_RUNTIME_LIBRARY_ENV', ''); } function bandwidthd_install_deinstall() { conf_mount_rw(); - config_lock(); - exec("rm -f /usr/local/etc/rc.d/bandwidthd*"); - exec("rm -rf " . PKG_BANDWIDTHD_BASE . "/htdocs"); - exec("rm -f /usr/local/www/bandwidthd"); + stop_service("bandwidthd"); + mwexec("/bin/rm -rf " . PKG_BANDWIDTHD_BASE . "/htdocs"); + mwexec("/bin/rm -f /usr/local/www/bandwidthd"); // Remove the cron job, if it is there install_cron_job("/bin/kill -HUP `cat /var/run/bandwidthd.pid`", false); conf_mount_ro(); - config_unlock(); } function bandwidthd_install_config() { - global $config, $g; + global $config, $g, $bandwidthd_config; + conf_mount_rw(); /* bandwidthd doesn't have a way to pass a custom config path, unfortunately */ - /* the conf file must be ./etc/bandwidthd.conf relative to the current dir */ + /* So, the .conf file must be ./etc/bandwidthd.conf relative to the current dir */ $bandwidthd_base_dir = PKG_BANDWIDTHD_BASE; $bandwidthd_config_dir = PKG_BANDWIDTHD_BASE . "/etc"; $bandwidthd_runtime_library_env = PKG_BANDWIDTHD_RUNTIME_LIBRARY_ENV; - conf_mount_rw(); - config_lock(); - - /* user defined values */ + /* General Options */ $bandwidthd_config = $config['installedpackages']['bandwidthd']['config'][0]; - $meta_refresh = $bandwidthd_config['meta_refresh']; - if (is_numeric($meta_refresh)) - $meta_refresh = "meta_refresh $meta_refresh\n"; - else - $meta_refresh = ""; - - $graph = $bandwidthd_config['drawgraphs']; - if ($graph) - $graph = "graph true\n"; - else - $graph = "graph false\n"; - - $filter_text = $bandwidthd_config['filter']; - if (!is_blank($filter_text)) - $filter_text = "filter $filter_text\n"; - else - $filter_text = ""; - - $recover_cdf = $bandwidthd_config['recovercdf']; - if ($recover_cdf) - $recover_cdf = "recover_cdf true\n"; - else - $recover_cdf = ""; - - $output_cdf = $bandwidthd_config['outputcdf']; - if ($output_cdf) - $output_cdf_string = "output_cdf true\n"; - else - $output_cdf_string = ""; - - $output_postgresql = $bandwidthd_config['outputpostgresql']; - $postgresql_host = $bandwidthd_config['postgresqlhost']; - $postgresql_database = $bandwidthd_config['postgresqldatabase']; - $postgresql_username = $bandwidthd_config['postgresqlusername']; - $postgresql_password = $bandwidthd_config['postgresqlpassword']; - $postgresql_string = ""; - if ($output_postgresql) { - if (!is_blank($postgresql_host) && !is_blank($postgresql_username) && !is_blank($postgresql_database) && !is_blank($postgresql_password)) - $postgresql_string = "pgsql_connect_string \"user = $postgresql_username dbname = $postgresql_database password = $postgresql_password host = $postgresql_host\"\n"; - else - log_error("bandwidthd: You have to specify the postgreSQL Host, Database, Username and Password. postgreSQL details have been ignored."); - } - - $sensor_id = $bandwidthd_config['sensorid']; - - if (!is_blank($sensor_id)) - $sensor_id_string = "sensor_id \"$sensor_id\""; - else - $sensor_id_string = ""; - - $promiscuous = $bandwidthd_config['promiscuous']; - if ($promiscuous) - $promiscuous = "promiscuous true\n"; - else - $promiscuous = "promiscuous false\n"; - - $graph_cutoff = $bandwidthd_config['graphcutoff']; - if (!is_blank($graph_cutoff)) - $graph_cutoff = "graph_cutoff $graph_cutoff\n"; - else - $graph_cutoff = ""; - - $skip_intervals = $bandwidthd_config['skipintervals']; - if ($skip_intervals) { - $skip_intervals = "skip_intervals $skip_intervals\n"; - } else { - /* Includes the case where 0 is explicitly specified, which is the default anyway. */ - $skip_intervals = ""; - } - - if (!is_blank($bandwidthd_config['active_interface'])){ - $ifdescrs = array($bandwidthd_config['active_interface']); - } else { - log_error("You should specify an interface for bandwidthd to listen on. Exiting."); + /* Configure bandwidthd web interface */ + $dev = ""; + $ifdescrs = array($bandwidthd_config['active_interface']); + foreach ($ifdescrs as $ifdescr) { + $descr = convert_friendly_interface_to_real_interface_name($ifdescr); + $dev .= "dev \"{$descr}\"\n"; } - - $subnets_custom = explode(';',str_replace(' ','',$bandwidthd_config['subnets_custom'])); - - /* initialize to "" */ + /* Configure stats interface(s) */ $subnets = ""; - //$ifdescrs = array("lan", "wan"); - //for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { - //$ifdescrs['opt' . $j] = "opt" . $j; - //} - if (is_array($ifdescrs)) { - foreach ($ifdescrs as $int) { - /* calculate interface subnet information */ - $ifcfg = $config['interfaces'][$int]; - $subnet = gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']); - $subnetmask = gen_subnet_mask($ifcfg['subnet']); - $subnet_with_mask = ""; - if ($subnet == "pppoe") { - $subnet = find_interface_ip("ng0"); - if ($subnet) { - $subnet_with_mask = $subnet . "/32"; - } - } else { - if ($subnet) { - $subnet_with_mask = $subnet . "/" . $ifcfg['subnet']; - } - } - if (!empty($subnet_with_mask)) { - /* Only add the subnet if the user has not specified it in the custom subnets. */ - /* This avoids generating an unnecessary syntax error message from the config. */ - if (!in_array($subnet_with_mask, $subnets_custom)) - $subnets .= "subnet {$subnet_with_mask}\n"; - } + $stats_interfaces = $bandwidthd_config['interface_array'] ?: 'lan'; + foreach ($stats_interfaces as $iface) { + if (is_ipaddr(get_interface_ip($iface))) { + $subnets .= "subnet " . gen_subnet(get_interface_ip($iface),get_interface_subnet($iface)) . "/" . get_interface_subnet($iface) . "\n"; } } - - if (is_array($subnets_custom)) { - foreach ($subnets_custom as $sub) { - if (!empty($sub) && is_subnet($sub)) - $subnets .= "subnet {$sub}\n"; - } + $promiscuous_val = ($bandwidthd_config['promiscuous'] != "" ? "promiscuous true" : "promiscuous false"); + $sensor_id_string_val = ($bandwidthd_config['sensorid'] != "" ? "sensor_id \"{$bandwidthd_config['sensorid']}\"" : ""); + + /* Graphs Options */ + $graph_val = ($bandwidthd_config['drawgraphs'] != "" ? "graph true" : "graph false"); + $meta_refresh_val = ($bandwidthd_config['meta_refresh'] != "" ? "meta_refresh {$bandwidthd_config['meta_refresh']}" : ""); + $skip_intervals_val = ($bandwidthd_config['skipintervals'] != "" ? "skip_intervals {$bandwidthd_config['skipintervals']}" : ""); + $graph_cutoff_val = ($bandwidthd_config['graphcutoff'] != "" ? "graph_cutoff {$bandwidthd_config['graphcutoff']}" : ""); + $output_cdf_val = ($bandwidthd_config['outputcdf'] != "" ? "output_cdf true" : ""); + $recover_cdf_val = ($bandwidthd_config['recovercdf'] != "" ? "recover_cdf true" : ""); + + /* PostgreSQL Options */ + if ($bandwidthd_config['outputpostgresql']) { + $postgresql_host = $bandwidthd_config['postgresqlhost']; + $postgresql_database = $bandwidthd_config['postgresqldatabase']; + $postgresql_username = $bandwidthd_config['postgresqlusername']; + $postgresql_password = base64_decode($bandwidthd_config['postgresqlpasswordenc']); + $postgresql_string_val = "pgsql_connect_string \"user = $postgresql_username dbname = $postgresql_database password = $postgresql_password host = $postgresql_host\"\n"; + } else { + $postgresql_string_val = ""; } - /* initialize to "" */ - $dev = ""; - if (is_array($ifdescrs)) { - foreach ($ifdescrs as $ifdescr) { - $descr = convert_friendly_interface_to_real_interface_name($ifdescr); - $dev .= "dev \"$descr\"\n"; - } + /* Advanced Filter */ + if ($bandwidthd_config['advfilter']) { + $filter_text_val = "filter " . escapeshellarg(base64_decode($bandwidthd_config['advfilter'])); + } else { + $filter_text_val = ""; } + /* Write out the config file */ $config_file = <<<EOF # # This file was automatically generated by the pfSense -# package management system. Changing this file +# package management system. Changing this file # will lead to it being overwritten again when # the package manager resyncs. # @@ -214,62 +124,62 @@ function bandwidthd_install_config() { # Commented out options are here to provide # documentation and represent defaults -# Subnets to collect statistics on. Traffic that +# Subnets to collect statistics on. Traffic that # matches none of these subnets will be ignored. # Syntax is either IP Subnet Mask or CIDR -$subnets +{$subnets} # Device to listen on # Bandwidthd listens on the first device it detects -# by default. Run "bandwidthd -l" for a list of +# by default. Run "bandwidthd -l" for a list of # devices. -$dev +{$dev} ################################################### # Options that don't usually get changed # An interval is 2.5 minutes, this is how many # intervals to skip before doing a graphing run -$skip_intervals +{$skip_intervals_val} # Graph cutoff is how many k must be transferred by an # ip before we bother to graph it -$graph_cutoff +{$graph_cutoff_val} #Put interface in promiscuous mode to score to traffic #that may not be routing through the host machine. -$promiscuous +{$promiscuous_val} #Log data to cdf file htdocs/log.cdf -$output_cdf_string +{$output_cdf_val} #Read back the cdf file on startup -$recover_cdf +{$recover_cdf_val} # Standard postgres connect string, just like php, see postgres docs for # details -$postgresql_string +{$postgresql_string_val} # Arbitrary sensor name, I recommend the sensors fully qualified domain # name -$sensor_id_string +{$sensor_id_string_val} #Libpcap format filter string used to control what bandwidthd sees #Please always include "ip" in the string to avoid strange problems -$filter_text +{$filter_text_val} #Draw Graphs - This defaults to true to graph the traffic bandwidthd is recording #Usually set this to false if you only want cdf output or -#you are using the database output option. Bandwidthd will use very little +#you are using the database output option. Bandwidthd will use very little #ram and cpu if this is set to false. -$graph +{$graph_val} #Set META REFRESH seconds (default 150, use 0 to disable). -$meta_refresh +{$meta_refresh_val} EOF; - $fd = fopen("{$bandwidthd_config_dir}/bandwidthd.conf","w"); + $fd = fopen("{$bandwidthd_config_dir}/bandwidthd.conf", "w"); if (!$fd) { log_error("could not open {$bandwidthd_config_dir}/bandwidthd.conf for writing"); exit; @@ -277,13 +187,12 @@ EOF; fwrite($fd, $config_file); fclose($fd); + /* nanobsd hacks */ if ($g['platform'] == 'nanobsd') { $bandwidthd_nano_dir = "/var/bandwidthd"; $bandwidthd_htdocs_dir = $bandwidthd_nano_dir . "/htdocs"; if (!is_dir($bandwidthd_nano_dir)) { - if (file_exists($bandwidthd_nano_dir)) { - unlink($bandwidthd_nano_dir); - } + unlink_if_exists($bandwidthd_nano_dir); mkdir($bandwidthd_nano_dir); } } else { @@ -292,24 +201,19 @@ EOF; $rc = array(); $rc['file'] = 'bandwidthd.sh'; - $rc['stop'] = <<<EOD -/usr/bin/killall bandwidthd -EOD; + $rc['stop'] = '/usr/bin/killall bandwidthd'; - // If this is an old config before the enable checkbox was added, then enable by default - $bandwidthd_enable = (!isset($bandwidthd_config['enable']) || ($bandwidthd_config['enable'])); - if ($bandwidthd_enable) { + if ($bandwidthd_config['enable']) { if ($g['platform'] == 'nanobsd') { - // On nanobsd, /var/bandwidthd is created. - // In that is a real /var/bandwidth/htdocs, where the graph data is written - // A soft link to the real bandwidth program is made - /var/bandwidthd/bandwidthd - // A soft link to the etc folder with the conf file is made - /var/bandwidthd/etc - // bandwidthd is started from /var/bandwidthd with the current dir /var/bandwidth - // This way, it: - // looks in ./etc for the conf file - // writes graph files in ./htdocs - // writes cdf log files (if selected in the config) to ./ - // All of this is on the /var filesystem, which is a read-write memory disk on nanobsd + /* On nanobsd: + * first, /var/bandwidthd is created, with real /var/bandwidth/htdocs inside, where the graph data is written; + * soft link to the real bandwidth program is made - /var/bandwidthd/bandwidthd; + * soft link to the etc folder with the conf file is made - /var/bandwidthd/etc; + * bandwidthd is started from /var/bandwidthd with the current dir /var/bandwidth. + * This way, it looks in ./etc for the conf file, writes graph files in ./htdocs + * writes cdf log files (if selected in the config) to ./ + * All of these are on the /var filesystem, which is a read-write memory disk on nanobsd */ + $rc['start'] = <<<EOD if [ ! -d "{$bandwidthd_nano_dir}" ] ; then if [ -e "{$bandwidthd_nano_dir}" ] ; then @@ -358,21 +262,17 @@ EOD; $rc['start'] = "return"; } - /* write out rc.d start/stop file */ + /* Write out rc.d file */ write_rcfile($rc); if (!is_dir($bandwidthd_htdocs_dir)) { - if (file_exists($bandwidthd_htdocs_dir)) { - unlink($bandwidthd_htdocs_dir); - } - mkdir($bandwidthd_htdocs_dir); + unlink_if_exists($bandwidthd_htdocs_dir); + safe_mkdir($bandwidthd_htdocs_dir); } + $bandwidthd_www_link = $g["www_path"] . "/bandwidthd"; if (!is_link($bandwidthd_www_link)) { - if (file_exists($bandwidthd_www_link)) { - // It is a file and not a link - clean it up. - unlink($bandwidthd_www_link); - } + unlink_if_exists($bandwidthd_www_link); symlink($bandwidthd_htdocs_dir, $bandwidthd_www_link); } @@ -381,20 +281,138 @@ EOD; exec("echo \"Please start bandwidthd to populate this directory.\" > " . $bandwidthd_index_file); } - if (($bandwidthd_enable) && ($output_cdf)) { + /* Cron job for graphs */ + if (($bandwidthd_config['enable']) && ($output_cdf)) { // Use cron job to rotate logs every day at 00:01 install_cron_job("/bin/kill -HUP `cat /var/run/bandwidthd.pid`", true, "1", "0"); - } - else - { - // Remove the cron job, if it is there + } else { + // Remove the cron job if it is there install_cron_job("/bin/kill -HUP `cat /var/run/bandwidthd.pid`", false); } + conf_mount_ro(); - config_unlock(); - stop_service("bandwidthd"); - if ($bandwidthd_enable) { - start_service("bandwidthd"); + + /* Restart the service if enabled; otherwise stop it */ + if ($bandwidthd_config['enable']) { + restart_service("bandwidthd"); + } else { + stop_service("bandwidthd"); + } +} + +function bandwidthd_upgrade_config() { + global $config, $changes; + // The 'Advanced Filter' options and 'Database Password' are now base64-encoded + // in order to now break config.xml if they contain some special chars. + // If this is an old config, pick up the original unencoded values and upgrade + $changes = 0; + $bandwidthd_config = $config['installedpackages']['bandwidthd']['config'][0]; + if (isset($bandwidthd_config['filter'])) { + $config['installedpackages']['bandwidthd']['config'][0]['advfilter'] = base64_encode($bandwidthd_config['filter']); + unset($config['installedpackages']['bandwidthd']['config'][0]['filter']); + $changes++; + } + if (isset($bandwidthd_config['postgresqlpassword'])) { + $config['installedpackages']['bandwidthd']['config'][0]['postgresqlpasswordenc'] = base64_encode($bandwidthd_config['postgresqlpassword']); + unset($config['installedpackages']['bandwidthd']['config'][0]['postgresqlpassword']); + $changes++; + } + // Subnet(s) for Statistics Collection - convert old subnets_custom to interface_array here as well. + if (isset($bandwidthd_config['subnets_custom'])) { + $i = 0; + $subnets_custom = explode(';', $bandwidthd_config['subnets_custom']); + // For each configured interface on this box... + $iflist = get_configured_interface_list_by_realif(); + foreach ($iflist as $if) { + // first, gets its subnet... + $sn = gen_subnet(get_interface_ip($if), get_interface_subnet($if)); + foreach ($subnets_custom as $subnet_custom) { + // next, strip the subnet mask from the old settings value... + $subnet_custom = substr($subnet_custom, 0, strpos($subnet_custom, '/')); + // next, try to match the originally configured subnet against configured interfaces... + if ($subnet_custom != "" && $subnet_custom == $sn) { + // skip PPPoE interfaces if any... + $realif = get_real_interface($if); + if (!preg_match("/pppoe[0-9]+/i", $realif)) { + // and finally, set the new config value for config.xml + $config['installedpackages']['bandwidthd']['config'][0]['interface_array'][$i] = $if; + $i++; + $changes++; + } + } + } + } + // Remove the old settings value now that we are done with config upgrade + unset($config['installedpackages']['bandwidthd']['config'][0]['subnets_custom']); + } + // Write the upgraded config.xml if something changed + if ($changes > 0 ) { + write_config("[bandwidthd] Upgraded old package configuration."); + } +} + +function bandwidthd_validate_input($post, &$input_errors) { + if ($post['active_interface']) { + $realif = get_real_interface($post['active_interface']); + $ip = find_interface_ip($realif); + if (!is_ipaddrv4($ip)) { + // IPv6-only interfaces are not supported + $errif = convert_friendly_interface_to_friendly_descr($post['active_interface']); + $input_errors[] = gettext("The \"{$errif}\" interface selected under 'BandwidthD Web Interface' has no IPv4 configured. Configured IPv4 is required."); + } + } else { + $input_errors[] = "You must select the 'BandwidthD Web Interface'."; + } + // bandwidthd does not work with PPPoE; IPv6 is also not supported + if ($post['interface_array']) { + foreach ($post['interface_array'] as $ifname) { + $realif = get_real_interface($ifname); + $ip = find_interface_ip($realif); + $errif = convert_friendly_interface_to_friendly_descr($ifname); + if (preg_match("/pppoe[0-9]+/i", $realif)) { + $input_errors[] = gettext("Sorry, BandwidthD does not support PPPoE interfaces. Remove \"{$errif}\" from 'Subnet(s) for Statistics Collection'."); + } + if (!is_ipaddrv4($ip)) { + $input_errors[] = gettext("The \"{$errif}\" interface selected under 'Subnet(s) for Statistics Collection' has no IPv4 configured. Configured IPv4 is required."); + } + } + } else { + $input_errors[] = "You must select at least on interface under 'Subnet(s) for Statistics Collection'."; + } + // Only support sane characters in Sensor ID + if ($post['sensorid']) { + if ((!is_hostname($post['sensorid'])) && !preg_match("/^[a-zA-Z0-9\-\=\(\):. ]*$/", $post['sensorid'])) { + $input_errors[] .= gettext('Sensor ID must be either a hostname or a string which may only contain characters matching ^[a-zA-Z0-9\-\(\):. ]*$ regexp.'); + } + } + if (($post['meta_refresh']) && (!is_numericint($post['meta_refresh']))) { + $input_errors[] = gettext("The value for 'Meta Refresh' must be a positive integer."); + } + if (($post['skipintervals']) && (!is_numericint($post['skipintervals']))) { + $input_errors[] = gettext("The value for 'Skip Intervals' must be a positive integer."); + } + if (($post['graphcutoff']) && (!is_numericint($post['graphcutoff']))) { + $input_errors[] = gettext("The value for 'Graph Cutoff' must be a positive integer."); + } + if ($post['outputpostgresql']) { + if (!$post['postgresqlhost']) { + $input_errors[] = gettext("The value for 'Database Host' must not be empty when 'Output to PostgreSQL' is enabled."); + } + if (!$post['postgresqldatabase']) { + $input_errors[] = gettext("The value for 'Database Name' must not be empty when 'Output to PostgreSQL' is enabled."); + } + if (!$post['postgresqlusername']) { + $input_errors[] = gettext("The value for 'Database User' must not be empty when 'Output to PostgreSQL' is enabled."); + } + if (!$post['postgresqlpasswordenc']) { + $input_errors[] = gettext("The value for 'Database Password' must not be empty when 'Output to PostgreSQL' is enabled."); + } + } + if (($post['postgresqlhost']) && (!is_hostname($post['postgresqlhost']))) { + $input_errors[] = gettext("The value for 'Database Host' must be a valid hostname or IPv4."); + } + if (($post['advfilter']) && !preg_match("/^[a-zA-Z0-9\+\-\=\(\):. ]*$/", $post['advfilter'])) { + $input_errors[] = gettext('Advanced traffic filtering options may only contain characters matching ^[a-zA-Z0-9\+\-\=\(\):. ]*$ regexp.'); } } diff --git a/config/bandwidthd/bandwidthd.xml b/config/bandwidthd/bandwidthd.xml index fc768761..1668f748 100644 --- a/config/bandwidthd/bandwidthd.xml +++ b/config/bandwidthd/bandwidthd.xml @@ -3,213 +3,297 @@ <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - <![CDATA[ +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - bandwidthd.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + bandwidthd.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2006 Scott Ullrich + Copyright (C) 2009 Bill Marquette + Copyright (C) 2012-2013 Phil Davis + 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: + 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. - 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. - 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. - */ -/* ========================================================================== */ + 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>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>bandwidthd</name> - <version>2.0.1_5 pkg v.0.4</version> - <title>Bandwidthd</title> + <version>0.6</version> + <title>Diagnostics: Bandwidthd</title> <aftersaveredirect>/pkg_edit.php?xml=bandwidthd.xml&id=0</aftersaveredirect> <include_file>/usr/local/pkg/bandwidthd.inc</include_file> <menu> <name>BandwidthD</name> <tooltiptext></tooltiptext> - <section>Services</section> + <section>Diagnostics</section> + <url>/bandwidthd/index.html</url> + </menu> + <menu> + <name>BandwidthD Settings</name> + <tooltiptext></tooltiptext> + <section>Diagnostics</section> <url>/pkg_edit.php?xml=bandwidthd.xml&id=0</url> </menu> <service> - <name>bandwidthd</name> - <rcfile>bandwidthd.sh</rcfile> - <executable>bandwidthd</executable> - <description>BandwidthD bandwidth monitoring daemon</description> + <name>bandwidthd</name> + <rcfile>bandwidthd.sh</rcfile> + <executable>bandwidthd</executable> + <description>BandwidthD bandwidth monitoring daemon</description> </service> <tabs> <tab> - <text>BandwidthD</text> + <text>Settings</text> <url>/pkg_edit.php?xml=bandwidthd.xml&id=0</url> <active/> </tab> <tab> <text>Access BandwidthD</text> - <url>/bandwidthd/index.html" target="_blank</url> + <url>/bandwidthd/index.html</url> </tab> </tabs> + <advanced_options>enabled</advanced_options> <configpath>installedpackages->package->bandwidthd</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0677</chmod> <item>https://packages.pfsense.org/packages/config/bandwidthd/bandwidthd.inc</item> </additional_files_needed> <fields> <field> - <fielddescr>Enable bandwidthd</fielddescr> + <name>General Options</name> + <type>listtopic</type> + </field> + <field> + <fielddescr>Enable BandwidthD</fielddescr> <fieldname>enable</fieldname> <type>checkbox</type> <description></description> </field> <field> - <fielddescr>Interface</fielddescr> + <fielddescr>BandwidthD Web Interface</fielddescr> <fieldname>active_interface</fieldname> - <description>The interface that bandwidthd will bind to.</description> + <description>Bind the BandwidthD web interface to IP address of the specified interface.</description> <type>interfaces_selection</type> + <hideinterfaceregex>(loopback|wan)</hideinterfaceregex> <required/> <default_value>lan</default_value> </field> <field> - <fielddescr>Subnet</fielddescr> - <fieldname>subnets_custom</fieldname> - <description>The subnet(s) on which bandwidthd will report. (separate with ';' for multiple subnets, e.g. 192.168.1.0/24;10.0.0.0/24) The ordinary subnet for the selected interface/s is automatically put in the config, do not specify it here.</description> + <fielddescr>Subnet(s) for Statistics Collection</fielddescr> + <fieldname>interface_array</fieldname> + <description> + <![CDATA[ + The subnet(s) on which BandwidthD will collect statistics. Traffic that matches none of these subnets will be ignored.<br /> + <strong>Note: PPPoE interfaces are NOT supported!</strong> + ]]> + </description> + <type>interfaces_selection</type> + <hideinterfaceregex>loopback</hideinterfaceregex> + <size>3</size> + <multiple>true</multiple> + <required/> + </field> + <field> + <fielddescr>Promiscuous</fielddescr> + <fieldname>promiscuous</fieldname> + <description> + <![CDATA[ + Put interface in promiscuous mode to see traffic that may not be routing through the host machine.<br /> + Note: If the interface is connected to a switch then the interface will only see the traffic on its port. + ]]> + </description> + <type>checkbox</type> + </field> + <field> + <fielddescr>Sensor ID</fielddescr> + <fieldname>sensorid</fieldname> + <description> + <![CDATA[ + Arbitrary sensor name.<br /> + (Using the sensor's fully qualified domain name is recommended.) + ]]> + </description> <type>input</type> </field> <field> - <fielddescr>Skip intervals</fielddescr> - <fieldname>skipintervals</fieldname> - <description>Number of intervals to skip between graphing. Default 0. Each interval is 200 seconds = 3 min 20 sec.</description> + <name>Graph Options</name> + <type>listtopic</type> + </field> + <field> + <fielddescr>Draw Graphs</fielddescr> + <fieldname>drawgraphs</fieldname> + <description> + <![CDATA[ + Enabled by default in order to graph the traffic that BandwidthD is recording. Uncheck this if you only want CDF output or you are using the database output option.<br /> + BandwidthD will use very little RAM and CPU if this option is disabled. + ]]> + </description> + <type>checkbox</type> + <default_value>on</default_value> + </field> + <field> + <fielddescr>Meta Refresh</fielddescr> + <fieldname>meta_refresh</fieldname> + <description> + <![CDATA[ + Sets the interval (seconds) at which the browser graph display refreshes<br /> + Default 150, use 0 to disable. + ]]> + </description> <type>input</type> </field> <field> - <fielddescr>Graph cutoff</fielddescr> - <fieldname>graphcutoff</fieldname> - <description>Graph cutoff is how many KB must be transferred by an IP before it is graphed. Default 1024.</description> + <fielddescr>Skip Intervals</fielddescr> + <fieldname>skipintervals</fieldname> + <description> + <![CDATA[ + Number of intervals to skip between graphing.<br /> + Default 0. (Each interval is 200 seconds = 3 min 20 sec.) + ]]> + </description> <type>input</type> </field> <field> - <fielddescr>Promiscuous</fielddescr> - <fieldname>promiscuous</fieldname> - <description>Put interface in promiscuous mode to see traffic that may not be routing through the host machine.<br> - Note: If the interface is connected to a switch then the interface will only see the traffic on its port.</description> - <type>checkbox</type> + <fielddescr>Graph Cutoff</fielddescr> + <fieldname>graphcutoff</fieldname> + <description> + <![CDATA[ + Graph cutoff means how many KB must be transferred by an IP before it is graphed.<br /> + Default 1024. + ]]> + </description> + <type>input</type> </field> <field> - <fielddescr>output_cdf</fielddescr> + <fielddescr>Output to CDF</fielddescr> <fieldname>outputcdf</fieldname> - <description>Log data to cdf files log*.cdf</description> + <description>Log data to CDF files log*.cdf</description> <type>checkbox</type> </field> <field> - <fielddescr>recover_cdf</fielddescr> + <fielddescr>Recover CDF</fielddescr> <fieldname>recovercdf</fieldname> - <description>Read back the cdf files on startup</description> + <description>Read back the CDF files on startup.</description> <type>checkbox</type> </field> <field> - <fielddescr>output PostgreSQL</fielddescr> + <fielddescr>Graph and Log Info</fielddescr> + <fieldname>graph_log_info</fieldname> + <description> + <![CDATA[ + If "Draw Graphs" is on, then the daily report and graph html data is regenerated every (skip intervals + 1) * 200 seconds. + The data volumes in the report are for the same period as the span of the graph.<br /> + If "Output to CDF" is on, then a cron job is added to rotate the log files at 00:01 each day. 6 log files are kept for each log frequency (daily, weekly, monthly, yearly). + At the respective rotation intervals, the oldest log is deleted, the others are shuffled back and a new log is created.<br /><br /> + <table cellpadding="1" cellspacing="0" style="text-align: left"><tbody> + <tr><th></th><th>Data Interval</th><th>Graph Span</th><th>Log Rotation</th><th>Log File Name</th></tr> + <tr><th>Daily</th><td>200 seconds</td><td>2 days</td><td>1 day</td><td>log.1.[0-5].cdf</td></tr> + <tr><th>Weekly</th><td>10 minutes</td><td>7 days</td><td>7 days</td><td>log.2.[0-5].cdf</td></tr> + <tr><th>Monthly</th><td>1 hour</td><td>35 days</td><td>35 days</td><td>log.3.[0-5].cdf</td></tr> + <tr><th>Yearly</th><td>12 hours</td><td>412.5 days</td><td>412.5 days </td><td>log.4.[0-5].cdf</td></tr> + </tbody></table> + ]]> + </description> + <type>info</type> + </field> + <field> + <name>PostgreSQL Options</name> + <type>listtopic</type> + </field> + <field> + <fielddescr>Output to PostgreSQL</fielddescr> <fieldname>outputpostgresql</fieldname> - <description>Log data to a PostgreSQL database.<br> - Get the postgreSQL schema and PHP files to display the results from: <a target="_new" href="https://github.com/individual-it/bandwidthd-pSQL-frontend">https://github.com/individual-it/bandwidthd-pSQL-frontend</a></description> + <description> + <![CDATA[ + Log data to a PostgreSQL database.<br /> + Get the PostgreSQL schema and PHP files to display the results from <a href="https://github.com/individual-it/bandwidthd-pSQL-frontend">https://github.com/individual-it/bandwidthd-pSQL-frontend</a> + ]]> + </description> + <enablefields>postgresqlhost,postgresqldatabase,postgresqlusername,postgresqlpasswordenc</enablefields> <type>checkbox</type> </field> <field> - <fielddescr>Database host</fielddescr> + <fielddescr>Database Host</fielddescr> <fieldname>postgresqlhost</fieldname> - <description>Hostname of the postgreSQL database server.</description> + <description>Hostname of the PostgreSQL database server.</description> <type>input</type> </field> <field> - <fielddescr>Database name</fielddescr> + <fielddescr>Database Name</fielddescr> <fieldname>postgresqldatabase</fieldname> - <description>Database on the postgreSQL database server.</description> + <description>Database on the PostgreSQL database server.</description> <type>input</type> </field> <field> <fielddescr>Database Username</fielddescr> <fieldname>postgresqlusername</fieldname> - <description>Username of the postgreSQL database server.</description> + <description>Username of the PostgreSQL database server.</description> <type>input</type> </field> <field> <fielddescr>Database Password</fielddescr> - <fieldname>postgresqlpassword</fieldname> - <description>Password of the postgreSQL database server.</description> + <fieldname>postgresqlpasswordenc</fieldname> + <description>Password of the PostgreSQL database server.</description> <type>password</type> + <encoding>base64</encoding> </field> <field> - <fielddescr>sensor_id</fielddescr> - <fieldname>sensorid</fieldname> - <description>Arbitrary sensor name, I recommend the sensors fully qualified domain name.</description> - <type>input</type> - </field> - <field> - <fielddescr>Filter</fielddescr> - <fieldname>filter</fieldname> - <description>Libpcap format filter string used to control what bandwidthd sees. Please always include "ip" in the string to avoid strange problems.</description> - <type>input</type> - </field> - <field> - <fielddescr>Draw Graphs</fielddescr> - <fieldname>drawgraphs</fieldname> - <description>This defaults to true to graph the traffic bandwidthd is recording. Set this to false if you only want cdf output or you are using the database output option. Bandwidthd will use very little RAM and CPU if this is set to false.</description> - <type>checkbox</type> - <default_value>on</default_value> - </field> - <field> - <fielddescr>Meta Refresh</fielddescr> - <fieldname>meta_refresh</fieldname> - <description>Sets the interval (seconds) at which the browser graph display refreshes (default 150, use 0 to disable).</description> - <type>input</type> - </field> - <field> - <fielddescr>Graph and Log Info</fielddescr> - <fieldname>graph_log_info</fieldname> - <description>If draw graphs is on, then the daily report and graph html data is regenerated every (skip intervals + 1) * 200 seconds. The data volumes in the report are for the same period as the span of the graph.<br> - If output_cdf is on, then a cron job is added to rotate the log files at 00:01 each day. 6 log files are kept for each log frequency (daily, weekly, monthly, yearly). At the respective rotation intervals, the oldest log is deleted, the others are shuffled back and a new log is created.<br> - <table cellpadding=1 cellspacing=0 style="text-align: left;"> <tbody> - <tr><th> </th><th> Data Interval </th><th> Graph Span </th><th> Log Rotation </th><th> Log File Name </th></tr> - <tr><th> Daily </th><td> 200 seconds </td><td> 2 days </td><td> 1 day </td><td> log.1.[0-5].cdf </td></tr> - <tr><th> Weekly </th><td> 10 minutes </td><td> 7 days </td><td> 7 days </td><td> log.2.[0-5].cdf </td></tr> - <tr><th> Monthly </th><td> 1 hour </td><td> 35 days </td><td> 35 days </td><td> log.3.[0-5].cdf </td></tr> - <tr><th> Yearly </th><td> 12 hours </td><td> 412.5 days </td><td> 412.5 days </td><td> log.4.[0-5].cdf </td></tr> - </tbody> </table> + <fielddescr>Advanced Filter</fielddescr> + <fieldname>advfilter</fieldname> + <description> + <![CDATA[ + Libpcap format filter string used to control what traffic is counted. + Please, refer to <a href="https://www.freebsd.org/cgi/man.cgi?query=pcap-filter&sektion=7&apropos=0&manpath=FreeBSD+10.1-RELEASE+and+Ports">pcap-filter(7)</a> for documentation. + <br /> + NOTE: You should always specify "ip" in the filter to avoid strange results.<br /><br /> + Example: We only want to account for a certain IP.<br /> + Filter expression: <em>ip and host 192.0.2.1</em><br /><br /> + <strong>WARNING: You are completely on your own with this! If misconfigured, BandwidthD will malfunction or even not start at all.</strong> + ]]> </description> - <type>info</type> + <type>textarea</type> + <encoding>base64</encoding> + <cols>65</cols> + <rows>1</rows> + <advancedfield/> </field> </fields> <custom_php_resync_config_command> bandwidthd_install_config(); </custom_php_resync_config_command> <custom_php_install_command> + bandwidthd_upgrade_config(); bandwidthd_install_config(); </custom_php_install_command> <custom_php_deinstall_command> bandwidthd_install_deinstall(); </custom_php_deinstall_command> + <custom_php_validation_command> + bandwidthd_validate_input($_POST, $input_errors); + </custom_php_validation_command> </packagegui> diff --git a/config/cron/cron.inc b/config/cron/cron.inc index 0c7c6769..7a7a8993 100644 --- a/config/cron/cron.inc +++ b/config/cron/cron.inc @@ -1,14 +1,11 @@ <?php -/* $Id$ */ -/* -/* ========================================================================== */ /* cron.inc + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + 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: @@ -30,65 +27,23 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require_once("services.inc"); -function cron_pkg_is_service_running($servicename) { - exec("/bin/ps ax | awk '{ print $5 }'", $psout); - array_shift($psout); - foreach ($psout as $line) { - $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); - } - if (is_service_running($servicename, $ps) or is_process_running($servicename)) { - return true; - } else { - return false; - } -} - function cron_sync_package() { - - global $config; - //synch cron tab configure_cron(); - exec("/usr/local/etc/rc.d/cron.sh stop"); - exec("/usr/local/etc/rc.d/cron.sh start"); - + // Previous package versions were "helpfully" killing cron on uninstall. + // Also, need to make sure cron is running, otherwise the package is useless. + // TODO: Something like this needs to be eventually done in configure_cron() in services.inc. + if (!is_process_running("cron")) { + exec("cd /tmp && /usr/sbin/cron -s 2>/dev/null"); + } } - function cron_install_command() { - - global $config; conf_mount_rw(); - config_lock(); - - //write_config(); - - write_rcfile(array( - "file" => "cron.sh", - "start" => "[ `/bin/pgrep -f 'cron -s' | wc -l` -eq 0 ] && /usr/sbin/cron -s &", - "stop" => "[ -f \"/var/run/cron.pid\" ] && kill -9 `cat /var/run/cron.pid`; rm -f /var/run/cron.pid; /bin/pkill -f 'cron -s'" - ) - ); - - cron_sync_package(); - - //if (pkg_is_service_running('cron')) { - //documentation purposes - //} - - conf_mount_ro(); - config_unlock(); - -} - - -function cron_deinstall_command() { - conf_mount_rw(); - exec("/usr/local/etc/rc.d/cron.sh stop"); + // Clean up possible lingering garbage after previous package versions unlink_if_exists("/usr/local/etc/rc.d/cron.sh"); - conf_mount_ro(); + cron_sync_package(); } ?> diff --git a/config/cron/cron.php b/config/cron/cron.php index d7ed1494..7d55b086 100644 --- a/config/cron/cron.php +++ b/config/cron/cron.php @@ -1,8 +1,9 @@ <?php -/* $Id$ */ /* cron.php + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,13 +27,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require_once("guiconfig.inc"); require_once("/usr/local/pkg/cron.inc"); $a_cron = &$config['cron']['item']; - if ($_GET['act'] == "del") { if ($_GET['type'] == 'php') { if ($a_cron[$_GET['id']]) { @@ -56,147 +55,101 @@ include("head.inc"); <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tabs"> <tr><td class="tabnavtbl"> <?php - $tab_array = array(); $tab_array[] = array(gettext("Settings"), true, "/packages/cron/cron.php"); $tab_array[] = array(gettext("Edit"), false, "/packages/cron/cron_edit.php"); display_top_tabs($tab_array); - ?> </td></tr> </table> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="content"> - <tr> - <td class="tabcont" > - -<form action="cron.php" method="post" name="iform" id="iform"> -<?php - -if ($config_change == 1) { - write_config(); - $config_change = 0; -} - -//if ($savemsg) print_info_box($savemsg); -//if (file_exists($d_hostsdirty_path)): echo"<p>"; -//print_info_box_np("This is an info box."); -//echo"<br />"; -//endif; - -?> +<tr><td class="tabcont" > + <form action="cron.php" method="post" name="iform" id="iform"> + <?php + if ($config_change == 1) { + write_config(); + $config_change = 0; + } + ?> <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="title"> - <tr> - <td> - <p><!--<span class="vexpl"><span class="red"><strong>Cron<br></strong></span>--> - Cron controls the scheduling of commands. - <br /><br /> - For more information see: <a href='http://www.freebsd.org/doc/en/books/handbook/configtuning-cron.html' target='_blank'>http://www.freebsd.org/doc/en/books/handbook/configtuning-cron.html</a> - </p> - </td> - </tr> + <tr><td> + <div> + Cron controls the scheduling of commands.<br /><br /> + For more information see: <a href='http://www.freebsd.org/doc/en/books/handbook/configtuning-cron.html'>http://www.freebsd.org/doc/en/books/handbook/configtuning-cron.html</a> + </div> + </td></tr> </table> <br /> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="heading"> - <tr> - <td width="5%" class="listhdrr">minute</td> - <td width="5%" class="listhdrr">hour</td> - <td width="5%" class="listhdrr">mday</td> - <td width="5%" class="listhdrr">month</td> - <td width="5%" class="listhdrr">wday</td> - <td width="5%" class="listhdrr">who</td> - <td width="60%" class="listhdr">command</td> - <td width="10%" class="list"> - <table border="0" cellspacing="0" cellpadding="1" summary="icons"> - <tr> - <td width="17"></td> - <td valign="middle"><a href="cron_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td> - </tr> - </table> - </td> - </tr> - - - <?php - - $i = 0; - if (count($a_cron) > 0) { - foreach ($a_cron as $ent) { + <tr> + <td width="5%" class="listhdrr">minute</td> + <td width="5%" class="listhdrr">hour</td> + <td width="5%" class="listhdrr">mday</td> + <td width="5%" class="listhdrr">month</td> + <td width="5%" class="listhdrr">wday</td> + <td width="5%" class="listhdrr">who</td> + <td width="60%" class="listhdr">command</td> + <td width="10%" class="list"> + <table border="0" cellspacing="0" cellpadding="1" summary="icons"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="cron_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td> + </tr> + </table> + </td> + </tr> - ?> - <tr> - <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"> - <?=$ent['minute'];?> - </td> - <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"> - <?=$ent['hour'];?> - </td> - <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"> - <?=$ent['mday'];?> - </td> - <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"> - <?=$ent['month'];?> - </td> - <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"> - <?=$ent['wday'];?> - </td> - <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"> - <?=$ent['who'];?> - </td> - <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"> - <?=$ent['command'];?> - </td> - <td valign="middle" style="white-space:nowrap" class="list"> - <table border="0" cellspacing="0" cellpadding="1" summary="edit delete"> - <tr> - <td valign="middle"><a href="cron_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a></td> - <td><a href="cron_edit.php?type=php&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td> - </tr> - </table> - </td> - </tr> - <?php - - $i++; + <?php + $i = 0; + if (count($a_cron) > 0) { + foreach ($a_cron as $ent) { + ?> + <tr> + <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['minute'];?> </td> + <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['hour'];?> </td> + <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['mday'];?> </td> + <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['month'];?> </td> + <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['wday'];?> </td> + <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['who'];?> </td> + <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['command'];?> </td> + <td valign="middle" style="white-space:nowrap" class="list"> + <table border="0" cellspacing="0" cellpadding="1" summary="edit delete"> + <tr> + <td valign="middle"><a href="cron_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a></td> + <td><a href="cron_edit.php?type=php&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td> + </tr> + </table> + </td> + </tr> + <?php + $i++; + } } - } ?> - <tr> - <td class="list" colspan="7"></td> - <td class="list"> - <table border="0" cellspacing="0" cellpadding="1" summary="add"> - <tr> - <td width="17"></td> - <td valign="middle"><a href="cron_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td> - </tr> - </table> - </td> - </tr> - - - <tr> - <td class="list" colspan="8"></td> - <td class="list"></td> - </tr> - </table> - -</form> - - -<br /> -<br /> -<br /> -<br /> -<br /> -<br /> -<br /> -<br /> - + <tr> + <td class="list" colspan="7"></td> + <td class="list"> + <table border="0" cellspacing="0" cellpadding="1" summary="add"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="cron_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td> + </tr> + </table> </td> </tr> + + <tr> + <td class="list" colspan="8"></td> + <td class="list"></td> + </tr> + </table> + + </form> +</td></tr> </table> </div> diff --git a/config/cron/cron.xml b/config/cron/cron.xml index 5a2b770b..84b7f07e 100644 --- a/config/cron/cron.xml +++ b/config/cron/cron.xml @@ -1,21 +1,24 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - <![CDATA[ +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* cron.xml + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + 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. @@ -23,6 +26,7 @@ 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 @@ -33,79 +37,43 @@ 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>Cron</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>Cron Settings</name> - <version>0.2.2</version> + <version>0.3.0</version> <title>Settings</title> <include_file>/usr/local/pkg/cron.inc</include_file> <menu> <name>Cron</name> - <tooltiptext>cron settings.</tooltiptext> + <tooltiptext>Cron settings.</tooltiptext> <section>Services</section> <configfile>cron.xml</configfile> <url>/packages/cron/cron.php</url> </menu> - <service> - <name>cron</name> - <rcfile>cron.sh</rcfile> - <executable>cron</executable> - <description>Scheduled commands daemon</description> - </service> - <tabs> - <tab> - <text>Settings</text> - <url>/packages/cron.php</url> - <active/> - </tab> - </tabs> <configpath>installedpackages->package->$packagename->configuration->cron</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/cron/cron.xml</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/cron/cron.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/packages/cron/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/cron/cron.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/packages/cron/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/cron/cron_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/packages/cron/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/cron/index.php</item> </additional_files_needed> - <fields> - <field> - <fielddescr>Variable One</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - <field> - <fielddescr>Variable Two</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - </fields> - <custom_add_php_command> - </custom_add_php_command> <custom_php_resync_config_command> cron_sync_package(); </custom_php_resync_config_command> @@ -115,7 +83,4 @@ <custom_php_install_command> cron_install_command(); </custom_php_install_command> - <custom_php_deinstall_command> - cron_deinstall_command(); - </custom_php_deinstall_command> </packagegui> diff --git a/config/cron/cron_edit.php b/config/cron/cron_edit.php index 2b72a04d..b89c28e0 100644 --- a/config/cron/cron_edit.php +++ b/config/cron/cron_edit.php @@ -1,9 +1,9 @@ <?php -/* $Id$ */ /* - cron_edit.php + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,11 +27,9 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require_once("guiconfig.inc"); require_once("/usr/local/pkg/cron.inc"); - $a_cron = &$config['cron']['item']; $id = $_GET['id']; @@ -40,19 +38,18 @@ if (isset($_POST['id'])) { } if ($_GET['act'] == "del") { - if ($_GET['type'] == 'php') { - if ($a_cron[$_GET['id']]) { - unset($a_cron[$_GET['id']]); - write_config(); - cron_sync_package(); - header("Location: cron.php"); - exit; - } - } + if ($_GET['type'] == 'php') { + if ($a_cron[$_GET['id']]) { + unset($a_cron[$_GET['id']]); + write_config(); + cron_sync_package(); + header("Location: cron.php"); + exit; + } + } } if (isset($id) && $a_cron[$id]) { - $pconfig['minute'] = $a_cron[$id]['minute']; $pconfig['hour'] = $a_cron[$id]['hour']; $pconfig['mday'] = $a_cron[$id]['mday']; @@ -60,11 +57,9 @@ if (isset($id) && $a_cron[$id]) { $pconfig['wday'] = $a_cron[$id]['wday']; $pconfig['who'] = $a_cron[$id]['who']; $pconfig['command'] = $a_cron[$id]['command']; - } if ($_POST) { - unset($input_errors); $pconfig = $_POST; @@ -80,10 +75,10 @@ if ($_POST) { $ent['command'] = $_POST['command']; if (isset($id) && $a_cron[$id]) { - //update + // update $a_cron[$id] = $ent; } else { - //add + // add $a_cron[] = $ent; } @@ -115,165 +110,78 @@ function show_advanced_config() { <?php if ($input_errors) print_input_errors($input_errors); ?> - <div id="mainlevel"> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="mainlevel"> <tr><td class="tabnavtbl"> <?php - $tab_array = array(); $tab_array[] = array(gettext("Settings"), false, "/packages/cron/cron.php"); $tab_array[] = array(gettext("Edit"), true, "/packages/cron/cron_edit.php"); display_top_tabs($tab_array); - ?> </td></tr> </table> -<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="mainarea"> - <tr> - <td class="tabcont" > - - <!-- - <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="title"> - <tr> - <td> - <p> - <span class="vexpl"><span class="red"><strong>Cron<br /></strong></span> - </p> - </td> - </tr> - </table> - --> - <br /> - <form action="cron_edit.php" method="post" name="iform" id="iform"> - <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="form"> - <tr> - <td width="25%" valign="top" class="vncellreq">minute</td> - <td width="75%" class="vtable"> - <input name="minute" type="text" class="formfld" id="minute" size="40" value="<?=htmlspecialchars($pconfig['minute']);?>" /> - </td> - </tr> - - <tr> - <td width="25%" valign="top" class="vncellreq">hour</td> - <td width="75%" class="vtable"> - <input name="hour" type="text" class="formfld" id="hour" size="40" value="<?=htmlspecialchars($pconfig['hour']);?>" /> - </td> - </tr> - - <tr> - <td width="25%" valign="top" class="vncellreq">mday</td> - <td width="75%" class="vtable"> - <input name="mday" type="text" class="formfld" id="mday" size="40" value="<?=htmlspecialchars($pconfig['mday']);?>" /> - </td> - </tr> - - <tr> - <td width="25%" valign="top" class="vncellreq">month</td> - <td width="75%" class="vtable"> - <input name="month" type="text" class="formfld" id="month" size="40" value="<?=htmlspecialchars($pconfig['month']);?>" /> - </td> - </tr> - - <tr> - <td width="25%" valign="top" class="vncellreq">wday</td> - <td width="75%" class="vtable"> - <input name="wday" type="text" class="formfld" id="wday" size="40" value="<?=htmlspecialchars($pconfig['wday']);?>" /> - </td> - </tr> - - <tr> - <td width="25%" valign="top" class="vncellreq">who</td> - <td width="75%" class="vtable"> - <input name="who" type="text" class="formfld" id="who" size="40" value="<?=htmlspecialchars($pconfig['who']);?>" /> - </td> - </tr> - - <tr> - <td width="25%" valign="top" class="vncellreq">command</td> - <td width="75%" class="vtable"> - <!-- <input name="command" type="text" class="formfld" id="command" size="40" value="<?=htmlspecialchars($pconfig['command']);?>" /> --> - <textarea rows="3" cols="68" name="command" id="command"><?=htmlspecialchars($pconfig['command']);?></textarea> - </td> - </tr> - <!-- - <tr> - <td width="22%" valign="top" class="vncell">PHP</td> - <td width="78%" class="vtable"> - --> - <?php - //echo "<textarea name=\"php\" id=\"php\" cols=\"70\" rows=\"15\" wrap=\"off\">".htmlspecialchars($pconfig['php'])."</textarea>\n"; - ?> - <!-- - <br> - <select name='dialplan_expression_select' id='dialplan_expression_select' onchange="document.getElementById('dialplan_expression').value += document.getElementById('dialplan_expression_select').value + '\n';" class='formfld'> - <option></option> - <option value='snortkillsessions'>snort kill sessions</option> - </select> - <span class="vexpl"> - <br /> - </span> - </td> - </tr> - --> - <!-- - <tr> - <td width="22%" valign="top" class="vncellreq">Enabled</td> - <td width="78%" class="vtable"> - <?php - echo " <select name='enabled' class='formfld'>\n"; - echo " <option></option>\n"; - switch (htmlspecialchars($pconfig['enabled'])) { - case "true": - echo " <option value='true' selected='selected'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - break; - case "false": - echo " <option value='true'>true</option>\n"; - echo " <option value='false' selected='selected'>false</option>\n"; - - break; - default: - echo " <option value='true' selected='selected'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - } - echo " </select>\n"; - ?> - </td> - </tr> - --> - <!-- - <tr> - <td width="25%" valign="top" class="vncellreq">Description</td> - <td width="75%" class="vtable"> - <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>" /> - <br /><span class="vexpl">Enter the description here.<br /></span> - </td> - </tr> - --> - - <tr> - <td valign="top"> </td> - <td> - <input name="Submit" type="submit" class="formbtn" value="Save" /> <input class="formbtn" type="button" value="Cancel" onclick="history.back()" /> - <?php if (isset($id) && $a_cron[$id]): ?> - <input name="id" type="hidden" value="<?=$id;?>" /> - <?php endif; ?> - </td> - </tr> - </table> - </form> - - <br /> - <br /> - <br /> - <br /> - <br /> - <br /> - - </td> - </tr> +<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="mainarea"> +<tr><td class="tabcont" > + <br /> + <form action="cron_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="form"> + <tr> + <td width="25%" valign="top" class="vncellreq">minute</td> + <td width="75%" class="vtable"> + <input name="minute" type="text" class="formfld" id="minute" size="40" value="<?=htmlspecialchars($pconfig['minute']);?>" /> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">hour</td> + <td width="75%" class="vtable"> + <input name="hour" type="text" class="formfld" id="hour" size="40" value="<?=htmlspecialchars($pconfig['hour']);?>" /> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">mday</td> + <td width="75%" class="vtable"> + <input name="mday" type="text" class="formfld" id="mday" size="40" value="<?=htmlspecialchars($pconfig['mday']);?>" /> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">month</td> + <td width="75%" class="vtable"> + <input name="month" type="text" class="formfld" id="month" size="40" value="<?=htmlspecialchars($pconfig['month']);?>" /> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">wday</td> + <td width="75%" class="vtable"> + <input name="wday" type="text" class="formfld" id="wday" size="40" value="<?=htmlspecialchars($pconfig['wday']);?>" /> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">who</td> + <td width="75%" class="vtable"> + <input name="who" type="text" class="formfld" id="who" size="40" value="<?=htmlspecialchars($pconfig['who']);?>" /> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">command</td> + <td width="75%" class="vtable"> + <textarea rows="3" cols="68" name="command" id="command"><?=htmlspecialchars($pconfig['command']);?></textarea> + </td> + </tr> + <tr> + <td valign="top"> </td> + <td> + <input name="Submit" type="submit" class="formbtn" value="Save" /> <input class="formbtn" type="button" value="Cancel" onclick="history.back()" /> + <?php if (isset($id) && $a_cron[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + </table> + </form> + <br /> +</td></tr> </table> </div> diff --git a/config/cron/index.php b/config/cron/index.php index 0d4ff4cd..24237ecc 100644 --- a/config/cron/index.php +++ b/config/cron/index.php @@ -3,4 +3,4 @@ Header("Location: /"); exit; -?>
\ No newline at end of file +?> diff --git a/config/darkstat/darkstat.xml b/config/darkstat/darkstat.xml index d0b71cac..3b691741 100644 --- a/config/darkstat/darkstat.xml +++ b/config/darkstat/darkstat.xml @@ -262,7 +262,6 @@ <![CDATA[ function sync_package_darkstat() { conf_mount_rw(); - config_lock(); global $config, $darkstat_config; $darkstat_config =& $config['installedpackages']['darkstat']['config'][0]; @@ -353,7 +352,6 @@ restart_service("darkstat"); } - config_unlock(); conf_mount_ro(); } diff --git a/config/diag_states_pt/diag_new_states.php b/config/diag_states_pt/diag_new_states.php index d187068f..00b22e33 100644 --- a/config/diag_states_pt/diag_new_states.php +++ b/config/diag_states_pt/diag_new_states.php @@ -1,43 +1,35 @@ <?php /* - diag_new_staes.php - Copyright (C) 2002 Paul Taylor - 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. + diag_new_states.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2002 Paul Taylor + 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. */ - require_once("guiconfig.inc"); - global $config; -if ($config['version'] >= 6) - $pgtitle = array("Diagnostics", "Show States"); -else - $pgtitle = "Diagnostics: Show States"; - -/* put your custom HTML head content here */ -/* using some of the $pfSenseHead function calls */ - function displayIP($ip, $col) { global $viewPassThru; @@ -55,10 +47,10 @@ function displayIP($ip, $col) { case 'dstip': if ($_GET['dfilter']) { - if ($_GET['dfilter'] == $ip) + if ($_GET['dfilter'] == $ip) { return $ip; - } - else { + } + } else { return '<a href="?dfilter='.$ip.$viewPassThru.'">'. $ip .'</a>'; } break; @@ -69,32 +61,34 @@ function displayIP($ip, $col) { function sortOrder($column) { if ($_GET['order'] == $column) { - if ($_GET['sort'] == 'des') - return "&sort=asc"; - return "&sort=des"; + if ($_GET['sort'] == 'des') { + return "&sort=asc"; + } + return "&sort=des"; + } else { + return "&sort=asc"; } - else - return "&sort=asc"; } +// FIXME: Needs changes to handle IPv6 addresses properly function stripPort($ip, $showPort = false) { if (!$showPort) { - if (strpos($ip,':') > 0) - return substr($ip,0,strpos($ip,":")); - else + if (strpos($ip, ':') > 0) { + return substr($ip, 0, strpos($ip, ":")); + } else { return ($ip); - } - else { - if (strpos($ip,':') > 0) { - return substr($ip,(strpos($ip,":")+1)); } - else + } else { + if (strpos($ip, ':') > 0) { + return substr($ip, (strpos($ip, ":")+1)); + } else { return " "; + } } } // sfilter and dfilter allow setting of source and dest IP filters -// on the output. $filterPassThru allows these source and dest +// on the output. $filterPassThru allows these source and dest // filters to be passed on in the column sorting links. if (($_GET['sfilter']) or ($_GET['dfilter'])) { @@ -102,18 +96,18 @@ if (($_GET['sfilter']) or ($_GET['dfilter'])) { if ($_GET['sfilter']) { if (is_ipaddr($_GET['sfilter'])) { $sfilter = $_GET['sfilter']; - $filterPassThru = '&sfilter=' . $_GET['sfilter']; - } - else + $filterPassThru = '&sfilter=' . $_GET['sfilter']; + } else { unset ($_GET['sfilter']); + } } if ($_GET['dfilter']) { if (is_ipaddr($_GET['dfilter'])) { $dfilter = $_GET['dfilter']; - $filterPassThru = '&dfilter=' . $_GET['dfilter']; - } - else + $filterPassThru = '&dfilter=' . $_GET['dfilter']; + } else { unset ($_GET['dfilter']); + } } } @@ -129,28 +123,29 @@ $rawdata = array(); // [5] => tcp I 192.168.111.99:61221 192.168.111.150:22 4:4 710 86399 726 242K // -w 132 sets width of data to 132 // $dataRows defaults to 300 for embedded hardware -exec("echo q | /usr/local/sbin/pftop -w 132 $dataRows",$rawdata); +exec("echo q | /usr/local/sbin/pftop -w 132 $dataRows", $rawdata); -// exporting TERM set to nothing gets you a "dumb" term. echo q to pftop makes it +// exporting TERM set to nothing gets you a "dumb" term. echo q to pftop makes it // quit out after displaying the first page of data. // Get top line with total state data $topDataLine = $rawdata[2]; //pfTop: Up State 1-5/5, View: default, Order: none -$slashPos = strpos($topDataLine,'/') + 1; -$commaPos = strpos($topDataLine,','); +$slashPos = strpos($topDataLine, '/') + 1; +$commaPos = strpos($topDataLine, ','); if (($slashPos > 1) and ($commaPos > 1)) { - $totalStates = substr($topDataLine,$slashPos,($commaPos - $slashPos)); -} else $totalStates = 0; + $totalStates = substr($topDataLine, $slashPos, ($commaPos - $slashPos)); +} else { + $totalStates = 0; +} // Get rid of the header data -unset($rawdata[0],$rawdata[1],$rawdata[2],$rawdata[3]); +unset($rawdata[0], $rawdata[1], $rawdata[2], $rawdata[3]); if (isset($rawdata)) { $count = 0; foreach ($rawdata as $line) { - if (!strlen(trim($line)) < 70) - { + if (!strlen(trim($line)) < 70) { //PR DIR SRC DEST STATE AGE EXP PKTS BYTES //tcp Out 192.168.111.99:62831 66.84.12.81:110 FIN_WAIT_2:FIN_WAIT_2 00:01:20 00:00:11 28 1933 // 0 1 2 3 4 5 6 7 8 @@ -160,23 +155,24 @@ if (isset($rawdata)) { $data[$count]['dir'] = strtolower($split[1]); $srcTmp = $split[2]; $data[$count]['srcip'] = stripPort($srcTmp); - $data[$count]['srcport'] = stripPort($srcTmp,true); + $data[$count]['srcport'] = stripPort($srcTmp, true); $dstTmp = $split[3]; $data[$count]['expire'] = $split[6]; $data[$count]['dstip'] = stripPort($dstTmp); - $data[$count]['dstport'] = stripPort($dstTmp,true); + $data[$count]['dstport'] = stripPort($dstTmp, true); $data[$count]['packets'] = $split[7]; $data[$count]['bytes'] = $split[8]; $count++; } } // Clear the statistics snapshot files, which track the packets and bytes of connections - if (isset($_GET['clear'])) - { - if (file_exists('/tmp/packets')) + if (isset($_GET['clear'])) { + if (file_exists('/tmp/packets')) { unlink('/tmp/packets'); - if (file_exists('/tmp/bytes')) + } + if (file_exists('/tmp/bytes')) { unlink('/tmp/bytes'); + } // Redirect so we don't hit "clear" every time we refresh the screen. header("Location: diag_new_states.php?".$filterPassThru); @@ -184,8 +180,7 @@ if (isset($rawdata)) { } // Create a new set of stats snapshot files - if (isset($_GET['new'])) - { + if (isset($_GET['new'])) { $packets = array(); $bytes = array(); @@ -198,36 +193,33 @@ if (isset($rawdata)) { } // Write the files out - writeStats("packets",$packets); - writeStats("bytes",$bytes); + writeStats("packets", $packets); + writeStats("bytes", $bytes); // If we're in view mode, pass that on. - if (isset($_GET['view'])) - $filterPassThru .= "&view=1"; + if (isset($_GET['view'])) { + $filterPassThru .= "&view=1"; + } // Redirect so we don't hit "new" every time we refresh the screen. - header("Location: diag_new_states.php?&order=bytes&sort=des".$filterPassThru); + header("Location: diag_new_states.php?&order=bytes&sort=des".$filterPassThru); exit; } // View the delta from the last snapshot against the current data. - if (isset($_GET['view'])) - { + if (isset($_GET['view'])) { // Read the stats data files - readStats("packets",$packets); - readStats("bytes",$bytes); + readStats("packets", $packets); + readStats("bytes", $bytes); if (is_array($data)) { foreach ($data as $key => $row) { - if (isset($packets[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']])) - { - if (isset($bytes[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']])) - { + if (isset($packets[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']])) { + if (isset($bytes[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']])) { $tempPackets = $data[$key]['packets'] - $packets[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']]; $tempBytes = $data[$key]['bytes'] - $bytes[$row['srcip']][$row['srcport']][$row['dstip']][$row['dstport']][$row['protocol']]; - if (($tempPackets > -1) && ($tempBytes > -1)) - { + if (($tempPackets > -1) && ($tempBytes > -1)) { $data[$key]['packets'] = $tempPackets; $data[$key]['bytes'] = $tempBytes; } @@ -237,51 +229,48 @@ if (isset($rawdata)) { } } - $filterPassThru .= "&view=1"; - $viewPassThru = "&view=1"; + $filterPassThru .= "&view=1"; + $viewPassThru = "&view=1"; } // Sort it by the selected order if ($_GET['order']) { - natsort2d($data,$_GET['order']); - if ($_GET['sort']) - { - if ($_GET['sort'] == "des") - $data = array_reverse($data); + natsort2d($data, $_GET['order']); + if ($_GET['sort']) { + if ($_GET['sort'] == "des") { + $data = array_reverse($data); + } } } } -function natsort2d( &$arrIn, $index = null ) -{ - - $arrTemp = array(); - $arrOut = array(); +function natsort2d( &$arrIn, $index = null ) { - if (is_array($arrIn)) { - foreach ( $arrIn as $key=>$value ) { + $arrTemp = array(); + $arrOut = array(); - reset($value); - $arrTemp[$key] = is_null($index) - ? current($value) - : $value[$index]; - } - } + if (is_array($arrIn)) { + foreach ( $arrIn as $key=>$value ) { + reset($value); + $arrTemp[$key] = is_null($index) ? current($value) : $value[$index]; + } + } - natsort($arrTemp); + natsort($arrTemp); - foreach ( $arrTemp as $key=>$value ) { - $arrOut[$key] = $arrIn[$key]; - } + foreach ( $arrTemp as $key=>$value ) { + $arrOut[$key] = $arrIn[$key]; + } - $arrIn = $arrOut; + $arrIn = $arrOut; } function writeStats($fname, &$data) { $fname = "/tmp/" . $fname; - if (file_exists($fname)) + if (file_exists($fname)) { unlink($fname); + } $file = fopen($fname, 'a'); fwrite($file, serialize($data)); fclose($file); @@ -289,9 +278,8 @@ function writeStats($fname, &$data) { function readStats($fname, &$data) { $fname = "/tmp/" . $fname; - if (file_exists($fname)) - { - $file = fopen($fname,'r'); + if (file_exists($fname)) { + $file = fopen($fname, 'r'); $data = unserialize(fread($file, filesize($fname))); fclose($file); } @@ -300,11 +288,11 @@ function readStats($fname, &$data) { // Get timestamp of snapshot file, if it exists, for display later. if (!(file_exists('/tmp/packets'))) { $lastSnapshot = "Never"; -} -else { +} else { $lastSnapshot = strftime("%m/%d/%y %H:%M:%S",filectime('/tmp/packets')); } // The next include must be here because we use redirection above +$pgtitle = "Diagnostics: Show States"; include("head.inc"); ?> @@ -315,75 +303,77 @@ include("head.inc"); <?php include("fbegin.inc"); ?> -<?php - if ($config['version'] < 6) - echo '<p class="pgtitle">' . $pgtitle . '</p>'; -?> - <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td class="listhdrr" colspan="9">Statistics snapshot control</td> - </tr> - <tr> - <?php if (($lastSnapshot!='Never') && (!isset($_GET['view']))) :?> - <td class="listlr"><a href="?view=1&order=bytes&sort=des<?=$filterPassThru;?>">View delta</a></td> - <td class="listr"><a href="?new=1<?=$filterPassThru;?>">Start new</a></td> - <td class="listr"><a href="?clear=1">Clear snapshot</a></td> - <td class="listr" colspan="6" align="right">Last statistics snapshot: <?=$lastSnapshot;?></td> - <?php endif; ?> - <?php if (($lastSnapshot!='Never') && (isset($_GET['view']))) :?> - <td class="listlr"><a href="?new=1<?=$filterPassThru;?>">Start new</a></td> - <td class="listr"><a href="?clear=1">Clear</a></td> - <td class="listr" colspan="7" align="right"><span class="red">Viewing delta of statistics snapshot: <?=$lastSnapshot;?></span></td> - <?php endif; ?> - <?php if ($lastSnapshot=='Never') :?> - <td class="listlr"><a href="?new=1<?=$filterPassThru;?>">Start new</a></td> - <td class="listr" colspan="8" align="right">Last statistics snapshot: <?=$lastSnapshot;?></td> - <?php endif; ?> - </tr> - <tr> - <td colspan="8"> </td> - </tr> - <tr> - <td class="listhdrr"><a href="?order=srcip<?=sortOrder('srcip');echo $filterPassThru;?>">Source</a></td> - <td class="listhdrr"><a href="?order=srcport<?=sortOrder('srcport');echo $filterPassThru;?>">Port</a></td> - <td class="listhdrr"><a href="?order=dir<?=sortOrder('dir');echo $filterPassThru;?>">Dir</a></td> - <td class="listhdrr"><a href="?order=dstip<?=sortOrder('dstip');echo $filterPassThru;?>">Destination</a></td> - <td class="listhdrr"><a href="?order=dstport<?=sortOrder('dstport');echo $filterPassThru;?>">Port</a></td> - <td class="listhdrr"><a href="?order=protocol<?=sortOrder('protocol');echo $filterPassThru;?>">Protocol</a></td> - <td class="listhdrr" align="right"><a href="?order=packets<?=sortOrder('packets');echo $filterPassThru;?>">Packets</a></td> - <td class="listhdrr" align="right"><a href="?order=bytes<?=sortOrder('bytes');echo $filterPassThru;?>">Bytes</a></td> - <td class="listhdr" align="right"><a href="?order=expire<?=sortOrder('expire');echo $filterPassThru;?>">Expires</a></td> - <td class="list"></td> - </tr> -<?php $count = 0; -if (is_array($data)): foreach ($data as $entry): - if ((!isset($sfilter) and (!isset($dfilter))) or - ((isset($sfilter)) and ($entry['srcip']==$sfilter)) or - ((isset($dfilter)) and ($entry['dstip']==$dfilter))): - ?> - <tr> - <td class="listlr"><?=displayIP($entry['srcip'],'srcip');?></td> - <td class="listr"><?=$entry['srcport'];?></td> - <td class="listr"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_<?=$entry['dir'];?>.gif" width="11" height="11" style="margin-top: 2px"></td> - <td class="listr"><?=displayIP($entry['dstip'],'dstip');?></td> - <td class="listr"><?=$entry['dstport'];?></td> - <td class="listr"><?=$entry['protocol'];?></td> - <td class="listr" align="right"><?=$entry['packets'];?></td> - <td class="listr" align="right"><?=$entry['bytes'];?></td> - <td class="listr" align="right"><?=$entry['expire'];?></td> - </tr> -<?php $count++; endif; endforeach; endif; ?> + <tr> + <td class="listhdrr" colspan="9">Statistics snapshot control</td> + </tr> + <tr> + <?php if (($lastSnapshot != 'Never') && (!isset($_GET['view']))) :?> + <td class="listlr"><a href="?view=1&order=bytes&sort=des<?=$filterPassThru;?>">View delta</a></td> + <td class="listr"><a href="?new=1<?=$filterPassThru;?>">Start new</a></td> + <td class="listr"><a href="?clear=1">Clear snapshot</a></td> + <td class="listr" colspan="6" align="right">Last statistics snapshot: <?=$lastSnapshot;?></td> + <?php endif; ?> + <?php if (($lastSnapshot != 'Never') && (isset($_GET['view']))) :?> + <td class="listlr"><a href="?new=1<?=$filterPassThru;?>">Start new</a></td> + <td class="listr"><a href="?clear=1">Clear</a></td> + <td class="listr" colspan="7" align="right"><span class="red">Viewing delta of statistics snapshot: <?=$lastSnapshot;?></span></td> + <?php endif; ?> + <?php if ($lastSnapshot == 'Never') :?> + <td class="listlr"><a href="?new=1<?=$filterPassThru;?>">Start new</a></td> + <td class="listr" colspan="8" align="right">Last statistics snapshot: <?=$lastSnapshot;?></td> + <?php endif; ?> + </tr> + <tr> + <td colspan="8"> </td> + </tr> + <tr> + <td class="listhdrr"><a href="?order=srcip<?=sortOrder('srcip');echo $filterPassThru;?>">Source</a></td> + <td class="listhdrr"><a href="?order=srcport<?=sortOrder('srcport');echo $filterPassThru;?>">Port</a></td> + <td class="listhdrr"><a href="?order=dir<?=sortOrder('dir');echo $filterPassThru;?>">Dir</a></td> + <td class="listhdrr"><a href="?order=dstip<?=sortOrder('dstip');echo $filterPassThru;?>">Destination</a></td> + <td class="listhdrr"><a href="?order=dstport<?=sortOrder('dstport');echo $filterPassThru;?>">Port</a></td> + <td class="listhdrr"><a href="?order=protocol<?=sortOrder('protocol');echo $filterPassThru;?>">Protocol</a></td> + <td class="listhdrr" align="right"><a href="?order=packets<?=sortOrder('packets');echo $filterPassThru;?>">Packets</a></td> + <td class="listhdrr" align="right"><a href="?order=bytes<?=sortOrder('bytes');echo $filterPassThru;?>">Bytes</a></td> + <td class="listhdr" align="right"><a href="?order=expire<?=sortOrder('expire');echo $filterPassThru;?>">Expires</a></td> + <td class="list"></td> + </tr> + <?php + $count = 0; + if (is_array($data)) { + foreach ($data as $entry) { + if ((!isset($sfilter) && (!isset($dfilter))) || + ((isset($sfilter)) && ($entry['srcip'] == $sfilter)) || + ((isset($dfilter)) && ($entry['dstip'] == $dfilter))) { + ?> + <tr> + <td class="listlr"><?=displayIP($entry['srcip'], 'srcip');?></td> + <td class="listr"><?=$entry['srcport'];?></td> + <td class="listr"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_<?=$entry['dir'];?>.gif" width="11" height="11" style="margin-top: 2px" alt="" /></td> + <td class="listr"><?=displayIP($entry['dstip'], 'dstip');?></td> + <td class="listr"><?=$entry['dstport'];?></td> + <td class="listr"><?=$entry['protocol'];?></td> + <td class="listr" align="right"><?=$entry['packets'];?></td> + <td class="listr" align="right"><?=$entry['bytes'];?></td> + <td class="listr" align="right"><?=$entry['expire'];?></td> + </tr> + <?php + $count++; + } + } + } + ?> </table> -<br><strong>Firewall connection states displayed: <?=$count;?>/<?=$totalStates;?></strong> +<br /><strong>Firewall connection states displayed: <?=$count;?>/<?=$totalStates;?></strong> <?php if ($filterPassThru): ?> -<p> -<form action="diag_new_states.php" method="GET"> -<input type="hidden" name="order" value="bytes"> -<input type="hidden" name="sort" value="des"> -<input type="submit" class="formbtn" value="Unfilter View"> -</form> -</p> +<div> + <form action="diag_new_states.php" method="get"> + <input type="hidden" name="order" value="bytes" /> + <input type="hidden" name="sort" value="des" /><br /> + <input type="submit" class="formbtn" value="Unfilter View" /> + </form> +</div> <?php endif; ?> <?php include("fend.inc"); ?> </body> diff --git a/config/diag_states_pt/diag_new_states.xml b/config/diag_states_pt/diag_new_states.xml index 0e4e6c7d..849c4b55 100644 --- a/config/diag_states_pt/diag_new_states.xml +++ b/config/diag_states_pt/diag_new_states.xml @@ -2,51 +2,47 @@ <!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + diag_new_states.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2002 Paul Taylor + 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: + 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. - 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. - 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>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> <name>diag_new_states</name> - <version>0.2</version> + <version>0.3</version> <title>Diagnostics: States New</title> <menu> <name>States New</name> @@ -55,11 +51,7 @@ <url>diag_new_states.php</url> </menu> <additional_files_needed> - <prefix>/usr/local/www/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/</prefix> <item>https://packages.pfsense.org/packages/config/diag_states_pt/diag_new_states.php</item> </additional_files_needed> - <custom_php_deinstall_command> - mwexec("rm /usr/local/www/diag_new_states.php"); - </custom_php_deinstall_command> </packagegui> diff --git a/config/filemgr/file_manager.php b/config/filemgr/file_manager.php new file mode 100644 index 00000000..5e858591 --- /dev/null +++ b/config/filemgr/file_manager.php @@ -0,0 +1,497 @@ +<?php +/* + file_manager.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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. +*/ +include("rbfminc/config.php"); +//include("rbfminc/session.php"); +require_once('config.inc'); +require("guiconfig.inc"); + +$closehead = false; +include("head.inc"); + +global $config; +if ('ok' == 'ok') { + set_time_limit(1800); //30 min + include("rbfminc/functions.php"); + + clearstatcache(); + $_GET['p'] = urldecode($_GET['p']); + + if ($_COOKIE['current_folder']) { + $initial_folder_cookie = $_COOKIE['current_folder']; + } + + if ($_GET['url_field']) { + setcookie('url_field', $_GET['url_field']); + $url_field = $_GET['url_field']; + } else { + $url_field = $_COOKIE['url_field']; + } + + if ($_GET['p']) { + if (substr($_GET['p'], -1) != "/") { + $_GET['p'] = $_GET['p']."/"; + } + $current_folder = $_GET['p']; + } elseif (($initial_folder_cookie) && (file_exists($initial_folder_cookie))) { + if (substr($initial_folder_cookie, -1) != "/") { + $initial_folder_cookie = $initial_folder_cookie."/"; + } + $current_folder = $initial_folder_cookie; + } elseif (($initial_folder) && (file_exists($initial_folder))) { + if (substr($initial_folder, -1) != "/") { + $initial_folder = $initial_folder."/"; + } + $current_folder = $initial_folder; + } else { + $current_folder = $_SERVER['DOCUMENT_ROOT']."/"; + } + + if (($only_below) && (strlen($current_folder) < strlen($initial_folder))) { + setcookie('current_folder', '', time()-3600); + header("Location: file_manager.php"); + exit(); + } + + //setcookie('current_folder', $current_folder); + + if (substr($current_folder, 0, strlen($_SERVER['DOCUMENT_ROOT'])) == $_SERVER['DOCUMENT_ROOT']) { + $url_path = "http://" . $_SERVER['HTTP_HOST'] . "/" . substr($current_folder, strlen($_SERVER['DOCUMENT_ROOT'])); + } + + if (($_POST['save_file'] == 'save_file') && ($_GET['f'])) { + if ($handle = fopen($current_folder.$_GET['f'] , 'w')) { + if (fwrite($handle, stripslashes($_POST['file_content'])) === FALSE) { + $alert_info .= "Cannot write to file ({$current_folder}{$_GET['f']})"; + } else { + $alert_info .= "File ({$current_folder}{$_GET['f']}) successfully saved"; + $redirect = "file_manager.php?p=".urlencode($current_folder); + } + } else { + $alert_info .= "Invalid file!!!"; + } + } + + + if ($_POST['upload_file'] == 'upload_file') { + if ($_FILES['file']['error'] == 8) { + $alert_info .= "File upload stopped by extension!!!"; + } + if ($_FILES['file']['error'] == 7) { + $alert_info .= "Failed to write file to disk!!!"; + } + if ($_FILES['file']['error'] == 6) { + $alert_info .= "Missing a temporary folder!!!"; + } + if ($_FILES['file']['error'] == 4) { + $alert_info .= "No image was uploaded!!!"; + } + if ($_FILES['file']['error'] == 3) { + $alert_info .= "The uploaded file was only partially uploaded!!!"; + } + if ($_FILES['file']['error'] == 2) { + $alert_info .= "The uploaded file exceeds the MAX_FILE_SIZE!!!"; + } + if ($_FILES['file']['error'] == 1) { + $alert_info .= "The uploaded file exceeds the upload_max_filesize!!!"; + } + + + if (!$alert_info) { + if ((file_exists($current_folder.$_FILES['file']['name'])) && (!$_POST['replace_file'])) { + $alert_info .= "A file with the same name already exist in this folder\\nTo replace this file check \"Replace existing file\" in upload form!"; + $redirect = "file_manager.php?p=".urlencode($current_folder); + } else { + if (!@move_uploaded_file($_FILES["file"]["tmp_name"], $current_folder.$_FILES['file']['name'])) { + $alert_info .= "Failed to upload file!!!"; + } else { + $alert_info .= "File successfully uploaded!"; + $redirect = "file_manager.php?p=".urlencode($current_folder); + } + } + } + } + + if (($_GET['do'] == 'delete') && ($_GET['file']) && ($_GET['type'] == 'file')) { + if (file_exists($current_folder.$_GET['file'])) { + if (!@unlink($current_folder.$_GET['file'])) { + $alert_info = "You cannot delete this file\\nThe relevant permissions must permit this."; + } else { + $alert_info = "File deleted"; + $redirect = "file_manager.php?p=".urlencode($current_folder); + } + } else { + $alert_info = "You cannot delete this file\\nInvalid file"; + } + } + + if (($_GET['do'] == 'delete') && ($_GET['file']) && ($_GET['type'] == 'directory')) { + if (file_exists($current_folder.$_GET['file'])) { + if (!RecursiveFolderDelete($current_folder.$_GET['file'])) { + $alert_info = "You cannot delete this directory\\nThe relevant permissions must permit this."; + } else { + $alert_info = "Folder deleted"; + $redirect = "file_manager.php?p=".urlencode($current_folder); + } + } else { + $alert_info = "You cannot delete this directory\\nInvalid directory"; + } + } + + if ($_POST['create_folder'] == "Create folder") { + if (@mkdir($current_folder.$_POST['folder_name'])) { + $alert_info = "Folder created successfully!"; + } else { + $alert_info = "Invalid folder name!"; + } + } + + + preg_match_all("/\//", $current_folder, $m); + if (count($m[0]) > 1) { + $up_one_level = " ondblclick=\"document.location='{$_SERVER['PHP_SELF']}?p=".urlencode(substr($current_folder, 0, strrpos(substr($current_folder, 0, -1), "/"))."/")."'\""; + } + + + if ($handle = @opendir($current_folder)) { + while (false !== ($folder_content = readdir($handle))) { + if ((is_dir($current_folder . '/' . $folder_content)) && ($folder_content != '.' && $folder_content != '..')) { + $folders[] = $folder_content; + } elseif ((!is_dir($current_folder . '/' . $folder_content)) && ($folder != '.') && ($folder_content != '..')) { + $files[] = $folder_content; + } + } + closedir($handle); + } else { + $error = "<h1 style=\"color:red\" align=\"center\">Invalid directory</h1>"; + } + + $container .= <<<EOF +<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" class=\"list\" width=\"100%\" summary=\"file manager\"> + <tr> + <th style=\"padding:0;width:18px\"> </th> + <th>Name</th> + <th colspan=\"5\"> </th> + <th>Ext.</th> + <th>Size</th> + <th>Date</th> + <th>Attributes</th> + </tr> + <tr> + <td style=\"padding:0;width:18px\" title=\"UP one level\"><img width=\"16\" height=\"16\" src=\"rbfmimg/folder.png\" alt=\"F\" {$up_one_level} /></td> + <td colspan=\"11\"><b title=\"UP one level\"{$up_one_level}>[..]</b></td> + </tr> +EOF; + + $id = 1; + + if (is_array($folders)) { + array_multisort($folders, SORT_ASC, SORT_REGULAR); + foreach ($folders as $v) { + if ($v) { + $vf = $v.'/'; + $last_updated_time = date("Y.m.d H:i:s", filemtime($current_folder.$v)); + $fileperms = GetFilePerms($current_folder.$v); + + if ($url_path) { + $browser = "<a href=\"{$url_path}{$v}\" target=\"_blank\"><img src=\"rbfmimg/ico_open_as_web.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"W\" title=\"Open as web page\" /></a>"; + if ($url_field) { + $use_url = "<img src=\"rbfmimg/ico_use_file.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL ({$url_path}{$v})\" onclick=\"window.opener.document.getElementById('{$url_field}').value='{$url_path}{$v}'; window.close()\" style=\"cursor: pointer\" />"; + } else { + $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; + } + } else { + $browser = " "; + $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; + } + + + $container .= <<<EOF + <tr> + <td style=\"padding:0;width:18px\"> + <img width=\"16\" height=\"16\" src=\"rbfmimg/folder.png\" alt=\"Folder\" ondblclick=\"document.location='{$_SERVER['PHP_SELF']}?p=".urlencode($current_folder.$vf)."'\" /> + </td> + <td> + <div style=\"padding-top:2px;\" id=\"f{$id}\" ondblclick=\"document.location='{$_SERVER['PHP_SELF']}?p=".urlencode($current_folder.$vf)."'\"> + {$v} + </div> + + <form class=\"rename_field\" id=\"r{$id}\" name=\"r{$id}\" method=\"post\" action=\"rbfminc/rename.php\" target=\"results\" onsubmit=\"this.n.blur(); return false\"> + <input class=\"input_name rename_input\" name=\"n\" type=\"text\" value=\"{$v}\" id=\"rf{$id}\" onblur=\"document.form{$id}.submit(); document.getElementById('f{$id}').style.display = 'block'; document.getElementById('r{$id}').style.display = 'none'; document.getElementById('f{$id}').innerHTML = this.value; document.form{$id}.o.value = this.value;\" /> + <input name=\"cf\" type=\"hidden\" value=\"{$current_folder}\" /> + <input name=\"o\" type=\"hidden\" value=\"{$v}\" /> + <input name=\"t\" type=\"hidden\" value=\"d\" /> + <input name=\"submitS\" type=\"submit\" value=\"submitS\" style='display: none; width:0;height:0' /> + </form> + </td> + <!--<td>{$use_url}</td>--> + <td>{$browser}</td> + <td> </td> + <td> + <img width=\"16\" height=\"16\" src=\"rbfmimg/ico_rename.png\" alt=\"Rename\" title=\"Rename\" onclick=\" document.getElementById('r{$id}').style.display = 'block'; document.getElementById('f{$id}').style.display = 'none'; document.getElementById('rf{$id}').focus(); document.getElementById('rf{$id}').select()\" /> + </td> + <td> </td> + <td> + <img width=\"16\" height=\"16\" src=\"rbfmimg/ico_delete.png\" alt=\"D\" title=\"Delete\" onclick=\"if(confirm('Delete folder "{$v}"?') && confirm('You cannot undo this operation!!!') && confirm('To delete this folder "{$v}" press OK\\nTo cancel this operation press CANCEL')){document.location = 'file_manager.php?p=".urlencode($current_folder)."&do=delete&file=".urlencode($v)."&type=directory'}\" /> + </td> + <td class=\"srow\"> </td> + <td><b><DIR></b></td> + <td class=\"srow\">{$last_updated_time}</td> + <td class=\"fileperms\">{$fileperms}</td> + </tr> +EOF; + + $id++; + } + } + } + + if (is_array($files)) { + array_multisort($files, SORT_ASC, SORT_REGULAR); + foreach ($files as $v) { + if ($v) { + $extension = substr(strrchr($v, "."), 1); + + $file_image = "ico_file.png"; + if (($extension == 'php') || ($extension == 'php3')) { + $file_image = "ico_php.png"; + } + if (($extension == 'htm') || ($extension == 'HTM') || ($extension == 'html') || ($extension == 'HTML')) { + $file_image = "ico_html.png"; + } + if (($extension == 'jpg') || ($extension == 'JPG') || ($extension == 'jpeg') || ($extension == 'JPEG') || + ($extension == 'gif') || ($extension == 'GIF') || ($extension == 'png') || ($extension == 'PNG')) { + $file_image = "ico_picture.png"; + } + + $last_updated_time = date("Y.m.d H:i:s", filemtime($current_folder.$v)); + $file_size = roundsize(filesize($current_folder.$v)); + + if (($extension == 'txt') || ($extension == 'inc') || ($extension == 'sh') || ($extension == 'js') || ($extension == 'xml') || + ($extension == 'conf') || ($extension == 'config') || ($extension == 'ini') || ($extension == 'php') || ($extension == 'php3') || + ($extension == 'htm') || ($extension == 'HTM') || ($extension == 'html') || ($extension == 'HTML') || ($extension == 'css') || ($extension == 'CSS')) { + $edit_file_content = "<a href=\"file_manager.php?p=".urlencode($current_folder)."&f=".urlencode($v)."&do=edit#file_edit\"><img width=\"16\" height=\"16\" src=\"rbfmimg/ico_script_edit.png\" alt=\"Edit\" title=\"View/Edit\" border=\"0\" /></a>"; + } else { + $edit_file_content = " "; + } + + $fileperms = GetFilePerms($current_folder.$v); + + if ($url_path) { + $browser = "<a href=\"{$url_path}{$v}\" target=\"_blank\"><img src=\"rbfmimg/ico_open_as_web.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"W\" title=\"Open as web page\" /></a>"; + if ($url_field) { + $use_url = "<img src=\"rbfmimg/ico_use_file.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL ({$url_path}{$v})\" onclick=\"window.opener.document.getElementById('{$url_field}').value='{$url_path}{$v}'; window.close()\" style=\"cursor: pointer\" />"; + } else { + $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; + } + } else { + $browser = " "; + $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; + } + + $container .= <<<EOF + <tr> + <td style=\"padding:0;width:18px\"> + <img width=\"16\" height=\"16\" src=\"rbfmimg/{$file_image}\" alt=\"File\" ondblclick=\"document.location = 'rbfminc/download.php?p=".urlencode($current_folder)."&file_name=".urlencode($v)."'\" /> + </td> + <td> + <div style=\"padding-top:2px;\" id=\"f{$id}\" ondblclick=\"document.location = 'rbfminc/download.php?p=".urlencode($current_folder)."&file_name=".urlencode($v)."'\"> + {$v} + </div> + + <form class=\"rename_field\" id=\"r{$id}\" name=\"r{$id}\" method=\"post\" action=\"rbfminc/rename.php\" target=\"results\" onsubmit=\"this.n.blur(); return false\"> + <input name=\"cf\" type=\"hidden\" value=\"{$current_folder}\" /> + <input name=\"o\" type=\"hidden\" value=\"{$v}\" /> + <input name=\"t\" type=\"hidden\" value=\"f\" /> + <input class=\"input_name\" name=\"n\" type=\"text\" value=\"{$v}\" id=\"rf{$id}\" onblur=\"document.form{$id}.submit(); document.getElementById('f{$id}').style.display = 'block'; document.getElementById('r{$id}').style.display = 'none'; document.getElementById('f{$id}').innerHTML = this.value; document.form{$id}.o.value = this.value;\" /> + <input name=\"submitS\" type=\"submit\" value=\"submitS\" style=\"display: none; width:0;height:0\" /> + </form> + </td> + <!--<td>{$use_url}</td>--> + <td>{$browser}</td> + <td> + <a href=\"rbfminc/download.php?p=".urlencode($current_folder)."&file_name=".urlencode($v)."\"><img width=\"16\" height=\"16\" src=\"rbfmimg/ico_download.png\" alt=\"Download\" title=\"Download\" border=\"0\"/></a> + </td> + <td> + <img width=\"16\" height=\"16\" src=\"rbfmimg/ico_rename.png\" alt=\"Rename\" title=\"Rename\" onclick=\"document.getElementById('f{$id}').style.display = 'none'; document.getElementById('r{$id}').style.display = 'block'; document.getElementById('rf{$id}').focus(); document.getElementById('rf{$id}').select()\" /> + </td> + <td>{$edit_file_content}</td> + <td> + <img width=\"16\" height=\"16\" src=\"rbfmimg/ico_delete.png\" alt=\"D\" title=\"Delete\" onclick=\"if(confirm('Delete file "{$v}"?') && confirm('You cannot undo this operation!!!') && confirm('To delete this file "{$v}" press OK\\nTo cancel this operation press CANCEL')){document.location = 'file_manager.php?p=".urlencode($current_folder)."&do=delete&file=".urlencode($v)."&type=file'}\" /> + </td> + <td class=\"srow\">{$extension}</td> + <td>{$file_size}</td> + <td class=\"srow\">{$last_updated_time}</td> + <td class=\"fileperms\">{$fileperms}</td> + </tr> +EOF; + + $id++; + } + } + } + + $container .= "</table>"; + + $container = preg_replace("/\s+/m", " ", $container); + +?> + +<link href="rbfminc/file_editor_style.css" rel="stylesheet" type="text/css" /> +</head> + +<body> + + +<?php include("fbegin.inc"); ?> + +<?php echo $security_issues; ?> +<div class="file_editor"> + <div class="header"></div> + <form id="path" name="path" method="get" action="" class="path"> + <input name="p" type="text" id="location" value="<?php echo $current_folder; ?>" /> + <input name="go" type="image" id="go" value="Go" src="rbfmimg/go.png" style="width:35; height:18" /> + </form> + <div class="url_path"><br />URL path: <a href="/<?php echo $url_path; ?>" target="_blank"><?php echo $url_path; ?></a></div> + <div class="container"> <?php echo $container; ?> <?php echo $error; ?> </div> + <form action="" method="post" enctype="multipart/form-data" name="form_upload" id="form_upload" class="form_upload"> + Upload a file in current folder: + <input type="file" name="file" id="file" /> + + <input name="replace_file" type="checkbox" value="1" /> + Replace existing file + <input type="submit" name="upload" id="upload" value="Upload" /> + <input name="upload_file" type="hidden" id="upload_file" value="upload_file" /> + </form> + <form action="" method="post" enctype="multipart/form-data" name="form_create" id="form_create" class="form_create"> + Create new folder here; Folder name: + <input name="folder_name" type="text" style="width:290" /> + <input type="submit" name="create_folder" id="create_folder" value="Create folder" /> + </form> + <iframe name="results" frameborder="0" scrolling="auto" class='results'></iframe> + <div align="center" style="margin-top:5px"> [ <img src="rbfmimg/ico_open_as_web.png" width="16" height="16" align="middle" alt="open" /> OPEN IN BROWSER ] + [ <img src="rbfmimg/ico_download.png" width="16" height="16" align="middle" alt="download" /> DOWNLOAD ] + [ <img src="rbfmimg/ico_rename.png" width="16" height="16" align="middle" alt="rename" /> RENAME ] + [ <img src="rbfmimg/ico_script_edit.png" width="16" height="16" align="middle" alt="view" /> VIEW/EDIT ] + [ <img src="rbfmimg/ico_delete.png" width="16" height="16" align="middle" alt="delete" /> DELETE ] </div> + <?php + if ($_GET['do'] == 'edit') { + + $file_content = file_get_contents($current_folder.$_GET['f']); + echo <<<EOD +<form id=\"form_edit\" name=\"form_edit\" method=\"post\" action=\"\" style='width: 670px;margin: 10px auto 0;border-top: 1px #999999 solid'> + <a name=\"file_edit\"></a> + File: <b>{$current_folder}{$_GET['f']}</b><br /> + <textarea name=\"file_content\" id=\"file_content\" cols=\"1\" rows=\"1\" style=\"width: 99%; height: 400px\">".htmlentities ($file_content)."</textarea><br /> + <input name=\"save\" type=\"submit\" value=\"Save\" /> + <input name=\"close\" type=\"button\" value=\"Close file editor\" onclick=\"document.location = 'file_manager.php?f=".urlencode($current_folder)."'\" /> + <input name=\"save_file\" type=\"hidden\" value=\"save_file\" /> +</form> +EOD; + + } + +?> + <div class="footer"></div> +</div> +<small>Created by <a href="http://www.tomschaefer.org/pfsense">TomSchaefer</a></small> +<?php +if ($alert_info) { + echo <<<EOD + <script type=\"text/javascript\"> + //<![CDATA[ + alert('{$alert_info}'); + //]]> + </script> +EOD; +} + +if ($redirect) { + echo <<<EOD + <script type=\"text/javascript\"> + //<![CDATA[ + document.location = '{$redirect}'; + //]]> + </script> +EOD; +} +?> + +<?php include("fend.inc"); ?> +</body> +</html> + +<?php +} else { +?> + + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Login</title> + <style type="text/css"> + /*<![CDATA[*/ + body,td,th,input { + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + } + body { + background-color: #EEEEEE; + } + /*]]>*/ + </style> + </head> + <body> + <div class="login"><br /><br /><br /><br /> + <div style="color:red" align="center"><?php echo $error_message; ?></div> + <form id="login_form" name="login_form" method="post" action=""> + <table border="0" align="center" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF" style="border:1px solid #999999; padding:10px" summary="login"> + <tr> + <td align="right">Username:</td> + <td><input type="text" name="username" id="username" class="login_input" style="width:230px" /></td> + </tr> + <tr> + <td align="right">Password:</td> + <td><input type="password" name="password" id="password" class="login_input" style="width:100px" /> + </td> + </tr> + <tr> + <td colspan="2" align="right"><input type="submit" name="button" id="button" value="Login »" /></td> + </tr> + </table> + <input name="login" type="hidden" value="login" /> + </form> + </div> + </body> + </html> + +<?php +} +?> diff --git a/config/filemgr/file_manager.tmp b/config/filemgr/file_manager.tmp deleted file mode 100644 index 8c5ee1c5..00000000 --- a/config/filemgr/file_manager.tmp +++ /dev/null @@ -1,595 +0,0 @@ -<?php -include "rbfminc/config.php"; -//include "rbfminc/session.php"; -require_once('config.inc'); -require("guiconfig.inc"); - -$closehead = false; -include("head.inc"); - -global $config; -if('ok' == 'ok'){ - set_time_limit(1800); //30 min - include "rbfminc/functions.php"; - - clearstatcache (); - $_GET['p'] = urldecode($_GET['p']); - - if($_COOKIE['current_folder']){ - $initial_folder_cookie = $_COOKIE['current_folder']; - } - - if($_GET['url_field']){ - setcookie('url_field', $_GET['url_field']); - $url_field = $_GET['url_field']; - }else{ - $url_field = $_COOKIE['url_field']; - } - - if($_GET['p']){ - if(substr($_GET['p'], -1) != "/"){$_GET['p'] = $_GET['p']."/";} - $current_folder = $_GET['p']; - }elseif($initial_folder_cookie and file_exists($initial_folder_cookie)){ - if(substr($initial_folder_cookie, -1) != "/"){$initial_folder_cookie = $initial_folder_cookie."/";} - $current_folder = $initial_folder_cookie; - }elseif($initial_folder and file_exists($initial_folder)){ - if(substr($initial_folder, -1) != "/"){$initial_folder = $initial_folder."/";} - $current_folder = $initial_folder; - }else{ - $current_folder = $_SERVER['DOCUMENT_ROOT']."/"; - } - - - if($only_below and strlen($current_folder) < strlen($initial_folder)){ - setcookie('current_folder', '', time()-3600); - header("Location: file_manager.php"); - exit(); - } - - - //setcookie('current_folder', $current_folder); - - if(substr($current_folder, 0, strlen($_SERVER['DOCUMENT_ROOT'])) == $_SERVER['DOCUMENT_ROOT']){ - $url_path = "http://".$_SERVER['HTTP_HOST']."/".substr($current_folder, strlen($_SERVER['DOCUMENT_ROOT'])); - } - - - if($_POST['save_file'] == 'save_file' and $_GET['f']){ - if($handle = fopen($current_folder.$_GET['f'] , 'w')){ - if (fwrite($handle, stripslashes($_POST['file_content'])) === FALSE) { - $alert_info .= "Cannot write to file ({$current_folder}{$_GET['f']})"; - }else{ - $alert_info .= "File ({$current_folder}{$_GET['f']}) successfully saved"; - $redirect = "file_manager.php?p=".urlencode($current_folder); - } - }else{ - $alert_info .= "Invalid file!!!"; - } - } - - - if($_POST['upload_file'] == 'upload_file'){ - if($_FILES['file']['error'] == 8){ - $alert_info .= "File upload stopped by extension!!!"; - } - if($_FILES['file']['error'] == 7){ - $alert_info .= "Failed to write file to disk!!!"; - } - if($_FILES['file']['error'] == 6){ - $alert_info .= "Missing a temporary folder!!!"; - } - if($_FILES['file']['error'] == 4){ - $alert_info .= "No image was uploaded!!!"; - } - if($_FILES['file']['error'] == 3){ - $alert_info .= "The uploaded file was only partially uploaded!!!"; - } - if($_FILES['file']['error'] == 2){ - $alert_info .= "The uploaded file exceeds the MAX_FILE_SIZE!!!"; - } - if($_FILES['file']['error'] == 1){ - $alert_info .= "The uploaded file exceeds the upload_max_filesize!!!"; - } - - - if(!$alert_info){ - if(file_exists($current_folder.$_FILES['file']['name']) and !$_POST['replace_file']){ - $alert_info .= "A file with the same name already exist in this folder\\nTo replace this file check \"Replace existing file\" in upload form!"; - $redirect = "file_manager.php?p=".urlencode($current_folder); - }else{ - if(!@move_uploaded_file($_FILES["file"]["tmp_name"], $current_folder.$_FILES['file']['name'])){ - $alert_info .= "Failed to upload file!!!"; - }else{ - $alert_info .= "File successfully uploaded!"; - $redirect = "file_manager.php?p=".urlencode($current_folder); - } - } - } - } - - if($_GET['do'] == 'delete' and $_GET['file'] and $_GET['type'] == 'file'){ - if(file_exists($current_folder.$_GET['file'])){ - if(!@unlink($current_folder.$_GET['file'])){ - $alert_info = "You cannot delete this file\\nThe relevant permissions must permit this."; - }else{ - $alert_info = "File deleted"; - $redirect = "file_manager.php?p=".urlencode($current_folder); - } - }else{ - $alert_info = "You cannot delete this file\\nInvalid file"; - } - } - - if($_GET['do'] == 'delete' and $_GET['file'] and $_GET['type'] == 'directory'){ - if(file_exists($current_folder.$_GET['file'])){ - if(!RecursiveFolderDelete($current_folder.$_GET['file'])){ - $alert_info = "You cannot delete this directory\\nThe relevant permissions must permit this."; - }else{ - $alert_info = "Folder deleted"; - $redirect = "file_manager.php?p=".urlencode($current_folder); - } - }else{ - $alert_info = "You cannot delete this directory\\nInvalid directory"; - } - } - - if($_POST['create_folder'] == "Create folder"){ - if(@mkdir($current_folder.$_POST['folder_name'])){ - $alert_info = "Folder created successfully!"; - }else{ - $alert_info = "Invalid folder bane!"; - } - } - - - preg_match_all("/\//", $current_folder, $m); - if(count($m[0]) > 1){ - $up_one_level = " ondblclick=\"document.location='{$_SERVER['PHP_SELF']}?p=".urlencode(substr($current_folder, 0, strrpos(substr($current_folder, 0, -1), "/"))."/")."'\""; - } - - - if ($handle = @opendir($current_folder)) { - while (false !== ($folder_content = readdir($handle))) { - if(is_dir($current_folder.'/'.$folder_content) and $folder_content!='.' and $folder_content!='..'){ - $folders[] = $folder_content; - }elseif(!is_dir($current_folder.'/'.$folder_content) and $folder!='.' and $folder_content!='..'){ - $files[] = $folder_content; - } - } - closedir($handle); - }else{ - $error = "<h1 style=\"color:red\" align=\"center\">Invalid directory</h1>"; - } - - $container .= " -<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" class=\"list\" width=\"100%\" summary=\"file manager\"> - <tr> - <th style=\"padding:0;width:18px\"> </th> - <th>Name</th> - <th colspan=\"5\"> </th> - <th>Ext.</th> - <th>Size</th> - <th>Date</th> - <th>Attributes</th> - </tr> - <tr> - <td style=\"padding:0;width:18px\" title=\"UP one level\"><img width=\"16\" height=\"16\" src=\"rbfmimg/folder.png\" alt=\"F\" {$up_one_level} /></td> - <td colspan=\"11\"><b title=\"UP one level\"{$up_one_level}>[..]</b></td> - </tr> -"; - - $id = 1; - - if(is_array($folders)){ - array_multisort($folders, SORT_ASC, SORT_REGULAR); - foreach($folders as $v){ - if($v){ - - $vf = $v.'/'; - - $last_updated_time = date("Y.m.d H:i:s", filemtime($current_folder.$v)); - - $fileperms = GetFilePerms($current_folder.$v); - - if($url_path){ - $browser = "<a href=\"{$url_path}{$v}\" target=\"_blank\"><img src=\"rbfmimg/ico_open_as_web.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"W\" title=\"Open as web page\" /></a>"; - if($url_field){ - $use_url = "<img src=\"rbfmimg/ico_use_file.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL ({$url_path}{$v})\" onclick=\"window.opener.document.getElementById('{$url_field}').value='{$url_path}{$v}'; window.close()\" style=\"cursor: pointer\" />"; - }else{ - $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; - } - }else{ - $browser = " "; - $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; - } - - - $container .= " - <tr> - <td style=\"padding:0;width:18px\"> - <img width=\"16\" height=\"16\" - src=\"rbfmimg/folder.png\" - alt=\"Folder\" - ondblclick=\"document.location='{$_SERVER['PHP_SELF']}?p=".urlencode($current_folder.$vf)."'\" - /> - </td> - <td> - - <div style=\"padding-top:2px;\" - id=\"f{$id}\" - ondblclick=\"document.location='{$_SERVER['PHP_SELF']}?p=".urlencode($current_folder.$vf)."'\" - > - {$v} - </div> - - <form - class=\"rename_field\" - id=\"r{$id}\" - name=\"r{$id}\" - method=\"post\" - action=\"rbfminc/rename.php\" - target=\"results\" - onsubmit=\" - this.n.blur(); - return false - \" - > - - <input - class=\"input_name rename_input\" - name=\"n\" - type=\"text\" - value=\"{$v}\" - id=\"rf{$id}\" - onblur=\" - document.form{$id}.submit(); - document.getElementById('f{$id}').style.display = 'block'; - document.getElementById('r{$id}').style.display = 'none'; - document.getElementById('f{$id}').innerHTML = this.value; - document.form{$id}.o.value = this.value; - \" - /> - - <input name=\"cf\" type=\"hidden\" value=\"{$current_folder}\" /> - <input name=\"o\" type=\"hidden\" value=\"{$v}\" /> - <input name=\"t\" type=\"hidden\" value=\"d\" /> - <input name=\"submitS\" type=\"submit\" value=\"submitS\" style='display: none; width:0;height:0' /> - </form> - </td> - <!--<td>{$use_url}</td>--> - <td>{$browser}</td> - <td> </td> - <td> - <img width=\"16\" height=\"16\" - src=\"rbfmimg/ico_rename.png\" - alt=\"Rename\" title=\"Rename\" - onclick=\" - document.getElementById('r{$id}').style.display = 'block'; - document.getElementById('f{$id}').style.display = 'none'; - document.getElementById('rf{$id}').focus(); - document.getElementById('rf{$id}').select() - \" - /> - </td> - <td> </td> - <td> - <img width=\"16\" height=\"16\" - src=\"rbfmimg/ico_delete.png\" - alt=\"D\" - title=\"Delete\" - onclick=\" - if( - confirm('Delete folder "{$v}"?') && - confirm('You cannot undo this operation!!!') && - confirm('To delete this folder "{$v}" press OK\\nTo cancel this operation press CANCEL') - ){ - document.location = 'file_manager.php?p=".urlencode($current_folder)."&do=delete&file=".urlencode($v)."&type=directory' - } - \" - /> - </td> - <td class=\"srow\"> </td> - <td><b><DIR></b></td> - <td class=\"srow\">{$last_updated_time}</td> - <td class=\"fileperms\">{$fileperms}</td> - </tr> - "; - $id++; - } - } - } - if(is_array($files)){ - array_multisort($files, SORT_ASC, SORT_REGULAR); - foreach($files as $v){ - if($v){ - - $extension = substr(strrchr($v, "."), 1); - - $file_image = "ico_file.png"; - if($extension == 'php' or $extension == 'php3'){$file_image = "ico_php.png";} - if( - $extension == 'htm' or - $extension == 'HTM' or - $extension == 'html' or - $extension == 'HTML' - ){$file_image = "ico_html.png";} - if( - $extension == 'jpg' or - $extension == 'JPG' or - $extension == 'jpeg' or - $extension == 'JPEG' or - $extension == 'gif' or - $extension == 'GIF' or - $extension == 'png' or - $extension == 'PNG' - ){$file_image = "ico_picture.png";} - - $last_updated_time = date("Y.m.d H:i:s", filemtime($current_folder.$v)); - - $file_size = roundsize(filesize($current_folder.$v)); - - if( - $extension == 'txt' or - $extension == 'inc' or - $extension == 'sh' or - $extension == 'js' or - $extension == 'xml' or - $extension == 'conf' or - $extension == 'config' or - $extension == 'ini' or - $extension == 'php' or - $extension == 'php3' or - $extension == 'htm' or - $extension == 'HTM' or - $extension == 'html' or - $extension == 'HTML' or - $extension == 'css' or - $extension == 'CSS' - ){ - $edit_file_content = "<a href=\"file_manager.php?p=".urlencode($current_folder)."&f=".urlencode($v)."&do=edit#file_edit\"><img width=\"16\" height=\"16\" src=\"rbfmimg/ico_script_edit.png\" alt=\"Edit\" title=\"View/Edit\" border=\"0\" /></a>"; - }else{ - $edit_file_content = " "; - } - - $fileperms = GetFilePerms($current_folder.$v); - - if($url_path){ - $browser = "<a href=\"{$url_path}{$v}\" target=\"_blank\"><img src=\"rbfmimg/ico_open_as_web.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"W\" title=\"Open as web page\" /></a>"; - if($url_field){ - $use_url = "<img src=\"rbfmimg/ico_use_file.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL ({$url_path}{$v})\" onclick=\"window.opener.document.getElementById('{$url_field}').value='{$url_path}{$v}'; window.close()\" style=\"cursor: pointer\" />"; - }else{ - $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; - } - }else{ - $browser = " "; - $use_url = "<img src=\"rbfmimg/ico_use_file_inactive.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"U\" title=\"Use URL (Inactive!!!)\" />"; - } - - - $container .= " - <tr> - <td style=\"padding:0;width:18px\"> - <img width=\"16\" height=\"16\" src=\"rbfmimg/{$file_image}\" alt=\"File\" ondblclick=\"document.location = 'rbfminc/download.php?p=".urlencode($current_folder)."&file_name=".urlencode($v)."'\" /> - </td> - <td> - <div style=\"padding-top:2px;\" - id=\"f{$id}\" - ondblclick=\"document.location = 'rbfminc/download.php?p=".urlencode($current_folder)."&file_name=".urlencode($v)."'\" - > - {$v} - </div> - - <form - class=\"rename_field\" - id=\"r{$id}\" - name=\"r{$id}\" - method=\"post\" - action=\"rbfminc/rename.php\" - target=\"results\" - onsubmit=\"this.n.blur(); return false\" - > - <input name=\"cf\" type=\"hidden\" value=\"{$current_folder}\" /> - <input name=\"o\" type=\"hidden\" value=\"{$v}\" /> - <input name=\"t\" type=\"hidden\" value=\"f\" /> - <input - class=\"input_name\" - name=\"n\" - type=\"text\" - value=\"{$v}\" - id=\"rf{$id}\" - onblur=\" - document.form{$id}.submit(); - document.getElementById('f{$id}').style.display = 'block'; - document.getElementById('r{$id}').style.display = 'none'; - document.getElementById('f{$id}').innerHTML = this.value; - document.form{$id}.o.value = this.value; - \" - /> - <input name=\"submitS\" type=\"submit\" value=\"submitS\" style=\"display: none; width:0;height:0\" /> - </form> - </td> - <!--<td>{$use_url}</td>--> - <td>{$browser}</td> - <td> - <a href=\"rbfminc/download.php?p=".urlencode($current_folder)."&file_name=".urlencode($v)."\"><img width=\"16\" height=\"16\" - src=\"rbfmimg/ico_download.png\" - alt=\"Download\" - title=\"Download\" - border=\"0\" - /></a> - </td> - <td> - <img width=\"16\" height=\"16\" - src=\"rbfmimg/ico_rename.png\" - alt=\"Rename\" - title=\"Rename\" - onclick=\"document.getElementById('f{$id}').style.display = 'none'; - document.getElementById('r{$id}').style.display = 'block'; - document.getElementById('rf{$id}').focus(); - document.getElementById('rf{$id}').select()\" - /> - </td> - <td>{$edit_file_content}</td> - <td> - <img width=\"16\" height=\"16\" - src=\"rbfmimg/ico_delete.png\" - alt=\"D\" - title=\"Delete\" - onclick=\" - if( - confirm('Delete file "{$v}"?') && - confirm('You cannot undo this operation!!!') && - confirm('To delete this file "{$v}" press OK\\nTo cancel this operation press CANCEL') - ){ - document.location = 'file_manager.php?p=".urlencode($current_folder)."&do=delete&file=".urlencode($v)."&type=file' - } - \" - /> - </td> - <td class=\"srow\">{$extension}</td> - <td>{$file_size}</td> - <td class=\"srow\">{$last_updated_time}</td> - <td class=\"fileperms\">{$fileperms}</td> - </tr> - "; - $id++; - } - } - } - - $container .= "</table>"; - - $container = preg_replace("/\s+/m", " ", $container); - -?> - -<link href="rbfminc/file_editor_style.css" rel="stylesheet" type="text/css" /> -</head> - -<body> - - -<?php include("fbegin.inc"); ?> - -<?php echo $security_issues; ?> -<div class="file_editor"> - <div class="header"> - - </div> - <form id="path" name="path" method="get" action="" class="path"> - <input name="p" type="text" id="location" value="<?php echo $current_folder; ?>" /> - <input name="go" type="image" id="go" value="Go" src="rbfmimg/go.png" style="width:35;height:18" /> - </form> - <div class="url_path"><br />URL path: <a href="/<?php echo $url_path; ?>" target="_blank"><?php echo $url_path; ?></a></div> - <div class="container"> <?php echo $container; ?> <?php echo $error; ?> </div> - <form action="" method="post" enctype="multipart/form-data" name="form_upload" id="form_upload" class="form_upload"> - Upload a file in current folder: - <input type="file" name="file" id="file" /> - - <input name="replace_file" type="checkbox" value="1" /> - Replace existing file - <input type="submit" name="upload" id="upload" value="Upload" /> - <input name="upload_file" type="hidden" id="upload_file" value="upload_file" /> - </form> - <form action="" method="post" enctype="multipart/form-data" name="form_create" id="form_create" class="form_create"> - Create new folder here; Folder name: - <input name="folder_name" type="text" style="width:290" /> - <input type="submit" name="create_folder" id="create_folder" value="Create folder" /> - </form> - <iframe name="results" frameborder="0" scrolling="auto" class='results'></iframe> - <div align="center" style="margin-top:5px"> [ <img src="rbfmimg/ico_open_as_web.png" width="16" height="16" align="middle" alt="open" /> OPEN IN BROWSER ] - [ <img src="rbfmimg/ico_download.png" width="16" height="16" align="middle" alt="download" /> DOWNLOAD ] - [ <img src="rbfmimg/ico_rename.png" width="16" height="16" align="middle" alt="rename" /> RENAME ] - [ <img src="rbfmimg/ico_script_edit.png" width="16" height="16" align="middle" alt="view" /> VIEW/EDIT ] - [ <img src="rbfmimg/ico_delete.png" width="16" height="16" align="middle" alt="delete" /> DELETE ] </div> - <?php - if($_GET['do'] == 'edit'){ - - $file_content = file_get_contents($current_folder.$_GET['f']); - echo " -<form id=\"form_edit\" name=\"form_edit\" method=\"post\" action=\"\" style='width: 670px;margin: 10px auto 0;border-top: 1px #999999 solid'> - <a name=\"file_edit\"></a> - File: <b>{$current_folder}{$_GET['f']}</b><br /> - <textarea name=\"file_content\" id=\"file_content\" cols=\"1\" rows=\"1\" style=\"width: 99%; height: 400px\">".htmlentities ($file_content)."</textarea><br /> - <input name=\"save\" type=\"submit\" value=\"Save\" /> - <input name=\"close\" type=\"button\" value=\"Close file editor\" onclick=\"document.location = 'file_manager.php?f=".urlencode($current_folder)."'\" /> - <input name=\"save_file\" type=\"hidden\" value=\"save_file\" /> -</form> -"; - } - -?> - <div class="footer"></div> -</div> -<small>Created by <a href="http://www.tomschaefer.org/pfsense">TomSchaefer</a></small> -<?php -if($alert_info){ - echo " -<script type=\"text/javascript\"> -//<![CDATA[ - alert('{$alert_info}'); -//]]> -</script> - "; -} -if($redirect){ - echo " -<script type=\"text/javascript\"> -//<![CDATA[ - document.location = '{$redirect}'; -//]]> -</script> - "; -} -?> -<?php include("fend.inc"); ?> -</body> -</html> -<?php -}else{ -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Login</title> -<style type="text/css"> -/*<![CDATA[*/ -body,td,th,input { - font-family: Arial, Helvetica, sans-serif; - font-size: 12px; -} -body { - background-color: #EEEEEE; -} -/*]]>*/ -</style></head> -<body><br /><br /><br /><br /> -<div class="login"> - <div style="color:red" align="center"><?php echo $error_message; ?></div> - <form id="login_form" name="login_form" method="post" action=""> - <table border="0" align="center" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF" style="border:1px solid #999999; padding:10px" summary="login"> - <tr> - <td align="right">Username:</td> - <td><input type="text" name="username" id="username" class="login_input" style="width:230px" /></td> - </tr> - <tr> - <td align="right">Password:</td> - <td><input type="password" name="password" id="password" class="login_input" style="width:100px" /> - </td> - </tr> - <tr> - <td colspan="2" align="right"><input type="submit" name="button" id="button" value="Login »" /></td> - </tr> - </table> - <input name="login" type="hidden" value="login" /> - </form> -</div> -</body> -</html> - - -<?php -} -?> diff --git a/config/filemgr/filemgr.inc b/config/filemgr/filemgr.inc deleted file mode 100644 index 56d34a60..00000000 --- a/config/filemgr/filemgr.inc +++ /dev/null @@ -1,154 +0,0 @@ -<?php -/* $Id$ */ -/* -/* ========================================================================== */ -/* - filemgr.inc - - All rights reserved. - */ -/* ========================================================================== */ -/* - - 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 php_sync_package_fm() -{ - global $config; -} - - -function php_install_command_fm() -{ - - global $config; - conf_mount_rw(); - config_lock(); - - if (!is_dir('/usr/local/www/packages/')) { - exec("mkdir /usr/local/www/packages/"); - } - - if (!is_dir('/usr/local/www/packages/filemgr/')) { - exec("mkdir /usr/local/www/packages/filemgr/"); - } - - if (!is_dir('/usr/local/www/packages/filemgr/rbfmimg/')) { - exec("mkdir /usr/local/www/packages/filemgr/rbfmimg/"); - } - - if (!is_dir('/usr/local/www/packages/filemgr/rbfminc/')) { - exec("mkdir /usr/local/www/packages/filemgr/rbfminc/"); - } - - - - - - //rename PHP files from .tmp to .php - exec("cp /tmp/file_manager.tmp /usr/local/www/packages/filemgr/file_manager.php"); - unlink_if_exists("/tmp/file_manager.tmp"); - - exec("cp /tmp/filemgr.inc /usr/local/www/packages/filemgr/filemgr.inc"); - unlink_if_exists("/tmp/filemgr.inc"); - - exec("cp /tmp/filemgr.xml /usr/local/www/packages/filemgr/filemgr.xml"); - unlink_if_exists("/tmp/filemgr.xml"); - - exec("cp /tmp/index.tmp /usr/local/www/packages/filemgr/index.php"); - unlink_if_exists("/tmp/index.tmp"); - - exec("cp /tmp/bg_footer.png /usr/local/www/packages/filemgr/rbfmimg/bg_footer.png"); - unlink_if_exists("/tmp/bg_footer.png"); - - exec("cp /tmp/bg_header.png /usr/local/www/packages/filemgr/rbfmimg/bg_header.png"); - unlink_if_exists("/tmp/bg_header.png"); - exec("cp /tmp/bg_page.png /usr/local/www/packages/filemgr/rbfmimg/bg_page.png"); - unlink_if_exists("/tmp/bg_page.png"); - exec("cp /tmp/file_editor_bg.png /usr/local/www/packages/filemgr/rbfmimg/file_editor_bg.png"); - unlink_if_exists("/tmp/file_editor_bg.png"); - exec("cp /tmp/folder.png /usr/local/www/packages/filemgr/rbfmimg/folder.png"); - unlink_if_exists("/tmp/folder.png"); - exec("cp /tmp/folder_go.png /usr/local/www/packages/filemgr/rbfmimg/folder_go.png"); - unlink_if_exists("/tmp/folder_go.png"); - exec("cp /tmp/folder_up.png /usr/local/www/packages/filemgr/rbfmimg/folder_up.png"); - unlink_if_exists("/tmp/folder_up.png"); - exec("cp /tmp/go.png /usr/local/www/packages/filemgr/rbfmimg/go.png"); - unlink_if_exists("/tmp/go.png"); - exec("cp /tmp/ico_delete.png /usr/local/www/packages/filemgr/rbfmimg/ico_delete.png"); - unlink_if_exists("/tmp/ico_delete.png"); - exec("cp /tmp/ico_download.png /usr/local/www/packages/filemgr/rbfmimg/ico_download.png"); - unlink_if_exists("/tmp/ico_download.png"); - exec("cp /tmp/ico_file.png /usr/local/www/packages/filemgr/rbfmimg/ico_file.png"); - unlink_if_exists("/tmp/ico_file.png"); - exec("cp /tmp/ico_html.png /usr/local/www/packages/filemgr/rbfmimg/ico_html.png"); - unlink_if_exists("/tmp/ico_html.png"); - exec("cp /tmp/ico_open_as_web.png /usr/local/www/packages/filemgr/rbfmimg/ico_open_as_web.png"); - unlink_if_exists("/tmp/ico_open_as_web.png"); - exec("cp /tmp/ico_php.png /usr/local/www/packages/filemgr/rbfmimg/ico_php.png"); - unlink_if_exists("/tmp/ico_php.png"); - exec("cp /tmp/ico_picture.png /usr/local/www/packages/filemgr/rbfmimg/ico_picture.png"); - unlink_if_exists("/tmp/ico_picture.png"); - exec("cp /tmp/ico_rename.png /usr/local/www/packages/filemgr/rbfmimg/ico_rename.png"); - unlink_if_exists("/tmp/ico_rename.png"); - exec("cp /tmp/ico_script_edit.png /usr/local/www/packages/filemgr/rbfmimg/ico_script_edit.png"); - unlink_if_exists("/tmp/ico_script_edit.png"); - exec("cp /tmp/ico_use_file.png /usr/local/www/packages/filemgr/rbfmimg/ico_use_file.png"); - unlink_if_exists("/tmp/ico_use_file.png"); - exec("cp /tmp/ico_use_file_inactive.png /usr/local/www/packages/filemgr/rbfmimg/ico_use_file_inactive.png"); - unlink_if_exists("/tmp/ico_use_file_inactive.png"); - exec("cp /tmp/index.html /usr/local/www/packages/filemgr/rbfmimg/index.html"); - unlink_if_exists("/tmp/index.html"); - exec("cp /tmp/new.png /usr/local/www/packages/filemgr/rbfmimg/new.png"); - unlink_if_exists("/tmp/new.png"); - - exec("cp /tmp/config.tmp /usr/local/www/packages/filemgr/rbfminc/config.php"); - unlink_if_exists("/tmp/config.tmp"); - exec("cp /tmp/download.tmp /usr/local/www/packages/filemgr/rbfminc/download.php"); - unlink_if_exists("/tmp/download.tmp"); - exec("cp /tmp/file_editor_style.css /usr/local/www/packages/filemgr/rbfminc/file_editor_style.css"); - unlink_if_exists("/tmp/file_editor_style.css"); - exec("cp /tmp/functions.tmp /usr/local/www/packages/filemgr/rbfminc/functions.php"); - unlink_if_exists("/tmp/functions.tmp"); - exec("cp /tmp/index.html /usr/local/www/packages/filemgr/rbfminc/index.html"); - unlink_if_exists("/tmp/index.html"); - exec("cp /tmp/rename.tmp /usr/local/www/packages/filemgr/rbfminc/rename.php"); - unlink_if_exists("/tmp/rename.tmp"); - exec("cp /tmp/session.tmp /usr/local/www/packages/filemgr/rbfminc/session.php"); - unlink_if_exists("/tmp/session.tmp"); - - - - conf_mount_ro(); - config_unlock(); -} - - -function deinstall_command_fm() -{ - conf_mount_rw(); - $handle = popen("/usr/local/etc/rc.d/filemgr.sh stop", "r"); - unlink_if_exists("/usr/local/pkg/filemgr.xml"); - unlink_if_exists("/usr/local/pkg/filemgr.inc"); - exec("rm -R /usr/local/www/packages/filemgr/filemgrs"); - exec("rm -R /usr/local/www/packages/filemgr"); - exec("rm /usr/local/etc/rc.d/filemgr.sh"); - exec("pfctl -t filemgr -T kill"); - exec("sed -i -e '/filemgr/d' /tmp/rules.debug"); - exec("pfctl -o basic -f /tmp/rules.debug"); - conf_mount_ro(); -} - -?>
\ No newline at end of file diff --git a/config/filemgr/filemgr.xml b/config/filemgr/filemgr.xml index c2a7ac42..fdcf46d0 100644 --- a/config/filemgr/filemgr.xml +++ b/config/filemgr/filemgr.xml @@ -1,18 +1,32 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - <![CDATA[ +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* filemgr.xml - + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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 @@ -23,27 +37,24 @@ 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> +*/ +/* ====================================================================================== */ + ]]> + </copyright> <description>PHP File Manager</description> - <requirements>none</requirements> <faq>https://forum.pfsense.org/index.php/topic,26974.0.html</faq> <name>File Manager</name> - <version>0.1.4</version> - <title>Settings</title> - <include_file>/usr/local/pkg/filemgr.inc</include_file> + <version>0.2.0</version> + <title>Diagnostics: File Manager</title> <menu> <name>File Manager</name> - <tooltiptext>File Manager settings</tooltiptext> <section>Diagnostics</section> <configfile>filemgr.xml</configfile> <url>/packages/filemgr/file_manager.php</url> </menu> <tabs> <tab> - <text>Settings</text> + <text>File Manager</text> <url>/packages/filemgr/file_manager.php</url> <active/> </tab> @@ -51,190 +62,126 @@ <configpath>installedpackages->package->$packagename->configuration->filemgr</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/filemgr/filemgr.xml</item> </additional_files_needed> <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/filemgr.inc</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/file_manager.tmp</item> + <prefix>/usr/local/www/packages/filemgr/</prefix> + <item>https://packages.pfsense.org/packages/config/filemgr/file_manager.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/index.tmp</item> + <prefix>/usr/local/www/packages/filemgr/</prefix> + <item>https://packages.pfsense.org/packages/config/filemgr/index.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/bg_footer.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/bg_header.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/bg_page.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/file_editor_bg.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/folder.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/folder_go.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/folder_up.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/go.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_delete.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_download.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_file.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_html.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_open_as_web.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_php.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_picture.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_rename.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_script_edit.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_use_file.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/ico_use_file_inactive.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/index.html</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfmimg/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfmimg/new.png</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/config.tmp</item> + <prefix>/usr/local/www/packages/filemgr/rbfminc/</prefix> + <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/config.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/download.tmp</item> + <prefix>/usr/local/www/packages/filemgr/rbfminc/</prefix> + <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/download.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfminc/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/file_editor_style.css</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/functions.tmp</item> + <prefix>/usr/local/www/packages/filemgr/rbfminc/</prefix> + <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/functions.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/packages/filemgr/rbfminc/</prefix> <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/index.html</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/rename.tmp</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/session.tmp</item> - </additional_files_needed> - <fields> - <field> - <fielddescr>Variable One</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - <field> - <fielddescr>Variable Two</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - </fields> - <custom_add_php_command> - </custom_add_php_command> - <custom_php_resync_config_command> - php_sync_package_fm(); - </custom_php_resync_config_command> - <custom_delete_php_command> - php_sync_package_fm(); - </custom_delete_php_command> - <custom_php_install_command> - php_install_command_fm(); - </custom_php_install_command> - <custom_php_deinstall_command> - deinstall_command_fm(); - </custom_php_deinstall_command> -</packagegui>
\ No newline at end of file + <prefix>/usr/local/www/packages/filemgr/rbfminc/</prefix> + <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/rename.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/packages/filemgr/rbfminc/</prefix> + <item>https://packages.pfsense.org/packages/config/filemgr/rbfminc/session.php</item> + </additional_files_needed> +</packagegui> diff --git a/config/filemgr/index.php b/config/filemgr/index.php new file mode 100644 index 00000000..156ade3d --- /dev/null +++ b/config/filemgr/index.php @@ -0,0 +1,44 @@ +<?php +/* + index.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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. +*/ +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Redirect</title> + <script type="text/javascript"> + //<![CDATA[ + window.parent.location="../../index.php"; + //]]> + </script> +</head> +<body> +</body> +</html> diff --git a/config/filemgr/index.tmp b/config/filemgr/index.tmp deleted file mode 100644 index 47092a0c..00000000 --- a/config/filemgr/index.tmp +++ /dev/null @@ -1,11 +0,0 @@ -<html> -<head> -<SCRIPT type="text/javascript"> -//<![CDATA[ -window.parent.location="../../index.php"; -//]]> -</SCRIPT> -</head> - - -</html>
\ No newline at end of file diff --git a/config/filemgr/rbfminc/config.php b/config/filemgr/rbfminc/config.php new file mode 100644 index 00000000..776abf58 --- /dev/null +++ b/config/filemgr/rbfminc/config.php @@ -0,0 +1,123 @@ +<?php +/* + config.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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. +*/ +// Initial folder +$initial_folder = "/"; +// 0 = you can browse all files on the server; +// 1= you can browse only the $initial_folder and below +$only_below = 0; + +// Login info {Please change the initial username and password} +$username = 'admin'; +$password = 'admin'; + +/* ==================================== */ +/* BEGIN Protect against GLOBALS tricks */ +if (isset($_POST['GLOBALS']) || isset($_FILES['GLOBALS']) || isset($_GET['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { + die("Hacking attempt"); +} + +if (isset($_SESSION) && !is_array($_SESSION)) { + die("Hacking attempt"); +} + +if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on') { + $not_unset = array('_GET', '_POST', '_COOKIE', 'HTTP_SERVER_VARS', '_SESSION', 'HTTP_ENV_VARS', '_FILES'); + + if (!isset($_SESSION) || !is_array($_SESSION)) { + $_SESSION = array(); + } + $input = array_merge($_GET, $_POST, $_COOKIE, $HTTP_SERVER_VARS, $_SESSION, $HTTP_ENV_VARS, $_FILES); + + unset($input['input']); + unset($input['not_unset']); + + while (list($var,) = @each($input)) { + if (in_array($var, $not_unset)) { + die('Hacking attempt!'); + } + unset($$var); + } + + unset($input); +} + +if (!get_magic_quotes_gpc()) { + if (is_array($_GET)) { + while (list($k, $v) = each($_GET)) { + if (is_array($_GET[$k])) { + while (list($k2, $v2) = each($_GET[$k])) { + $_GET[$k][$k2] = addslashes($v2); + } + @reset($_GET[$k]); + } else { + $_GET[$k] = addslashes($v); + } + } + @reset($_GET); + } + + if (is_array($_POST)) { + while (list($k, $v) = each($_POST)) { + if (is_array($_POST[$k])) { + while (list($k2, $v2) = each($_POST[$k])) { + $_POST[$k][$k2] = addslashes($v2); + } + @reset($_POST[$k]); + } else { + $_POST[$k] = addslashes($v); + } + } + @reset($_POST); + } + + if (is_array($_COOKIE)) { + while (list($k, $v) = each($_COOKIE)) { + if (is_array($_COOKIE[$k])) { + while (list($k2, $v2) = each($_COOKIE[$k])) { + $_COOKIE[$k][$k2] = addslashes($v2); + } + @reset($_COOKIE[$k]); + } else { + $_COOKIE[$k] = addslashes($v); + } + } + @reset($_COOKIE); + } +} +/* END Protect against GLOBALS tricks */ +/* ==================================== */ + +/* +if ($username == 'admin' and $password == 'admin') { + $security_issues = "<div align=\"center\" style=\"color: red;\"><strong>Security issue</strong>: Please change your username or password</div>"; +} +*/ +$security_issues = "<br />"; +?> diff --git a/config/filemgr/rbfminc/config.tmp b/config/filemgr/rbfminc/config.tmp deleted file mode 100644 index 405514f8..00000000 --- a/config/filemgr/rbfminc/config.tmp +++ /dev/null @@ -1,95 +0,0 @@ -<?php - - -$initial_folder = "/"; //initial folder -$only_below = 0; // 0=you can brows all server; 1=you can brows only the $initial_folder and below - -//Login info {Please change the initial username and password} -$username = 'admin'; -$password = 'admin'; - - - -/***********************************/ -// Protect against GLOBALS tricks -if (isset($_POST['GLOBALS']) || isset($_FILES['GLOBALS']) || isset($_GET['GLOBALS']) || isset($_COOKIE['GLOBALS'])){ - die("Hacking attempt"); -} - -if (isset($_SESSION) && !is_array($_SESSION)){ - die("Hacking attempt"); -} - -if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on'){ - $not_unset = array('_GET', '_POST', '_COOKIE', 'HTTP_SERVER_VARS', '_SESSION', 'HTTP_ENV_VARS', '_FILES'); - - if (!isset($_SESSION) || !is_array($_SESSION)){ - $_SESSION = array(); - } - $input = array_merge($_GET, $_POST, $_COOKIE, $HTTP_SERVER_VARS, $_SESSION, $HTTP_ENV_VARS, $_FILES); - - unset($input['input']); - unset($input['not_unset']); - - while (list($var,) = @each($input)){ - if (in_array($var, $not_unset)){ - die('Hacking attempt!'); - } - unset($$var); - } - - unset($input); -} - -if( !get_magic_quotes_gpc() ){ - if( is_array($_GET) ){ - while( list($k, $v) = each($_GET) ){ - if( is_array($_GET[$k]) ) - { - while( list($k2, $v2) = each($_GET[$k]) ){ - $_GET[$k][$k2] = addslashes($v2); - } - @reset($_GET[$k]); - }else{ - $_GET[$k] = addslashes($v); - } - } - @reset($_GET); - } - - if( is_array($_POST) ){ - while( list($k, $v) = each($_POST) ){ - if( is_array($_POST[$k]) ) - { - while( list($k2, $v2) = each($_POST[$k]) ){ - $_POST[$k][$k2] = addslashes($v2); - } - @reset($_POST[$k]); - }else{ - $_POST[$k] = addslashes($v); - } - } - @reset($_POST); - } - - if( is_array($_COOKIE) ){ - while( list($k, $v) = each($_COOKIE) ){ - if( is_array($_COOKIE[$k]) ){ - while( list($k2, $v2) = each($_COOKIE[$k]) ){ - $_COOKIE[$k][$k2] = addslashes($v2); - } - @reset($_COOKIE[$k]); - }else{ - $_COOKIE[$k] = addslashes($v); - } - } - @reset($_COOKIE); - } -} -//END Protect against GLOBALS tricks -/***********************************/ -//if($username == 'admin' and $password == 'admin'){ - //$security_issues = "<div align=\"center\" style=\"color: red;\"><b>Security issue</b>: Please change your username or password</div>"; -//} -$security_issues = "<br />"; -?> diff --git a/config/filemgr/rbfminc/download.php b/config/filemgr/rbfminc/download.php new file mode 100644 index 00000000..88ff1788 --- /dev/null +++ b/config/filemgr/rbfminc/download.php @@ -0,0 +1,69 @@ +<?php +/* + download.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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. +*/ +include_once("auth.inc"); +include("functions.php"); + +// Set the cache policy +ob_end_clean(); +header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); +header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +// Gets the parameters +$_GET['file_name'] = urldecode($_GET['file_name']); +$_GET['p'] = urldecode($_GET['p']); + +// Check Authentication +$candownload = false; +$candownload = session_auth(); +if ($candownload) { + if (($_GET['file_name']) && ($_GET['p'])) { + $filepath = $_GET['p'].$_GET['file_name']; + if (file_exists($filepath)) { + $type = wp_check_filetype($_GET['file_name']); + header('Content-type: ' . $type[$_GET['file_name']]); + header('Content-Disposition: attachment; filename="'.$_GET['file_name'].'"'); + header('Content-Length: ' . filesize($filepath)); + header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($filepath)).' GMT', true, 200); + flush(); + readfile($filepath); + exit; + } else { + echo "File not found"; + } + } else { + echo "File Unknown"; + } +} else { + echo "Session Expired"; +} + +?> diff --git a/config/filemgr/rbfminc/download.tmp b/config/filemgr/rbfminc/download.tmp deleted file mode 100644 index badc6d19..00000000 --- a/config/filemgr/rbfminc/download.tmp +++ /dev/null @@ -1,49 +0,0 @@ -<?php -include_once("auth.inc"); -include "functions.php"; -//Set the cache policy -ob_end_clean(); -header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -//Gets the parameters -$_GET['file_name'] = urldecode($_GET['file_name']); -$_GET['p'] = urldecode($_GET['p']); -//Check Authentication -$candownload = false; -if (function_exists("session_auth")) - {//pfSense 2.X - $candownload = session_auth();} -else - {//pfSense 1.2.3 - $candownload = htpasswd_backed_basic_auth();} -if ($candownload) -{ - if($_GET['file_name'] and $_GET['p']){ - $filepath = $_GET['p'].$_GET['file_name']; - if(file_exists($filepath)){ - $type = wp_check_filetype($_GET['file_name']); - header('Content-type: ' . $type[$_GET['file_name']]); - header('Content-Disposition: attachment; filename="'.$_GET['file_name'].'"'); - header('Content-Length: ' . filesize($filepath)); - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($filepath)).' GMT', true, 200); - flush(); - readfile($filepath); - exit; - } - else - { - echo("File not found"); - } - } - else - { - echo("File Unknown"); - } -} -else -{ - echo("Session Expired"); -} -?>
\ No newline at end of file diff --git a/config/filemgr/rbfminc/functions.php b/config/filemgr/rbfminc/functions.php new file mode 100644 index 00000000..bab912a7 --- /dev/null +++ b/config/filemgr/rbfminc/functions.php @@ -0,0 +1,221 @@ +<?php +/* + functions.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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. +*/ +function RecursiveFolderDelete($folderPath) { + if (is_dir($folderPath )) { + foreach (scandir($folderPath) as $value) { + if ($value != "." && $value != "..") { + $value = $folderPath . "/" . $value; + if (is_dir($value)) { + RecursiveFolderDelete($value); + } elseif (is_file($value)) { + @unlink($value); + } + } + } + if (!@rmdir($folderPath)) { + return FALSE; + } else { + return TRUE; + } + } else { + return FALSE; + } +} + + +function GetFilePerms($file) { + $perms = fileperms($file); + + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = '?'; + } + + // Owner + $info .= " " . (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-')); + // Group + $info .= " " . (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-')); + // World + $info .= " ".(($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')); + + $info = "[" . substr(sprintf('%o', fileperms($file)), -4) . "] " . $info; + return $info; +} + + +function merge_filters($tag) { + global $wp_filter, $merged_filters; + + if (isset($wp_filter['all']) && is_array($wp_filter['all'])) { + $wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]); + } + + if (isset($wp_filter[$tag])) { + reset($wp_filter[$tag]); + uksort($wp_filter[$tag], "strnatcasecmp"); + } + $merged_filters[$tag] = true; +} + + +function apply_filters($tag, $string) { + global $wp_filter, $merged_filters; + + if (!isset($merged_filters[$tag])) { + merge_filters($tag); + } + + if (!isset($wp_filter[$tag])) { + return $string; + } + + reset($wp_filter[$tag]); + + $args = func_get_args(); + + do { + foreach ((array)current($wp_filter[$tag]) as $the_) { + if (!is_null($the_['function'])) { + $args[1] = $string; + $string = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); + } + } + + } while (next($wp_filter[$tag]) !== false); + + return $string; +} + + +function wp_check_filetype($filename, $mimes = null) { + // Accepted MIME types are set here as PCRE unless provided. + $mimes = is_array($mimes) ? $mimes : apply_filters('upload_mimes', array( + 'jpg|jpeg|jpe' => 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'bmp' => 'image/bmp', + 'tif|tiff' => 'image/tiff', + 'ico' => 'image/x-icon', + 'asf|asx|wax|wmv|wmx' => 'video/asf', + 'avi' => 'video/avi', + 'mov|qt' => 'video/quicktime', + 'mpeg|mpg|mpe' => 'video/mpeg', + 'txt|c|cc|h' => 'text/plain', + 'rtx' => 'text/richtext', + 'css' => 'text/css', + 'htm|html' => 'text/html', + 'php|php3|' => 'application/php', + 'mp3|mp4' => 'audio/mpeg', + 'ra|ram' => 'audio/x-realaudio', + 'wav' => 'audio/wav', + 'ogg' => 'audio/ogg', + 'mid|midi' => 'audio/midi', + 'wma' => 'audio/wma', + 'rtf' => 'application/rtf', + 'js' => 'application/javascript', + 'pdf' => 'application/pdf', + 'doc' => 'application/msword', + 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', + 'wri' => 'application/vnd.ms-write', + 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', + 'mdb' => 'application/vnd.ms-access', + 'mpp' => 'application/vnd.ms-project', + 'swf' => 'application/x-shockwave-flash', + 'class' => 'application/java', + 'tar' => 'application/x-tar', + 'zip' => 'application/zip', + 'gz|gzip' => 'application/x-gzip', + 'exe' => 'application/x-msdownload', + // openoffice formats + 'odt' => 'application/vnd.oasis.opendocument.text', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odf' => 'application/vnd.oasis.opendocument.formula', + + )); + + $type = false; + $ext = false; + + foreach ($mimes as $ext_preg => $mime_match) { + $ext_preg = '!\.(' . $ext_preg . ')$!i'; + if (preg_match($ext_preg, $filename, $ext_matches)) { + $type = $mime_match; + $ext = $ext_matches[1]; + break; + } + } + + return compact('ext', 'type'); +} + + + +function roundsize($size) { + $i=0; + $iec = array("B", "Kb", "Mb", "Gb", "Tb"); + while (($size/1024)>1) { + $size=$size/1024; + $i++; + } + return(round($size, 1) . " " . $iec[$i]); +} + +?> diff --git a/config/filemgr/rbfminc/functions.tmp b/config/filemgr/rbfminc/functions.tmp deleted file mode 100644 index f06ee69c..00000000 --- a/config/filemgr/rbfminc/functions.tmp +++ /dev/null @@ -1,189 +0,0 @@ -<?php -function RecursiveFolderDelete ( $folderPath ) -{ - if ( is_dir ( $folderPath ) ) - { - foreach ( scandir ( $folderPath ) as $value ) - { - if ( $value != "." && $value != ".." ) - { - $value = $folderPath . "/" . $value; - if ( is_dir ( $value ) ) - { - RecursiveFolderDelete ( $value ); - } - elseif ( is_file ( $value ) ) - { - @unlink ( $value ); - } - } - } - if(!@rmdir ( $folderPath )){ - return FALSE; - }else{ - return TRUE; - } - } - else - { - return FALSE; - } -} - - - -function GetFilePerms($file) { - $perms = fileperms($file); - if (($perms & 0xC000) == 0xC000) {$info = 's'; } // Socket - elseif (($perms & 0xA000) == 0xA000) {$info = 'l'; } // Symbolic Link - elseif (($perms & 0x8000) == 0x8000) {$info = '-'; } // Regular - elseif (($perms & 0x6000) == 0x6000) {$info = 'b'; } // Block special - elseif (($perms & 0x4000) == 0x4000) {$info = 'd'; } // Directory - elseif (($perms & 0x2000) == 0x2000) {$info = 'c'; } // Character special - elseif (($perms & 0x1000) == 0x1000) {$info = 'p'; } // FIFO pipe - else {$info = '?';} // Unknown - // Owner - $info .= " ".(($perms & 0x0100) ? 'r' : '-'); - $info .= (($perms & 0x0080) ? 'w' : '-'); - $info .= (($perms & 0x0040) ? - (($perms & 0x0800) ? 's' : 'x' ) : - (($perms & 0x0800) ? 'S' : '-')); - // Group - $info .= " ".(($perms & 0x0020) ? 'r' : '-'); - $info .= (($perms & 0x0010) ? 'w' : '-'); - $info .= (($perms & 0x0008) ? - (($perms & 0x0400) ? 's' : 'x' ) : - (($perms & 0x0400) ? 'S' : '-')); - // World - $info .= " ".(($perms & 0x0004) ? 'r' : '-'); - $info .= (($perms & 0x0002) ? 'w' : '-'); - $info .= (($perms & 0x0001) ? - (($perms & 0x0200) ? 't' : 'x' ) : - (($perms & 0x0200) ? 'T' : '-')); - - $info = "[".substr(sprintf('%o', fileperms($file)), -4)."] ".$info; - - return $info; -} - - - -function merge_filters($tag) { - global $wp_filter, $merged_filters; - - if ( isset($wp_filter['all']) && is_array($wp_filter['all']) ) - $wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]); - - if ( isset($wp_filter[$tag]) ){ - reset($wp_filter[$tag]); - uksort($wp_filter[$tag], "strnatcasecmp"); - } - $merged_filters[ $tag ] = true; -} - - - -function apply_filters($tag, $string) { - global $wp_filter, $merged_filters; - - if ( !isset( $merged_filters[ $tag ] ) ) - merge_filters($tag); - - if ( !isset($wp_filter[$tag]) ) - return $string; - - reset( $wp_filter[ $tag ] ); - - $args = func_get_args(); - - do{ - foreach( (array) current($wp_filter[$tag]) as $the_ ) - if ( !is_null($the_['function']) ){ - $args[1] = $string; - $string = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); - } - - } while ( next($wp_filter[$tag]) !== false ); - - return $string; -} - - - -function wp_check_filetype($filename, $mimes = null) { - // Accepted MIME types are set here as PCRE unless provided. - $mimes = is_array($mimes) ? $mimes : apply_filters('upload_mimes', array ( - 'jpg|jpeg|jpe' => 'image/jpeg', - 'gif' => 'image/gif', - 'png' => 'image/png', - 'bmp' => 'image/bmp', - 'tif|tiff' => 'image/tiff', - 'ico' => 'image/x-icon', - 'asf|asx|wax|wmv|wmx' => 'video/asf', - 'avi' => 'video/avi', - 'mov|qt' => 'video/quicktime', - 'mpeg|mpg|mpe' => 'video/mpeg', - 'txt|c|cc|h' => 'text/plain', - 'rtx' => 'text/richtext', - 'css' => 'text/css', - 'htm|html' => 'text/html', - 'php|php3|' => 'application/php', - 'mp3|mp4' => 'audio/mpeg', - 'ra|ram' => 'audio/x-realaudio', - 'wav' => 'audio/wav', - 'ogg' => 'audio/ogg', - 'mid|midi' => 'audio/midi', - 'wma' => 'audio/wma', - 'rtf' => 'application/rtf', - 'js' => 'application/javascript', - 'pdf' => 'application/pdf', - 'doc' => 'application/msword', - 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', - 'wri' => 'application/vnd.ms-write', - 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', - 'mdb' => 'application/vnd.ms-access', - 'mpp' => 'application/vnd.ms-project', - 'swf' => 'application/x-shockwave-flash', - 'class' => 'application/java', - 'tar' => 'application/x-tar', - 'zip' => 'application/zip', - 'gz|gzip' => 'application/x-gzip', - 'exe' => 'application/x-msdownload', - // openoffice formats - 'odt' => 'application/vnd.oasis.opendocument.text', - 'odp' => 'application/vnd.oasis.opendocument.presentation', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'odg' => 'application/vnd.oasis.opendocument.graphics', - 'odc' => 'application/vnd.oasis.opendocument.chart', - 'odb' => 'application/vnd.oasis.opendocument.database', - 'odf' => 'application/vnd.oasis.opendocument.formula', - - )); - - $type = false; - $ext = false; - - foreach ($mimes as $ext_preg => $mime_match) { - $ext_preg = '!\.(' . $ext_preg . ')$!i'; - if ( preg_match($ext_preg, $filename, $ext_matches) ) { - $type = $mime_match; - $ext = $ext_matches[1]; - break; - } - } - - return compact('ext', 'type'); -} - - - -function roundsize($size){ - $i=0; - $iec = array("B", "Kb", "Mb", "Gb", "Tb"); - while (($size/1024)>1) { - $size=$size/1024; - $i++;} - return(round($size,1)." ".$iec[$i]); -} - -?>
\ No newline at end of file diff --git a/config/filemgr/rbfminc/rename.php b/config/filemgr/rbfminc/rename.php new file mode 100644 index 00000000..27553f18 --- /dev/null +++ b/config/filemgr/rbfminc/rename.php @@ -0,0 +1,68 @@ +<?php +/* + rename.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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. +*/ +include("config.php"); +include("session.php"); + +if ($user_login == 'ok') { + include("functions.php"); +?> + +<html> +<head> +<title>Rename</title> +</head> +<body> +<script type="text/javascript"> +//<![CDATA[ +<?php +if ($_POST['o'] != $_POST['n']) { + if (@rename($_POST['cf'].$_POST['o'], $_POST['cf'].$_POST['n'])) { + if ($_POST['t'] == 'd') { + echo "alert('Directory successfuly renamed from \"{$_POST['o']}\" to \"{$_POST['n']}\"');"; + } else { + echo "alert('File successfuly renamed from \"{$_POST['o']}\" to \"{$_POST['n']}\"');"; + } + } else { + echo <<<EOD + alert('Rename error'); + window.parent.location.href = window.parent.location.href; +EOD; + } +} + +?> +//]]> +</script> +</body> +</html> + +<?php +} +?> diff --git a/config/filemgr/rbfminc/rename.tmp b/config/filemgr/rbfminc/rename.tmp deleted file mode 100644 index 266e38d4..00000000 --- a/config/filemgr/rbfminc/rename.tmp +++ /dev/null @@ -1,41 +0,0 @@ -<?php -include "config.php"; -include "session.php"; - -if($user_login == 'ok'){ - - include "functions.php"; - -?> -<html> -<head> -<title>Rename</title> -</head> -<body> -<script type="text/javascript"> -//<![CDATA[ -<?php -//print_r($_POST); -if($_POST['o'] != $_POST['n']){ - if(@rename($_POST['cf'].$_POST['o'], $_POST['cf'].$_POST['n'])){ - if($_POST['t'] == 'd'){ - echo "alert('Directory successfuly renamed from \"{$_POST['o']}\" to \"{$_POST['n']}\"');"; - }else{ - echo "alert('File successfuly renamed from \"{$_POST['o']}\" to \"{$_POST['n']}\"');"; - } - }else{ - echo " - alert('Rename error'); - window.parent.location.href = window.parent.location.href; - "; - } -} - -?> -//]]> -</script> -</body> -</html> -<?php -} -?>
\ No newline at end of file diff --git a/config/filemgr/rbfminc/session.php b/config/filemgr/rbfminc/session.php new file mode 100644 index 00000000..b616643f --- /dev/null +++ b/config/filemgr/rbfminc/session.php @@ -0,0 +1,58 @@ +<?php +/* + session.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Tom Schaefer <tom@tomschaefer.org> + 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. +*/ +session_name("file_manager_session"); + +// Create session +session_start(); +if (($_POST['login'] == 'login') && ($_POST['username']) && ($_POST['password'])) { + $_SESSION = array(); + $_SESSION['username'] = $_POST['username']; + $_SESSION['password'] = $_POST['password']; +} + +if ($_GET['logout'] == "logout") { + setcookie('url_field', '', time()-3600); + setcookie('current_folder', '', time()-3600); + $_SESSION = array(); + session_destroy(); + session_unset(); + header("Location: file_manager.php"); +} + + +if (($_SESSION['username']) && ($_SESSION['password'])) { + if (($_SESSION['username'] == $username) && ($_SESSION['password'] == $password)) { + $user_login = 'ok'; + } else { + $error_message = "Incorrect username or password!"; + } +} + +?> diff --git a/config/filemgr/rbfminc/session.tmp b/config/filemgr/rbfminc/session.tmp deleted file mode 100644 index 7cfc133d..00000000 --- a/config/filemgr/rbfminc/session.tmp +++ /dev/null @@ -1,32 +0,0 @@ -<?php -session_name("file_manager_session"); - -session_start(); - -/*************************************************************************************************/ -//create session -if($_POST['login'] == 'login' and $_POST['username'] and $_POST['password']){ - $_SESSION = array(); - $_SESSION['username']=$_POST['username']; - $_SESSION['password']=$_POST['password']; -} - -if($_GET['logout'] == "logout"){ - setcookie('url_field', '', time()-3600); - setcookie('current_folder', '', time()-3600); - $_SESSION = array(); - session_destroy(); - session_unset(); - header("Location: file_manager.php"); -} - - -if($_SESSION['username'] and $_SESSION['password']){ - if($_SESSION['username'] == $username and $_SESSION['password'] == $password){ - $user_login = 'ok'; - }else{ - $error_message = "Incorect username or password!"; - } -} - -?> diff --git a/config/ftpproxy/ftpproxy.inc b/config/ftpproxy/ftpproxy.inc index ece580c2..386a1d84 100644 --- a/config/ftpproxy/ftpproxy.inc +++ b/config/ftpproxy/ftpproxy.inc @@ -31,7 +31,6 @@ */ function sync_package_ftpproxy() { conf_mount_rw(); - config_lock(); global $config; $cf = $config['installedpackages']['ftpclientproxy']['config'][0]; @@ -85,7 +84,6 @@ function sync_package_ftpproxy() { ); restart_service("ftp-proxy"); conf_mount_ro(); - config_unlock(); filter_configure(); } diff --git a/config/haproxy-devel/haproxy.xml b/config/haproxy-devel/haproxy.xml index e057bfb2..386e43a7 100644 --- a/config/haproxy-devel/haproxy.xml +++ b/config/haproxy-devel/haproxy.xml @@ -3,46 +3,46 @@ <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - <![CDATA[ + <![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - haproxy.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2009 Scott Ullrich - All rights reserved. - */ -/* ========================================================================== */ + haproxy.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Scott Ullrich + 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: + 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. + 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> <name>haproxy</name> - <version>1.0</version> + <version>0.28</version> <title>HAProxy</title> <aftersaveredirect>/pkg_edit.php?xml=haproxy_pools.php</aftersaveredirect> <include_file>/usr/local/pkg/haproxy.inc</include_file> @@ -75,72 +75,58 @@ <configpath>installedpackages->haproxy->config</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_listeners.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_listeners_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_global.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_files.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_pools.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_pool_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_stats.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/haproxy_templates.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_socketinfo.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_xmlrpcsyncclient.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_htmllist.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_utils.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/widgets/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php</item> </additional_files_needed> <additional_files_needed> @@ -150,31 +136,20 @@ </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/pkg_haproxy_tabs.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_upgrade_config.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/javascript/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy-devel/www/javascript/haproxy_geturl.js</item> </additional_files_needed> - <custom_delete_php_command> - </custom_delete_php_command> - <custom_add_php_command> - </custom_add_php_command> - <custom_php_resync_config_command> - </custom_php_resync_config_command> <custom_php_install_command> haproxy_custom_php_install_command(); </custom_php_install_command> <custom_php_deinstall_command> haproxy_custom_php_deinstall_command(); </custom_php_deinstall_command> - <custom_php_command_before_form> - </custom_php_command_before_form> </packagegui> diff --git a/config/haproxy-legacy/haproxy_frontends.php b/config/haproxy-legacy/haproxy_frontends.php index 1aef0b8f..6fdb97ff 100755 --- a/config/haproxy-legacy/haproxy_frontends.php +++ b/config/haproxy-legacy/haproxy_frontends.php @@ -45,9 +45,7 @@ if ($_POST) { if ($_POST['apply']) { $retval = 0; - config_lock(); $retval = haproxy_configure(); - config_unlock(); $savemsg = get_std_save_message($retval); unlink_if_exists($d_haproxyconfdirty_path); } diff --git a/config/haproxy-legacy/haproxy_global.php b/config/haproxy-legacy/haproxy_global.php index 4ea03c75..59d26503 100755 --- a/config/haproxy-legacy/haproxy_global.php +++ b/config/haproxy-legacy/haproxy_global.php @@ -46,9 +46,7 @@ if ($_POST) { if ($_POST['apply']) { $retval = 0; - config_lock(); $retval = haproxy_configure(); - config_unlock(); $savemsg = get_std_save_message($retval); unlink_if_exists($d_haproxyconfdirty_path); } else { diff --git a/config/haproxy-legacy/haproxy_servers.php b/config/haproxy-legacy/haproxy_servers.php index e04ed74c..8a385ed1 100755 --- a/config/haproxy-legacy/haproxy_servers.php +++ b/config/haproxy-legacy/haproxy_servers.php @@ -46,9 +46,7 @@ if ($_POST) { if ($_POST['apply']) { $retval = 0; - config_lock(); $retval = haproxy_configure(); - config_unlock(); $savemsg = get_std_save_message($retval); unlink_if_exists($d_haproxyconfdirty_path); } diff --git a/config/haproxy/haproxy_global.php b/config/haproxy/haproxy_global.php index 40b5cd90..5ea4010c 100755 --- a/config/haproxy/haproxy_global.php +++ b/config/haproxy/haproxy_global.php @@ -45,9 +45,7 @@ if ($_POST) { if ($_POST['apply']) { $retval = 0; - config_lock(); $retval = haproxy_configure(); - config_unlock(); $savemsg = get_std_save_message($retval); unlink_if_exists($d_haproxyconfdirty_path); } else { diff --git a/config/haproxy/haproxy_listeners.php b/config/haproxy/haproxy_listeners.php index a5bc9a22..adc0178c 100755 --- a/config/haproxy/haproxy_listeners.php +++ b/config/haproxy/haproxy_listeners.php @@ -45,9 +45,7 @@ if ($_POST) { if ($_POST['apply']) { $retval = 0; - config_lock(); $retval = haproxy_configure(); - config_unlock(); $savemsg = get_std_save_message($retval); unlink_if_exists($d_haproxyconfdirty_path); } diff --git a/config/haproxy/haproxy_pools.php b/config/haproxy/haproxy_pools.php index a0bf75a2..aed3c3e6 100755 --- a/config/haproxy/haproxy_pools.php +++ b/config/haproxy/haproxy_pools.php @@ -49,9 +49,7 @@ if ($_POST) { if ($_POST['apply']) { $retval = 0; - config_lock(); $retval = haproxy_configure(); - config_unlock(); $savemsg = get_std_save_message($retval); unlink_if_exists($d_haproxyconfdirty_path); } diff --git a/config/haproxy1_5/haproxy.xml b/config/haproxy1_5/haproxy.xml index 7468b211..c59b2592 100644 --- a/config/haproxy1_5/haproxy.xml +++ b/config/haproxy1_5/haproxy.xml @@ -2,47 +2,47 @@ <!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> + <![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - haproxy.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2009 Scott Ullrich - All rights reserved. - */ -/* ========================================================================== */ + haproxy.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Scott Ullrich + 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: + 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. + 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> <name>haproxy</name> - <version>1.0</version> + <version>0.28</version> <title>HAProxy</title> <aftersaveredirect>/pkg_edit.php?xml=haproxy_pools.php</aftersaveredirect> <include_file>/usr/local/pkg/haproxy.inc</include_file> @@ -75,72 +75,58 @@ <configpath>installedpackages->haproxy->config</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/pkg/haproxy.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_listeners.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_listeners_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_global.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_files.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_pools.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_pool_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_stats.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/haproxy_templates.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/pkg/haproxy_socketinfo.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/pkg/haproxy_xmlrpcsyncclient.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/pkg/haproxy_htmllist.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/pkg/haproxy_utils.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/widgets/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/widgets/widgets/haproxy.widget.php</item> </additional_files_needed> <additional_files_needed> @@ -150,31 +136,20 @@ </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/pkg/pkg_haproxy_tabs.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/pkg/haproxy_upgrade_config.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/javascript/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/haproxy1_5/www/javascript/haproxy_geturl.js</item> </additional_files_needed> - <custom_delete_php_command> - </custom_delete_php_command> - <custom_add_php_command> - </custom_add_php_command> - <custom_php_resync_config_command> - </custom_php_resync_config_command> <custom_php_install_command> haproxy_custom_php_install_command(); </custom_php_install_command> <custom_php_deinstall_command> haproxy_custom_php_deinstall_command(); </custom_php_deinstall_command> - <custom_php_command_before_form> - </custom_php_command_before_form> </packagegui> diff --git a/config/imspector/imspector.inc b/config/imspector/imspector.inc index 7853e627..bc5a939c 100644 --- a/config/imspector/imspector.inc +++ b/config/imspector/imspector.inc @@ -177,8 +177,7 @@ /*continue sync process*/ log_error("Imspector: Saving changes."); - config_lock(); - + /* remove existing rules */ exec('/sbin/pfctl -a imspector -Fr > /dev/null'); exec('/sbin/pfctl -a imspector -Fn > /dev/null'); @@ -408,8 +407,7 @@ EOD; imspector_action('restart'); } } - config_unlock(); - + /*check xmlrpc sync*/ imspector_sync_on_changes(); } diff --git a/config/ladvd/ladvd.inc b/config/ladvd/ladvd.inc index acf277b3..da37a1a9 100644 --- a/config/ladvd/ladvd.inc +++ b/config/ladvd/ladvd.inc @@ -1,7 +1,10 @@ <?php /* ladvd.inc - Copyright (C) 2006 Scott Ullrich + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2014 Andrea Tuccia + Copyright (C) 2014 Ermal Luçi + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -25,7 +28,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require_once("globals.inc"); require_once("util.inc"); require_once("functions.inc"); @@ -50,39 +52,39 @@ function ladvd_resync_config() { $cmdline = ""; if (!empty($ladvd_conf['autoenable'])) { - $cmdline .= "-a "; + $cmdline .= "-a "; } if (!empty($ladvd_conf['silent'])) { - $cmdline .= "-s "; + $cmdline .= "-s "; } if (!empty($ladvd_conf['management'])) { - $cmdline .= "-m " . escapeshellarg(get_real_interface($ladvd_conf['management'])) . " "; + $cmdline .= "-m " . escapeshellarg(get_real_interface($ladvd_conf['management'])) . " "; } if (!empty($ladvd_conf['location'])) { - $cmdline .= "-l '{$ladvd_conf['location']}' "; + $cmdline .= "-l '{$ladvd_conf['location']}' "; } if (!empty($ladvd_conf['lldp'])) { - $cmdline .= "-L "; + $cmdline .= "-L "; } if (!empty($ladvd_conf['cdp'])) { - $cmdline .= "-C "; + $cmdline .= "-C "; } if (!empty($ladvd_conf['edp'])) { - $cmdline .= "-E "; + $cmdline .= "-E "; } if (!empty($ladvd_conf['fdp'])) { - $cmdline .= "-F "; + $cmdline .= "-F "; } if (!empty($ladvd_conf['ndp'])) { - $cmdline .= "-N "; + $cmdline .= "-N "; } $ifaces = explode(",", $ladvd_conf['iface_array']); @@ -91,7 +93,7 @@ function ladvd_resync_config() { write_rcfile(array( "file" => "ladvd.sh", - "start" => "/usr/local/sbin/ladvd $cmdline", + "start" => "/usr/local/sbin/ladvd {$cmdline}", "stop" => "/usr/bin/killall -9 ladvd" ) ); diff --git a/config/ladvd/ladvd.xml b/config/ladvd/ladvd.xml index 0367a19a..5862afca 100644 --- a/config/ladvd/ladvd.xml +++ b/config/ladvd/ladvd.xml @@ -1,15 +1,25 @@ <?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[ +<![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ /* ladvd.xml - Copyright (C) 2006 Scott Ullrich + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2014 Andrea Tuccia + Copyright (C) 2014 Ermal Luçi + 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. @@ -17,6 +27,7 @@ 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 @@ -28,11 +39,12 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* ====================================================================================== */ ]]> </copyright> <description>Link Layer Discovery Protocol</description> <name>LADVD</name> - <version>1.0.2</version> + <version>1.0.4.2</version> <category>Network Management</category> <title>Services: LADVD</title> <savetext>Save</savetext> @@ -41,13 +53,11 @@ <additional_files_needed> <item>https://packages.pfsense.org/packages/config/ladvd/ladvd.inc</item> <prefix>/usr/local/pkg/</prefix> - <chmod>0644</chmod> </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/www/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/ladvd/status_ladvd.php</item> - </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <item>https://packages.pfsense.org/packages/config/ladvd/status_ladvd.php</item> + </additional_files_needed> <menu> <name>LADVD</name> <tooltiptext>Modify LADVD settings.</tooltiptext> @@ -59,12 +69,12 @@ <tooltiptext></tooltiptext> <section>Status</section> <url>/status_ladvd.php</url> - </menu> + </menu> <service> <name>ladvd</name> <rcfile>ladvd.sh</rcfile> <executable>ladvd</executable> - <description>Send and decode link layer advertisements</description> + <description>Send and decode link layer advertisements.</description> </service> <tabs> <tab> @@ -81,7 +91,7 @@ <field> <fielddescr>Enable ladvd</fielddescr> <fieldname>enable</fieldname> - <description>Enable or disable ladvd</description> + <description>Enable or disable ladvd.</description> <enablefields>iface_array[],autoenable,silent,management,location,lldp,cdp,edp,ndp</enablefields> <type>checkbox</type> </field> @@ -92,7 +102,7 @@ <multiple>true</multiple> <size>3</size> <type>interfaces_selection</type> - <description>Select the interfaces that LADVD will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description> + <description>Select the interfaces that LADVD will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description> </field> <field> <fielddescr>Auto-enable protocols</fielddescr> diff --git a/config/ladvd/status_ladvd.php b/config/ladvd/status_ladvd.php index 3333145a..86e7187c 100644 --- a/config/ladvd/status_ladvd.php +++ b/config/ladvd/status_ladvd.php @@ -1,7 +1,10 @@ <?php /* status_ladvd.php - Copyright (C) 2006 Scott Ullrich + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2014 Andrea Tuccia + Copyright (C) 2014 Ermal Luçi + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -15,7 +18,7 @@ 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 + 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 @@ -25,7 +28,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); $pgtitle = "LADVD: Status"; @@ -37,9 +39,9 @@ $control_script = "/usr/local/sbin/ladvdc"; function listCmds() { global $commands; echo "<br/>This status page includes the following information:\n"; - echo "<ul width=\"100%\">\n"; + echo "<ul>\n"; for ($i = 0; isset($commands[$i]); $i++ ) { - echo "<li><strong><a href=\"#" . $commands[$i][0] . "\">" . $commands[$i][0] . "</a></strong></li>\n"; + echo "<li><strong><a href=\"#" . str_replace(' ', '_', $commands[$i][0]) . "\">" . $commands[$i][0] . "</a></strong></li>\n"; } echo "</ul>\n"; } @@ -59,11 +61,12 @@ function defCmdT($title, $command) { } function doCmdT($title, $command) { - echo "<p>\n"; - echo "<a name=\"" . $title . "\">\n"; + echo "<div>\n"; + echo "<a name=\"" . str_replace(' ', '_', $title) . "\" />\n"; echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"; echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n"; - echo "<tr><td class=\"listlr\"><pre>"; /* no newline after pre */ + /* no newline after pre */ + echo "<tr><td class=\"listlr\"><pre>"; $execOutput = ""; $execStatus = ""; @@ -72,47 +75,43 @@ function doCmdT($title, $command) { echo htmlspecialchars($line, ENT_NOQUOTES); } pclose($fd); - echo "</pre></tr>\n"; + echo "</pre></td></tr>\n"; echo "</table>\n"; + echo "</div>\n"; } ?> -<html> - <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> - <?php include("fbegin.inc"); ?> - <?php if ($savemsg) print_info_box($savemsg); ?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> - <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr><td class="tabnavtbl"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td class="tabnavtbl"> <?php - $tab_array = array(); - $tab_array[] = array(gettext("General"), false, "/pkg_edit.php?xml=ladvd.xml&id=0"); - $tab_array[] = array(gettext("Status"), true, "/status_ladvd.php"); - display_top_tabs($tab_array); - ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> - <tr> - <td> + $tab_array = array(); + $tab_array[] = array(gettext("General"), false, "/pkg_edit.php?xml=ladvd.xml&id=0"); + $tab_array[] = array(gettext("Status"), true, "/status_ladvd.php"); + display_top_tabs($tab_array); +?> + </td></tr> + <tr><td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr><td> <?php - defCmdT("LADVD Devices", "{$control_script}"); - defCmdT("LADVD Detailed decode", "{$control_script} -f"); + defCmdT("LADVD Devices", "{$control_script}"); + defCmdT("LADVD Detailed decode", "{$control_script} -f"); ?> - <div id="cmdspace" style="width:100%"> - <?php listCmds(); ?> - <?php execCmds(); ?> - </div> - </td> - </tr> - </table> - </div> - </td> - </tr> + <div id="cmdspace" style="width:100%"> + <?php listCmds(); ?> + <?php execCmds(); ?> + </div> + </td></tr> </table> - <?php include("fend.inc"); ?> - </body> + </div> + </td></tr> +</table> +<?php include("fend.inc"); ?> +</body> </html> diff --git a/config/lcdproc-dev/lcdproc.inc b/config/lcdproc-dev/lcdproc.inc index ebe3cc57..e9656afd 100644 --- a/config/lcdproc-dev/lcdproc.inc +++ b/config/lcdproc-dev/lcdproc.inc @@ -1,321 +1,318 @@ <?php -/* $Id$ */ /* - lcdproc.inc - Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>, - Copyright (C) 2012 Michele Di Maria <michele@nt2.it> - All rights reserved. + lcdproc.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2012 Michele Di Maria + 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: + 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. + 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. + 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. + 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. */ - require_once("config.inc"); - require_once("functions.inc"); - require_once("service-utils.inc"); - /* LCDproc */ - define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); - $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); - if ($pfs_version == "2.1" || $pfs_version == "2.2") { - define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf'); - } else { - define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); - } - define('LCDPROC_HOST','localhost'); - define('LCDPROC_PORT','13666'); - define('LCDPROC_SERVICE_NAME','lcdproc'); - /* Functions */ - function lcdproc_notice ($msg) { syslog(LOG_NOTICE, "lcdproc: {$msg}"); } - function lcdproc_warn ($msg) { syslog(LOG_WARNING, "lcdproc: {$msg}"); } - function lcdproc_write_config($file, $text) { - $handle = fopen($file, 'w'); - if(!$handle) { - lcdproc_warn("Could not open {$file} for writing."); - exit; - } - fwrite($handle, $text); - fclose($handle); - } - function lcdproc_write_script($file, $text) { - $handle = fopen($file, 'wx'); - if(!$handle) { - lcdproc_warn("Could not open {$file} for writing."); - exit; - } - fwrite($handle, $text); - fclose($handle); - chmod($file, 0755); - } - function before_form_lcdproc(&$pkg) { - global $config; - config_lock(); - config_unlock(); +require_once("config.inc"); +require_once("functions.inc"); +require_once("service-utils.inc"); + +/* LCDproc */ +define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); +$pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pfs_version == "2.1" || $pfs_version == "2.2") { + define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf'); +} else { + define('LCDPROC_CONFIG', '/usr/local/etc/LCDd.conf'); +} +define('LCDPROC_HOST', '127.0.0.1'); +define('LCDPROC_PORT', '13666'); +define('LCDPROC_SERVICE_NAME', 'lcdproc'); + +/* Functions */ +function lcdproc_notice($msg) { + syslog(LOG_NOTICE, "lcdproc: {$msg}"); +} + +function lcdproc_warn($msg) { + syslog(LOG_WARNING, "lcdproc: {$msg}"); +} + +function lcdproc_write_config($file, $text) { + $handle = fopen($file, 'w'); + if (!$handle) { + lcdproc_warn("Could not open {$file} for writing."); + exit; } - function before_form_lcdproc_screens(&$pkg) { - global $config; - config_lock(); - config_unlock(); + fwrite($handle, $text); + fclose($handle); +} + +function lcdproc_write_script($file, $text) { + $handle = fopen($file, 'wx'); + if (!$handle) { + lcdproc_warn("Could not open {$file} for writing."); + exit; } - function validate_form_lcdproc($post, &$input_errors) { - if($post['comport']) { - switch($post['comport']) { - case "none": - case "com1": - case "com2": - case "com1a": - case "com2a": - case "ucom1": - case "ucom2": - case "lpt1": - case "ugen0.2": - case "ugen1.2": - case "ugen1.3"; - case "ugen2.2": - continue; - break; - default: - $input_errors[] = "The chosen com port is not valid"; - break; + fwrite($handle, $text); + fclose($handle); + chmod($file, 0755); +} + +function validate_form_lcdproc($post, &$input_errors) { + if ($post['comport']) { + switch($post['comport']) { + case "none": + case "com1": + case "com2": + case "com1a": + case "com2a": + case "ucom1": + case "ucom2": + case "lpt1": + case "ugen0.2": + case "ugen1.2": + case "ugen1.3"; + case "ugen2.2": + continue; + break; + default: + $input_errors[] = "The chosen COM port is not valid"; + break; } } - if($post['size']) { - switch($post['size']) { - case "12x1": - case "12x2": - case "12x4": - case "16x1": - case "16x2": - case "16x4": - case "20x1": - case "20x2": - case "20x4": - case "40x2": - continue; - break; - default: - $input_errors[] = "The chosen display size is not valid"; - break; - } + if ($post['size']) { + switch($post['size']) { + case "12x1": + case "12x2": + case "12x4": + case "16x1": + case "16x2": + case "16x4": + case "20x1": + case "20x2": + case "20x4": + case "40x2": + continue; + break; + default: + $input_errors[] = "The chosen display size is not valid"; + break; } - if($post['port_speed']) { - switch($post['port_speed']) { - case "0": - case "1200": - case "2400": - case "9600": - case "19200": - case "57600": - case "115200": - continue; - break; - default: - $input_errors[] = "The chosen port speed is not valid"; - break; - } - } } - function validate_form_lcdproc_screens($post, &$input_errors) { - // No validation required ?! + if ($post['port_speed']) { + switch($post['port_speed']) { + case "0": + case "1200": + case "2400": + case "9600": + case "19200": + case "57600": + case "115200": + continue; + break; + default: + $input_errors[] = "The chosen port speed is not valid"; + break; + } } - function sync_package_lcdproc_screens() { - sync_package_lcdproc(); - } - function sync_package_lcdproc() { - global $g; - global $config; - global $input_errors; +} + +function sync_package_lcdproc_screens() { + sync_package_lcdproc(); +} + +function sync_package_lcdproc() { + global $g; + global $config; + global $input_errors; - # detect boot process - if (is_array($_POST)){ - if (! preg_match("/\w+/",$_POST['__csrf_magic'])) + # Detect boot process + if (platform_booting()) { + return; + } + + # Continue sync package + lcdproc_notice("Sync: Begin package sync"); + $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + + /* Since config is written before this file invoked, we don't need to read post data */ + if ($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { + switch ($lcdproc_config['comport']) { + case "com1": + $realport = "/dev/cua0"; + break; + case "com2": + $realport = "/dev/cua1"; + break; + case "com1a": + $realport = "/dev/cuau0"; + break; + case "com2a": + $realport = "/dev/cuau1"; + break; + case "ucom1": + $realport = "/dev/cuaU0"; + break; + case "ucom2": + $realport = "/dev/cuaU1"; + break; + case "lpt1": + $realport = "/dev/lpt0"; + break; + case "ugen0.2": + $realport = "/dev/ugen0.2"; + break; + case "ugen1.2": + $realport = "/dev/ugen1.2"; + break; + case "ugen1.3": + $realport = "/dev/ugen1.3"; + break; + case "ugen2.2": + $realport = "/dev/ugen2.2"; + break; + default: + lcdproc_warn("The selected COM port is not valid!"); return; - } + } - #continue sync package - lcdproc_notice("Sync: Begin package sync"); - config_lock(); - $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; - $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - /* since config is written before this file invoked we don't need to read post data */ - if($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { - switch($lcdproc_config['comport']) { - case "com1": - $realport = "/dev/cua0"; - break; - case "com2": - $realport = "/dev/cua1"; - break; - case "com1a": - $realport = "/dev/cuau0"; - break; - case "com2a": - $realport = "/dev/cuau1"; - break; - case "ucom1": - $realport = "/dev/cuaU0"; - break; - case "ucom2": - $realport = "/dev/cuaU1"; - break; - case "lpt1": - $realport = "/dev/lpt0"; - break; - case "ugen0.2": - $realport = "/dev/ugen0.2"; - break; - case "ugen1.2": - $realport = "/dev/ugen1.2"; - break; - case "ugen1.3": - $realport = "/dev/ugen1.3"; - break; - case "ugen2.2": - $realport = "/dev/ugen2.2"; - break; - default: - lcdproc_warn("The selected com port is not valid!"); - config_unlock(); - return; - } - $config_text = "[server]\n"; - $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; - $config_text .= "Driver={$lcdproc_config[driver]}\n"; - $config_text .= "Bind=127.0.0.1\n"; - $config_text .= "Port=13666\n"; - $config_text .= "ReportLevel=3\n"; - $config_text .= "ReportToSyslog=yes\n"; - $config_text .= "User=nobody\n"; - $config_text .= "Foreground=no\n"; - $config_text .= "ServerScreen=no\n"; - $config_text .= "GoodBye=\"Thanks for using\"\n"; - $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; - $config_text .= "WaitTime={$lcdproc_config[refresh_frequency]}\n"; - if ($lcdproc_config[backlight] != "" && $lcdproc_config[backlight] != "default") - { - /* Backlight setting */ - $config_text .= "Backlight={$lcdproc_config[backlight]}\n"; - } - if ($lcdproc_config[driver] == "sdeclcd") - { - /* Sdeclcd Keys settings */ - $config_text .= "PrevScreenKey=Down\n"; - $config_text .= "NextScreenKey=Up\n"; - /* Sdeclcd Menu settings */ - $config_text .= "[menu]\n"; - $config_text .= "MenuKey=Left\n"; - $config_text .= "EnterKey=Right\n"; - $config_text .= "UpKey=Up\n"; - $config_text .= "DownKey=Down\n"; - } - else - { - /* Generic Keys settings */ - $config_text .= "ToggleRotateKey=Enter\n"; - $config_text .= "PrevScreenKey=Left\n"; - $config_text .= "NextScreenKey=Right\n"; - $config_text .= "ScrollUpKey=Up\n"; - $config_text .= "ScrollDownKey=Down\n"; - /* Generic Menu settings */ - $config_text .= "[menu]\n"; - $config_text .= "MenuKey=Escape\n"; - $config_text .= "EnterKey=Enter\n"; - $config_text .= "UpKey=Up\n"; - $config_text .= "DownKey=Down\n"; - } - /* lcdproc default driver definitions */ - switch($lcdproc_config[driver]) { - case "bayrad": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - break; - case "CFontz": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= set_lcd_value("contrast", 1000, 350); - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 50); - $config_text .= "NewFirmware=no\n"; - $config_text .= "Reboot=no\n"; - break; - case "CFontz633": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= set_lcd_value("contrast", 1000, 350); - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 50); - $config_text .= "NewFirmware=yes\n"; - $config_text .= "Reboot=yes\n"; - break; - case "CFontzPacket": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Model=635\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= set_lcd_value("contrast", 1000, 350); - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 50); - $config_text .= "NewFirmware=yes\n"; - $config_text .= "Reboot=yes\n"; - break; - case "curses": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Foreground=blue\n"; - $config_text .= "Background=cyan\n"; - $config_text .= "Backlight=red\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "TopLeftX=7\n"; - $config_text .= "TopLeftY=7\n"; - $config_text .= "UseACS=no\n"; - break; - case "CwLnx": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Model=12232\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Reboot=no\n"; - break; - case "ea65": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "OffBrightness=0\n"; - $config_text .= set_lcd_value("brightness", 1000, 500); - break; - case "EyeboxOne": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Backlight=yes\n"; - break; - case "glk": - $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text = "[server]\n"; + $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; + $config_text .= "Driver={$lcdproc_config[driver]}\n"; + $config_text .= "Bind=127.0.0.1\n"; + $config_text .= "Port=13666\n"; + $config_text .= "ReportLevel=3\n"; + $config_text .= "ReportToSyslog=yes\n"; + $config_text .= "User=nobody\n"; + $config_text .= "Foreground=no\n"; + $config_text .= "ServerScreen=no\n"; + $config_text .= "GoodBye=\"Thanks for using\"\n"; + $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; + $config_text .= "WaitTime={$lcdproc_config[refresh_frequency]}\n"; + if ($lcdproc_config[backlight] != "" && $lcdproc_config[backlight] != "default") { + /* Backlight setting */ + $config_text .= "Backlight={$lcdproc_config[backlight]}\n"; + } + if ($lcdproc_config[driver] == "sdeclcd") { + /* Sdeclcd Keys settings */ + $config_text .= "PrevScreenKey=Down\n"; + $config_text .= "NextScreenKey=Up\n"; + /* Sdeclcd Menu settings */ + $config_text .= "[menu]\n"; + $config_text .= "MenuKey=Left\n"; + $config_text .= "EnterKey=Right\n"; + $config_text .= "UpKey=Up\n"; + $config_text .= "DownKey=Down\n"; + } else { + /* Generic Keys settings */ + $config_text .= "ToggleRotateKey=Enter\n"; + $config_text .= "PrevScreenKey=Left\n"; + $config_text .= "NextScreenKey=Right\n"; + $config_text .= "ScrollUpKey=Up\n"; + $config_text .= "ScrollDownKey=Down\n"; + /* Generic Menu settings */ + $config_text .= "[menu]\n"; + $config_text .= "MenuKey=Escape\n"; + $config_text .= "EnterKey=Enter\n"; + $config_text .= "UpKey=Up\n"; + $config_text .= "DownKey=Down\n"; + } + + /* lcdproc default driver definitions */ + switch($lcdproc_config[driver]) { + case "bayrad": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + break; + case "CFontz": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= set_lcd_value("contrast", 1000, 350); + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 50); + $config_text .= "NewFirmware=no\n"; + $config_text .= "Reboot=no\n"; + break; + case "CFontz633": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= set_lcd_value("contrast", 1000, 350); + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 50); + $config_text .= "NewFirmware=yes\n"; + $config_text .= "Reboot=yes\n"; + break; + case "CFontzPacket": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Model=635\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= set_lcd_value("contrast", 1000, 350); + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 50); + $config_text .= "NewFirmware=yes\n"; + $config_text .= "Reboot=yes\n"; + break; + case "curses": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Foreground=blue\n"; + $config_text .= "Background=cyan\n"; + $config_text .= "Backlight=red\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "TopLeftX=7\n"; + $config_text .= "TopLeftY=7\n"; + $config_text .= "UseACS=no\n"; + break; + case "CwLnx": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Model=12232\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Reboot=no\n"; + break; + case "ea65": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "OffBrightness=0\n"; + $config_text .= set_lcd_value("brightness", 1000, 500); + break; + case "EyeboxOne": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Backlight=yes\n"; + break; + case "glk": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= set_lcd_value("contrast", 1000, 350); + break; + case "hd44780": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; + $config_text .= "ConnectionType={$lcdproc_config['connection_type']}\n"; + if ($lcdproc_config['comport'] != "none") { $config_text .= "Device={$realport}\n"; - $config_text .= set_lcd_value("contrast", 1000, 350); - break; - case "hd44780": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; - $config_text .= "ConnectionType={$lcdproc_config['connection_type']}\n"; - if($lcdproc_config['comport'] != "none") - $config_text .= "Device={$realport}\n"; - $config_text .= "Port=0x378\n"; + $config_text .= "Port=0x378\n"; $config_text .= "Speed=0\n"; $config_text .= "Keypad=yes\n"; $config_text .= set_lcd_value("contrast", 1000, 850); @@ -327,159 +324,158 @@ $config_text .= "DelayMult=1\n"; $config_text .= "DelayBus=true\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; - if ($lcdproc_config[connection_type] == "winamp") - { - $config_text .= "KeyDirect_1=Enter\n"; - $config_text .= "KeyDirect_2=Up\n"; - $config_text .= "KeyDirect_3=Down\n"; - $config_text .= "KeyDirect_4=Escape\n"; - } - else - { - } - break; - case "icp_a106": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - break; - case "IOWarrior": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "lb216": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= set_lcd_value("brightness", 255, 255); - $config_text .= "Reboot=no\n"; - break; - case "lcdm001": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - break; - case "lcterm": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "MD8800": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 0); - break; - case "ms6931": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Reboot=no\n"; - break; - case "mtc_s16209x": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= set_lcd_value("brightness", 255, 255); - $config_text .= "Reboot=no\n"; - break; - case "MtxOrb": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Type=lcd\n"; - $config_text .= "hasAdjustableBacklight=yes\n"; - $config_text .= "Reboot=no\n"; - $config_text .= set_lcd_value("contrast", 1000, 480); - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 0); - break; - case "nexcom": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "NoritakeVFD": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 0); - $config_text .= "Parity=0\n"; - $config_text .= "Reboot=no\n"; - break; - case "picolcd": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "KeyTimeout=500\n"; - $config_text .= set_lcd_value("contrast", 1000, 1000); - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 0); - $config_text .= "Blacklight_Timer=60\n"; - $config_text .= "Keylights=on\n"; - $config_text .= "Key0Light=on\n"; - $config_text .= "Key1Light=off\n"; - $config_text .= "Key2Light=off\n"; - $config_text .= "Key3Light=off\n"; - $config_text .= "Key4Light=off\n"; - $config_text .= "Key5Light=off\n"; - break; - case "pyramid": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "sdeclcd": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - break; - case "sed1330": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - break; - case "sed1520": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - break; - case "serialPOS": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Type=AEDEX\n"; - break; - case "serialVFD": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "use_parallel=no\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Type=0\n"; //Just the first - $config_text .= set_lcd_value("brightness", 1000, 1000); - $config_text .= set_lcd_value("offbrightness", 1000, 0); - $config_text .= "ISO_8859_1=yes\n"; - break; - case "shuttleVFD": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - break; - case "SureElec": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Edition=2\n"; - $config_text .= set_lcd_value("contrast", 1000, 200); - $config_text .= set_lcd_value("brightness", 1000, 480); - break; - case "sli": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - break; - default: - lcdproc_warn("The chosen lcdproc driver is not a valid choice"); - unset($lcdproc_config[driver]); - } - /* Port speed */ - if ($lcdproc_config[port_speed] <> '' && $lcdproc_config[port_speed] <> '0') { - $port_speed = $lcdproc_config[port_speed]; - $config_text .= "Speed={$port_speed}\n"; - } - /* generate rc file start and stop */ - $stop = <<<EOD + } + if ($lcdproc_config[connection_type] == "winamp") { + $config_text .= "KeyDirect_1=Enter\n"; + $config_text .= "KeyDirect_2=Up\n"; + $config_text .= "KeyDirect_3=Down\n"; + $config_text .= "KeyDirect_4=Escape\n"; + } + break; + case "icp_a106": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + break; + case "IOWarrior": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "lb216": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= set_lcd_value("brightness", 255, 255); + $config_text .= "Reboot=no\n"; + break; + case "lcdm001": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + break; + case "lcterm": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "MD8800": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 0); + break; + case "ms6931": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Reboot=no\n"; + break; + case "mtc_s16209x": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= set_lcd_value("brightness", 255, 255); + $config_text .= "Reboot=no\n"; + break; + case "MtxOrb": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Type=lcd\n"; + $config_text .= "hasAdjustableBacklight=yes\n"; + $config_text .= "Reboot=no\n"; + $config_text .= set_lcd_value("contrast", 1000, 480); + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 0); + break; + case "nexcom": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "NoritakeVFD": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 0); + $config_text .= "Parity=0\n"; + $config_text .= "Reboot=no\n"; + break; + case "picolcd": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "KeyTimeout=500\n"; + $config_text .= set_lcd_value("contrast", 1000, 1000); + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 0); + $config_text .= "Blacklight_Timer=60\n"; + $config_text .= "Keylights=on\n"; + $config_text .= "Key0Light=on\n"; + $config_text .= "Key1Light=off\n"; + $config_text .= "Key2Light=off\n"; + $config_text .= "Key3Light=off\n"; + $config_text .= "Key4Light=off\n"; + $config_text .= "Key5Light=off\n"; + break; + case "pyramid": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "sdeclcd": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + break; + case "sed1330": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + break; + case "sed1520": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + break; + case "serialPOS": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Type=AEDEX\n"; + break; + case "serialVFD": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "use_parallel=no\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Type=0\n"; // Just the first + $config_text .= set_lcd_value("brightness", 1000, 1000); + $config_text .= set_lcd_value("offbrightness", 1000, 0); + $config_text .= "ISO_8859_1=yes\n"; + break; + case "shuttleVFD": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + break; + case "SureElec": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Edition=2\n"; + $config_text .= set_lcd_value("contrast", 1000, 200); + $config_text .= set_lcd_value("brightness", 1000, 480); + break; + case "sli": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + break; + default: + lcdproc_warn("The chosen lcdproc driver is not a valid choice"); + unset($lcdproc_config[driver]); + } + + /* Port speed */ + if ($lcdproc_config[port_speed] <> '' && $lcdproc_config[port_speed] <> '0') { + $port_speed = $lcdproc_config[port_speed]; + $config_text .= "Speed={$port_speed}\n"; + } + + /* Generate rc file start and stop */ + $stop = <<<EOD if [ `pgrep -f lcdproc_client.ph` ];then pkill -f lcdproc_client.ph sleep 1 @@ -490,67 +486,67 @@ if [ `pgrep -anx LCDd` ]; then fi EOD; - $start = $stop ."\n"; - $start .= "\t/usr/bin/nice -20 /usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ." -u nobody\n"; - $start .= "\t/usr/bin/nice -20 /usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php &\n"; - /* write out the configuration */ - conf_mount_rw(); - lcdproc_write_config(LCDPROC_CONFIG, $config_text); - write_rcfile(array( - 'file' => 'lcdproc.sh', - 'start' => $start, - 'stop' => $stop - )); - conf_mount_ro(); - /* or restart lcdproc if settings were changed*/ - if(is_service_running(LCDPROC_SERVICE_NAME)) { - lcdproc_notice("Sync: Restarting the service"); - restart_service(LCDPROC_SERVICE_NAME); - } + $start = $stop ."\n"; + $start .= "\t/usr/bin/nice -20 /usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ." -u nobody\n"; + $start .= "\t/usr/bin/nice -20 /usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php &\n"; + + /* Write out the configuration */ + conf_mount_rw(); + lcdproc_write_config(LCDPROC_CONFIG, $config_text); + write_rcfile(array( + 'file' => 'lcdproc.sh', + 'start' => $start, + 'stop' => $stop + )); + conf_mount_ro(); + /* Or restart lcdproc if settings were changed*/ + if (is_service_running(LCDPROC_SERVICE_NAME)) { + lcdproc_notice("Sync: Restarting the service"); + restart_service(LCDPROC_SERVICE_NAME); } - if((! $lcdproc_config['driver']) || (! $lcdproc_config['comport'])) { - /* no parameters user does not want lcdproc running */ - /* lets stop the service and remove the rc file */ - if(file_exists(LCDPROC_RCFILE)) { - if(!$lcdproc_config['enable']) { - lcdproc_notice('Stopping service: lcdproc disabled'); - } else { - lcdproc_notice('Stopping service: no com port selected'); - } - stop_service(LCDPROC_SERVICE_NAME); - conf_mount_rw(); - unlink(LCDPROC_RCFILE); - unlink(LCDPROC_CONFIG); - conf_mount_ro(); + } + + if ((!$lcdproc_config['driver']) || (!$lcdproc_config['comport'])) { + /* No parameters - user does not want lcdproc running */ + /* Let's stop the service and remove the rc file */ + if (file_exists(LCDPROC_RCFILE)) { + if (!$lcdproc_config['enable']) { + lcdproc_notice('Stopping service: lcdproc disabled'); + } else { + lcdproc_notice('Stopping service: no COM port selected'); } + stop_service(LCDPROC_SERVICE_NAME); + conf_mount_rw(); + unlink(LCDPROC_RCFILE); + unlink(LCDPROC_CONFIG); + conf_mount_ro(); } - config_unlock(); - lcdproc_notice("Sync: End package sync"); } - function set_lcd_value($fieldname, $max, $default_value) { - global $config; - $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; - $value = $lcdproc_config[$fieldname]; - $returnvalue = ""; - if ($value != '' && $value != '-1') { - $realvalue = (int)($max * $value / 100); - } - else - { - $realvalue = $default_value; - } - switch ($fieldname) - { - case "brightness": - $returnvalue = "Brightness={$realvalue}\n"; - break; - case "offbrightness": - $returnvalue = "OffBrightness={$realvalue}\n"; - break; - case "contrast": - $returnvalue = "Contrast={$realvalue}\n"; - break; - } - return $returnvalue; + lcdproc_notice("Sync: End package sync"); +} + +function set_lcd_value($fieldname, $max, $default_value) { + global $config; + $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; + $value = $lcdproc_config[$fieldname]; + $returnvalue = ""; + if ($value != '' && $value != '-1') { + $realvalue = (int)($max * $value / 100); + } else { + $realvalue = $default_value; } + switch ($fieldname) { + case "brightness": + $returnvalue = "Brightness={$realvalue}\n"; + break; + case "offbrightness": + $returnvalue = "OffBrightness={$realvalue}\n"; + break; + case "contrast": + $returnvalue = "Contrast={$realvalue}\n"; + break; + } + return $returnvalue; +} + ?> diff --git a/config/lcdproc-dev/lcdproc.xml b/config/lcdproc-dev/lcdproc.xml index 588b898b..ce62cb5c 100644 --- a/config/lcdproc-dev/lcdproc.xml +++ b/config/lcdproc-dev/lcdproc.xml @@ -1,8 +1,51 @@ <?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <title>Services: LCDproc 0.5.6 pkg v. 0.9.9</title> + <copyright> +<![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ +/* + lcdproc.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> + <title>Services: LCDproc</title> <name>lcdproc</name> - <version>0.5.6 pkg v. 0.9.9</version> + <version>0.9.13</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/lcdproc.inc</include_file> <tabs> @@ -18,29 +61,26 @@ </tabs> <menu> <name>LCDproc</name> - <tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext> + <tooltiptext>Set LCDproc settings such as display driver and COM port.</tooltiptext> <section>Services</section> <url>/pkg_edit.php?xml=lcdproc.xml&id=0</url> </menu> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/lcdproc-dev/lcdproc.inc</item> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/pkg/</prefix> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/lcdproc-dev/lcdproc_screens.xml</item> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/pkg/</prefix> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/lcdproc-dev/lcdproc_client.php</item> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/pkg/</prefix> </additional_files_needed> <additional_files_needed> <item>https://files.pfsense.org/misc/nexcom.so</item> - <prefix>/usr/local/lib/lcdproc/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/lib/lcdproc/</prefix> + <chmod>0755</chmod> </additional_files_needed> <service> <name>lcdproc</name> @@ -50,14 +90,14 @@ </service> <fields> <field> - <fielddescr>Enable LCDproc at startup</fielddescr> + <fielddescr>Enable LCDproc</fielddescr> <fieldname>enable</fieldname> <type>checkbox</type> </field> <field> <fieldname>comport</fieldname> - <fielddescr>Com Port</fielddescr> - <description>Set the com port LCDproc should use.</description> + <fielddescr>COM Port</fielddescr> + <description>Set the COM port LCDproc should use.</description> <type>select</type> <options> <option> @@ -66,27 +106,27 @@ </option> <option> <value>com1</value> - <name>Serial Com port 1 (/dev/cua0)</name> - </option> + <name>Serial COM port 1 (/dev/cua0)</name> + </option> <option> <value>com2</value> - <name>Serial Com port 2 (/dev/cua1)</name> + <name>Serial COM port 2 (/dev/cua1)</name> </option> <option> <value>com1a</value> - <name>Serial Com port 1 alternate (/dev/cuau0)</name> + <name>Serial COM port 1 alternate (/dev/cuau0)</name> </option> <option> <value>com2a</value> - <name>Serial Com port 2 alternate (/dev/cuau1)</name> - </option> + <name>Serial COM port 2 alternate (/dev/cuau1)</name> + </option> <option> <value>ucom1</value> - <name>USB Com port 1 (/dev/cuaU0)</name> + <name>USB COM port 1 (/dev/cuaU0)</name> </option> <option> <value>ucom2</value> - <name>USB Com port 2 (/dev/cuaU1)</name> + <name>USB COM port 2 (/dev/cuaU1)</name> </option> <option> <value>lpt1</value> @@ -94,20 +134,20 @@ </option> <option> <value>ugen0.2</value> - <name>USB Com port 1 alternate (/dev/ugen0.2)</name> - </option> + <name>USB COM port 1 alternate (/dev/ugen0.2)</name> + </option> <option> <value>ugen1.2</value> - <name>USB Com port 2 alternate (/dev/ugen1.2)</name> + <name>USB COM port 2 alternate (/dev/ugen1.2)</name> </option> <option> <value>ugen1.3</value> - <name>USB Com port 3 alternate (/dev/ugen1.3)</name> + <name>USB COM port 3 alternate (/dev/ugen1.3)</name> </option> <option> <value>ugen2.2</value> - <name>USB Com port 4 alternate (/dev/ugen2.2)</name> - </option> + <name>USB COM port 4 alternate (/dev/ugen2.2)</name> + </option> </options> <default_value>ucom1</default_value> </field> @@ -241,7 +281,7 @@ <option> <value>nexcom</value> <name>nexcom (x86 only)</name> - </option> + </option> <option> <value>NoritakeVFD</value> <name>NoritakeVFD</name> @@ -249,15 +289,15 @@ <option> <value>picolcd</value> <name>picolcd</name> - </option> + </option> <option> <value>pyramid</value> <name>pyramid</name> - </option> + </option> <option> <value>sdeclcd</value> <name>Watchguard Firebox with SDEC</name> - </option> + </option> <option> <value>sed1330</value> <name>sed1330</name> @@ -277,7 +317,7 @@ <option> <value>shuttleVFD</value> <name>shuttleVFD</name> - </option> + </option> <option> <value>sli</value> <name>sli</name> @@ -289,7 +329,7 @@ <option> <value>SureElec</value> <name>SureElec</name> - </option> + </option> <option> <value>t6963</value> <name>t6963</name> @@ -317,7 +357,7 @@ </option> <option> <value>8bit</value> - <name>8bit wiring to parallel port(lcdtime)</name> + <name>8bit wiring to parallel port (lcdtime)</name> </option> <option> <value>winamp</value> @@ -385,7 +425,7 @@ </option> </options> <default_value>lcd2usb</default_value> - </field> + </field> <field> <fieldname>refresh_frequency</fieldname> <fielddescr>Refresh frequency</fielddescr> @@ -414,11 +454,16 @@ </option> </options> <default_value>5</default_value> - </field> + </field> <field> <fieldname>port_speed</fieldname> <fielddescr>Port speed</fielddescr> - <description>Set the port speed. Caution: not all the driver or panels support all the speeds, leave "default" if unsure.</description> + <description> + <![CDATA[ + Set the port speed.<br /> + Caution: not all the driver or panels support all the speeds, leave "default" if unsure. + ]]> + </description> <type>select</type> <options> <option> @@ -448,14 +493,19 @@ <option> <value>115200</value> <name>115200 bps</name> - </option> + </option> </options> <default_value>0</default_value> </field> <field> <fieldname>brightness</fieldname> <fielddescr>Brightness</fielddescr> - <description>Set the brightness of the LCD panel. This option is not supported by all the LCD panels, leave "default" if unsure.</description> + <description> + <![CDATA[ + Set the brightness of the LCD panel.<br /> + This option is not supported by all the LCD panels, leave "default" if unsure. + ]]> + </description> <type>select</type> <options> <option> @@ -473,11 +523,11 @@ <option> <value>20</value> <name>20%</name> - </option> + </option> <option> <value>30</value> <name>30%</name> - </option> + </option> <option> <value>40</value> <name>40%</name> @@ -501,18 +551,23 @@ <option> <value>90</value> <name>90%</name> - </option> + </option> <option> <value>100</value> <name>100%</name> </option> - </options> + </options> <default_value>-1</default_value> </field> <field> <fieldname>offbrightness</fieldname> <fielddescr>Off brightness</fielddescr> - <description>Set the off-brightness of the LCD panel. This value is used when the display is normally switched off in case LCDd is inactive. This option is not supported by all the LCD panels, leave "default" if unsure.</description> + <description> + <![CDATA[ + Set the off-brightness of the LCD panel. This value is used when the display is normally switched off in case LCDd is inactive.<br /> + This option is not supported by all the LCD panels, leave "default" if unsure. + ]]> + </description> <type>select</type> <options> <option> @@ -530,11 +585,11 @@ <option> <value>20</value> <name>20%</name> - </option> + </option> <option> <value>30</value> <name>30%</name> - </option> + </option> <option> <value>40</value> <name>40%</name> @@ -558,18 +613,23 @@ <option> <value>90</value> <name>90%</name> - </option> + </option> <option> <value>100</value> <name>100%</name> </option> - </options> + </options> <default_value>-1</default_value> - </field> + </field> <field> <fieldname>contrast</fieldname> <fielddescr>Contrast</fielddescr> - <description>Set the contrast of the LCD panel. This option is not supported by all the LCD panels, leave "default" if unsure.</description> + <description> + <![CDATA[ + Set the contrast of the LCD panel.<br /> + This option is not supported by all the LCD panels, leave "default" if unsure. + ]]> + </description> <type>select</type> <options> <option> @@ -587,11 +647,11 @@ <option> <value>20</value> <name>20%</name> - </option> + </option> <option> <value>30</value> <name>30%</name> - </option> + </option> <option> <value>40</value> <name>40%</name> @@ -615,18 +675,23 @@ <option> <value>90</value> <name>90%</name> - </option> + </option> <option> <value>100</value> <name>100%</name> </option> - </options> + </options> <default_value>-1</default_value> - </field> + </field> <field> <fieldname>backlight</fieldname> <fielddescr>Backlight</fielddescr> - <description>Set the backlight setting. If set to the default value, then the backlight setting of the display can be influenced by the clients. This option is not supported by all the LCD panels, leave "default" if unsure.</description> + <description> + <![CDATA[ + Set the backlight setting. If set to the default value, then the backlight setting of the display can be influenced by the clients.<br /> + This option is not supported by all the LCD panels, leave "default" if unsure. + ]]> + </description> <type>select</type> <options> <option> @@ -647,19 +712,20 @@ <field> <fieldname>outputleds</fieldname> <fielddescr>Enable Output LEDs</fielddescr> - <description>Enable the Output LEDs present on some LCD panels. This feature is currently supported by the CFontz633 driver only. <br> - Each LED can be off or show two colors: RED (alarm) or GREEN (everything ok) and shows: <br> - LED1: NICs status (green: ok, red: at least one nic down);<br> - LED2: CARP status (green: master, red: backup, off: CARP not implemented);<br> - LED3: CPU status (green < 50, red > 50%);<br> - LED4: Gateway status (green: ok, red: at least one gateway not responding, off: no gateway configured).</description> + <description> + <![CDATA[ + Enable the Output LEDs present on some LCD panels. This feature is currently supported by the CFontz633 driver only.<br /> + Each LED can be off or show two colors: RED (alarm) or GREEN (everything ok) and shows:<br /> + LED1: NICs status (green: ok, red: at least one nic down)<br /> + LED2: CARP status (green: master, red: backup, off: CARP not implemented)<br /> + LED3: CPU status (green < 50%, red > 50%)<br /> + LED4: Gateway status (green: ok, red: at least one gateway not responding, off: no gateway configured). + ]]> + </description> <type>checkbox</type> <default_value>default</default_value> - </field> + </field> </fields> - <custom_php_command_before_form> - before_form_lcdproc($pkg); - </custom_php_command_before_form> <custom_php_validation_command> validate_form_lcdproc($_POST, $input_errors); </custom_php_validation_command> diff --git a/config/lcdproc-dev/lcdproc_client.php b/config/lcdproc-dev/lcdproc_client.php index 922ed14e..6635bf7f 100644 --- a/config/lcdproc-dev/lcdproc_client.php +++ b/config/lcdproc-dev/lcdproc_client.php @@ -1,932 +1,935 @@ <?php -/* $Id$ */ /* - lcdproc_client.php - Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl> - Copyright (C) 2012 Michele Di Maria <michele@nt2.it> - 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. + lcdproc_client.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + 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. */ - - /* trick interface into running this. we are only - * calling from useland so this is not a security issue - */ - require_once("config.inc"); - require_once("functions.inc"); - require_once("interfaces.inc"); - require_once("/usr/local/pkg/lcdproc.inc"); - - function get_pfstate() { - global $config; - $matches = ""; - if (isset($config['system']['maximumstates']) and $config['system']['maximumstates'] > 0) - $maxstates="/{$config['system']['maximumstates']}"; - else - $maxstates="/". pfsense_default_state_size(); - - $curentries = `/sbin/pfctl -si |grep current`; - if (preg_match("/([0-9]+)/", $curentries, $matches)) { - $curentries = $matches[1]; - } - return $curentries . $maxstates; +require_once("config.inc"); +require_once("functions.inc"); +require_once("interfaces.inc"); +require_once("/usr/local/pkg/lcdproc.inc"); + +function get_pfstate() { + global $config; + $matches = ""; + if (isset($config['system']['maximumstates']) and $config['system']['maximumstates'] > 0) { + $maxstates = "/{$config['system']['maximumstates']}"; + } else { + $maxstates = "/". pfsense_default_state_size(); } - - function disk_usage() { - $dfout = ""; - exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout); - $diskusage = trim($dfout[0]); - - return $diskusage; + $curentries = shell_exec('/sbin/pfctl -si | /usr/bin/grep current'); + if (preg_match("/([0-9]+)/", $curentries, $matches)) { + $curentries = $matches[1]; } - - function mem_usage() { - $memory = ""; - exec("/sbin/sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_inactive_count " . - "vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $memory); - - $totalMem = $memory[0]; - $availMem = $memory[1] + $memory[2] + $memory[3]; - $usedMem = $totalMem - $availMem; - $memUsage = round(($usedMem * 100) / $totalMem, 0); - - return $memUsage; + return $curentries . $maxstates; +} + +function disk_usage() { + $dfout = ""; + exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout); + $diskusage = trim($dfout[0]); + + return $diskusage; +} + +function mem_usage() { + $memory = ""; + exec("/sbin/sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_inactive_count " . + "vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $memory); + + $totalMem = $memory[0]; + $availMem = $memory[1] + $memory[2] + $memory[3]; + $usedMem = $totalMem - $availMem; + $memUsage = round(($usedMem * 100) / $totalMem, 0); + + return $memUsage; +} + +/* Calculates non-idle CPU time and returns as a percentage */ +function cpu_usage() { + $duration = 250000; + $diff = array('user', 'nice', 'sys', 'intr', 'idle'); + $cpuTicks = array_combine($diff, explode(" ", shell_exec('/sbin/sysctl -n kern.cp_time'))); + usleep($duration); + $cpuTicks2 = array_combine($diff, explode(" ", shell_exec('/sbin/sysctl -n kern.cp_time'))); + + $totalStart = array_sum($cpuTicks); + $totalEnd = array_sum($cpuTicks2); + + // Something wrapped ?!?! + if ($totalEnd <= $totalStart) { + return 0; } - /* Calculates non-idle CPU time and returns as a percentage */ - function cpu_usage() { - $duration = 250000; - $diff = array('user', 'nice', 'sys', 'intr', 'idle'); - $cpuTicks = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`)); - usleep($duration); - $cpuTicks2 = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`)); + // Calculate total cycles used + $totalUsed = ($totalEnd - $totalStart) - ($cpuTicks2['idle'] - $cpuTicks['idle']); - $totalStart = array_sum($cpuTicks); - $totalEnd = array_sum($cpuTicks2); + // Calculate the percentage used + $cpuUsage = floor(100 * ($totalUsed / ($totalEnd - $totalStart))); - // Something wrapped ?!?! - if ($totalEnd <= $totalStart) - return 0; + return $cpuUsage; +} - // Calculate total cycles used - $totalUsed = ($totalEnd - $totalStart) - ($cpuTicks2['idle'] - $cpuTicks['idle']); - - // Calculate the percentage used - $cpuUsage = floor(100 * ($totalUsed / ($totalEnd - $totalStart))); - - return $cpuUsage; +function get_uptime_stats() { + exec("/usr/bin/uptime", $output, $ret); + $temp = explode(",", $output[0]); + if (stristr($output[0], "day")) { + $status = "$temp[0] $temp[1]"; + } else { + $status = "$temp[0] "; } - - function get_uptime_stats() { - exec("/usr/bin/uptime", $output, $ret); - $temp = explode(",", $output[0]); - if(stristr($output[0], "day")) { - $status = "$temp[0] $temp[1]"; - } else { - $status = "$temp[0] "; - } - $status = trim(str_replace(" ", " ", $status)); - $status = substr($status, strpos($status, "up ") + 3); - return($status); + $status = trim(str_replace(" ", " ", $status)); + $status = substr($status, strpos($status, "up ") + 3); + + return($status); +} + +function get_loadavg_stats() { + exec("/usr/bin/uptime", $output, $ret); + if (stristr($output[0], "day")) { + $temp = explode(" ", $output[0]); + $status = "$temp[11] $temp[12] $temp[13]"; + } else { + $temp = explode(" ", $output[0]); + $status = "$temp[10] $temp[11] $temp[12]"; } - - function get_loadavg_stats() { - exec("/usr/bin/uptime", $output, $ret); - if(stristr($output[0], "day")) { - $temp = explode(" ", $output[0]); - $status = "$temp[11] $temp[12] $temp[13]"; + return($status); +} + +function get_mbuf_stats() { + exec("/usr/bin/netstat -mb | /usr/bin/grep \"mbufs in use\" | /usr/bin/awk '{ print $1 }' | /usr/bin/cut -d\"/\" -f1", $mbufs_inuse); + exec("/usr/bin/netstat -mb | /usr/bin/grep \"mbufs in use\" | /usr/bin/awk '{ print $1 }' | /usr/bin/cut -d\"/\" -f3", $mbufs_total); + $status = "$mbufs_inuse[0] \/ $mbufs_total[0]"; + return($status); +} + +function get_version() { + global $g; + $version = @file_get_contents("/etc/version"); + $version = trim($version); + return("{$g['product_name']} {$version}"); +} + +function get_cpufrequency() { + $cpufreqs = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); + $cpufreqs = explode(" ", trim($cpufreqs[0])); + $maxfreq = explode("/", $cpufreqs[0]); + $maxfreq = $maxfreq[0]; + $curfreq = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); + $curfreq = trim($curfreq[0]); + $status = "$curfreq\/$maxfreq Mhz"; + return($status); +} + +function get_cpufrequency_perc() { + $cpufreqs = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); + $cpufreqs = explode(" ", trim($cpufreqs[0])); + $maxfreq = explode("/", $cpufreqs[0]); + $maxfreq = $maxfreq[0]; + $curfreq = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); + $curfreq = trim($curfreq[0]); + $status = $curfreq/$maxfreq * 100; + return($status); +} + +function get_interfaces_stats() { + global $g; + global $config; + $ifstatus = array(); + $i = 0; + $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); + for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { + $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; + } + foreach ($ifdescrs as $ifdescr => $ifname) { + $ifinfo = get_interface_info($ifdescr); + if ($ifinfo['status'] == "up") { + $online = "Up"; } else { - $temp = explode(" ", $output[0]); - $status = "$temp[10] $temp[11] $temp[12]"; - } - return($status); - } - - function get_mbuf_stats() { - exec("netstat -mb | grep \"mbufs in use\" | awk '{ print $1 }' | cut -d\"/\" -f1", $mbufs_inuse); - exec("netstat -mb | grep \"mbufs in use\" | awk '{ print $1 }' | cut -d\"/\" -f3", $mbufs_total); - $status = "$mbufs_inuse[0] \/ $mbufs_total[0]"; - return($status); - } - - function get_version() { - global $g; - $version = @file_get_contents("/etc/version"); - $version = trim($version); - return("{$g['product_name']} {$version}"); - } - - function get_cpufrequency(){ - $cpufreqs = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); - $cpufreqs = explode(" ", trim($cpufreqs[0])); - $maxfreq = explode("/", $cpufreqs[0]); - $maxfreq = $maxfreq[0]; - $curfreq = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); - $curfreq = trim($curfreq[0]); - $status = "$curfreq\/$maxfreq Mhz"; - return($status); - } - - function get_cpufrequency_perc(){ - $cpufreqs = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); - $cpufreqs = explode(" ", trim($cpufreqs[0])); - $maxfreq = explode("/", $cpufreqs[0]); - $maxfreq = $maxfreq[0]; - $curfreq = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); - $curfreq = trim($curfreq[0]); - $status = $curfreq/$maxfreq * 100; - return($status); - } - - function get_interfaces_stats() { - global $g; - global $config; - $ifstatus = array(); - $i = 0; - $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { - $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; + $online = "Down"; } - foreach ($ifdescrs as $ifdescr => $ifname){ - $ifinfo = get_interface_info($ifdescr); - if($ifinfo['status'] == "up") { - $online = "Up"; - } else { - $online = "Down"; - } - if(!empty($ifinfo['ipaddr'])) { - $ip = htmlspecialchars($ifinfo['ipaddr']); - } else { - $ip = "-"; - } - $ifstatus[] = htmlspecialchars($ifname) ." [$online]"; + if (!empty($ifinfo['ipaddr'])) { + $ip = htmlspecialchars($ifinfo['ipaddr']); + } else { + $ip = "-"; } - $status = " ". implode(", ", $ifstatus); - return($status); + $ifstatus[] = htmlspecialchars($ifname) ." [$online]"; } + $status = " ". implode(", ", $ifstatus); + return($status); +} - function get_slbd_stats() { - global $g; - global $config; +function get_slbd_stats() { + global $g; + global $config; - if (!is_array($config['load_balancer']['lbpool'])) { - $config['load_balancer']['lbpool'] = array(); - } - $a_pool = &$config['load_balancer']['lbpool']; - - $slbd_logfile = "{$g['varlog_path']}/slbd.log"; - - $nentries = $config['syslog']['nentries']; - if (!$nentries) - $nentries = 50; - - $now = time(); - $year = date("Y"); - $pstatus = ""; - $i = 0; - foreach ($a_pool as $vipent) { - $pstatus[] = "{$vipent['name']}"; - if ($vipent['type'] == "gateway") { - $poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool"; - if(file_exists("$poolfile")) { - $poolstatus = file_get_contents("$poolfile"); - } else { - continue; - } - foreach ((array) $vipent['servers'] as $server) { - $lastchange = ""; - $svr = split("\|", $server); - $monitorip = $svr[1]; - if(stristr($poolstatus, $monitorip)) { - $online = "Up"; - } else { - $online = "Down"; - } - $pstatus[] = strtoupper($svr[0]) ." [{$online}]"; - } + if (!is_array($config['load_balancer']['lbpool'])) { + $config['load_balancer']['lbpool'] = array(); + } + $a_pool = &$config['load_balancer']['lbpool']; + + $slbd_logfile = "{$g['varlog_path']}/slbd.log"; + + $nentries = $config['syslog']['nentries']; + if (!$nentries) { + $nentries = 50; + } + + $now = time(); + $year = date("Y"); + $pstatus = ""; + $i = 0; + foreach ($a_pool as $vipent) { + $pstatus[] = "{$vipent['name']}"; + if ($vipent['type'] == "gateway") { + $poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool"; + if (file_exists("$poolfile")) { + $poolstatus = file_get_contents("$poolfile"); } else { - $pstatus[] = "{$vipent['monitor']}"; + continue; } - } - if(count($a_pool) == 0) { - $pstatus[] = "Disabled"; - } - $status = implode(", ", $pstatus); - return($status); - } - - function get_carp_stats () { - global $g; - global $config; - - if(is_array($config['virtualip']['vip'])) { - $carpint = 0; - $initcount = 0; - $mastercount = 0; - $backupcount = 0; - foreach($config['virtualip']['vip'] as $carp) { - if ($carp['mode'] != "carp") { - continue; - } - $ipaddress = $carp['subnet']; - $password = $carp['password']; - $netmask = $carp['subnet_bits']; - $vhid = $carp['vhid']; - $advskew = $carp['advskew']; - $carp_int = find_carp_interface($ipaddress); - $status = get_carp_interface_status($carp_int); - switch($status) { - case "MASTER": - $mastercount++; - break; - case "BACKUP": - $backupcount++; - break; - case "INIT": - $initcount++; - break; + foreach ((array) $vipent['servers'] as $server) { + $lastchange = ""; + $svr = explode("|", $server); + $monitorip = $svr[1]; + if (stristr($poolstatus, $monitorip)) { + $online = "Up"; + } else { + $online = "Down"; } + $pstatus[] = strtoupper($svr[0]) ." [{$online}]"; } - $status = "M/B/I {$mastercount}/{$backupcount}/{$initcount}"; } else { - $status = "CARP Disabled"; + $pstatus[] = "{$vipent['monitor']}"; } - return($status); - } - - function get_ipsec_tunnel_sad() { - /* query SAD */ - if(file_exists("/usr/local/sbin/setkey")) - $fd = @popen("/usr/local/sbin/setkey -D", "r"); - else - $fd = @popen("/sbin/setkey -D", "r"); - $sad = array(); - if ($fd) { - while (!feof($fd)) { - $line = chop(fgets($fd)); - if (!$line) - continue; - if ($line == "No SAD entries.") + } + if (count($a_pool) == 0) { + $pstatus[] = "Disabled"; + } + $status = implode(", ", $pstatus); + return($status); +} + +function get_carp_stats() { + global $g; + global $config; + + if (is_array($config['virtualip']['vip'])) { + $carpint = 0; + $initcount = 0; + $mastercount = 0; + $backupcount = 0; + foreach ($config['virtualip']['vip'] as $carp) { + if ($carp['mode'] != "carp") { + continue; + } + $ipaddress = $carp['subnet']; + $password = $carp['password']; + $netmask = $carp['subnet_bits']; + $vhid = $carp['vhid']; + $advskew = $carp['advskew']; + $carp_int = find_carp_interface($ipaddress); + $status = get_carp_interface_status($carp_int); + switch ($status) { + case "MASTER": + $mastercount++; break; - if ($line[0] != "\t") { - if (is_array($cursa)) - $sad[] = $cursa; - $cursa = array(); - list($cursa['src'],$cursa['dst']) = explode(" ", $line); - $i = 0; - } else { - $linea = explode(" ", trim($line)); - if ($i == 1) { - $cursa['proto'] = $linea[0]; - $cursa['spi'] = substr($linea[2], strpos($linea[2], "x")+1, -1); - } else if ($i == 2) { - $cursa['ealgo'] = $linea[1]; - } else if ($i == 3) { - $cursa['aalgo'] = $linea[1]; - } + case "BACKUP": + $backupcount++; + break; + case "INIT": + $initcount++; + break; + } + } + $status = "M/B/I {$mastercount}/{$backupcount}/{$initcount}"; + } else { + $status = "CARP Disabled"; + } + return($status); +} + +function get_ipsec_tunnel_sad() { + /* query SAD */ + if (file_exists("/usr/local/sbin/setkey")) { + $fd = @popen("/usr/local/sbin/setkey -D", "r"); + } else { + $fd = @popen("/sbin/setkey -D", "r"); + } + $sad = array(); + if ($fd) { + while (!feof($fd)) { + $line = chop(fgets($fd)); + if (!$line) { + continue; + } + if ($line == "No SAD entries.") { + break; + } + if ($line[0] != "\t") { + if (is_array($cursa)) { + $sad[] = $cursa; + $cursa = array(); } - $i++; + list($cursa['src'],$cursa['dst']) = explode(" ", $line); + $i = 0; + } else { + $linea = explode(" ", trim($line)); + if ($i == 1) { + $cursa['proto'] = $linea[0]; + $cursa['spi'] = substr($linea[2], strpos($linea[2], "x")+1, -1); + } else if ($i == 2) { + $cursa['ealgo'] = $linea[1]; + } else if ($i == 3) { + $cursa['aalgo'] = $linea[1]; } - if (is_array($cursa) && count($cursa)) - $sad[] = $cursa; - pclose($fd); + } + $i++; } - return($sad); - } - - function get_ipsec_tunnel_src($tunnel) { - global $g, $config, $sad; - $if = "WAN"; - if ($tunnel['interface']) { - $if = $tunnel['interface']; - $realinterface = convert_friendly_interface_to_real_interface_name($if); - $interfaceip = find_interface_ip($realinterface); + if (is_array($cursa) && count($cursa)) { + $sad[] = $cursa; } - return $interfaceip; + pclose($fd); } - - function output_ipsec_tunnel_status($tunnel) { - global $g, $config, $sad; - $if = "WAN"; - $interfaceip = get_ipsec_tunnel_src($tunnel); - $foundsrc = false; - $founddst = false; - - if(!is_array($sad)) { - /* we have no sad array, bail */ - return(false); - } - foreach($sad as $sa) { - if($sa['src'] == $interfaceip) - $foundsrc = true; - if($sa['dst'] == $tunnel['remote-gateway']) - $founddst = true; + return($sad); +} + +function get_ipsec_tunnel_src($tunnel) { + global $g, $config, $sad; + $if = "WAN"; + if ($tunnel['interface']) { + $if = $tunnel['interface']; + $realinterface = convert_friendly_interface_to_real_interface_name($if); + $interfaceip = find_interface_ip($realinterface); + } + return $interfaceip; +} + +function output_ipsec_tunnel_status($tunnel) { + global $g, $config, $sad; + $if = "WAN"; + $interfaceip = get_ipsec_tunnel_src($tunnel); + $foundsrc = false; + $founddst = false; + + if (!is_array($sad)) { + /* we have no sad array, bail */ + return(false); + } + foreach ($sad as $sa) { + if ($sa['src'] == $interfaceip) { + $foundsrc = true; } - if($foundsrc && $founddst) { - /* tunnel is up */ - $iconfn = "pass"; - return(true); - } else { - /* tunnel is down */ - $iconfn = "reject"; - return(false); + if ($sa['dst'] == $tunnel['remote-gateway']) { + $founddst = true; } } + if ($foundsrc && $founddst) { + /* tunnel is up */ + $iconfn = "pass"; + return(true); + } else { + /* tunnel is down */ + $iconfn = "reject"; + return(false); + } +} - function get_ipsec_stats() { - global $g, $config, $sad; - $sad = array(); - $sad = get_ipsec_tunnel_sad(); - - $activecounter = 0; - $inactivecounter = 0; - - if($config['ipsec']['tunnel']) { - foreach ($config['ipsec']['tunnel'] as $tunnel){ - $ipsecstatus = false; - - $tun_disabled = "false"; - $foundsrc = false; - $founddst = false; - - if (isset($tunnel['disabled'])) { - $tun_disabled = "true"; - continue; - } - - if(output_ipsec_tunnel_status($tunnel)) { - /* tunnel is up */ - $iconfn = "true"; - $activecounter++; - } else { - /* tunnel is down */ - $iconfn = "false"; - $inactivecounter++; - } - } - } +function get_ipsec_stats() { + global $g, $config, $sad; + $sad = array(); + $sad = get_ipsec_tunnel_sad(); - if (is_array($config['ipsec']['tunnel'])) { - $status = "Up/Down $activecounter/$inactivecounter"; - } else { - $status = "IPSEC Disabled"; - } - return($status); - } + $activecounter = 0; + $inactivecounter = 0; - - /* Define functions */ - function send_lcd_commands($lcd, $lcd_cmds) { - if(!is_array($lcd_cmds) || (empty($lcd_cmds))) { - lcdproc_warn("Failed to interpret lcd commands"); - return; - } - while (($cmd_output = fgets($lcd, 8000)) !== false) { - if(preg_match("/^huh?/", $cmd_output)) { - lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\""); + if ($config['ipsec']['tunnel']) { + foreach ($config['ipsec']['tunnel'] as $tunnel) { + $ipsecstatus = false; + + $tun_disabled = "false"; + $foundsrc = false; + $founddst = false; + + if (isset($tunnel['disabled'])) { + $tun_disabled = "true"; + continue; } - } - foreach($lcd_cmds as $lcd_cmd) { - if(! fwrite($lcd, "$lcd_cmd\n")) { - lcdproc_warn("Connection to LCDd process lost $errstr ($errno)"); - $lcdproc_connect_errors++; - return false; + + if (output_ipsec_tunnel_status($tunnel)) { + /* tunnel is up */ + $iconfn = "true"; + $activecounter++; + } else { + /* tunnel is down */ + $iconfn = "false"; + $inactivecounter++; } } - return true; } - function get_lcdpanel_width(){ - global $config; - $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; - if (is_null($lcdproc_size_config['size'])) { - return "16"; - } - else - { - $dimensions = split("x", $lcdproc_size_config['size']); - return $dimensions[0]; - } + if (is_array($config['ipsec']['tunnel'])) { + $status = "Up/Down $activecounter/$inactivecounter"; + } else { + $status = "IPSEC Disabled"; } - - function get_lcdpanel_height(){ - global $config; - $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; - if (is_null($lcdproc_size_config['size'])) { - return "2"; - } - else - { - $dimensions = split("x", $lcdproc_size_config['size']); - return $dimensions[1]; - } - } - - function get_lcdpanel_refresh_frequency(){ - global $config; - $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; - $value = $lcdproc_size_config['refresh_frequency']; - if (is_null($value)) { - return "5"; - } - else - { - return $value; + return($status); +} + +function send_lcd_commands($lcd, $lcd_cmds) { + if (!is_array($lcd_cmds) || (empty($lcd_cmds))) { + lcdproc_warn("Failed to interpret lcd commands"); + return; + } + while (($cmd_output = fgets($lcd, 8000)) !== false) { + if (preg_match("/^huh?/", $cmd_output)) { + lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\""); } } - - function outputled_enabled_CFontz633(){ - global $config; - $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; - $value = $lcdproc_config['outputleds']; - if (is_null($value)) - {return false;} - else - { - if ($value && $lcdproc_config['driver'] == "CFontz633") - {return true;} - else if ($value && $lcdproc_config['driver'] == "CFontzPacket") - {return true;} - else - {return false;} + foreach ($lcd_cmds as $lcd_cmd) { + if (! fwrite($lcd, "$lcd_cmd\n")) { + lcdproc_warn("Connection to LCDd process lost $errstr ($errno)"); + $lcdproc_connect_errors++; + return false; } } - - function outputled_carp () { - /* Returns the status of CARP for the box. - Assumes ALL CARP status are the same for all the intefaces. - -1 = CARP Disabled - 0 = CARP on Backup - 1 = CARP on Master */ - global $g; - global $config; - - if(is_array($config['virtualip']['vip'])) { - $carpint = 0; - foreach($config['virtualip']['vip'] as $carp) { - if ($carp['mode'] != "carp") { - continue; - } - $carp_int = find_carp_interface($carp['subnet']); - $status = get_carp_interface_status($carp_int); - switch($status) { - case "MASTER": - return 1; - break; - case "BACKUP": - return 0; - break; - } - } + return true; +} + +function get_lcdpanel_width() { + global $config; + $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; + if (is_null($lcdproc_size_config['size'])) { + return "16"; + } else { + $dimensions = explode("x", $lcdproc_size_config['size']); + return $dimensions[0]; + } +} + +function get_lcdpanel_height() { + global $config; + $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; + if (is_null($lcdproc_size_config['size'])) { + return "2"; + } else { + $dimensions = explode("x", $lcdproc_size_config['size']); + return $dimensions[1]; + } +} + +function get_lcdpanel_refresh_frequency() { + global $config; + $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; + $value = $lcdproc_size_config['refresh_frequency']; + if (is_null($value)) { + return "5"; + } else { + return $value; + } +} + +function outputled_enabled_CFontz633() { + global $config; + $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; + $value = $lcdproc_config['outputleds']; + if (is_null($value)) { + return false; + } else { + if ($value && $lcdproc_config['driver'] == "CFontz633") { + return true; + } else if ($value && $lcdproc_config['driver'] == "CFontzPacket") { + return true; } else { - return -1; - } - } - - function outputled_gateway() { - /* Returns the status of the gateways. - -1 = No gateway defined - 0 = At least 1 gateway down or with issues - 1 = All gateway up */ - global $g; - global $config; - $a_gateways = return_gateways_array(); - $gateways_status = array(); - $gateways_status = return_gateways_status(true); - foreach ($a_gateways as $gname => $gateway) - { - if ($gateways_status[$gname]['status'] != "none") - { - return 0; - } - } - return 1; - } - - function get_traffic_stats(&$in_data, &$out_data){ - global $config; - global $traffic_last_ugmt, $traffic_last_ifin, $traffic_last_ifout; - $lcdproc_screen_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - /* read the configured interface */ - $ifnum = $lcdproc_screen_config['scr_traffic_interface']; - /* get the real interface name (code from ifstats.php)*/ - $realif = get_real_interface($ifnum); - if(!$realif) - $realif = $ifnum; // Need for IPSec case interface. - /* get the interface stats (code from ifstats.php)*/ - $ifinfo = pfSense_get_interface_stats($realif); - /* get the current time (code from ifstats.php)*/ - $temp = gettimeofday(); - $timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0; - /* calculate the traffic stats */ - $deltatime = $timing - $traffic_last_ugmt; - $in_data = "IN: " . formatSpeedBits(((double)$ifinfo['inbytes']-$traffic_last_ifin)/$deltatime); - $out_data = "OUT: " . formatSpeedBits(((double)$ifinfo['outbytes']-$traffic_last_ifout)/$deltatime); - $traffic_last_ugmt = $timing; - $traffic_last_ifin = (double)$ifinfo['inbytes']; - $traffic_last_ifout = (double)$ifinfo['outbytes']; - } - - function formatSpeedBits($speed) { - /* format speed in bits/sec, input: bytes/sec - Code from: graph.php ported to PHP*/ - if ($speed < 125000) - {return sprintf("%5.1f Kbps", $speed / 125);} - if ($speed < 125000000) - {return sprintf("%5.1f Mbps", $speed / 125000);} - // else - return sprintf("%5.1f Gbps", $speed / 125000000); - } - - function add_summary_declaration(&$lcd_cmds, $name) { - $lcdpanel_height = get_lcdpanel_height(); - $lcdpanel_width = get_lcdpanel_width(); - if ($lcdpanel_height >= "4") - { - $lcd_cmds[] = "widget_add $name title_summary string"; - $lcd_cmds[] = "widget_add $name text_summary string"; - if ($lcdpanel_width > "16") - {$lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES FREQ\"";} - else - {$lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES\"";} - } - } - - function add_summary_values(&$lcd_cmds, $name, $lcd_summary_data) { - if ($lcd_summary_data != "") - { - $lcd_cmds[] = "widget_set $name text_summary 1 4 \"{$lcd_summary_data}\""; + return false; } } - - function build_interface($lcd) { - global $g; - global $config; - $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - $refresh_frequency = get_lcdpanel_refresh_frequency() * 8; - - $lcd_cmds = array(); - $lcd_cmds[] = "hello"; - $lcd_cmds[] = "client_set name pfSense"; - - /* process screens to display */ - if(is_array($lcdproc_screens_config)) { - foreach($lcdproc_screens_config as $name => $screen) { - if($screen == "on") { - switch($name) { - case "scr_version": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"Welcome to\""; - break; - case "scr_time": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Time\""; - break; - case "scr_uptime": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Uptime\""; - break; - case "scr_hostname": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Name\""; - break; - case "scr_system": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Stats\""; - break; - case "scr_disk": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Disk Use\""; - break; - case "scr_load": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Averages\""; - break; - case "scr_states": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Traffic States\""; - break; - case "scr_carp": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CARP State\""; - break; - case "scr_ipsec": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ IPsec Tunnels\""; - break; - case "scr_slbd": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Balancer\""; - break; - case "scr_interfaces": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Interfaces\""; - break; - case "scr_mbuf": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ MBuf Usage\""; - break; - case "scr_cpufrequency": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CPU Frequency\""; - break; - case "scr_traffic": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt string"; - break; - } - add_summary_declaration($lcd_cmds, $name); - } +} + +function outputled_carp() { + /* Returns the status of CARP for the box. + Assumes ALL CARP status are the same for all the intefaces. + -1 = CARP Disabled + 0 = CARP on Backup + 1 = CARP on Master */ + global $g; + global $config; + + if (is_array($config['virtualip']['vip'])) { + $carpint = 0; + foreach ($config['virtualip']['vip'] as $carp) { + if ($carp['mode'] != "carp") { + continue; } - } - send_lcd_commands($lcd, $lcd_cmds); - } - - function loop_status($lcd) { - global $g; - global $config; - global $lcdproc_connect_errors; - $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - $lcdpanel_width = get_lcdpanel_width(); - $lcdpanel_height = get_lcdpanel_height(); - if(empty($g['product_name'])) { - $g['product_name'] = "pfSense"; - } - - $refresh_frequency = get_lcdpanel_refresh_frequency(); - /* keep a counter to see how many times we can loop */ - $i = 1; - while($i) { - /* prepare the summary data */ - if ($lcdpanel_height >= "4") { - $summary_states = split("/",get_pfstate()); - $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]); - if ($lcdpanel_width > "16") { - $lcd_summary_data = $lcd_summary_data . sprintf(" %3d%%", get_cpufrequency_perc()); - } - } - else { - $lcd_summary_data = "";} - - $lcd_cmds = array(); - - /* initializes the widget counter */ - $widget_counter = 0; - - /* controls the output leds */ - if (outputled_enabled_CFontz633()) - { - $led_output_value = 0; - /* LED 1: Interface status */ - if (substr_count(get_interfaces_stats(), "Down") > 0 ) - {$led_output_value = $led_output_value + pow(2, 4);} - else - {$led_output_value = $led_output_value + pow(2, 0);} - /* LED 2: CARP status */ - switch (outputled_carp()) - { - case -1:/* CARP disabled */ - break; - case 0: /* CARP on Backup */ - $led_output_value = $led_output_value + pow(2, 1); + $carp_int = find_carp_interface($carp['subnet']); + $status = get_carp_interface_status($carp_int); + switch($status) { + case "MASTER": + return 1; break; - case 1: /* CARP on Master */ - $led_output_value = $led_output_value + pow(2, 5); - } - /* LED 3: CPU Usage */ - if (cpu_usage() > 50) - {$led_output_value = $led_output_value + pow(2, 6);} - else - {$led_output_value = $led_output_value + pow(2, 2);} - /* LED 4: Gateway status */ - switch (outputled_gateway()) - { - case -1:/* Gateways not configured */ - break; - case 0: /* Gateway down or with issues */ - $led_output_value = $led_output_value + pow(2, 7); + case "BACKUP": + return 0; break; - case 1: /* All Gateways up */ - $led_output_value = $led_output_value + pow(2, 3); - } - /* Sends the command to the panel */ - $lcd_cmds[] = "output {$led_output_value}"; } - - /* process screens to display */ - foreach((array) $lcdproc_screens_config as $name => $screen) { - if($screen != "on") { - continue; - } + } + } else { + return -1; + } +} + +function outputled_gateway() { + /* Returns the status of the gateways. + -1 = No gateway defined + 0 = At least 1 gateway down or with issues + 1 = All gateway up */ + global $g; + global $config; + $a_gateways = return_gateways_array(); + $gateways_status = array(); + $gateways_status = return_gateways_status(true); + foreach ($a_gateways as $gname => $gateway) { + if ($gateways_status[$gname]['status'] != "none") { + return 0; + } + } + return 1; +} + +function get_traffic_stats(&$in_data, &$out_data){ + global $config; + global $traffic_last_ugmt, $traffic_last_ifin, $traffic_last_ifout; + $lcdproc_screen_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + /* read the configured interface */ + $ifnum = $lcdproc_screen_config['scr_traffic_interface']; + /* get the real interface name (code from ifstats.php)*/ + $realif = get_real_interface($ifnum); + if (!$realif) { + $realif = $ifnum; + } + // Need for IPSec case interface. + /* get the interface stats (code from ifstats.php)*/ + $ifinfo = pfSense_get_interface_stats($realif); + /* get the current time (code from ifstats.php)*/ + $temp = gettimeofday(); + $timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0; + /* calculate the traffic stats */ + $deltatime = $timing - $traffic_last_ugmt; + $in_data = "IN: " . formatSpeedBits(((double)$ifinfo['inbytes']-$traffic_last_ifin)/$deltatime); + $out_data = "OUT: " . formatSpeedBits(((double)$ifinfo['outbytes']-$traffic_last_ifout)/$deltatime); + $traffic_last_ugmt = $timing; + $traffic_last_ifin = (double)$ifinfo['inbytes']; + $traffic_last_ifout = (double)$ifinfo['outbytes']; +} + +function formatSpeedBits($speed) { + /* format speed in bits/sec, input: bytes/sec + Code from: graph.php ported to PHP */ + if ($speed < 125000) { + return sprintf("%5.1f Kbps", $speed / 125); + } + if ($speed < 125000000) { + return sprintf("%5.1f Mbps", $speed / 125000); + } + return sprintf("%5.1f Gbps", $speed / 125000000); +} + +function add_summary_declaration(&$lcd_cmds, $name) { + $lcdpanel_height = get_lcdpanel_height(); + $lcdpanel_width = get_lcdpanel_width(); + if ($lcdpanel_height >= "4") { + $lcd_cmds[] = "widget_add $name title_summary string"; + $lcd_cmds[] = "widget_add $name text_summary string"; + if ($lcdpanel_width > "16") { + $lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES FREQ\""; + } else { + $lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES\""; + } + } +} + +function add_summary_values(&$lcd_cmds, $name, $lcd_summary_data) { + if ($lcd_summary_data != "") { + $lcd_cmds[] = "widget_set $name text_summary 1 4 \"{$lcd_summary_data}\""; + } +} + +function build_interface($lcd) { + global $g; + global $config; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + $refresh_frequency = get_lcdpanel_refresh_frequency() * 8; + + $lcd_cmds = array(); + $lcd_cmds[] = "hello"; + $lcd_cmds[] = "client_set name pfSense"; + + /* process screens to display */ + if (is_array($lcdproc_screens_config)) { + foreach ($lcdproc_screens_config as $name => $screen) { + if ($screen == "on") { switch($name) { case "scr_version": - $version = get_version(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$version}\""; - break; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"Welcome to\""; + break; case "scr_time": - $time = date("n/j/Y H:i"); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$time}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Time\""; break; case "scr_uptime": - $uptime = get_uptime_stats(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$uptime}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Uptime\""; break; case "scr_hostname": - exec("/bin/hostname", $output, $ret); - $hostname = $output[0]; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$hostname}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Name\""; break; case "scr_system": - $processor = cpu_usage(); - $memory = mem_usage(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"CPU {$processor}%, Mem {$memory}%\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Stats\""; break; case "scr_disk": - $disk = disk_usage(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Disk {$disk}%\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Disk Use\""; break; case "scr_load": - $loadavg = get_loadavg_stats(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$loadavg}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Averages\""; break; case "scr_states": - $states = get_pfstate(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Cur/Max {$states}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Traffic States\""; break; case "scr_carp": - $carp = get_carp_stats(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$carp}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CARP State\""; break; case "scr_ipsec": - $ipsec = get_ipsec_stats(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$ipsec}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ IPsec Tunnels\""; break; case "scr_slbd": - $slbd = get_slbd_stats(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$slbd}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Balancer\""; break; case "scr_interfaces": - $interfaces = get_interfaces_stats(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$interfaces}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Interfaces\""; break; case "scr_mbuf": - $mbufstats = get_mbuf_stats(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$mbufstats}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ MBuf Usage\""; break; case "scr_cpufrequency": - $cpufreq = get_cpufrequency(); - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$cpufreq}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CPU Frequency\""; break; case "scr_traffic": - get_traffic_stats($in_data, $out_data); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"{$in_data}\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 \"{$out_data}\""; - break; - } - if ($name != "scr_traffic_interface") { - $widget_counter++; - add_summary_values($lcd_cmds, $name, $lcd_summary_data); + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt string"; + break; } - } - if (send_lcd_commands($lcd, $lcd_cmds)) { - $lcdproc_connect_errors = 0; // Reset the error counter + add_summary_declaration($lcd_cmds, $name); } - else { //an error occurred - return; + } + } + send_lcd_commands($lcd, $lcd_cmds); +} + +function loop_status($lcd) { + global $g; + global $config; + global $lcdproc_connect_errors; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + $lcdpanel_width = get_lcdpanel_width(); + $lcdpanel_height = get_lcdpanel_height(); + if (empty($g['product_name'])) { + $g['product_name'] = "pfSense"; + } + + $refresh_frequency = get_lcdpanel_refresh_frequency(); + /* keep a counter to see how many times we can loop */ + $i = 1; + while ($i) { + /* prepare the summary data */ + if ($lcdpanel_height >= "4") { + $summary_states = explode("/", get_pfstate()); + $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]); + if ($lcdpanel_width > "16") { + $lcd_summary_data = $lcd_summary_data . sprintf(" %3d%%", get_cpufrequency_perc()); } - if (($refresh_frequency * $widget_counter) > 5) { - sleep(5); + } else { + $lcd_summary_data = ""; + } + + $lcd_cmds = array(); + + /* initializes the widget counter */ + $widget_counter = 0; + + /* controls the output leds */ + if (outputled_enabled_CFontz633()) { + $led_output_value = 0; + /* LED 1: Interface status */ + if (substr_count(get_interfaces_stats(), "Down") > 0 ) { + $led_output_value = $led_output_value + pow(2, 4); + } else { + $led_output_value = $led_output_value + pow(2, 0); } - else { - sleep($refresh_frequency * $widget_counter); + /* LED 2: CARP status */ + switch (outputled_carp()) { + /* CARP disabled */ + case -1: + break; + /* CARP on Backup */ + case 0: + $led_output_value = $led_output_value + pow(2, 1); + break; + /* CARP on Master */ + case 1: + $led_output_value = $led_output_value + pow(2, 5); } - $i++; + /* LED 3: CPU Usage */ + if (cpu_usage() > 50) { + $led_output_value = $led_output_value + pow(2, 6); + } else { + $led_output_value = $led_output_value + pow(2, 2); + } + /* LED 4: Gateway status */ + switch (outputled_gateway()) { + /* Gateways not configured */ + case -1: + break; + /* Gateway down or with issues */ + case 0: + $led_output_value = $led_output_value + pow(2, 7); + break; + /* All Gateways up */ + case 1: + $led_output_value = $led_output_value + pow(2, 3); + } + /* Sends the command to the panel */ + $lcd_cmds[] = "output {$led_output_value}"; + } + + /* process screens to display */ + foreach ((array) $lcdproc_screens_config as $name => $screen) { + if ($screen != "on") { + continue; + } + switch($name) { + case "scr_version": + $version = get_version(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$version}\""; + break; + case "scr_time": + $time = date("n/j/Y H:i"); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$time}\""; + break; + case "scr_uptime": + $uptime = get_uptime_stats(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$uptime}\""; + break; + case "scr_hostname": + exec("/bin/hostname", $output, $ret); + $hostname = $output[0]; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$hostname}\""; + break; + case "scr_system": + $processor = cpu_usage(); + $memory = mem_usage(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"CPU {$processor}%, Mem {$memory}%\""; + break; + case "scr_disk": + $disk = disk_usage(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Disk {$disk}%\""; + break; + case "scr_load": + $loadavg = get_loadavg_stats(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$loadavg}\""; + break; + case "scr_states": + $states = get_pfstate(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Cur/Max {$states}\""; + break; + case "scr_carp": + $carp = get_carp_stats(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$carp}\""; + break; + case "scr_ipsec": + $ipsec = get_ipsec_stats(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$ipsec}\""; + break; + case "scr_slbd": + $slbd = get_slbd_stats(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$slbd}\""; + break; + case "scr_interfaces": + $interfaces = get_interfaces_stats(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$interfaces}\""; + break; + case "scr_mbuf": + $mbufstats = get_mbuf_stats(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$mbufstats}\""; + break; + case "scr_cpufrequency": + $cpufreq = get_cpufrequency(); + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$cpufreq}\""; + break; + case "scr_traffic": + get_traffic_stats($in_data, $out_data); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"{$in_data}\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 \"{$out_data}\""; + break; + } + if ($name != "scr_traffic_interface") { + $widget_counter++; + add_summary_values($lcd_cmds, $name, $lcd_summary_data); + } + } + if (send_lcd_commands($lcd, $lcd_cmds)) { + $lcdproc_connect_errors = 0; // Reset the error counter + } else { + //an error occurred + return; } + if (($refresh_frequency * $widget_counter) > 5) { + sleep(5); + } else { + sleep($refresh_frequency * $widget_counter); + } + $i++; } - /* Initialize the wan traffic counters */ - $traffic_last_ugmt = 0; - $traffic_last_ifin = 0; - $traffic_last_ifout = 0; - /* Initialize the global error counter */ - $lcdproc_connect_errors = 0; - $lcdproc_max_connect_errors = 3; - /* Connect to the LCDd port and interface with the LCD */ - while ($lcdproc_connect_errors <= $lcdproc_max_connect_errors) - { - lcdproc_warn("Start client procedure. Error counter: ($lcdproc_connect_errors)"); - sleep(1); - $lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10); - stream_set_timeout($lcd, 0 , 25000); // Sets the socket timeout as 25ms - if (!$lcd) { - lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)"); - $lcdproc_connect_errors++; - } else { - /* Allow the script to run forever (0) */ - set_time_limit(0); - build_interface($lcd); - loop_status($lcd); - fclose($lcd); - } - } - if ($lcdproc_connect_errors >= $lcdproc_max_connect_errors) - { - lcdproc_warn("Too many errors, the client ends."); +} + +/* Initialize the wan traffic counters */ +$traffic_last_ugmt = 0; +$traffic_last_ifin = 0; +$traffic_last_ifout = 0; +/* Initialize the global error counter */ +$lcdproc_connect_errors = 0; +$lcdproc_max_connect_errors = 3; +/* Connect to the LCDd port and interface with the LCD */ +while ($lcdproc_connect_errors <= $lcdproc_max_connect_errors) { + lcdproc_warn("Start client procedure. Error counter: ($lcdproc_connect_errors)"); + sleep(1); + $lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10); + stream_set_timeout($lcd, 0 , 25000); // Sets the socket timeout as 25ms + if (!$lcd) { + lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)"); + $lcdproc_connect_errors++; + } else { + /* Allow the script to run forever (0) */ + set_time_limit(0); + build_interface($lcd); + loop_status($lcd); + fclose($lcd); } +} +if ($lcdproc_connect_errors >= $lcdproc_max_connect_errors) { + lcdproc_warn("Too many errors, the client ends."); +} ?> diff --git a/config/lcdproc-dev/lcdproc_screens.xml b/config/lcdproc-dev/lcdproc_screens.xml index 9f4a8e2e..c3ba7aa1 100644 --- a/config/lcdproc-dev/lcdproc_screens.xml +++ b/config/lcdproc-dev/lcdproc_screens.xml @@ -1,8 +1,51 @@ <?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[ +/* $Id$ */ +/* ====================================================================================== */ +/* + lcdproc_screens.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <title>Services: LCDproc: Screens</title> <name>lcdproc_screens</name> - <version>0.5.5 pkg v. 0.9.4</version> + <version>0.9.13</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/lcdproc.inc</include_file> <tabs> @@ -18,7 +61,7 @@ </tabs> <menu> <name>LCDproc</name> - <tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext> + <tooltiptext>Set LCDproc settings such as display driver and COM port.</tooltiptext> <section>Services</section> <url>/pkg_edit.php?xml=lcdproc.xml&id=0</url> </menu> @@ -27,7 +70,7 @@ <fielddescr>Enable Version</fielddescr> <fieldname>scr_version</fieldname> <type>checkbox</type> - </field> + </field> <field> <fielddescr>Enable Time</fielddescr> <fieldname>scr_time</fieldname> @@ -87,7 +130,7 @@ <fielddescr>Enable Mbuf</fielddescr> <fieldname>scr_mbuf</fieldname> <type>checkbox</type> - </field> + </field> <field> <fielddescr>Enable CPU Frequency</fielddescr> <fieldname>scr_cpufrequency</fieldname> @@ -103,14 +146,8 @@ <fieldname>scr_traffic_interface</fieldname> <type>interfaces_selection</type> <description>If Interface Traffic is enabled, here you specify which interface to monitor</description> - </field> + </field> </fields> - <custom_php_command_before_form> - before_form_lcdproc_screens($pkg); - </custom_php_command_before_form> - <custom_php_validation_command> - validate_form_lcdproc_screens($_POST, $input_errors); - </custom_php_validation_command> <custom_php_resync_config_command> sync_package_lcdproc_screens(); </custom_php_resync_config_command> diff --git a/config/lcdproc/lcdproc.inc b/config/lcdproc/lcdproc.inc index 2251618c..9aecfa3b 100644 --- a/config/lcdproc/lcdproc.inc +++ b/config/lcdproc/lcdproc.inc @@ -1,347 +1,323 @@ <?php -/* $Id$ */ /* - lcdproc.inc - Copyright (C) 2007 Seth Mos <seth.mos@dds.nl> - 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. + lcdproc.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + 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. */ - - require_once("config.inc"); - require_once("functions.inc"); - - /* LCDproc */ - define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); - define('LCDPROC_CLIENT', '/tmp/lcdclient.sh'); - $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); - if ($pfs_version == "2.1" || $pfs_version == "2.2") { - define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf'); - } else { - define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); +require_once("config.inc"); +require_once("functions.inc"); + +/* LCDproc */ +define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); +define('LCDPROC_CLIENT', '/tmp/lcdclient.sh'); +$pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pfs_version == "2.1" || $pfs_version == "2.2") { + define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf'); +} else { + define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); +} +define('LCDPROC_HOST','127.0.0.1'); +define('LCDPROC_PORT','13666'); + +function lcdproc_notice ($msg) { + syslog(LOG_NOTICE, "lcdproc: {$msg}"); +} + +function lcdproc_warn ($msg) { + syslog(LOG_WARNING, "lcdproc: {$msg}"); +} + +function lcdproc_write_config($file, $text) { + $handle = fopen($file, 'w'); + if (!$handle) { + lcdproc_warn("Could not open {$file} for writing."); + exit; } - define('LCDPROC_HOST','127.0.0.1'); - define('LCDPROC_PORT','13666'); - - function lcdproc_notice ($msg) { syslog(LOG_NOTICE, "lcdproc: {$msg}"); } - function lcdproc_warn ($msg) { syslog(LOG_WARNING, "lcdproc: {$msg}"); } - - function lcdproc_action ($action) { - if (file_exists(LCDPROC_RCFILE)) - mwexec(LCDPROC_RCFILE.' '.$action); + fwrite($handle, $text); + fclose($handle); +} + +function lcdproc_write_script($file, $text) { + $handle = fopen($file, 'wx'); + if (!$handle) { + lcdproc_warn("Could not open {$file} for writing."); + exit; } - - function lcdproc_running () { - if((int)exec('pgrep LCDd | wc -l') > 0) - return true; - return false; - } - - function lcdproc_write_config($file, $text) { - $handle = fopen($file, 'w'); - if(!$handle) { - lcdproc_warn("Could not open {$file} for writing."); - exit; + fwrite($handle, $text); + fclose($handle); + chmod($file, 0755); +} + +function validate_form_lcdproc($post, &$input_errors) { + if ($post['comport']) { + switch ($post['comport']) { + case "none": + continue; + break; + case "com2": + continue; + break; + case "ucom1": + continue; + break; + case "ucom2": + continue; + break; + case "lpt1": + continue; + break; + case "ugen0.2": + continue; + break; + case "ugen1.2": + continue; + break; + case "ugen2.2": + continue; + break; + default: + $input_errors[] = "The chosen com port is not valid"; + break; } - fwrite($handle, $text); - fclose($handle); } - - function lcdproc_write_script($file, $text) { - $handle = fopen($file, 'wx'); - if(!$handle) { - lcdproc_warn("Could not open {$file} for writing."); - exit; + if ($post['size']) { + switch ($post['size']) { + case "12x1": + continue; + break; + case "12x2": + continue; + break; + case "12x4": + continue; + break; + case "16x1": + continue; + break; + case "16x2": + continue; + break; + case "16x4": + continue; + break; + case "20x1": + continue; + break; + case "20x2": + continue; + break; + case "20x4": + continue; + break; + default: + $input_errors[] = "The chosen display size is not valid"; + break; } - fwrite($handle, $text); - fclose($handle); - chmod($file, 0755); - } - - function before_form_lcdproc(&$pkg) { - global $config; - - config_lock(); - - config_unlock(); - } - - function before_form_lcdproc_screens(&$pkg) { - global $config; - - config_lock(); - - config_unlock(); } - - function validate_form_lcdproc($post, &$input_errors) { - if($post['comport']) { - switch($post['comport']) { - case "none": - continue; - break; - case "com2": - continue; - break; - case "ucom1": - continue; - break; - case "ucom2": - continue; - break; - case "lpt1": - continue; - break; - case "ugen0.2": - continue; - break; - case "ugen1.2": - continue; - break; - case "ugen2.2": - continue; - break; - default: - $input_errors[] = "The chosen com port is not valid"; - break; - } +} + +function sync_package_lcdproc_screens() { + sync_package_lcdproc(); +} + +function sync_package_lcdproc() { + global $g; + global $config; + global $input_errors; + + $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + + /* Since config is written before this file invoked, we don't need to read post data */ + if ($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { + switch ($lcdproc_config['comport']) { + case "com2": + $realport = "/dev/cua1"; + break; + case "ucom1": + $realport = "/dev/cuaU0"; + break; + case "ucom2": + $realport = "/dev/cuaU1"; + break; + case "lpt1": + $realport = "/dev/lpt0"; + break; + case "ugen0.2": + $realport = "/dev/ugen0.2"; + break; + case "ugen1.2": + $realport = "/dev/ugen1.2"; + break; + case "ugen2.2": + $realport = "/dev/ugen2.2"; + break; + default: + lcdproc_warn("The selected com port is not valid!"); + return; } - if($post['size']) { - switch($post['size']) { - case "12x1": - continue; - break; - case "12x2": - continue; - break; - case "12x4": - continue; - break; - case "16x1": - continue; - break; - case "16x2": - continue; - break; - case "16x4": - continue; - break; - case "20x1": - continue; - break; - case "20x2": - continue; - break; - case "20x4": - continue; - break; - default: - $input_errors[] = "The chosen display size is not valid"; - break; - } - } - } - function validate_form_lcdproc_screens($post, &$input_errors) { - // No validation required ?! - } - - function sync_package_lcdproc_screens() { - sync_package_lcdproc(); - } - function sync_package_lcdproc() { - global $g; - global $config; - global $input_errors; - - config_lock(); - - $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; - $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - - /* since config is written before this file invoked we don't need to read post data */ - if($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { - switch($lcdproc_config['comport']) { - case "com2": - $realport = "/dev/cua1"; - break; - case "ucom1": - $realport = "/dev/cuaU0"; - break; - case "ucom2": - $realport = "/dev/cuaU1"; - break; - case "lpt1": - $realport = "/dev/lpt0"; - break; - case "ugen0.2": - $realport = "/dev/ugen0.2"; - break; - case "ugen1.2": - $realport = "/dev/ugen1.2"; - break; - case "ugen2.2": - $realport = "/dev/ugen2.2"; - break; - default: - lcdproc_warn("The selected com port is not valid!"); - return; - } - - $config_text = "[server]\n"; - $config_text .= "Driver={$lcdproc_config[driver]}\n"; - $config_text .= "Bind=127.0.0.1\n"; - $config_text .= "Port=13666\n"; - $config_text .= "ReportLevel=3\n"; - $config_text .= "ReportToSyslog=yes\n"; - $config_text .= "WaitTime=5\n"; - $config_text .= "User=nobody\n"; - $config_text .= "ServerScreen=no\n"; - $config_text .= "Foreground=no\n"; - $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; - $config_text .= "GoodBye=\"Thanks for using\"\n"; - $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; - /* FIXME: Specific to the pyramid project */ - $config_text .= "ToggleRotateKey=Enter\n"; - $config_text .= "PrevScreenKey=Left\n"; - $config_text .= "NextScreenKey=Right\n"; - $config_text .= "ScrollUpKey=Up\n"; - $config_text .= "ScrollDownKey=Down\n"; - /* FIXME: pyramid test menu */ - $config_text .= "[menu]\n"; - $config_text .= "MenuKey=Escape\n"; - $config_text .= "EnterKey=Enter\n"; - $config_text .= "UpKey=Up\n"; - $config_text .= "DownKey=Down\n"; - /* lcdproc default driver definitions */ - switch($lcdproc_config[driver]) { - case "SureElec": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Edition=2\n"; - $config_text .= "Contrast=200\n"; - $config_text .= "Brightness=480\n"; - $config_text .= "Speed=19200\n"; - break; - case "nexcom": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "bayrad": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Speed=9600\n"; - break; - case "picolcd": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "KeyTimeout=500\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "Blacklight_Timer=60\n"; - $config_text .= "Contrast=1000\n"; - $config_text .= "Keylights=on\n"; - $config_text .= "Key0Light=on\n"; - $config_text .= "Key1Light=off\n"; - $config_text .= "Key2Light=off\n"; - $config_text .= "Key3Light=off\n"; - $config_text .= "Key4Light=off\n"; - $config_text .= "Key5Light=off\n"; - break; - case "CFontz": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Contrast=350\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "OffBrightness=50\n"; - $config_text .= "Speed=9600\n"; - $config_text .= "NewFirmware=no\n"; - $config_text .= "Reboot=no\n"; - break; - case "CFontz633": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Contrast=350\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "OffBrightness=50\n"; - $config_text .= "Speed=19200\n"; - $config_text .= "NewFirmware=yes\n"; - $config_text .= "Reboot=yes\n"; - break; - case "CFontzPacket": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Model=635\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Contrast=350\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "OffBrightness=50\n"; - $config_text .= "Speed=115200\n"; - $config_text .= "NewFirmware=yes\n"; - $config_text .= "Reboot=yes\n"; - break; - case "curses": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Foreground=blue\n"; - $config_text .= "Background=cyan\n"; - $config_text .= "Backlight=red\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "TopLeftX=7\n"; - $config_text .= "TopLeftY=7\n"; - $config_text .= "UseACS=no\n"; - break; - case "CwLynx": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Model=12232\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Speed=19200\n"; - $config_text .= "Reboot=no\n"; - break; - case "pyramid": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "ea65": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "OffBrightness=0\n"; - $config_text .= "Brightness=500\n"; - break; - default: - lcdproc_warn("The chosen lcdproc driver is not a valid choice"); - unset($lcdproc_config[driver]); - } + $config_text = "[server]\n"; + $config_text .= "Driver={$lcdproc_config[driver]}\n"; + $config_text .= "Bind=127.0.0.1\n"; + $config_text .= "Port=13666\n"; + $config_text .= "ReportLevel=3\n"; + $config_text .= "ReportToSyslog=yes\n"; + $config_text .= "WaitTime=5\n"; + $config_text .= "User=nobody\n"; + $config_text .= "ServerScreen=no\n"; + $config_text .= "Foreground=no\n"; + $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; + $config_text .= "GoodBye=\"Thanks for using\"\n"; + $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; + /* FIXME: Specific to the pyramid project */ + $config_text .= "ToggleRotateKey=Enter\n"; + $config_text .= "PrevScreenKey=Left\n"; + $config_text .= "NextScreenKey=Right\n"; + $config_text .= "ScrollUpKey=Up\n"; + $config_text .= "ScrollDownKey=Down\n"; + /* FIXME: pyramid test menu */ + $config_text .= "[menu]\n"; + $config_text .= "MenuKey=Escape\n"; + $config_text .= "EnterKey=Enter\n"; + $config_text .= "UpKey=Up\n"; + $config_text .= "DownKey=Down\n"; + + /* lcdproc default driver definitions */ + switch ($lcdproc_config[driver]) { + case "SureElec": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Edition=2\n"; + $config_text .= "Contrast=200\n"; + $config_text .= "Brightness=480\n"; + $config_text .= "Speed=19200\n"; + break; + case "nexcom": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "bayrad": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Speed=9600\n"; + break; + case "picolcd": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "KeyTimeout=500\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "Blacklight_Timer=60\n"; + $config_text .= "Contrast=1000\n"; + $config_text .= "Keylights=on\n"; + $config_text .= "Key0Light=on\n"; + $config_text .= "Key1Light=off\n"; + $config_text .= "Key2Light=off\n"; + $config_text .= "Key3Light=off\n"; + $config_text .= "Key4Light=off\n"; + $config_text .= "Key5Light=off\n"; + break; + case "CFontz": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Contrast=350\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "OffBrightness=50\n"; + $config_text .= "Speed=9600\n"; + $config_text .= "NewFirmware=no\n"; + $config_text .= "Reboot=no\n"; + break; + case "CFontz633": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Contrast=350\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "OffBrightness=50\n"; + $config_text .= "Speed=19200\n"; + $config_text .= "NewFirmware=yes\n"; + $config_text .= "Reboot=yes\n"; + break; + case "CFontzPacket": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Model=635\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Contrast=350\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "OffBrightness=50\n"; + $config_text .= "Speed=115200\n"; + $config_text .= "NewFirmware=yes\n"; + $config_text .= "Reboot=yes\n"; + break; + case "curses": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Foreground=blue\n"; + $config_text .= "Background=cyan\n"; + $config_text .= "Backlight=red\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "TopLeftX=7\n"; + $config_text .= "TopLeftY=7\n"; + $config_text .= "UseACS=no\n"; + break; + case "CwLynx": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Model=12232\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Speed=19200\n"; + $config_text .= "Reboot=no\n"; + break; + case "pyramid": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "ea65": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "OffBrightness=0\n"; + $config_text .= "Brightness=500\n"; + break; + default: + lcdproc_warn("The chosen lcdproc driver is not a valid choice"); + unset($lcdproc_config[driver]); + } - /* generate rc file start and stop */ - $client_script = <<<EOD + /* Generate rc file start and stop */ + $client_script = <<<EOD #!/bin/sh # script starts a lcd client and always keeps it active. @@ -355,8 +331,8 @@ done EOD; - /* generate rc file start and stop */ - $stop = <<<EOD + /* Generate rc file start and stop */ + $stop = <<<EOD if [ `ps auxw |awk '/LCD[d]/ {print $2}'| wc -l` != 0 ]; then ps auxw |awk '/LCD[d]/ {print $2}'|xargs kill @@ -368,47 +344,47 @@ if [ `ps auxw |awk '/lcdclient.s[h]/ {print $2}'| wc -l` != 0 ]; then fi EOD; - $start = $stop ."\n"; - $start .= "\t/usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ."\n"; - $start .= "\t". LCDPROC_CLIENT ." &\n"; - - /* write out the configuration */ - conf_mount_rw(); - lcdproc_write_script(LCDPROC_CLIENT, $client_script); - lcdproc_write_config(LCDPROC_CONFIG, $config_text); - write_rcfile(array( - 'file' => 'lcdproc.sh', - 'start' => $start, - 'stop' => $stop - )); - conf_mount_ro(); - /* or restart lcdproc if settings were changed */ - if(lcdproc_running($_POST['comport'])) { - lcdproc_notice("Restarting service lcdproc"); - lcdproc_action('restart'); - } + $start = $stop ."\n"; + $start .= "\t/usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ."\n"; + $start .= "\t". LCDPROC_CLIENT ." &\n"; + + /* Write out the configuration */ + conf_mount_rw(); + lcdproc_write_script(LCDPROC_CLIENT, $client_script); + lcdproc_write_config(LCDPROC_CONFIG, $config_text); + write_rcfile(array( + 'file' => 'lcdproc.sh', + 'start' => $start, + 'stop' => $stop + )); + conf_mount_ro(); + + /* Or restart lcdproc if settings were changed */ + if (is_process_running("LCDd") && ($_POST['comport'] != "")) { + lcdproc_notice("Restarting service lcdproc"); + restart_service("lcdproc"); } + } - if((! $lcdproc_config['driver']) || ($lcdproc_config['comport'] == "none")) { - /* no parameters user does not want lcdproc running */ - /* lets stop the service and remove the rc file */ + if ((! $lcdproc_config['driver']) || ($lcdproc_config['comport'] == "none")) { + /* No parameters - user does not want lcdproc running */ + /* Let's stop the service and remove the rc file */ - if(file_exists(LCDPROC_RCFILE)) { - if(!$lcdproc_config['enable']) { - lcdproc_notice('Stopping service: lcdproc disabled'); - } else { - lcdproc_notice('Stopping service: no com port selected'); - } - lcdproc_action('stop'); - conf_mount_rw(); - unlink(LCDPROC_RCFILE); - unlink(LCDPROC_CLIENT); - unlink(LCDPROC_CONFIG); - conf_mount_ro(); + if (file_exists(LCDPROC_RCFILE)) { + if (!$lcdproc_config['enable']) { + lcdproc_notice('Stopping service: lcdproc disabled'); + } else { + lcdproc_notice('Stopping service: no com port selected'); } + stop_service("lcdproc"); + conf_mount_rw(); + unlink(LCDPROC_RCFILE); + unlink(LCDPROC_CLIENT); + unlink(LCDPROC_CONFIG); + conf_mount_ro(); } - config_unlock(); } +} ?> diff --git a/config/lcdproc/lcdproc.xml b/config/lcdproc/lcdproc.xml index 8f268b49..4f109e47 100644 --- a/config/lcdproc/lcdproc.xml +++ b/config/lcdproc/lcdproc.xml @@ -1,8 +1,51 @@ <?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[ +/* $Id$ */ +/* ====================================================================================== */ +/* + lcdproc.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <title>Services: LCDproc</title> <name>lcdproc</name> - <version>0.5.5 pkg.v.1.0.1</version> + <version>1.0.3</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/lcdproc.inc</include_file> <tabs> @@ -18,44 +61,41 @@ </tabs> <menu> <name>LCDproc</name> - <tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext> + <tooltiptext>Set LCDproc settings such as display driver and COM port.</tooltiptext> <section>Services</section> <url>/pkg_edit.php?xml=lcdproc.xml&id=0</url> </menu> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/lcdproc/lcdproc.inc</item> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/pkg/</prefix> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/lcdproc/lcdproc_screens.xml</item> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/pkg/</prefix> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/lcdproc/lcdproc_client.php</item> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/pkg/</prefix> </additional_files_needed> <additional_files_needed> <item>https://files.pfsense.org/packages/lcdproc/nexcom.so</item> - <prefix>/usr/local/lib/lcdproc/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/lib/lcdproc/</prefix> + <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://files.pfsense.org/packages/lcdproc/SureElec.so</item> - <prefix>/usr/local/lib/lcdproc/</prefix> - <chmod>0755</chmod> - </additional_files_needed> + <prefix>/usr/local/lib/lcdproc/</prefix> + <chmod>0755</chmod> + </additional_files_needed> <additional_files_needed> <item>https://files.pfsense.org/packages/lcdproc/picolcd.so</item> - <prefix>/usr/local/lib/lcdproc/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/lib/lcdproc/</prefix> + <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://files.pfsense.org/packages/lcdproc/libusb.so.2</item> - <prefix>/usr/local/lib/lcdproc/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/lib/lcdproc/</prefix> + <chmod>0755</chmod> </additional_files_needed> <service> <name>lcdproc</name> @@ -71,8 +111,8 @@ </field> <field> <fieldname>comport</fieldname> - <fielddescr>Com Port</fielddescr> - <description>Set the com port LCDproc should use.</description> + <fielddescr>COM Port</fielddescr> + <description>Set the COM port LCDproc should use.</description> <type>select</type> <options> <option> @@ -81,15 +121,15 @@ </option> <option> <value>com2</value> - <name>Serial Com port 2 (/dev/cua1)</name> + <name>Serial COM port 2 (/dev/cua1)</name> </option> <option> <value>ucom1</value> - <name>USB Com port 1 (/dev/cuaU0)</name> + <name>USB COM port 1 (/dev/cuaU0)</name> </option> <option> <value>ucom2</value> - <name>USB Com port 2 (/dev/cuaU1)</name> + <name>USB COM port 2 (/dev/cuaU1)</name> </option> <option> <value>lpt1</value> @@ -97,16 +137,16 @@ </option> <option> <value>ugen0.2</value> - <name>USB Com port 1 alternate (/dev/ugen0.2)</name> - </option> + <name>USB COM port 1 alternate (/dev/ugen0.2)</name> + </option> <option> <value>ugen1.2</value> - <name>USB Com port 2 alternate (/dev/ugen1.2)</name> + <name>USB COM port 2 alternate (/dev/ugen1.2)</name> </option> <option> <value>ugen2.2</value> - <name>USB Com port 3 alternate (/dev/ugen2.2)</name> - </option> + <name>USB COM port 3 alternate (/dev/ugen2.2)</name> + </option> </options> <default_value>ucom1</default_value> </field> @@ -272,7 +312,7 @@ <option> <value>pyramid</value> <name>pyramid</name> - </option> + </option> <option> <value>picolcd</value> <name>picolcd</name> @@ -304,7 +344,7 @@ <option> <value>SureElec</value> <name>SureElec</name> - </option> + </option> <option> <value>svga</value> <name>svga</name> @@ -335,7 +375,7 @@ <field> <fieldname>refresh_frequency</fieldname> <fielddescr>Refresh frequency</fielddescr> - <description>Set the refresh frequency of the information on the LCD Panel</description> + <description>Set the refresh frequency of the information on the LCD Panel.</description> <type>select</type> <options> <option> @@ -360,11 +400,8 @@ </option> </options> <default_value>5</default_value> - </field> + </field> </fields> - <custom_php_command_before_form> - before_form_lcdproc($pkg); - </custom_php_command_before_form> <custom_php_validation_command> validate_form_lcdproc($_POST, $input_errors); </custom_php_validation_command> diff --git a/config/lcdproc/lcdproc_client.php b/config/lcdproc/lcdproc_client.php index 464d6260..70bd0840 100644 --- a/config/lcdproc/lcdproc_client.php +++ b/config/lcdproc/lcdproc_client.php @@ -1,721 +1,705 @@ <?php -/* $Id$ */ /* - lcdproc_client.php - Copyright (C) 2007 Seth Mos <seth.mos@dds.nl> - 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. + lcdproc_client.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + 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. */ - - /* trick interface into running this. we are only - * calling from useland so this is not a security issue - */ - require_once("config.inc"); - require_once("functions.inc"); - require_once("/usr/local/pkg/lcdproc.inc"); - - function get_pfstate() { - global $config; - $matches = ""; - if (isset($config['system']['maximumstates']) and $config['system']['maximumstates'] > 0) - $maxstates="/{$config['system']['maximumstates']}"; - else - $maxstates="/10000"; - - $curentries = `/sbin/pfctl -si |grep current`; - if (preg_match("/([0-9]+)/", $curentries, $matches)) { - $curentries = $matches[1]; - } - return $curentries . $maxstates; +require_once("config.inc"); +require_once("functions.inc"); +require_once("/usr/local/pkg/lcdproc.inc"); + +function get_pfstate() { + global $config; + $matches = ""; + if (isset($config['system']['maximumstates']) and $config['system']['maximumstates'] > 0) { + $maxstates = "/{$config['system']['maximumstates']}"; + } else { + $maxstates = "/10000"; } - - function disk_usage() { - $dfout = ""; - exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout); - $diskusage = trim($dfout[0]); - - return $diskusage; + $curentries = shell_exec('/sbin/pfctl -si | /usr/bin/grep current'); + if (preg_match("/([0-9]+)/", $curentries, $matches)) { + $curentries = $matches[1]; } - - function mem_usage() { - $memory = ""; - exec("/sbin/sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_inactive_count " . - "vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $memory); - - $totalMem = $memory[0]; - $availMem = $memory[1] + $memory[2] + $memory[3]; - $usedMem = $totalMem - $availMem; - $memUsage = round(($usedMem * 100) / $totalMem, 0); - - return $memUsage; + return $curentries . $maxstates; +} + +function disk_usage() { + $dfout = ""; + exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout); + $diskusage = trim($dfout[0]); + return $diskusage; +} + +function mem_usage() { + $memory = ""; + exec("/sbin/sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_inactive_count " . + "vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $memory); + + $totalMem = $memory[0]; + $availMem = $memory[1] + $memory[2] + $memory[3]; + $usedMem = $totalMem - $availMem; + $memUsage = round(($usedMem * 100) / $totalMem, 0); + return $memUsage; +} + +/* Calculates non-idle CPU time and returns as a percentage */ +function cpu_usage() { + $duration = 1; + $diff = array('user', 'nice', 'sys', 'intr', 'idle'); + $cpuTicks = array_combine($diff, explode(" ", shell_exec('/sbin/sysctl -n kern.cp_time'))); + sleep($duration); + $cpuTicks2 = array_combine($diff, explode(" ", shell_exec('/sbin/sysctl -n kern.cp_time'))); + + $totalStart = array_sum($cpuTicks); + $totalEnd = array_sum($cpuTicks2); + + // Something wrapped ?!?! + if ($totalEnd <= $totalStart) { + return 0; } - /*function array_combine($arr1, $arr2) { - $out = array(); + // Calculate total cycles used + $totalUsed = ($totalEnd - $totalStart) - ($cpuTicks2['idle'] - $cpuTicks['idle']); - $arr1 = array_values($arr1); - $arr2 = array_values($arr2); - - foreach($arr1 as $key1 => $value1) { - $out[(string)$value1] = $arr2[$key1]; - } + // Calculate the percentage used + $cpuUsage = floor(100 * ($totalUsed / ($totalEnd - $totalStart))); + return $cpuUsage; +} - return $out; - }*/ - - /* Calculates non-idle CPU time and returns as a percentage */ - function cpu_usage() { - $duration = 1; - $diff = array('user', 'nice', 'sys', 'intr', 'idle'); - $cpuTicks = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`)); - sleep($duration); - $cpuTicks2 = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`)); - - $totalStart = array_sum($cpuTicks); - $totalEnd = array_sum($cpuTicks2); - - // Something wrapped ?!?! - if ($totalEnd <= $totalStart) - return 0; - - // Calculate total cycles used - $totalUsed = ($totalEnd - $totalStart) - ($cpuTicks2['idle'] - $cpuTicks['idle']); - - // Calculate the percentage used - $cpuUsage = floor(100 * ($totalUsed / ($totalEnd - $totalStart))); - - return $cpuUsage; +function get_uptime_stats() { + exec("/usr/bin/uptime", $output, $ret); + if (stristr($output[0], "day")) { + $temp = explode(" ", $output[0]); + $status = "$temp[2] $temp[3] $temp[4] $temp[5] $temp[6] $temp[7] ". substr($temp[8], 0, -1); + } else { + $temp = explode(" ", $output[0]); + $status = "$temp[2] $temp[3] $temp[4] $temp[5] $temp[6] ". substr($temp[7], 0, -1); } - - function get_uptime_stats() { - exec("/usr/bin/uptime", $output, $ret); - if(stristr($output[0], "day")) { - $temp = explode(" ", $output[0]); - $status = "$temp[2] $temp[3] $temp[4] $temp[5] $temp[6] $temp[7] ". substr($temp[8], 0, -1); + return($status); +} + +function get_loadavg_stats() { + exec("/usr/bin/uptime", $output, $ret); + if (stristr($output[0], "day")) { + $temp = explode(" ", $output[0]); + $status = "$temp[11] $temp[12] $temp[13]"; + } else { + $temp = explode(" ", $output[0]); + $status = "$temp[10] $temp[11] $temp[12]"; + } + return($status); +} + +function get_mbuf_stats() { + exec("/usr/bin/netstat -mb | /usr/bin/grep \"mbufs in use\" | /usr/bin/awk '{ print $1 }' | /usr/bin/cut -d\"/\" -f1", $mbufs_inuse); + exec("/usr/bin/netstat -mb | /usr/bin/grep \"mbufs in use\" | /usr/bin/awk '{ print $1 }' | /usr/bin/cut -d\"/\" -f3", $mbufs_total); + $status = "$mbufs_inuse[0] \/ $mbufs_total[0]"; + + return($status); +} + +function get_cpufrequency() { + $cpufreqs = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); + $cpufreqs = explode(" ", trim($cpufreqs[0])); + $maxfreq = explode("/", $cpufreqs[0]); + $maxfreq = $maxfreq[0]; + $curfreq = ""; + exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); + $curfreq = trim($curfreq[0]); + $status = "$curfreq\/$maxfreq Mhz"; + return($status); +} + +function get_interfaces_stats() { + global $g; + global $config; + $ifstatus = array(); + $i = 0; + $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); + for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { + $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; + } + foreach ($ifdescrs as $ifdescr => $ifname) { + $ifinfo = get_interface_info($ifdescr); + if ($ifinfo['status'] == "up") { + $online = "Up"; } else { - $temp = explode(" ", $output[0]); - $status = "$temp[2] $temp[3] $temp[4] $temp[5] $temp[6] ". substr($temp[7], 0, -1); + $online = "Down"; } - return($status); - } - - function get_loadavg_stats() { - exec("/usr/bin/uptime", $output, $ret); - if(stristr($output[0], "day")) { - $temp = explode(" ", $output[0]); - $status = "$temp[11] $temp[12] $temp[13]"; + if (!empty($ifinfo['ipaddr'])) { + $ip = htmlspecialchars($ifinfo['ipaddr']); } else { - $temp = explode(" ", $output[0]); - $status = "$temp[10] $temp[11] $temp[12]"; + $ip = "-"; } - return($status); + $ifstatus[] = htmlspecialchars($ifname) ." [$online]"; } - - function get_mbuf_stats() { - exec("netstat -mb | grep \"mbufs in use\" | awk '{ print $1 }' | cut -d\"/\" -f1", $mbufs_inuse); - exec("netstat -mb | grep \"mbufs in use\" | awk '{ print $1 }' | cut -d\"/\" -f3", $mbufs_total); - $status = "$mbufs_inuse[0] \/ $mbufs_total[0]"; - return($status); + $status = " ". implode(", ", $ifstatus); + return($status); +} + +function get_slbd_stats() { + global $g; + global $config; + + if (!is_array($config['load_balancer']['lbpool'])) { + $config['load_balancer']['lbpool'] = array(); } - - function get_cpufrequency(){ - $cpufreqs = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs); - $cpufreqs = explode(" ", trim($cpufreqs[0])); - $maxfreq = explode("/", $cpufreqs[0]); - $maxfreq = $maxfreq[0]; - $curfreq = ""; - exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq); - $curfreq = trim($curfreq[0]); - $status = "$curfreq\/$maxfreq Mhz"; - return($status); + $a_pool = &$config['load_balancer']['lbpool']; + + $slbd_logfile = "{$g['varlog_path']}/slbd.log"; + + $nentries = $config['syslog']['nentries']; + if (!$nentries) { + $nentries = 50; } - function get_interfaces_stats() { - global $g; - global $config; - $ifstatus = array(); - $i = 0; - $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { - $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; - } - foreach ($ifdescrs as $ifdescr => $ifname){ - $ifinfo = get_interface_info($ifdescr); - if($ifinfo['status'] == "up") { - $online = "Up"; - } else { - $online = "Down"; - } - if(!empty($ifinfo['ipaddr'])) { - $ip = htmlspecialchars($ifinfo['ipaddr']); + $now = time(); + $year = date("Y"); + $pstatus = ""; + $i = 0; + foreach ($a_pool as $vipent) { + $pstatus[] = "{$vipent['name']}"; + if ($vipent['type'] == "gateway") { + $poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool"; + if (file_exists("$poolfile")) { + $poolstatus = file_get_contents("$poolfile"); } else { - $ip = "-"; + continue; } - $ifstatus[] = htmlspecialchars($ifname) ." [$online]"; - } - $status = " ". implode(", ", $ifstatus); - return($status); - } - - function get_slbd_stats() { - global $g; - global $config; - - if (!is_array($config['load_balancer']['lbpool'])) { - $config['load_balancer']['lbpool'] = array(); - } - $a_pool = &$config['load_balancer']['lbpool']; - - $slbd_logfile = "{$g['varlog_path']}/slbd.log"; - - $nentries = $config['syslog']['nentries']; - if (!$nentries) - $nentries = 50; - - $now = time(); - $year = date("Y"); - $pstatus = ""; - $i = 0; - foreach ($a_pool as $vipent) { - $pstatus[] = "{$vipent['name']}"; - if ($vipent['type'] == "gateway") { - $poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool"; - if(file_exists("$poolfile")) { - $poolstatus = file_get_contents("$poolfile"); + foreach ((array) $vipent['servers'] as $server) { + $lastchange = ""; + $svr = explode("|", $server); + $monitorip = $svr[1]; + if (stristr($poolstatus, $monitorip)) { + $online = "Up"; } else { - continue; - } - foreach ((array) $vipent['servers'] as $server) { - $lastchange = ""; - $svr = split("\|", $server); - $monitorip = $svr[1]; - if(stristr($poolstatus, $monitorip)) { - $online = "Up"; - } else { - $online = "Down"; - } - $pstatus[] = strtoupper($svr[0]) ." [{$online}]"; + $online = "Down"; } - } else { - $pstatus[] = "{$vipent['monitor']}"; + $pstatus[] = strtoupper($svr[0]) ." [{$online}]"; } + } else { + $pstatus[] = "{$vipent['monitor']}"; } - if(count($a_pool) == 0) { - $pstatus[] = "Disabled"; - } - $status = implode(", ", $pstatus); - return($status); } - - function get_carp_stats () { - global $g; - global $config; - - if(is_array($config['virtualip']['vip'])) { - $carpint = 0; - $initcount = 0; - $mastercount = 0; - $backupcount = 0; - foreach($config['virtualip']['vip'] as $carp) { - if ($carp['mode'] != "carp") { - continue; - } - $ipaddress = $carp['subnet']; - $password = $carp['password']; - $netmask = $carp['subnet_bits']; - $vhid = $carp['vhid']; - $advskew = $carp['advskew']; - $carp_int = find_carp_interface($ipaddress); - $status = get_carp_interface_status($carp_int); - switch($status) { - case "MASTER": - $mastercount++; - break; - case "BACKUP": - $backupcount++; - break; - case "INIT": - $initcount++; - break; - } + if (count($a_pool) == 0) { + $pstatus[] = "Disabled"; + } + $status = implode(", ", $pstatus); + return($status); +} + +function get_carp_stats () { + global $g; + global $config; + + if (is_array($config['virtualip']['vip'])) { + $carpint = 0; + $initcount = 0; + $mastercount = 0; + $backupcount = 0; + foreach ($config['virtualip']['vip'] as $carp) { + if ($carp['mode'] != "carp") { + continue; + } + $ipaddress = $carp['subnet']; + $password = $carp['password']; + $netmask = $carp['subnet_bits']; + $vhid = $carp['vhid']; + $advskew = $carp['advskew']; + $carp_int = find_carp_interface($ipaddress); + $status = get_carp_interface_status($carp_int); + switch($status) { + case "MASTER": + $mastercount++; + break; + case "BACKUP": + $backupcount++; + break; + case "INIT": + $initcount++; + break; } - $status = "M/B/I {$mastercount}/{$backupcount}/{$initcount}"; - } else { - $status = "CARP Disabled"; } - return($status); + $status = "M/B/I {$mastercount}/{$backupcount}/{$initcount}"; + } else { + $status = "CARP Disabled"; } + return($status); +} - function get_ipsec_tunnel_sad() { - /* query SAD */ - if(file_exists("/usr/local/sbin/setkey")) - $fd = @popen("/usr/local/sbin/setkey -D", "r"); - else - $fd = @popen("/sbin/setkey -D", "r"); - $sad = array(); - if ($fd) { - while (!feof($fd)) { - $line = chop(fgets($fd)); - if (!$line) - continue; - if ($line == "No SAD entries.") - break; - if ($line[0] != "\t") { - if (is_array($cursa)) - $sad[] = $cursa; - $cursa = array(); - list($cursa['src'],$cursa['dst']) = explode(" ", $line); - $i = 0; - } else { - $linea = explode(" ", trim($line)); - if ($i == 1) { - $cursa['proto'] = $linea[0]; - $cursa['spi'] = substr($linea[2], strpos($linea[2], "x")+1, -1); - } else if ($i == 2) { - $cursa['ealgo'] = $linea[1]; - } else if ($i == 3) { - $cursa['aalgo'] = $linea[1]; - } +function get_ipsec_tunnel_sad() { + /* query SAD */ + if (file_exists("/usr/local/sbin/setkey")) { + $fd = @popen("/usr/local/sbin/setkey -D", "r"); + } else { + $fd = @popen("/sbin/setkey -D", "r"); + } + $sad = array(); + if ($fd) { + while (!feof($fd)) { + $line = chop(fgets($fd)); + if (!$line) { + continue; + } + if ($line == "No SAD entries.") { + break; + } + if ($line[0] != "\t") { + if (is_array($cursa)) { + $sad[] = $cursa; + $cursa = array(); } - $i++; + list($cursa['src'],$cursa['dst']) = explode(" ", $line); + $i = 0; + } else { + $linea = explode(" ", trim($line)); + if ($i == 1) { + $cursa['proto'] = $linea[0]; + $cursa['spi'] = substr($linea[2], strpos($linea[2], "x")+1, -1); + } else if ($i == 2) { + $cursa['ealgo'] = $linea[1]; + } else if ($i == 3) { + $cursa['aalgo'] = $linea[1]; } - if (is_array($cursa) && count($cursa)) - $sad[] = $cursa; - pclose($fd); + } + $i++; } - return($sad); - } - - function get_ipsec_tunnel_src($tunnel) { - global $g, $config, $sad; - $if = "WAN"; - if ($tunnel['interface']) { - $if = $tunnel['interface']; - $realinterface = convert_friendly_interface_to_real_interface_name($if); - $interfaceip = find_interface_ip($realinterface); + if (is_array($cursa) && count($cursa)) { + $sad[] = $cursa; } - return $interfaceip; + pclose($fd); } - - function output_ipsec_tunnel_status($tunnel) { - global $g, $config, $sad; - $if = "WAN"; - $interfaceip = get_ipsec_tunnel_src($tunnel); - $foundsrc = false; - $founddst = false; - - if(!is_array($sad)) { - /* we have no sad array, bail */ - return(false); - } - foreach($sad as $sa) { - if($sa['src'] == $interfaceip) - $foundsrc = true; - if($sa['dst'] == $tunnel['remote-gateway']) - $founddst = true; + return($sad); +} + +function get_ipsec_tunnel_src($tunnel) { + global $g, $config, $sad; + $if = "WAN"; + if ($tunnel['interface']) { + $if = $tunnel['interface']; + $realinterface = convert_friendly_interface_to_real_interface_name($if); + $interfaceip = find_interface_ip($realinterface); + } + return $interfaceip; +} + +function output_ipsec_tunnel_status($tunnel) { + global $g, $config, $sad; + $if = "WAN"; + $interfaceip = get_ipsec_tunnel_src($tunnel); + $foundsrc = false; + $founddst = false; + + if (!is_array($sad)) { + /* we have no sad array, bail */ + return(false); + } + foreach ($sad as $sa) { + if ($sa['src'] == $interfaceip) { + $foundsrc = true; } - if($foundsrc && $founddst) { - /* tunnel is up */ - $iconfn = "pass"; - return(true); - } else { - /* tunnel is down */ - $iconfn = "reject"; - return(false); + if ($sa['dst'] == $tunnel['remote-gateway']) { + $founddst = true; } } + if ($foundsrc && $founddst) { + /* tunnel is up */ + $iconfn = "pass"; + return(true); + } else { + /* tunnel is down */ + $iconfn = "reject"; + return(false); + } +} - function get_ipsec_stats() { - global $g, $config, $sad; - $sad = array(); - $sad = get_ipsec_tunnel_sad(); - - $activecounter = 0; - $inactivecounter = 0; - - if($config['ipsec']['tunnel']) { - foreach ($config['ipsec']['tunnel'] as $tunnel){ - $ipsecstatus = false; - - $tun_disabled = "false"; - $foundsrc = false; - $founddst = false; - - if (isset($tunnel['disabled'])) { - $tun_disabled = "true"; - continue; - } - - if(output_ipsec_tunnel_status($tunnel)) { - /* tunnel is up */ - $iconfn = "true"; - $activecounter++; - } else { - /* tunnel is down */ - $iconfn = "false"; - $inactivecounter++; - } - } - } +function get_ipsec_stats() { + global $g, $config, $sad; + $sad = array(); + $sad = get_ipsec_tunnel_sad(); - if (is_array($config['ipsec']['tunnel'])) { - $status = "Up/Down $activecounter/$inactivecounter"; - } else { - $status = "IPSEC Disabled"; - } - return($status); - } + $activecounter = 0; + $inactivecounter = 0; - - /* Define functions */ - function send_lcd_commands($lcd, $lcd_cmds) { - if(!is_array($lcd_cmds) || (empty($lcd_cmds))) { - lcdproc_warn("Failed to interpret lcd commands"); - return; - } - foreach($lcd_cmds as $lcd_cmd) { - $cmd_output = ""; - if(! fwrite($lcd, "$lcd_cmd\n")) { - lcdproc_warn("Connection to LCDd process lost $errstr ($errno)"); - die(); + if ($config['ipsec']['tunnel']) { + foreach ($config['ipsec']['tunnel'] as $tunnel) { + $ipsecstatus = false; + + $tun_disabled = "false"; + $foundsrc = false; + $founddst = false; + + if (isset($tunnel['disabled'])) { + $tun_disabled = "true"; + continue; } - $cmd_output = fgets($lcd, 256); - // FIXME: add support for interpreting menu commands here. - if(preg_match("/^huh?/", $cmd_output)) { - lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\""); + + if (output_ipsec_tunnel_status($tunnel)) { + /* tunnel is up */ + $iconfn = "true"; + $activecounter++; + } else { + /* tunnel is down */ + $iconfn = "false"; + $inactivecounter++; } } } - function get_lcdpanel_width(){ - global $config; - $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; - if (is_null($lcdproc_size_config['size'])) { - return "16"; - } - else - { - $dimensions = split("x", $lcdproc_size_config['size']); - return $dimensions[0]; - } + if (is_array($config['ipsec']['tunnel'])) { + $status = "Up/Down $activecounter/$inactivecounter"; + } else { + $status = "IPSEC Disabled"; } - - function get_lcdpanel_height(){ - global $config; - $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; - if (is_null($lcdproc_size_config['size'])) { - return "2"; - } - else - { - $dimensions = split("x", $lcdproc_size_config['size']); - return $dimensions[1]; + return($status); +} + +function send_lcd_commands($lcd, $lcd_cmds) { + if (!is_array($lcd_cmds) || (empty($lcd_cmds))) { + lcdproc_warn("Failed to interpret lcd commands"); + return; + } + foreach ($lcd_cmds as $lcd_cmd) { + $cmd_output = ""; + if (! fwrite($lcd, "$lcd_cmd\n")) { + lcdproc_warn("Connection to LCDd process lost $errstr ($errno)"); + die(); } - } - - function get_lcdpanel_refresh_frequency(){ - global $config; - $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; - $value = $lcdproc_size_config['refresh_frequency']; - if (is_null($value)) { - return "5"; - } - else - { - return $value; + $cmd_output = fgets($lcd, 256); + // FIXME: add support for interpreting menu commands here. + if (preg_match("/^huh?/", $cmd_output)) { + lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\""); } } - - function add_summary_declaration(&$lcd_cmds, $name) { - $lcdpanel_height = get_lcdpanel_height(); - if ($lcdpanel_height >= "4") - { - $lcd_cmds[] = "widget_add $name title_summary scroller"; - $lcd_cmds[] = "widget_add $name text_summary scroller"; - } +} + +function get_lcdpanel_width() { + global $config; + $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; + if (is_null($lcdproc_size_config['size'])) { + return "16"; + } else { + $dimensions = explode("x", $lcdproc_size_config['size']); + return $dimensions[0]; } - - function add_summary_values(&$lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width) { - if ($lcd_summary_data != "") - { - $lcd_cmds[] = "widget_set $name title_summary 1 3 $lcdpanel_width 3 h 2 \"CPU MEM STATES\""; - $lcd_cmds[] = "widget_set $name text_summary 1 4 $lcdpanel_width 4 h 2 \"{$lcd_summary_data}\""; - } +} + +function get_lcdpanel_height() { + global $config; + $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; + if (is_null($lcdproc_size_config['size'])) { + return "2"; + } else { + $dimensions = explode("x", $lcdproc_size_config['size']); + return $dimensions[1]; } - - function build_interface($lcd) { - global $g; - global $config; - $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - $refresh_frequency = get_lcdpanel_refresh_frequency() * 10; - - $lcd_cmds = array(); - $lcd_cmds[] = "hello"; - $lcd_cmds[] = "client_set name pfSense"; - $lcd_cmds[] = "screen_add welcome_scr"; - $lcd_cmds[] = "screen_set welcome_scr heartbeat off"; - $lcd_cmds[] = "screen_set welcome_scr name welcome"; - $lcd_cmds[] = "screen_set welcome_scr duration $refresh_frequency"; - $lcd_cmds[] = "widget_add welcome_scr title_wdgt title"; - $lcd_cmds[] = "widget_add welcome_scr text_wdgt scroller"; - add_summary_declaration($lcd_cmds, "welcome_scr"); - - /* process screens to display */ - if(is_array($lcdproc_screens_config)) { - foreach($lcdproc_screens_config as $name => $screen) { - if($screen == "on") { - switch($name) { - case "scr_time": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_uptime": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_hostname": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_system": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_disk": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_load": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_states": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_carp": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_ipsec": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_slbd": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_interfaces": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_mbuf": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - case "scr_cpufrequency": - $lcd_cmds[] = "screen_add $name"; - $lcd_cmds[] = "screen_set $name heartbeat off"; - $lcd_cmds[] = "screen_set $name name $name"; - $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; - $lcd_cmds[] = "widget_add $name title_wdgt string"; - $lcd_cmds[] = "widget_add $name text_wdgt scroller"; - break; - } - add_summary_declaration($lcd_cmds, $name); - } - } - } - send_lcd_commands($lcd, $lcd_cmds); +} + +function get_lcdpanel_refresh_frequency() { + global $config; + $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0]; + $value = $lcdproc_size_config['refresh_frequency']; + if (is_null($value)) { + return "5"; + } else { + return $value; } +} - function loop_status($lcd) { - global $g; - global $config; - $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - $lcdpanel_width = get_lcdpanel_width(); - $lcdpanel_height = get_lcdpanel_height(); - if(empty($g['product_name'])) { - $g['product_name'] = "pfSense"; - } - $version = @file_get_contents("/etc/version"); - $version = trim($version); - $refresh_frequency = get_lcdpanel_refresh_frequency(); - /* keep a counter to see how many times we can loop */ - $i = 1; - while($i) { - /* prepare the summary data */ - if ($lcdpanel_height >= "4") { - $summary_states = split("/",get_pfstate()); - $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]); - } - else { - $lcd_summary_data = "";} - - $lcd_cmds = array(); - $lcd_cmds[] = "widget_set welcome_scr title_wdgt \"Welcome to\""; - $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$g['product_name']} {$version}\""; - add_summary_values($lcd_cmds, "welcome_scr", $lcd_summary_data, $lcdpanel_width); - - /* process screens to display */ - foreach((array) $lcdproc_screens_config as $name => $screen) { - if($screen != "on") { - continue; - } - switch($name) { +function add_summary_declaration(&$lcd_cmds, $name) { + $lcdpanel_height = get_lcdpanel_height(); + if ($lcdpanel_height >= "4") { + $lcd_cmds[] = "widget_add $name title_summary scroller"; + $lcd_cmds[] = "widget_add $name text_summary scroller"; + } +} + +function add_summary_values(&$lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width) { + if ($lcd_summary_data != "") { + $lcd_cmds[] = "widget_set $name title_summary 1 3 $lcdpanel_width 3 h 2 \"CPU MEM STATES\""; + $lcd_cmds[] = "widget_set $name text_summary 1 4 $lcdpanel_width 4 h 2 \"{$lcd_summary_data}\""; + } +} + +function build_interface($lcd) { + global $g; + global $config; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + $refresh_frequency = get_lcdpanel_refresh_frequency() * 10; + + $lcd_cmds = array(); + $lcd_cmds[] = "hello"; + $lcd_cmds[] = "client_set name pfSense"; + $lcd_cmds[] = "screen_add welcome_scr"; + $lcd_cmds[] = "screen_set welcome_scr heartbeat off"; + $lcd_cmds[] = "screen_set welcome_scr name welcome"; + $lcd_cmds[] = "screen_set welcome_scr duration $refresh_frequency"; + $lcd_cmds[] = "widget_add welcome_scr title_wdgt title"; + $lcd_cmds[] = "widget_add welcome_scr text_wdgt scroller"; + add_summary_declaration($lcd_cmds, "welcome_scr"); + + /* process screens to display */ + if (is_array($lcdproc_screens_config)) { + foreach ($lcdproc_screens_config as $name => $screen) { + if ($screen == "on") { + switch ($name) { case "scr_time": - $time = date("n/j/Y H:i"); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Time\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$time}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_uptime": - $uptime = get_uptime_stats(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Uptime\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$uptime}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_hostname": - exec("/bin/hostname", $output, $ret); - $hostname = $output[0]; - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Name\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$hostname}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_system": - $processor = cpu_usage(); - $memory = mem_usage(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Stats\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"CPU {$processor}%, Mem {$memory}%\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_disk": - $disk = disk_usage(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Disk Use\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"Disk {$disk}%\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_load": - $loadavg = get_loadavg_stats(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Averages\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$loadavg}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_states": - $states = get_pfstate(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Traffic States\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"Curr/Max {$states}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_carp": - $carp = get_carp_stats(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CARP State\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$carp}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_ipsec": - $ipsec = get_ipsec_stats(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ IPsec Tunnels\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$ipsec}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_slbd": - $slbd = get_slbd_stats(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Balancer\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$slbd}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_interfaces": - $interfaces = get_interfaces_stats(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Interfaces\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$interfaces}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_mbuf": - $mbufstats = get_mbuf_stats(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ MBuf Usage\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$mbufstats}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; case "scr_cpufrequency": - $cpufreq = get_cpufrequency(); - $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CPU Frequency\""; - $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$cpufreq}\""; + $lcd_cmds[] = "screen_add $name"; + $lcd_cmds[] = "screen_set $name heartbeat off"; + $lcd_cmds[] = "screen_set $name name $name"; + $lcd_cmds[] = "screen_set $name duration $refresh_frequency"; + $lcd_cmds[] = "widget_add $name title_wdgt string"; + $lcd_cmds[] = "widget_add $name text_wdgt scroller"; break; } - add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width); + add_summary_declaration($lcd_cmds, $name); } - send_lcd_commands($lcd, $lcd_cmds); - sleep($refresh_frequency); - $i++; } } + send_lcd_commands($lcd, $lcd_cmds); +} + +function loop_status($lcd) { + global $g; + global $config; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + $lcdpanel_width = get_lcdpanel_width(); + $lcdpanel_height = get_lcdpanel_height(); + if (empty($g['product_name'])) { + $g['product_name'] = "pfSense"; + } + $version = @file_get_contents("/etc/version"); + $version = trim($version); + $refresh_frequency = get_lcdpanel_refresh_frequency(); + /* keep a counter to see how many times we can loop */ + $i = 1; + while ($i) { + /* prepare the summary data */ + if ($lcdpanel_height >= "4") { + $summary_states = explode("/", get_pfstate()); + $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]); + } else { + $lcd_summary_data = ""; + } - /* Connect to the LCDd port and interface with the LCD */ - $lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10); - if (!$lcd) { - lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)"); - } else { - build_interface($lcd); - loop_status($lcd); - /* loop exited? Close fd and wait for the script to kick in again */ - fclose($lcd); + $lcd_cmds = array(); + $lcd_cmds[] = "widget_set welcome_scr title_wdgt \"Welcome to\""; + $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$g['product_name']} {$version}\""; + add_summary_values($lcd_cmds, "welcome_scr", $lcd_summary_data, $lcdpanel_width); + + /* process screens to display */ + foreach ((array) $lcdproc_screens_config as $name => $screen) { + if ($screen != "on") { + continue; + } + switch($name) { + case "scr_time": + $time = date("n/j/Y H:i"); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Time\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$time}\""; + break; + case "scr_uptime": + $uptime = get_uptime_stats(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Uptime\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$uptime}\""; + break; + case "scr_hostname": + exec("/bin/hostname", $output, $ret); + $hostname = $output[0]; + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Name\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$hostname}\""; + break; + case "scr_system": + $processor = cpu_usage(); + $memory = mem_usage(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Stats\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"CPU {$processor}%, Mem {$memory}%\""; + break; + case "scr_disk": + $disk = disk_usage(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Disk Use\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"Disk {$disk}%\""; + break; + case "scr_load": + $loadavg = get_loadavg_stats(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Averages\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$loadavg}\""; + break; + case "scr_states": + $states = get_pfstate(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Traffic States\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"Curr/Max {$states}\""; + break; + case "scr_carp": + $carp = get_carp_stats(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CARP State\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$carp}\""; + break; + case "scr_ipsec": + $ipsec = get_ipsec_stats(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ IPsec Tunnels\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$ipsec}\""; + break; + case "scr_slbd": + $slbd = get_slbd_stats(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Balancer\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$slbd}\""; + break; + case "scr_interfaces": + $interfaces = get_interfaces_stats(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Interfaces\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$interfaces}\""; + break; + case "scr_mbuf": + $mbufstats = get_mbuf_stats(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ MBuf Usage\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$mbufstats}\""; + break; + case "scr_cpufrequency": + $cpufreq = get_cpufrequency(); + $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CPU Frequency\""; + $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$cpufreq}\""; + break; + } + add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width); + } + send_lcd_commands($lcd, $lcd_cmds); + sleep($refresh_frequency); + $i++; } +} + +/* Connect to the LCDd port and interface with the LCD */ +$lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10); +if (!$lcd) { + lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)"); +} else { + build_interface($lcd); + loop_status($lcd); + /* loop exited? Close fd and wait for the script to kick in again */ + fclose($lcd); +} + ?> diff --git a/config/lcdproc/lcdproc_screens.xml b/config/lcdproc/lcdproc_screens.xml index d8cc2382..def770e6 100644 --- a/config/lcdproc/lcdproc_screens.xml +++ b/config/lcdproc/lcdproc_screens.xml @@ -1,8 +1,51 @@ <?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[ +/* $Id$ */ +/* ====================================================================================== */ +/* + lcdproc_screens.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl> + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <title>Services: LCDproc: Screens</title> <name>lcdproc_screens</name> - <version>0.5.2_1-p9</version> + <version>1.0.3</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/lcdproc.inc</include_file> <tabs> @@ -18,7 +61,7 @@ </tabs> <menu> <name>LCDproc</name> - <tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext> + <tooltiptext>Set LCDproc settings such as display driver and COM port.</tooltiptext> <section>Services</section> <url>/pkg_edit.php?xml=lcdproc.xml&id=0</url> </menu> @@ -82,19 +125,13 @@ <fielddescr>Enable Mbuf</fielddescr> <fieldname>scr_mbuf</fieldname> <type>checkbox</type> - </field> + </field> <field> <fielddescr>Enable CPU Frequency</fielddescr> <fieldname>scr_cpufrequency</fieldname> <type>checkbox</type> - </field> + </field> </fields> - <custom_php_command_before_form> - before_form_lcdproc_screens($pkg); - </custom_php_command_before_form> - <custom_php_validation_command> - validate_form_lcdproc_screens($_POST, $input_errors); - </custom_php_validation_command> <custom_php_resync_config_command> sync_package_lcdproc_screens(); </custom_php_resync_config_command> diff --git a/config/netio/netio.xml b/config/netio/netio.xml index 8e49f64c..34f188c2 100644 --- a/config/netio/netio.xml +++ b/config/netio/netio.xml @@ -1,52 +1,48 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + netio.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Bill Marquette + 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: + 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. - 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. - 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. - */ -/* ========================================================================== */ - ]]> + 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>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>netio</name> - <version>1.14</version> + <version>1.27</version> <title>netio: Client</title> <preoutput>yes</preoutput> <donotsave>true</donotsave> @@ -80,15 +76,19 @@ <field> <fielddescr>Port</fielddescr> <fieldname>port</fieldname> - <description>Enter the port that netio will connect to. (default 18767)</description> + <description>Enter the port that netio will connect to. (Default: 18767)</description> <type>input</type> </field> </fields> <custom_add_php_command> - mwexec("killall netio"); + <![CDATA[ + mwexec("/usr/bin/killall netio"); $netio_options = ""; - if($_POST['port'] != "") $netio_options .= " -p {$_POST['port']}"; - $netio_options .= $_POST['hostname']; - system("/usr/local/bin/netio " . $netio_options); + if ($_POST['port'] != "") { + $netio_options .= " -p {$_POST['port']}"; + $netio_options .= $_POST['hostname']; + system("/usr/local/bin/netio " . $netio_options); + } + ]]> </custom_add_php_command> </packagegui> diff --git a/config/netio/netioserver.xml b/config/netio/netioserver.xml index 4c32ee19..da73e902 100644 --- a/config/netio/netioserver.xml +++ b/config/netio/netioserver.xml @@ -1,52 +1,48 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + netioserver.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Bill Marquette + 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: + 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. - 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. - 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. - */ -/* ========================================================================== */ - ]]> + 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>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>netioserver</name> - <version>1.14</version> + <version>1.27</version> <title>netio: Server</title> <preoutput>yes</preoutput> <donotsave>true</donotsave> @@ -71,13 +67,17 @@ <field> <fielddescr>Port</fielddescr> <fieldname>port</fieldname> - <description>Enter the port that netio will bind to. (default 18767)</description> + <description>Enter the port that netio will bind to. (Default: 18767)</description> <type>input</type> </field> </fields> <custom_add_php_command> - mwexec("killall netio"); - if($_POST['port'] != "") $netioserver_options = " -p {$_POST['port']}"; - system("/usr/local/bin/netio -s" . $netioserver_options); + <![CDATA[ + mwexec("/usr/bin/killall netio"); + if($_POST['port'] != "") { + $netioserver_options = " -p {$_POST['port']}"; + system("/usr/local/bin/netio -s" . $netioserver_options); + } + ]]> </custom_add_php_command> </packagegui> diff --git a/config/notes/notes.inc b/config/notes/notes.inc index 29b51396..ddc54a3f 100644 --- a/config/notes/notes.inc +++ b/config/notes/notes.inc @@ -1,14 +1,11 @@ <?php -/* $Id$ */ -/* -/* ========================================================================== */ /* notes.inc + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + 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: @@ -30,62 +27,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -function notes_sync_package() { - - //global $config; - -} - - -function notes_install_command() { - - global $config; - conf_mount_rw(); - config_lock(); - - if (!is_dir('/usr/local/www/packages/')) { - exec("mkdir /usr/local/www/packages/"); - } - - //if (!is_dir('/usr/local/www/packages/notes/')) { - // exec("mkdir /usr/local/www/packages/notes/"); - //} - - //rename PHP files from .tmp to .php - //exec("cp /tmp/notes.tmp /usr/local/www/packages/phpservice/notes.php"); - //unlink_if_exists("/tmp/notes.tmp"); - - //write_config(); - - //write_rcfile(array( - // "file" => "notes.sh", - // "start" => "/usr/local/bin/php /usr/local/pkg/notes.php", - // "stop" => "rm /tmp/phpmonitor.pid" - // ) - //); - - notes_sync_package(); - - //if (pkg_is_service_running('notes')) { - //documentation purposes - //} - - conf_mount_ro(); - config_unlock(); - -} - - function notes_deinstall_command() { - conf_mount_rw(); - config_lock(); unlink_if_exists("/usr/local/pkg/notes.xml"); unlink_if_exists("/usr/local/pkg/notes.inc"); conf_mount_ro(); - config_unlock(); - } -?>
\ No newline at end of file +?> diff --git a/config/notes/notes.xml b/config/notes/notes.xml index 34d2f676..e74a76f1 100644 --- a/config/notes/notes.xml +++ b/config/notes/notes.xml @@ -1,21 +1,24 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - <![CDATA[ +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* notes.xml + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + 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. @@ -23,6 +26,7 @@ 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 @@ -34,14 +38,12 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* ========================================================================== */ - ]]> +/* ====================================================================================== */ + ]]> </copyright> <description>Notes</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>Notes</name> - <version>0.2.5</version> + <version>0.2.6</version> <title>Settings</title> <include_file>/usr/local/pkg/notes.inc</include_file> <menu> @@ -61,7 +63,6 @@ <configpath>installedpackages->package->$packagename->configuration->notes</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/notes/notes.inc</item> </additional_files_needed> <adddeleteeditpagefields> @@ -84,11 +85,15 @@ <field> <fielddescr>Category</fielddescr> <fieldname>category</fieldname> - <description>Enter a category.</description> + <description>Enter the category.</description> <type>input</type> </field> <field> - <fielddescr><b>Notes</b> <br /> <br /></fielddescr> + <fielddescr> + <![CDATA[ + <strong>Notes</strong><br /><br /> + ]]> + </fielddescr> <fieldname>notes</fieldname> <description></description> <type>textarea</type> @@ -98,18 +103,7 @@ <rows>20</rows> </field> </fields> - <custom_add_php_command> - </custom_add_php_command> - <custom_php_resync_config_command> - notes_sync_package(); - </custom_php_resync_config_command> - <custom_delete_php_command> - notes_sync_package(); - </custom_delete_php_command> - <custom_php_install_command> - notes_install_command(); - </custom_php_install_command> <custom_php_deinstall_command> notes_deinstall_command(); </custom_php_deinstall_command> -</packagegui>
\ No newline at end of file +</packagegui> diff --git a/config/ntop/bin/librrd_th.so.2 b/config/ntop/bin/librrd_th.so.2 Binary files differdeleted file mode 100755 index eae27341..00000000 --- a/config/ntop/bin/librrd_th.so.2 +++ /dev/null diff --git a/config/ntop/ntop.xml b/config/ntop/ntop.xml deleted file mode 100644 index 5a7cd47a..00000000 --- a/config/ntop/ntop.xml +++ /dev/null @@ -1,157 +0,0 @@ -<?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[ -/* $Id$ */ -/* ========================================================================== */ -/* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2008 Scott Ullrich - 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> - <name>ntop</name> - <version>3.0</version> - <title>Diagnostics: ntop Settings</title> - <savetext>Change</savetext> - <aftersaveredirect>pkg_edit.php?xml=ntop.xml&id=0</aftersaveredirect> - <additional_files_needed> - <prefix>/usr/local/lib/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/ntop/bin/librrd_th.so.2</item> - </additional_files_needed> - <menu> - <name>ntop Settings</name> - <tooltiptext>Set ntop settings such as password and port.</tooltiptext> - <section>Diagnostics</section> - <url>/pkg_edit.php?xml=ntop.xml&id=0</url> - </menu> - <menu> - <name>ntop</name> - <tooltiptext>Access ntop</tooltiptext> - <section>Diagnostics</section> - <url>http://$myurl:3000</url> - <depends_on_service>ntop</depends_on_service> - </menu> - <service> - <name>ntop</name> - <rcfile>ntop.sh</rcfile> - <executable>ntop</executable> - <description>NTOP bandwidth monitoring/graphing</description> - </service> - <tabs> - <tab> - <text>ntop Settings</text> - <url>/pkg_edit.php?xml=ntop.xml&id=0</url> - <active/> - </tab> - <tab> - <text>Access ntop</text> - <url>http://$myurl:3000</url> - </tab> - </tabs> - <fields> - <field> - <fielddescr>ntop Admin Password</fielddescr> - <fieldname>password</fieldname> - <description>Enter the password for the NTOP Web GUI. Minimum 5 characters.</description> - <type>password</type> - </field> - <field> - <fielddescr>ntop Admin Password AGAIN</fielddescr> - <fieldname>passwordagain</fieldname> - <type>password</type> - </field> - <field> - <fielddescr>Interface</fielddescr> - <fieldname>interface_array</fieldname> - <type>interfaces_selection</type> - <size>3</size> - <value>lan</value> - <multiple>true</multiple> - </field> - </fields> - <custom_php_global_functions> - function sync_package_ntop() { - conf_mount_rw(); - config_lock(); - global $config; - global $input_errors; - $ntop_config =& $_POST; - $if_final = ""; - $ifaces_final = ""; - system("/bin/mkdir -p /var/db/ntop"); - system("/bin/mkdir -p /var/db/ntop/rrd"); - system("/bin/mkdir -p /var/db/ntop/rrd/graphics"); - system("/bin/chmod -R 755 /var/db/ntop"); - system("/usr/sbin/chown -R nobody:nobody /var/db/ntop"); - if($ntop_config['password'] and $ntop_config['passwordagain']) { - if($ntop_config['password'] == $ntop_config['passwordagain']) { - $first = 0; - foreach($_POST['interface_array'] as $iface) { - $if = convert_friendly_interface_to_real_interface_name($iface); - if($if) { - if($first == 1) - $ifaces_final .= ","; - $ifaces_final .= $if; - $first = 1; - } - } - exec("/usr/local/bin/ntop --set-admin-password=" . $_POST['password'] . " &", $ntopout); - $start = "/usr/local/bin/ntop -i " . $ifaces_final . " -u root -d --ipv4 -M -x 8102 -X 8192 &"; - write_rcfile(array( - "file" => "ntop.sh", - "start" => $start, - "stop" => "/usr/bin/killall ntop" - ) - ); - restart_service("ntop"); - } else { - $input_errors[] = "The provided passwords did not match."; - } - } else { - $input_errors[] = "You must provide (and confirm) ntop's password."; - } - conf_mount_ro(); - config_unlock(); - } - </custom_php_global_functions> - <custom_add_php_command> - sync_package_ntop(); - </custom_add_php_command> - <custom_php_resync_config_command> - sync_package_ntop(); - </custom_php_resync_config_command> - <custom_php_install_command> - </custom_php_install_command> - <custom_php_deinstall_command> - exec("rm /usr/local/etc/rc.d/ntop*"); - </custom_php_deinstall_command> -</packagegui>
\ No newline at end of file diff --git a/config/ntop2/ntop.xml b/config/ntop2/ntop.xml index 4db9e9c8..57354f61 100644 --- a/config/ntop2/ntop.xml +++ b/config/ntop2/ntop.xml @@ -103,7 +103,6 @@ <![CDATA[ function sync_package_ntop() { conf_mount_rw(); - config_lock(); global $config; global $input_errors; if ($_POST) { @@ -149,7 +148,6 @@ sleep(2); start_service("ntop"); conf_mount_ro(); - config_unlock(); } ]]> </custom_php_global_functions> @@ -175,4 +173,4 @@ } ]]> </custom_php_validation_command> -</packagegui>
\ No newline at end of file +</packagegui> diff --git a/config/ntopng/ntopng.xml b/config/ntopng/ntopng.xml index 3d07b064..6c01515c 100644 --- a/config/ntopng/ntopng.xml +++ b/config/ntopng/ntopng.xml @@ -143,7 +143,6 @@ return; } conf_mount_rw(); - config_lock(); global $config; global $input_errors; global $pf_version, $scripts_path, $fonts_path; @@ -263,7 +262,6 @@ mwexec_bg("{$redis_path}/redis-cli SET user.admin.password " . escapeshellarg($password)); mwexec_bg("{$redis_path}/redis-cli save"); conf_mount_ro(); - config_unlock(); } function ntopng_update_geoip() { $fetchcmd = "/usr/bin/fetch"; diff --git a/config/nut/nut.inc b/config/nut/nut.inc index 578bb82f..e0ca9d30 100644 --- a/config/nut/nut.inc +++ b/config/nut/nut.inc @@ -498,8 +498,6 @@ EOD; global $config; global $input_errors; - config_lock(); - stop_service("nut"); /* create state path */ @@ -514,13 +512,13 @@ EOD; $return = sync_package_nut_snmp(); } - if ($return && $_POST['monitor']) { - /* only start if changing settings as we have a startup script for system boot */ + if ((!platform_booting()) && (nut_config('monitor'))) { + /* only start if enabled and system is not booting */ /* this prevents service from starting / stopping / starting on boot */ log_error("[nut] INFO: Starting service"); start_service("nut"); - if ((int)exec('/bin/pgrep upsmon | /usr/bin/wc -l') == 0) { + if (!is_process_running('upsmon')) { log_error("[nut] ERROR: Service failed to start: check configuration."); } } elseif (!$return && file_exists(NUT_RCFILE)) { @@ -542,7 +540,5 @@ EOD; exec('/bin/rm -rf /var/db/nut'); conf_mount_ro(); } - - config_unlock(); } ?> diff --git a/config/olsrd/olsrd.inc b/config/olsrd/olsrd.inc index 9eee0196..4e15f9cf 100644 --- a/config/olsrd/olsrd.inc +++ b/config/olsrd/olsrd.inc @@ -1,34 +1,64 @@ <?php -/* COPYRIGHT */ - +/* + olsrd.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Ermal Luçi + 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. +*/ require_once("config.inc"); function setup_wireless_olsr() { global $config, $g; - if ($g['platform'] == 'jail' || !$config['installedpackages']['olsrd'] || !$config['installedpackages']) + if ($g['platform'] == 'jail' || !$config['installedpackages']['olsrd'] || !$config['installedpackages']) { return; - if(isset($config['system']['developerspew'])) { + } + if (isset($config['system']['developerspew'])) { $mt = microtime(); echo "setup_wireless_olsr($interface) being called $mt\n"; } conf_mount_rw(); - foreach($config['installedpackages']['olsrd']['config'] as $olsrd) { + foreach ($config['installedpackages']['olsrd']['config'] as $olsrd) { $olsr_enable = $olsrd['enable']; if ($olsr_enable <> "on") { - if (is_process_running("olsrd")) + if (is_process_running("olsrd")) { mwexec("/usr/bin/killall olsrd", true); + } return; } $fd = fopen("{$g['varetc_path']}/olsr.conf", "w"); - if($olsrd['announcedynamicroute'] or $olsrd['enableannounce'] == "on") { + if ($olsrd['announcedynamicroute'] or $olsrd['enableannounce'] == "on") { $enableannounce .= "\nHna4\n"; $enableannounce .= "{\n"; - if($olsrd['announcedynamicroute']) + } + if ($olsrd['announcedynamicroute']) { $enableannounce .= "\t{$olsrd['announcedynamicroute']}\n"; - if($olsrd['enableannounce'] == "on") + } + if ($olsrd['enableannounce'] == "on") { $enableannounce .= "0.0.0.0 0.0.0.0"; $enableannounce .= "\n}\n"; } else { @@ -171,8 +201,8 @@ MprCoverage 3 EODA; -if($olsrd['enablehttpinfo'] == "on") { - $olsr .= <<<EODB + if ($olsrd['enablehttpinfo'] == "on") { + $olsr .= <<<EODB LoadPlugin "/usr/local/lib/olsrd_httpinfo.so.0.1" { @@ -182,11 +212,11 @@ LoadPlugin "/usr/local/lib/olsrd_httpinfo.so.0.1" EODB; -} + } -if($olsrd['enabledsecure'] == "on") { - @file_put_contents("{$g['tmp_path']}/olsrkey.txt", $olsrd['securekey']); - $olsr .= <<<EODC + if ($olsrd['enabledsecure'] == "on") { + @file_put_contents("{$g['tmp_path']}/olsrkey.txt", $olsrd['securekey']); + $olsr .= <<<EODC LoadPlugin "/usr/local/lib/olsrd_secure.so.0.5" { @@ -195,9 +225,9 @@ LoadPlugin "/usr/local/lib/olsrd_secure.so.0.5" EODC; -} + } -if($olsrd['enabledyngw'] == "on") { + if ($olsrd['enabledyngw'] == "on") { /* unset default route, olsr auto negotiates */ mwexec("/sbin/route delete default"); @@ -222,13 +252,13 @@ LoadPlugin "/usr/local/lib/olsrd_dyn_gw.so.0.4" EODE; -} + } -foreach($config['installedpackages']['olsrd']['config'] as $conf) { - $interfaces = explode(',', $conf['iface_array']); - foreach($interfaces as $interface) { - $realinterface = convert_friendly_interface_to_real_interface_name($interface); -$olsr .= <<<EODAD + foreach ($config['installedpackages']['olsrd']['config'] as $conf) { + $interfaces = explode(',', $conf['iface_array']); + foreach ($interfaces as $interface) { + $realinterface = convert_friendly_interface_to_real_interface_name($interface); + $olsr .= <<<EODAD Interface "{$realinterface}" { @@ -271,20 +301,21 @@ Interface "{$realinterface}" EODAD; + } + break; } - break; + + fwrite($fd, $olsr); + fclose($fd); + } - fwrite($fd, $olsr); - fclose($fd); - } - if (is_process_running("olsrd")) + if (is_process_running("olsrd")) { mwexec("/usr/bin/killall olsrd", true); + } sleep(2); - mwexec_bg("/usr/local/sbin/olsrd -f {$g['varetc_path']}/olsr.conf"); - conf_mount_ro(); } diff --git a/config/olsrd/olsrd.xml b/config/olsrd/olsrd.xml index 3939f357..464f730d 100644 --- a/config/olsrd/olsrd.xml +++ b/config/olsrd/olsrd.xml @@ -1,19 +1,59 @@ <?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[ +/* $Id$ */ +/* ====================================================================================== */ +/* + olsrd.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Ermal Luçi + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <name>olsrd</name> - <version>1.0</version> + <version>1.0.3</version> <title>OLSRD</title> <include_file>/usr/local/pkg/olsrd.inc</include_file> - <!-- Menu is where this packages menu will appear --> <menu> <name>OLSRD</name> <section>Services</section> <configfile>olsrd.xml</configfile> </menu> <service> - <name>OLSRD</name> - <rcfile>/usr/local/sbin/olsrd -f /var/etc/olsr.conf</rcfile> - </service> + <name>OLSRD</name> + <rcfile>/usr/local/sbin/olsrd -f /var/etc/olsr.conf</rcfile> + </service> <tabs> <tab> <text>OLSRD Settings</text> @@ -22,20 +62,15 @@ </tab> </tabs> <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/olsrd/olsrd.inc</item> - </additional_files_needed> - <!-- configpath gets expanded out automatically and config items will be - stored in that location --> + <prefix>/usr/local/pkg/</prefix> + <item>https://packages.pfsense.org/packages/config/olsrd/olsrd.inc</item> + </additional_files_needed> <configpath>['installedpackages']['OLSRD']['config']</configpath> - <!-- fields gets invoked when the user adds or edits a item. the following items - will be parsed and rendered for the user as a gui with input, and selectboxes. --> <fields> <field> <fielddescr>Enable OLSR</fielddescr> <fieldname>enable</fieldname> - <description>Enables the dynamic mesh linking daemon</description> + <description>Enables the dynamic mesh linking daemon.</description> <type>checkbox</type> </field> <field> @@ -56,18 +91,18 @@ <multiple>true</multiple> <size>3</size> <type>interfaces_selection</type> - <description>Select the interfaces that OLSR will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description> + <description>Select the interfaces that OLSR will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description> </field> <field> <fielddescr>Enable HTTPInfo Plugin</fielddescr> <fieldname>enablehttpinfo</fieldname> - <description>Enables the OLSR stats web server</description> + <description>Enables the OLSR stats web server.</description> <type>checkbox</type> </field> <field> <fielddescr>HTTPInfo Port</fielddescr> <fieldname>port</fieldname> - <description>Port that HTTPInfo will listen on</description> + <description>Port that HTTPInfo will listen on.</description> <type>input</type> </field> <field> @@ -85,19 +120,19 @@ <field> <fielddescr>Enable Dynamic Gateway</fielddescr> <fieldname>enabledyngw</fieldname> - <description>Enables the OLSR Dynamic Gateways feature</description> + <description>Enables the OLSR Dynamic Gateways feature.</description> <type>checkbox</type> </field> <field> <fielddescr>Announce self as Dynamic Gateway</fielddescr> <fieldname>enableannounce</fieldname> - <description>Enables the OLSR Dynamic Gateways Announcing feature</description> + <description>Enables the OLSR Dynamic Gateways Announcing feature.</description> <type>checkbox</type> </field> <field> <fielddescr>Announce Dynamic local route</fielddescr> <fieldname>announcedynamicroute</fieldname> - <description>Enter the IP/Netmask</description> + <description>Enter the IP/Netmask.</description> <type>textarea</type> <rows>3</rows> <cols>50</cols> @@ -105,7 +140,7 @@ <field> <fielddescr>Ping</fielddescr> <fieldname>ping</fieldname> - <description>Pings this host to ensure connectivity</description> + <description>Pings this host to ensure connectivity.</description> <type>input</type> </field> <field> @@ -117,7 +152,7 @@ <field> <fielddescr>Enable Secure Mode</fielddescr> <fieldname>enabledsecure</fieldname> - <description>Enables the secure mode</description> + <description>Enables the secure mode.</description> <type>checkbox</type> </field> <field> diff --git a/config/open-vm-tools/open-vm-tools.inc b/config/open-vm-tools/open-vm-tools.inc deleted file mode 100644 index 76e8c212..00000000 --- a/config/open-vm-tools/open-vm-tools.inc +++ /dev/null @@ -1,172 +0,0 @@ -<?php - -function open_vm_tools_deinstall() { - exec("rm /usr/local/etc/rc.d/vmware*"); -} - -function open_vm_tools_install() { - exec("/bin/cp /usr/local/lib/vmware-tools/modules/drivers/*.ko /boot/kernel/"); - if(!file_exists("/boot/loader.conf")) - touch("/boot/loader.conf"); - $load_conf = file_get_contents("/boot/loader.conf") . "\n"; - if(!strstr($load_conf, "vmxnet")) { - $load_conf .= <<<EOFA - -vmblock_load="YES" -vmmemct_load="YES" -vmhgfs_load="YES" -vmxnet_load="YES" - -EOFA; - - file_put_contents("/boot/loader.conf", $load_conf); -} - - $vmware_guestd = <<<EOF -#!/bin/sh -# -# This file was automatically generated -# by the pfSense package manager. -# -# Do not edit this file. Edit -# /usr/local/pkg/open-vm-tools.inc instead. -# -# PROVIDE: vmware-guestd -# REQUIRE: DAEMON -# BEFORE: LOGIN - -. /etc/rc.subr - -# Global -checkvm_cmd="/usr/local/bin/vmware-checkvm > /dev/null" - -# VMware guest daemon -name="vmware_guestd" -rcvar="\${name}_enable" -start_precmd="\${checkvm_cmd}" -unset start_cmd -stop_precmd="\${checkvm_cmd}" -unset stop_cmd -command="/usr/local/bin/vmtoolsd" -command_args="-c /usr/local/share/vmware-tools/tools.conf -p /usr/local/lib/open-vm-tools/plugins/vmsvc" -pidfile="/var/run/\${name}.pid" - -load_rc_config \$name -vmware_guestd_enable="YES" -vmware_guestd_flags="--background \${pidfile}" -run_rc_command "\$1" - -EOF; - - $vmware_kmod = <<<EOF -#!/bin/sh -# -# This file was automatically generated -# by the pfSense package manager. -# -# Do not edit this file. Edit -# /usr/local/pkg/open-vm-tools.inc instead. -# -# PROVIDE: vmware-kmod -# REQUIRE: FILESYSTEMS -# BEFORE: netif - -. /etc/rc.subr - -# Global -checkvm_cmd="/usr/local/bin/vmware-checkvm > /dev/null" - -# Functions -vmware_guest_vmmemctl_start() -{ - echo 'Loading vmmemctl kernel module.' - kldload /usr/local/lib/vmware-tools/modules/drivers/vmmemctl.ko >/dev/null 2>&1 -} -vmware_guest_vmxnet_start() -{ - echo 'Loading vmxnet kernel module.' - kldload /usr/local/lib/vmware-tools/modules/drivers/vmxnet.ko >/dev/null 2>&1 -} -vmware_guest_vmblock_start() -{ - echo 'Loading vmblock kernel module.' - kldload /usr/local/lib/vmware-tools/modules/drivers/vmblock.ko >/dev/null 2>&1 -} -vmware_guest_vmhgfs_start() -{ - echo 'Loading vmhgfs kernel module.' - kldload /usr/local/lib/vmware-tools/modules/drivers/vmhgfs.ko >/dev/null 2>&1 -} - -# VMware kernel module: vmmemctl -name="vmware_guest_vmmemctl" -rcvar="\${name}_enable" -start_precmd="\${checkvm_cmd}" -start_cmd="vmware_guest_vmmemctl_start" -stop_precmd="\${checkvm_cmd}" -stop_cmd=":" - -load_rc_config \$name -vmware_guest_vmmemctl_enable="YES" -run_rc_command "\$1" - -# VMware kernel module: vmxnet -name="vmware_guest_vmxnet" -rcvar="\${name}_enable" -start_precmd="\${checkvm_cmd}" -start_cmd="vmware_guest_vmxnet_start" -stop_precmd="\${checkvm_cmd}" -stop_cmd=":" - -load_rc_config \$name -vmware_guest_vmxnet_enable="YES" -run_rc_command "\$1" - -# VMware kernel module: vmblock -name="vmware_guest_vmblock" -rcvar="\${name}_enable" -start_precmd="\${checkvm_cmd}" -start_cmd="vmware_guest_vmblock_start" -stop_precmd="\${checkvm_cmd}" -stop_cmd=":" - -load_rc_config \$name -vmware_guest_vmblock_enable="YES" -run_rc_command "\$1" - -# VMware kernel module: vmhgfs -name="vmware_guest_vmhgfs" -rcvar="\${name}_enable" -start_precmd="\${checkvm_cmd}" -start_cmd="vmware_guest_vmhgfs_start" -stop_precmd="\${checkvm_cmd}" -stop_cmd=":" - -load_rc_config \$name -vmware_guest_vmhgfs_enable="YES" -run_rc_command "\$1" - -EOF; - - // Write out conf files. - $fd = fopen("/usr/local/etc/rc.d/vmware-guestd.sh", "w"); - if(!$fd) - die("Could not open /usr/local/etc/rc.d/vmware-guestd.sh for writing"); - fwrite($fd, $vmware_guestd); - fclose($fd); - $fd = fopen("/usr/local/etc/rc.d/vmware-kmod.sh", "w"); - if(!$fd) - die("Could not open /usr/local/etc/rc.d/vmware-kmod.sh for writing"); - fwrite($fd, $vmware_kmod); - fclose($fd); - - // Remove non used files - unlink_if_exists("/usr/local/etc/rc.d/vmware-kmod"); - unlink_if_exists("/usr/local/etc/rc.d/vmware-guestd"); - - // Make sure files are executable. - exec("chmod a+rx /usr/local/etc/rc.d/*.sh"); - -} - -?> diff --git a/config/open-vm-tools/open-vm-tools.xml b/config/open-vm-tools/open-vm-tools.xml deleted file mode 100644 index b4b1c0e8..00000000 --- a/config/open-vm-tools/open-vm-tools.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?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[ - /* ========================================================================== */ - /* - open-vm-tools.xml - part of pfSense (http://www.pfSense.org) - Copyright (C) 2008-2014 Electric Sheep Fencing LP - 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> - <name>open-vm-tools</name> - <version>102166_7</version> - <title>Open VM Tools</title> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0644</chmod> - <item>https://packages.pfsense.org/packages/config/open-vm-tools/open-vm-tools.inc</item> - </additional_files_needed> - <custom_add_php_command> - </custom_add_php_command> - <custom_php_install_command> - conf_mount_rw(); - open_vm_tools_install(); - exec("/usr/local/etc/rc.d/vmware-guestd.sh start"); - exec("/usr/local/etc/rc.d/vmware-kmod.sh start"); - conf_mount_ro(); - </custom_php_install_command> - <custom_php_deinstall_command> - conf_mount_rw(); - exec("/usr/local/etc/rc.d/vmware-guestd.sh stop"); - exec("/usr/local/etc/rc.d/vmware-kmod.sh stop"); - open_vm_tools_deinstall(); - conf_mount_ro(); - </custom_php_deinstall_command> - <include_file>/usr/local/pkg/open-vm-tools.inc</include_file> -</packagegui> diff --git a/config/open-vm-tools_2/open-vm-tools.inc b/config/open-vm-tools_2/open-vm-tools.inc index 912c4032..f005074e 100644 --- a/config/open-vm-tools_2/open-vm-tools.inc +++ b/config/open-vm-tools_2/open-vm-tools.inc @@ -1,22 +1,56 @@ <?php - +/* + open-vm-tools.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008-2015 Electric Sheep Fencing LP + 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 open_vm_tools_deinstall() { - exec("rm /usr/local/etc/rc.d/vmware*"); + conf_mount_rw(); + stop_service("vmware-guestd"); + unlink_if_exists("/usr/local/etc/rc.d/vmware-guestd.sh"); + unlink_if_exists("/usr/local/etc/rc.d/vmware-kmod.sh"); unlink_if_exists("/boot/kernel/vmblock.ko"); unlink_if_exists("/boot/kernel/vmhgfs.ko"); unlink_if_exists("/boot/kernel/vmmemctl.ko"); unlink_if_exists("/boot/kernel/vmxnet.ko"); + conf_mount_ro(); } function open_vm_tools_install() { + conf_mount_rw(); - // clean up old .ko files if they exist + // Clean up old .ko files if they exist unlink_if_exists("/boot/kernel/vmblock.ko"); unlink_if_exists("/boot/kernel/vmhgfs.ko"); unlink_if_exists("/boot/kernel/vmmemctl.ko"); unlink_if_exists("/boot/kernel/vmxnet.ko"); + // Remove other unused files if they exist + unlink_if_exists("/usr/local/etc/rc.d/vmware-kmod"); + unlink_if_exists("/usr/local/etc/rc.d/vmware-guestd"); - $pfs_version=substr(trim(file_get_contents("/etc/version")),0,3); + $pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); if ($pfs_version == "2.1") { $openvmtools_path = "/usr/pbi/open-vm-tools-nox11-" . php_uname("m"); } else if ($pfs_version == "2.2") { @@ -24,10 +58,7 @@ function open_vm_tools_install() { } else { $openvmtools_path = "/usr/local"; } - - // won't copy this either for now, some sequences of loading/unloading of the module will kernel panic. - //exec("cp $openvmtools_path/local/lib/vmware-tools/modules/drivers/vmmemctl.ko /boot/kernel/"); - + $vmware_tools_conf = <<<EOF [powerops] poweron-script= @@ -40,10 +71,10 @@ EOF; $vmware_guestd = <<<EOF #!/bin/sh # -# This file was automatically generated +# This file was automatically generated # by the pfSense package manager. -# -# Do not edit this file. Edit +# +# Do not edit this file. Edit # /usr/local/pkg/open-vm-tools.inc instead. # # PROVIDE: vmware-guestd @@ -76,10 +107,10 @@ EOF; $vmware_kmod = <<<EOF #!/bin/sh # -# This file was automatically generated +# This file was automatically generated # by the pfSense package manager. -# -# Do not edit this file. Edit +# +# Do not edit this file. Edit # /usr/local/pkg/open-vm-tools.inc instead. # # PROVIDE: vmware-kmod @@ -120,8 +151,9 @@ EOF; } fwrite($fd, $vmware_guestd); fclose($fd); + chmod("/usr/local/etc/rc.d/vmware-guestd.sh", 0755); - /* the kernel modules aren't stable at this time, omit them. + /* The kernel modules aren't stable at this time, omit them. $fd = fopen("/usr/local/etc/rc.d/vmware-kmod.sh", "w"); if (!$fd) { log_error("Could not open /usr/local/etc/rc.d/vmware-kmod.sh for writing"); @@ -129,8 +161,12 @@ EOF; } fwrite($fd, $vmware_kmod); fclose($fd); + chmod("/usr/local/etc/rc.d/vmware-kmod.sh", 0755); */ - + /* Won't copy this either for now, some sequences of loading/unloading of the module will cause kernel panic. + mwexec("/bin/cp $openvmtools_path/local/lib/vmware-tools/modules/drivers/vmmemctl.ko /boot/kernel/"); + */ + $fd = fopen("$openvmtools_path/share/vmware-tools/tools.conf", "w"); if (!$fd) { log_error("Could not open $openvmtools_path/share/vmware-tools/tools.conf for writing"); @@ -139,13 +175,7 @@ EOF; fwrite($fd, $vmware_tools_conf); fclose($fd); - // Remove non used files - unlink_if_exists("/usr/local/etc/rc.d/vmware-kmod"); - unlink_if_exists("/usr/local/etc/rc.d/vmware-guestd"); - - // Make sure files are executable. - exec("chmod a+rx /usr/local/etc/rc.d/*.sh"); - + start_service("vmware-guestd"); } ?> diff --git a/config/open-vm-tools_2/open-vm-tools.xml b/config/open-vm-tools_2/open-vm-tools.xml index 5540672b..b2bd6d7f 100644 --- a/config/open-vm-tools_2/open-vm-tools.xml +++ b/config/open-vm-tools_2/open-vm-tools.xml @@ -1,63 +1,63 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ - /* ========================================================================== */ - /* - open-vm-tools.xml - part of pfSense (http://www.pfSense.org) - Copyright (C) 2008-2015 Electric Sheep Fencing LP - All rights reserved. + <copyright> +<![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ +/* + open-vm-tools.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008-2015 Electric Sheep Fencing LP + All rights reserved. +*/ +/* ====================================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - /* ========================================================================== */ - /* - 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. + 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. + 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> + + 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> <name>open-vm-tools</name> - <version>313025</version> + <version>1280544.11</version> <title>Open VM Tools</title> + <include_file>/usr/local/pkg/open-vm-tools.inc</include_file> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/open-vm-tools_2/open-vm-tools.inc</item> - </additional_files_needed> - <custom_add_php_command> - </custom_add_php_command> - <custom_php_install_command> - conf_mount_rw(); + </additional_files_needed> + <service> + <name>vmware-guestd</name> + <rcfile>vmware-guestd.sh</rcfile> + <executable>vmtoolsd</executable> + <description>VMware Guest Daemon</description> + </service> + <custom_php_install_command> open_vm_tools_install(); - exec("/usr/local/etc/rc.d/vmware-guestd.sh start"); - conf_mount_ro(); - </custom_php_install_command> - <custom_php_deinstall_command> - conf_mount_rw(); - exec("/usr/local/etc/rc.d/vmware-guestd.sh stop"); + </custom_php_install_command> + <custom_php_deinstall_command> open_vm_tools_deinstall(); - conf_mount_ro(); - </custom_php_deinstall_command> - <include_file>/usr/local/pkg/open-vm-tools.inc</include_file> + </custom_php_deinstall_command> </packagegui> diff --git a/config/openbgpd/openbgpd.xml b/config/openbgpd/openbgpd.xml index e7d77786..83e0122c 100644 --- a/config/openbgpd/openbgpd.xml +++ b/config/openbgpd/openbgpd.xml @@ -2,78 +2,73 @@ <!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> + <![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - openbgpd.xml - Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com) - part of pfSense (http://www.pfSense.com) - All rights reserved. - */ -/* ========================================================================== */ + openbgpd.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007 Scott Ullrich (sullrich@gmail.com) + 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: + 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. + 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> <name>OpenBGPD</name> - <version>1</version> + <version>0.9.3.4</version> <title>Services: OpenBGPD</title> <include_file>/usr/local/pkg/openbgpd.inc</include_file> - <service> - <name>bgpd</name> - <rcfile>bgpd.sh</rcfile> - <executable>bgpd</executable> - <description>OpenBSD BGP Daemon</description> - </service> + <service> + <name>bgpd</name> + <rcfile>bgpd.sh</rcfile> + <executable>bgpd</executable> + <description>OpenBSD BGP Daemon</description> + </service> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/openbgpd/openbgpd_status.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/openbgpd/openbgpd_raw.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/openbgpd/openbgpd.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/openbgpd/openbgpd_groups.xml</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/openbgpd/openbgpd_neighbors.xml</item> </additional_files_needed> <menu> @@ -121,18 +116,24 @@ <field> <fielddescr>Holdtime</fielddescr> <fieldname>holdtime</fieldname> - <description>Set the holdtime in seconds. The holdtime is reset to its initial value every time either a KEEPALIVE or an UPDATE message is received from the neighbor. If the holdtime expires the session is dropped. The default is 90 seconds. Neighboring systems negotiate the holdtime used when the connection is established in the OPEN messages. Each neighbor announces its configured hold- time; the smaller one is then agreed upon.</description> + <description> + <![CDATA[ + Set the holdtime in seconds. The holdtime is reset to its initial value every time either a KEEPALIVE or an UPDATE message is received from the neighbor.<br /> + If the holdtime expires the session is dropped. The default is 90 seconds. Neighboring systems negotiate the holdtime used when the connection is established in the OPEN messages.<br /> + Each neighbor announces its configured hold- time; the smaller one is then agreed upon. + ]]> + </description> <type>input</type> </field> <field> <fielddescr>fib-update</fielddescr> <fieldname>fibupdate</fieldname> - <description>If set to no, do not update the Forwarding Information Base a.k.a. the kernel routing table. The default is yes.</description> + <description>If set to no, do not update the Forwarding Information Base a.k.a. the kernel routing table. The default is yes.</description> <type>select</type> <options> - <option><name>yes</name><value>yes</value></option> - <option><name>no</name><value>no</value></option> + <option><name>yes</name><value>yes</value></option> + <option><name>no</name><value>no</value></option> </options> </field> <field> @@ -151,24 +152,34 @@ <field> <fielddescr>CARP Status IP</fielddescr> <fieldname>carpstatusip</fieldname> - <description>IP address used to determine the CARP status. When the VIP is in BACKUP status, bgpd will not be started. <br/>NOTE: On 2.1.x and before this requires changes to /etc/rc.carpmaster to start bgpd and /etc/rc.carpbackup to stop bgpd or it will not be fully effective. On pfSense 2.2.x and later, full support is automatic.</description> + <description> + <![CDATA[ + IP address used to determine the CARP status. When the VIP is in BACKUP status, bgpd will not be started.<br /> + NOTE: On 2.1.x and before this requires changes to /etc/rc.carpmaster to start bgpd and /etc/rc.carpbackup to stop bgpd or it will not be fully effective. On pfSense 2.2.x and later, full support is automatic. + ]]> + </description> <type>input</type> <size>25</size> </field> <field> <fielddescr>Networks</fielddescr> <fieldname>network</fieldname> - <type>rowhelper</type> - <description></description> - <rowhelper> + <type>rowhelper</type> + <description></description> + <rowhelper> <rowhelperfield> - <fielddescr>Announce the specified network as belonging to our AS. If set to "(inet|inet6)connected", inet or inet6 routes to directly attached networks will be announced. If set to "(inet|inet6) static", all inet or inet6 static routes will be announced.</fielddescr> - <fieldname>networks</fieldname> - <description>Network that you would like to advertise</description> - <type>input</type> - <size>45</size> + <fielddescr> + <![CDATA[ + Announce the specified network as belonging to our AS. If set to "(inet|inet6)connected", inet or inet6 routes to directly attached networks will be announced.<br /> + If set to "(inet|inet6) static", all inet or inet6 static routes will be announced. + ]]> + </fielddescr> + <fieldname>networks</fieldname> + <description>Network that you would like to advertise</description> + <type>input</type> + <size>45</size> </rowhelperfield> - </rowhelper> + </rowhelper> </field> </fields> <custom_php_deinstall_command> diff --git a/config/openvpn_tapfix_20x/openvpn_tapfix_203.patch b/config/openvpn_tapfix_20x/openvpn_tapfix_203.patch deleted file mode 100644 index 897a1199..00000000 --- a/config/openvpn_tapfix_20x/openvpn_tapfix_203.patch +++ /dev/null @@ -1,290 +0,0 @@ -diff --git /etc/inc/openvpn.inc.orig /etc/inc/openvpn.inc -index 777b395..701a032 100644 ---- a/etc/inc/openvpn.inc -+++ b/etc/inc/openvpn.inc -@@ -394,19 +394,37 @@ function openvpn_reconfigure($mode, $settings) { - // If the CIDR is less than a /30, OpenVPN will complain if you try to - // use the server directive. It works for a single client without it. - // See ticket #1417 -- if ($cidr < 30) { -+ if (!empty($ip) && !empty($mask) && ($cidr < 30)) { - $conf .= "server {$ip} {$mask}\n"; - $conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; - } - case 'p2p_shared_key': -- list($ip1, $ip2) = openvpn_get_interface_ip($ip, $mask); -- $conf .= "ifconfig $ip1 $ip2\n"; -+ if (!empty($ip) && !empty($mask)) { -+ list($ip1, $ip2) = openvpn_get_interface_ip($ip, $mask); -+ $conf .= "ifconfig $ip1 $ip2\n"; -+ } - break; - case 'server_tls': - case 'server_user': - case 'server_tls_user': -- $conf .= "server {$ip} {$mask}\n"; -- $conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; -+ if (!empty($ip) && !empty($mask)) { -+ $conf .= "server {$ip} {$mask}\n"; -+ $conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; -+ } else { -+ if ($settings['serverbridge_dhcp']) { -+ if ((!empty($settings['serverbridge_interface'])) && (strcmp($settings['serverbridge_interface'], "none"))) { -+ $biface_ip=get_interface_ip($settings['serverbridge_interface']); -+ $biface_sm=gen_subnet_mask(get_interface_subnet($settings['serverbridge_interface'])); -+ if (is_ipaddr($biface_ip) && is_ipaddr($settings['serverbridge_dhcp_start']) && is_ipaddr($settings['serverbridge_dhcp_end'])) { -+ $conf .= "server-bridge {$biface_ip} {$biface_sm} {$settings['serverbridge_dhcp_start']} {$settings['serverbridge_dhcp_end']}\n"; -+ } else { -+ $conf .= "mode server\n"; -+ } -+ } else { -+ $conf .= "mode server\n"; -+ } -+ } -+ } - break; - } - -@@ -452,7 +452,9 @@ function openvpn_reconfigure($mode, $settings) { - case 'server_user': - $conf .= "client-cert-not-required\n"; - case 'server_tls_user': -- $conf .= "username-as-common-name\n"; -+ /* username-as-common-name is not compatible with server-bridge */ -+ if (stristr($conf, "server-bridge") === false) -+ $conf .= "username-as-common-name\n"; - if (!empty($settings['authmode'])) { - $authcfgs = explode(",", $settings['authmode']); - $sed = "\$authmodes=array("; - -diff --git /usr/local/www/vpn_openvpn_server.php.orig /usr/local/www/vpn_openvpn_server.php -index 0ef67a7..bd9f527 100644 ---- a/usr/local/www/vpn_openvpn_server.php -+++ b/usr/local/www/vpn_openvpn_server.php -@@ -147,6 +147,11 @@ if($_GET['act']=="edit"){ - $pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip']; - $pconfig['pool_enable'] = $a_server[$id]['pool_enable']; - -+ $pconfig['serverbridge_dhcp'] = $a_server[$id]['serverbridge_dhcp']; -+ $pconfig['serverbridge_interface'] = $a_server[$id]['serverbridge_interface']; -+ $pconfig['serverbridge_dhcp_start'] = $a_server[$id]['serverbridge_dhcp_start']; -+ $pconfig['serverbridge_dhcp_end'] = $a_server[$id]['serverbridge_dhcp_end']; -+ - $pconfig['dns_domain'] = $a_server[$id]['dns_domain']; - if ($pconfig['dns_domain']) - $pconfig['dns_domain_enable'] = true; -@@ -188,7 +193,6 @@ if($_GET['act']=="edit"){ - $pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']); - } - } -- - if ($_POST) { - - unset($input_errors); -@@ -284,9 +288,22 @@ if ($_POST) { - $reqdfieldsn = array(gettext('Shared key')); - } - -- $reqdfields[] = 'tunnel_network'; -- $reqdfieldsn[] = gettext('Tunnel network'); -- -+ if ($pconfig['dev_mode'] != "tap") { -+ $reqdfields[] = 'tunnel_network'; -+ $reqdfieldsn[] = gettext('Tunnel network'); -+ } else { -+ if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network']) -+ $input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed."); -+ if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) -+ || (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end'])) -+ $input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined."); -+ if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddr($pconfig['serverbridge_dhcp_start']))) -+ $input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address."); -+ if (($pconfig['serverbridge_dhcp_end'] && !is_ipaddr($pconfig['serverbridge_dhcp_end']))) -+ $input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address."); -+ if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end'])) -+ $input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end)."); -+ } - do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); - - if (!$input_errors) { -@@ -341,6 +358,11 @@ if ($_POST) { - $server['dynamic_ip'] = $pconfig['dynamic_ip']; - $server['pool_enable'] = $pconfig['pool_enable']; - -+ $server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp']; -+ $server['serverbridge_interface'] = $pconfig['serverbridge_interface']; -+ $server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start']; -+ $server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end']; -+ - if ($pconfig['dns_domain_enable']) - $server['dns_domain'] = $pconfig['dns_domain']; - -@@ -559,6 +581,56 @@ function netbios_change() { - } - } - -+function tuntap_change() { -+ -+ mindex = document.iform.mode.selectedIndex; -+ mvalue = document.iform.mode.options[mindex].value; -+ -+ switch(mvalue) { -+ case "p2p_tls": -+ case "p2p_shared_key": -+ p2p = true; -+ break; -+ default: -+ p2p = false; -+ break; -+ } -+ -+ index = document.iform.dev_mode.selectedIndex; -+ value = document.iform.dev_mode.options[index].value; -+ switch(value) { -+ case "tun": -+ document.getElementById("ipv4_tunnel_network").className="vncellreq"; -+ document.getElementById("serverbridge_dhcp").style.display="none"; -+ document.getElementById("serverbridge_interface").style.display="none"; -+ document.getElementById("serverbridge_dhcp_start").style.display="none"; -+ document.getElementById("serverbridge_dhcp_end").style.display="none"; -+ break; -+ case "tap": -+ document.getElementById("ipv4_tunnel_network").className="vncell"; -+ if (!p2p) { -+ document.getElementById("serverbridge_dhcp").style.display=""; -+ document.getElementById("serverbridge_interface").style.display=""; -+ document.getElementById("serverbridge_dhcp_start").style.display=""; -+ document.getElementById("serverbridge_dhcp_end").style.display=""; -+ if (document.iform.serverbridge_dhcp.checked) { -+ document.iform.serverbridge_interface.disabled = false; -+ document.iform.serverbridge_dhcp_start.disabled = false; -+ document.iform.serverbridge_dhcp_end.disabled = false; -+ } else { -+ document.iform.serverbridge_interface.disabled = true; -+ document.iform.serverbridge_dhcp_start.disabled = true; -+ document.iform.serverbridge_dhcp_end.disabled = true; -+ } -+ } else { -+ document.iform.serverbridge_dhcp.disabled = true; -+ document.iform.serverbridge_interface.disabled = true; -+ document.iform.serverbridge_dhcp_start.disabled = true; -+ document.iform.serverbridge_dhcp_end.disabled = true; -+ } -+ break; -+ } -+} - //--> - </script> - <?php -@@ -619,7 +691,7 @@ if ($savemsg) - <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td> - <td width="78%" class="vtable"> -- <select name='mode' id='mode' class="formselect" onchange='mode_change()'> -+ <select name='mode' id='mode' class="formselect" onchange='mode_change(); tuntap_change()'> - <?php - foreach ($openvpn_server_modes as $name => $desc): - $selected = ""; -@@ -666,7 +738,7 @@ if ($savemsg) - <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Device Mode"); ?></td> - <td width="78%" class="vtable"> -- <select name="dev_mode" class="formselect"> -+ <select name="dev_mode" class="formselect" onchange='tuntap_change()'> - <?php - foreach ($openvpn_dev_mode as $device): - $selected = ""; -@@ -976,7 +1048,7 @@ if ($savemsg) - <td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td> - </tr> - <tr> -- <td width="22%" valign="top" class="vncellreq"><?=gettext("Tunnel Network"); ?></td> -+ <td width="22%" valign="top" class="vncellreq" id="ipv4_tunnel_network"><?=gettext("Tunnel Network"); ?></td> - <td width="78%" class="vtable"> - <input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>"> - <br> -@@ -989,6 +1061,76 @@ if ($savemsg) - "to connecting clients. (see Address Pool)"); ?> - </td> - </tr> -+ <tr id="serverbridge_dhcp"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Bridge DHCP"); ?></td> -+ <td width="78%" class="vtable"> -+ <table border="0" cellpadding="2" cellspacing="0"> -+ <tr> -+ <td> -+ <?php set_checked($pconfig['serverbridge_dhcp'],$chk); ?> -+ <input name="serverbridge_dhcp" type="checkbox" value="yes" <?=$chk;?> onchange='tuntap_change()' /> -+ </td> -+ <td> -+ <span class="vexpl"> -+ <?=gettext("Allow clients on the bridge to obtain DHCP."); ?><br> -+ </span> -+ </td> -+ </tr> -+ </table> -+ </td> -+ </tr> -+ <tr id="serverbridge_interface"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Bridge Interface"); ?></td> -+ <td width="78%" class="vtable"> -+ <select name="serverbridge_interface" class="formselect"> -+ <?php -+ $serverbridge_interface['none'] = "none"; -+ $serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr()); -+ $carplist = get_configured_carp_interface_list(); -+ foreach ($carplist as $cif => $carpip) -+ $serverbridge_interface[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")"; -+ $aliaslist = get_configured_ip_aliases_list(); -+ foreach ($aliaslist as $aliasip => $aliasif) -+ $serverbridge_interface[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; -+ foreach ($serverbridge_interface as $iface => $ifacename): -+ $selected = ""; -+ if ($iface == $pconfig['serverbridge_interface']) -+ $selected = "selected"; -+ ?> -+ <option value="<?=$iface;?>" <?=$selected;?>> -+ <?=htmlspecialchars($ifacename);?> -+ </option> -+ <?php endforeach; ?> -+ </select> <br> -+ <?=gettext("The interface to which this tap instance will be, " . -+ "bridged. This is not done automatically. You must assign this " . -+ "interface and create the bridge separately. " . -+ "This setting controls which existing IP address and subnet " . -+ "mask are used by OpenVPN for the bridge. Setting this to " . -+ "'none' will cause the Server Bridge DHCP settings below to be ignored."); ?> -+ </td> -+ </tr> -+ <tr id="serverbridge_dhcp_start"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP Start"); ?></td> -+ <td width="78%" class="vtable"> -+ <input name="serverbridge_dhcp_start" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_start']);?>"> -+ <br> -+ <?=gettext("When using tap mode as multi-point server, " . -+ "you may optionally supply a DHCP range to use on the " . -+ "interface to which this tap instance is bridged. " . -+ "If these settings are left blank, DHCP will be passed " . -+ "through to the LAN, and the interface setting above " . -+ "will be ignored."); ?> -+ </td> -+ </tr> -+ <tr id="serverbridge_dhcp_end"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP End"); ?></td> -+ <td width="78%" class="vtable"> -+ <input name="serverbridge_dhcp_end" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_end']);?>"> -+ <br> -+ <?=gettext(""); ?> -+ </td> -+ </tr> - <tr id="gwredir_opts"> - <td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td> - <td width="78%" class="vtable"> -@@ -1486,6 +1628,7 @@ dns_server_change(); - wins_server_change(); - ntp_server_change(); - netbios_change(); -+tuntap_change(); - //--> - </script> - </body> diff --git a/config/openvpn_tapfix_20x/openvpn_tapfix_20x.inc b/config/openvpn_tapfix_20x/openvpn_tapfix_20x.inc deleted file mode 100644 index 8f574212..00000000 --- a/config/openvpn_tapfix_20x/openvpn_tapfix_20x.inc +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -function openvpn_tapfix_20x_install() { - global $g, $config; - $pfs_version = substr(trim(file_get_contents("/etc/version")),0,5); - switch ($pfs_version) { - case "2.0.3": - $patch_file = "openvpn_tapfix_203.patch"; - break; - default: - $patch_file = "openvpn_tapfix_20x.patch"; - } - // Test to make sure the patch is not already applied. - $out = `patch -fslC --reverse -p1 -b .before_openvpn_tapfix_20x -d / -i /usr/local/pkg/{$patch_file} |& grep -ci reject`; - if ($out == 0) { - // If the patch has not already been applied, test to see if it will apply cleanly. - $out = `patch -fsNlC -p1 -b .before_openvpn_tapfix_20x -d / -i /usr/local/pkg/{$patch_file} |& grep -ci reject`; - if ($out == 0) { - // The patch should apply cleanly, let 'er rip. - mwexec("patch -fsNl -p1 -b .before_openvpn_tapfix_20x -d / -i /usr/local/pkg/{$patch_file} "); - } - } -} - -?>
\ No newline at end of file diff --git a/config/openvpn_tapfix_20x/openvpn_tapfix_20x.patch b/config/openvpn_tapfix_20x/openvpn_tapfix_20x.patch deleted file mode 100644 index ed4232bb..00000000 --- a/config/openvpn_tapfix_20x/openvpn_tapfix_20x.patch +++ /dev/null @@ -1,301 +0,0 @@ -diff --git /etc/inc/openvpn.inc.orig /etc/inc/openvpn.inc -index 777b395..701a032 100644 ---- a/etc/inc/openvpn.inc -+++ b/etc/inc/openvpn.inc -@@ -394,21 +394,39 @@ function openvpn_reconfigure($mode, $settings) { - // If the CIDR is less than a /30, OpenVPN will complain if you try to - // use the server directive. It works for a single client without it. - // See ticket #1417 -- if ($cidr < 30) { -+ if (!empty($ip) && !empty($mask) && ($cidr < 30)) { - $conf .= "server {$ip} {$mask}\n"; - $conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; - } - case 'p2p_shared_key': -- $baselong = ip2long32($ip) & ip2long($mask); -- $ip1 = long2ip32($baselong + 1); -- $ip2 = long2ip32($baselong + 2); -- $conf .= "ifconfig $ip1 $ip2\n"; -+ if (!empty($ip) && !empty($mask)) { -+ $baselong = ip2long32($ip) & ip2long($mask); -+ $ip1 = long2ip32($baselong + 1); -+ $ip2 = long2ip32($baselong + 2); -+ $conf .= "ifconfig $ip1 $ip2\n"; -+ } - break; - case 'server_tls': - case 'server_user': - case 'server_tls_user': -- $conf .= "server {$ip} {$mask}\n"; -- $conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; -+ if (!empty($ip) && !empty($mask)) { -+ $conf .= "server {$ip} {$mask}\n"; -+ $conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n"; -+ } else { -+ if ($settings['serverbridge_dhcp']) { -+ if ((!empty($settings['serverbridge_interface'])) && (strcmp($settings['serverbridge_interface'], "none"))) { -+ $biface_ip=get_interface_ip($settings['serverbridge_interface']); -+ $biface_sm=gen_subnet_mask(get_interface_subnet($settings['serverbridge_interface'])); -+ if (is_ipaddr($biface_ip) && is_ipaddr($settings['serverbridge_dhcp_start']) && is_ipaddr($settings['serverbridge_dhcp_end'])) { -+ $conf .= "server-bridge {$biface_ip} {$biface_sm} {$settings['serverbridge_dhcp_start']} {$settings['serverbridge_dhcp_end']}\n"; -+ } else { -+ $conf .= "mode server\n"; -+ } -+ } else { -+ $conf .= "mode server\n"; -+ } -+ } -+ } - break; - } - -@@ -452,7 +452,9 @@ function openvpn_reconfigure($mode, $settings) { - case 'server_user': - $conf .= "client-cert-not-required\n"; - case 'server_tls_user': -- $conf .= "username-as-common-name\n"; -+ /* username-as-common-name is not compatible with server-bridge */ -+ if (stristr($conf, "server-bridge") === false) -+ $conf .= "username-as-common-name\n"; - if (!empty($settings['authmode'])) { - $authcfgs = explode(",", $settings['authmode']); - $sed = "\$authmodes=array("; - -@@ -1021,4 +1039,4 @@ function openvpn_refresh_crls() { - } - } - --?> -\ No newline at end of file -+?> -diff --git /usr/local/www/vpn_openvpn_server.php.orig /usr/local/www/vpn_openvpn_server.php -index 0ef67a7..bd9f527 100644 ---- a/usr/local/www/vpn_openvpn_server.php -+++ b/usr/local/www/vpn_openvpn_server.php -@@ -147,6 +147,11 @@ if($_GET['act']=="edit"){ - $pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip']; - $pconfig['pool_enable'] = $a_server[$id]['pool_enable']; - -+ $pconfig['serverbridge_dhcp'] = $a_server[$id]['serverbridge_dhcp']; -+ $pconfig['serverbridge_interface'] = $a_server[$id]['serverbridge_interface']; -+ $pconfig['serverbridge_dhcp_start'] = $a_server[$id]['serverbridge_dhcp_start']; -+ $pconfig['serverbridge_dhcp_end'] = $a_server[$id]['serverbridge_dhcp_end']; -+ - $pconfig['dns_domain'] = $a_server[$id]['dns_domain']; - if ($pconfig['dns_domain']) - $pconfig['dns_domain_enable'] = true; -@@ -188,7 +193,6 @@ if($_GET['act']=="edit"){ - $pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']); - } - } -- - if ($_POST) { - - unset($input_errors); -@@ -284,9 +288,22 @@ if ($_POST) { - $reqdfieldsn = array(gettext('Shared key')); - } - -- $reqdfields[] = 'tunnel_network'; -- $reqdfieldsn[] = gettext('Tunnel network'); -- -+ if ($pconfig['dev_mode'] != "tap") { -+ $reqdfields[] = 'tunnel_network'; -+ $reqdfieldsn[] = gettext('Tunnel network'); -+ } else { -+ if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network']) -+ $input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed."); -+ if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) -+ || (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end'])) -+ $input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined."); -+ if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddr($pconfig['serverbridge_dhcp_start']))) -+ $input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address."); -+ if (($pconfig['serverbridge_dhcp_end'] && !is_ipaddr($pconfig['serverbridge_dhcp_end']))) -+ $input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address."); -+ if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end'])) -+ $input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end)."); -+ } - do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); - - if (!$input_errors) { -@@ -341,6 +358,11 @@ if ($_POST) { - $server['dynamic_ip'] = $pconfig['dynamic_ip']; - $server['pool_enable'] = $pconfig['pool_enable']; - -+ $server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp']; -+ $server['serverbridge_interface'] = $pconfig['serverbridge_interface']; -+ $server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start']; -+ $server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end']; -+ - if ($pconfig['dns_domain_enable']) - $server['dns_domain'] = $pconfig['dns_domain']; - -@@ -559,6 +581,56 @@ function netbios_change() { - } - } - -+function tuntap_change() { -+ -+ mindex = document.iform.mode.selectedIndex; -+ mvalue = document.iform.mode.options[mindex].value; -+ -+ switch(mvalue) { -+ case "p2p_tls": -+ case "p2p_shared_key": -+ p2p = true; -+ break; -+ default: -+ p2p = false; -+ break; -+ } -+ -+ index = document.iform.dev_mode.selectedIndex; -+ value = document.iform.dev_mode.options[index].value; -+ switch(value) { -+ case "tun": -+ document.getElementById("ipv4_tunnel_network").className="vncellreq"; -+ document.getElementById("serverbridge_dhcp").style.display="none"; -+ document.getElementById("serverbridge_interface").style.display="none"; -+ document.getElementById("serverbridge_dhcp_start").style.display="none"; -+ document.getElementById("serverbridge_dhcp_end").style.display="none"; -+ break; -+ case "tap": -+ document.getElementById("ipv4_tunnel_network").className="vncell"; -+ if (!p2p) { -+ document.getElementById("serverbridge_dhcp").style.display=""; -+ document.getElementById("serverbridge_interface").style.display=""; -+ document.getElementById("serverbridge_dhcp_start").style.display=""; -+ document.getElementById("serverbridge_dhcp_end").style.display=""; -+ if (document.iform.serverbridge_dhcp.checked) { -+ document.iform.serverbridge_interface.disabled = false; -+ document.iform.serverbridge_dhcp_start.disabled = false; -+ document.iform.serverbridge_dhcp_end.disabled = false; -+ } else { -+ document.iform.serverbridge_interface.disabled = true; -+ document.iform.serverbridge_dhcp_start.disabled = true; -+ document.iform.serverbridge_dhcp_end.disabled = true; -+ } -+ } else { -+ document.iform.serverbridge_dhcp.disabled = true; -+ document.iform.serverbridge_interface.disabled = true; -+ document.iform.serverbridge_dhcp_start.disabled = true; -+ document.iform.serverbridge_dhcp_end.disabled = true; -+ } -+ break; -+ } -+} - //--> - </script> - <?php -@@ -619,7 +691,7 @@ if ($savemsg) - <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td> - <td width="78%" class="vtable"> -- <select name='mode' id='mode' class="formselect" onchange='mode_change()'> -+ <select name='mode' id='mode' class="formselect" onchange='mode_change(); tuntap_change()'> - <?php - foreach ($openvpn_server_modes as $name => $desc): - $selected = ""; -@@ -666,7 +738,7 @@ if ($savemsg) - <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Device Mode"); ?></td> - <td width="78%" class="vtable"> -- <select name="dev_mode" class="formselect"> -+ <select name="dev_mode" class="formselect" onchange='tuntap_change()'> - <?php - foreach ($openvpn_dev_mode as $device): - $selected = ""; -@@ -976,7 +1048,7 @@ if ($savemsg) - <td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td> - </tr> - <tr> -- <td width="22%" valign="top" class="vncellreq"><?=gettext("Tunnel Network"); ?></td> -+ <td width="22%" valign="top" class="vncellreq" id="ipv4_tunnel_network"><?=gettext("Tunnel Network"); ?></td> - <td width="78%" class="vtable"> - <input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>"> - <br> -@@ -989,6 +1061,76 @@ if ($savemsg) - "to connecting clients. (see Address Pool)"); ?> - </td> - </tr> -+ <tr id="serverbridge_dhcp"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Bridge DHCP"); ?></td> -+ <td width="78%" class="vtable"> -+ <table border="0" cellpadding="2" cellspacing="0"> -+ <tr> -+ <td> -+ <?php set_checked($pconfig['serverbridge_dhcp'],$chk); ?> -+ <input name="serverbridge_dhcp" type="checkbox" value="yes" <?=$chk;?> onchange='tuntap_change()' /> -+ </td> -+ <td> -+ <span class="vexpl"> -+ <?=gettext("Allow clients on the bridge to obtain DHCP."); ?><br> -+ </span> -+ </td> -+ </tr> -+ </table> -+ </td> -+ </tr> -+ <tr id="serverbridge_interface"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Bridge Interface"); ?></td> -+ <td width="78%" class="vtable"> -+ <select name="serverbridge_interface" class="formselect"> -+ <?php -+ $serverbridge_interface['none'] = "none"; -+ $serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr()); -+ $carplist = get_configured_carp_interface_list(); -+ foreach ($carplist as $cif => $carpip) -+ $serverbridge_interface[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")"; -+ $aliaslist = get_configured_ip_aliases_list(); -+ foreach ($aliaslist as $aliasip => $aliasif) -+ $serverbridge_interface[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; -+ foreach ($serverbridge_interface as $iface => $ifacename): -+ $selected = ""; -+ if ($iface == $pconfig['serverbridge_interface']) -+ $selected = "selected"; -+ ?> -+ <option value="<?=$iface;?>" <?=$selected;?>> -+ <?=htmlspecialchars($ifacename);?> -+ </option> -+ <?php endforeach; ?> -+ </select> <br> -+ <?=gettext("The interface to which this tap instance will be, " . -+ "bridged. This is not done automatically. You must assign this " . -+ "interface and create the bridge separately. " . -+ "This setting controls which existing IP address and subnet " . -+ "mask are used by OpenVPN for the bridge. Setting this to " . -+ "'none' will cause the Server Bridge DHCP settings below to be ignored."); ?> -+ </td> -+ </tr> -+ <tr id="serverbridge_dhcp_start"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP Start"); ?></td> -+ <td width="78%" class="vtable"> -+ <input name="serverbridge_dhcp_start" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_start']);?>"> -+ <br> -+ <?=gettext("When using tap mode as multi-point server, " . -+ "you may optionally supply a DHCP range to use on the " . -+ "interface to which this tap instance is bridged. " . -+ "If these settings are left blank, DHCP will be passed " . -+ "through to the LAN, and the interface setting above " . -+ "will be ignored."); ?> -+ </td> -+ </tr> -+ <tr id="serverbridge_dhcp_end"> -+ <td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP End"); ?></td> -+ <td width="78%" class="vtable"> -+ <input name="serverbridge_dhcp_end" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_end']);?>"> -+ <br> -+ <?=gettext(""); ?> -+ </td> -+ </tr> - <tr id="gwredir_opts"> - <td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td> - <td width="78%" class="vtable"> -@@ -1486,6 +1628,7 @@ dns_server_change(); - wins_server_change(); - ntp_server_change(); - netbios_change(); -+tuntap_change(); - //--> - </script> - </body> diff --git a/config/openvpn_tapfix_20x/openvpn_tapfix_20x.xml b/config/openvpn_tapfix_20x/openvpn_tapfix_20x.xml deleted file mode 100644 index ef498545..00000000 --- a/config/openvpn_tapfix_20x/openvpn_tapfix_20x.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?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[ -/* $Id$ */ -/* ========================================================================== */ -/* - openvpn_tapfix_20x.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2011 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>OpenVPN tap Bridging Fix</description> - <requirements>pfSense 2.0.x</requirements> - <faq>None</faq> - <name>OpenVPN tap Bridging Fix</name> - <version>0.4</version> - <title>OpenVPN tap Bridging Fix</title> - <include_file>/usr/local/pkg/openvpn_tapfix_20x.inc</include_file> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/openvpn_tapfix_20x/openvpn_tapfix_20x.inc</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/openvpn_tapfix_20x/openvpn_tapfix_20x.patch</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/openvpn_tapfix_20x/openvpn_tapfix_203.patch</item> - </additional_files_needed> - <custom_php_install_command> - openvpn_tapfix_20x_install(); - </custom_php_install_command> -</packagegui> diff --git a/config/pfflowd/pfflowd.xml b/config/pfflowd/pfflowd.xml index ea32c858..44294d69 100644 --- a/config/pfflowd/pfflowd.xml +++ b/config/pfflowd/pfflowd.xml @@ -122,7 +122,6 @@ <![CDATA[ function sync_package_pfflowd() { conf_mount_rw(); - config_lock(); global $config; foreach ($config['installedpackages']['pfflowd']['config'] as $cf) { if ($cf['host'] != "") { @@ -152,7 +151,6 @@ } } conf_mount_ro(); - config_unlock(); } function validate_form_pfflowd($post, &$input_errors) { diff --git a/config/phpservice/phpservice.inc b/config/phpservice/phpservice.inc index 6236d0b6..cffdb09f 100644 --- a/config/phpservice/phpservice.inc +++ b/config/phpservice/phpservice.inc @@ -1,14 +1,11 @@ <?php -/* $Id$ */ -/* -/* ========================================================================== */ -/* - phpservice.inc - Copyright (C) 2008 Mark J Crane - All rights reserved. - */ -/* ========================================================================== */ /* + phpservice.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Mark J Crane + 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: @@ -30,199 +27,100 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +function phpservice_sync_package() { + global $config; + + if ($config['installedpackages']['phpservice']['config'] != "") { + + conf_mount_rw(); + $tmp = <<<EOF +<?php + +// Set time limit to indefinite execution +set_time_limit (0); -if (!function_exists("pkg_is_service_running")) { - function pkg_is_service_running($servicename) - { - exec("/bin/ps ax | awk '{ print $5 }'", $psout); - array_shift($psout); - foreach($psout as $line) { - $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); - } - if(is_service_running($servicename, $ps) or is_process_running($servicename) ) { - return true; - } - else { - return false; - } +//run this program as long as the pid file exists +$filename = '/tmp/phpmonitor.pid'; +$fp = fopen($filename, 'w'); +fwrite($fp, "If this file is deleted then phpmonitor will stop."); +fclose($fp); +unset($filename); + +function send_to_syslog($syslogaddress, $syslogport, $syslogmsg) { + + $syslogaddress = "127.0.0.1"; + $syslogport = 514; + + $fp = fsockopen("udp://".$syslogaddress, $syslogport, $errno, $errstr); + if (!$fp) { + return; + } else { + fwrite($fp, $syslogmsg); + fclose($fp); } } -if (!function_exists("byte_convert")) { - function byte_convert( $bytes ) { - if ($bytes<=0) - return '0 Byte'; +$x = 0; +while ($x == 0) { - $convention=1000; //[1000->10^x|1024->2^x] - $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); - $e=floor(log($bytes,$convention)); - return round($bytes/pow($convention,$e),2).' '.$s[$e]; - } +// If the pid file does not exist then close the program. +if (!file_exists('/tmp/phpmonitor.pid')) { + return; } - -function phpservice_sync_package_php() -{ - - global $config; - if($config['installedpackages']['phpservice']['config'] != "") { - - conf_mount_rw(); - config_unlock(); - - $tmp = "<?php\n"; - $tmp .= "\n"; - $tmp .= "// Set time limit to indefinite execution\n"; - $tmp .= "set_time_limit (0);\n"; - $tmp .= "\n"; - $tmp .= "//run this program as long as the pid file exists\n"; - $tmp .= "\$filename = '/tmp/phpmonitor.pid';\n"; - $tmp .= "\$fp = fopen(\$filename, 'w');\n"; - $tmp .= "fwrite(\$fp, \"If this file is deleted then phpmonitor will stop.\");\n"; - $tmp .= "fclose(\$fp);\n"; - $tmp .= "unset(\$filename);\n"; - $tmp .= "\n"; - $tmp .= "//require_once(\"config.inc\");\n"; - $tmp .= "//global \$config;\n"; - $tmp .= "//\$syslogaddress = \$config['syslog']['remoteserver'];\n"; - $tmp .= "\$syslogaddress = \"127.0.0.1\";\n"; - $tmp .= "\$syslogport = 514;\n"; - $tmp .= "echo \"syslog server: \".\$syslogaddress.\"\\n\";\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= "function send_to_syslog(\$syslogaddress, \$syslogport, \$syslogmsg) {\n"; - $tmp .= "\n"; - $tmp .= " \$fp = fsockopen(\"udp://\".\$syslogaddress, \$syslogport, \$errno, \$errstr);\n"; - $tmp .= " if (!\$fp) {\n"; - $tmp .= " //echo \"ERROR: \$errno - \$errstr<br />\\n\";\n"; - $tmp .= " } else {\n"; - $tmp .= " fwrite(\$fp, \$syslogmsg);\n"; - $tmp .= " fclose(\$fp);\n"; - $tmp .= " }\n"; - $tmp .= "\n"; - $tmp .= "}\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= "//\$msg = \"1.begin loop. \".date('r').\"\\n\";\n"; - $tmp .= "//\$fp = fopen('/tmp/phpmonitor.txt', 'a');\n"; - $tmp .= "//fwrite(\$fp, \$msg.\"\\n\");\n"; - $tmp .= "//fclose(\$fp);\n"; - $tmp .= "\n"; - $tmp .= "\$x = 0;\n"; - $tmp .= "while(\$x == 0) {\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= " if(!file_exists('/tmp/phpmonitor.pid')) {\n"; - $tmp .= " //if the file does not exist then close the program.\n"; - $tmp .= " echo \"program closing\\n\";\n"; - $tmp .= " return;\n"; - $tmp .= " }\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= "\n"; - - foreach($config['installedpackages']['phpservice']['config'] as $rowhelper) { + +EOF; + + foreach ($config['installedpackages']['phpservice']['config'] as $rowhelper) { if ($rowhelper['enabled'] != "false") { $tmp_php = base64_decode($rowhelper['php']); if (strlen($tmp_php) > 0) { $tmp .= "// name: ".$rowhelper['name']." \n"; - $tmp .= "// description: ".$rowhelper['description']." \n\n"; + $tmp .= "// description: ".$rowhelper['description']." \n\n"; $tmp .= base64_decode($rowhelper['php']); $tmp .= "\n"; } } - } - - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= " //usleep(100000); //micro seconds //2 seconds 2000000\n"; - $tmp .= " sleep(1); //in seconds\n"; - $tmp .= " //if (\$x > 60){ exit; } //exit after 60 seconds for testing\n"; - $tmp .= "} //emd while\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= "?>"; - - $fout = fopen("/usr/local/pkg/phpservice.php","w"); - fwrite($fout, $tmp); - unset($tmp); - fclose($fout); - - conf_mount_ro(); - } -} + $tmp .= <<< EOF - -function phpservice_sync_package() -{ - - global $config; - phpservice_sync_package_php(); +sleep(1); } - +?> -function phpservice_install_command() -{ +EOF; - global $config; - conf_mount_rw(); - config_lock(); + $fout = fopen("/usr/local/pkg/phpservice.php", "w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); - if (!is_dir('/usr/local/www/packages/')) { - exec("mkdir /usr/local/www/packages/"); - } - - if (!is_dir('/usr/local/www/packages/phpservice/')) { - exec("mkdir /usr/local/www/packages/phpservice/"); + restart_service("phpservice"); + conf_mount_ro(); + } else { + stop_service("phpservice"); } +} - - //rename PHP files from .tmp to .php - exec("cp /tmp/phpservice_php.tmp /usr/local/www/packages/phpservice/phpservice_php.php"); - unlink_if_exists("/tmp/phpservice_php.tmp"); - - exec("cp /tmp/phpservice_php_edit.tmp /usr/local/www/packages/phpservice/phpservice_php_edit.php"); - unlink_if_exists("/tmp/phpservice_php_edit.tmp"); - - //write_config(); - +function phpservice_install_command() { + conf_mount_rw(); write_rcfile(array( "file" => "phpservice.sh", "start" => "/usr/local/bin/php /usr/local/pkg/phpservice.php >> /var/log/phpservice.log &", - "stop" => "rm /tmp/phpmonitor.pid" + "stop" => "/bin/rm -f /tmp/phpmonitor.pid; sleep 3" ) ); - phpservice_sync_package(); - //$handle = popen("/usr/local/etc/rc.d/phpservice.sh start", "r"); - //pclose($handle); - - //if (pkg_is_service_running('phpservice')) { - //documentation purposes - //} - conf_mount_ro(); - config_unlock(); - } -function phpservice_deinstall_command() -{ - +function phpservice_deinstall_command() { conf_mount_rw(); - config_lock(); - $handle = popen("/usr/local/etc/rc.d/phpservice.sh stop", "r"); - unlink_if_exists("/usr/local/pkg/phpservice.xml"); - unlink_if_exists("/usr/local/pkg/phpservice.inc"); - unlink_if_exists("/usr/local/www/phpservice.inc"); + stop_service("phpservice"); unlink_if_exists("/usr/local/etc/rc.d/phpservice.sh"); conf_mount_ro(); - config_unlock(); - } ?> diff --git a/config/phpservice/phpservice.xml b/config/phpservice/phpservice.xml index eb7e670e..e437be20 100644 --- a/config/phpservice/phpservice.xml +++ b/config/phpservice/phpservice.xml @@ -1,47 +1,49 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - phpservice.xml - Copyright (C) 2008 Mark J Crane - All rights reserved. - */ -/* ========================================================================== */ + phpservice.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Mark J Crane + 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: + 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. + 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>PHP Service</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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>PHP Service</description> <name>PHP Service Settings</name> - <version>0.4.1</version> + <version>0.5.0</version> <title>Settings</title> <include_file>/usr/local/pkg/phpservice.inc</include_file> <menu> @@ -55,66 +57,27 @@ <name>phpservice</name> <rcfile>phpservice.sh</rcfile> <executable>phpservice</executable> - <description>PHP run from a command line as a service.</description> + <description>PHP script as a service</description> <custom_php_service_status_command> - exec("/bin/pgrep -f phpservice"); + exec("/bin/pgrep -fq phpservice"); </custom_php_service_status_command> </service> - <tabs> - <tab> - <text>Settings</text> - <url>/pkg_edit.php?xml=phpservice.xml&id=0</url> - <active/> - </tab> - <tab> - <text>Settings</text> - <url>/packages/phpservice_php.php</url> - <active/> - </tab> - </tabs> - <configpath>installedpackages->package->$packagename->configuration->phpservice</configpath> + <configpath>installedpackages->package->$packagename->configuration->phpservice</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/phpservice/phpservice.xml</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/phpservice/phpservice.inc</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/phpservice/phpservice_php.tmp</item> + <prefix>/usr/local/www/packages/phpservice/</prefix> + <item>https://packages.pfsense.org/packages/config/phpservice/phpservice_php.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/phpservice/phpservice_php_edit.tmp</item> - </additional_files_needed> - <fields> - <field> - <fielddescr>Variable One</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - <field> - <fielddescr>Variable Two</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - </fields> - <custom_add_php_command> - </custom_add_php_command> + <prefix>/usr/local/www/packages/phpservice/</prefix> + <item>https://packages.pfsense.org/packages/config/phpservice/phpservice_php_edit.php</item> + </additional_files_needed> <custom_php_resync_config_command> phpservice_sync_package(); </custom_php_resync_config_command> - <custom_delete_php_command> - phpservice_sync_package(); - </custom_delete_php_command> <custom_php_install_command> phpservice_install_command(); </custom_php_install_command> diff --git a/config/phpservice/phpservice_php.php b/config/phpservice/phpservice_php.php new file mode 100644 index 00000000..582d2f41 --- /dev/null +++ b/config/phpservice/phpservice_php.php @@ -0,0 +1,151 @@ +<?php +/* + phpservice_php.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Mark J Crane + 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. +*/ +require("guiconfig.inc"); +require("/usr/local/pkg/phpservice.inc"); + +$a_phpservice = &$config['installedpackages']['phpservice']['config']; + +if ($_GET['act'] == "del") { + if ($_GET['type'] == 'php') { + if ($a_phpservice[$_GET['id']]) { + unset($a_phpservice[$_GET['id']]); + write_config(); + header("Location: phpservice_php.php"); + exit; + } + } +} + +$pgtitle = "PHP Service"; +include("head.inc"); + +?> + + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> + +<div id="mainlevel"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabnavtbl"> +<?php + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/packages/phpservice/phpservice_php.php"); + display_top_tabs($tab_array); + +?> +</td></tr> +</table> + +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabcont" > + <form action="phpservice_php.php" method="post" name="iform" id="iform"> +<?php +if ($config_change == 1) { + write_config(); + $config_change = 0; +} +?> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr><td> + <div> + The custom PHP code that is defined below is run over and over again inside a continuous loop. There are many possible uses such as monitoring CPU, Memory, File System Space, interacting with Snort, and many others uses that are yet to be discovered.<br /> + It can send events to the sylog that will can be viewed from the system log or remote syslog server. Example: <em>exec("logger This is a test");</em><br /><br /> + For more information see: <a href='https://doc.pfsense.org/index.php/PHPService'>https://doc.pfsense.org/index.php/PHPService</a> + </div> + </td></tr> + </table> + <br /> + + <table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="30%" class="listhdrr">Name</td> + <td width="20%" class="listhdrr">Enabled</td> + <td width="40%" class="listhdr">Description</td> + <td width="10%" class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="phpservice_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" /></a></td> + </tr> + </table> + </td> + </tr> + + <?php + $i = 0; + if (count($a_phpservice) > 0) { + foreach ($a_phpservice as $ent) { + ?> + <tr> + <td class="listr" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"><?=$ent['name'];?> </td> + <td class="listr" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"><?=$ent['enabled'];?> </td> + <td class="listbg" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"><?=htmlspecialchars($ent['description']);?> </td> + <td valign="middle" nowrap class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td valign="middle"><a href="phpservice_php_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" /></a></td> + <td><a href="phpservice_php_edit.php?type=php&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" /></a></td> + </tr> + </table> + </td> + </tr> + <?php $i++; + } + } + ?> + + <tr> + <td class="list" colspan="3"></td> + <td class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="phpservice_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" /></a></td> + </tr> + </table> + </td> + </tr> + <tr> + <td class="list" colspan="3"></td> + <td class="list"></td> + </tr> + </table> + </form> +<br /> + +</td></tr> +</table> +</div> + +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/phpservice/phpservice_php.tmp b/config/phpservice/phpservice_php.tmp deleted file mode 100644 index 55de1ae8..00000000 --- a/config/phpservice/phpservice_php.tmp +++ /dev/null @@ -1,192 +0,0 @@ -<?php -/* $Id$ */ -/* - phpservice_php.php - Copyright (C) 2008 Mark J Crane - 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. -*/ - -require("guiconfig.inc"); -require("/usr/local/pkg/phpservice.inc"); - -$a_phpservice = &$config['installedpackages']['phpservice']['config']; - - -if ($_GET['act'] == "del") { - if ($_GET['type'] == 'php') { - if ($a_phpservice[$_GET['id']]) { - unset($a_phpservice[$_GET['id']]); - write_config(); - header("Location: phpservice_php.php"); - exit; - } - } -} - -include("head.inc"); - -?> - - -<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<?php include("fbegin.inc"); ?> -<p class="pgtitle">PHP Service:</p> - -<div id="mainlevel"> -<table width="100%" border="0" cellpadding="0" cellspacing="0"> -<tr><td class="tabnavtbl"> -<?php - - $tab_array = array(); - $tab_array[] = array(gettext("Settings"), false, "/packages/phpservice/phpservice_php.php"); - display_top_tabs($tab_array); - -?> -</td></tr> -</table> - -<table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td class="tabcont" > - -<form action="phpservice_php.php" method="post" name="iform" id="iform"> -<?php - -if ($config_change == 1) { - write_config(); - $config_change = 0; -} - -//if ($savemsg) print_info_box($savemsg); -//if (file_exists($d_hostsdirty_path)): echo"<p>"; -//print_info_box_np("This is an info box."); -//echo"<br />"; -//endif; - -?> - <table width="100%" border="0" cellpadding="6" cellspacing="0"> - <tr> - <td><p><!--<span class="vexpl"><span class="red"><strong>PHP Service<br></strong></span>--> - Is command line PHP designed to run PHP as a Service. The custom PHP code that is defined below is run over and over again inside a continuous loop. There are many possible uses such as monitoring CPU, Memory, File System Space, interacting with Snort, and many others uses that are yet to be discovered. - It can send events to the sylog that will can be viewed from the system log or remote syslog server. example: exec("logger This is a test"); - <br /><br /> - For more information see: <a href='https://doc.pfsense.org/index.php/PHPService'>https://doc.pfsense.org/index.php/PHPService</a> - </p></td> - </tr> - </table> - <br /> - - <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td width="30%" class="listhdrr">Name</td> - <td width="20%" class="listhdrr">Enabled</td> - <td width="40%" class="listhdr">Description</td> - <td width="10%" class="list"> - - <table border="0" cellspacing="0" cellpadding="1"> - <tr> - <td width="17"></td> - <td valign="middle"><a href="phpservice_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> - </tr> - </table> - - </td> - </tr> - - - <?php - - $i = 0; - if (count($a_phpservice) > 0) { - - foreach ($a_phpservice as $ent) { - - ?> - <tr> - <td class="listr" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"> - <?=$ent['name'];?> - </td> - <td class="listr" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"> - <?=$ent['enabled'];?> - </td> - <td class="listbg" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"> - <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?> - </td> - <td valign="middle" nowrap class="list"> - <table border="0" cellspacing="0" cellpadding="1"> - <tr> - <td valign="middle"><a href="phpservice_php_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> - <td><a href="phpservice_php_edit.php?type=php&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> - </tr> - </table> - </td> - </tr> - <?php - - $i++; - } - } - ?> - - <tr> - <td class="list" colspan="3"></td> - <td class="list"> - <table border="0" cellspacing="0" cellpadding="1"> - <tr> - <td width="17"></td> - <td valign="middle"><a href="phpservice_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> - </tr> - </table> - </td> - </tr> - - - <tr> - <td class="list" colspan="3"></td> - <td class="list"></td> - </tr> - </table> - -</form> - - -<br> -<br> -<br> -<br> -<br> -<br> -<br> -<br> - -</td> -</tr> -</table> - -</div> - - -<?php include("fend.inc"); ?> -</body> -</html> diff --git a/config/phpservice/phpservice_php_edit.php b/config/phpservice/phpservice_php_edit.php new file mode 100644 index 00000000..9727add6 --- /dev/null +++ b/config/phpservice/phpservice_php_edit.php @@ -0,0 +1,180 @@ +<?php +/* + phpservice_php_edit.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Mark J Crane + 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. +*/ +require("guiconfig.inc"); +require("/usr/local/pkg/phpservice.inc"); + +$a_phpservice = &$config['installedpackages']['phpservice']['config']; + +$id = $_GET['id']; +if (isset($_POST['id'])) { + $id = $_POST['id']; +} + +if ($_GET['act'] == "del") { + if ($_GET['type'] == 'php') { + if ($a_phpservice[$_GET['id']]) { + unset($a_phpservice[$_GET['id']]); + write_config(); + phpservice_sync_package(); + header("Location: phpservice_php.php"); + exit; + } + } +} + +if (isset($id) && $a_phpservice[$id]) { + $pconfig['name'] = $a_phpservice[$id]['name']; + $pconfig['php'] = base64_decode($a_phpservice[$id]['php']); + $pconfig['enabled'] = $a_phpservice[$id]['enabled']; + $pconfig['description'] = $a_phpservice[$id]['description']; +} + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + if (!$input_errors) { + + $ent = array(); + $ent['name'] = $_POST['name']; + $ent['php'] = base64_encode($_POST['php']); + $ent['enabled'] = $_POST['enabled']; + $ent['description'] = $_POST['description']; + + if (isset($id) && $a_phpservice[$id]) { + //update + $a_phpservice[$id] = $ent; + } + else { + //add + $a_phpservice[] = $ent; + } + + write_config(); + phpservice_sync_package(); + + header("Location: phpservice_php.php"); + exit; + } +} + +$pgtitle = "PHP Service: Edit"; +include("head.inc"); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<script type="text/javascript"> +//<![CDATA[ +function show_advanced_config() { + document.getElementById("showadvancedbox").innerHTML=''; + aodiv = document.getElementById('showadvanced'); + aodiv.style.display = "block"; +//]]> +</script> + +<div id="mainlevel"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/packages/phpservice/phpservice_php.php"); + display_top_tabs($tab_array); +?> +</td></tr> +</table> + +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabcont"><br /> + <form action="phpservice_php_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="25%" valign="top" class="vncellreq">Name</td> + <td width="75%" class="vtable"><input name="name" type="text" class="formfld" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" /></td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">PHP</td> + <td width="78%" class="vtable"> + <?php + echo "<textarea name=\"php\" id=\"php\" cols=\"70\" rows=\"15\" wrap=\"off\">" . htmlspecialchars($pconfig['php']) . "</textarea>\n"; + ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Enabled</td> + <td width="78%" class="vtable"> + <?php + echo "\t\t<select name='enabled' class='formfld'>\n"; + echo "\t\t\t<option></option>\n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo "\t\t\t<option value='true' selected='selected'>true</option>\n"; + echo "\t\t\t<option value='false'>false</option>\n"; + break; + case "false": + echo "\t\t\t<option value='true'>true</option>\n"; + echo "\t\t\t<option value='false' selected='selected'>false</option>\n"; + break; + default: + echo "\t\t\t<option value='true' selected='selected'>true</option>\n"; + echo "\t\t\t<option value='false'>false</option>\n"; + } + echo "\t\t</select>\n"; + ?> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">Description</td> + <td width="75%" class="vtable"> + <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>" /> + <br /><span class="vexpl">Enter the description here.<br /></span> + </td> + </tr> + <tr> + <td valign="top"> </td> + <td> + <input name="Submit" type="submit" class="formbtn" value="Save" /> <input class="formbtn" type="button" value="Cancel" onclick="history.back()" /> + <?php if (isset($id) && $a_phpservice[$id]): ?><input name="id" type="hidden" value="<?=$id;?>" /><?php endif; ?> + </td> + </tr> + </table> + </form> + <br /> + +</td></tr> +</table> +</div> + +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/phpservice/phpservice_php_edit.tmp b/config/phpservice/phpservice_php_edit.tmp deleted file mode 100644 index 20a9998a..00000000 --- a/config/phpservice/phpservice_php_edit.tmp +++ /dev/null @@ -1,225 +0,0 @@ -<?php -/* $Id$ */ -/* - - phpservice_php_edit.php - Copyright (C) 2008 Mark J Crane - 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. -*/ - -require("guiconfig.inc"); -require("/usr/local/pkg/phpservice.inc"); - - -$a_phpservice = &$config['installedpackages']['phpservice']['config']; - -$id = $_GET['id']; -if (isset($_POST['id'])) { - $id = $_POST['id']; -} - -if ($_GET['act'] == "del") { - if ($_GET['type'] == 'php') { - if ($a_phpservice[$_GET['id']]) { - unset($a_phpservice[$_GET['id']]); - write_config(); - phpservice_sync_package(); - header("Location: phpservice_php.php"); - exit; - } - } -} - -if (isset($id) && $a_phpservice[$id]) { - - $pconfig['name'] = $a_phpservice[$id]['name']; - $pconfig['php'] = base64_decode($a_phpservice[$id]['php']); - $pconfig['enabled'] = $a_phpservice[$id]['enabled']; - $pconfig['description'] = $a_phpservice[$id]['description']; - -} - -if ($_POST) { - - unset($input_errors); - $pconfig = $_POST; - - if (!$input_errors) { - - $ent = array(); - $ent['name'] = $_POST['name']; - $ent['php'] = base64_encode($_POST['php']); - $ent['enabled'] = $_POST['enabled']; - $ent['description'] = $_POST['description']; - - if (isset($id) && $a_phpservice[$id]) { - //update - $a_phpservice[$id] = $ent; - } - else { - //add - $a_phpservice[] = $ent; - } - - write_config(); - phpservice_sync_package(); - - header("Location: phpservice_php.php"); - exit; - } -} - -include("head.inc"); - -?> - -<script type="text/javascript" language="JavaScript"> - -function show_advanced_config() { - document.getElementById("showadvancedbox").innerHTML=''; - aodiv = document.getElementById('showadvanced'); - aodiv.style.display = "block"; -</script> - -<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<?php include("fbegin.inc"); ?> -<p class="pgtitle">PHP Service: Edit</p> -<?php if ($input_errors) print_input_errors($input_errors); ?> - - -<div id="mainlevel"> -<table width="100%" border="0" cellpadding="0" cellspacing="0"> -<tr><td class="tabnavtbl"> -<?php - - $tab_array = array(); - $tab_array[] = array(gettext("Settings"), false, "/packages/phpservice/phpservice_php.php"); - display_top_tabs($tab_array); - -?> -</td></tr> -</table> -<table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td class="tabcont" > - - <!-- - <table width="100%" border="0" cellpadding="6" cellspacing="0"> - <tr> - <td><p><span class="vexpl"><span class="red"><strong>PHP<br> - </strong></span> - </p></td> - </tr> - </table> - --> - <br /> - - <form action="phpservice_php_edit.php" method="post" name="iform" id="iform"> - <table width="100%" border="0" cellpadding="6" cellspacing="0"> - - <tr> - <td width="25%" valign="top" class="vncellreq">Name</td> - <td width="75%" class="vtable"> - <input name="name" type="text" class="formfld" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>"> - </td> - </tr> - - <tr> - <td width="22%" valign="top" class="vncell">PHP</td> - <td width="78%" class="vtable"> - <?php - echo "<textarea name=\"php\" id=\"php\" cols=\"70\" rows=\"15\" wrap=\"off\">".htmlspecialchars($pconfig['php'])."</textarea>\n"; - ?> - <!-- - <br> - <select name='dialplan_expression_select' id='dialplan_expression_select' onchange="document.getElementById('dialplan_expression').value += document.getElementById('dialplan_expression_select').value + '\n';" class='formfld'> - <option></option> - <option value='snortkillsessions'>snort kill sessions</option> - </select> - <span class="vexpl"> - <br /> - </span> - --> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vncellreq">Enabled</td> - <td width="78%" class="vtable"> - <?php - echo " <select name='enabled' class='formfld'>\n"; - echo " <option></option>\n"; - switch (htmlspecialchars($pconfig['enabled'])) { - case "true": - echo " <option value='true' selected='yes'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - break; - case "false": - echo " <option value='true'>true</option>\n"; - echo " <option value='false' selected='yes'>false</option>\n"; - - break; - default: - echo " <option value='true' selected='yes'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - } - echo " </select>\n"; - ?> - </td> - </tr> - <tr> - <td width="25%" valign="top" class="vncellreq">Description</td> - <td width="75%" class="vtable"> - <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>"> - <br><span class="vexpl">Enter the description here.<br></span> - </td> - </tr> - - <tr> - <td valign="top"> </td> - <td> - <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> - <?php if (isset($id) && $a_phpservice[$id]): ?> - <input name="id" type="hidden" value="<?=$id;?>"> - <?php endif; ?> - </td> - </tr> - </table> - </form> - - <br> - <br> - <br> - <br> - <br> - <br> - - </td> - </tr> -</table> - -</div> - -<?php include("fend.inc"); ?> -</body> -</html> diff --git a/config/phpsysinfo/phpsysinfo.inc b/config/phpsysinfo/phpsysinfo.inc index f6b8d264..54ece241 100644 --- a/config/phpsysinfo/phpsysinfo.inc +++ b/config/phpsysinfo/phpsysinfo.inc @@ -1,17 +1,14 @@ <?php function phpsysinfo_install_deinstall() { conf_mount_rw(); - config_lock(); exec("cd /var/db/pkg/ && pkg_delete `ls | grep mbmon`"); exec("rm -d -R /usr/local/www/phpsysinfo"); conf_mount_ro(); - config_unlock(); } function phpsysinfo_install_config() { global $config, $g; conf_mount_rw(); - config_lock(); exec("cd .."); exec("tar -zxovf /usr/local/pkg/phpsysinfo-2.5.4.tar.gz"); exec("mv phpsysinfo /usr/local/www/phpsysinfo"); @@ -155,6 +152,5 @@ fwrite($hf, '?>'); fwrite($hf, "\n"); fclose($hf); conf_mount_ro(); - config_unlock(); } ?> diff --git a/config/pure-ftpd/pure-ftpd.xml b/config/pure-ftpd/pure-ftpd.xml deleted file mode 100644 index e5dcc79f..00000000 --- a/config/pure-ftpd/pure-ftpd.xml +++ /dev/null @@ -1,149 +0,0 @@ -<?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[ -/* $Id$ */ -/* ========================================================================== */ -/* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> - <name>pure-ftpd</name> - <version>1.0.20_1</version> - <title>Services: PureFTPD Accounts</title> - <!-- Menu is where this packages menu will appear --> - <menu> - <name>Pure FTPD Accounts</name> - <tooltiptext>Pure FTPd Server is a fast, production quality, standards-conformant FTP server based on Troll-FTPd. It has no known vulnerability, it is trivial to set up, and it is especially designed for modern kernels. Features include PAM support, IPv6, chroot()ed home directories, virtual domains, built-in 'ls', FXP protocol, anti-warez system, bandwidth throttling, restricted ports for passive downloads, an LDAP backend, XML output, and more.</tooltiptext> - <section>Services</section> - <configfile>pure-ftpd.xml</configfile> - </menu> - <menu> - <name>Pure FTPD Settings</name> - <tooltiptext>Pure FTPd Server is a fast, production quality, standards-conformant FTP server based on Troll-FTPd. It has no known vulnerability, it is trivial to set up, and it is especially designed for modern kernels. Features include PAM support, IPv6, chroot()ed home directories, virtual domains, built-in 'ls', FXP protocol, anti-warez system, bandwidth throttling, restricted ports for passive downloads, an LDAP backend, XML output, and more.</tooltiptext> - <section>Services</section> - <url>pkg_edit.php?xml=pure-ftpdsettings.xml&id=0</url> - </menu> - <!-- configpath gets expanded out automatically and config items will be - stored in that location seperated with -> --> - <configpath>installedpackages->package->$packagename->configuration</configpath> - <!-- adddeleteeditpagefields items will appear on the first page where you can add / delete or edit - items. An example of this would be the nat page where you add new nat redirects --> - <adddeleteeditpagefields> - <columnitem> - <fielddescr>Username</fielddescr> - <fieldname>username</fieldname> - </columnitem> - <columnitem> - <fielddescr>Description</fielddescr> - <fieldname>description</fieldname> - </columnitem> - </adddeleteeditpagefields> - - <additional_files_needed> - <item>https://packages.pfsense.org/packages/config/pure-ftpd/pure-ftpdsettings.xml</item> - </additional_files_needed> - - <!-- fields gets invoked when the user adds or edits a item. the following items - will be parsed and rendered for the user as a gui with input, and selectboxes. --> - <fields> - <field> - <fielddescr>Username</fielddescr> - <fieldname>username</fieldname> - <description>Enter the username here</description> - <type>input</type> - </field> - <field> - <fielddescr>Password</fielddescr> - <fieldname>password</fieldname> - <description>Enter the password here</description> - <type>password</type> - </field> - <field> - <fielddescr>Username Description</fielddescr> - <fieldname>description</fieldname> - <description>Enter the description of the user here</description> - <type>input</type> - </field> - <field> - <fielddescr>Account Expiration</fielddescr> - <fieldname>expiration</fieldname> - <description>Amount of days when account expires. Leave blank for never.</description> - <type>input</type> - </field> - </fields> - <custom_delete_php_command> - rmdir_recursive("/home/" . $username); - system("/usr/sbin/pw userdel " . $username); - </custom_delete_php_command> - <custom_add_php_command> - conf_mount_rw(); - config_lock(); - $expires = ""; - if($_POST['expiration']) $expires = " -e " . $_POST['expiration']; - mwexec("/bin/mkdir /home/{$_POST['username']}"); - mwexec("/usr/sbin/chown -R {$_POST['username']}:wheel /home/{$_POST['username']}"); - mwexec("/usr/sbin/pw useradd " . $_POST['username'] . $expires . " -m -d /home/" . $_POST['username'] . "/./ -s \"/usr/sbin/nologini\""); - $fd = popen("/usr/sbin/pw usermod -n " . $_POST['username'] . " -H 0", "w"); - $salt = md5(time()); - $crypted_pw = crypt($_POST['password'],$salt); - fwrite($fd, $crypted_pw); - pclose($fd); - mwexec("/usr/sbin/pw usermod " . $_POST['username'] . " -s /nonexistent"); - conf_mount_ro(); - config_unlock(); - $savemsg = "User has been added."; - </custom_add_php_command> - <custom_php_install_command> - $fout = fopen("/usr/local/etc/rc.d/pure-ftpd.sh","w"); - fwrite($fout, "#!/bin/sh\n\n"); - fwrite($fout, "# PACKAGE: Pure-FTPD\n"); - fwrite($fout, "# EXECUTABLE: pure-ftpd\n"); - fwrite($fout, "/usr/local/sbin/pure-ftpd -A -B /usr/local/etc/pure-ftpd.conf\n"); - fclose($fout); - chmod("/usr/local/etc/rc.d/pure-ftpd.sh", 0755); - mwexec("/usr/local/etc/rc.d/pure-ftpd.sh"); - </custom_php_install_command> - <custom_php_deinstall_command> - mwexec("/usr/bin/killall pure-ftpd"); - rmdir_recursive("/usr/local/etc/pure*"); - rmdir_recursive("/usr/local/etc/rc.d/pure*"); - </custom_php_deinstall_command> -</packagegui> diff --git a/config/pure-ftpd/pure-ftpdsettings.xml b/config/pure-ftpd/pure-ftpdsettings.xml deleted file mode 100644 index f904545c..00000000 --- a/config/pure-ftpd/pure-ftpdsettings.xml +++ /dev/null @@ -1,162 +0,0 @@ -<?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[ -/* $Id$ */ -/* ========================================================================== */ -/* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> - <name>pure-ftpdsettings</name> - <version>none</version> - <title>Services: PureFTPD Settings</title> - <aftersaveredirect>pkg_edit.php?xml=pure-ftpdsettings.xml&id=0</aftersaveredirect> - <!-- Menu is where this packages menu will appear --> - <menu> - <name>Pure FTPD Settings</name> - <tooltiptext>Pure FTPd Server is a fast, production quality, standards-conformant FTP server based on Troll-FTPd. It has no known vulnerability, it is trivial to set up, and it is especially designed for modern kernels. Features include PAM support, IPv6, chroot()ed home directories, virtual domains, built-in 'ls', FXP protocol, anti-warez system, bandwidth throttling, restricted ports for passive downloads, an LDAP backend, XML output, and more.</tooltiptext> - <section>Services</section> - <configfile>pureftpdsettings.xml</configfile> - </menu> - <!-- configpath gets expanded out automatically and config items will be - stored in that location seperated with -> --> - <configpath>installedpackages->package->$packagename->configuration->settings</configpath> - <!-- fields gets invoked when the user adds or edits a item. the following items - will be parsed and rendered for the user as a gui with input, and selectboxes. --> - <fields> - <field> - <fielddescr>Maximum connections</fielddescr> - <fieldname>connections</fieldname> - <description>Maximum number of clients allowed</description> - <type>input</type> - <validationtype>number</validationtype> - </field> - <field> - <fielddescr>Maximum connections per ip address</fielddescr> - <fieldname>connectionsperip</fieldname> - <description>Maximum number of clients allowed to connect per ip address</description> - <type>input</type> - </field> - <field> - <fielddescr>Upload cutoff threshold</fielddescr> - <fieldname>cutoffthreshold</fieldname> - <description>Disallow upload if the partition is more than percentage full.</description> - <type>input</type> - <validationtype>number</validationtype> - </field> - <field> - <fielddescr>Begin tcp port range</fielddescr> - <fieldname>beginport</fieldname> - <description>Specify that client connections begin at this port.</description> - <type>input</type> - </field> - <field> - <fielddescr>End tcp port range</fielddescr> - <fieldname>endport</fieldname> - <description>Specify that client connections end at this port.</description> - <type>input</type> - <validationtype>number</validationtype> - </field> - <field> - <fielddescr>Limit upload bandwidth</fielddescr> - <fieldname>uploadbw</fieldname> - <description>Limit the upload bandwdith in KB/s</description> - <type>input</type> - <validationtype>number</validationtype> - </field> - <field> - <fielddescr>Limit download bandwidth</fielddescr> - <fieldname>downloadbw</fieldname> - <description>Limit the download bandwdith in KB/s</description> - <type>input</type> - <validationtype>number</validationtype> - </field> - <field> - <fielddescr>Client File Deletion</fielddescr> - <fieldname>filedeletion</fieldname> - <description>Allow clients to upload files but disallow their ability to delete uploaded items.</description> - <type>checkbox</type> - </field> - <field> - <fielddescr>NAT Workaround mode</fielddescr> - <fieldname>natworkaround</fieldname> - <description>NAT mode. Force active mode. If your FTP server is behind a NAT box that doesn't support applicative FTP proxying, or if you use port redirection without a transparent FTP proxy, use this. Well... the previous sentence isn't very clear. Okay: if your network looks like this: FTP--NAT.gateway/router--Internet and if you want people coming from the internet to have access to your FTP server, please try without this option first. If Netscape clients can connect without any problem, your NAT gate-way rulez. If Netscape doesn't display directory listings, your NAT gateway sucks.</description> - <type>checkbox</type> - </field> - <field> - <fielddescr>Chroot environment</fielddescr> - <fieldname>chroot</fieldname> - <description>Allow users (but root) to only see their ~ and no system files.</description> - <type>checkbox</type> - </field> - </fields> - <custom_delete_php_command> - </custom_delete_php_command> - <custom_add_php_command> - conf_mount_rw(); - config_lock(); - unlink_if_exists("/usr/local/etc/rc.d/pure-ftp*"); - $fout = fopen("/usr/local/etc/rc.d/pure-ftpd.sh","w"); - fwrite($fout, "#!/bin/sh\n\n"); - $startline = "/usr/local/sbin/pure-ftpd"; - if($_POST['connections']) $startline .= " -c " . $_POST['connections']; - if($_POST['connectionsperip']) $startline .= " -C " . $_POST['connectionsperip']; - if($_POST['cutoffthreshold']) $startline .= " -k " . $_POST['cutoffthreshold'];; - if($_POST['beginport'] and $_POST['endport']) $startline .= " -p " . $_POST['beginport'] . ":" . $_POST['endport']; - if($_POST['uploadbw'] and $_POST['downloadbw']) $startline .= " -T " . $_POST['uploadbw'] . ":" . $_POST['downloadbw'];; - if($_POST['natworkaround']) $startline .= " -N"; - if($_POST['filedeletion']) $startline .= " -K"; - if($_POST['chroot']) $startline .= " -A"; - $startline .= " -B /usr/local/etc/pure-ftpd.conf"; - fwrite($fout, $startline . "\n"); - fclose($fout); - conf_mount_ro(); - config_unlock(); - chmod("/usr/local/etc/rc.d/pure-ftpd.sh", 0755); - mwexec("killall pure-ftpd"); - mwexec("/usr/local/etc/rc.d/pure-ftpd.sh"); - </custom_add_php_command> - <custom_php_install_command> - </custom_php_install_command> - <custom_php_deinstall_command> - </custom_php_deinstall_command> -</packagegui> - diff --git a/config/quagga_ospfd/quagga_ospfd.xml b/config/quagga_ospfd/quagga_ospfd.xml index 617b5da0..01d67d8a 100644 --- a/config/quagga_ospfd/quagga_ospfd.xml +++ b/config/quagga_ospfd/quagga_ospfd.xml @@ -1,32 +1,70 @@ +<?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[ +/* $Id$ */ +/* ====================================================================================== */ +/* + quagga_ospfd.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012-2015 Jim Pingle + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <name>quagga_ospfd</name> - <version>0.6.5</version> + <version>0.6.6</version> <title>Services: Quagga OSPFd</title> <include_file>/usr/local/pkg/quagga_ospfd.inc</include_file> <aftersaveredirect>pkg_edit.php?xml=quagga_ospfd.xml&id=0</aftersaveredirect> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>644</chmod> <item>https://packages.pfsense.org/packages/config/quagga_ospfd/quagga_ospfd.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>644</chmod> <item>https://packages.pfsense.org/packages/config/quagga_ospfd/quagga_ospfd_interfaces.xml</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>644</chmod> <item>http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd_raw.xml</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>644</chmod> <item>https://packages.pfsense.org/packages/config/quagga_ospfd/status_ospfd.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/bin/</prefix> - <chmod>777</chmod> + <chmod>755</chmod> <item>https://packages.pfsense.org/packages/config/quagga_ospfd/quaggactl</item> </additional_files_needed> <menu> @@ -76,11 +114,7 @@ <field> <fielddescr>Master Password</fielddescr> <fieldname>password</fieldname> - <description> - <![CDATA[ - Password to access the Zebra and OSPF management daemons. Required. - ]]> - </description> + <description>Password to access the Zebra and OSPF management daemons. Required.</description> <type>input</type> <required/> </field> @@ -101,7 +135,8 @@ <fieldname>routerid</fieldname> <description> <![CDATA[ - Specify the Router ID. RID is the highest logical (loopback) IP address configured on a router. For more information on router identifiers see <a target='_new' href='http://en.wikipedia.org/wiki/Open_Shortest_Path_First'>wikipedia</a>. + Specify the Router ID. RID is the highest logical (loopback) IP address configured on a router.<br /> + For more information on router identifiers see <a href='http://en.wikipedia.org/wiki/Open_Shortest_Path_First'>wikipedia</a>. ]]> </description> <type>input</type> @@ -111,7 +146,8 @@ <fieldname>area</fieldname> <description> <![CDATA[ - OSPFd area for this instance of OSPF. For more information on Areas see <a target='_new' href='http://en.wikipedia.org/wiki/Open_Shortest_Path_First#Area_types'>wikipedia</a>. + OSPFd area for this instance of OSPF.<br /> + For more information on Areas see <a href='http://en.wikipedia.org/wiki/Open_Shortest_Path_First#Area_types'>wikipedia</a>. ]]> </description> <type>input</type> @@ -151,19 +187,29 @@ <field> <fielddescr>SPF Hold Time</fielddescr> <fieldname>spfholdtime</fieldname> - <description>Set the SPF holdtime in MILLIseconds. The minimum time between two consecutive shortest path first calculations. The default value is 5 seconds; the valid range is 1-5 seconds.</description> + <description> + <![CDATA[ + Set the SPF holdtime in <strong>milli</strong>seconds. The minimum time between two consecutive shortest path first calculations.<br /> + The default value is 5 seconds; the valid range is 1-5 seconds. + ]]> + </description> <type>input</type> </field> <field> <fielddescr>SPF Delay</fielddescr> <fieldname>spfdelay</fieldname> - <description>Set SPF delay in MILLIseconds. The delay between receiving an update to the link state database and starting the shortest path first calculation. The default value is 1; valid range is 1-10 seconds.</description> + <description> + <![CDATA[ + Set SPF delay in <strong>milli</strong>seconds. The delay between receiving an update to the link state database and starting the shortest path first calculation.<br /> + The default value is 1; valid range is 1-10 seconds. + ]]> + </description> <type>input</type> </field> <field> <fielddescr>RFC 1583 compatible</fielddescr> <fieldname>rfc1583</fieldname> - <description>If set to yes, decisions regarding AS-external routes are evaluated according to RFC 1583. The default is no.</description> + <description>If set to yes, decisions regarding AS-external routes are evaluated according to RFC 1583. The default is no.</description> <type>checkbox</type> </field> <field> @@ -202,7 +248,12 @@ <field> <fielddescr>CARP Status IP</fielddescr> <fieldname>carpstatusip</fieldname> - <description>IP address used to determine the CARP status. When the VIP is in BACKUP status, quagga will not be started. <br/>NOTE: Requires changes to /etc/rc.carpmaster to start quagga and /etc/rc.carpbackup to stop quagga or it will not be fully effective.</description> + <description> + <![CDATA[ + IP address used to determine the CARP status. When the VIP is in BACKUP status, quagga will not be started.<br /> + NOTE: Requires changes to /etc/rc.carpmaster to start quagga and /etc/rc.carpbackup to stop quagga or it will not be fully effective. + ]]> + </description> <type>input</type> <size>25</size> </field> diff --git a/config/quagga_ospfd/quagga_ospfd_interfaces.xml b/config/quagga_ospfd/quagga_ospfd_interfaces.xml index f9953112..ef594bfd 100644 --- a/config/quagga_ospfd/quagga_ospfd_interfaces.xml +++ b/config/quagga_ospfd/quagga_ospfd_interfaces.xml @@ -1,12 +1,53 @@ +<?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[ +/* $Id$ */ +/* ====================================================================================== */ +/* + quagga_ospfd_interfaces.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012-2015 Jim Pingle + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <name>quagga_ospfd_interfaces</name> - <version>0.1</version> + <version>0.6.6</version> <title>Services: Quagga OSPFd</title> <include_file>/usr/local/pkg/quagga_ospfd.inc</include_file> <aftersaveredirect>pkg.php?xml=quagga_ospfd_interfaces.xml</aftersaveredirect> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/quagga_ospfd/quagga_ospfd.inc</item> </additional_files_needed> <menu> @@ -17,23 +58,23 @@ <url>/pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> </menu> <tabs> - <tab> - <text>Global Settings</text> - <url>pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> - </tab> - <tab> - <text>Interface Settings</text> - <url>pkg.php?xml=quagga_ospfd_interfaces.xml</url> - <active/> - </tab> - <tab> - <text>Raw Config</text> - <url>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</url> - </tab> - <tab> - <text>Status</text> - <url>/status_ospfd.php</url> - </tab> + <tab> + <text>Global Settings</text> + <url>pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> + </tab> + <tab> + <text>Interface Settings</text> + <url>pkg.php?xml=quagga_ospfd_interfaces.xml</url> + <active/> + </tab> + <tab> + <text>Raw Config</text> + <url>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</url> + </tab> + <tab> + <text>Status</text> + <url>/status_ospfd.php</url> + </tab> </tabs> <adddeleteeditpagefields> <columnitem> @@ -87,7 +128,7 @@ <field> <fielddescr>Interface is Passive</fielddescr> <fieldname>passive</fieldname> - <description>Prevent transmission and reception of OSPF packets on this interface. The specified interface will be announced as a stub network.</description> + <description>Prevent transmission and reception of OSPF packets on this interface. The specified interface will be announced as a stub network.</description> <type>checkbox</type> </field> <field> @@ -112,7 +153,10 @@ <fielddescr>Router Priority</fielddescr> <fieldname>routerpriorityelections</fieldname> <description> - Router priority when participating in elections for DR (Default 1) Valid range is 0-255. 0 will cause the router to not participate in election. + <![CDATA[ + Router priority when participating in elections for DR (Default 1)<br /> + Valid range is 0-255. 0 will cause the router to not participate in election. + ]]> </description> <type>input</type> </field> diff --git a/config/quagga_ospfd/quagga_ospfd_raw.xml b/config/quagga_ospfd/quagga_ospfd_raw.xml index b34558de..3b56cc52 100644 --- a/config/quagga_ospfd/quagga_ospfd_raw.xml +++ b/config/quagga_ospfd/quagga_ospfd_raw.xml @@ -1,12 +1,53 @@ +<?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[ +/* $Id$ */ +/* ====================================================================================== */ +/* + quagga_ospfd_raw.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012-2015 Jim Pingle + 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. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <name>quagga_ospfd_raw</name> - <version>0.1</version> + <version>0.6.6</version> <title>Services: Quagga OSPFd</title> <include_file>/usr/local/pkg/quagga_ospfd.inc</include_file> <aftersaveredirect>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</aftersaveredirect> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>http://www.pfsense.com/packages/config/quagga_ospfd/quagga_ospfd.inc</item> </additional_files_needed> <menu> @@ -17,23 +58,23 @@ <url>/pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> </menu> <tabs> - <tab> - <text>Global Settings</text> - <url>pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> - </tab> - <tab> - <text>Interface Settings</text> - <url>pkg.php?xml=quagga_ospfd_interfaces.xml</url> - </tab> - <tab> - <text>Raw Config</text> - <url>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</url> - <active/> - </tab> - <tab> - <text>Status</text> - <url>/status_ospfd.php</url> - </tab> + <tab> + <text>Global Settings</text> + <url>pkg_edit.php?xml=quagga_ospfd.xml&id=0</url> + </tab> + <tab> + <text>Interface Settings</text> + <url>pkg.php?xml=quagga_ospfd_interfaces.xml</url> + </tab> + <tab> + <text>Raw Config</text> + <url>pkg_edit.php?xml=quagga_ospfd_raw.xml&id=0</url> + <active/> + </tab> + <tab> + <text>Status</text> + <url>/status_ospfd.php</url> + </tab> </tabs> <service> <name>Quagga OSPFd</name> @@ -49,7 +90,12 @@ <field> <fielddescr>ospfd.conf</fielddescr> <fieldname>ospfd</fieldname> - <description>Note: Once you click "Save" below, the assistant (in the "Global Settings" and "Interface Settings" tabs above) will be overridden with whatever you type here. To get back the assisted config save this form below once with both empty input fields.</description> + <description> + <![CDATA[ + Note: Once you click "Save" below, the assistant (in the "Global Settings" and "Interface Settings" tabs above) will be overridden with whatever you type here.<br /> + To get back the assisted config save this form below once with both empty input fields. + ]]> + </description> <type>textarea</type> <encoding>base64</encoding> <rows>30</rows> @@ -58,7 +104,12 @@ <field> <fielddescr>zebra.conf</fielddescr> <fieldname>zebra</fieldname> - <description>Note: Once you click "Save" below, the assistant (in the "Global Settings" and "Interface Settings" tabs above) will be overridden with whatever you type here. To get back the assisted config save this form below once with both empty input fields.</description> + <description> + <![CDATA[ + Note: Once you click "Save" below, the assistant (in the "Global Settings" and "Interface Settings" tabs above) will be overridden with whatever you type here.<br /> + To get back the assisted config save this form below once with both empty input fields. + ]]> + </description> <type>textarea</type> <encoding>base64</encoding> <rows>30</rows> diff --git a/config/routed/routed.inc b/config/routed/routed.inc index f7ace8a5..471c2772 100644 --- a/config/routed/routed.inc +++ b/config/routed/routed.inc @@ -1,8 +1,9 @@ <?php -/* $Id$ */ /* routed.inc + part of pfSense (https://www.pfSense.org/) Copyright (C) 2006 Bill Marquette + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -25,39 +26,42 @@ 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 setup_routed() { global $config; $gw = ""; - if (!is_array($config['installedpackages']['routed'])) + if (!is_array($config['installedpackages']['routed'])) { return; - if (!is_array($config['installedpackages']['routed']['config'])) + } + if (!is_array($config['installedpackages']['routed']['config'])) { return; + } if (isset($config['installedpackages']['routed']['config'][0]['enable']) && - $config['installedpackages']['routed']['config'][0]['enable'] == "on") { + $config['installedpackages']['routed']['config'][0]['enable'] == "on") { /* if user selected individual interfaces */ $ifarr = array_flip(explode(",", $config['installedpackages']['routed']['config'][0]['iface_array'])); $allifs = get_interface_arr(); if (!empty($ifarr)) { - foreach($allifs as $ifname) { + foreach ($allifs as $ifname) { $friendly_ifname = convert_real_interface_to_friendly_interface_name($ifname); - if (array_key_exists($friendly_ifname, $ifarr)) + if (array_key_exists($friendly_ifname, $ifarr)) { $gw .= setup_etc_gateways($ifname, 'enable'); - else + } else { $gw .= setup_etc_gateways($ifname, 'disable'); + } } - } else + } else { /* setup for all interfaces */ $gw = setup_etc_gateways(); + } conf_mount_rw(); file_put_contents("/etc/gateways", $gw); - conf_mount_ro(); - restart_routed(); - } else - stop_routed(); + conf_mount_ro(); + restart_service("routed"); + } else { + stop_service("routed"); + } } function setup_etc_gateways($iface="", $mode="") { @@ -66,52 +70,56 @@ function setup_etc_gateways($iface="", $mode="") { $ret = ""; if ($iface != "") { $realif=convert_friendly_interface_to_real_interface_name($iface); - if (!empty($realif)) + if (!empty($realif)) { $ret = "if={$realif} "; + } } switch($mode) { - case "enable": - if ($config['installedpackages']['routed']['config'][0]['ripversion'] == "2") { - $ret .= "ripv2 "; - $passwd = $config['installedpackages']['routed']['config'][0]['passwd']; - if ($passwd != "") { - $ret .= "passwd={$passwd} "; - } - $add_no_ag = $config['installedpackages']['routed']['config'][0]['enable_no_ag']; - $add_no_super_ag = $config['installedpackages']['routed']['config'][0]['enable_no_super_ag']; - if($add_no_ag == "on") { - $ret .= "no_ag "; - } - if($add_no_super_ag == "on") { - $ret .= "no_super_ag "; + case "enable": + if ($config['installedpackages']['routed']['config'][0]['ripversion'] == "2") { + $ret .= "ripv2 "; + $passwd = $config['installedpackages']['routed']['config'][0]['passwd']; + if ($passwd != "") { + $ret .= "passwd={$passwd} "; + } + $add_no_ag = $config['installedpackages']['routed']['config'][0]['enable_no_ag']; + $add_no_super_ag = $config['installedpackages']['routed']['config'][0]['enable_no_super_ag']; + if ($add_no_ag == "on") { + $ret .= "no_ag "; + } + if ($add_no_super_ag == "on") { + $ret .= "no_super_ag "; + } } - } - break; - case "disable": - $ret .= "no_rip_out no_solicit no_rdisc no_rdisc_adv"; - break; - - default: - break; - + break; + case "disable": + $ret .= "no_rip_out no_solicit no_rdisc no_rdisc_adv"; + break; + default: + break; } $ret .= "\n"; return $ret; } -function start_routed() { - mwexec_bg("/sbin/routed"); -} - -function stop_routed() { - killbyname("routed"); +function routed_install_command() { + conf_mount_rw(); + write_rcfile(array( + "file" => "routed.sh", + "start" => "/usr/bin/nohup /sbin/routed > /dev/null 2>&1 &", + "stop" => "/bin/pkill routed" + ) + ); + conf_mount_ro(); } -function restart_routed() { - stop_routed(); - start_routed(); +function routed_deinstall_command() { + stop_service("routed"); + conf_mount_rw(); + unlink_if_exists("/usr/local/etc/rc.d/routed.sh"); + conf_mount_ro(); } ?> diff --git a/config/routed/routed.xml b/config/routed/routed.xml index 8764b172..b38d7ee3 100644 --- a/config/routed/routed.xml +++ b/config/routed/routed.xml @@ -1,51 +1,65 @@ <?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - /* $Id$ */ - /* - part of pfSense (https://www.pfsense.org/) +<![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ +/* + routed.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2006 Bill Marquette <bill.marquette@gmail.com> + 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: - Copyright (C) 2006 Bill Marquette - bill.marquette@gmail.com. - 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. - 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. - 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. - */ + 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> <name>routed</name> - <version>1.1</version> + <version>1.2</version> <title>Services: RIP</title> <include_file>/usr/local/pkg/routed.inc</include_file> - <additional_files_needed> <item>https://packages.pfsense.org/packages/config/routed/routed.inc</item> </additional_files_needed> - - <!-- Menu is where this packages menu will appear --> <menu> <name>RIP</name> <section>Services</section> <configfile>routed.xml</configfile> <url>pkg_edit.php?xml=routed.xml&id=0</url> </menu> + <service> + <name>routed</name> + <rcfile>routed.sh</rcfile> + <executable>routed</executable> + <description>Routing Information Protocol Daemon</description> + </service> <tabs> <tab> <text>ROUTED Settings</text> @@ -53,16 +67,12 @@ <active/> </tab> </tabs> - <!-- configpath gets expanded out automatically and config items will be - stored in that location --> <configpath>['installedpackages']['routed']['config']</configpath> - <!-- fields gets invoked when the user adds or edits a item. the following items - will be parsed and rendered for the user as a gui with input, and selectboxes. --> <fields> <field> <fielddescr>Enable RIP</fielddescr> <fieldname>enable</fieldname> - <description>Enables the Routing Information Protocol daemon</description> + <description>Enables the Routing Information Protocol daemon.</description> <type>checkbox</type> <enablefields>iface_array[],ripversion,passwd,enable_no_ag,enable_no_super_ag</enablefields> </field> @@ -73,7 +83,7 @@ <multiple>true</multiple> <size>3</size> <type>interfaces_selection</type> - <description>Select the interfaces that RIP will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description> + <description>Select the interfaces that RIP will bind to. You can use the CTRL or COMMAND key to select multiple interfaces.</description> <required /> </field> <field> @@ -91,36 +101,30 @@ <field> <fielddescr>RIPv2 password</fielddescr> <fieldname>passwd</fieldname> - <description>Specify a RIPv2 password. This password will be sent - in the clear on all RIPv2 responses received and sent. - </description> + <description>Specify a RIPv2 password. This password will be sent in the clear on all RIPv2 responses received and sent.</description> <type>input</type> </field> <field> <fielddescr>no_ag</fielddescr> <fieldname>enable_no_ag</fieldname> - <description>turns off aggregation of subnets in RIPv1 and RIPv2 responses.</description> + <description>Turns off aggregation of subnets in RIPv1 and RIPv2 responses.</description> <type>checkbox</type> </field> <field> <fielddescr>no_super_ag</fielddescr> <fieldname>enable_no_super_ag</fieldname> - <description>turns off aggregation of networks into supernets in RIPv2 responses.</description> + <description>Turns off aggregation of networks into supernets in RIPv2 responses.</description> <type>checkbox</type> </field> </fields> <aftersaveredirect>pkg_edit.php?xml=routed.xml&id=0</aftersaveredirect> - <custom_php_command_before_form> - </custom_php_command_before_form> - <custom_delete_php_command> - </custom_delete_php_command> <custom_php_resync_config_command> - conf_mount_rw(); setup_routed(); - conf_mount_ro(); </custom_php_resync_config_command> <custom_php_install_command> + routed_install_command(); </custom_php_install_command> <custom_php_deinstall_command> + routed_deinstall_command(); </custom_php_deinstall_command> </packagegui> diff --git a/config/shellcmd/shellcmd.inc b/config/shellcmd/shellcmd.inc index c5020d5f..04cbf3d6 100644 --- a/config/shellcmd/shellcmd.inc +++ b/config/shellcmd/shellcmd.inc @@ -69,26 +69,9 @@ function shellcmd_install_command() global $config; conf_mount_rw(); - config_lock(); - - //write_config(); - - //write_rcfile(array( - // "file" => "shellcmd.sh", - // "start" => "/usr/sbin/shellcmd -s &", - // "stop" => "kill -9 `cat /var/run/shellcmd.pid`" - // ) - //); - shellcmd_sync_package(); - - //if (pkg_is_service_running('shellcmd')) { - //documentation purposes - //} - conf_mount_ro(); - config_unlock(); - + } @@ -96,12 +79,10 @@ function shellcmd_deinstall_command() { conf_mount_rw(); - config_lock(); $handle = popen("/usr/local/etc/rc.d/shellcmd.sh stop", "r"); //unlink_if_exists("/usr/local/etc/rc.d/shellcmd.sh"); conf_mount_ro(); - config_unlock(); - + } ?> diff --git a/config/siproxd/siproxd.xml b/config/siproxd/siproxd.xml index 455fca9c..cca84138 100644 --- a/config/siproxd/siproxd.xml +++ b/config/siproxd/siproxd.xml @@ -4,15 +4,22 @@ <packagegui> <copyright> <![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ /* siproxd.xml + part of pfSense (https://www.pfSense.org/) Copyright (C) 2006 Scott Ullrich Copyright (C) 2010 Jim Pingle + 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. @@ -20,6 +27,7 @@ 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 @@ -31,13 +39,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* ====================================================================================== */ ]]> </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>siproxdsettings</name> - <version>1.0.3</version> + <version>1.0.5</version> <title>siproxd: Settings</title> <include_file>/usr/local/pkg/siproxd.inc</include_file> <aftersaveredirect>/pkg_edit.php?xml=siproxd.xml&id=0</aftersaveredirect> @@ -69,17 +75,14 @@ </tabs> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/siproxd/siproxdusers.xml</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/siproxd/siproxd.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/siproxd/siproxd_registered_phones.php</item> </additional_files_needed> <fields> @@ -104,7 +107,12 @@ <field> <fielddescr>Listening port</fielddescr> <fieldname>port</fieldname> - <description>Enter the port on which to listen for SIP traffic (default 5060). Do not change this unless you know what you're doing.</description> + <description> + <![CDATA[ + Enter the port on which to listen for SIP traffic (default 5060).<br /> + <strong> WARNING: Do not change this unless you know what you're doing.</strong> + ]]> + </description> <type>input</type> </field> <field> @@ -174,13 +182,23 @@ <field> <fielddescr>TCP inactivity timeout</fielddescr> <fieldname>tcp_timeout</fieldname> - <description>Inactivity timeout (seconds). After that an idling TCP connection is disconnected. NOTE: Making this too short may cause multiple parallel registrations for the same phone. This timeout must be set larger than the used registration interval.</description> + <description> + <![CDATA[ + Inactivity timeout (seconds). After that an idling TCP connection is disconnected.<br /> + NOTE: Making this too short may cause multiple parallel registrations for the same phone. This timeout must be set larger than the used registration interval. + ]]> + </description> <type>input</type> </field> <field> <fielddescr>TCP Connect Timeout</fielddescr> <fieldname>tcp_connect_timeout</fieldname> - <description>Defines How many msecs siproxd will wait for an successful connect when establishing an outgoing SIP signalling connection. This should be kept as short as possible as waiting for an TCP connection to establish is a BLOCKING operation - while waiting for a connect to succeed no SIP messages are processed (RTP is not affected).</description> + <description> + <![CDATA[ + Defines How many msecs siproxd will wait for an successful connect when establishing an outgoing SIP signalling connection.<br /> + This should be kept as short as possible as waiting for an TCP connection to establish is a BLOCKING operation - while waiting for a connect to succeed no SIP messages are processed (RTP is not affected). + ]]> + </description> <type>input</type> </field> <field> @@ -218,14 +236,23 @@ <field> <fielddescr>Expedited RTP Forwarding</fielddescr> <fieldname>expeditedforwarding</fieldname> - <description>This service is designed to allow ISPs to offer a service with attributes similar to a "leased line". This service offers the ULTIMATE IN LOW LOSS, LOW LATENCY AND LOW JITTER by ensuring that there is always sufficient room in output queues for the contracted expedited forwarding traffic. + <description> + <![CDATA[ + This service is designed to allow ISPs to offer a service with attributes similar to a "leased line".<br /> + This service offers the ULTIMATE IN LOW LOSS, LOW LATENCY AND LOW JITTER by ensuring that there is always sufficient room in output queues for the contracted expedited forwarding traffic. + ]]> </description> <type>checkbox</type> </field> <field> <fielddescr>Expedited SIP Forwarding</fielddescr> <fieldname>expeditedsipforwarding</fieldname> - <description>This service is designed to allow ISPs to offer a service with attributes similar to a "leased line". This service offers the ULTIMATE IN LOW LOSS, LOW LATENCY AND LOW JITTER by ensuring that there is always sufficient room in output queues for the contracted expedited forwarding traffic.</description> + <description> + <![CDATA[ + This service is designed to allow ISPs to offer a service with attributes similar to a "leased line".<br /> + This service offers the ULTIMATE IN LOW LOSS, LOW LATENCY AND LOW JITTER by ensuring that there is always sufficient room in output queues for the contracted expedited forwarding traffic. + ]]> + </description> <type>checkbox</type> </field> <field> @@ -257,13 +284,23 @@ <field> <fielddescr>Enable Fix Bogus Via Networks Plugin</fielddescr> <fieldname>plugin_fix_bogus_via</fieldname> - <description>Incoming (from public network) SIP messages are checked for broken SIP Via headers. If the IP address in the latest Via Header is part of the list below, it will be replaced by the IP where the SIP message has been received from.</description> + <description> + <![CDATA[ + Incoming (from public network) SIP messages are checked for broken SIP Via headers.<br /> + If the IP address in the latest Via Header is part of the list below, it will be replaced by the IP where the SIP message has been received from. + ]]> + </description> <type>checkbox</type> </field> <field> <fielddescr>Bogus Via Networks</fielddescr> <fieldname>plugin_fix_bogus_via_networks</fieldname> - <description>Comma separated list of networks which should have their via headers rewritten. Example: 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16</description> + <description> + <![CDATA[ + Comma separated list of networks which should have their via headers rewritten.<br /> + Example: 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 + ]]> + </description> <type>input</type> </field> <field> @@ -325,7 +362,12 @@ <field> <fielddescr>TCP Debug Port</fielddescr> <fieldname>debug_port</fieldname> - <description>You may connect to this port from a remote machine and receive debug output. This allows better creation of debug output on embedded systems that do not have enough memory for large disk files. Port number 0 means this feature is disabled.</description> + <description> + <![CDATA[ + You may connect to this port from a remote machine and receive debug output. This allows better creation of debug output on embedded systems that do not have enough memory for large disk files.<br /> + NOTE: Port number 0 means this feature is disabled. + ]]> + </description> <type>input</type> </field> </fields> diff --git a/config/siproxd/siproxdusers.xml b/config/siproxd/siproxdusers.xml index 4ed4abc7..7a636a3b 100644 --- a/config/siproxd/siproxdusers.xml +++ b/config/siproxd/siproxdusers.xml @@ -2,51 +2,48 @@ <!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> + <![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + siproxdusers.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2006 Scott Ullrich + Copyright (C) 2010 Jim Pingle + 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: + 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. - 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. - 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>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> <name>siproxdusers</name> - <version>0.5.9</version> + <version>1.0.5</version> <title>siproxd: Users</title> <include_file>/usr/local/pkg/siproxd.inc</include_file> <tabs> @@ -101,4 +98,4 @@ <custom_php_resync_config_command> sync_package_sipproxd_users(); </custom_php_resync_config_command> -</packagegui>
\ No newline at end of file +</packagegui> diff --git a/config/snort/snort.xml b/config/snort/snort.xml index 6c70b39e..e3e1cdad 100755 --- a/config/snort/snort.xml +++ b/config/snort/snort.xml @@ -3,51 +3,50 @@ <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - <![CDATA[ + <![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - authng.xml - part of pfSense (https://www.pfsense.org) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + snort.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009-2010 Robert Zelaya + Copyright (C) 2011-2012 Ermal Luçi + Copyright (C) 2013-2015 Bill Meeks + Copyright (C) 2015 Electric Sheep Fencing LP + All rights reserved. +*/ +/* ====================================================================================== */ /* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + 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. - 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. - 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. - */ -/* ========================================================================== */ - ]]> + 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>Snort IDS/IPS Package</description> - <requirements>None</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>Snort</name> - <version>2.9.7.3</version> - <title>Services:2.9.7.3 pkg v3.2.6</title> + <version>3.2.6</version> + <title>Services: Snort IDS</title> <include_file>/usr/local/pkg/snort/snort.inc</include_file> <menu> <name>Snort</name> @@ -65,258 +64,206 @@ </tabs> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_check_cron_misc.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_conf_template.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_migrate_config.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_post_install.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_sync.xml</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/deprecated_rules</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_alerts.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_barnyard.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_blocked.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_define_servers.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_download_rules.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_download_updates.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_check_for_rule_updates.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_defs.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_interfaces.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_interfaces_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_interfaces_global.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_rules.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_rules_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_rulesets.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_preprocessors.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_passlist.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_passlist_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_interfaces_suppress.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_interfaces_suppress_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_list_view.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_rules_flowbits.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_edit_hat_data.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_frag3_engine.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_stream5_engine.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_httpinspect_engine.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_ftp_client_engine.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_ftp_server_engine.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_import_aliases.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_select_alias.php</item> </additional_files_needed> <additional_files_needed> <prefix>/etc/inc/priv/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort.priv.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_ip_reputation.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_ip_list_mgmt.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_iprep_list_browser.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_interface_logs.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_log_mgmt.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_sid_mgmt.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/snort/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_generate_conf.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/javascript/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_alerts.js</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/widgets/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/snort/snort_alerts.widget.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/include/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/snort/widget-snort.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/var/db/snort/sidmods/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/snort/disablesid-sample.conf</item> </additional_files_needed> <additional_files_needed> <prefix>/var/db/snort/sidmods/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/snort/enablesid-sample.conf</item> </additional_files_needed> <additional_files_needed> <prefix>/var/db/snort/sidmods/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/snort/modifysid-sample.conf</item> </additional_files_needed> <fields> </fields> - <custom_add_php_command> - </custom_add_php_command> <custom_php_resync_config_command> <![CDATA[ sync_snort_package_config(); diff --git a/config/snort/snort_sync.xml b/config/snort/snort_sync.xml index f3db2ce9..46922822 100755 --- a/config/snort/snort_sync.xml +++ b/config/snort/snort_sync.xml @@ -1,52 +1,50 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> -<![CDATA[ + <copyright> + <![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* -snortsync.xml -part of pfSense (http://www.pfSense.com) -Copyright (C) 2013 Marcello Coutinho -based on pfblocker_sync.xml -All rights reserved. - -Based on m0n0wall (http://m0n0.ch/wall) -Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. -All rights reserved. + snort.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2013 Marcello Coutinho + Copyright (C) 2014-2015 Bill Meeks + Copyright (C) 2015 Electric Sheep Fencing LP + All rights reserved. */ -/* ========================================================================== */ +/* ====================================================================================== */ /* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: + 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. -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. -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. + 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><![CDATA[Describe your package here]]></description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> +/* ====================================================================================== */ + ]]> + </copyright> + <description>Snort: XMLRPC Sync</description> <name>snortsync</name> - <version>1.0</version> + <version>3.2.6</version> <title>Snort: XMLRPC Sync</title> <include_file>/usr/local/pkg/snort/snort.inc</include_file> <tabs> diff --git a/config/softflowd/softflowd.xml b/config/softflowd/softflowd.xml index 6e9c080f..adf5359c 100644 --- a/config/softflowd/softflowd.xml +++ b/config/softflowd/softflowd.xml @@ -183,7 +183,6 @@ <![CDATA[ function sync_package_softflowd() { conf_mount_rw(); - config_lock(); global $config; $cf = $config['installedpackages']['softflowd']['config'][0]; $interface_list = explode(",", $cf['interface']); @@ -249,7 +248,6 @@ } } conf_mount_ro(); - config_unlock(); } function validate_form_softflowd($post, &$input_errors) { diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index 71f20106..bbfae23e 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -43,7 +43,6 @@ function sync_package_spamd() { } conf_mount_rw(); - config_lock(); $fd = fopen("/etc/spamd.conf","w"); /* all header */ fwrite($fd, "all:\\\n\t:whitelist:blacklist"); @@ -155,8 +154,6 @@ function sync_package_spamd() { spamd_install_cron(true); log_error("Mounting RO"); conf_mount_ro(); - log_error("Unlocking config"); - config_unlock(); log_error("Restart cron"); mwexec("killall -HUP cron"); log_error("Setting up spamd.conf symlink"); @@ -176,7 +173,6 @@ function sync_package_spamd() { function sync_package_spamd_whitelist() { global $config; conf_mount_rw(); - config_lock(); /* write out ip to the whitelist db */ $fd = fopen("/var/db/whitelist.txt","w"); if($config['installedpackages']['spamdwhitelist']['config'] != "") { @@ -189,7 +185,6 @@ function sync_package_spamd_whitelist() { mwexec("/usr/bin/killall -HUP spamlogd"); mwexec("/sbin/pfctl -t spamd-white -T add {$spamd['ip']}"); conf_mount_ro(); - config_unlock(); } function spamd_generate_rules($type) { diff --git a/config/spamd/spamd_db.php b/config/spamd/spamd_db.php index e1d004f7..83601805 100644 --- a/config/spamd/spamd_db.php +++ b/config/spamd/spamd_db.php @@ -145,7 +145,6 @@ if($_GET['whitelist'] <> "") { } function delete_from_blacklist($srcip) { - config_lock(); $blacklist = explode("\n", file_get_contents("/var/db/blacklist.txt")); $fd = fopen("/var/db/blacklist.txt", "w"); foreach($blacklist as $bl) { @@ -156,11 +155,9 @@ function delete_from_blacklist($srcip) { fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete {$srcip}"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - config_unlock(); } function delete_from_whitelist($srcip) { - config_lock(); $whitelist = explode("\n", file_get_contents("/var/db/whitelist.txt")); $fd = fopen("/var/db/whitelist.txt", "w"); foreach($whitelist as $wl) { @@ -171,7 +168,6 @@ function delete_from_whitelist($srcip) { fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt"); - config_unlock(); } $pgtitle = "SpamD: Database"; diff --git a/config/spamd/spamd_db_ext.php b/config/spamd/spamd_db_ext.php index 61a90141..010027e3 100644 --- a/config/spamd/spamd_db_ext.php +++ b/config/spamd/spamd_db_ext.php @@ -165,7 +165,6 @@ if($_GET['whitelist'] <> "") { } function delete_from_spamd_db($srcip) { - config_lock(); $fd = fopen("/tmp/execcmds", "w"); fwrite($fd, "#!/bin/sh\n"); fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip}\n"); @@ -178,7 +177,6 @@ function delete_from_spamd_db($srcip) { system("/bin/sh /tmp/execcmds"); mwexec("/usr/bin/killall -HUP spamlogd"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - config_unlock(); } function basic_auth_prompt(){ @@ -189,17 +187,14 @@ function basic_auth_prompt(){ } function add_to_blacklist($srcip) { - config_lock(); $fd = fopen("/var/db/blacklist.txt", "a"); fwrite($fd, "{$srcip}\n"); fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T add -f /var/db/blacklist.txt"); mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); - config_unlock(); } function delete_from_blacklist($srcip) { - config_lock(); $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); $fd = fopen("/var/db/blacklist.txt", "w"); foreach($blacklist as $bl) { @@ -210,11 +205,9 @@ function delete_from_blacklist($srcip) { fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - config_unlock(); } function delete_from_whitelist($srcip) { - config_lock(); $whitelist = split("\n", file_get_contents("/var/db/whitelist.txt")); $fd = fopen("/var/db/whitelist.txt", "w"); foreach($whitelist as $wl) { @@ -225,7 +218,6 @@ function delete_from_whitelist($srcip) { fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt"); - config_unlock(); } function hup_spamd() { @@ -234,4 +226,4 @@ function hup_spamd() { exit; -?>
\ No newline at end of file +?> diff --git a/config/spamd/spamd_verify_to_address.php b/config/spamd/spamd_verify_to_address.php index 56821370..504107d3 100644 --- a/config/spamd/spamd_verify_to_address.php +++ b/config/spamd/spamd_verify_to_address.php @@ -114,9 +114,7 @@ foreach($grey_hosts as $grey) { if($debug) echo "/usr/local/sbin/spamdb -a \"<$email_to>\" -T\n"; exec("/usr/local/sbin/spamdb -a \"<$email_to>\" -T"); - config_lock(); system("echo $server_ip >> /var/db/blacklist.txt"); - config_unlock(); $result = mwexec("/usr/local/sbin/spamdb -a $server_ip -t"); } else { if($debug) @@ -141,4 +139,4 @@ if($debug) { mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); -?>
\ No newline at end of file +?> diff --git a/config/squid/squid_auth.inc b/config/squid/squid_auth.inc index 7c99a01b..54e69b49 100644 --- a/config/squid/squid_auth.inc +++ b/config/squid/squid_auth.inc @@ -35,8 +35,7 @@ function global_eval_auth_options() { global $config; conf_mount_rw(); - config_lock(); - + switch ($config['installedpackages']['squidauth']['config'][0]['auth_method']) { case "none": dynamic_auth_content("pkg_edit"); @@ -69,7 +68,6 @@ function global_eval_auth_options() break; } - config_unlock(); conf_mount_ro(); } /* end function global_eval_auth_options */ @@ -443,4 +441,4 @@ function dynamic_auth_content($pkgvar) { } } /* end function dynamic_auth_content */ -?>
\ No newline at end of file +?> diff --git a/config/squid/squid_ng.inc b/config/squid/squid_ng.inc index f96c73e4..01f56ea3 100644 --- a/config/squid/squid_ng.inc +++ b/config/squid/squid_ng.inc @@ -38,7 +38,6 @@ function global_write_squid_config() { global $config; conf_mount_rw(); - config_lock(); /* define squid configuration file in variable for replace function */ $squidconfig = "/usr/local/etc/squid/squid.conf"; @@ -791,7 +790,6 @@ function global_write_squid_config() fclose($fout); conf_mount_ro(); - config_unlock(); touch($squidconfig); } /* end function write_squid_config */ @@ -1032,7 +1030,6 @@ function write_static_squid_config() { function mod_htpasswd() { global $config; conf_mount_rw(); - config_lock(); if (!file_exists("/usr/local/etc/squid/advanced/ncsa")) mwexec("mkdir -p /usr/local/etc/squid/advanced/ncsa"); @@ -1048,7 +1045,6 @@ function mod_htpasswd() { fclose($passfile); conf_mount_ro(); - config_unlock(); } function generate_htpasswd($username, $password) { diff --git a/config/squid3/31/squid_auth.inc b/config/squid3/31/squid_auth.inc index 7c99a01b..54e69b49 100644 --- a/config/squid3/31/squid_auth.inc +++ b/config/squid3/31/squid_auth.inc @@ -35,8 +35,7 @@ function global_eval_auth_options() { global $config; conf_mount_rw(); - config_lock(); - + switch ($config['installedpackages']['squidauth']['config'][0]['auth_method']) { case "none": dynamic_auth_content("pkg_edit"); @@ -69,7 +68,6 @@ function global_eval_auth_options() break; } - config_unlock(); conf_mount_ro(); } /* end function global_eval_auth_options */ @@ -443,4 +441,4 @@ function dynamic_auth_content($pkgvar) { } } /* end function dynamic_auth_content */ -?>
\ No newline at end of file +?> diff --git a/config/squid3/31/squid_ng.inc b/config/squid3/31/squid_ng.inc index 3b9ef405..d1c37dbf 100644 --- a/config/squid3/31/squid_ng.inc +++ b/config/squid3/31/squid_ng.inc @@ -38,7 +38,6 @@ function global_write_squid_config() { global $config; conf_mount_rw(); - config_lock(); /* define squid configuration file in variable for replace function */ $squidconfig = "/usr/local/etc/squid/squid.conf"; @@ -791,7 +790,6 @@ function global_write_squid_config() fclose($fout); conf_mount_ro(); - config_unlock(); touch($squidconfig); } /* end function write_squid_config */ @@ -1032,7 +1030,6 @@ function write_static_squid_config() { function mod_htpasswd() { global $config; conf_mount_rw(); - config_lock(); if (!file_exists("/usr/local/etc/squid/advanced/ncsa")) mwexec("mkdir -p /usr/local/etc/squid/advanced/ncsa"); @@ -1048,7 +1045,6 @@ function mod_htpasswd() { fclose($passfile); conf_mount_ro(); - config_unlock(); } function generate_htpasswd($username, $password) { diff --git a/config/squid3/33/squid_auth.inc b/config/squid3/33/squid_auth.inc index 7c99a01b..54e69b49 100644 --- a/config/squid3/33/squid_auth.inc +++ b/config/squid3/33/squid_auth.inc @@ -35,8 +35,7 @@ function global_eval_auth_options() { global $config; conf_mount_rw(); - config_lock(); - + switch ($config['installedpackages']['squidauth']['config'][0]['auth_method']) { case "none": dynamic_auth_content("pkg_edit"); @@ -69,7 +68,6 @@ function global_eval_auth_options() break; } - config_unlock(); conf_mount_ro(); } /* end function global_eval_auth_options */ @@ -443,4 +441,4 @@ function dynamic_auth_content($pkgvar) { } } /* end function dynamic_auth_content */ -?>
\ No newline at end of file +?> diff --git a/config/squid3/33/squid_ng.inc b/config/squid3/33/squid_ng.inc index 3b9ef405..d1c37dbf 100755 --- a/config/squid3/33/squid_ng.inc +++ b/config/squid3/33/squid_ng.inc @@ -38,7 +38,6 @@ function global_write_squid_config() { global $config; conf_mount_rw(); - config_lock(); /* define squid configuration file in variable for replace function */ $squidconfig = "/usr/local/etc/squid/squid.conf"; @@ -791,7 +790,6 @@ function global_write_squid_config() fclose($fout); conf_mount_ro(); - config_unlock(); touch($squidconfig); } /* end function write_squid_config */ @@ -1032,7 +1030,6 @@ function write_static_squid_config() { function mod_htpasswd() { global $config; conf_mount_rw(); - config_lock(); if (!file_exists("/usr/local/etc/squid/advanced/ncsa")) mwexec("mkdir -p /usr/local/etc/squid/advanced/ncsa"); @@ -1048,7 +1045,6 @@ function mod_htpasswd() { fclose($passfile); conf_mount_ro(); - config_unlock(); } function generate_htpasswd($username, $password) { diff --git a/config/strikeback/strikeback.inc b/config/strikeback/strikeback.inc index 89e7596c..131e961b 100644 --- a/config/strikeback/strikeback.inc +++ b/config/strikeback/strikeback.inc @@ -44,7 +44,6 @@ function php_install_command_sb() global $config; conf_mount_rw(); - config_lock(); if (!is_dir('/usr/local/www/packages/')) { exec("mkdir /usr/local/www/packages/"); @@ -105,7 +104,6 @@ function php_install_command_sb() exec("mv /usr/local/www/packages/strikeback/43132.png /usr/local/www/packages/strikeback/color.png"); conf_mount_ro(); - config_unlock(); } diff --git a/config/stunnel/stunnel.inc b/config/stunnel/stunnel.inc index dd3eee5c..4398a0dc 100644 --- a/config/stunnel/stunnel.inc +++ b/config/stunnel/stunnel.inc @@ -122,7 +122,6 @@ function stunnel_delete($config) { function stunnel_save($config) { $GLOBALS['config']['installedpackages']['stunnelcerts']['savemsg']=''; conf_mount_rw(); - config_lock(); if (!file_exists(STUNNEL_ETCDIR)) @mkdir(STUNNEL_ETCDIR, 0755, true); $fout = fopen(STUNNEL_ETCDIR . "/stunnel.conf","w"); @@ -148,7 +147,6 @@ function stunnel_save($config) { } fclose($fout); conf_mount_ro(); - config_unlock(); system("/usr/local/etc/rc.d/stunnel.sh stop 2>/dev/null"); system("/usr/local/etc/rc.d/stunnel.sh start 2>/dev/null"); } @@ -221,7 +219,6 @@ function stunnel_install() { unlink_if_exists("/usr/local/etc/rc.d/stunnel"); conf_mount_rw(); - config_lock(); $fout = fopen(STUNNEL_ETCDIR . "/stunnel.conf","w"); fwrite($fout, "cert = " . STUNNEL_ETCDIR . "/stunnel.pem \n"); fwrite($fout, "chroot = /var/tmp/stunnel \n"); @@ -238,7 +235,6 @@ function stunnel_install() { } fclose($fout); conf_mount_ro(); - config_unlock(); } function stunnel_deinstall() { diff --git a/config/suricata/suricata.xml b/config/suricata/suricata.xml index 79189b44..e2c4735c 100644 --- a/config/suricata/suricata.xml +++ b/config/suricata/suricata.xml @@ -1,46 +1,46 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> <![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - suricata.xml - part of the Suricata package for pfSense - Copyright (C) 2014 Bill meeks - - All rights reserved. - */ -/* ========================================================================== */ + suricata.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2014-2015 Bill Meeks + All rights reserved. +*/ +/* ====================================================================================== */ /* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + 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. - 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. - 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. - */ -/* ========================================================================== */ + 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>Suricata IDS/IPS Package</description> - <requirements>None</requirements> <name>suricata</name> <version>2.0.8 pkg v2.1.6</version> <title>Services: Suricata IDS</title> @@ -60,259 +60,205 @@ <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata.priv.inc</item> <prefix>/etc/inc/priv/</prefix> - <chmod>077</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata.inc</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_sync.xml</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_check_cron_misc.inc</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_check_for_rule_updates.php</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_yaml_template.inc</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_generate_yaml.php</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_migrate_config.php</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_post_install.php</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_uninstall.php</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_defs.inc</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_geoipupdate.php</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_etiqrisk_update.php</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/deprecated_rules</item> <prefix>/usr/local/pkg/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_download_updates.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_global.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_alerts.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_interfaces.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_interfaces_edit.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_download_rules.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_rules.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_rulesets.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_rules_flowbits.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_rules_edit.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_flow_stream.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_os_policy_engine.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_import_aliases.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_suppress.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_suppress_edit.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_logs_browser.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_logs_mgmt.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_sid_mgmt.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_list_view.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_app_parsers.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_libhtp_policy_engine.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_define_vars.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_barnyard.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_ip_list_mgmt.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_ip_reputation.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <item>https://packages.pfsense.org/packages/config/suricata/suricata_iprep_list_browser.php</item> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/javascript/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/suricata_alerts.js</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/widgets/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/suricata_alerts.widget.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/include/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/widget-suricata.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/suricata_blocked.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/suricata_passlist.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/suricata_passlist_edit.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/suricata/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/suricata_select_alias.php</item> </additional_files_needed> <additional_files_needed> <prefix>/var/db/suricata/sidmods/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/disablesid-sample.conf</item> </additional_files_needed> <additional_files_needed> <prefix>/var/db/suricata/sidmods/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/enablesid-sample.conf</item> </additional_files_needed> <additional_files_needed> <prefix>/var/db/suricata/sidmods/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/suricata/modifysid-sample.conf</item> </additional_files_needed> <!-- configpath gets expanded out automatically and config items will be stored in that location --> <configpath>['installedpackages']['suricata']</configpath> - <tabs> - </tabs> - <fields> - </fields> <custom_php_install_command> <![CDATA[ include_once("/usr/local/pkg/suricata/suricata_post_install.php"); diff --git a/config/syslog-ng/syslog-ng.inc b/config/syslog-ng/syslog-ng.inc index 56decfad..f0c17ff1 100644 --- a/config/syslog-ng/syslog-ng.inc +++ b/config/syslog-ng/syslog-ng.inc @@ -1,8 +1,9 @@ <?php -/* $Id$ */ /* syslog-ng.inc + part of pfSense (https://www.pfSense.org/) Copyright (C) 2012 Lance Leger + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,7 +27,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require_once('globals.inc'); require_once('config.inc'); require_once('util.inc'); @@ -34,29 +34,31 @@ require_once('pfsense-utils.inc'); require_once('pkg-utils.inc'); require_once('service-utils.inc'); -if(!function_exists("filter_configure")) +if (!function_exists("filter_configure")) { require_once("filter.inc"); +} -$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("SYSLOGNG_BASEDIR", "/usr/pbi/syslog-ng-" . php_uname("m") . "/"); -else +} else { define("SYSLOGNG_BASEDIR", "/usr/local/"); +} function syslogng_get_real_interface_address($interface) { $interface = convert_friendly_interface_to_real_interface_name($interface); - $line = trim(shell_exec("ifconfig $interface | grep inet | grep -v inet6 | awk '{ print \$2, \$4 }'")); - list($ip, $netmask) = explode(" ", $line); - - return array($ip, long2ip(hexdec($netmask))); + $ip = get_interface_ip($interface); + return array($ip); } function syslogng_install_command() { conf_mount_rw(); - if (is_link("/usr/local/lib/syslog-ng")) - unlink_if_exists("/usr/local/lib/syslog-ng"); - if (!file_exists("/usr/local/lib/syslog-ng")) + if (is_link("/usr/local/lib/syslog-ng")) { + unlink("/usr/local/lib/syslog-ng"); + } + if (!file_exists("/usr/local/lib/syslog-ng")) { @symlink(SYSLOGNG_BASEDIR . "local/lib/syslog-ng", "/usr/local/lib/syslog-ng"); + } syslogng_install_cron(true); conf_mount_ro(); syslogng_resync(); @@ -64,10 +66,10 @@ function syslogng_install_command() { function syslogng_deinstall_command() { conf_mount_rw(); - exec("/usr/local/etc/rc.d/syslog-ng.sh stop"); + service_stop("syslog-ng"); unlink_if_exists("/usr/local/etc/rc.d/syslog-ng.sh"); if (is_link("/usr/local/lib/syslog-ng")) - unlink_if_exists("/usr/local/lib/syslog-ng"); + unlink("/usr/local/lib/syslog-ng"); syslogng_install_cron(false); unlink_if_exists("/usr/local/etc/logrotate.conf"); unlink_if_exists("/usr/local/etc/syslog-ng.conf"); @@ -77,88 +79,95 @@ function syslogng_deinstall_command() { function syslogng_validate_general($post, &$input_errors) { global $config; - + $objects = $config['installedpackages']['syslogngadvanced']['config']; - - if(empty($post['interfaces'])) { + + if (empty($post['interfaces'])) { $input_errors[] = 'You must select at least one interface in \'Interfaces\' field'; } else { $post['interfaces'] = implode(",", $post['interfaces']); } - - if(!is_port($post['default_port'])) + + if (!is_port($post['default_port'])) { $input_errors[] = 'You must enter a valid port number in the \'Default Port\' field'; - + } + $sockstat = trim(shell_exec("sockstat -l -P " . $post['default_protocol'] . " -p " . $post['default_port'] . " | grep -v ^USER | grep -v syslog-ng")); - if(!empty($sockstat)) + if (!empty($sockstat)) { $input_errors[] = 'The port specified in the \'Default Port\' field is already in use'; - - if(!preg_match("/^\\/[^?*:;{}\\\\]+[^\\/]$/", $post['default_logdir'])) { + } + + if (!preg_match("/^\\/[^?*:;{}\\\\]+[^\\/]$/", $post['default_logdir'])) { $input_errors[] = 'You must enter a valid directory in the \'Default Log Directory\' field'; - } elseif($post['default_logdir'] == "/var/log") { + } elseif ($post['default_logdir'] == "/var/log") { $input_errors[] = 'You must enter a valid directory in the \'Default Log Directory\' field -- /var/log is reserved for pfSense'; } - - if(!preg_match("/^[^\\/?*:;{}\\\\]+$/", $post['default_logfile'])) + + if (!preg_match("/^[^\\/?*:;{}\\\\]+$/", $post['default_logfile'])) { $input_errors[] = 'You must enter a valid file in the \'Default Log File\' field'; - + } + $default_objects = syslogng_build_default_objects($post); - - if(empty($objects)) { + + if (empty($objects)) { $objects = $default_objects; } else { $objects = syslogng_merge_objects($objects, $default_objects); } - - if($errors = syslogng_test_object_syntax($objects)) + + if ($errors = syslogng_test_object_syntax($objects)) { $input_errors[] = "Syslog-ng syntax test failed:\n" . $errors; + } } function syslogng_validate_advanced($post, &$input_errors) { global $config; - + $objects = $config['installedpackages']['syslogngadvanced']['config']; - if($post['objectname'] == '_DEFAULT') { + if ($post['objectname'] == '_DEFAULT') { $input_errors[] = 'Creation or modification of \'_DEFAULT\' objects not permitted. Change default settings under \'General\' tab.'; } - + $post['objectparameters'] = base64_encode($post['objectparameters']); $new_object[] = array("objecttype"=>$post['objecttype'], "objectname"=>$post['objectname'], "objectparameters"=>$post['objectparameters']); - - if(empty($objects)) { + + if (empty($objects)) { $objects = $new_object; } else { $objects = syslogng_merge_objects($objects, $new_object); } - - if($errors = syslogng_test_object_syntax($objects)) + + if ($errors = syslogng_test_object_syntax($objects)) { $input_errors[] = "Syslog-ng syntax test failed:\n" . $errors; + } } function syslogng_install_cron($should_install) { - global $config, $g; - - if($g['booting']==true) + global $config; + + if (platform_booting()) { return; - - if(!$config['cron']['item']) + } + + if (!$config['cron']['item']) { return; + } $x=0; $rotate_job_id=-1; $rotate_is_installed = false; - - foreach($config['cron']['item'] as $item) { - if(strstr($item['task_name'], "syslogng_rotate_logs")) { + + foreach ($config['cron']['item'] as $item) { + if (strstr($item['task_name'], "syslogng_rotate_logs")) { $rotate_job_id = $x; } $x++; } $need_write = false; - switch($should_install) { + switch ($should_install) { case true: - if($rotate_job_id < 0) { + if ($rotate_job_id < 0) { $cron_item = array(); $cron_item['task_name'] = "syslogng_rotate_logs"; $cron_item['minute'] = "0"; @@ -167,21 +176,21 @@ function syslogng_install_cron($should_install) { $cron_item['month'] = "*"; $cron_item['wday'] = "*"; $cron_item['who'] = "root"; - $cron_item['command'] = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf"; + $cron_item['command'] = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf"; $config['cron']['item'][] = $cron_item; $need_write = true; } - if($need_write) { + if ($need_write) { parse_config(true); write_config("Adding syslog-ng Cron Jobs"); } break; case false: - if($rotate_job_id >= 0) { + if ($rotate_job_id >= 0) { unset($config['cron']['item'][$rotate_job_id]); $need_write = true; } - if($need_write) { + if ($need_write) { parse_config(true); write_config("Removing syslog-ng Cron Jobs"); } @@ -192,17 +201,17 @@ function syslogng_install_cron($should_install) { function syslogng_build_default_objects($settings) { $default_objects = array(); - + $interfaces = $settings['interfaces']; $default_protocol = $settings['default_protocol']; $default_port = $settings['default_port']; $default_logdir = $settings['default_logdir']; $default_logfile = $settings['default_logfile']; - + $default_objects[0] = array("objecttype"=>"source", "objectname"=>"_DEFAULT", "objectparameters"=>"{ internal(); syslog(transport($default_protocol) port($default_port)"); foreach (explode(",", $interfaces) as $interface) { $interface_address = syslogng_get_real_interface_address($interface); - if($interface_address[0]) { + if ($interface_address[0]) { $default_objects[0]['objectparameters'] .= " ip({$interface_address[0]})"; } } @@ -212,51 +221,52 @@ function syslogng_build_default_objects($settings) { $default_objects[1]['objectparameters'] = base64_encode($default_objects[1]['objectparameters']); $default_objects[2] = array("objecttype"=>"log", "objectname"=>"_DEFAULT", "objectparameters"=>"{ source(_DEFAULT); destination(_DEFAULT); };"); $default_objects[2]['objectparameters'] = base64_encode($default_objects[2]['objectparameters']); - + return $default_objects; } -function syslogng_merge_objects($objects1, $objects2) -{ - foreach($objects2 as $object2) { +function syslogng_merge_objects($objects1, $objects2) { + + foreach ($objects2 as $object2) { $match = 0; - foreach($objects1 as &$object1) { - if(($object2['objecttype'] == $object1['objecttype']) && ($object2['objectname'] == $object1['objectname'])) { + foreach ($objects1 as &$object1) { + if (($object2['objecttype'] == $object1['objecttype']) && ($object2['objectname'] == $object1['objectname'])) { $object1 = $object2; $match = 1; } } - if($match == 0) + if ($match == 0) { array_push($objects1, $object2); + } } return $objects1; } function syslogng_test_object_syntax($objects) { - exec("mv /usr/local/etc/syslog-ng.conf /usr/local/etc/syslog-ng.conf.backup"); + rename("/usr/local/etc/syslog-ng.conf", "/usr/local/etc/syslog-ng.conf.backup"); syslogng_build_conf($objects); $errors = trim(shell_exec('/usr/local/sbin/syslog-ng --syntax-only 2>&1')); - exec("mv /usr/local/etc/syslog-ng.conf /usr/local/etc/syslog-ng.conf.tested"); - exec("mv /usr/local/etc/syslog-ng.conf.backup /usr/local/etc/syslog-ng.conf"); - + rename("/usr/local/etc/syslog-ng.conf", "/usr/local/etc/syslog-ng.conf.tested"); + rename("/usr/local/etc/syslog-ng.conf.backup", "/usr/local/etc/syslog-ng.conf"); + return $errors; } function syslogng_get_log_files($objects) { $log_files = array(); - - foreach($objects as $object) { - if($object['objecttype'] == 'destination') { + + foreach ($objects as $object) { + if ($object['objecttype'] == 'destination') { preg_match("/\bfile\b\(['\"]([^'\"]*)['\"]/", base64_decode($object['objectparameters']), $match); - if($match) { + if ($match) { $log_file = $match[1]; array_push($log_files, $log_file); } } } - + return $log_files; } @@ -264,15 +274,15 @@ function syslogng_build_conf($objects) { $conf = "# This file is automatically generated by pfSense\n"; $conf .= "# Do not edit manually !\n"; $conf .= "@version:3.6\n"; - - foreach($objects as $object) { - if($object['objecttype'] == 'log' || $object['objecttype'] == 'options') { + + foreach ($objects as $object) { + if ($object['objecttype'] == 'log' || $object['objecttype'] == 'options') { $conf .= $object['objecttype'] . " " . base64_decode($object['objectparameters']) . "\n"; } else { $conf .= $object['objecttype'] . " " . $object['objectname'] . " " . base64_decode($object['objectparameters']) . "\n"; } } - + file_put_contents('/usr/local/etc/syslog-ng.conf', $conf); } @@ -287,7 +297,7 @@ function syslogng_build_logrotate_conf($settings, $objects) { $log_files = syslogng_get_log_files($objects); - foreach($log_files as $log_file) { + foreach ($log_files as $log_file) { $conf .= "$log_file "; } @@ -295,9 +305,9 @@ function syslogng_build_logrotate_conf($settings, $objects) { $conf .= "\trotate $max_archives\n"; $conf .= "\t$archive_frequency\n"; - if($compress_archives == 'on') { + if ($compress_archives == 'on') { $conf .= "\tcompress\n"; - if($compress_type == 'bz2') { + if ($compress_type == 'bz2') { $conf .= "\tcompresscmd bzip2\n"; } } @@ -312,103 +322,113 @@ function syslogng_build_logrotate_conf($settings, $objects) { function syslogng_generate_rules($type) { global $config; - + $settings = $config['installedpackages']['syslogng']['config'][0]; - + $interfaces = ($settings['interfaces'] ? $settings['interfaces'] : 'lan'); $default_protocol = ($settings['default_protocol'] ? $settings['default_protocol'] : 'udp'); $default_port = ($settings['default_port'] ? $settings['default_port'] : 5140); - + $rules = ""; - switch($type) { + switch ($type) { case 'rule': foreach ($interfaces as $interface) { $rules .= "pass in quick on $interface proto $default_protocol from any to !($interface) port $default_port no state label\n"; } break; } - + return $rules; } - + function syslogng_resync() { global $config; conf_mount_rw(); - + $settings = $config['installedpackages']['syslogng']['config'][0]; $objects = $config['installedpackages']['syslogngadvanced']['config']; - - if(!isset($settings['enable'])) + + if (!isset($settings['enable'])) { $settings['enable'] = 'off'; - if(!isset($settings['interfaces'])) + } + if (!isset($settings['interfaces'])) { $settings['interfaces'] = 'lan'; - if(!isset($settings['default_protocol'])) + } + if (!isset($settings['default_protocol'])) { $settings['default_protocol'] = 'udp'; - if(!isset($settings['default_port'])) + } + if (!isset($settings['default_port'])) { $settings['default_port'] = 5140; - if(!isset($settings['default_logdir'])) + } + if (!isset($settings['default_logdir'])) { $settings['default_logdir'] = '/var/syslog-ng'; - if(!isset($settings['default_logfile'])) + } + if (!isset($settings['default_logfile'])) { $settings['default_logfile'] = 'default.log'; - if(!isset($settings['archive_frequency'])) + } + if (!isset($settings['archive_frequency'])) { $settings['archive_frequency'] = 'daily'; - if(!isset($settings['compress_archives'])) + } + if (!isset($settings['compress_archives'])) { $settings['compress_archives'] = 'on'; - if(!isset($settings['compress_type'])) + } + if (!isset($settings['compress_type'])) { $settings['compress_type'] = 'gz'; - if(!isset($settings['max_archives'])) + } + if (!isset($settings['max_archives'])) { $settings['max_archives'] = 30; - + } + $default_objects = syslogng_build_default_objects($settings); - - if(empty($objects)) { + + if (empty($objects)) { $objects = $default_objects; } else { $objects = syslogng_merge_objects($objects, $default_objects); } - - $sort = array(); - foreach($objects as $k=>$v) { - $sort['objecttype'][$k] = $v['objecttype']; - $sort['objectname'][$k] = $v['objectname']; - } - array_multisort($sort['objecttype'], SORT_ASC, $sort['objectname'], SORT_ASC, $objects); + + $sort = array(); + foreach ($objects as $k=>$v) { + $sort['objecttype'][$k] = $v['objecttype']; + $sort['objectname'][$k] = $v['objectname']; + } + array_multisort($sort['objecttype'], SORT_ASC, $sort['objectname'], SORT_ASC, $objects); syslogng_build_conf($objects); syslogng_build_logrotate_conf($settings, $objects); $config['installedpackages']['syslogng']['config'][0] = $settings; $config['installedpackages']['syslogngadvanced']['config'] = $objects; - - if($settings['enable'] == 'on') { - if(!file_exists($settings['default_logdir'])) { + + if ($settings['enable'] == 'on') { + if (!file_exists($settings['default_logdir'])) { exec("mkdir -p " . $settings['default_logdir']); } - + syslogng_write_rcfile(); - - if(!is_service_running('syslog-ng')) { + + if (!is_service_running('syslog-ng')) { log_error("Starting syslog-ng"); - exec("/usr/local/etc/rc.d/syslog-ng.sh start"); + start_service("syslog-ng"); } else { log_error("Reloading syslog-ng for configuration sync"); - exec("/usr/local/etc/rc.d/syslog-ng.sh restart"); + restart_service("syslog-ng"); } - + // Sleep for a couple seconds to give syslog-ng a chance to fire up fully. for ($i=0; $i < 10; $i++) { - if(!is_service_running('syslog-ng')) + if (!is_service_running('syslog-ng')) { sleep(1); + } } } else { - if(is_service_running('syslog-ng')) { + if (is_service_running('syslog-ng')) { log_error("Stopping syslog-ng"); - exec("/usr/local/etc/rc.d/syslog-ng.sh stop"); - + stop_service("syslog-ng"); unlink_if_exists("/usr/local/etc/rc.d/syslog-ng.sh"); } } - + write_config(); conf_mount_ro(); filter_configure(); diff --git a/config/syslog-ng/syslog-ng.xml b/config/syslog-ng/syslog-ng.xml index 7d58a2ef..9b0ccffc 100644 --- a/config/syslog-ng/syslog-ng.xml +++ b/config/syslog-ng/syslog-ng.xml @@ -2,47 +2,47 @@ <!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - syslog-ng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2012 Lance Leger - All rights reserved. - */ -/* ========================================================================== */ + syslog-ng.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Lance Leger + 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: + 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. + 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> <name>Syslog-ng</name> - <version>3.5.4.1_1 pkg.v.1.0.1</version> + <version>1.0.8</version> <title>Services: Syslog-ng</title> <include_file>/usr/local/pkg/syslog-ng.inc</include_file> <menu> @@ -72,18 +72,15 @@ </tab> </tabs> <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng.inc</item> + <prefix>/usr/local/pkg/</prefix> + <item>https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng.inc</item> </additional_files_needed> <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/pkg/</prefix> <item>https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng_advanced.xml</item> - </additional_files_needed> + </additional_files_needed> <additional_files_needed> - <prefix>/usr/local/www/</prefix> - <chmod>0755</chmod> + <prefix>/usr/local/www/</prefix> <item>https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng_log_viewer.php</item> </additional_files_needed> <fields> @@ -108,8 +105,8 @@ <type>select</type> <value>udp</value> <options> - <option><name>UDP</name><value>udp</value></option> - <option><name>TCP</name><value>tcp</value></option> + <option><name>UDP</name><value>udp</value></option> + <option><name>TCP</name><value>tcp</value></option> </options> <required/> </field> @@ -144,7 +141,7 @@ <type>select</type> <value>daily</value> <options> - <option><name>Daily</name><value>daily</value></option> + <option><name>Daily</name><value>daily</value></option> <option><name>Weekly</name><value>weekly</value></option> <option><name>Monthly</name><value>monthly</value></option> </options> @@ -163,8 +160,8 @@ <type>select</type> <value>gz</value> <options> - <option><name>Gzip</name><value>gz</value></option> - <option><name>Bzip2</name><value>bz2</value></option> + <option><name>Gzip</name><value>gz</value></option> + <option><name>Bzip2</name><value>bz2</value></option> </options> </field> <field> @@ -175,7 +172,7 @@ <default_value>30</default_value> <required/> </field> - </fields> + </fields> <custom_php_validation_command> syslogng_validate_general($_POST, $input_errors); </custom_php_validation_command> @@ -188,5 +185,7 @@ <custom_php_deinstall_command> syslogng_deinstall_command(); </custom_php_deinstall_command> - <filter_rules_needed>syslogng_generate_rules</filter_rules_needed> + <filter_rules_needed> + syslogng_generate_rules(); + </filter_rules_needed> </packagegui> diff --git a/config/syslog-ng/syslog-ng_advanced.xml b/config/syslog-ng/syslog-ng_advanced.xml index b1290544..94067580 100644 --- a/config/syslog-ng/syslog-ng_advanced.xml +++ b/config/syslog-ng/syslog-ng_advanced.xml @@ -1,48 +1,48 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - syslog-ng_advanced.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2012 Lance Leger - All rights reserved. - */ -/* ========================================================================== */ + syslog-ng_advanced.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Lance Leger + 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: + 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. + 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. - */ -/* ========================================================================== */ - ]]> - </copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + 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> <name>Syslog-ng Advanced</name> - <version>0.1.0</version> + <version>1.0.8</version> <title>Services: Syslog-ng Advanced</title> <include_file>/usr/local/pkg/syslog-ng.inc</include_file> <delete_string>An object has been deleted.</delete_string> @@ -133,4 +133,4 @@ <custom_php_resync_config_command> syslogng_resync(); </custom_php_resync_config_command> -</packagegui>
\ No newline at end of file +</packagegui> diff --git a/config/syslog-ng/syslog-ng_log_viewer.php b/config/syslog-ng/syslog-ng_log_viewer.php index c8183f14..c914110a 100644 --- a/config/syslog-ng/syslog-ng_log_viewer.php +++ b/config/syslog-ng/syslog-ng_log_viewer.php @@ -1,37 +1,32 @@ <?php -/* $Id$ */ -/* ========================================================================== */ /* - syslog-ng_log_viewer.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2012 Lance Leger - 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. - */ -/* ========================================================================== */ + syslog-ng_log_viewer.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Lance Leger + 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. +*/ require("guiconfig.inc"); require("/usr/local/pkg/syslog-ng.inc"); @@ -41,50 +36,56 @@ $default_logfile = $config['installedpackages']['syslogng']['config'][0]['defaul $compress_archives = $config['installedpackages']['syslogng']['config'][0]['compress_archives']; $compress_type = $config['installedpackages']['syslogng']['config'][0]['compress_type']; -if($_POST['logfile']) +if ($_POST['logfile']) { $logfile = $_POST['logfile']; -else +} else { $logfile = $default_logdir . "/" . $default_logfile; - -if($_POST['limit']) +} + +if ($_POST['limit']) { $limit = intval($_POST['limit']); -else +} else { $limit = "10"; +} -if($_POST['archives']) +if ($_POST['archives']) { $archives = true; +} -if($_POST['filter']) +if ($_POST['filter']) { $filter = $_POST['filter']; +} -if($_POST['not']) +if ($_POST['not']) { $not = true; +} $log_messages = array(); -if(file_exists($logfile) && (filesize($logfile) > 0)) { +if (file_exists($logfile) && (filesize($logfile) > 0)) { $grep = "grep -ih"; - - if(($compress_archives == 'on') && glob($logfile . "*" . $compress_type) && $archives) { + + if (($compress_archives == 'on') && glob($logfile . "*" . $compress_type) && $archives) { if($compress_type == 'bz2') { $grep = "bzgrep -ih"; } else { $grep = "zgrep -ih"; } } - - if(isset($filter) && $not) { + + if (isset($filter) && $not) { $grepcmd = "$grep -v '$filter' $logfile"; } else { $grepcmd = "$grep '$filter' $logfile"; } - - if($archives) + + if ($archives) { $grepcmd = $grepcmd . "*"; - + } + $log_lines = trim(shell_exec("$grepcmd | wc -l")); $log_output = trim(shell_exec("$grepcmd | sort -M | tail -n $limit")); - - if(!empty($log_output)) { + + if (!empty($log_output)) { $log_messages = explode("\n", $log_output); $log_messages_count = sizeof($log_messages); } @@ -92,7 +93,7 @@ if(file_exists($logfile) && (filesize($logfile) > 0)) { $pgtitle = "Services: Syslog-ng Log Viewer"; include("head.inc"); -?> +?> <body link="#000000" vlink="#000000" alink="#000000"> <?php include("fbegin.inc"); ?> <?php if ($savemsg) print_info_box($savemsg); ?> @@ -107,11 +108,11 @@ include("head.inc"); display_top_tabs($tab_array); ?> </td></tr> - <tr><td> + <tr><td> <div id="mainarea"> - <table id="maintable" name="maintable" class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> - + <table> <tr><td width="22%">Log File</td><td width="78%"><select name="logfile"> <?php @@ -143,7 +144,7 @@ include("head.inc"); <?php if(!empty($log_messages)) { echo "<tr><td class=\"listtopic\">Showing $log_messages_count of $log_lines messages</td></tr>\n"; - foreach($log_messages as $log_message) { + foreach($log_messages as $log_message) { echo "<tr><td class=\"listr\">$log_message</td></tr>\n"; } } else { @@ -156,7 +157,7 @@ include("head.inc"); <tr><td width="22%">Inverse Filter (NOT)</td><td width="78%"><input type="checkbox" name="not" <?php if($not) echo " CHECKED"; ?> /></td></tr> <tr><td colspan="2"><input type="submit" value="Refresh" /></td></tr> </table> - + </td></tr> </table> </div> @@ -164,4 +165,5 @@ include("head.inc"); </table> </form> <?php include("fend.inc"); ?> -</body>
\ No newline at end of file +</body> +</html> diff --git a/config/systempatches/patches.inc b/config/systempatches/patches.inc index f47324c4..0aa37fb8 100644 --- a/config/systempatches/patches.inc +++ b/config/systempatches/patches.inc @@ -1,7 +1,9 @@ <?php /* patches.inc + part of pfSense (https://www.pfSense.org/) Copyright (C) 2012 Jim Pingle + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -25,12 +27,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require_once("globals.inc"); require_once("util.inc"); global $git_root_url, $patch_suffix, $patch_dir, $patch_cmd; -$git_root_url = "http://github.com/pfsense/pfsense/commit/"; +$git_root_url = "https://github.com/pfsense/pfsense/commit/"; $patch_suffix = ".patch"; $patch_dir = "/var/patches"; $patch_cmd = "/usr/bin/patch"; diff --git a/config/systempatches/system_patches.php b/config/systempatches/system_patches.php index feeee07e..c33499cb 100644 --- a/config/systempatches/system_patches.php +++ b/config/systempatches/system_patches.php @@ -1,7 +1,9 @@ <?php /* system_patches.php + part of pfSense (https://www.pfSense.org/) Copyright (C) 2012 Jim Pingle + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -152,7 +154,7 @@ if (isset($_POST['del_x'])) { } $closehead = false; -$pgtitle = array(gettext("System"),gettext("Patches")); +$pgtitle = array(gettext("System"), gettext("Patches")); include("head.inc"); ?> @@ -166,7 +168,7 @@ include("head.inc"); <body link="#000000" vlink="#000000" alink="#000000"> <?php include("fbegin.inc"); ?> <form action="system_patches.php" method="post" name="iform"> -<script type="text/javascript" language="javascript" src="/javascript/row_toggle.js"></script> +<script type="text/javascript" src="/javascript/row_toggle.js"></script> <?php if ($savemsg) print_info_box_np($savemsg, "Patches", "Close", false); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system patches"> <tr><td><div id="mainarea"> @@ -204,7 +206,7 @@ include("head.inc"); <?php if (count($a_patches) == 0): ?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected patches");?>" border="0" alt="delete" /> <?php else: ?> - <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" /> + <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" /> <?php endif; ?> </td> <td><a href="system_patches_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new patch"); ?>" alt="add" /></a></td> @@ -221,7 +223,7 @@ foreach ($a_patches as $thispatch): ?> <tr valign="top" id="fr<?=$npatches;?>"> - <td class="listt"><input type="checkbox" id="frc<?=$npatches;?>" name="patch[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$npatches;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /></td> + <td class="listt"><input type="checkbox" id="frc<?=$npatches;?>" name="patch[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$npatches;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /></td> <td class="listlr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';"> <?=$thispatch['descr'];?> </td> @@ -260,10 +262,10 @@ foreach ($a_patches as $thispatch): <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';"> <?= isset($thispatch['autoapply']) ? "Yes" : "No" ?> </td> - <td valign="middle" class="list" nowrap> + <td valign="middle" class="list" nowrap="nowrap"> <table border="0" cellspacing="0" cellpadding="1" summary="edit"> <tr> - <td><input onmouseover="fr_insline(<?=$npatches;?>, true)" onmouseout="fr_insline(<?=$npatches;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected patches before this patch");?>" height="17" type="image" width="17" border="0" /></td> + <td><input onmouseover="fr_insline(<?=$npatches;?>, true)" onmouseout="fr_insline(<?=$npatches;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected patches before this patch");?>" type="image" /></td> <td><a href="system_patches_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit patch"); ?>" alt="edit" /></a></td> </tr> <tr> @@ -280,17 +282,17 @@ endforeach; ?> <tr> <td class="list" colspan="8"></td> - <td class="list" valign="middle" nowrap> + <td class="list" valign="middle" nowrap="nowrap"> <table border="0" cellspacing="0" cellpadding="1" summary="edit"> <tr> - <td><?php if ($npatches == 0): ?><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected patches to end"); ?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" width="17" height="17" title="<?=gettext("move selected patches to end");?>" border="0" alt="move" /><?php endif; ?></td> + <td><?php if ($npatches == 0): ?><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected patches to end"); ?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected patches to end");?>" alt="move" /><?php endif; ?></td> </tr> <tr> <td width="17"> <?php if (count($a_patches) == 0): ?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected patches");?>" border="0" alt="delete" /> <?php else: ?> - <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" /> + <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" /> <?php endif; ?> </td> <td><a href="system_patches_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new patch"); ?>" alt="add" /></a></td> diff --git a/config/systempatches/system_patches_edit.php b/config/systempatches/system_patches_edit.php index 9e1f7a49..9cde3e48 100644 --- a/config/systempatches/system_patches_edit.php +++ b/config/systempatches/system_patches_edit.php @@ -1,7 +1,9 @@ <?php /* system_patches_edit.php + part of pfSense (https://www.pfSense.org/) Copyright (C) 2012 Jim Pingle + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -80,7 +82,7 @@ if ($_POST) { $pconfig = $_POST; /* input validation */ - if(empty($_POST['location'])) { + if (empty($_POST['location'])) { $reqdfields = explode(" ", "patch"); $reqdfieldsn = array(gettext("Patch Contents")); } else { diff --git a/config/systempatches/systempatches.xml b/config/systempatches/systempatches.xml index ad7f5953..06f024a8 100644 --- a/config/systempatches/systempatches.xml +++ b/config/systempatches/systempatches.xml @@ -3,19 +3,22 @@ <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> <copyright> - <![CDATA[ -/* ========================================================================== */ +<![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ /* systempatches.xml - part of pfSense (http://www.pfSense.com) + part of pfSense (https://www.pfSense.org/) Copyright (C) 2012 Jim Pingle + 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. @@ -23,6 +26,7 @@ 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 @@ -34,30 +38,25 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* ========================================================================== */ +/* ====================================================================================== */ ]]> </copyright> - <description>System Patches</description> - <requirements>None</requirements> - <faq>Applies patches supplied by the user to the firewall.</faq> + <description>System Patches applies patches supplied by the user to the firewall.</description> <name>System Patches</name> - <version>1.0.4</version> + <version>1.0.5</version> <title>System: Patches</title> <include_file>/usr/local/pkg/patches.inc</include_file> <menu> <name>Patches</name> - <tooltiptext></tooltiptext> <section>System</section> <url>/system_patches.php</url> </menu> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>644</chmod> <item>https://packages.pfsense.org/packages/config/systempatches/system_patches.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>644</chmod> <item>https://packages.pfsense.org/packages/config/systempatches/system_patches_edit.php</item> </additional_files_needed> <additional_files_needed> @@ -67,7 +66,6 @@ </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>644</chmod> <item>https://packages.pfsense.org/packages/config/systempatches/patches.inc</item> </additional_files_needed> <custom_php_install_command> @@ -76,4 +74,4 @@ <custom_php_deinstall_command> patch_package_deinstall(); </custom_php_deinstall_command> -</packagegui>
\ No newline at end of file +</packagegui> diff --git a/config/test_package/test.inc b/config/test_package/test.inc new file mode 100644 index 00000000..292f8d44 --- /dev/null +++ b/config/test_package/test.inc @@ -0,0 +1,40 @@ +<?php +/* + test.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 John Doe + Copyright (C) 2010-2012 Jane Roe + Copyright (C) 2014 Johnnie Doe + 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. +*/ +function sync_package_test() { + // Put your own code to execute on package reconfiguration here +} + +function sync_package_test_reinstall() { + // Put your code to execute on package (re)install here +} + +?> diff --git a/config/test_package/test_package.php b/config/test_package/test_package.php deleted file mode 100644 index 8d68cf39..00000000 --- a/config/test_package/test_package.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -/* DISABLE_PHP_LINT_CHECKING */ - -class CommitTest { - function __construct() { - } - - public function testFunction() { - } -} - - -?>
\ No newline at end of file diff --git a/config/test_package/test_package.xml b/config/test_package/test_package.xml index 3e268fee..b073dba5 100644 --- a/config/test_package/test_package.xml +++ b/config/test_package/test_package.xml @@ -2,212 +2,165 @@ <!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - authng.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2007 to whom it may belong - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + test_package.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 John Doe + Copyright (C) 2010-2012 Jane Roe + Copyright (C) 2014 Johnnie Doe + 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: + 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. + 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. + 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. - */ -/* ========================================================================== */ - ]]> + + 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>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> - <name>Snort</name> - <version>2.6.0.2</version> - <title>Services: Snort</title> - <include_file>/usr/local/pkg/snort.inc</include_file> + <description>Describe your package here</description> + <requirements>Describe your package requirements here</requirements> + <faq>Currently there are no FAQ items provided.</faq> + <name>Test</name> + <version>1.0</version> + <title>Services: Test</title> + <include_file>/usr/local/pkg/test.inc</include_file> <menu> - <name>Snort</name> - <tooltiptext>Setup snort specific settings</tooltiptext> + <name>Test</name> + <tooltiptext>Setup test specific settings</tooltiptext> <section>Services</section> - <url>/pkg_edit.php?xml=snort.xml&id=0</url> + <url>/pkg_edit.php?xml=test_package.xml&id=0</url> </menu> <service> - <name>snort</name> - <rcfile>snort.sh</rcfile> - <executable>snort</executable> + <name>test</name> + <rcfile>test.sh</rcfile> + <executable>test</executable> </service> <tabs> <tab> - <text>Snort Settings</text> - <url>/pkg_edit.php?xml=snort.xml&id=0</url> + <text>Test Settings</text> + <url>/pkg_edit.php?xml=test_package.xml&id=0</url> <active/> </tab> <tab> - <text>Update Snort Rules</text> - <url>/snort_download_rules.php</url> - </tab> - <tab> - <text>Snort Rulesets</text> - <url>/snort_rulesets.php</url> - </tab> - <tab> - <text>Snort Blocked</text> - <url>/snort_blocked.php</url> + <text>Update Test Rules</text> + <url>/test_download_rules.php</url> </tab> <tab> - <text>Snort Whitelist</text> - <url>/pkg.php?xml=snort_whitelist.xml</url> + <text>Test Whitelist</text> + <url>/pkg.php?xml=test_whitelist.xml</url> </tab> <tab> - <text>Snort Alerts</text> - <url>/snort_alerts.php</url> + <text>Test Alerts</text> + <url>/test_alerts.php</url> </tab> </tabs> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort.inc</item> + <item>https://packages.pfsense.org/packages/config/test/test.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/bin/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/bin/snort2c</item> + <item>https://packages.pfsense.org/packages/config/test/bin/test</item> + <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort_download_rules.php</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort_rulesets.php</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort_whitelist.xml</item> + <item>https://packages.pfsense.org/packages/config/test/test_download_rules.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort_blocked.php</item> + <item>https://packages.pfsense.org/packages/config/test/test_alerts.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort_check_for_rule_updates.php</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/www/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort_alerts.php</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/pf/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/snort/snort_dynamic_ip_reload.php</item> + <item>https://packages.pfsense.org/packages/config/test/test_whitelist.xml</item> </additional_files_needed> <fields> <field> - <fielddescr>Interface</fielddescr> - <fieldname>iface_array</fieldname> - <description>Select all WAN type interfaces</description> + <fielddescr>Test Interface</fielddescr> + <fieldname>interfaces</fieldname> + <description>Select all LAN type interfaces</description> <type>interfaces_selection</type> <size>3</size> <value>lan</value> <multiple>true</multiple> + <required>true</required> </field> <field> <fielddescr>Performance</fielddescr> <fieldname>performance</fieldname> - <description>ac method is the fastest startup but consumes more a lot more memory. acs/ac-banded and ac-sparsebands/mwm/lowmem methods use quite a bit less.</description> + <description>Snail is slowest, warp is fastest.</description> <type>select</type> <options> <option> - <name>lowmem</name> - <value>lowmem</value> + <name>Snail</name> + <value>snailvalue</value> </option> <option> - <name>ac-std</name> - <value>ac-std</value> + <name>Low</name> + <value>lowvalue</value> </option> <option> - <name>ac</name> - <value>ac</value> + <name>Standard</name> + <value>stdvalue</value> </option> <option> - <name>ac-banded</name> - <value>ac-banded</value> + <name>Fast</name> + <value>fastvalue</value> </option> <option> - <name>ac-sparsebands</name> - <value>ac-sparsebands</value> - </option> - - <option> - <name>mwm</name> - <value>mwm</value> - </option> - <option> - <name>acs</name> - <value>acs</value> + <name>Warp</name> + <value>warpvalue</value> </option> </options> </field> <field> - <fielddescr>Oinkmaster code</fielddescr> - <fieldname>oinkmastercode</fieldname> - <description>Obtain a snort.org Oinkmaster code and paste here.</description> - <type>input</type> - <size>60</size> - <value></value> - </field> - <field> - <fielddescr>Block offenders</fielddescr> - <fieldname>blockoffenders</fieldname> - <description>Automatically block hosts that generate a snort alert.</description> + <fielddescr>Generate alerts</fielddescr> + <fieldname>testalerts</fieldname> + <description>Automatically generate alerts.</description> <type>checkbox</type> <size>60</size> </field> <field> <fielddescr>Update rules automatically</fielddescr> <fieldname>automaticrulesupdate</fieldname> - <description>Automatically check for and update rules once a week from snort.org.</description> + <description>Automatically check for and update rules once a week from example.org.</description> <type>checkbox</type> </field> </fields> <custom_add_php_command> - sync_package_snort(); + sync_package_test(); </custom_add_php_command> <custom_php_resync_config_command> - sync_package_snort(); + sync_package_test(); </custom_php_resync_config_command> <custom_php_install_command> - sync_package_snort_reinstall(); + sync_package_test_reinstall(); </custom_php_install_command> -</packagegui>
\ No newline at end of file +</packagegui> diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index 717ce967..82d5b453 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -26,7 +26,6 @@ if (!function_exists('clear_log_file')) { function tinc_save() { global $config; conf_mount_rw(); - config_lock(); exec("/bin/mv -f /usr/local/etc/tinc /usr/local/etc/tinc.old"); safe_mkdir("/usr/local/etc/tinc"); safe_mkdir("/usr/local/etc/tinc/hosts"); @@ -127,7 +126,6 @@ function tinc_save() { rmdir_recursive("/usr/local/etc/tinc.old"); conf_mount_ro(); - config_unlock(); } function tinc_install() { @@ -142,7 +140,6 @@ function tinc_install() { clear_log_file("/var/log/tinc.log"); conf_mount_rw(); - config_lock(); /* Create Interface Group */ if (!is_array($config['ifgroups']['ifgroupentry'])) @@ -161,14 +158,12 @@ function tinc_install() { write_config(); conf_mount_ro(); - config_unlock(); } function tinc_deinstall() { global $config; /* Remove Interface Group */ conf_mount_rw(); - config_lock(); if (!is_array($config['ifgroups']['ifgroupentry'])) $config['ifgroups']['ifgroupentry'] = array(); @@ -200,7 +195,6 @@ function tinc_deinstall() { write_config(); } conf_mount_ro(); - config_unlock(); rmdir_recursive("/var/tmp/tinc"); rmdir_recursive("/usr/local/etc/tinc*"); diff --git a/config/tinydns/tinydns.inc b/config/tinydns/tinydns.inc index f2bda436..3bf64777 100644 --- a/config/tinydns/tinydns.inc +++ b/config/tinydns/tinydns.inc @@ -420,7 +420,7 @@ function tinydns_setup_ping_items() { log_error("Could not open {$g['vardb_path']}/pkgpinghosts for writing."); return; } - config_lock(); + /* write out each ip address so ping_hosts.sh can begin monitoring ip * status and create a database of the status information that we can use. */ @@ -484,7 +484,6 @@ function tinydns_setup_ping_items() { } } fclose($fd); - config_unlock(); } function tinydns_create_zone_file() { @@ -492,7 +491,6 @@ function tinydns_create_zone_file() { conf_mount_rw(); if(file_exists("/tmp/config.cache")) unlink("/tmp/config.cache"); - config_lock(); if(file_exists("{$g['varrun_path']}/service/tinydns/root/data")) exec("rm -f {$g['varrun_path']}/service/tinydns/root/data"); if(!is_dir("{$g['varrun_path']}/service/tinydns/root")) @@ -648,7 +646,6 @@ function tinydns_create_zone_file() { fclose($fd); /* tell tinydns to reload zone file */ exec("cd {$g['varrun_path']}/service/tinydns/root && /usr/local/bin/tinydns-data"); - config_unlock(); conf_mount_ro(); } diff --git a/config/vhosts/system_advanced_create_certs.tmp b/config/vhosts/system_advanced_create_certs.php index 2b0b2229..3ed25d55 100644 --- a/config/vhosts/system_advanced_create_certs.tmp +++ b/config/vhosts/system_advanced_create_certs.php @@ -1,10 +1,9 @@ <?php -/* $Id$ */ /* system_advanced_create_certs.php - part of pfSense - - Copyright (C) 2004 Scott Ullrich + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Mark J Crane + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,15 +27,13 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); -if(file_exists("/var/etc/ssl/openssl.cnf")) { +if (file_exists("/var/etc/ssl/openssl.cnf")) { $openssl = file_get_contents("/var/etc/ssl/openssl.cnf"); } -/* Lets match the fileds in the read in file and - populate the variables for the form */ +/* Lets match the fileds in the read file and populate the variables for the form */ preg_match('/C\=(.*)\n/', $openssl, $countrycodeA); preg_match('/\nST\=(.*)\n/', $openssl, $stateorprovinceA); preg_match('/\nL\=(.*)\n/', $openssl, $citynameA); @@ -139,36 +136,36 @@ if ($_POST) { fwrite($fd, "authorityKeyIdentifier=keyid:always,issuer:always\n"); fclose($fd); -$pgtitle = "System: Advanced functions: Create Certificates"; +$pgtitle = "System: Advanced - Create Certificates"; include("head.inc"); ?> <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<p class="pgtitle"><?=$pgtitle?></p> <form action="system_advanced_create_certs.php" method="post" name="iform" id="iform"> - <?php if ($input_errors) print_input_errors($input_errors); ?> - <?php if ($savemsg) print_info_box($savemsg); ?> - <p>One moment please... + <?php if ($input_errors) print_input_errors($input_errors); ?> + <?php if ($savemsg) print_info_box($savemsg); ?> + <div>One moment please...</div> <?php mwexec("cd /tmp/ && /usr/bin/openssl req -new -x509 -keyout /tmp/cakey.pem -out /tmp/cacert.pem -days 3650 -config /var/etc/ssl/openssl.cnf -passin pass:test -nodes"); $cacert1 = file_get_contents("/tmp/cacert.pem"); $cakey1 = file_get_contents("/tmp/cakey.pem"); - $cacertA = str_replace("\r","",$cacert1); - $cakeyA = str_replace("\r","",$cakey1); - $cacert = str_replace("\n","\\n",$cacertA); - $cakey = str_replace("\n","\\n",$cakeyA); + $cacertA = str_replace("\r", "", $cacert1); + $cakeyA = str_replace("\r", "", $cakey1); + $cacert = str_replace("\n", "\\n", $cacertA); + $cakey = str_replace("\n", "\\n", $cakeyA); ?> - <script language="JavaScript"> - <!-- + <script type="text/javascript"> + //<![CDATA[ var cacert='<?=$cacert?>'; var cakey='<?=$cakey?>'; opener.document.forms[0].certificate.value=cacert; opener.document.forms[0].privatekey.value=cakey; this.close(); - --> + //]]> </script> - +</form> +<?php include("fend.inc"); ?> </body> </html> @@ -176,61 +173,52 @@ include("head.inc"); } else { -$pgtitle = ' System: Advanced - Create Certificates'; +$pgtitle = "System: Advanced - Create Certificates"; include("head.inc"); ?> - - <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <form action="system_advanced_create_certs.php" method="post" name="iform" id="iform"> - <p class="pgtitle">System: Advanced - Create Certificates</p> - <table width="100%" border="0" cellpadding="6" cellspacing="0"> <tr> <td width="35%" valign="top" class="vncell"><B>Country Code (2 Letters)</td> <td width="78%" class="vtable"> - <input name="countrycode" value="<?=$countrycode?>"> - </span> + <input name="countrycode" type="text" value="<?=$countrycode?>" /> </td> </tr> <tr> <td width="35%" valign="top" class="vncell"><B>State or Province name</td> <td width="78%" class="vtable"> - <input name="stateorprovince" value="<?=$stateorprovince?>"> - </span> + <input name="stateorprovince" type="text" value="<?=$stateorprovince?>" /> </td> </tr> <tr> <td width="35%" valign="top" class="vncell"><B>City name</td> <td width="78%" class="vtable"> - <input name="cityname" value="<?=$cityname?>"> - </span> + <input name="cityname" type="text" value="<?=$cityname?>" /> </td> </tr> <tr> <td width="35%" valign="top" class="vncell"><B>Organization name</td> <td width="78%" class="vtable"> - <input name="orginizationname" value="<?=$orginizationname?>"> - </span> + <input name="orginizationname" type="text" value="<?=$orginizationname?>" /> </td> </tr> <tr> <td width="35%" valign="top" class="vncell"><B>Organization department</td> <td width="78%" class="vtable"> - <input name="orginizationdepartment" value="<?=$orginizationdepartment?>"> - </span> + <input name="orginizationdepartment" type="text" value="<?=$orginizationdepartment?>" /> </td> </tr> <tr> <td width="35%" valign="top" class="vncell"><B>Common Name (Your name)</td> <td width="78%" class="vtable"> - <input name="commonname" value="<?=$commonname?>"> - </span> + <input name="commonname" type="text" value="<?=$commonname?>" /> </td> </tr> @@ -238,8 +226,7 @@ include("head.inc"); <tr> <td width="35%" valign="top" class="vncell"><B>E-Mail address</td> <td width="78%" class="vtable"> - <input name="email" value="<?=$email?>"> - </span> + <input name="email" type="text" value="<?=$email?>" /> </td> </tr> --> @@ -247,13 +234,15 @@ include("head.inc"); <tr> <td width="35%" valign="top"> </td> <td width="78%"> - <input name="Submit" type="submit" class="formbtn" value="Save"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> </td> </tr> </table> + </form> - </body> - </html> +<?php include("fend.inc"); ?> +</body> +</html> <?php } diff --git a/config/vhosts/vhosts.inc b/config/vhosts/vhosts.inc index 1958632e..cf2f97b8 100644 --- a/config/vhosts/vhosts.inc +++ b/config/vhosts/vhosts.inc @@ -1,14 +1,11 @@ <?php -/* $Id$ */ -/* -/* ========================================================================== */ -/* - vhosts.inc - Copyright (C) 2008 Mark J Crane - All rights reserved. - */ -/* ========================================================================== */ /* + vhosts.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Mark J Crane + 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: @@ -30,262 +27,217 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -//show errors - ini_set('display_errors', '1'); - //error_reporting (E_ALL); // Report everything - //error_reporting (E_ALL ^ E_NOTICE); // Report everything - error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings - -if (!function_exists("pkg_is_service_running")) { - function pkg_is_service_running($servicename) - { - exec("/bin/ps ax | awk '{ print $5 }'", $psout); - array_shift($psout); - foreach($psout as $line) { - $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); - } - if(is_service_running($servicename, $ps) or is_process_running($servicename) ) { - return true; - } - else { - return false; - } - } +//sort array +function sort_host($a, $b) { + return strcmp($a["host"], $b["host"]); } -if (!function_exists("byte_convert")) { - function byte_convert( $bytes ) { - if ($bytes<=0) - return '0 Byte'; - - $convention=1000; //[1000->10^x|1024->2^x] - $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); - $e=floor(log($bytes,$convention)); - return round($bytes/pow($convention,$e),2).' '.$s[$e]; - } +function sort_port($a, $b) { + return strcmp($a["port"], $b["port"]); } -//sort array - function sort_host($a, $b){ - return strcmp($a["host"], $b["host"]); - } - - function sort_port($a, $b){ - return strcmp($a["port"], $b["port"]); - } - - function sort_ip_address($a, $b){ - return natsort($a["ipaddress"], $b["ipaddress"]); - } - +function sort_ip_address($a, $b) { + return natsort($a["ipaddress"], $b["ipaddress"]); +} -//check to see if the service is installed if it is return the id - function get_service_id ($service_array, $fieldname, $fieldvalue) { - $x = 0; - $id = ''; - foreach($service_array as $rowhelper) { - if ($rowhelper[$fieldname] == $fieldvalue) { - $id = $x; //return the id - } - $x++; - } - if (strlen($id) > 0) { - return ($id); - } - else { - return false; +// Check to see if the service is installed if it is return the id +function get_service_id ($service_array, $fieldname, $fieldvalue) { + $x = 0; + $id = ''; + foreach ($service_array as $rowhelper) { + if ($rowhelper[$fieldname] == $fieldvalue) { + $id = $x; //return the id } + $x++; } + if (strlen($id) > 0) { + return ($id); + } else { + return false; + } +} -function vhosts_sync_package_php() -{ +function vhosts_sync_package() { global $config; - if($config['installedpackages']['vhosts']['config'] != "") { - + if ($config['installedpackages']['vhosts']['config'] != "") { conf_mount_rw(); - config_unlock(); - - //sort the vhosts array - $vhostarray = $config['installedpackages']['vhosts']['config']; - if (count(vhostarray) > 1) { - usort($vhostarray, 'sort_ipaddress'); - usort($vhostarray, 'sort_host'); - usort($vhostarray, 'sort_port'); - } - $vhostarray_http = ''; - $vhostarray_https = ''; - $x = 0; - foreach($vhostarray as $rowhelper) { - if ($rowhelper['enabled'] != "false") { - if (strlen($rowhelper['certificate']) > 0 && strlen($rowhelper['privatekey']) > 0) { - $vhostarray_https[$x]['host'] = $rowhelper['host']; - $vhostarray_https[$x]['ipaddress'] = $rowhelper['ipaddress']; - $vhostarray_https[$x]['port'] = $rowhelper['port']; - $vhostarray_https[$x]['directory'] = $rowhelper['directory']; - $vhostarray_https[$x]['certificate'] = $rowhelper['certificate']; - $vhostarray_https[$x]['privatekey'] = $rowhelper['privatekey']; - $vhostarray_https[$x]['enabled'] = $rowhelper['enabled']; - $vhostarray_https[$x]['description'] = $rowhelper['description']; - } - else { - $vhostarray_http[$x]['host'] = $rowhelper['host']; - $vhostarray_http[$x]['ipaddress'] = $rowhelper['ipaddress']; - $vhostarray_http[$x]['port'] = $rowhelper['port']; - $vhostarray_http[$x]['directory'] = $rowhelper['directory']; - $vhostarray_http[$x]['certificate'] = ''; - $vhostarray_http[$x]['privatekey'] = ''; - $vhostarray_http[$x]['enabled'] = $rowhelper['enabled']; - $vhostarray_http[$x]['description'] = $rowhelper['description']; - $server_port = $rowhelper['port']; - } - $x++; + + //sort the vhosts array + $vhostarray = $config['installedpackages']['vhosts']['config']; + if (count(vhostarray) > 1) { + usort($vhostarray, 'sort_ipaddress'); + usort($vhostarray, 'sort_host'); + usort($vhostarray, 'sort_port'); + } + $vhostarray_http = ''; + $vhostarray_https = ''; + $x = 0; + foreach ($vhostarray as $rowhelper) { + if ($rowhelper['enabled'] != "false") { + if (strlen($rowhelper['certificate']) > 0 && strlen($rowhelper['privatekey']) > 0) { + $vhostarray_https[$x]['host'] = $rowhelper['host']; + $vhostarray_https[$x]['ipaddress'] = $rowhelper['ipaddress']; + $vhostarray_https[$x]['port'] = $rowhelper['port']; + $vhostarray_https[$x]['directory'] = $rowhelper['directory']; + $vhostarray_https[$x]['certificate'] = $rowhelper['certificate']; + $vhostarray_https[$x]['privatekey'] = $rowhelper['privatekey']; + $vhostarray_https[$x]['enabled'] = $rowhelper['enabled']; + $vhostarray_https[$x]['description'] = $rowhelper['description']; + } else { + $vhostarray_http[$x]['host'] = $rowhelper['host']; + $vhostarray_http[$x]['ipaddress'] = $rowhelper['ipaddress']; + $vhostarray_http[$x]['port'] = $rowhelper['port']; + $vhostarray_http[$x]['directory'] = $rowhelper['directory']; + $vhostarray_http[$x]['certificate'] = ''; + $vhostarray_http[$x]['privatekey'] = ''; + $vhostarray_http[$x]['enabled'] = $rowhelper['enabled']; + $vhostarray_http[$x]['description'] = $rowhelper['description']; + $server_port = $rowhelper['port']; } + $x++; } - unset($x); + } + unset($x); - //HTTP configuration + // HTTP configuration if (count($vhostarray_http) > 0) { - $tmp = "#\n"; - $tmp .= "# lighttpd configuration file\n"; - $tmp .= "#\n"; - $tmp .= "# use a it as base for lighttpd 1.0.0 and above\n"; - $tmp .= "#\n"; - $tmp .= "############ Options you really have to take care of ####################\n"; - $tmp .= "\n"; - $tmp .= "## FreeBSD!\n"; - $tmp .= "server.event-handler = \"freebsd-kqueue\"\n"; - $tmp .= "server.network-backend = \"writev\" ## Fixes 7.x upload issues\n"; - $tmp .= "\n"; - $tmp .= "## modules to load\n"; - $tmp .= "server.modules = (\n"; - $tmp .= " \"mod_access\", \"mod_accesslog\",\n"; - $tmp .= " \"mod_fastcgi\", \"mod_cgi\",\"mod_rewrite\"\n"; - $tmp .= " )\n"; - $tmp .= "\n"; - $tmp .= "## Unused modules\n"; - $tmp .= "# \"mod_setenv\",\n"; - $tmp .= "# \"mod_compress\"\n"; - $tmp .= "# \"mod_redirect\",\n"; - $tmp .= "# \"mod_rewrite\",\n"; - $tmp .= "# \"mod_ssi\",\n"; - $tmp .= "# \"mod_usertrack\",\n"; - $tmp .= "# \"mod_expire\",\n"; - $tmp .= "# \"mod_secdownload\",\n"; - $tmp .= "# \"mod_rrdtool\",\n"; - $tmp .= "# \"mod_auth\",\n"; - $tmp .= "# \"mod_status\",\n"; - $tmp .= "# \"mod_alias\",\n"; - $tmp .= "# \"mod_proxy\",\n"; - $tmp .= "# \"mod_simple_vhost\",\n"; - $tmp .= "# \"mod_evhost\",\n"; - $tmp .= "# \"mod_userdir\",\n"; - $tmp .= "# \"mod_cgi\",\n"; - $tmp .= "# \"mod_accesslog\"\n"; - $tmp .= "\n"; - $tmp .= "## a static document-root, for virtual-hosting take look at the\n"; - $tmp .= "## server.virtual-* options\n"; - $tmp .= "server.document-root = \"/usr/local/vhosts/\"\n"; - $tmp .= "\n"; - $tmp .= "# Maximum idle time with nothing being written (php downloading)\n"; - $tmp .= "server.max-write-idle = 999\n"; - $tmp .= "\n"; - $tmp .= "## where to send error-messages to\n"; - $tmp .= "server.errorlog = \"/var/log/lighttpd.error.log\"\n"; - $tmp .= "\n"; - $tmp .= "# files to check for if .../ is requested\n"; - $tmp .= "server.indexfiles = ( \"index.php\", \"index.html\",\n"; - $tmp .= " \"index.htm\", \"default.htm\" )\n"; - $tmp .= "\n"; - $tmp .= "# mimetype mapping\n"; - $tmp .= "mimetype.assign = (\n"; - $tmp .= " \".pdf\" => \"application/pdf\",\n"; - $tmp .= " \".sig\" => \"application/pgp-signature\",\n"; - $tmp .= " \".spl\" => \"application/futuresplash\",\n"; - $tmp .= " \".class\" => \"application/octet-stream\",\n"; - $tmp .= " \".ps\" => \"application/postscript\",\n"; - $tmp .= " \".torrent\" => \"application/x-bittorrent\",\n"; - $tmp .= " \".dvi\" => \"application/x-dvi\",\n"; - $tmp .= " \".gz\" => \"application/x-gzip\",\n"; - $tmp .= " \".pac\" => \"application/x-ns-proxy-autoconfig\",\n"; - $tmp .= " \".swf\" => \"application/x-shockwave-flash\",\n"; - $tmp .= " \".tar.gz\" => \"application/x-tgz\",\n"; - $tmp .= " \".tgz\" => \"application/x-tgz\",\n"; - $tmp .= " \".tar\" => \"application/x-tar\",\n"; - $tmp .= " \".zip\" => \"application/zip\",\n"; - $tmp .= " \".mp3\" => \"audio/mpeg\",\n"; - $tmp .= " \".m3u\" => \"audio/x-mpegurl\",\n"; - $tmp .= " \".wma\" => \"audio/x-ms-wma\",\n"; - $tmp .= " \".wax\" => \"audio/x-ms-wax\",\n"; - $tmp .= " \".ogg\" => \"audio/x-wav\",\n"; - $tmp .= " \".wav\" => \"audio/x-wav\",\n"; - $tmp .= " \".gif\" => \"image/gif\",\n"; - $tmp .= " \".jpg\" => \"image/jpeg\",\n"; - $tmp .= " \".jpeg\" => \"image/jpeg\",\n"; - $tmp .= " \".png\" => \"image/png\",\n"; - $tmp .= " \".xbm\" => \"image/x-xbitmap\",\n"; - $tmp .= " \".xpm\" => \"image/x-xpixmap\",\n"; - $tmp .= " \".xwd\" => \"image/x-xwindowdump\",\n"; - $tmp .= " \".css\" => \"text/css\",\n"; - $tmp .= " \".html\" => \"text/html\",\n"; - $tmp .= " \".htm\" => \"text/html\",\n"; - $tmp .= " \".js\" => \"text/javascript\",\n"; - $tmp .= " \".asc\" => \"text/plain\",\n"; - $tmp .= " \".c\" => \"text/plain\",\n"; - $tmp .= " \".conf\" => \"text/plain\",\n"; - $tmp .= " \".text\" => \"text/plain\",\n"; - $tmp .= " \".txt\" => \"text/plain\",\n"; - $tmp .= " \".dtd\" => \"text/xml\",\n"; - $tmp .= " \".xml\" => \"text/xml\",\n"; - $tmp .= " \".mpeg\" => \"video/mpeg\",\n"; - $tmp .= " \".mpg\" => \"video/mpeg\",\n"; - $tmp .= " \".mov\" => \"video/quicktime\",\n"; - $tmp .= " \".qt\" => \"video/quicktime\",\n"; - $tmp .= " \".avi\" => \"video/x-msvideo\",\n"; - $tmp .= " \".asf\" => \"video/x-ms-asf\",\n"; - $tmp .= " \".asx\" => \"video/x-ms-asf\",\n"; - $tmp .= " \".wmv\" => \"video/x-ms-wmv\",\n"; - $tmp .= " \".bz2\" => \"application/x-bzip\",\n"; - $tmp .= " \".tbz\" => \"application/x-bzip-compressed-tar\",\n"; - $tmp .= " \".tar.bz2\" => \"application/x-bzip-compressed-tar\"\n"; - $tmp .= " )\n"; - $tmp .= "\n"; - $tmp .= "# Use the \"Content-Type\" extended attribute to obtain mime type if possible\n"; - $tmp .= "#mimetypes.use-xattr = \"enable\"\n"; - $tmp .= "\n"; - $tmp .= "#### accesslog module\n"; - $tmp .= "#accesslog.filename = \"/dev/null\"\n"; - $tmp .= "\n"; - $tmp .= "## deny access the file-extensions\n"; - $tmp .= "#\n"; - $tmp .= "# ~ is for backupfiles from vi, emacs, joe, ...\n"; - $tmp .= "# .inc is often used for code includes which should in general not be part\n"; - $tmp .= "# of the document-root\n"; - $tmp .= "url.access-deny = ( \"~\", \".db\" )\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= "######### Options that are good to be but not neccesary to be changed #######\n"; - $tmp .= "\n"; - $tmp .= "## bind to port (default: 80)\n"; - $tmp .= "server.port = $server_port\n"; - $tmp .= "\n"; - $tmp .= "#the regex method isn't working\n"; - $tmp .= "#\$HTTP[\"host\"] =~ \"(^|\\.)host01\\.com\$\" {\n"; - $tmp .= "# server.document-root = \"/usr/local/vhosts/host01\"\n"; - $tmp .= "#}\n"; - $tmp .= "\n"; + $tmp = <<<EOF +# +# lighttpd configuration file +# +# use a it as base for lighttpd 1.0.0 and above +# +############ Options you really have to take care of #################### + +## FreeBSD! +server.event-handler = "freebsd-kqueue" +server.network-backend = "writev" ## Fixes 7.x upload issues + +## modules to load +server.modules = ( + "mod_access", "mod_accesslog", + "mod_fastcgi", "mod_cgi","mod_rewrite" + ) + +## Unused modules +# "mod_setenv", +# "mod_compress" +# "mod_redirect", +# "mod_rewrite", +# "mod_ssi", +# "mod_usertrack", +# "mod_expire", +# "mod_secdownload", +# "mod_rrdtool", +# "mod_auth", +# "mod_status", +# "mod_alias", +# "mod_proxy", +# "mod_simple_vhost", +# "mod_evhost", +# "mod_userdir", +# "mod_cgi", +# "mod_accesslog" + +## a static document-root, for virtual-hosting take look at the +## server.virtual-* options +server.document-root = "/usr/local/vhosts/" + +# Maximum idle time with nothing being written (php downloading) +server.max-write-idle = 999 + +## where to send error-messages to +server.errorlog = "/var/log/lighttpd.error.log" + +# files to check for if .../ is requested +server.indexfiles = ( "index.php", "index.html", + "index.htm", "default.htm" ) + +# mimetype mapping +mimetype.assign = ( + ".pdf" => "application/pdf", + ".sig" => "application/pgp-signature", + ".spl" => "application/futuresplash", + ".class" => "application/octet-stream", + ".ps" => "application/postscript", + ".torrent" => "application/x-bittorrent", + ".dvi" => "application/x-dvi", + ".gz" => "application/x-gzip", + ".pac" => "application/x-ns-proxy-autoconfig", + ".swf" => "application/x-shockwave-flash", + ".tar.gz" => "application/x-tgz", + ".tgz" => "application/x-tgz", + ".tar" => "application/x-tar", + ".zip" => "application/zip", + ".mp3" => "audio/mpeg", + ".m3u" => "audio/x-mpegurl", + ".wma" => "audio/x-ms-wma", + ".wax" => "audio/x-ms-wax", + ".ogg" => "audio/x-wav", + ".wav" => "audio/x-wav", + ".gif" => "image/gif", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".png" => "image/png", + ".xbm" => "image/x-xbitmap", + ".xpm" => "image/x-xpixmap", + ".xwd" => "image/x-xwindowdump", + ".css" => "text/css", + ".html" => "text/html", + ".htm" => "text/html", + ".js" => "text/javascript", + ".asc" => "text/plain", + ".c" => "text/plain", + ".conf" => "text/plain", + ".text" => "text/plain", + ".txt" => "text/plain", + ".dtd" => "text/xml", + ".xml" => "text/xml", + ".mpeg" => "video/mpeg", + ".mpg" => "video/mpeg", + ".mov" => "video/quicktime", + ".qt" => "video/quicktime", + ".avi" => "video/x-msvideo", + ".asf" => "video/x-ms-asf", + ".asx" => "video/x-ms-asf", + ".wmv" => "video/x-ms-wmv", + ".bz2" => "application/x-bzip", + ".tbz" => "application/x-bzip-compressed-tar", + ".tar.bz2" => "application/x-bzip-compressed-tar" + ) + +# Use the "Content-Type" extended attribute to obtain mime type if possible +#mimetypes.use-xattr = "enable" + +#### accesslog module +#accesslog.filename = "/dev/null" + +## deny access the file-extensions +# +# ~ is for backupfiles from vi, emacs, joe, ... +# .inc is often used for code includes which should in general not be part +# of the document-root +url.access-deny = ( "~", ".db" ) + + +######### Options that are good to be but not neccesary to be changed ####### + +## bind to port (default: 80) +server.port = {$server_port} + +EOF; $ipaddress_previous_value = ''; $host_previous_value = ''; $port_previous_value = ''; $ipaddress_and_port_previous_value = ''; - $x=1; - foreach($vhostarray_http as $rowhelper) { - if ($rowhelper['enabled'] != "false") { + $x = 1; + foreach ($vhostarray_http as $rowhelper) { + if ($rowhelper['enabled'] != "false") { $host = $rowhelper['host']; $ipaddress = $rowhelper['ipaddress']; $port = $rowhelper['port']; @@ -297,43 +249,47 @@ function vhosts_sync_package_php() $privatekey = base64_decode($rowhelper['privatekey']); } - //set directory default to the host - if (strlen($directory) == 0) { $directory = $host; } + // Set directory default to the host + if (strlen($directory) == 0) { + $directory = $host; + } - //if the vhost directory doesn't exist then create it - //echo '/usr/local/vhosts/'.$directory.'<br />'; - if (!is_dir('/usr/local/vhosts/'.$directory)) { - exec("mkdir /usr/local/vhosts/".$directory); - } - if (!file_exists('/usr/local/vhosts/'.$directory.'/index.php')) { - $index_file = '/usr/local/vhosts/'.$directory.'/index.php'; - $index_tmp = "<?php\n"; - $index_tmp .= " echo phpinfo();\n"; - $index_tmp .= "?>\n"; - $fout = fopen($index_file,"w"); - fwrite($fout, $index_tmp); - fclose($fout); - unset($index_file); - } + // If the vhost directory doesn't exist then create it + safe_mkdir("/usr/local/vhosts/{$directory}"); - //set the default port - if (strlen($port) == 0) { $port = '8001'; } + if (!file_exists("/usr/local/vhosts/{$directory}/index.php")) { + $index_file = "/usr/local/vhosts/{$directory}/index.php"; + $index_tmp = "<?php\n"; + $index_tmp .= " echo phpinfo();\n"; + $index_tmp .= "?>\n"; + $fout = fopen($index_file, "w"); + fwrite($fout, $index_tmp); + fclose($fout); + unset($index_file); + } - if ($ipaddress.':'.$port != $ipaddress_and_port_previous_value) { - if ($x > 1) { $tmp .= "}\n\n"; } - $tmp .= "\$SERVER[\"socket\"] == \"".$ipaddress.":".$port."\" {\n"; + // Set the default port + if (strlen($port) == 0) { + $port = '8001'; } - $tmp .= " \$HTTP[\"host\"] == \"".$host."\" {\n"; - $tmp .= " server.document-root = \"/usr/local/vhosts/".$directory."\"\n"; + if ($ipaddress . ':' . $port != $ipaddress_and_port_previous_value) { + if ($x > 1) { + $tmp .= "}\n\n"; + } + $tmp .= "\$SERVER[\"socket\"] == \"" . $ipaddress . ":" . $port . "\" {\n"; + } - //enable ssl if the cert and key were both provided + $tmp .= " \$HTTP[\"host\"] == \"" . $host . "\" {\n"; + $tmp .= " server.document-root = \"/usr/local/vhosts/" . $directory . "\"\n"; + + // Enable SSL if the cert and key were both provided if (strlen($rowhelper['certificate']) > 0 && strlen($rowhelper['privatekey']) > 0) { - $pem_file = "/var/etc/cert-vhosts-".$ipaddress."-".$port.".pem"; - $fout = fopen($pem_file,"w"); + $pem_file = "/var/etc/cert-vhosts-{$ipaddress}-{$port}.pem"; + $fout = fopen($pem_file, "w"); fwrite($fout, $certificate.PHP_EOL.$privatekey); fclose($fout); - $tmp .= " ssl.pemfile = \"".$pem_file."\"\n"; + $tmp .= " ssl.pemfile = \"" . $pem_file . "\"\n"; $tmp .= " ssl.engine = \"enable\"\n"; unset($pem_file); } @@ -348,94 +304,58 @@ function vhosts_sync_package_php() $x++; } } - $tmp .= "}\n"; - - - /* - $tmp .= "\$SERVER[\"socket\"] == \"10.7.0.1:8001\" {\n"; - $tmp .= " \$HTTP[\"host\"] == \"vhost01.com\" {\n"; - $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n"; - $tmp .= " #ssl.engine = \"enable\"\n"; - $tmp .= " server.document-root = \"/usr/local/vhosts/host01\"\n"; - $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n"; - $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n"; - $tmp .= " #server.error-handler-404 = \"/e404.php\"\n"; - $tmp .= " }\n"; - $tmp .= "\n"; - $tmp .= " \$HTTP[\"host\"] == \"vhost03.com\" {\n"; - $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n"; - $tmp .= " #ssl.engine = \"enable\"\n"; - $tmp .= " server.document-root = \"/usr/local/vhosts/host03\"\n"; - $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n"; - $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n"; - $tmp .= " #server.error-handler-404 = \"/e404.php\"\n"; - $tmp .= " }\n"; - $tmp .= "}\n"; - $tmp .= "\n"; - $tmp .= "\$SERVER[\"socket\"] == \"10.7.0.1:8002\" {\n"; - $tmp .= " \$HTTP[\"host\"] == \"vhost02.com\" {\n"; - $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n"; - $tmp .= " #ssl.engine = \"enable\"\n"; - $tmp .= " server.document-root = \"/usr/local/vhosts/host02\"\n"; - $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n"; - $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n"; - $tmp .= " #server.error-handler-404 = \"/e404.php\"\n"; - $tmp .= " }\n"; - $tmp .= "}\n"; - */ - $tmp .= "\n"; - $tmp .= "## error-handler for status 404\n"; - $tmp .= "#server.error-handler-404 = \"/error-handler.html\"\n"; - $tmp .= "#server.error-handler-404 = \"/error-handler.php\"\n"; - $tmp .= "\n"; - $tmp .= "## to help the rc.scripts\n"; - $tmp .= "server.pid-file = \"/var/run/vhosts-http.pid\"\n"; - $tmp .= "\n"; - $tmp .= "## virtual directory listings\n"; - $tmp .= "server.dir-listing = \"disable\"\n"; - $tmp .= "\n"; - $tmp .= "## enable debugging\n"; - $tmp .= "debug.log-request-header = \"disable\"\n"; - $tmp .= "debug.log-response-header = \"disable\"\n"; - $tmp .= "debug.log-request-handling = \"disable\"\n"; - $tmp .= "debug.log-file-not-found = \"disable\"\n"; - $tmp .= "\n"; - $tmp .= "#### compress module\n"; - $tmp .= "#compress.cache-dir = \"/tmp/lighttpd/cache/compress/\"\n"; - $tmp .= "#compress.filetype = (\"text/plain\", \"text/html\")\n"; - $tmp .= "\n"; - $tmp .= "#server.network-backend = \"writev\"\n"; - $tmp .= "server.upload-dirs = ( \"/root/\", \"/tmp/\", \"/var/\" )\n"; - $tmp .= "server.max-request-size = 2097152\n"; - $tmp .= "\n"; - $tmp .= "#### fastcgi module\n"; - $tmp .= "## read fastcgi.txt for more info\n"; - $tmp .= "fastcgi.server = ( \".php\" =>\n"; - $tmp .= " ( \"localhost\" =>\n"; - $tmp .= " (\n"; - $tmp .= " \"socket\" => \"/tmp/php5-fastcgi.socket\",\n"; - $tmp .= " \"min-procs\" => 1,\n"; - $tmp .= " \"max-procs\" => 1,\n"; - $tmp .= " \"idle-timeout\" => 0,\n"; - $tmp .= " \"bin-environment\" => (\n"; - $tmp .= " \"PHP_FCGI_MAX_REQUESTS\" => \"500\",\n"; - $tmp .= " \"PHP_FCGI_CHILDREN\" => \"1\"\n"; - $tmp .= " ),\n"; - $tmp .= " \"bin-path\" => \"/usr/local/bin/php\"\n"; - $tmp .= " )\n"; - $tmp .= " )\n"; - $tmp .= ")\n"; - $tmp .= "\n"; - $tmp .= "#### CGI module\n"; - $tmp .= "cgi.assign = ( \".cgi\" => \"\" )\n"; - - $fout = fopen("/var/etc/vhosts-http.conf","w"); + + $tmp .= <<<EOF +} + +## error-handler for status 404 +#server.error-handler-404 = "/error-handler.html" +#server.error-handler-404 = "/error-handler.php" + +## to help the rc.scripts +server.pid-file = "/var/run/vhosts-http.pid" + +## virtual directory listings +server.dir-listing = "disable" + +## enable debugging +debug.log-request-header = "disable" +debug.log-response-header = "disable" +debug.log-request-handling = "disable" +debug.log-file-not-found = "disable" + +#### compress module +#compress.cache-dir = "/tmp/lighttpd/cache/compress/" +#compress.filetype = ("text/plain", "text/html") + +#server.network-backend = "writev" +server.upload-dirs = ( "/root/", "/tmp/", "/var/" ) +server.max-request-size = 2097152 + +#### fastcgi module +## read fastcgi.txt for more info +fastcgi.server = ( ".php" => + ( "localhost" => + ( + "socket" => "/var/run/php-fpm.socket", + "broken-scriptfilename" => "enable" + ) + ) +) + +#### CGI module +cgi.assign = ( ".cgi" => "" ) + +EOF; + + $fout = fopen("/var/etc/vhosts-http.conf", "w"); fwrite($fout, $tmp); unset($tmp); fclose($fout); - } //end (if count(vhostarray_http) > 0) + // END (if count(vhostarray_http) > 0) + } - //HTTPS configuration + // HTTPS configuration $ipaddress_previous_value = ''; $host_previous_value = ''; $port_previous_value = ''; @@ -456,330 +376,255 @@ function vhosts_sync_package_php() $privatekey = base64_decode($rowhelper['privatekey']); } - //set directory default to the host - if (strlen($directory) == 0) { $directory = $host; } + // Set directory default to the host + if (strlen($directory) == 0) { + $directory = $host; + } - //if the vhost directory doesn't exist then create it - //echo '/usr/local/vhosts/'.$directory.'<br />'; - if (!is_dir('/usr/local/vhosts/'.$directory)) { - exec("mkdir /usr/local/vhosts/".$directory); - } - if (!file_exists('/usr/local/vhosts/'.$directory.'/index.php')) { - $index_file = '/usr/local/vhosts/'.$directory.'/index.php'; - $index_tmp = "<?php\n"; - $index_tmp .= " echo phpinfo();\n"; - $index_tmp .= "?>\n"; - $fout = fopen($index_file,"w"); - fwrite($fout, $index_tmp); - fclose($fout); - unset($index_file); - } + // If the vhost directory doesn't exist then create it + safe_mkdir("/usr/local/vhosts/{$directory}"); - //set the default port - if (strlen($port) == 0) { $port = '443'; } - - $tmp = "#\n"; - $tmp .= "# lighttpd configuration file\n"; - $tmp .= "#\n"; - $tmp .= "# use a it as base for lighttpd 1.0.0 and above\n"; - $tmp .= "#\n"; - $tmp .= "############ Options you really have to take care of ####################\n"; - $tmp .= "\n"; - $tmp .= "## FreeBSD!\n"; - $tmp .= "server.event-handler = \"freebsd-kqueue\"\n"; - $tmp .= "server.network-backend = \"writev\" ## Fixes 7.x upload issues\n"; - $tmp .= "\n"; - $tmp .= "## modules to load\n"; - $tmp .= "server.modules = (\n"; - $tmp .= " \"mod_access\", \"mod_accesslog\",\n"; - $tmp .= " \"mod_fastcgi\", \"mod_cgi\",\"mod_rewrite\"\n"; - $tmp .= " )\n"; - $tmp .= "\n"; - $tmp .= "## Unused modules\n"; - $tmp .= "# \"mod_setenv\",\n"; - $tmp .= "# \"mod_compress\"\n"; - $tmp .= "# \"mod_redirect\",\n"; - $tmp .= "# \"mod_rewrite\",\n"; - $tmp .= "# \"mod_ssi\",\n"; - $tmp .= "# \"mod_usertrack\",\n"; - $tmp .= "# \"mod_expire\",\n"; - $tmp .= "# \"mod_secdownload\",\n"; - $tmp .= "# \"mod_rrdtool\",\n"; - $tmp .= "# \"mod_auth\",\n"; - $tmp .= "# \"mod_status\",\n"; - $tmp .= "# \"mod_alias\",\n"; - $tmp .= "# \"mod_proxy\",\n"; - $tmp .= "# \"mod_simple_vhost\",\n"; - $tmp .= "# \"mod_evhost\",\n"; - $tmp .= "# \"mod_userdir\",\n"; - $tmp .= "# \"mod_cgi\",\n"; - $tmp .= "# \"mod_accesslog\"\n"; - $tmp .= "\n"; - $tmp .= "## a static document-root, for virtual-hosting take look at the\n"; - $tmp .= "## server.virtual-* options\n"; - $tmp .= "\n"; - $tmp .= "## ".$description." \n\n"; - $tmp .= "server.document-root = \"/usr/local/vhosts/".$directory."\"\n"; - - $tmp .= "\n"; - $tmp .= "# Maximum idle time with nothing being written (php downloading)\n"; - $tmp .= "server.max-write-idle = 999\n"; - $tmp .= "\n"; - $tmp .= "## where to send error-messages to\n"; - $tmp .= "server.errorlog = \"/var/log/lighttpd.error.log\"\n"; - $tmp .= "\n"; - $tmp .= "# files to check for if .../ is requested\n"; - $tmp .= "server.indexfiles = ( \"index.php\", \"index.html\",\n"; - $tmp .= " \"index.htm\", \"default.htm\" )\n"; - $tmp .= "\n"; - $tmp .= "# mimetype mapping\n"; - $tmp .= "mimetype.assign = (\n"; - $tmp .= " \".pdf\" => \"application/pdf\",\n"; - $tmp .= " \".sig\" => \"application/pgp-signature\",\n"; - $tmp .= " \".spl\" => \"application/futuresplash\",\n"; - $tmp .= " \".class\" => \"application/octet-stream\",\n"; - $tmp .= " \".ps\" => \"application/postscript\",\n"; - $tmp .= " \".torrent\" => \"application/x-bittorrent\",\n"; - $tmp .= " \".dvi\" => \"application/x-dvi\",\n"; - $tmp .= " \".gz\" => \"application/x-gzip\",\n"; - $tmp .= " \".pac\" => \"application/x-ns-proxy-autoconfig\",\n"; - $tmp .= " \".swf\" => \"application/x-shockwave-flash\",\n"; - $tmp .= " \".tar.gz\" => \"application/x-tgz\",\n"; - $tmp .= " \".tgz\" => \"application/x-tgz\",\n"; - $tmp .= " \".tar\" => \"application/x-tar\",\n"; - $tmp .= " \".zip\" => \"application/zip\",\n"; - $tmp .= " \".mp3\" => \"audio/mpeg\",\n"; - $tmp .= " \".m3u\" => \"audio/x-mpegurl\",\n"; - $tmp .= " \".wma\" => \"audio/x-ms-wma\",\n"; - $tmp .= " \".wax\" => \"audio/x-ms-wax\",\n"; - $tmp .= " \".ogg\" => \"audio/x-wav\",\n"; - $tmp .= " \".wav\" => \"audio/x-wav\",\n"; - $tmp .= " \".gif\" => \"image/gif\",\n"; - $tmp .= " \".jpg\" => \"image/jpeg\",\n"; - $tmp .= " \".jpeg\" => \"image/jpeg\",\n"; - $tmp .= " \".png\" => \"image/png\",\n"; - $tmp .= " \".xbm\" => \"image/x-xbitmap\",\n"; - $tmp .= " \".xpm\" => \"image/x-xpixmap\",\n"; - $tmp .= " \".xwd\" => \"image/x-xwindowdump\",\n"; - $tmp .= " \".css\" => \"text/css\",\n"; - $tmp .= " \".html\" => \"text/html\",\n"; - $tmp .= " \".htm\" => \"text/html\",\n"; - $tmp .= " \".js\" => \"text/javascript\",\n"; - $tmp .= " \".asc\" => \"text/plain\",\n"; - $tmp .= " \".c\" => \"text/plain\",\n"; - $tmp .= " \".conf\" => \"text/plain\",\n"; - $tmp .= " \".text\" => \"text/plain\",\n"; - $tmp .= " \".txt\" => \"text/plain\",\n"; - $tmp .= " \".dtd\" => \"text/xml\",\n"; - $tmp .= " \".xml\" => \"text/xml\",\n"; - $tmp .= " \".mpeg\" => \"video/mpeg\",\n"; - $tmp .= " \".mpg\" => \"video/mpeg\",\n"; - $tmp .= " \".mov\" => \"video/quicktime\",\n"; - $tmp .= " \".qt\" => \"video/quicktime\",\n"; - $tmp .= " \".avi\" => \"video/x-msvideo\",\n"; - $tmp .= " \".asf\" => \"video/x-ms-asf\",\n"; - $tmp .= " \".asx\" => \"video/x-ms-asf\",\n"; - $tmp .= " \".wmv\" => \"video/x-ms-wmv\",\n"; - $tmp .= " \".bz2\" => \"application/x-bzip\",\n"; - $tmp .= " \".tbz\" => \"application/x-bzip-compressed-tar\",\n"; - $tmp .= " \".tar.bz2\" => \"application/x-bzip-compressed-tar\"\n"; - $tmp .= " )\n"; - $tmp .= "\n"; - $tmp .= "# Use the \"Content-Type\" extended attribute to obtain mime type if possible\n"; - $tmp .= "#mimetypes.use-xattr = \"enable\"\n"; - $tmp .= "\n"; - $tmp .= "#### accesslog module\n"; - $tmp .= "#accesslog.filename = \"/dev/null\"\n"; - $tmp .= "\n"; - $tmp .= "## deny access the file-extensions\n"; - $tmp .= "#\n"; - $tmp .= "# ~ is for backupfiles from vi, emacs, joe, ...\n"; - $tmp .= "# .inc is often used for code includes which should in general not be part\n"; - $tmp .= "# of the document-root\n"; - $tmp .= "url.access-deny = ( \"~\", \".db\" )\n"; - $tmp .= "\n"; - $tmp .= "\n"; - $tmp .= "######### Options that are good to be but not neccesary to be changed #######\n"; - $tmp .= "\n"; - $tmp .= "## bind to port (default: 80)\n"; - $tmp .= "server.port = ".$port."\n"; - $tmp .= "\n"; - $tmp .= "#the regex method isn't working\n"; - $tmp .= "#\$HTTP[\"host\"] =~ \"(^|\\.)host01\\.com\$\" {\n"; - $tmp .= "# server.document-root = \"/usr/local/vhosts/host01\"\n"; - $tmp .= "#}\n"; - $tmp .= "\n"; - - //enable ssl if the cert and key were both provided - $pem_file = "/var/etc/cert-vhosts-".$ipaddress."-".$port.".pem"; - $fout = fopen($pem_file,"w"); - //echo $certificate; //exit; - fwrite($fout, $certificate.PHP_EOL.$privatekey); + if (!file_exists("/usr/local/vhosts/{$directory}/index.php")) { + $index_file = "/usr/local/vhosts/{$directory}/index.php"; + $index_tmp = "<?php\n"; + $index_tmp .= " echo phpinfo();\n"; + $index_tmp .= "?>\n"; + $fout = fopen($index_file, "w"); + fwrite($fout, $index_tmp); fclose($fout); - $tmp .= "## ssl configuration\n"; - $tmp .= "ssl.pemfile = \"".$pem_file."\"\n"; - $tmp .= "ssl.engine = \"enable\"\n"; - unset($pem_file); + unset($index_file); + } - $tmp .= "\n"; - $tmp .= "## error-handler for status 404\n"; - $tmp .= "#server.error-handler-404 = \"/error-handler.html\"\n"; - $tmp .= "#server.error-handler-404 = \"/error-handler.php\"\n"; - $tmp .= "\n"; - $tmp .= "## to help the rc.scripts\n"; - $tmp .= "server.pid-file = \"/var/run/vhosts-".$ipaddress."-".$port."-ssl.pid\"\n"; - $tmp .= "\n"; - $tmp .= "## virtual directory listings\n"; - $tmp .= "server.dir-listing = \"disable\"\n"; - $tmp .= "\n"; - $tmp .= "## enable debugging\n"; - $tmp .= "debug.log-request-header = \"disable\"\n"; - $tmp .= "debug.log-response-header = \"disable\"\n"; - $tmp .= "debug.log-request-handling = \"disable\"\n"; - $tmp .= "debug.log-file-not-found = \"disable\"\n"; - $tmp .= "\n"; - $tmp .= "#### compress module\n"; - $tmp .= "#compress.cache-dir = \"/tmp/lighttpd/cache/compress/\"\n"; - $tmp .= "#compress.filetype = (\"text/plain\", \"text/html\")\n"; - $tmp .= "\n"; - $tmp .= "#server.network-backend = \"writev\"\n"; - $tmp .= "server.upload-dirs = ( \"/root/\", \"/tmp/\", \"/var/\" )\n"; - $tmp .= "server.max-request-size = 2097152\n"; - $tmp .= "\n"; - $tmp .= "#### fastcgi module\n"; - $tmp .= "## read fastcgi.txt for more info\n"; - $tmp .= "fastcgi.server = ( \".php\" =>\n"; - $tmp .= " ( \"localhost\" =>\n"; - $tmp .= " (\n"; - $tmp .= " \"socket\" => \"/tmp/php5-fastcgi.socket\",\n"; - $tmp .= " \"min-procs\" => 1,\n"; - $tmp .= " \"max-procs\" => 1,\n"; - $tmp .= " \"idle-timeout\" => 0,\n"; - $tmp .= " \"bin-environment\" => (\n"; - $tmp .= " \"PHP_FCGI_MAX_REQUESTS\" => \"500\",\n"; - $tmp .= " \"PHP_FCGI_CHILDREN\" => \"1\"\n"; - $tmp .= " ),\n"; - $tmp .= " \"bin-path\" => \"/usr/local/bin/php\"\n"; - $tmp .= " )\n"; - $tmp .= " )\n"; - $tmp .= ")\n"; - $tmp .= "\n"; - $tmp .= "#### CGI module\n"; - $tmp .= "cgi.assign = ( \".cgi\" => \"\" )\n"; - - $fout = fopen("/var/etc/vhosts-".$ipaddress."-".$port."-ssl.conf","w"); - fwrite($fout, $tmp); - unset($tmp); + // Set the default port + if (strlen($port) == 0) { + $port = '443'; + } + + $tmp =<<<EOF +# +# lighttpd configuration file +# +# use a it as base for lighttpd 1.0.0 and above +# +############ Options you really have to take care of #################### + +## FreeBSD! +server.event-handler = "freebsd-kqueue" +server.network-backend = "writev" ## Fixes 7.x upload issues + +## modules to load +server.modules = ( + "mod_access", "mod_accesslog", + "mod_fastcgi", "mod_cgi","mod_rewrite" + ) + +## Unused modules +# "mod_setenv", +# "mod_compress" +# "mod_redirect", +# "mod_rewrite", +# "mod_ssi", +# "mod_usertrack", +# "mod_expire", +# "mod_secdownload", +# "mod_rrdtool", +# "mod_auth", +# "mod_status", +# "mod_alias", +# "mod_proxy", +# "mod_simple_vhost", +# "mod_evhost", +# "mod_userdir", +# "mod_cgi", +# "mod_accesslog" + +## a static document-root, for virtual-hosting take look at the +## server.virtual-* options + +## + +server.document-root = "/usr/local/vhosts/" + +# Maximum idle time with nothing being written (php downloading) +server.max-write-idle = 999 + +## where to send error-messages to +server.errorlog = "/var/log/lighttpd.error.log" + +# files to check for if .../ is requested +server.indexfiles = ( "index.php", "index.html", + "index.htm", "default.htm" ) + +# mimetype mapping +mimetype.assign = ( + ".pdf" => "application/pdf", + ".sig" => "application/pgp-signature", + ".spl" => "application/futuresplash", + ".class" => "application/octet-stream", + ".ps" => "application/postscript", + ".torrent" => "application/x-bittorrent", + ".dvi" => "application/x-dvi", + ".gz" => "application/x-gzip", + ".pac" => "application/x-ns-proxy-autoconfig", + ".swf" => "application/x-shockwave-flash", + ".tar.gz" => "application/x-tgz", + ".tgz" => "application/x-tgz", + ".tar" => "application/x-tar", + ".zip" => "application/zip", + ".mp3" => "audio/mpeg", + ".m3u" => "audio/x-mpegurl", + ".wma" => "audio/x-ms-wma", + ".wax" => "audio/x-ms-wax", + ".ogg" => "audio/x-wav", + ".wav" => "audio/x-wav", + ".gif" => "image/gif", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".png" => "image/png", + ".xbm" => "image/x-xbitmap", + ".xpm" => "image/x-xpixmap", + ".xwd" => "image/x-xwindowdump", + ".css" => "text/css", + ".html" => "text/html", + ".htm" => "text/html", + ".js" => "text/javascript", + ".asc" => "text/plain", + ".c" => "text/plain", + ".conf" => "text/plain", + ".text" => "text/plain", + ".txt" => "text/plain", + ".dtd" => "text/xml", + ".xml" => "text/xml", + ".mpeg" => "video/mpeg", + ".mpg" => "video/mpeg", + ".mov" => "video/quicktime", + ".qt" => "video/quicktime", + ".avi" => "video/x-msvideo", + ".asf" => "video/x-ms-asf", + ".asx" => "video/x-ms-asf", + ".wmv" => "video/x-ms-wmv", + ".bz2" => "application/x-bzip", + ".tbz" => "application/x-bzip-compressed-tar", + ".tar.bz2" => "application/x-bzip-compressed-tar" + ) + +# Use the "Content-Type" extended attribute to obtain mime type if possible +#mimetypes.use-xattr = "enable" + +#### accesslog module +#accesslog.filename = "/dev/null" + +## deny access the file-extensions +# +# ~ is for backupfiles from vi, emacs, joe, ... +# .inc is often used for code includes which should in general not be part +# of the document-root +url.access-deny = ( "~", ".db" ) + + +######### Options that are good to be but not neccesary to be changed ####### + +## bind to port (default: 80) +server.port = {$port} + +EOF; + // Enable SSL if the cert and key were both provided + $pem_file = "/var/etc/cert-vhosts-{$ipaddress}-{$port}.pem"; + $fout = fopen($pem_file, "w"); + fwrite($fout, $certificate.PHP_EOL.$privatekey); fclose($fout); + $tmp .= "## ssl configuration\n"; + $tmp .= "ssl.pemfile = \"" . $pem_file . "\"\n"; + $tmp .= "ssl.engine = \"enable\"\n"; + unset($pem_file); - if (!function_exists('write_rcfile')) { require("/etc/inc/service-utils.inc"); } - write_rcfile(array( - "file" => "vhosts-".$ipaddress."-".$port."-ssl.sh", - "start" => "/usr/local/sbin/lighttpd -f /var/etc/vhosts-".$ipaddress."-".$port."-ssl.conf", - "stop" => "kill `cat /var/run/vhosts-".$ipaddress."-".$port."-ssl.pid`" - ) - ); - //add or update a service - $ent['name'] = "vhosts-ssl-$x"; - $ent['rcfile'] = "vhosts-".$ipaddress."-".$port."-ssl.sh"; - $ent['executable'] = "vhosts-".$ipaddress."-".$port."-ssl"; - $ent['description'] = "vHosts SSL, Host: $host, IP Address: ".$ipaddress.", port: ".$port." desc: ".$description; - $ent['custom_php_service_status_command'] = "\$vhost_output=''; exec('/bin/pgrep -anf '.".escapeshellarg($ent['executable']).", \$vhost_output, \$retval); \$rc=(intval(\$retval) == 0);"; - $a_service = $config['installedpackages']['service']; - $service_id = get_service_id ($a_service, 'name', "vhosts-ssl-$x"); - if (is_int($service_id)) { - //update - $a_service[$service_id] = $ent; - } - else { - //add - $a_service[] = $ent; - } + $tmp .= <<<EOF - } //if enabled - $x++; - } //end for each - } //end if array count - write_config(); - conf_mount_ro(); +## error-handler for status 404 +#server.error-handler-404 = "/error-handler.html" +#server.error-handler-404 = "/error-handler.php" - } -} +## to help the rc.scripts +server.pid-file = "/var/run/vhosts-{$ipaddress}-{$port}-ssl.pid" +## virtual directory listings +server.dir-listing = "disable" -function vhosts_sync_package() { - global $config; - vhosts_sync_package_php(); -} +## enable debugging +debug.log-request-header = "disable" +debug.log-response-header = "disable" +debug.log-request-handling = "disable" +debug.log-file-not-found = "disable" +#### compress module +#compress.cache-dir = "/tmp/lighttpd/cache/compress/" +#compress.filetype = ("text/plain", "text/html") -function vhosts_install_command() { +#server.network-backend = "writev" +server.upload-dirs = ( "/root/", "/tmp/", "/var/" ) +server.max-request-size = 2097152 - global $config; - conf_mount_rw(); - config_lock(); +#### fastcgi module +## read fastcgi.txt for more info +fastcgi.server = ( ".php" => + ( "localhost" => + ( + "socket" => "/var/run/php-fpm.socket", + "broken-scriptfilename" => "enable" + ) + ) +) - if (!is_dir('/usr/local/www/packages/')) { - exec("mkdir /usr/local/www/packages/"); - } +#### CGI module +cgi.assign = ( ".cgi" => "" ) - if (!is_dir('/usr/local/www/packages/vhosts/')) { - exec("mkdir /usr/local/www/packages/vhosts/"); - } +EOF; - if (!is_dir('/usr/local/vhosts/')) { - exec("mkdir /usr/local/vhosts/"); - } + $fout = fopen("/var/etc/vhosts-{$ipaddress}-{$port}-ssl.conf", "w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); - if(stristr(php_uname('r'), '7.2') == TRUE) { - if (!file_exists('/usr/local/php5')) { - chdir('/usr/local/'); - exec ("fetch https://files.pfsense.org/packages/7/vhosts/php5.tar.gz"); - exec("tar zxvf /usr/local/php5.tar.gz -C /usr/local/"); - exec("rm /usr/local/php5.tar.gz"); - } - if (!file_exists('/usr/local/lib/libxml2.so.5')) { - chdir('/usr/local/lib/'); - exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/libxml2.so.5"); - } - if (!file_exists('/usr/local/lib/libxml2.so')) { - chdir('/usr/local/lib/'); - exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/libxml2.so"); - } - if (!file_exists('/usr/local/lib/libxml2.la')) { - chdir('/usr/local/lib/'); - exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/libxml2.la"); - } - if (!file_exists('/usr/local/lib/libxml2.a')) { - chdir('/usr/local/lib/'); - exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/lib/libxml2.a"); - } - } - if(stristr(php_uname('r'), '8.1') == TRUE) { - if (!file_exists('/usr/local/php5')) { - chdir('/usr/local/'); - exec ("fetch https://files.pfsense.org/packages/8/vhosts/php5.tar.gz"); - exec("tar zxvf /usr/local/php5.tar.gz -C /usr/local/"); - exec("rm /usr/local/php5.tar.gz"); + write_rcfile(array( + "file" => "vhosts-{$ipaddress}-{$port}-ssl.sh", + "start" => "/usr/local/sbin/lighttpd -f /var/etc/vhosts-{$ipaddress}-{$port}-ssl.conf", + "stop" => "kill `cat /var/run/vhosts-{$ipaddress}-{$port}-ssl.pid`" + ) + ); + + // Add or update a service + $ent['name'] = "vhosts-ssl-{$x}"; + $ent['rcfile'] = "vhosts-{$ipaddress}-{$port}-ssl.sh"; + $ent['executable'] = "vhosts-{$ipaddress}-{$port}-ssl"; + $ent['description'] = "vHosts SSL, Host: {$host}, IP Address: {$ipaddress}, port: {$port}, desc: {$description}"; + $ent['custom_php_service_status_command'] = "\$vhost_output=''; exec('/bin/pgrep -anf '.".escapeshellarg($ent['executable']).", \$vhost_output, \$retval); \$rc=(intval(\$retval) == 0);"; + $a_service = $config['installedpackages']['service']; + $service_id = get_service_id ($a_service, 'name', "vhosts-ssl-{$x}"); + if (is_int($service_id)) { + // Update + $a_service[$service_id] = $ent; + } else { + // Add + $a_service[] = $ent; + } + // END if enabled + } + $x++; + // END foreach + } + // END if array count } + write_config(); + conf_mount_ro(); } +} - //rename PHP files from .tmp to .php - exec("cp /tmp/vhosts_php.tmp /usr/local/www/packages/vhosts/vhosts_php.php"); - unlink_if_exists("/tmp/vhosts_php.tmp"); - - exec("cp /tmp/vhosts_php_edit.tmp /usr/local/www/packages/vhosts/vhosts_php_edit.php"); - unlink_if_exists("/tmp/vhosts_php_edit.tmp"); - - chdir('/tmp/'); - exec ("fetch https://packages.pfsense.org/packages/config/vhosts/system_advanced_create_certs.tmp"); - exec("cp /tmp/system_advanced_create_certs.tmp /usr/local/www/packages/vhosts/system_advanced_create_certs.php"); - unlink_if_exists("/tmp/system_advanced_create_certs.tmp"); - - //write_config(); +function vhosts_install_command() { + global $config; + conf_mount_rw(); + safe_mkdir("/usr/local/vhosts/"); - if (!function_exists('write_rcfile')) { require("/etc/inc/service-utils.inc"); } write_rcfile(array( "file" => "vhosts-http.sh", "start" => "/usr/local/sbin/lighttpd -f /var/etc/vhosts-http.conf", @@ -788,32 +633,17 @@ function vhosts_install_command() { ); vhosts_sync_package(); - - //if (pkg_is_service_running('vhosts')) { - //documentation purposes - //} - - conf_mount_ro(); - config_unlock(); - } -function vhosts_deinstall_command() -{ +function vhosts_deinstall_command() { conf_mount_rw(); - config_lock(); - $handle = popen("/usr/local/etc/rc.d/vhosts.sh stop", "r"); - unlink_if_exists("/usr/local/pkg/vhosts.xml"); - unlink_if_exists("/usr/local/pkg/vhosts.inc"); - unlink_if_exists("/usr/local/www/vhosts.inc"); + stop_service("vhosts-http"); unlink_if_exists("/usr/local/etc/rc.d/vhosts-http.sh"); - exec ("rm /usr/local/etc/rc.d/vhosts*"); - exec ("rm /var/etc/vhosts*"); - exec("rm -R /usr/local/www/packages/vhosts"); - exec("rm -R /usr/local/php5"); + exec("/bin/rm -f /usr/local/etc/rc.d/vhosts*"); + exec("/bin/rm -f /var/etc/vhosts*"); + exec("/bin/rm -rf /usr/local/www/packages/vhosts"); conf_mount_ro(); - config_unlock(); } ?> diff --git a/config/vhosts/vhosts.xml b/config/vhosts/vhosts.xml index 91c50079..306ccc69 100644 --- a/config/vhosts/vhosts.xml +++ b/config/vhosts/vhosts.xml @@ -1,52 +1,54 @@ <?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> +<![CDATA[ /* $Id$ */ -/* ========================================================================== */ +/* ====================================================================================== */ /* - vhosts.xml - Copyright (C) 2008 Mark J Crane - All rights reserved. - */ -/* ========================================================================== */ + vhosts.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Mark J Crane + 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: + 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. + 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. - */ -/* ========================================================================== */ - ]]> - </copyright> + 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>vHosts</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> <name>vHosts Settings</name> - <version>0.7.3</version> - <title>Settings</title> + <version>0.8.0</version> + <title>vHosts Settings</title> <include_file>/usr/local/pkg/vhosts.inc</include_file> <menu> <name>vHosts</name> - <tooltiptext>vHosts Service settings.</tooltiptext> + <tooltiptext>vHosts Service Settings.</tooltiptext> <section>Services</section> <configfile>vhosts.xml</configfile> <url>/packages/vhosts/vhosts_php.php</url> @@ -55,67 +57,32 @@ <name>vhosts-http</name> <rcfile>vhosts-http.sh</rcfile> <executable>vhosts-http</executable> - <description>LigHTTPD web server service. Uses PHP5 with fast cgi.</description> + <description>lighttpd vHosts Web Server</description> </service> - <tabs> - <tab> - <text>Settings</text> - <url>/pkg_edit.php?xml=vhosts.xml&id=0</url> - <active/> - </tab> - <tab> - <text>Settings</text> - <url>/packages/vhosts_php.php</url> - <active/> - </tab> - </tabs> <configpath>installedpackages->package->$packagename->configuration->vhosts</configpath> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/vhosts/vhosts.xml</item> + <item>https://packages.pfsense.org/packages/config/vhosts/vhosts.inc</item> </additional_files_needed> <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/vhosts/vhosts.inc</item> + <prefix>/usr/local/www/packages/vhosts/</prefix> + <item>https://packages.pfsense.org/packages/config/vhosts/vhosts_php.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/vhosts/vhosts_php.tmp</item> + <prefix>/usr/local/www/packages/vhosts/</prefix> + <item>https://packages.pfsense.org/packages/config/vhosts/vhosts_php_edit.php</item> </additional_files_needed> <additional_files_needed> - <prefix>/tmp/</prefix> - <chmod>0755</chmod> - <item>https://packages.pfsense.org/packages/config/vhosts/vhosts_php_edit.tmp</item> + <prefix>/usr/local/www/packages/vhosts/</prefix> + <item>https://packages.pfsense.org/packages/config/vhosts/system_advanced_create_certs.php</item> </additional_files_needed> - <fields> - <field> - <fielddescr>Variable One</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - <field> - <fielddescr>Variable Two</fielddescr> - <fieldname>var1</fieldname> - <description>Enter the variable one here.</description> - <type>input</type> - </field> - </fields> - <custom_add_php_command> - </custom_add_php_command> <custom_php_resync_config_command> vhosts_sync_package(); </custom_php_resync_config_command> - <custom_delete_php_command> - vhosts_sync_package(); - </custom_delete_php_command> <custom_php_install_command> vhosts_install_command(); </custom_php_install_command> <custom_php_deinstall_command> vhosts_deinstall_command(); </custom_php_deinstall_command> -</packagegui>
\ No newline at end of file +</packagegui> diff --git a/config/vhosts/vhosts_php.tmp b/config/vhosts/vhosts_php.php index d2777dc9..cd973b5d 100644 --- a/config/vhosts/vhosts_php.tmp +++ b/config/vhosts/vhosts_php.php @@ -1,8 +1,9 @@ <?php -/* $Id$ */ /* vhosts_php.php + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,21 +27,18 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); require("/usr/local/pkg/vhosts.inc"); $a_vhosts = &$config['installedpackages']['vhosts']['config']; - +$pgtitle = "vHosts: Web Server"; include("head.inc"); ?> - <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> -<p class="pgtitle">vHosts: Web Server</p> <div id="mainlevel"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> @@ -56,35 +54,23 @@ include("head.inc"); </table> <table width="100%" border="0" cellpadding="0" cellspacing="0"> -<tr> -<td class="tabcont" > +<tr><td class="tabcont"> <form action="vhosts_php.php" method="post" name="iform" id="iform"> - <?php - + <?php if ($config_change == 1) { write_config(); - $config_change = 0; + $config_change = 0; } - - //if ($savemsg) print_info_box($savemsg); - //if (file_exists($d_hostsdirty_path)): echo"<p>"; - //print_info_box_np("This is an info box."); - //echo"<br />"; - //endif; - ?> - <table width="100%" border="0" cellpadding="6" cellspacing="0"> - <tr> - <td><p><!--<span class="vexpl"><span class="red"><strong>PHP Service<br></strong></span>--> - vHosts is a web server package that can host HTML, Javascript, CSS, and PHP. It creates another instance of the lighttpd web server - that is already installed. It uses PHP5 in FastCGI mode and has access to PHP Data Ojbects and PDO SQLite. To use SFTP enable SSH from - System -> Advanced -> Enable Secure Shell. Then SFTP can be used to access the files at /usr/local/vhosts. - After adding or updating an entry make sure to restart the <a href='/status_services.php'>service</a> to apply the settings. - <br /><br /> - For more information see: <a href='https://doc.pfsense.org/index.php/vhosts'>https://doc.pfsense.org/index.php/vhosts</a> - </p></td> - </tr> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr><td> + <div>vHosts is a web server package that can host HTML, Javascript, CSS, and PHP. It creates another instance of the lighttpd web server + that is already installed. It uses PHP5 in FastCGI mode and has access to PHP Data Ojbects and PDO SQLite. To use SFTP enable SSH from + System -> Advanced -> Enable Secure Shell. Then SFTP can be used to access the files at /usr/local/vhosts.<br /> + After adding or updating an entry make sure to restart the <a href='/status_services.php'>service</a> to apply the settings.<br /><br /> + </div> + </td></tr> </table> <br /> @@ -97,42 +83,49 @@ include("head.inc"); <td width="40%" class="listhdr">Description</td> <td width="10%" class="list"> <table border="0" cellspacing="0" cellpadding="1"> - <tr> + <tr> <td width="17"></td> - <td valign="middle"><a href="vhosts_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> - </tr> + <td valign="middle"><a href="vhosts_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" /></a></td> + </tr> </table> </td> </tr> - <?php + <?php $i = 0; if (count($a_vhosts) > 0) { - //sort array - if (!function_exists('sort_host')) { - function sort_host($a, $b){ - return strcmp($a["host"], $b["host"]); - } + // Sort array + if (!function_exists('sort_host')) { + function sort_host($a, $b) { + return strcmp($a["host"], $b["host"]); } - //disable for now because it throws off the edit and delete - //if (count($a_vhosts) > 1) { - // usort($a_vhosts, 'sort_host'); - //} + } + foreach ($a_vhosts as $ent) { $host = $ent['host']; $port = $ent['port']; - if (strlen($ent['certificate']) == 0) { $http_protocol = 'http'; } else { $http_protocol = 'https'; } - if ($http_protocol == 'http' && $port == '80') { $port = ''; } - if ($http_protocol == 'https' && $port == '443') { $port = ''; } - if (strlen($port) > 0) { $port = ':'.$port; } + if (strlen($ent['certificate']) == 0) { + $http_protocol = 'http'; + } else { + $http_protocol = 'https'; + } + if ($http_protocol == 'http' && $port == '80') { + $port = ''; + } + if ($http_protocol == 'https' && $port == '443') { + $port = ''; + } + if (strlen($port) > 0) { + $port = ':'.$port; + } $vhost_url = $http_protocol.'://'.$host.$port; - ?> + ?> <tr> <td class="listr" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';"> - <a href='<?=$vhost_url;?>' target='_blank'><?=$ent['host'];?></a> + <a href='<?=$vhost_url;?>'><?=$ent['host'];?></a> </td> <td class="listr" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';"> - <a href='<?=$vhost_url;?>' target='_blank'><?=$ent['port'];?></a> + <a href='<?=$vhost_url;?>'><?=$ent['port'];?></a> </td> <td class="listr" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';"> <div align='center'> @@ -150,30 +143,30 @@ include("head.inc"); <?php echo $ent['enabled']; ?> </td> <td class="listbg" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';"> - <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?> + <?=htmlspecialchars($ent['description']);?> </td> <td valign="middle" nowrap class="list"> - <table border="0" cellspacing="0" cellpadding="1"> + <table border="0" cellspacing="0" cellpadding="1"> <tr> - <td valign="middle"><a href="vhosts_php_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> - <td><a href="vhosts_php_edit.php?type=php&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + <td valign="middle"><a href="vhosts_php_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" /></a></td> + <td><a href="vhosts_php_edit.php?type=php&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" /></a></td> </tr> - </table> + </table> </td> - </tr> + </tr> <?php - $i++; + $i++; } } ?> <tr> <td class="list" colspan="5"></td> - <td class="list"> + <td class="list"> <table border="0" cellspacing="0" cellpadding="1"> <tr> <td width="17"></td> - <td valign="middle"><a href="vhosts_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + <td valign="middle"><a href="vhosts_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" /></a></td> </tr> </table> </td> @@ -186,24 +179,13 @@ include("head.inc"); </table> </form> + <br /> - - <br> - <br> - <br> - <br> - <br> - <br> - <br> - <br> - -</td> -</tr> +</td></tr> </table> </div> - <?php include("fend.inc"); ?> </body> </html> diff --git a/config/vhosts/vhosts_php_edit.php b/config/vhosts/vhosts_php_edit.php new file mode 100644 index 00000000..cb5a330f --- /dev/null +++ b/config/vhosts/vhosts_php_edit.php @@ -0,0 +1,299 @@ +<?php +/* + vhosts_php_edit.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2008 Mark J Crane + 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. +*/ +require("guiconfig.inc"); +require("/usr/local/pkg/vhosts.inc"); + +$a_vhosts = &$config['installedpackages']['vhosts']['config']; + +$id = $_GET['id']; +if (isset($_POST['id'])) { + $id = $_POST['id']; +} + +$a_vhosts = &$config['installedpackages']['vhosts']['config']; +$a_service = $config['installedpackages']['service']; + +if ($_GET['act'] == "del") { + if ($_GET['type'] == 'php') { + if ($a_vhosts[$_GET['id']]) { + // Get vhost info + $x = 0; + $y = 0; + foreach ($a_vhosts as $rowhelper) { + if (strlen($rowhelper['certificate']) > 0) { + $y++; + } + if ($_GET['id'] == $x) { + // Return the id + $id = $x; + $host = $rowhelper['host']; + $ipaddress = $rowhelper['ipaddress']; + $port = $rowhelper['port']; + $directory = $rowhelper['directory']; + if (strlen($rowhelper['certificate']) > 0) { + $ssl = true; + $ssl_id = $y; + } else { + $ssl = false; + } + } + $x++; + } + + // Delete vhosts entry + unset($a_vhosts[$_GET['id']]); + + // Delete the SSL files and service + if ($ssl) { + unlink_if_exists("/var/etc/vhosts-{$ipaddress}-{$port}-ssl.conf"); + unlink_if_exists("/var/etc/cert-vhosts-{$ipaddress}-{$port}.pem"); + unlink_if_exists("/usr/local/etc/rc.d/vhosts-{$ipaddress}-{$port}-ssl.sh"); + $service_id = get_service_id ($a_service, 'rcfile', "vhosts-{$ipaddress}-{$port}-ssl.sh"); + if (is_int($service_id)) { + exec("kill `cat /var/run/vhosts-{$ipaddress}-{$port}-ssl.pid`"); + unset($config['installedpackages']['service'][$service_id]); + } + } + + write_config(); + header("Location: vhosts_php.php"); + exit; + } + } +} + +if (isset($id) && $a_vhosts[$id]) { + $pconfig['host'] = $a_vhosts[$id]['host']; + $pconfig['ipaddress'] = $a_vhosts[$id]['ipaddress']; + $pconfig['port'] = $a_vhosts[$id]['port']; + $pconfig['directory'] = $a_vhosts[$id]['directory']; + if (strlen($a_vhosts[$id]['certificate']) > 0) { + $pconfig['certificate'] = base64_decode($a_vhosts[$id]['certificate']); + } + if (strlen($a_vhosts[$id]['privatekey']) > 0) { + $pconfig['privatekey'] = base64_decode($a_vhosts[$id]['privatekey']); + } + $pconfig['enabled'] = $a_vhosts[$id]['enabled']; + $pconfig['description'] = $a_vhosts[$id]['description']; +} + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + if (!$input_errors) { + + $ent = array(); + $ent['host'] = $_POST['host']; + $ent['ipaddress'] = $_POST['ipaddress']; + $ent['port'] = $_POST['port']; + $ent['directory'] = $_POST['directory']; + + if (strlen($_POST['certificate']) > 0) { + $ent['certificate'] = base64_encode($_POST['certificate']); + } else { + $ent['certificate'] = ''; + } + if (strlen($_POST['privatekey']) > 0) { + $ent['privatekey'] = base64_encode($_POST['privatekey']); + } else { + $ent['privatekey'] = ''; + } + $ent['enabled'] = $_POST['enabled']; + $ent['description'] = $_POST['description']; + + if (isset($id) && $a_vhosts[$id]) { + // Update + $a_vhosts[$id] = $ent; + } else { + // Add + $a_vhosts[] = $ent; + } + + write_config(); + vhosts_sync_package(); + + header("Location: vhosts_php.php"); + exit; + } +} + +$pgtitle = "vHosts: Edit"; +include("head.inc"); + +?> + +<script type="text/javascript"> +//<![CDATA[ +function show_advanced_config() { + document.getElementById("showadvancedbox").innerHTML=''; + aodiv = document.getElementById('showadvanced'); + aodiv.style.display = "block"; +} +//]]> +</script> +<script type="text/javascript"> +//<![CDATA[ +function openwindow(url) { + var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150"); + if (oWin==null || typeof(oWin)=="undefined") { + return false; + } else { + return true; + } +} +//]]> +</script> + +<body link="#0000CC" vlink="#000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> + +<div id="mainlevel"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabnavtbl"> +<?php + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), true, "/packages/vhosts/vhosts_php.php"); + display_top_tabs($tab_array); + +?> +</td></tr> +</table> + +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabcont" > + <br /> + <form action="vhosts_php_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq">Host</td> + <td width="78%" class="vtable"> + <input name="host" type="text" class="formfld" id="host" size="40" value="<?=htmlspecialchars($pconfig['host']);?>" /> + <br /> + Required. If the host is intended for internal you can use the DNS forwarder to set a host name that is valid inside the local network. default: vhost01.local + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">IP Address</td> + <td width="78%" class="vtable"> + <input name="ipaddress" type="text" class="formfld" id="ipaddress" size="40" value="<?=htmlspecialchars($pconfig['ipaddress']);?>" /> + <br /> + Required. Make sure the IP and Port combination does not conflict with the local system. example: 192.168.0.1 + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Port</td> + <td width="78%" class="vtable"> + <input name="port" type="text" class="formfld" id="port" size="40" value="<?=htmlspecialchars($pconfig['port']);?>" /> + <br /> + Make sure the IP and Port combination does not conflict with the local system. default: 8001 + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Directory</td> + <td width="78%" class="vtable"> + <input name="directory" type="text" class="formfld" id="directory" size="40" value="<?=htmlspecialchars($pconfig['directory']);?>" /> + <br /> + This vHosts directory is located in /usr/local/vhosts. The default directory is the host name. + <br /> + example: vhost01.local + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Certificate</td> + <td width="78%" class="vtable"> + <textarea name="certificate" cols="65" rows="7" id="certificate" class="formpre"><?=htmlspecialchars($pconfig['certificate']);?></textarea> + <br /> + Paste a signed certificate in X.509 PEM format here. <a href="javascript:if(openwindow('/packages/vhosts/system_advanced_create_certs.php') == false) alert('Popup blocker detected. Action aborted.');" >Create</a> certificates automatically. + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Key</td> + <td width="78%" class="vtable"> + <textarea name="privatekey" cols="65" rows="7" id="privatekey" class="formpre"><?=htmlspecialchars($pconfig['privatekey']);?></textarea> + <br /> + Paste an RSA private key in PEM format here. + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Enabled</td> + <td width="78%" class="vtable"> + <?php + echo "<select name='enabled' class='formfld'>\n"; + echo "\t<option></option>\n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo "\t<option value='true' selected='yes'>true</option>\n"; + echo "\t<option value='false'>false</option>\n"; + break; + case "false": + echo "\t<option value='true'>true</option>\n"; + echo "\t<option value='false' selected='yes'>false</option>\n"; + break; + default: + echo "\t<option value='true' selected='yes'>true</option>\n"; + echo "\t<option value='false'>false</option>\n"; + } + echo "</select>\n"; + ?> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncell">Description</td> + <td width="75%" class="vtable"> + <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>" /> + <br /><span class="vexpl">Enter the description here.<br /></span> + </td> + </tr> + <tr> + <td valign="top"> </td> + <td> + <input name="Submit" type="submit" class="formbtn" value="Save" /> <input class="formbtn" type="button" value="Cancel" onclick="history.back()" /> + <?php if (isset($id) && $a_vhosts[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + </table> + </form> + <br /> + +</td></tr> +</table> + +</div> + +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/vhosts/vhosts_php_edit.tmp b/config/vhosts/vhosts_php_edit.tmp deleted file mode 100644 index 8760686e..00000000 --- a/config/vhosts/vhosts_php_edit.tmp +++ /dev/null @@ -1,324 +0,0 @@ -<?php -/* $Id$ */ -/* - - vhosts_php_edit.php - Copyright (C) 2008 Mark J Crane - 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. -*/ - -require("guiconfig.inc"); -require("/usr/local/pkg/vhosts.inc"); - -$a_vhosts = &$config['installedpackages']['vhosts']['config']; - -$id = $_GET['id']; -if (isset($_POST['id'])) { - $id = $_POST['id']; -} - -$a_vhosts = &$config['installedpackages']['vhosts']['config']; -$a_service = $config['installedpackages']['service']; - -if ($_GET['act'] == "del") { - if ($_GET['type'] == 'php') { - if ($a_vhosts[$_GET['id']]) { - //get vhost info - $x = 0; - $y = 0; - foreach($a_vhosts as $rowhelper) { - if (strlen($rowhelper['certificate']) > 0) { - $y++; - } - if ($_GET['id'] == $x) { - $id = $x; //return the id - $host = $rowhelper['host']; - $ipaddress = $rowhelper['ipaddress']; - $port = $rowhelper['port']; - $directory = $rowhelper['directory']; - if (strlen($rowhelper['certificate']) > 0) { - $ssl = true; - $ssl_id = $y; - } - else { - $ssl = false; - } - } - - $x++; - } - - //delete vhosts entry - unset($a_vhosts[$_GET['id']]); - - //delete the SSL files and service - if ($ssl) { - unlink_if_exists("/var/etc/lighty-vhosts-".$ipaddress."-".$port."-ssl.conf"); - unlink_if_exists("/var/etc/cert-vhosts-".$ipaddress."-".$port.".pem"); - unlink_if_exists("/usr/local/etc/rc.d/vhosts-".$ipaddress."-".$port."-ssl.sh"); - $service_id = get_service_id ($a_service, 'rcfile', "vhosts-".$ipaddress."-".$port."-ssl.sh"); - if (is_int($service_id)) { - exec("kill `cat /var/run/lighty-vhosts-".$ipaddress."-".$port."-ssl.pid`"); - unset($config['installedpackages']['service'][$service_id]); - } - } - - write_config(); - header("Location: vhosts_php.php"); - exit; - } - } -} - -if (isset($id) && $a_vhosts[$id]) { - $pconfig['host'] = $a_vhosts[$id]['host']; - $pconfig['ipaddress'] = $a_vhosts[$id]['ipaddress']; - $pconfig['port'] = $a_vhosts[$id]['port']; - $pconfig['directory'] = $a_vhosts[$id]['directory']; - if (strlen($a_vhosts[$id]['certificate']) > 0) { - $pconfig['certificate'] = base64_decode($a_vhosts[$id]['certificate']); - } - if (strlen($a_vhosts[$id]['privatekey']) > 0) { - $pconfig['privatekey'] = base64_decode($a_vhosts[$id]['privatekey']); - } - $pconfig['enabled'] = $a_vhosts[$id]['enabled']; - $pconfig['description'] = $a_vhosts[$id]['description']; -} - -if ($_POST) { - - unset($input_errors); - $pconfig = $_POST; - - if (!$input_errors) { - - $ent = array(); - $ent['host'] = $_POST['host']; - $ent['ipaddress'] = $_POST['ipaddress']; - $ent['port'] = $_POST['port']; - $ent['directory'] = $_POST['directory']; - - if (strlen($_POST['certificate']) > 0) { - $ent['certificate'] = base64_encode($_POST['certificate']); - } - else { - $ent['certificate'] = ''; - } - if (strlen($_POST['privatekey']) > 0) { - $ent['privatekey'] = base64_encode($_POST['privatekey']); - } - else { - $ent['privatekey'] = ''; - } - $ent['enabled'] = $_POST['enabled']; - $ent['description'] = $_POST['description']; - - if (isset($id) && $a_vhosts[$id]) { - //update - $a_vhosts[$id] = $ent; - } - else { - //add - $a_vhosts[] = $ent; - } - - write_config(); - vhosts_sync_package(); - - header("Location: vhosts_php.php"); - exit; - } -} - -include("head.inc"); - -?> - -<script type="text/javascript" language="JavaScript"> - -function show_advanced_config() { - document.getElementById("showadvancedbox").innerHTML=''; - aodiv = document.getElementById('showadvanced'); - aodiv.style.display = "block"; -</script> -<script language="javascript"> - function openwindow(url) { - var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150"); - if (oWin==null || typeof(oWin)=="undefined") { - return false; - } else { - return true; - } - } -</script> -<body link="#0000CC" vlink="#000CC" alink="#0000CC"> -<?php include("fbegin.inc"); ?> -<p class="pgtitle">vHosts: Edit</p> -<?php if ($input_errors) print_input_errors($input_errors); ?> - - -<div id="mainlevel"> -<table width="100%" border="0" cellpadding="0" cellspacing="0"> -<tr><td class="tabnavtbl"> -<?php - - $tab_array = array(); - $tab_array[] = array(gettext("Settings"), true, "/packages/vhosts/vhosts_php.php"); - display_top_tabs($tab_array); - -?> -</td></tr> -</table> -<table width="100%" border="0" cellpadding="0" cellspacing="0"> -<tr> -<td class="tabcont" > - - <!-- - <table width="100%" border="0" cellpadding="6" cellspacing="0"> - <tr> - <td><p><span class="vexpl"><span class="red"><strong>PHP<br> - </strong></span> - </p></td> - </tr> - </table> - --> - <br /> - - <form action="vhosts_php_edit.php" method="post" name="iform" id="iform"> - <table width="100%" border="0" cellpadding="6" cellspacing="0"> - - <tr> - <td width="22%" valign="top" class="vncellreq">Host</td> - <td width="78%" class="vtable"> - <input name="host" type="text" class="formfld" id="host" size="40" value="<?=htmlspecialchars($pconfig['host']);?>"> - <br /> - Required. If the host is intended for internal you can use the DNS forwarder to set a host name that is valid inside the local network. default: vhost01.local - </td> - </tr> - - <tr> - <td width="22%" valign="top" class="vncellreq">IP Address</td> - <td width="78%" class="vtable"> - <input name="ipaddress" type="text" class="formfld" id="ipaddress" size="40" value="<?=htmlspecialchars($pconfig['ipaddress']);?>"> - <br /> - Required. Make sure the IP and Port combination does not conflict with the local system. example: 192.168.0.1 - </td> - </tr> - - <tr> - <td width="22%" valign="top" class="vncell">Port</td> - <td width="78%" class="vtable"> - <input name="port" type="text" class="formfld" id="port" size="40" value="<?=htmlspecialchars($pconfig['port']);?>"> - <br /> - Make sure the IP and Port combination does not conflict with the local system. default: 8001 - </td> - </tr> - - <tr> - <td width="22%" valign="top" class="vncell">Directory</td> - <td width="78%" class="vtable"> - <input name="directory" type="text" class="formfld" id="directory" size="40" value="<?=htmlspecialchars($pconfig['directory']);?>"> - <br /> - This vHosts directory is located in /usr/local/vhosts. The default directory is the host name. - <br /> - example: vhost01.local - </td> - </tr> - - <tr> - <td width="22%" valign="top" class="vncell">Certificate</td> - <td width="78%" class="vtable"> - <textarea name="certificate" cols="65" rows="7" id="certificate" class="formpre"><?=htmlspecialchars($pconfig['certificate']);?></textarea> - <br /> - Paste a signed certificate in X.509 PEM format here. <a href="javascript:if(openwindow('/packages/vhosts/system_advanced_create_certs.php') == false) alert('Popup blocker detected. Action aborted.');" >Create</a> certificates automatically. - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vncell">Key</td> - <td width="78%" class="vtable"> - <textarea name="privatekey" cols="65" rows="7" id="privatekey" class="formpre"><?=htmlspecialchars($pconfig['privatekey']);?></textarea> - <br /> - Paste an RSA private key in PEM format here. - </td> - </tr> - - <tr> - <td width="22%" valign="top" class="vncellreq">Enabled</td> - <td width="78%" class="vtable"> - <?php - echo " <select name='enabled' class='formfld'>\n"; - echo " <option></option>\n"; - switch (htmlspecialchars($pconfig['enabled'])) { - case "true": - echo " <option value='true' selected='yes'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - break; - case "false": - echo " <option value='true'>true</option>\n"; - echo " <option value='false' selected='yes'>false</option>\n"; - break; - default: - echo " <option value='true' selected='yes'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - } - echo " </select>\n"; - ?> - </td> - </tr> - <tr> - <td width="25%" valign="top" class="vncell">Description</td> - <td width="75%" class="vtable"> - <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>"> - <br><span class="vexpl">Enter the description here.<br></span> - </td> - </tr> - - <tr> - <td valign="top"> </td> - <td> - <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> - <?php if (isset($id) && $a_vhosts[$id]): ?> - <input name="id" type="hidden" value="<?=$id;?>"> - <?php endif; ?> - </td> - </tr> - </table> - </form> - - <br> - <br> - <br> - <br> - <br> - <br> - -</td> -</tr> -</table> - -</div> - -<?php include("fend.inc"); ?> -</body> -</html> diff --git a/config/vnstat/vnstat.inc b/config/vnstat/vnstat.inc deleted file mode 100644 index 90adbfbc..00000000 --- a/config/vnstat/vnstat.inc +++ /dev/null @@ -1,231 +0,0 @@ -<?php -function vnstat_install_deinstall() { - conf_mount_rw(); - global $config; -// Remove Vnstat package and files - exec("cd /var/db/pkg/ && pkg_delete `ls | grep vnstat`"); - exec("rm -d -R /usr/local/www/vnstat"); -// Remove vnstat cron entry from config.xml - $task_key = '/usr/local/bin/vnstat -u'; - $x_name=''; - $x=0; - foreach($config['cron']['item'] as $item) { - if($item['command']==$task_key) { - $x_name = $x; - } - $x++; - } - unset($x); - if($x_name > 0) - { - unset($config['cron']['item'][$x_name]); - write_config(); - } - configure_cron(); - conf_mount_ro(); -} - -function vnstat_install_config() { - global $config; - conf_mount_rw(); -// Unpack and move Vnstat frontend - exec("cd .."); - exec("tar -zxovf /usr/local/pkg/vnstat_php_frontend-1.4.1.tar.gz"); - exec("mv vnstat_php_frontend-1.4.1 /usr/local/www/vnstat"); -// Add cron job to config.xml - $cron_item = array(); - $cron_item['minute'] = "*/1"; - $cron_item['hour'] = "*"; - $cron_item['mday'] = "*"; - $cron_item['month'] = "*"; - $cron_item['wday'] = "*"; - $cron_item['who'] = "root"; - $cron_item['command'] = "/usr/local/bin/vnstat -u"; - $config['cron']['item'][] = $cron_item; -// get system nic's and create a database for them - $array_of_real_nic_names = array(); - $array_of_custom_nic_names = array(); - $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { - $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; - } - foreach ($ifdescrs as $ifdescr => $ifname): - $ifinfo = get_interface_info($ifdescr); - $real_nic_names = convert_friendly_interface_to_real_interface_name($ifname); - array_push($array_of_real_nic_names, $real_nic_names); - endforeach; - // Get already nic's assigned to vnstat - exec("ls /var/db/vnstat/ | grep -v '\.'", $vnstat_nic); - // Compare real nic's with nic's assigned to vnstat - $result = array_diff($array_of_real_nic_names, $vnstat_nic); - // Create database for each nic - foreach ($result as $result2) - { - exec("/usr/local/bin/vnstat -u -i ". $result2); - } -// Find information to be writing in config.php - // $iface_list_array_items - exec("ls /var/db/vnstat/ | grep -v '\.'", $vnstat_nic_in); - $iface_list_array_items = implode("', '", $vnstat_nic_in); - $iface_list_array = "\$iface_list = array('$iface_list_array_items');"; - // $iface_title_array_items - $iface_title_array_items = array(); - $iface_title_array_items2 = array(); - foreach ($vnstat_nic_in as $vnstat_nic_out) - { - $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { - $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; - } - foreach ($ifdescrs as $ifdescr => $ifname): - $real_nic_names3 = convert_friendly_interface_to_real_interface_name($ifname); - If ($real_nic_names3 == $vnstat_nic_out) - { - $ifname_out = $ifname; - $iface_title_array_items = "\$iface_title['$vnstat_nic_out'] = '$ifname_out';\n"; - array_push($iface_title_array_items2, $iface_title_array_items); - } - endforeach; - } - $iface_title_array = implode($iface_title_array_items2); - // php in php static items - $vnstat_bin2 = "\$vnstat_bin = '/usr/local/bin/vnstat';"; - $data_dir2 = "\$data_dir = './dumps';"; - $graph_format2 ="\$graph_format='svg';"; - $colorscheme2 = "\$colorscheme['light'] = array("; - $colorscheme3 = "\$colorscheme['red'] = array("; - $colorscheme4 = "\$colorscheme['pfSense'] = array("; - -// ************ Write new config.php ****************** - $config_file = <<<EOF -<?php - // - // vnStat PHP frontend 1.4.1 (c)2006-2008 Bjorge Dijkstra (bjd@jooz.net) - // - // This program is free software; you can redistribute it and/or modify - // it under the terms of the GNU General Public License as published by - // the Free Software Foundation; either version 2 of the License, or - // (at your option) any later version. - // - // This program is distributed in the hope that it will be useful, - // but WITHOUT ANY WARRANTY; without even the implied warranty of - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - // GNU General Public License for more details. - // - // You should have received a copy of the GNU General Public License - // along with this program; if not, write to the Free Software - // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - // - // - // see file COPYING or at http://www.gnu.org/licenses/gpl.html - // for more information. - // - error_reporting(E_ALL | E_NOTICE); - - // - // configuration parameters - // - // edit these to reflect your particular situation - // - - // list of network interfaces monitored by vnStat -$iface_list_array - - // - // optional names for interfaces - // if there's no name set for an interface then the interface identifier - // will be displayed instead -$iface_title_array - - // - // There are two possible sources for vnstat data. If the - // variable is set then vnstat is called directly from the PHP script - // to get the interface data. - // - // The other option is to periodically dump the vnstat interface data to - // a file (e.g. by a cronjob). In that case the variable - // must be cleared and set to the location where the dumps - // are stored. Dumps must be named 'vnstat_dump_'. - // - // You can generate vnstat dumps with the command: - // vnstat --dumpdb -i > /path/to/data_dir/vnstat_dump_ - // -$vnstat_bin2 -$data_dir2 - - // graphics format to use: svg or png -$graph_format2 - - // Font to use for PNG graphs - define('GRAPH_FONT',dirname(__FILE__).'/VeraBd.ttf'); - - // Font to use for SVG graphs - define('SVG_FONT', 'Verdana'); - - // color schemes - // colors are defined as R,G,B,ALPHA quads where R, G and B range from 0-255 - // and ALPHA from 0-127 where 0 is opaque and 127 completely transparent. - // - define('DEFAULT_COLORSCHEME', 'pfSense'); - - $colorscheme2 - 'stylesheet' => 'vnstat.css', - 'image_background' => array( 255, 255, 255, 0 ), - 'graph_background' => array( 220, 220, 230, 0 ), - 'graph_background_2' => array( 205, 205, 220, 0 ), - 'grid_stipple_1' => array( 140, 140, 140, 0 ), - 'grid_stipple_2' => array( 200, 200, 200, 0 ), - 'border' => array( 0, 0, 0, 0 ), - 'text' => array( 0, 0, 0, 0 ), - 'rx' => array( 190, 190, 20, 50 ), - 'rx_border' => array( 40, 80, 40, 90 ), - 'tx' => array( 130, 160, 100, 50 ), - 'tx_border' => array( 80, 40, 40, 90 ) - ); - - // A red colorscheme based on a contribution by Enrico Tröger - $colorscheme3 - 'stylesheet' => 'vnstat_red.css', - 'image_background' => array( 225, 225, 225, 0 ), - 'graph_background' => array( 220, 220, 230, 0 ), - 'graph_background_2' => array( 205, 205, 220, 0 ), - 'grid_stipple_1' => array( 140, 140, 140, 0 ), - 'grid_stipple_2' => array( 200, 200, 200, 0 ), - 'border' => array( 0, 0, 0, 0 ), - 'text' => array( 0, 0, 0, 0 ), - 'rx' => array( 190, 20, 20, 50 ), - 'rx_border' => array( 80, 40, 40, 90 ), - 'tx' => array( 130, 130, 130, 50 ), - 'tx_border' => array( 60, 60, 60, 90 ) - ); - - // A red colorscheme based on a contribution by Perry Mason - $colorscheme4 - 'stylesheet' => 'vnstat_pfSense.css', - 'image_background' => array( 240, 240, 240, 0 ), - 'graph_background' => array( 255, 255, 255, 0 ), - 'graph_background_2' => array( 255, 255, 255, 0 ), - 'grid_stipple_1' => array( 144, 0, 0, 0 ), - 'grid_stipple_2' => array( 144, 0, 0, 0 ), - 'border' => array( 0, 0, 0, 0 ), - 'text' => array( 0, 0, 0, 0 ), - 'rx' => array( 190, 20, 20, 50 ), - 'rx_border' => array( 80, 40, 40, 90 ), - 'tx' => array( 130, 130, 130, 50 ), - 'tx_border' => array( 60, 60, 60, 90 ) - ); -?> -EOF; - - $hf = fopen("/usr/local/www/vnstat/config.php","w"); - if(!$hf) { - log_error("could not open /usr/local/www/vnstat/config.php for writing"); - exit; - } - fwrite($hf, $config_file); - fclose($hf); - write_config(); - configure_cron(); - conf_mount_ro(); -} -?>
\ No newline at end of file diff --git a/config/vnstat/vnstat.xml b/config/vnstat/vnstat.xml deleted file mode 100644 index 6e3ae3ac..00000000 --- a/config/vnstat/vnstat.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> -<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> -<packagegui> - <copyright></copyright> - <description>Describe your package here</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> - <name>vnstat</name> - <version>1.0</version> - <title>vnstat</title> - <aftersaveredirect>/pkg_edit.php?xml=vnstat.xml&id=0</aftersaveredirect> - <include_file>/usr/local/pkg/vnstat.inc</include_file> - <menu> - <name>vnstat</name> - <tooltiptext></tooltiptext> - <section>Status</section> - <url>/vnstat</url> - </menu> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0644</chmod> - <item>https://packages.pfsense.org/packages/config/vnstat/vnstat.inc</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/</prefix> - <chmod>0644</chmod> - <item>https://files.pfsense.org/packages/7/vnstat/vnstat_php_frontend-1.4.1.tar.gz</item> - </additional_files_needed> - <custom_php_resync_config_command></custom_php_resync_config_command> - <custom_php_install_command>vnstat_install_config();</custom_php_install_command> - <custom_php_deinstall_command>vnstat_install_deinstall();</custom_php_deinstall_command> -</packagegui> diff --git a/config/widentd/widentd.xml b/config/widentd/widentd.xml index 27a8ffe8..fe28ba2d 100644 --- a/config/widentd/widentd.xml +++ b/config/widentd/widentd.xml @@ -102,7 +102,6 @@ <![CDATA[ function sync_package_widentd() { conf_mount_rw(); - config_lock(); global $config; /* Write widentd.sh */ @@ -128,7 +127,6 @@ } else { restart_service("widentd"); } - config_unlock(); conf_mount_ro(); } diff --git a/config/widescreen/bin/all.css_ b/config/widescreen/bin/all.css_ deleted file mode 100644 index d11dedca..00000000 --- a/config/widescreen/bin/all.css_ +++ /dev/null @@ -1,1413 +0,0 @@ -/* Element CSS Definitions */ -html, body, td, th, input, select { - font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 0.9em; - -} - -.infobox { - width:100%; -} - -.infoboxsave { - padding-right: 10px; -} - -.infoboxnptd2 { - width:100%; - color:white; - background-color:#990000; - padding-right: 10px; -} - -.infoboxnptd { - width:8%; - background-color:#990000; -} - -.infoboxnptable { - height:32px; - width:100%; - background-color:#990000; -} - -.infoboxnptable2 { - height:32px; - width:100%; - background-color:#990000; -} - -.infoboxnp { - background-color:#990000; - width:100%; -} - -.infoboxnpimg { - vertical-align:middle; - width:28px; - height:32px; - background-color:#990000; -} - -.inputerrorsleft { - background-color: #990000; - width: 36px; -} - -.inputerrorsright { - background-color: #FFD9D1; - color: #000000; - font-size: 11px; - padding-left: 8px; - padding-top: 6px; -} - -div.GraphLink { - position: relative; -} - -span.GraphLinkLine { - position: absolute; - background-color: #990000; - width: 100%; -} - -/* DOM Tooltip CSS definitions */ -div.niceTitle -{ - background-color: #333333; - color: #FFFFFF; - font-weight: bold; - font-size: 13px; - font-family: "Trebuchet MS", sans-serif; - width: 220px; - left: 0; - top: 0; - padding: 4px; - position: absolute; - text-align: left; - z-index: 20; - -moz-border-radius: 0 10px 10px 10px; - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=87); - -moz-opacity: .87; - -khtml-opacity: .87; - opacity: .87; -} -div.niceTitle h1 -{ - background: #990000; - border-bottom: 1px dotted #FFFFFF; - font-weight: bold; - font-size: 13px; - font-family: "Trebuchet MS", sans-serif; - margin: 3px; - padding-top: 1px; - padding-bottom: 1px; - padding-left: 3px; - text-align: left; - left: 0; - top: 0; - -moz-border-radius: 0 8px 0 0; - -moz-opacity: 1; -} -div.niceTitle .contents -{ - margin: 0; - padding: 0 3px; - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100); - -moz-opacity: 1; - -khtml-opacity: 1; - opacity: 1; -} -div.niceTitle p -{ - background: #FFFFFF; - border: 1px solid #990000; - color: #000000; - font-size: 11px; - font-family: "Trebuchet MS", sans-serif; - padding: 5px; - margin: 3px; - text-align: left; - -moz-opacity: 1; - -moz-border-radius: 0 0 8px 8px; -} - -body { - margin: 0px auto; - align: left; - background: url('images/background.jpg') no-repeat; - background-position : left 0px; - background-attachment: fixed; - background-color: #7f7f7f; -} -a:link { - color: #550000; -} - -a:visited { - color: #550000; -} - -a:active { - color: #550000; -} - -a:hover { - color: #550000; -} - -form { - margin: 0px; -} -a { - text-decoration: none; -} -form input { - font-size: 1.1em; -} - -iframe { - z-index: 1; - border: 1px dashed #990000; -} -.iframe { - background-color: #FFFFFF; -} - -/* style of disabled formelements */ -#wrap div {margin:1em 0} -[disabled] { - color:#666666; - background:#eeeeee; -} - -/* ID Based CSS Definitions */ -/* margin: 0px auto makes the content centered, margin 0px 0px makes it aligned to the left */ -#wrapper { -/*+++ width: 810px;*/ - width: 100%; - margin: 0px 0px; -/* left: 0px; */ -} - -#header { - background: url('images/header.png') no-repeat; - background-position: 0px; - height: 40px; - min-width: 910px; -/*+++ width: 810px;*/ - width: 100%; - position: fixed; - left: 0; - margin-bottom: 5px; - z-index: 1; -} -#header-left { - position: relative; -/* background: url('images/logo.gif') no-repeat;*/ - background-position: center; - height: 40px; - width: 80px; - left: 0px; - top:0px; - float: left; -} -#header-leftright { -/*+++ position: relative;*/ - position: absolute; - background: url('images/header-mid.png') repeat-x; - background-position: center; - height: 40px; - left: 900px; - right:0; - top:0px; - z-index: 2; /*+++*/ -} -#header-left #status-link { - position: relative; - top: 0px; - left: 0px; -} -#header-right { -/*+++ position: relative;*/ - position: absolute; - /* background: url('images/header.gif') no-repeat; */ - height: 70px; - color: #fff; -/*+++ left: 0px;*/ -/* margin-left: 165px; +++*/ -/* left: -300px;*/ - right: 0px; - width: 400px; - z-index: 2;/*+++*/ -} -#header-right .alert { - position: relative; - /* background: url('images/alert.gif') no-repeat; */ - background-position: 4px 2px; - color: #fff; - height: 17px; - width: 500px; - padding: 4px; - padding-left: 27px; - float: left; -} -#header-right .container { -/*+++ position: relative;*/ - postition: absolute; -} -#header-right .container .left { -/*+++ position: relative; */ - position: absolute; - float: left; - font-size: 1.3em; - font-weight: bold; - top: 15px; - left: 4px; - display: none; -} -#header-right .container .right { -/*+++ position: relative;*/ - position: absolute; - float: right; - top: 22px; - padding-right: 4px; - z-index: 1; -} - -/* for forcing an alert run the following command from diagnostics>command, php command: -file_notice("blah", "blah blah...testing my new theme..."); -*/ - -#header-right .container .right #alerts { - position: fixed; - background: url('images/alert_bgr.png') no-repeat; - height: 40px; - width: 400px; - top: 0px; - left: 810px; - z-index: 2; - padding-top: 1px; - padding-left: 10px; - margin: 0px; -} - -#header-right .container .right #hostname { -/*+++ position: fixed;*/ - position: absolute; - background: url('images/hostname.png') no-repeat; - height: 40px; - width: 400px; - z-index: 1; - padding-right: 5px; - margin: 0px; -/*+++ top: 0px;*/ - top: -22px; -/*+++ left: 810px;*/ - left: 0px; /*+++*/ - font-size: 12px; - color: #000000; - font-weight: bold; - padding-left: 40px; - padding-top: 2px; - text-align: left; -} - - - - -table#marquee { - position: relative; - top: -4px; - left: 15px; - border: 0; - padding: 0; - margin: 0; - width: 350px; - background-color: transparent; - padding: 2px; - border: 0px; -} -span#marquee-container { - position: absolute; - visibility: hidden; - top: -100px; - left: -10000px; -} -div#marquee-text { -/* font-size: 1.18em; - font-weight: normal; - font-family: Verdana; - color: #ffffff; */ - font-size: 12px; - font-weight: normal; - font-style: italic; - color: #000000; -} -table#marquee div#container { - position: relative; - overflow: hidden; - width: 330px; - height: 16px; -} -table#marquee div#container div#scroller { - position: absolute; - left: 0px; - top: 0px; -} - - - - - -#content { - position: relative; - top: 0px; -/*+++ left: 75px; */ - left: 10%; - margin-top: 0px; - margin-left: 0px; - padding-top: 50px; -/*+++ padding-left: 20px;*/ - padding-left: 20px; -/*+++ width: 840px; */ - width: 80%; - min-width: 900px; - background-color: #ffffff; -/*+++ background-color: #009900;*/ -/*+++ background: url('images/horizontal.png') repeat-y;*/ -} - - -/* try to abuse left as a fadeout at the end of the page */ -/*+++ #left {*/ -/*+++ width: 810px; */ -/* width: 100%; - height: 1px; -}*/ -#left { - position: absolute; - top: 0; - width: 20px; - height: 100%; - left: -20px; - background: url('images/horiz-left.png') repeat-y; -} -#right { - position: relative; -/*+++ top: -10px;*/ - top: 10px; - left: 0px; -/*+++ width: 770px;*/ - width: 100%; - margin-top: 0px; -/*+++ margin-left: 5px;*/ - margin-right: 5px; - padding-top: 20px; -/*+++ padding-left: 10px;*/ -/*+++ padding-right: 10px;*/ - padding-bottom: 90px; - min-height: 400px; -/*+++ background-color: #000099; */ -} -#right-right { - position: absolute; - top: 0px; - right: -20px; - width: 20px; - height: 100%; - background: url('images/horiz-right.png') repeat-y; -} - -#footer { - position: absolute; -/* margin-bottom: 5px; */ -/*+++ background: url('images/footer.png') no-repeat;*/ -/* top: -100px; */ -/*+++ bottom: 0px;*/ -/*+++ left: 75px;*/ - left: 10%; -/*+++ width: 840px;*/ - width: 80%; - min-width: 900px; - height: 60px; - color: #000000; - text-align: center; - font-size: 0.9em; -/*+++ padding-top: 10px;*/ -/*+++ padding-left: 10px;*/ -/*+++ clear: both;*/ -} -#footer-left { - position: absolute; - left: -20px; - width: 30px; - height: 80px; - background: url('images/footer-left.png') no-repeat; -} -#footer-center { - position: absolute; - left: 10px; - width: 100%; - height: 80px; - background: url('images/footer-middle.png') repeat-x; -} -#footer-right { - position: absolute; - right: -40px; - width: 30px; - height: 80px; - background: url('images/footer-right.png') no-repeat; -} -#footer p { - padding: 0px; - margin: 0px; - -} - -/* Style the List */ -#navigation { - /* background: url('images/menu.gif') no-repeat; */ - /* width: 693px; */ -/* position: relative;*/ - position: fixed; - top: 0px; - left: 100px; - width: 810px; - padding: 0px; - height: 28px; - z-index: 1000; - -} -#navigation ul { - padding: 0; - margin: 0; - list-style: none; - text-align: center; -} -#navigation ul#menu { - padding-top: 3px; - padding-left: 5px; -} - -/* Style the List Elements */ -#navigation ul li { - float: left; - position: relative; - width: 7.0em; - top: 0px; - /* top: -1px; */ -} -/* Text mainmenubar */ -#navigation ul li div { - - background-image: url(images/mainmenu-right.gif); - background-position: 5% 50%; - background-repeat: no-repeat; - padding-top:0px; - font-size: 12px; - font-weight: normal; - color: #ffffff; - text-align: center; - height: 13px; - - - - -/* -background: url("images/mainmenuitem.gif") top left no-repeat; -vertical-align: top; -border: 0px; -width: 100px; -height:20px; -*/ - - -} -/* Make the List inside the List Elements */ -/* initially hidden with absolute position */ -#navigation ul li ul { - display: none; - position: absolute; -/* top: 2em; - left: -2px; */ - width: 120px; - font-weight: normal; -/* background: transparent bottom left no-repeat; /* This is key to making the menu maintain visibility when not on a link */ - /* background-color: #202020; */ - background: url("images/menubgr_footer.png") no-repeat; - background-position: bottom; -/* padding: 0em 0 0.4em 0; */ - padding-top: 5px; - padding-bottom: 10px; -} -/* to override top and left in browsers other than IE */ -/* which will position to the top right of the containing */ -/* li, rather than bottom left */ -#navigation ul li > ul { - top: auto; - left: auto; - left: -1px !important; -} -/* Show initial drop down upon mouse over, but do not show */ -/* nested side drop menus within listed elements */ -#navigation ul li:hover ul { - display: block; - cursor: pointer; -} -#navigation ul li:hover { - cursor: pointer; - cursor: pointer; -} -#navigation ul li:hover div { - text-decoration: none; - background-image: url(images/mainmenu-down.gif); - background-position: 5% 50%; - background-repeat: no-repeat; - -} - -#navigation ul li { - background-color: transparent; - color: #000000; -} -/* dropdownmenu */ -#navigation ul li ul li { - border: 0px solid #850000; - width: 120px; - height: 1.6em; - line-height: 1.6em; -/* background-color: #850000; */ - background: url(images/menubgr.png) repeat-y; - z-index: 2; -/* color: #000000; */ -/* filter:alpha(opacity=95); - -moz-opacity:0.95; - -khtml-opacity: 0.95; - opacity: 0.95; */ -} -#navigation ul li ul li:hover { -/* background-color: #666666; */ - background-image: url(images/menubgr_highlight.png); - background-repeat: repeat-y; -} - -/* textcolor in dropdownmenu */ -#navigation li li a { - display: block; - padding-left: 8px; - padding-right: 8px; - color: #ffffff; - font-size: 11px; - font-weight: normal; - text-align: left; -/* - background-image: url(images/menu-dot.gif); - background-position: 0% 50%; - background-repeat: no-repeat; -*/ -} - -#navigation ul li ul li a.navlnk:hover { - text-decoration: none; -} -#navigation ul li.first { - border-right: 0px; -} -#navigation ul li.middle { - border-right: 0px; -} -#navigation ul li.last { - -} - -#navigation ul li.dropfirst { - border-bottom: 0px; -} -#navigation ul li.dropmiddle { - border-bottom: 0px; -} -#navigation ul li.droplast { -} - -#wzdtabcont { - float: left; - background-color: #FFFFFF; - color: #000000; - padding: 0; -} - -ul#wzdnav { - font-size: 0.96em; - float: left; - width: 14.5em; - margin: 0; - padding-left: 18px; -} - -ul#wzdnav li { - list-style: none; - margin: 0; - padding-bottom: 0.2em; - padding-left: 0; -} - -ul#wzdnav a { - display: block; - padding: 0.3em; - font-weight: normal; -} - -#wzdnavbold a { - display: block; - padding: 0.3em; - font-weight: bold ! important; -} - -ul#wzdnav a:link { - color: black; - background-color: #eee; -} - -ul#wzdnav a:visited { - color: #666; - background-color: #eee; -} - -ul#wzdnav a:hover { - color: black; - background-color: white; -} - -ul#wzdnav a:active { - color: white; - background-color: gray; -} - -#graph { - position: relative; - z-index: 1; -} - -#logoutbtn { - position: absolute; - left: 95%; - vertical-align: middle; -} - -/* Class Based CSS Definitions */ -.pgtitle { - font-size: 18px; - color: #777777; - font-weight: bold; -} -.tfrtitle { - font-size: 18px; - color: #ffffff; - font-weight: bold; -} -.vncell { - background-color: #DDDDDD; - padding-right: 20px; - padding-left: 8px; - border-bottom: 1px solid #999999; -} -.formfld { - padding-left: 19px; - font-size: small; -} -.formselect { - font-size: 1.0em; -} -.langopt { - padding-left: 34px; - padding-top: 2px; - padding-bottom: 2px; -} -.saved { - /* background: url('/themes/nione/images/icons/icon_wzd_saved.png') no-repeat 0 1px #FFFFFF; */ - list-style-image: url('/themes/nervecenter/images/icons/icon_wzd_saved.png') ! important; -} -.notsaved { - /* background: url('/themes/nione/images/icons/icon_wzd_nsaved.png') no-repeat 0 1px #FFFFFF; */ - list-style-image: url('/themes/nervecenter/images/icons/icon_wzd_nsaved.png') ! important; -} -.en { - background: url('/themes/nervecenter/images/icons/icon_flag_en.png') no-repeat 0 1px #FFFFFF; -} -.de { - background: url('/themes/nervecenter/images/icons/icon_flag_de.png') no-repeat 0 1px #FFFFFF; -} -.es { - background: url('/themes/nervecenter/images/icons/icon_flag_es.png') no-repeat 0 1px #FFFFFF; -} -.pt_BR { - background: url('/themes/nervecenter/images/icons/icon_flag_pt_BR.png') no-repeat 0 1px #FFFFFF; -} -.host { - background: url('/themes/nervecenter/images/icons/icon_frmfld_host.png') no-repeat 0 1px #FFFFFF; -} -.search { - background: url('/themes/nervecenter/images/icons/icon_frmfld_search.png') no-repeat 0 1px #FFFFFF; -} -.file { - background: url('/themes/nervecenter/images/icons/icon_frmfld_file.png') no-repeat 0 1px #FFFFFF; -} -.mail { - background: url('/themes/nervecenter/images/icons/icon_frmfld_mail.png') no-repeat 0 1px #FFFFFF; -} -.imp { - background: url('/themes/nervecenter/images/icons/icon_frmfld_imp.png') no-repeat 0 1px #FFFFFF; -} -.pwd { - background: url('/themes/nervecenter/images/icons/icon_frmfld_pwd.png') no-repeat 0 1px #FFFFFF; -} -.user { - background: url('/themes/nervecenter/images/icons/icon_frmfld_user.png') no-repeat 0 1px #FFFFFF ; -} -.group { - background: url('/themes/nervecenter/images/icons/icon_frmfld_group.png') no-repeat 0 1px #FFFFFF; -} -.url { - background: url('/themes/nervecenter/images/icons/icon_frmfld_url.png') no-repeat 0 1px #FFFFFF; -} -.time { - background: url('/themes/nervecenter/images/icons/icon_frmfld_time.png') no-repeat 0 1px #FFFFFF; -} -.unknown { - background: url('/themes/nervecenter/images/icons/icon_frmfld_unknown.png') no-repeat 0 1px #FFFFFF; -} -.formfld_cert { - background: url('/themes/nervecenter/images/icons/icon_frmfld_cert.png') no-repeat 0 1px #FFFFFF; - padding-left: 28px; - font-family: Courier New, Courier, monospaced; - font-size: 11px; -} -.formfldalias { - background-color: #990000; - color: #FFFFFF; -} -.formpre { - font-family: Courier New, Courier, monospaced; - font-size: 10px; -} -.formbtn { - font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 13px; - font-weight: bold; -} -.formbtns { - font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; - font-weight: bold; -} -.vvcell { - background-color: #FFFFC6; -} -.errmsg { - font-weight: bold; - color: #CC0000; -} -.red { - color: #CC0000; -} -.gray { - color: #A0A0A0; -} -.vexpl { - font-size: 11px; -} -.navlnk { - color: #FFFFFF; - text-decoration: none; - font-size: 13px; -} -.navlnks { - color: #FFFFFF; - text-decoration: none; - font-size: 11px; -} -.redlnk { - color: #990000; - text-decoration: none; -} -.tblnk { - color: #FFFFFF; - text-decoration: none; -} -.vncellreq { - background-color: #DDDDDD; - padding-right: 20px; - padding-left: 8px; - font-weight: bold; - border-bottom: 1px solid #999999; -} -.vncellt { - background-color: #DDDDDD; - padding-right: 20px; - padding-left: 8px; - padding-top: 4px; - padding-bottom: 4px; - font-weight: bold; - border-bottom: 1px solid #999999; -} -.vtable { - border-bottom: 1px solid #999999; -} -.vnsepcell { - background-color: #BBBBBB; - padding-right: 20px; - padding-left: 8px; - font-weight: bold; - border-bottom: 1px solid #999999; - font-size: 11px; -} -.cpline { - font-size: 11px; - color: #FFFFFF; -} -.hostname { - font-size: 11px; - color: #990000; - font-weight: bold; -} -.vnsepcellr { - background-color: #BBBBBB; - padding-right: 20px; - padding-left: 8px; - font-weight: bold; - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; -} -.listrborder { - background-color: #FFFFFF; - border-right: 1px solid #999999; - border-left: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; - padding-right: 6px; - padding-left: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -.listr { - background-color: #FFFFFF; - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; - padding-right: 6px; - padding-left: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -.listrpad { - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; - padding-right: 16px; - padding-left: 10px; - padding-top: 8px; - padding-bottom: 8px; -} -.listn { - font-size: 11px; - padding-right: 16px; - padding-left: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -.listbg { - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; - color: #FFFFFF; - background-color: #990000; - padding-right: 16px; - padding-left: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -.listbggrey { - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; - background-color: #999999; - padding-right: 16px; - padding-left: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -.listhdr { - background-color: #BBBBBB; - padding-right: 16px; - padding-left: 6px; - font-weight: bold; - border-bottom: 1px solid #999999; - font-size: 11px; - padding-top: 5px; - padding-bottom: 5px; -} -.listhdr a { - color: #000000; -} -.listhdrr { - background-color: #BBBBBB; - padding-right: 16px; - padding-left: 6px; - font-weight: bold; - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; - padding-top: 5px; - padding-bottom: 5px; -} -.listhdrr a { - color: #000000; -} -.listlr { - background-color: #FFFFFF; - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - border-left: 1px solid #999999; - font-size: 11px; - padding-right: 6px; - padding-left: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -.listlrns { - background-color: #FFFFFF; - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - border-left: 1px solid #999999; - font-size: 11px; - padding-top: 4px; - padding-bottom: 4px; -} -.list { - font-size: 11px; - padding-left: 6px; - padding-top: 2px; - padding-bottom: 2px; -} -.listt { - font-size: 11px; - padding-top: 5px; -} -.listhdrrns { - background-color: #BBBBBB; - padding-left: 6px; - padding-top: 5px; - padding-bottom: 5px; - padding-right: 6px; - font-weight: bold; - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; -} -.listbgns { - border-right: 1px solid #999999; - border-bottom: 1px solid #999999; - font-size: 11px; - background-color: #D9DEE8; - padding-left: 6px; - padding-right: 4px; - padding-top: 4px; - padding-bottom: 4px; -} -.listtopic { - border-right: 1px solid #999999; - font-size: 11px; - background-color: #990000; - padding-right: 16px; - padding-left: 6px; - color: #FFFFFF; - font-weight: bold; - padding-top: 5px; - padding-bottom: 5px; -} - -.optsect_t { - border-right: 1px solid #999999; - background-color: #990000; - padding-right: 6px; - padding-left: 6px; - padding-top: 2px; - padding-bottom: 2px; -} -.optsect_s { - font-size: 11px; - color: #FFFFFF; - font-weight: bold; -} -.tabnavtbl { -} - - -/* MISC CSS Definitions */ -ul#tabnav { - font-size: 11px; - font-weight: bold; - list-style-type: none; - margin: 0; - padding: 0; -} -ul#tabnav li.tabinact1 { - float: left; - background-color: #777777; - color: #FFFFFF; - padding: 0; - white-space: nowrap; -} -ul#tabnav li.tabinact { - float: left; - border-left: 1px solid #999999; - background-color: #777777; - color: #FFFFFF; - padding: 0; - white-space: nowrap; -} -ul#tabnav li.tabinact a { - float: left; - display: block; - text-decoration: none; - padding: 5px 8px 5px 8px; - color: #FFFFFF; -} -ul#tabnav li.tabinact1 a { - float: left; - display: block; - text-decoration: none; - padding: 5px 8px 5px 8px; - color: #FFFFFF; -} -ul#tabnav li.tabact { - float: left; - background-color: #EEEEEE; - color: #000000; - padding: 5px 8px 5px 8px; - white-space: nowrap; -} -.tabcont { - background-color: #DDDDDD; - padding-right: 12px; - padding-left: 12px; - padding-top: 12px; - padding-bottom: 12px; -} -.tabact { - float: left; - background-color: #EEEEEE; - color: #000000; - padding: 5px 8px 5px 8px; - white-space: nowrap; -} -.tabinact { - font-weight: bold; - float: left; - border-left: 1px solid #999999; - background-color: #777777; - color: #FFFFFF; - padding: 0; - white-space: nowrap; -} -.menu { - background-color: #000000; - white-space: nowrap; - padding: 0px 5px 0px 5px; - width: 100%; - vertical-align: top; -} - -/* style of disabled formelements */ -[disabled] { - color:#666666; - background:#eeeeee; -} - - -/* Auto Complete Suggestions */ -div.suggestions { - -moz-box-sizing: border-box; - /* box-sizing: border-box; */ - border: 1px solid black; - position: absolute; - background-color: #990000; - color: #FFF; -} - -div.suggestions div { - cursor: default; - padding: 0px 3px; - background-color: #990000; - color: #FFF; -} - -div.suggestions div.current { - background-color: #3366cc; - color: #FFF; -} -/* End Auto Complete Suggestions */ - - -/* Nifty Corners Crap */ -.rtop,.artop{display:block} -.rtop *,.artop *{display:block;height:1px;overflow:hidden;font-size:1px} -.artop *{border-style: solid;border-width:0 1px} -.r1,.rl1,.re1,.rel1{margin-left:5px} -.r1,.rr1,.re1,.rer1{margin-right:5px} -.r2,.rl2,.re2,.rel2,.ra1,.ral1{margin-left:3px} -.r2,.rr2,.re2,.rer2,.ra1,.rar1{margin-right:3px} -.r3,.rl3,.re3,.rel3,.ra2,.ral2,.rs1,.rsl1,.res1,.resl1{margin-left:2px} -.r3,.rr3,.re3,.rer3,.ra2,.rar2,.rs1,.rsr1,.res1,.resr1{margin-right:2px} -.r4,.rl4,.rs2,.rsl2,.re4,.rel4,.ra3,.ral3,.ras1,.rasl1,.res2,.resl2{margin-left:1px} -.r4,.rr4,.rs2,.rsr2,.re4,.rer4,.ra3,.rar3,.ras1,.rasr1,.res2,.resr2{margin-right:1px} -.rx1,.rxl1{border-left-width:5px} -.rx1,.rxr1{border-right-width:5px} -.rx2,.rxl2{border-left-width:3px} -.rx2,.rxr2{border-right-width:3px} -.re2,.rel2,.ra1,.ral1,.rx3,.rxl3,.rxs1,.rxsl1{border-left-width:2px} -.re2,.rer2,.ra1,.rar1,.rx3,.rxr3,.rxs1,.rxsr1{border-right-width:2px} -.rxl1,.rxl2,.rxl3,.rxl4,.rxsl1,.rxsl2,.ral1,.ral2,.ral3,.ral4,.rasl1,.rasl2{border-right-width:0} -.rxr1,.rxr2,.rxr3,.rxr4,.rxsr1,.rxsr2,.rar1,.rar2,.rar3,.rar4,.rasr1,.rasr2{border-left-width:0} -.r4,.rl4,.rr4,.re4,.rel4,.rer4,.ra4,.rar4,.ral4,.rx4,.rxl4,.rxr4{height:2px} -.rer1,.rel1,.re1,.res1,.resl1,.resr1{border-width:1px 0 0;height:0px !important;height /**/:1px} -/* End Nifty Corners Crap */ - - - -/* CSS for Dynamic Log Viewer */ -/* Author: Erik Kristensen */ -div#log div.log-entry { - clear: both; -} - -div#log div.log-entry span, -div#log div.log-header span { - padding: 3px 2px 3px 2px; - padding-left: 8px; -} - -div#log div.log-entry span.log-action { - padding-bottom: 6px; - padding-left: 5px; - padding-right: 5px; -} - -div#log div.log-header span { - border-top: 1px solid #999; - background-color: #bbb; - font-weight: bold; - text-align: left; -} - -div#log span.log-action, -div#log span.log-time, -div#log span.log-interface, -div#log span.log-source, -div#log span.log-destination, -div#log span.log-protocol { - float: left; - text-align: left; - border-left: 1px solid #999; - border-bottom: 1px solid #999; - -} - -div#log span.log-general { - -} - -div#log span.log-protocol { - border-right: 1px solid #999; -} - -div#log span.log-action { - width: 2em; - text-align: center; -} - -div#log span.log-time { - width: 12.5em; -} - -div#log span.log-interface { - width: 5em; -} - -div#log span.log-source, -div#log span.log-destination { - width: 17.6em; -} - -div#log span.log-protocol { - width: 5.5em; -} -/* END CSS FOR DYNAMIC LOG VIEWER */ - -#login { - background: #cccccc; - border: 0px solid #666666; - margin: 5em auto; - padding: 0em; - width: 340px; -} - -#login h1 { - background: url(images/misc/logon.png) no-repeat top left; - margin-top: 0; - display: block; - text-indent: -1000px; - height: 50px; - border-bottom: none; -} - -#login p { - font-size: 1em; - font-weight: bold; - padding: 3px; - margin: 0em; - text-indent: 10px; -} - -#login span { - font-size: 1em; - font-weight: bold; - width: 20%; - padding: 3px; - margin: 0em; - text-indent: 10px; -} - -#login p#text { - font-size: 1em; - font-weight: normal; - padding: 3px; - margin: 0em; - text-indent: 10px; -} - -#login #username, #password, #password2 { - font-size: small; - width: 60%; - padding-left:19px - padding: 3px; - margin: 0em; -} - -#login #submit { - font-size: 1em; - font-weight: bold; - padding: 3px; - margin: 0em; - text-indent: 10px; -} - -/* Widget CSS */ -.widgetsubheader { - border-right: 1px solid #999999; - font-size: 11px; - background-color: #B1B1B1; - padding-right: 6px; - padding-left: 6px; - color: #000000; - font-weight: bold; - padding-top: 5px; - padding-bottom: 5px; -} -.widgetheader { - border-right: 1px solid #999999; - font-size: 11px; - background-color: #990000; - padding-right: 6px; - padding-left: 6px; - color: #FFFFFF; - font-weight: bold; - padding-top: 5px; - padding-bottom: 5px; -} -.widgetdiv{ - margin-top:5px; - padding: 5px; - background:#CCCCCC; -} -.widgetconfigdiv{ - background:#BBBBBB; - font-size: 11px; - color: #000000; - padding-right: 5px; - padding-left: 5px; - padding-top: 5px; - padding-bottom: 5px; -} - -div#log div.log-entry-mini { - clear: both; -} - -div#log div.log-entry-mini span { - padding: 2px 2px 2px 2px; - padding-left: 8px; -} - -div#log span.log-action-mini-header, -div#log span.log-interface-mini-header, -div#log span.log-source-mini-header, -div#log span.log-destination-mini-header, -div#log span.log-protocol-mini-header { - float: left; - text-align: left; - background-color: #B1B1B1; - font-size: 12px; - border-left: 1px solid #999; - border-bottom: 1px solid #999; -} - -div#log span.log-action-mini, -div#log span.log-time-mini, -div#log span.log-interface-mini, -div#log span.log-source-mini, -div#log span.log-destination-mini, -div#log span.log-protocol-mini { - float: left; - text-align: left; - background-color: #FFFFFF; - font-size: 11px; - border-left: 1px solid #999; - border-bottom: 1px solid #999; -} - -div#log span.log-action-mini, -div#log span.log-action-mini-header { - width: 6%; -} - -div#log span.log-interface-mini, -div#log span.log-interface-mini-header { - width: 8%; -} - -div#log span.log-source-mini, -div#log span.log-destination-mini, -div#log span.log-source-mini-header, -div#log span.log-destination-mini-header { - width: 31%; -} - -div#log span.log-protocol-mini, -div#log span.log-protocol-mini-header { - width: 8%; - border-right: 1px solid #999; -} - -/* Sortable tables */ -table.sortable thead { - cursor: default; - background-color: #EEEEEE; - padding-right: 12px; - padding-left: 12px; - padding-top: 12px; - padding-bottom: 12px; -} diff --git a/config/widescreen/bin/fbegin.inc_ b/config/widescreen/bin/fbegin.inc_ deleted file mode 100644 index 73f26aaa..00000000 --- a/config/widescreen/bin/fbegin.inc_ +++ /dev/null @@ -1,430 +0,0 @@ -<script src="/javascript/sorttable.js"></script> - -<?php -/* - pfSense_MODULE: header -*/ - -require_once("globals.inc"); -require_once("functions.inc"); - -/* $Id$ */ - - -/* Determine automated help URL. Should output the page name and - parameters separately */ -$uri_split = ""; -preg_match("/\/(.*)\?(.*)/", $_SERVER["REQUEST_URI"], $uri_split); - -/* If there was no match, there were no parameters, just grab the filename - Otherwise, use the matched filename from above. */ -if (empty($uri_split[0])) { - $pagename = ltrim($_SERVER["REQUEST_URI"], '/'); -} else { - $pagename = $uri_split[1]; -} -/* If the page name is still empty, the user must have requested / (index.php) */ -if (empty($pagename)) { - $pagename = "index.php"; -} - -/* If the filename is pkg_edit.php or wizard.php, reparse looking - for the .xml filename */ -if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) { - $param_split = explode('&', $uri_split[2]); - foreach ($param_split as $param) { - if (substr($param, 0, 4) == "xml=") { - $xmlfile = explode('=', $param); - $pagename = $xmlfile[1]; - } - } -} - -/* Build the full help URL. */ -$helpurl .= "{$g['help_base_url']}?page={$pagename}"; - -function return_ext_menu($section) { - global $config; - $htmltext = ""; - $extarray = array(); - if($config['installedpackages']['menu'] <> "") { - foreach($config['installedpackages']['menu'] as $menuitem) { - if($menuitem['section'] != $section) continue; - if($menuitem['url'] <> "") { - $addresswithport = getenv("HTTP_HOST"); - $colonpos = strpos($addresswithport, ":"); - if ($colonpos !== False){ - //my url is actually just the IP address of the pfsense box - $myurl = substr($addresswithport, 0, $colonpos); - } else { - $myurl = $addresswithport; - } - $description = str_replace('$myurl', $myurl, $menuitem['url']); - } else { - $description = '/pkg.php?xml=' . $menuitem['configfile']; - } - $extarray[] = array($menuitem['name'], $description); - } - } - return $extarray; -} - -function output_menu($arrayitem, $target="") { - foreach($arrayitem as $item) { - if($target) - $targetinfo = "target='{$target}'"; - echo '<li><a ' . $targetinfo. ' href="' . $item[1] . '" class="navlnk">' . $item[0] . '</a></li>' . "\n"; - } -} - -// System -$system_menu = array(); -$system_menu[] = array("Advanced", "/system_advanced_admin.php"); -$system_menu[] = array("Firmware", "/system_firmware.php"); -$system_menu[] = array("General Setup", "/system.php"); -$system_menu[] = array("Logout", "/index.php?logout"); -if ($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") - $system_menu[] = array("Packages", "/pkg_mgr_installed.php"); -$system_menu[] = array("Setup Wizard", "/wizard.php?xml=setup_wizard.xml"); -$system_menu[] = array("Routing", "/system_gateways.php"); -$system_menu[] = array("Cert Manager", "/system_camanager.php"); -$system_menu[] = array("User Manager", "/system_usermanager.php"); -$system_menu = msort(array_merge($system_menu, return_ext_menu("System")),0); - -// Interfaces -$interfaces_menu = array(); -if (!isset($config['system']['webgui']['noassigninterfaces'])) - $interfaces_menu[] = array("(assign)", "/interfaces_assign.php"); -$opts = get_configured_interface_with_descr(false, true); -foreach ($opts as $oif => $odescr) - if (!isset($config['interfaces'][$oif]['ovpn'])) - $interfaces_menu[] = array(htmlspecialchars($odescr), "/interfaces.php?if={$oif}"); -$interfaces_menu = msort(array_merge($interfaces_menu, return_ext_menu("Interfaces")),0); - -// Firewall -$firewall_menu = array(); -$firewall_menu[] = array("Aliases", "/firewall_aliases.php"); -$firewall_menu[] = array("NAT", "/firewall_nat.php"); -$firewall_menu[] = array("Rules", "/firewall_rules.php"); -$firewall_menu[] = array("Schedules", "/firewall_schedule.php"); -$firewall_menu[] = array("Traffic Shaper", "/firewall_shaper.php"); -$firewall_menu[] = array("Virtual IPs", "/firewall_virtual_ip.php"); -$firewall_menu = msort(array_merge($firewall_menu, return_ext_menu("Firewall")),0); - -// Services -$services_menu = array(); -$services_menu[] = array("Captive Portal", "/services_captiveportal.php"); -$services_menu[] = array("DNS Forwarder", "/services_dnsmasq.php"); -$services_menu[] = array("DHCP Relay", "/services_dhcp_relay.php"); -if($g['services_dhcp_server_enable']) - $services_menu[] = array("DHCP Server", "/services_dhcp.php"); -$services_menu[] = array("Dynamic DNS", "/services_dyndns.php"); -$services_menu[] = array("IGMP proxy", "/services_igmpproxy.php"); -$services_menu[] = array("Load Balancer", "/load_balancer_pool.php"); -$services_menu[] = array("OLSR", "/pkg_edit.php?xml=olsrd.xml&id=0"); -$services_menu[] = array("PPPoE Server", "/vpn_pppoe.php"); -$services_menu[] = array("RIP", "/pkg_edit.php?xml=routed.xml&id=0"); -$services_menu[] = array("SNMP", "/services_snmp.php"); -if(count($config['interfaces']) > 1) { - /* no use for UPnP in single-interface deployments - remove to reduce user confusion - */ - $services_menu[] = array("UPnP & NAT-PMP", "/pkg_edit.php?xml=miniupnpd.xml&id=0"); -} -$services_menu[] = array("OpenNTPD", "/pkg_edit.php?xml=openntpd.xml&id=0"); -$services_menu[] = array("Wake on LAN", "/services_wol.php"); -$services_menu = msort(array_merge($services_menu, return_ext_menu("Services")),0); - -// VPN -$vpn_menu = array(); -$vpn_menu[] = array("IPsec", "/vpn_ipsec.php"); -$vpn_menu[] = array("OpenVPN", "/vpn_openvpn_server.php"); -$vpn_menu[] = array("PPTP", "/vpn_pptp.php"); -$vpn_menu[] = array("L2TP", "/vpn_l2tp.php"); -$vpn_menu = msort(array_merge($vpn_menu, return_ext_menu("VPN")),0); - -// Status -$status_menu = array(); -if (isset($config['captiveportal']['enable'])) - $status_menu[] = array("Captive Portal", "/status_captiveportal.php"); -$status_menu[] = array("CARP (failover)", "/carp_status.php"); -$status_menu[] = array("Dashboard", "/index.php"); -$status_menu[] = array("Gateways", "/status_gateways.php"); -$status_menu[] = array("DHCP Leases", "/status_dhcp_leases.php"); -$status_menu[] = array("Filter Reload", "/status_filter_reload.php"); -$status_menu[] = array("Interfaces", "/status_interfaces.php"); -$status_menu[] = array("IPsec", "/diag_ipsec.php"); -$status_menu[] = array("Load Balancer", "/status_lb_pool.php"); -$status_menu[] = array("OpenVPN", "/status_openvpn.php"); -if ($g['platform'] == "pfSense") - $status_menu[] = array("Package Logs", "/diag_pkglogs.php"); -$status_menu[] = array("Queues", "/status_queues.php"); -$status_menu[] = array("RRD Graphs", "/status_rrd_graph.php"); -$status_menu[] = array("Services", "/status_services.php"); -$status_menu[] = array("System Logs", "/diag_logs.php"); -$status_menu[] = array("Traffic Graph", "/status_graph.php?if=wan"); -if(count($config['interfaces']) > 1) - $status_menu[] = array("UPnP & NAT-PMP", "/status_upnp.php"); -$ifentries = get_configured_interface_with_descr(); -foreach ($ifentries as $ent => $entdesc) { - if (is_array($config['interfaces'][$ent]['wireless']) && - preg_match($g['wireless_regex'], $config['interfaces'][$ent]['if'])) - $ifdescrs[$ent] = $entdesc; -} -if (count($ifdescrs) > 0) - $status_menu[] = array("Wireless", "/status_wireless.php"); -$status_menu = msort(array_merge($status_menu, return_ext_menu("Status")),0); - -// Diagnostics -$diagnostics_menu = array(); -$diagnostics_menu[] = array("ARP Tables", "/diag_arp.php"); -$diagnostics_menu[] = array("Authentication", "/diag_authentication.php"); -$diagnostics_menu[] = array("Backup/Restore", "/diag_backup.php"); -$diagnostics_menu[] = array("Command Prompt", "/exec.php"); -$diagnostics_menu[] = array("DNS Lookup", "/diag_dns.php"); -$diagnostics_menu[] = array("Edit File", "/edit.php"); -$diagnostics_menu[] = array("Factory Defaults", "/diag_defaults.php"); -$diagnostics_menu[] = array("Halt System", "/halt.php" ); -$diagnostics_menu[] = array("Limiter Info", "/diag_limiter_info.php"); -$diagnostics_menu[] = array("NDP Table", "/diag_ndp.php"); -$diagnostics_menu[] = array("Ping", "/diag_ping.php"); -$diagnostics_menu[] = array("pfInfo", "/diag_pf_info.php"); -$diagnostics_menu[] = array("pfTOP", "/diag_system_pftop.php"); -$diagnostics_menu[] = array("Reboot", "/reboot.php"); -$diagnostics_menu[] = array("Routes", "/diag_routes.php"); -$diagnostics_menu[] = array("SMART Status", "/diag_smart.php"); -$diagnostics_menu[] = array("States", "/diag_dump_states.php"); -$diagnostics_menu[] = array("States Summary", "/diag_states_summary.php"); -$diagnostics_menu[] = array("System Activity", "/diag_system_activity.php"); -$diagnostics_menu[] = array("Tables", "/diag_tables.php"); -$diagnostics_menu[] = array("Traceroute", "/diag_traceroute.php"); -$diagnostics_menu[] = array("Packet Capture", "/diag_packet_capture.php"); -if($g['platform'] == "nanobsd") - $diagnostics_menu[] = array("NanoBSD", "/diag_nanobsd.php"); - -if (isset($config['system']['developer'])) { - echo "<li><hr width=\"80%\"/></li>"; - $diagnostics_menu[] = array("Restart HTTPD", "/restart_httpd.php"); -} -$diagnostics_menu = msort(array_merge($diagnostics_menu, return_ext_menu("Diagnostics")),0); - -if(! $g['disablehelpmenu']) { - $help_menu = array(); - $help_menu[] = array("About this Page", $helpurl); - $help_menu[] = array("User Forum", "https://www.pfsense.org/j.php?jumpto=forum"); - $help_menu[] = array("Documentation", "https://www.pfsense.org/j.php?jumpto=doc"); - $help_menu[] = array("Developers Wiki", "https://www.pfsense.org/j.php?jumpto=devwiki"); - $help_menu[] = array("Paid Support", "https://www.pfsense.org/j.php?jumpto=portal"); - $help_menu[] = array("pfSense Book", "https://www.pfsense.org/j.php?jumpto=book"); - $help_menu[] = array("Search portal", "https://www.pfsense.org/j.php?jumpto=searchportal"); - $help_menu[] = array("FreeBSD Handbook", "https://www.pfsense.org/j.php?jumpto=fbsdhandbook"); - $help_menu = msort(array_merge($help_menu, return_ext_menu("Help")),0); -} - -/* NOTICE ACKNOWLEDGE CODE by Erik Kristensen */ -if ($_REQUEST['noticeaction'] == 'acknowledge') { - $notice_id = htmlspecialchars($_REQUEST['noticeid']); - close_notice($notice_id); -} -/**********************************************/ - -?> - -<div id="wrapper"> - <div id="header"> - <div id="header-left"><a href="index.php" id="status-link"><img src="/themes/<?= $g['theme']; ?>/images/transparent.gif" border="0"></a></div> - <div id="header-leftright"> - <div id="header-right"> - <div class="container"> - <div class="left">webConfigurator</div> - <div class="right"> - -<? - if (are_notices_pending()) { - $notices = get_notices(); - - $requests=array(); - - ## Get Query Arguments from URL ### - foreach ($_REQUEST as $key => $value) { - if ($key != "PHPSESSID") - $requests[] = $key.'='.$value; - } - if(is_array($requests)) - $request_string = implode("&", $requests); - - if(is_array($notices)) { - foreach ($notices as $key => $value) { - $date = date("m-d-y H:i:s", $key); - $noticemsg = str_replace("'", "", $value['notice']); - $noticemsg = str_replace('"', "", $noticemsg); - $noticemsg = str_replace("\n", "", $noticemsg); - $noticemsg = str_replace("<p>", "", $noticemsg); - $noticemsg = str_replace("<pre>", "", $noticemsg); - $noticemsg = str_replace("</pre>", "", $noticemsg); - $noticemsg = str_replace("</p>", "", $noticemsg); - $noticemsg = str_replace("<br>", "", $noticemsg); - $extra_args = ""; - if($_GET['xml']) - $extraargs="&xml=" . htmlspecialchars($_GET['xml']); - if($_POST['xml']) - $extraargs="&xml=" . htmlspecialchars($_POST['xml']); - if($_GET['id']) - $extraargs="&xml=" . htmlspecialchars($_GET['id']); - if($_POST['id']) - $extraargs="&xml=" . htmlspecialchars($_POST['id']); - $notice_msgs = '<a href="?noticeaction=acknowledge¬iceid=all' . $extraargs . '">Acknowledge All</a> .:. '; - if ($value['url']) { - $notice_msgs .= $date.' - <a href="'.$url.'?' . htmlspecialchars($request_string) . '¬iceaction=acknowledge¬iceid='.$key.'">['.$value['id'].']</a>'; - } else { - $notice_msgs .= $date.' - <a href="?' . htmlspecialchars($request_string) . '¬iceaction=acknowledge¬iceid='.$key.'">['.$value['id'].']'.htmlspecialchars($noticemsg).'</a>'; - } - $notice_msgs .= " .:. "; - } - } -?> - <div id="alerts"> - <script type="text/javascript"> - var content='<div id="marquee-text"><?= $notice_msgs; ?></div>' - </script> - <script type="text/javascript" src="/javascript/ticker.js"></script> - </div> -<? - } else { -?> - <div id="hostname"> - <? print $config['system']['hostname'] . "." . $config['system']['domain']; ?> - </div> -<? - } -?> - </div> - </div> - </div> - </div> - <div id="navigation" style="z-index:1000"> - <ul id="menu"> - <li class="firstdrop"> - <div>System</div> - <ul class="subdrop"> - <?php - output_menu($system_menu); - ?> - </ul> - </li> - <li class="drop"> - <div>Interfaces</div> - <ul class="subdrop"> - <?php - output_menu($interfaces_menu); - ?> - </ul> - </li> - <li class="drop"> - <div>Firewall</div> - <ul class="subdrop"> - <?php - output_menu($firewall_menu); - ?> - </ul> - </li> - <li class="drop"> - <div>Services</div> - <ul class="subdrop"> - <? - output_menu($services_menu); - ?> - </ul> - </li> - <li class="drop"> - <div>VPN</div> - <ul class="subdrop"> - <?php - output_menu($vpn_menu); - ?> - </ul> - </li> - <li class="drop"> - <div>Status</div> - <ul class="subdrop"> - <?php - output_menu($status_menu); - ?> - </ul> - </li> - <li class="drop"> - <div>Diagnostics</div> - <ul id="diag" class="subdrop"> - <? - output_menu($diagnostics_menu); - ?> - </ul> - </li> - <?php if(! $g['disablehelpmenu']): ?> - <li class="lastdrop"> - <div>Help</div> - <ul id="help" class="subdrop"> - <? - output_menu($help_menu, "_new"); - ?> - </ul> - </li> - <?php endif; ?> - </ul> - </div> - </div> <!-- Header DIV --> - <div id="content"> - <div id="left"> - </div> <!-- Left DIV --> - - <div id="right"> - -<?php - - /* display a top alert bar if need be */ - $need_alert_display = false; - $found_notices = are_notices_pending(); - if($found_notices == true) { - $notices = get_notices(); - if(!$notices) { - $need_alert_display = true; - $display_text = print_notices() . "<br>"; - } - } - if($need_alert_display == true) { - echo "<div style=\"background-color:#000000\" id=\"roundalert\">"; - echo "<table>"; - echo "<tr><td><font color=\"#ffffff\">"; - echo " <img align=\"middle\" src=\"/top_notification.gif\"> "; - echo $display_text; - echo "</td>"; - echo "</tr>"; - echo "</table>"; - echo "</div>"; - } - -function add_to_menu($url, $name) { - if (isAllowedPage($url)) - echo "<li><a href=\"{$url}\" class=\"navlnk\">{$name}</a></li>\n"; -} -?> - -<div> -<span class="pgtitle"><a href="<?= $_SERVER['SCRIPT_NAME'] ?>"><?=genhtmltitle($pgtitle);?></a></span> -<span style="float:right; margin: 0 0 20px 20px;"> -<?php if(! empty($statusurl)): ?> -<a href="<?php echo $statusurl; ?>" target="_new" title="Status of items on this page."><img src="/themes/<?php echo $g['theme']; ?>/images/status.png" border="0"></a> -<?php endif; ?> -<?php if(! empty($logurl)): ?> -<a href="<?php echo $logurl; ?>" target="_new" title="Log entries for items on this page."><img src="/themes/<?php echo $g['theme']; ?>/images/log.png" border="0"></a> -<?php endif; ?> -<?php if(! $g['disablehelpicon']): ?> -<a href="<?php echo $helpurl; ?>" target="_new" title="Help for items on this page."><img src="/themes/<?php echo $g['theme']; ?>/images/help.png" border="0"></a> -<?php endif; ?> -</span> -</div> -<br /> - -<?php - $pgtitle_output = true; -?> diff --git a/config/widescreen/bin/fend.inc_ b/config/widescreen/bin/fend.inc_ deleted file mode 100644 index 1eb3ada8..00000000 --- a/config/widescreen/bin/fend.inc_ +++ /dev/null @@ -1,23 +0,0 @@ -<!-- - pfSense_MODULE: footer ---> - - </div> <!-- Right DIV --> - <div id="right-right"> - </div> - </div> <!-- Content DIV --> - - <div id="footer"> - <div id="footer-left"></div> - <div id="footer-center"> - <a target="_blank" href="<?=$g['product_website_footer']?>" class="redlnk"><?=$g['product_name']?></a> is © - <?=$g['product_copyright_years']?> by <a href="<?=$g['product_copyright_url']?>" class="tblnk"><?=$g['product_copyright']?></a>. All Rights Reserved. - [<a href="/license.php" class="tblnk">view license</a>] - </div> - <div id="footer-right"></div> - </div> <!-- Footer DIV --> - -</div> <!-- Wrapper Div --> - -<?php outputJavaScriptFileInline("/usr/local/www/themes/{$g['theme']}/bottom-loader.js"); ?> - diff --git a/config/widescreen/bin/footer-left.png b/config/widescreen/bin/footer-left.png Binary files differdeleted file mode 100644 index 7c068c21..00000000 --- a/config/widescreen/bin/footer-left.png +++ /dev/null diff --git a/config/widescreen/bin/footer-middle.png b/config/widescreen/bin/footer-middle.png Binary files differdeleted file mode 100644 index 2176e741..00000000 --- a/config/widescreen/bin/footer-middle.png +++ /dev/null diff --git a/config/widescreen/bin/footer-right.png b/config/widescreen/bin/footer-right.png Binary files differdeleted file mode 100644 index 33169290..00000000 --- a/config/widescreen/bin/footer-right.png +++ /dev/null diff --git a/config/widescreen/bin/header-mid.png b/config/widescreen/bin/header-mid.png Binary files differdeleted file mode 100644 index 93963c65..00000000 --- a/config/widescreen/bin/header-mid.png +++ /dev/null diff --git a/config/widescreen/bin/horiz-left.png b/config/widescreen/bin/horiz-left.png Binary files differdeleted file mode 100644 index 8f772a4f..00000000 --- a/config/widescreen/bin/horiz-left.png +++ /dev/null diff --git a/config/widescreen/bin/horiz-right.png b/config/widescreen/bin/horiz-right.png Binary files differdeleted file mode 100644 index edacbc23..00000000 --- a/config/widescreen/bin/horiz-right.png +++ /dev/null diff --git a/config/widescreen/bin/index.php_ b/config/widescreen/bin/index.php_ deleted file mode 100644 index a6ad1019..00000000 --- a/config/widescreen/bin/index.php_ +++ /dev/null @@ -1,775 +0,0 @@ -<?php -/* $Id$ */ -/* - index.php - Copyright (C) 2004, 2005 Scott Ullrich - All rights reserved. - - Originally part of m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2004 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_BUILDER_BINARIES: /sbin/ifconfig - pfSense_MODULE: interfaces -*/ - -##|+PRIV -##|*IDENT=page-system-login/logout -##|*NAME=System: Login / Logout page / Dashboard -##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard. -##|*MATCH=index.php* -##|-PRIV - -// Turn on buffering to speed up rendering -ini_set('output_buffering','true'); - -// Start buffering with a cache size of 100000 -ob_start(null, "1000"); - -## Load Essential Includes -require_once('functions.inc'); -require_once('guiconfig.inc'); -require_once('notices.inc'); - -##build list of widgets -$directory = "/usr/local/www/widgets/widgets/"; -$dirhandle = opendir($directory); -$filename = ""; -$widgetnames = array(); -$widgetfiles = array(); -$widgetlist = array(); - -while (false !== ($filename = readdir($dirhandle))) { - $periodpos = strpos($filename, "."); - $widgetname = substr($filename, 0, $periodpos); - $widgetnames[] = $widgetname; - if ($widgetname != "system_information") - $widgetfiles[] = $filename; -} - -##sort widgets alphabetically -sort($widgetfiles); - -##insert the system information widget as first, so as to be displayed first -array_unshift($widgetfiles, "system_information.widget.php"); - -##if no config entry found, initialize config entry -if (!is_array($config['widgets'])) { - $config['widgets'] = array(); -} - - if ($_POST && $_POST['submit']) { - $config['widgets']['sequence'] = $_POST['sequence']; - - foreach ($widgetnames as $widget){ - if ($_POST[$widget . '-config']){ - $config['widgets'][$widget . '-config'] = $_POST[$widget . '-config']; - } - } - - write_config(gettext("Widget configuration has been changed.")); - header("Location: index.php"); - exit; - } - - ## Load Functions Files - require_once('includes/functions.inc.php'); - - ## Check to see if we have a swap space, - ## if true, display, if false, hide it ... - if(file_exists("/usr/sbin/swapinfo")) { - $swapinfo = `/usr/sbin/swapinfo`; - if(stristr($swapinfo,'%') == true) $showswap=true; - } - - ## User recently restored his config. - ## If packages are installed lets resync - if(file_exists('/conf/needs_package_sync')) { - if($config['installedpackages'] <> '') { - conf_mount_rw(); - @unlink('/conf/needs_package_sync'); - conf_mount_ro(); - if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") { - header('Location: pkg_mgr_install.php?mode=reinstallall'); - exit; - } - } - } - - ## If it is the first time webConfigurator has been - ## accessed since initial install show this stuff. - if(file_exists('/conf/trigger_initial_wizard')) { - echo <<<EOF -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> -<head> - <title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> - <link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" /> - <script type="text/javascript">var theme = "nervecenter"</script> - <script type="text/javascript" src="/themes/nervecenter/loader.js"></script> - -EOF; - - echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n"; - - if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) - echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n"; - else - echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />"; - - echo "<form>\n"; - echo "<center>\n"; - echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n"; - echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n"; - echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>"; - echo gettext("One moment while we start the initial setup wizard.") . "<p>\n"; - echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n"; - echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n"; - echo "</div>\n"; - echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n"; - echo "<script type=\"text/javascript\">\n"; - echo "NiftyCheck();\n"; - echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n"; - echo "</script>\n"; - exit; - } - - - ## Find out whether there's hardware encryption or not - unset($hwcrypto); - $fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r"); - if ($fd) { - while (!feof($fd)) { - $dmesgl = fgets($fd); - if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches) or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches) or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches) or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches) or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches) or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)) { - $hwcrypto = $matches[1]; - break; - } - } - fclose($fd); - } - -##build widget saved list information -if ($config['widgets'] && $config['widgets']['sequence'] != "") { - $pconfig['sequence'] = $config['widgets']['sequence']; - $widgetlist = $pconfig['sequence']; - $colpos = array(); - $savedwidgetfiles = array(); - $widgetname = ""; - $widgetlist = explode(",",$widgetlist); - - ##read the widget position and display information - foreach ($widgetlist as $widget){ - $dashpos = strpos($widget, "-"); - $widgetname = substr($widget, 0, $dashpos); - $colposition = strpos($widget, ":"); - $displayposition = strrpos($widget, ":"); - $colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1); - $displayarray[] = substr($widget,$displayposition+1); - $savedwidgetfiles[] = $widgetname . ".widget.php"; - } - - ##add widgets that may not be in the saved configuration, in case they are to be displayed later - foreach ($widgetfiles as $defaultwidgets){ - if (!in_array($defaultwidgets, $savedwidgetfiles)){ - $savedwidgetfiles[] = $defaultwidgets; - } - } - - ##find custom configurations of a particular widget and load its info to $pconfig - foreach ($widgetnames as $widget){ - if ($config['widgets'][$widget . '-config']){ - $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config']; - } - } - - $widgetlist = $savedwidgetfiles; -} else{ - // no saved widget sequence found, build default list. - $widgetlist = $widgetfiles; -} - -##build list of php include files -$phpincludefiles = array(); -$directory = "/usr/local/www/widgets/include/"; -$dirhandle = opendir($directory); -$filename = ""; -while (false !== ($filename = readdir($dirhandle))) { - $phpincludefiles[] = $filename; -} -foreach($phpincludefiles as $includename) { - if(!stristr($includename, ".inc")) - continue; - include($directory . $includename); -} - -##begin AJAX -$jscriptstr = <<<EOD -<script language="javascript" type="text/javascript"> - - -function widgetAjax(widget) { - uri = "widgets/widgets/" + widget + ".widget.php"; - var opt = { - // Use GET - method: 'get', - evalScripts: 'true', - asynchronous: true, - // Handle 404 - on404: function(t) { - alert('Error 404: location "' + t.statusText + '" was not found.'); - }, - // Handle other errors - onFailure: function(t) { - alert('Error ' + t.status + ' -- ' + t.statusText); - }, - onSuccess: function(t) { - widget2 = widget + "-loader"; - Effect.Fade(widget2, {queue:'front'}); - Effect.Appear(widget, {queue:'end'}); - } - } - new Ajax.Updater(widget, uri, opt); -} - - -function addWidget(selectedDiv){ - selectedDiv2 = selectedDiv + "-container"; - d = document; - textlink = d.getElementById(selectedDiv2); - Effect.Appear(selectedDiv2, {duration:1}); - if (textlink.style.display != "none") - { - Effect.Shake(selectedDiv2); - } - else - { - widgetAjax(selectedDiv); - selectIntLink = selectedDiv2 + "-input"; - textlink = d.getElementById(selectIntLink); - textlink.value = "show"; - showSave(); - } -} - -function configureWidget(selectedDiv){ - selectIntLink = selectedDiv + "-settings"; - d = document; - textlink = d.getElementById(selectIntLink); - if (textlink.style.display == "none") - Effect.BlindDown(selectIntLink, {duration:1}); - else - Effect.BlindUp(selectIntLink, {duration:1}); -} - -function showWidget(selectedDiv,swapButtons){ - //appear element - Effect.BlindDown(selectedDiv, {duration:1}); - showSave(); - d = document; - if (swapButtons){ - selectIntLink = selectedDiv + "-min"; - textlink = d.getElementById(selectIntLink); - textlink.style.display = "inline"; - - - selectIntLink = selectedDiv + "-open"; - textlink = d.getElementById(selectIntLink); - textlink.style.display = "none"; - - } - selectIntLink = selectedDiv + "-container-input"; - textlink = d.getElementById(selectIntLink); - textlink.value = "show"; - -} - -function minimizeWidget(selectedDiv,swapButtons){ - //fade element - Effect.BlindUp(selectedDiv, {duration:1}); - showSave(); - d = document; - if (swapButtons){ - selectIntLink = selectedDiv + "-open"; - textlink = d.getElementById(selectIntLink); - textlink.style.display = "inline"; - - selectIntLink = selectedDiv + "-min"; - textlink = d.getElementById(selectIntLink); - textlink.style.display = "none"; - } - selectIntLink = selectedDiv + "-container-input"; - textlink = d.getElementById(selectIntLink); - textlink.value = "hide"; - -} - -function closeWidget(selectedDiv){ - showSave(); - selectedDiv = selectedDiv + "-container"; - Effect.Fade(selectedDiv, {duration:1}); - d = document; - selectIntLink = selectedDiv + "-input"; - textlink = d.getElementById(selectIntLink); - textlink.value = "close"; -} - -function showSave(){ - d = document; - selectIntLink = "submit"; - textlink = d.getElementById(selectIntLink); - textlink.style.display = "inline"; -} - -function updatePref(){ - var widgets = document.getElementsByClassName('widgetdiv'); - var widgetSequence = ""; - var firstprint = false; - d = document; - for (i=0; i<widgets.length; i++){ - if (firstprint) - widgetSequence += ","; - var widget = widgets[i].id; - widgetSequence += widget + ":" + widgets[i].parentNode.id + ":"; - widget = widget + "-input"; - textlink = d.getElementById(widget).value; - widgetSequence += textlink; - firstprint = true; - } - selectLink = "sequence"; - textlink = d.getElementById(selectLink); - textlink.value = widgetSequence; - return true; -} - -function hideAllWidgets(){ - Effect.Fade('niftyOutter', {to: 0.2}); -} - -function showAllWidgets(){ - Effect.Fade('niftyOutter', {to: 1.0}); -} - - -function changeTabDIV(selectedDiv){ - var dashpos = selectedDiv.indexOf("-"); - var tabclass = selectedDiv.substring(0,dashpos); - d = document; - - //get deactive tabs first - tabclass = tabclass + "-class-tabdeactive"; - var tabs = document.getElementsByClassName(tabclass); - var incTabSelected = selectedDiv + "-deactive"; - for (i=0; i<tabs.length; i++){ - var tab = tabs[i].id; - dashpos = tab.lastIndexOf("-"); - var tab2 = tab.substring(0,dashpos) + "-deactive"; - if (tab2 == incTabSelected){ - tablink = d.getElementById(tab2); - tablink.style.display = "none"; - tab2 = tab.substring(0,dashpos) + "-active"; - tablink = d.getElementById(tab2); - tablink.style.display = "table-cell"; - - //now show main div associated with link clicked - tabmain = d.getElementById(selectedDiv); - tabmain.style.display = "block"; - } - else - { - tab2 = tab.substring(0,dashpos) + "-deactive"; - tablink = d.getElementById(tab2); - tablink.style.display = "table-cell"; - tab2 = tab.substring(0,dashpos) + "-active"; - tablink = d.getElementById(tab2); - tablink.style.display = "none"; - - //hide sections we don't want to see - tab2 = tab.substring(0,dashpos); - tabmain = d.getElementById(tab2); - tabmain.style.display = "none"; - - } - } -} - -</script> -EOD; -$closehead = false; - -## Set Page Title and Include Header -$pgtitle = array(sprintf(gettext("%s Dashboard"), $g['product_name'])); -include("head.inc"); - -echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n"; -echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n"; -echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n"; -echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n"; - -?> - -<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<form action="index.php" method="post"> -<script language="javascript" type="text/javascript"> -// <![CDATA[ - columns = ['col1','col2','col3','col4','col5','col6']; -// ]]> - var currwidth; - currwidth = document.documentElement.clientWidth; - window.onresize = function (){ - if (currwidth != document.documentElement.clientWidth){ - // let's refresh window if width was changed - window.location.href=window.location.href; - }; - currwidth = document.documentElement.clientWidth; - } -</script> - -<?php -include("fbegin.inc"); -echo $jscriptstr; - if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo")) - echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>"; -?> -<div id="widgetcontainer" style="display:none"> - <div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php - $widgetfiles_add = $widgetfiles; - sort($widgetfiles_add); - foreach($widgetfiles_add as $widget) { - if(!stristr($widget, "widget.php")) - continue; - - $periodpos = strpos($widget, "."); - $widgetname = substr($widget, 0, $periodpos); - $nicename = $widgetname; - $nicename = str_replace("_", " ", $nicename); - //make the title look nice - $nicename = ucwords($nicename); - - $widgettitle = $widgetname . "_title"; - $widgettitlelink = $widgetname . "_title_link"; - if ($$widgettitle != "") - { - //echo widget title - ?> - <span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'> - <u><?php echo $$widgettitle; ?></u></span><br> - <?php - } - else {?> - <span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'> - <u><?php echo $nicename; ?></u></span><br><?php - } - } - ?> - </p> - </div> -</div> - -<div id="welcomecontainer" style="display:none"> - <div id="welcome-container"> - <h1> - <div style="float:left;width:80%;padding: 2px"> - <?=gettext("Welcome to the Dashboard page"); ?>! - </div> - <div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" > - <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" /> - </div> - <div style="clear:both;"></div> - </h1> - <p> - <?=gettext("This page allows you to customize the information you want to be displayed!");?><br/> - <?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> <?=gettext("icon to add widgets.");?><br/> - <br/> - <?=gettext("You can move any widget around by clicking and dragging the title.");?> - </p> - </div> -</div> - -<input type="hidden" value="" name="sequence" id="sequence"> -<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="<?=gettext("Click here to add widgets"); ?>" style="cursor: pointer;" onmouseup="domTT_activate(this, event, 'content', document.getElementById('content1'), 'type', 'velcro', 'delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" /> - -<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" alt="<?=gettext("Click here for help"); ?>" style="cursor: help;" onmouseup="hideAllWidgets();domTT_activate(this, event, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" /> - - - - <input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" /> -</p> - -<div id="niftyOutter"> - <?php - $widgetcounter = 0; - $directory = "/usr/local/www/widgets/widgets/"; - $firstprint = false; - ?> -<script language="javascript" type="text/javascript"> -var printed2 = false; -var printed3 = false; -var printed4 = false; -var printed5 = false; -var printed6 = false; -var numofcols = parseInt(currwidth/400); // one column is minimum 350px -if (numofcols < 2) numofcols = 2; -var colpercent; // column width in percents -if (numofcols <= 2) colpercent = parseInt(100/numofcols-2); -else colpercent = parseInt(100/numofcols-1); - -function PrintDiv(colpos){ - if (colpos == "col2" && printed2 == false){ - document.write("</div><div id=\"col2\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px;padding-left:10px;\">"); - printed2=true; - }else if (colpos == "col3" && numofcols >= 3 && printed3 == false){ - document.write("</div><div id=\"col3\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px;padding-left:10px;\">"); - printed3=true; - }else if (colpos == "col4" && numofcols >= 4 && printed4 == false){ - document.write("</div><div id=\"col4\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px;padding-left:10px;\">"); - printed4=true; - }else if (colpos == "col5" && numofcols >= 5 && printed5 == false){ - document.write("</div><div id=\"col5\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px;padding-left:10px;\">"); - printed5=true; - }else if (colpos == "col6" && numofcols >= 6 && printed6 == false){ - document.write("</div><div id=\"col6\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px;padding-left:10px;\">"); - printed6=true; - } -} -document.write("<div id=\"col1\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px;padding-left:10px;\">"); -</script> - <?php - - foreach($widgetlist as $widget) { - - if(!stristr($widget, "widget.php")) - continue; - $periodpos = strpos($widget, "."); - $widgetname = substr($widget, 0, $periodpos); - if ($widgetname != ""){ - $nicename = $widgetname; - $nicename = str_replace("_", " ", $nicename); - - //make the title look nice - $nicename = ucwords($nicename); - } - - if ($config['widgets'] && $pconfig['sequence'] != ""){ - switch($displayarray[$widgetcounter]){ - case "show": - $divdisplay = "block"; - $display = "block"; - $inputdisplay = "show"; - $showWidget = "none"; - $mindiv = "inline"; - break; - case "hide": - $divdisplay = "block"; - $display = "none"; - $inputdisplay = "hide"; - $showWidget = "inline"; - $mindiv = "none"; - break; - case "close": - $divdisplay = "none"; - $display = "block"; - $inputdisplay = "close"; - $showWidget = "none"; - $mindiv = "inline"; - break; - default: - $divdisplay = "none"; - $display = "block"; - $inputdisplay = "none"; - $showWidget = "none"; - $mindiv = "inline"; - break; - } - } else { - if ($firstprint == false){ - $divdisplay = "block"; - $display = "block"; - $inputdisplay = "show"; - $showWidget = "none"; - $mindiv = "inline"; - $firstprint = true; - } else { - switch ($widget) { - case "interfaces.widget.php": - case "traffic_graphs.widget.php": - $divdisplay = "block"; - $display = "block"; - $inputdisplay = "show"; - $showWidget = "none"; - $mindiv = "inline"; - break; - default: - $divdisplay = "none"; - $display = "block"; - $inputdisplay = "close"; - $showWidget = "none"; - $mindiv = "inline"; - break; - } - } - } - - if ($config['widgets'] && $pconfig['sequence'] != ""){ -?> - <script language="javascript" type="text/javascript"> - colpos="<?=$colpos[$widgetcounter]?>"; - PrintDiv(colpos); - </script> - -<?php - } -?> - <div style="clear:both;"></div> - <div id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;"> - <input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input"> - <div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move"> - <div style="float:left;"> - <?php - - $widgettitle = $widgetname . "_title"; - $widgettitlelink = $widgetname . "_title_link"; - if ($$widgettitle != "") - { - //only show link if defined - if ($$widgettitlelink != "") {?> - <u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer"> - <?php } - //echo widget title - echo $$widgettitle; - if ($$widgettitlelink != "") { ?> - </span></u> - <?php } - } - else{ - if ($$widgettitlelink != "") {?> - <u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer"> - <?php } - echo $nicename; - if ($$widgettitlelink != "") { ?> - </span></u> - <?php } - } - ?> - </div> - <div align="right" style="float:right;"> - <div id="<?php echo $widgetname;?>-configure" onclick='return configureWidget("<?php echo $widgetname;?>")' style="display:none; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_configure.gif" /></div> - <div id="<?php echo $widgetname;?>-open" onclick='return showWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $showWidget;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" /></div> - <div id="<?php echo $widgetname;?>-min" onclick='return minimizeWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif"/></div> - <div id="<?php echo $widgetname;?>-close" onclick='return closeWidget("<?php echo $widgetname;?>",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" /></div> - </div> - <div style="clear:both;"></div> - </div> - <?php if ($divdisplay != "block") { ?> - <div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;"> - <br> - <center> - <img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width=25 height=25 alt="<?=gettext("Loading selected widget"); ?>..."> - </center> - <br> - </div> <?php } if ($divdisplay != "block") $display = none; ?> - <div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;"> - <?php - if ($divdisplay == "block") - { - include($directory . $widget); - } - ?> - </div> - <div style="clear:both;"></div> - </div> -<?php - $widgetcounter++; - - }//end foreach -?> - <script type="text/javascript"> - // If some columns still do not have widgets let's print them anyway so a user can move wigets to them - if (printed2 == false){ - document.write("</div><div id=\"col2\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px\">"); - } - if (numofcols >= 3 && printed3 == false){ - document.write("</div><div id=\"col3\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px\">"); - } - if (numofcols >= 4 && printed4 == false){ - document.write("</div><div id=\"col4\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px\">"); - } - if (numofcols >= 5 && printed5 == false){ - document.write("</div><div id=\"col5\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px\">"); - } - if (numofcols >= 6 && printed6 == false){ - document.write("</div><div id=\"col6\" style=\"float:left;width:"+colpercent+"%;padding-bottom:40px\">"); - } - </script> - </div> - <div style="clear:both;"></div> -</div> - -<!-- -<script type="text/javascript"> - document.write("+++test+++<br>"); - document.write("currwidth="+currwidth+"<br>"); - document.write("numofcols="+numofcols+"<br>"); - document.write("colpercent="+colpercent+"<br>"); -</script> ---> -<?php include("fend.inc"); ?> - -<script type="text/javascript"> - document.observe('dom:loaded', function(in_event) - { - Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave}); - Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave}); - Sortable.create("col3", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave}); - Sortable.create("col4", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave}); - Sortable.create("col5", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave}); - Sortable.create("col6", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave}); - <?php if (!$config['widgets'] && $pconfig['sequence'] != ""){ ?> - hideAllWidgets(); - domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle'); - <?php } ?> - }); -</script> - -<?php - //build list of javascript include files - $jsincludefiles = array(); - $directory = "widgets/javascript/"; - $dirhandle = opendir($directory); - $filename = ""; - while (false !== ($filename = readdir($dirhandle))) { - $jsincludefiles[] = $filename; - } - foreach($jsincludefiles as $jsincludename) { - if(!stristr($jsincludename, ".js")) - continue; - echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n"; - } -?> -</form> -</body> -</html> diff --git a/config/widescreen/widescreen.inc b/config/widescreen/widescreen.inc deleted file mode 100644 index 52c91d92..00000000 --- a/config/widescreen/widescreen.inc +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -/** - * Author: Evgeny Yurchenko - * Email: ey@tm-k.com - * - * Developed for: pfSense.com - * - * Copyright (c) 2010, pfSense.com - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution. - * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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. - * - */ - -require('filter.inc'); - -function widescreen_custom_php_install_command() -{ - exec("mkdir -p /usr/local/pkg/widescreen/backup"); - // Let's backup everything - copy("/usr/local/www/themes/pfsense_ng/all.css", "/usr/local/pkg/widescreen/backup/all.css.bak"); - copy("/usr/local/www/fbegin.inc", "/usr/local/pkg/widescreen/backup/fbegin.inc.bak"); - copy("/usr/local/www/fend.inc", "/usr/local/pkg/widescreen/backup/fend.inc.bak"); - copy("/usr/local/www/index.php", "/usr/local/pkg/widescreen/backup/index.php.bak"); - - // Install patches - copy("/usr/local/pkg/widescreen/all.css_", "/usr/local/www/themes/pfsense_ng/all.css"); - copy("/usr/local/pkg/widescreen/fbegin.inc_", "/usr/local/www/fbegin.inc"); - copy("/usr/local/pkg/widescreen/fend.inc_", "/usr/local/www/fend.inc"); - copy("/usr/local/pkg/widescreen/index.php_", "/usr/local/www/index.php"); - copy("/usr/local/pkg/widescreen/footer-left.png", "/usr/local/www/themes/pfsense_ng/images/footer-left.png"); - copy("/usr/local/pkg/widescreen/footer-middle.png", "/usr/local/www/themes/pfsense_ng/images/footer-middle.png"); - copy("/usr/local/pkg/widescreen/footer-right.png", "/usr/local/www/themes/pfsense_ng/images/footer-right.png"); - copy("/usr/local/pkg/widescreen/header-mid.png", "/usr/local/www/themes/pfsense_ng/images/header-mid.png"); - copy("/usr/local/pkg/widescreen/horiz-left.png", "/usr/local/www/themes/pfsense_ng/images/horiz-left.png"); - copy("/usr/local/pkg/widescreen/horiz-right.png", "/usr/local/www/themes/pfsense_ng/images/horiz-right.png"); -} - -function widescreen_custom_php_deinstall_command() -{ - copy("/usr/local/pkg/widescreen/backup/all.css.bak", "/usr/local/www/themes/pfsense_ng/all.css"); - copy("/usr/local/pkg/widescreen/backup/fbegin.inc.bak", "/usr/local/www/fbegin.inc"); - copy("/usr/local/pkg/widescreen/backup/fend.inc.bak", "/usr/local/www/fend.inc"); - copy("/usr/local/pkg/widescreen/backup/index.php.bak", "/usr/local/www/index.php"); - exec("rm /usr/local/www/themes/pfsense_ng/images/footer-left.png"); - exec("rm /usr/local/www/themes/pfsense_ng/images/footer-middle.png"); - exec("rm /usr/local/www/themes/pfsense_ng/images/footer-right.png"); - exec("rm /usr/local/www/themes/pfsense_ng/images/header-mid.png"); - exec("rm /usr/local/www/themes/pfsense_ng/images/horiz-left.png"); - exec("rm /usr/local/www/themes/pfsense_ng/images/horiz-right.png"); - exec("rm -r /usr/local/pkg/widescreen"); -} - -?>
\ No newline at end of file diff --git a/config/widescreen/widescreen.xml b/config/widescreen/widescreen.xml deleted file mode 100644 index 0692b533..00000000 --- a/config/widescreen/widescreen.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<packagegui> - <description>Widescreen theme</description> - <requirements></requirements> - <name>widescreen</name> - <version>0.2</version> - <title>widescreen</title> - <aftersaveredirect></aftersaveredirect> - <include_file>/usr/local/pkg/widescreen/widescreen.inc</include_file> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>077</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/widescreen.inc</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/all.css_</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/fbegin.inc_</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/fend.inc_</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/footer-left.png</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/footer-middle.png</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/footer-right.png</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/header-mid.png</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/horiz-left.png</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/horiz-right.png</item> - </additional_files_needed> - <additional_files_needed> - <prefix>/usr/local/pkg/widescreen/</prefix> - <chmod>644</chmod> - <item>https://packages.pfsense.org/packages/config/widescreen/bin/index.php_</item> - </additional_files_needed> - <custom_php_install_command> - widescreen_custom_php_install_command(); - </custom_php_install_command> - <custom_php_deinstall_command> - widescreen_custom_php_deinstall_command(); - </custom_php_deinstall_command> -</packagegui> diff --git a/config/widget-antivirus/antivirus_status.widget.php b/config/widget-antivirus/antivirus_status.widget.php index 6bca68a2..9c18d3f6 100644 --- a/config/widget-antivirus/antivirus_status.widget.php +++ b/config/widget-antivirus/antivirus_status.widget.php @@ -1,108 +1,96 @@ <?php /* - $Id: antivirus_statistics.widget.php - Copyright (C) 2010 Serg Dvoriancev <dv_serg@mail.ru>. - Part of pfSense widgets (www.pfsense.org) - originally based on m0n0wall (http://m0n0.ch/wall) - - Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net> - and Jonathan Watt <jwatt@jwatt.org>. - 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. + antivirus_status.widget.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2010 Serg Dvoriancev <dv_serg@mail.ru> + 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. */ - require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); -define('PATH_CLAMDB', '/var/db/clamav'); -$pfSversion = str_replace("\s", "", file_get_contents("/etc/version")); -if(preg_match("/^2.0/",$pfSversion)) - define('PATH_HAVPLOG', '/var/log/havp/access.log'); -else - define('PATH_HAVPLOG', '/var/log/access.log'); - +define('PATH_CLAMDB', '/var/db/clamav'); +define('PATH_HAVPLOG', '/var/log/access.log'); define('PATH_AVSTATUS', '/var/tmp/havp.status'); - -if (file_exists("/usr/local/pkg/havp.inc")) - require_once("/usr/local/pkg/havp.inc"); -else echo "No havp.inc found"; - -function havp_avdb_info($filename) -{ - $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; - $r = ''; - $path = PATH_CLAMDB . "/{$filename}"; - if (file_exists($path)) { - $handle = ''; - if ($handle = fopen($path, "r")) { - $s = fread($handle, 1024); - $s = explode(':', $s); - - # datetime - $dt = explode(" ", $s[1]); - $s[1] = strftime("%Y.%m.%d", strtotime("{$dt[0]} {$dt[1]} {$dt[2]}")); - if ($s[0] == 'ClamAV-VDB') - $r .= "<tr class='listr'><td>{$filename}</td><td $stl>{$s[1]}</td><td $stl>{$s[2]}</td><td $stl>{$s[7]}</td></tr>"; - } - fclose($handle); - } - return $r; +if (file_exists("/usr/local/pkg/havp.inc")) { + require_once("/usr/local/pkg/havp.inc"); +} else { + echo "No havp.inc found. You must have HAVP package installed to use this widget."; } -function dwg_avbases_info() -{ - $db = '<table width="100%" border="0" cellspacing="0" cellpadding="1" ><tbody>'; - $db .= '<tr class="vncellt" ><td>Database</td><td>Date</td><td>Ver.</td><td>Builder</td></tr>'; - $db .= havp_avdb_info("daily.cld"); - $db .= havp_avdb_info("daily.cvd"); - $db .= havp_avdb_info("bytecode.cld"); - $db .= havp_avdb_info("bytecode.cvd"); - $db .= havp_avdb_info("main.cld"); - $db .= havp_avdb_info("main.cvd"); - $db .= havp_avdb_info("safebrowsing.cld"); - $db .= havp_avdb_info("safebrowsing.cvd"); - $db .= '</tbody></table>'; - return $db; +function havp_avdb_info($filename) { + $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; + $r = ''; + $path = PATH_CLAMDB . "/{$filename}"; + if (file_exists($path)) { + $handle = ''; + if ($handle = fopen($path, "r")) { + $s = fread($handle, 1024); + $s = explode(':', $s); + # datetime + $dt = explode(" ", $s[1]); + $s[1] = strftime("%Y.%m.%d", strtotime("{$dt[0]} {$dt[1]} {$dt[2]}")); + if ($s[0] == 'ClamAV-VDB') { + $r .= "<tr class='listr'><td>{$filename}</td><td $stl>{$s[1]}</td><td $stl>{$s[2]}</td><td $stl>{$s[7]}</td></tr>"; + } + fclose($handle); + } + return $r; + } } -function avupdate_status() -{ - $s = "Not found."; - if (HVDEF_UPD_STATUS_FILE && file_exists(HVDEF_UPD_STATUS_FILE)) - $s = file_get_contents(HVDEF_UPD_STATUS_FILE); - return str_replace( "\n", "<br>", $s ); +function dwg_avbases_info() { + $db = '<table width="100%" border="0" cellspacing="0" cellpadding="1"><tbody>'; + $db .= '<tr class="vncellt" ><td>Database</td><td>Date</td><td>Ver.</td><td>Builder</td></tr>'; + $db .= havp_avdb_info("daily.cld"); + $db .= havp_avdb_info("daily.cvd"); + $db .= havp_avdb_info("bytecode.cld"); + $db .= havp_avdb_info("bytecode.cvd"); + $db .= havp_avdb_info("main.cld"); + $db .= havp_avdb_info("main.cvd"); + $db .= havp_avdb_info("safebrowsing.cld"); + $db .= havp_avdb_info("safebrowsing.cvd"); + $db .= '</tbody></table>'; + return $db; } -function dwg_av_statistic() -{ - $s = "Unknown."; - if (file_exists(PATH_HAVPLOG)) { - $log = file_get_contents(PATH_HAVPLOG); +function avupdate_status() { + $s = "Not found."; + if (HVDEF_UPD_STATUS_FILE && file_exists(HVDEF_UPD_STATUS_FILE)) { + $s = file_get_contents(HVDEF_UPD_STATUS_FILE); + return str_replace( "\n", "<br />", $s ); + } +} -$count = substr_count(strtolower($log), "virus clamd:"); -$s = "Found $count viruses (total)."; +function dwg_av_statistic() { + $s = "Unknown."; + if (file_exists(PATH_HAVPLOG)) { + $log = file_get_contents(PATH_HAVPLOG); + $count = substr_count(strtolower($log), "virus clamd:"); + $s = "Found $count viruses (total)."; /* # slowly worked - need apply cache or preparse stat @@ -123,59 +111,49 @@ $s = "Found $count viruses (total)."; $s .= "<tr align='center'><td>0</td><td>0</td><td>0</td><td>$count</td></tr>"; $s .= "</tbody></table>"; */ - } - - return $s; + } + return $s; } ?> - <table width="100%" border="0" cellspacing="0" cellpadding="0"> - <tbody> - <tr> - <td class="vncellt">HTTP Scanner</td> - <td class="listr" width=75%> - <?php - # havp version - echo exec("pkg_info | grep \"[h]avp\""); - ?> - </td> - </tr> - <tr> - <td class="vncellt">Antivirus Scanner</td> - <td class="listr" width=75%> - <?php - # Clamd version - echo exec("clamd -V"); - ?> - </td> - </tr> - <tr> - <td class="vncellt">Antivirus Bases</td> - <td class="listr" width=75%> - <?php - # Antivirus bases - if (function_exists("dwg_avbases_info")) - echo dwg_avbases_info(); - ?> - </td> - </tr> - <tr> - <td class="vncellt">Last Update</td> - <td class="listr" width=75%> - <?php - echo avupdate_status(); - ?> - </td> - </tr> - <tr> - <td class="vncellt">Statistic</td> - <td class="listr" width=75%> - <?php - echo dwg_av_statistic(); - ?> - </td> - </tr> - </tbody> - </table> - +<table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tbody> + <tr> + <td class="vncellt">HTTP Scanner</td> + <td class="listr" width="75%"> + <?php + // HAVP version; note - obviously broken now + echo exec("pkg_info | grep \"[h]avp\""); + ?> + </td> + </tr> + <tr> + <td class="vncellt">Antivirus Scanner</td> + <td class="listr" width="75%"> + <?php + // ClamD version + echo exec("clamd -V"); + ?> + </td> + </tr> + <tr> + <td class="vncellt">Antivirus Bases</td> + <td class="listr" width="75%"> + <?php echo dwg_avbases_info(); ?> + </td> + </tr> + <tr> + <td class="vncellt">Last Update</td> + <td class="listr" width="75%"> + <?php echo avupdate_status(); ?> + </td> + </tr> + <tr> + <td class="vncellt">Statistics</td> + <td class="listr" width="75%"> + <?php echo dwg_av_statistic(); ?> + </td> + </tr> + </tbody> +</table> diff --git a/config/widget-antivirus/widget-antivirus.xml b/config/widget-antivirus/widget-antivirus.xml index 468baf13..91a6a392 100644 --- a/config/widget-antivirus/widget-antivirus.xml +++ b/config/widget-antivirus/widget-antivirus.xml @@ -4,64 +4,59 @@ <packagegui> <copyright> <![CDATA[ -/* $Id$ */ -/* ========================================================================== */ +/* $Id$ */ +/* ====================================================================================== */ /* - widget-antivirus.xml - part of pfSense (http://www.pfSense.com) - Copyright (C) 2009 Jim Pingle - All rights reserved. - - Based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. - All rights reserved. - */ -/* ========================================================================== */ + widget-antivirus.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 Jim Pingle + 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: + 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. - 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. - 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. - */ -/* ========================================================================== */ + 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>Antivirus status widget add-on for Dashboard package and HAVP</description> - <requirements>Dashboard package and HAVP</requirements> - <faq>Currently there are no FAQ items provided.</faq> + <description>Antivirus status widget add-on for HAVP</description> + <requirements>HAVP package</requirements> <name>widget-antivirus</name> - <version>0.1</version> + <version>0.1.1</version> <title>Widget - Antivirus Status</title> <include_file>/usr/local/pkg/widget-antivirus.inc</include_file> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> - <chmod>077</chmod> <item>https://packages.pfsense.org/packages/config/widget-antivirus/widget-antivirus.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/include/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/widget-antivirus/antivirus_status.inc</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/widgets/widgets/</prefix> - <chmod>0644</chmod> <item>https://packages.pfsense.org/packages/config/widget-antivirus/antivirus_status.widget.php</item> </additional_files_needed> <custom_php_deinstall_command> |