aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/bacula-client/bacula-client.inc182
-rw-r--r--config/bacula-client/bacula-client.xml115
-rw-r--r--config/bacula-client/bacula-client_fd.xml96
-rw-r--r--config/bacula-client/bacula-client_view_config.php58
-rw-r--r--config/bandwidthd/bandwidthd.inc422
-rw-r--r--config/bandwidthd/bandwidthd.xml308
-rw-r--r--config/cron/cron.inc65
-rw-r--r--config/cron/cron.php199
-rw-r--r--config/cron/cron.xml63
-rw-r--r--config/cron/cron_edit.php238
-rw-r--r--config/cron/index.php2
-rw-r--r--config/diag_states_pt/diag_new_states.php362
-rw-r--r--config/diag_states_pt/diag_new_states.xml78
-rw-r--r--config/filemgr/file_manager.php497
-rw-r--r--config/filemgr/file_manager.tmp595
-rw-r--r--config/filemgr/filemgr.inc152
-rw-r--r--config/filemgr/filemgr.xml191
-rw-r--r--config/filemgr/index.php44
-rw-r--r--config/filemgr/index.tmp11
-rw-r--r--config/filemgr/rbfminc/config.php123
-rw-r--r--config/filemgr/rbfminc/config.tmp95
-rw-r--r--config/filemgr/rbfminc/download.php69
-rw-r--r--config/filemgr/rbfminc/download.tmp49
-rw-r--r--config/filemgr/rbfminc/functions.php221
-rw-r--r--config/filemgr/rbfminc/functions.tmp189
-rw-r--r--config/filemgr/rbfminc/rename.php68
-rw-r--r--config/filemgr/rbfminc/rename.tmp41
-rw-r--r--config/filemgr/rbfminc/session.php58
-rw-r--r--config/filemgr/rbfminc/session.tmp32
-rw-r--r--config/lcdproc/lcdproc_client.php58
-rw-r--r--config/open-vm-tools/open-vm-tools.inc172
-rw-r--r--config/open-vm-tools/open-vm-tools.xml65
-rw-r--r--config/open-vm-tools_2/open-vm-tools.inc76
-rw-r--r--config/open-vm-tools_2/open-vm-tools.xml98
-rw-r--r--config/phpservice/phpservice.inc223
-rw-r--r--config/phpservice/phpservice.xml127
-rw-r--r--config/phpservice/phpservice_php.php151
-rw-r--r--config/phpservice/phpservice_php.tmp192
-rw-r--r--config/phpservice/phpservice_php_edit.php180
-rw-r--r--config/phpservice/phpservice_php_edit.tmp225
-rw-r--r--config/routed/routed.inc102
-rw-r--r--config/routed/routed.xml92
-rw-r--r--config/syslog-ng/syslog-ng.inc262
-rw-r--r--config/syslog-ng/syslog-ng.xml97
-rw-r--r--config/syslog-ng/syslog-ng_advanced.xml74
-rw-r--r--config/syslog-ng/syslog-ng_log_viewer.php114
-rw-r--r--config/systempatches/patches.inc5
-rw-r--r--config/systempatches/system_patches.php20
-rw-r--r--config/systempatches/system_patches_edit.php4
-rw-r--r--config/systempatches/systempatches.xml26
-rw-r--r--config/vhosts/system_advanced_create_certs.php (renamed from config/vhosts/system_advanced_create_certs.tmp)75
-rw-r--r--config/vhosts/vhosts.inc1175
-rw-r--r--config/vhosts/vhosts.xml127
-rw-r--r--config/vhosts/vhosts_php.php (renamed from config/vhosts/vhosts_php.tmp)122
-rw-r--r--config/vhosts/vhosts_php_edit.php299
-rw-r--r--config/vhosts/vhosts_php_edit.tmp324
-rw-r--r--config/vnstat/vnstat.inc231
-rw-r--r--config/vnstat/vnstat.xml33
58 files changed, 4081 insertions, 5291 deletions
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 b57b2732..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,181 +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();
- 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();
}
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();
-
- /* 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.
#
@@ -211,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;
@@ -274,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 {
@@ -289,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
@@ -355,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);
}
@@ -378,19 +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();
- 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&amp;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&amp;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&amp;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.&lt;br&gt;
- 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.&nbsp;
+ 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).&nbsp;
+ 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.&lt;br&gt;
- Get the postgreSQL schema and PHP files to display the results from: &lt;a target="_new" href="https://github.com/individual-it/bandwidthd-pSQL-frontend"&gt;https://github.com/individual-it/bandwidthd-pSQL-frontend&lt;/a&gt;</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.&lt;br&gt;
- 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.&lt;br&gt;
- &lt;table cellpadding=1 cellspacing=0 style=&quot;text-align: left;&quot;&gt; &lt;tbody&gt;
- &lt;tr&gt;&lt;th&gt; &lt;/th&gt;&lt;th&gt; Data Interval &lt;/th&gt;&lt;th&gt; Graph Span &lt;/th&gt;&lt;th&gt; Log Rotation &lt;/th&gt;&lt;th&gt; Log File Name &lt;/th&gt;&lt;/tr&gt;
- &lt;tr&gt;&lt;th&gt; Daily &lt;/th&gt;&lt;td&gt; 200 seconds &lt;/td&gt;&lt;td&gt; 2 days &lt;/td&gt;&lt;td&gt; 1 day &lt;/td&gt;&lt;td&gt; log.1.[0-5].cdf &lt;/td&gt;&lt;/tr&gt;
- &lt;tr&gt;&lt;th&gt; Weekly &lt;/th&gt;&lt;td&gt; 10 minutes &lt;/td&gt;&lt;td&gt; 7 days &lt;/td&gt;&lt;td&gt; 7 days &lt;/td&gt;&lt;td&gt; log.2.[0-5].cdf &lt;/td&gt;&lt;/tr&gt;
- &lt;tr&gt;&lt;th&gt; Monthly &lt;/th&gt;&lt;td&gt; 1 hour &lt;/td&gt;&lt;td&gt; 35 days &lt;/td&gt;&lt;td&gt; 35 days &lt;/td&gt;&lt;td&gt; log.3.[0-5].cdf &lt;/td&gt;&lt;/tr&gt;
- &lt;tr&gt;&lt;th&gt; Yearly &lt;/th&gt;&lt;td&gt; 12 hours &lt;/td&gt;&lt;td&gt; 412.5 days &lt;/td&gt;&lt;td&gt; 412.5 days &lt;/td&gt;&lt;td&gt; log.4.[0-5].cdf &lt;/td&gt;&lt;/tr&gt;
- &lt;/tbody&gt; &lt;/table&gt;
+ <fielddescr>Advanced Filter</fielddescr>
+ <fieldname>advfilter</fieldname>
+ <description>
+ <![CDATA[
+ Libpcap format filter string used to control what traffic is counted.&nbsp;
+ Please, refer to <a href="https://www.freebsd.org/cgi/man.cgi?query=pcap-filter&amp;sektion=7&amp;apropos=0&amp;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 a457cf58..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,63 +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();
-
- //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();
-
-}
-
-
-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'];?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';">
- <?=$ent['hour'];?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';">
- <?=$ent['mday'];?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';">
- <?=$ent['month'];?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';">
- <?=$ent['wday'];?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';">
- <?=$ent['who'];?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';">
- <?=$ent['command'];?>&nbsp;
- </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&amp;act=del&amp;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'];?>&nbsp;</td>
+ <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['hour'];?>&nbsp;</td>
+ <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['mday'];?>&nbsp;</td>
+ <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['month'];?>&nbsp;</td>
+ <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['wday'];?>&nbsp;</td>
+ <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['who'];?>&nbsp;</td>
+ <td class="listr" ondblclick="document.location='cron_edit.php?id=<?=$i;?>';"><?=$ent['command'];?>&nbsp;</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&amp;act=del&amp;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">&nbsp;</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">&nbsp;</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/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 "&amp;sort=asc";
+ }
+ return "&amp;sort=des";
+ } else {
+ return "&amp;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 "&nbsp;";
+ }
}
}
// 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 = '&amp;sfilter=' . $_GET['sfilter'];
+ } else {
unset ($_GET['sfilter']);
+ }
}
if ($_GET['dfilter']) {
if (is_ipaddr($_GET['dfilter'])) {
$dfilter = $_GET['dfilter'];
- $filterPassThru = '&dfilter=' . $_GET['dfilter'];
- }
- else
+ $filterPassThru = '&amp;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 .= "&amp;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?&amp;order=bytes&amp;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 .= "&amp;view=1";
+ $viewPassThru = "&amp;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">&nbsp;</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&amp;order=bytes&amp;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">&nbsp;</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\">&nbsp;</th>
+ <th>Name</th>
+ <th colspan=\"5\">&nbsp;</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 = "&nbsp;";
+ $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>&nbsp;</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>&nbsp;</td>
+ <td>
+ <img width=\"16\" height=\"16\" src=\"rbfmimg/ico_delete.png\" alt=\"D\" title=\"Delete\" onclick=\"if(confirm('Delete folder &quot;{$v}&quot;?') &amp;&amp; confirm('You cannot undo this operation!!!') &amp;&amp; confirm('To delete this folder &quot;{$v}&quot; press OK\\nTo cancel this operation press CANCEL')){document.location = 'file_manager.php?p=".urlencode($current_folder)."&amp;do=delete&amp;file=".urlencode($v)."&amp;type=directory'}\" />
+ </td>
+ <td class=\"srow\">&nbsp;</td>
+ <td><b>&lt;DIR&gt;</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)."&amp;f=".urlencode($v)."&amp;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 = "&nbsp;";
+ }
+
+ $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 = "&nbsp;";
+ $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)."&amp;file_name=".urlencode($v)."'\" />
+ </td>
+ <td>
+ <div style=\"padding-top:2px;\" id=\"f{$id}\" ondblclick=\"document.location = 'rbfminc/download.php?p=".urlencode($current_folder)."&amp;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)."&amp;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 &quot;{$v}&quot;?') &amp;&amp; confirm('You cannot undo this operation!!!') &amp;&amp; confirm('To delete this file &quot;{$v}&quot; press OK\\nTo cancel this operation press CANCEL')){document.location = 'file_manager.php?p=".urlencode($current_folder)."&amp;do=delete&amp;file=".urlencode($v)."&amp;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" />
+ &nbsp;&nbsp;
+ <input name="replace_file" type="checkbox" value="1" />
+ Replace existing file &nbsp;&nbsp;
+ <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">
+ &nbsp;&nbsp;&nbsp;&nbsp;Create new folder here;&nbsp;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 ] &nbsp; &nbsp;
+ [ <img src="rbfmimg/ico_download.png" width="16" height="16" align="middle" alt="download" /> DOWNLOAD ] &nbsp; &nbsp;
+ [ <img src="rbfmimg/ico_rename.png" width="16" height="16" align="middle" alt="rename" /> RENAME ] &nbsp; &nbsp;
+ [ <img src="rbfmimg/ico_script_edit.png" width="16" height="16" align="middle" alt="view" /> VIEW/EDIT ] &nbsp; &nbsp;
+ [ <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 &raquo;" /></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\">&nbsp;</th>
- <th>Name</th>
- <th colspan=\"5\">&nbsp;</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 = "&nbsp;";
- $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>&nbsp;</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>&nbsp;</td>
- <td>
- <img width=\"16\" height=\"16\"
- src=\"rbfmimg/ico_delete.png\"
- alt=\"D\"
- title=\"Delete\"
- onclick=\"
- if(
- confirm('Delete folder &quot;{$v}&quot;?') &amp;&amp;
- confirm('You cannot undo this operation!!!') &amp;&amp;
- confirm('To delete this folder &quot;{$v}&quot; press OK\\nTo cancel this operation press CANCEL')
- ){
- document.location = 'file_manager.php?p=".urlencode($current_folder)."&amp;do=delete&amp;file=".urlencode($v)."&amp;type=directory'
- }
- \"
- />
- </td>
- <td class=\"srow\">&nbsp;</td>
- <td><b>&lt;DIR&gt;</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)."&amp;f=".urlencode($v)."&amp;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 = "&nbsp;";
- }
-
- $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 = "&nbsp;";
- $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)."&amp;file_name=".urlencode($v)."'\" />
- </td>
- <td>
- <div style=\"padding-top:2px;\"
- id=\"f{$id}\"
- ondblclick=\"document.location = 'rbfminc/download.php?p=".urlencode($current_folder)."&amp;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)."&amp;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 &quot;{$v}&quot;?') &amp;&amp;
- confirm('You cannot undo this operation!!!') &amp;&amp;
- confirm('To delete this file &quot;{$v}&quot; press OK\\nTo cancel this operation press CANCEL')
- ){
- document.location = 'file_manager.php?p=".urlencode($current_folder)."&amp;do=delete&amp;file=".urlencode($v)."&amp;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" />
- &nbsp; &nbsp;
- <input name="replace_file" type="checkbox" value="1" />
- Replace existing file &nbsp; &nbsp;
- <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">
- &nbsp;&nbsp;&nbsp;&nbsp;Create new folder here;&nbsp;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 ] &nbsp; &nbsp;
- [ <img src="rbfmimg/ico_download.png" width="16" height="16" align="middle" alt="download" /> DOWNLOAD ] &nbsp; &nbsp;
- [ <img src="rbfmimg/ico_rename.png" width="16" height="16" align="middle" alt="rename" /> RENAME ] &nbsp; &nbsp;
- [ <img src="rbfmimg/ico_script_edit.png" width="16" height="16" align="middle" alt="view" /> VIEW/EDIT ] &nbsp; &nbsp;
- [ <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 &raquo;" /></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 64186637..00000000
--- a/config/filemgr/filemgr.inc
+++ /dev/null
@@ -1,152 +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();
-
- 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();
-}
-
-
-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();
-}
-
-?>
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/lcdproc/lcdproc_client.php b/config/lcdproc/lcdproc_client.php
index e59e8635..70bd0840 100644
--- a/config/lcdproc/lcdproc_client.php
+++ b/config/lcdproc/lcdproc_client.php
@@ -41,7 +41,7 @@ function get_pfstate() {
} else {
$maxstates = "/10000";
}
- $curentries = shell_exec('/sbin/pfctl -si | grep current');
+ $curentries = shell_exec('/sbin/pfctl -si | /usr/bin/grep current');
if (preg_match("/([0-9]+)/", $curentries, $matches)) {
$curentries = $matches[1];
}
@@ -116,8 +116,8 @@ function get_loadavg_stats() {
}
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);
+ 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);
@@ -176,7 +176,7 @@ function get_slbd_stats() {
$nentries = $config['syslog']['nentries'];
if (!$nentries) {
- $nentries = 50;
+ $nentries = 50;
}
$now = time();
@@ -194,7 +194,7 @@ function get_slbd_stats() {
}
foreach ((array) $vipent['servers'] as $server) {
$lastchange = "";
- $svr = split("\|", $server);
+ $svr = explode("|", $server);
$monitorip = $svr[1];
if (stristr($poolstatus, $monitorip)) {
$online = "Up";
@@ -219,11 +219,11 @@ function get_carp_stats () {
global $config;
if (is_array($config['virtualip']['vip'])) {
- $carpint = 0;
+ $carpint = 0;
$initcount = 0;
$mastercount = 0;
$backupcount = 0;
- foreach($config['virtualip']['vip'] as $carp) {
+ foreach ($config['virtualip']['vip'] as $carp) {
if ($carp['mode'] != "carp") {
continue;
}
@@ -320,7 +320,7 @@ function output_ipsec_tunnel_status($tunnel) {
/* we have no sad array, bail */
return(false);
}
- foreach($sad as $sa) {
+ foreach ($sad as $sa) {
if ($sa['src'] == $interfaceip) {
$foundsrc = true;
}
@@ -348,12 +348,12 @@ function get_ipsec_stats() {
$inactivecounter = 0;
if ($config['ipsec']['tunnel']) {
- foreach ($config['ipsec']['tunnel'] as $tunnel) {
+ foreach ($config['ipsec']['tunnel'] as $tunnel) {
$ipsecstatus = false;
$tun_disabled = "false";
$foundsrc = false;
- $founddst = false;
+ $founddst = false;
if (isset($tunnel['disabled'])) {
$tun_disabled = "true";
@@ -368,7 +368,7 @@ function get_ipsec_stats() {
/* tunnel is down */
$iconfn = "false";
$inactivecounter++;
- }
+ }
}
}
@@ -385,7 +385,7 @@ function send_lcd_commands($lcd, $lcd_cmds) {
lcdproc_warn("Failed to interpret lcd commands");
return;
}
- foreach($lcd_cmds as $lcd_cmd) {
+ foreach ($lcd_cmds as $lcd_cmd) {
$cmd_output = "";
if (! fwrite($lcd, "$lcd_cmd\n")) {
lcdproc_warn("Connection to LCDd process lost $errstr ($errno)");
@@ -405,22 +405,22 @@ function get_lcdpanel_width() {
if (is_null($lcdproc_size_config['size'])) {
return "16";
} else {
- $dimensions = split("x", $lcdproc_size_config['size']);
+ $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 = split("x", $lcdproc_size_config['size']);
+ $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];
@@ -431,28 +431,28 @@ function get_lcdpanel_refresh_frequency() {
return $value;
}
}
-
+
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 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];
+ $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";
@@ -463,10 +463,10 @@ function build_interface($lcd) {
$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) {
+ foreach ($lcdproc_screens_config as $name => $screen) {
if ($screen == "on") {
switch ($name) {
case "scr_time":
@@ -572,7 +572,7 @@ function build_interface($lcd) {
$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;
+ break;
}
add_summary_declaration($lcd_cmds, $name);
}
@@ -598,8 +598,8 @@ function loop_status($lcd) {
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]);
+ $summary_states = explode("/", get_pfstate());
+ $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]);
} else {
$lcd_summary_data = "";
}
@@ -608,9 +608,9 @@ function loop_status($lcd) {
$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) {
+ foreach ((array) $lcdproc_screens_config as $name => $screen) {
if ($screen != "on") {
continue;
}
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/phpservice/phpservice.inc b/config/phpservice/phpservice.inc
index ec2b9bef..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,194 +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();
-
- $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();
+ $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();
-
}
-function phpservice_deinstall_command()
-{
-
+function phpservice_deinstall_command() {
conf_mount_rw();
- $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();
-
}
?>
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&amp;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'];?>&nbsp;</td>
+ <td class="listr" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"><?=$ent['enabled'];?>&nbsp;</td>
+ <td class="listbg" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';"><?=htmlspecialchars($ent['description']);?>&nbsp;</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&amp;act=del&amp;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'];?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';">
- <?=$ent['enabled'];?>&nbsp;
- </td>
- <td class="listbg" ondblclick="document.location='phpservice_php_edit.php?id=<?=$i;?>';">
- <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?>&nbsp;
- </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">&nbsp;</td>
+ <td>
+ <input name="Submit" type="submit" class="formbtn" value="Save" />&nbsp;<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">&nbsp;</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/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&amp;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&amp;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/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/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 = '&nbsp; &nbsp; 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">&nbsp;</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 4cbbb61d..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,261 +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();
- //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'];
@@ -296,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";
+ }
+
+ $tmp .= " \$HTTP[\"host\"] == \"" . $host . "\" {\n";
+ $tmp .= " server.document-root = \"/usr/local/vhosts/" . $directory . "\"\n";
- //enable ssl if the cert and key were both provided
+ // 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);
}
@@ -347,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 = '';
@@ -455,329 +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();
+#### 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",
@@ -786,28 +633,16 @@ function vhosts_install_command() {
);
vhosts_sync_package();
-
- //if (pkg_is_service_running('vhosts')) {
- //documentation purposes
- //}
-
- conf_mount_ro();
-
}
-function vhosts_deinstall_command()
-{
+function vhosts_deinstall_command() {
conf_mount_rw();
- $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();
}
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&amp;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&nbsp;
+ 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&nbsp;
+ 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>&nbsp;
+ <a href='<?=$vhost_url;?>'><?=$ent['host'];?></a>&nbsp;
</td>
<td class="listr" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';">
- <a href='<?=$vhost_url;?>' target='_blank'><?=$ent['port'];?></a>&nbsp;
+ <a href='<?=$vhost_url;?>'><?=$ent['port'];?></a>&nbsp;
</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']);?>&nbsp;
+ <?=htmlspecialchars($ent['description']);?>&nbsp;
</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&amp;act=del&amp;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">&nbsp;</td>
+ <td>
+ <input name="Submit" type="submit" class="formbtn" value="Save" />&nbsp;<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">&nbsp;</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&amp;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>