aboutsummaryrefslogtreecommitdiffstats
path: root/config/vhosts
diff options
context:
space:
mode:
Diffstat (limited to 'config/vhosts')
-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.inc1182
-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
6 files changed, 936 insertions, 1193 deletions
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 1958632e..cf2f97b8 100644
--- a/config/vhosts/vhosts.inc
+++ b/config/vhosts/vhosts.inc
@@ -1,14 +1,11 @@
<?php
-/* $Id$ */
-/*
-/* ========================================================================== */
-/*
- vhosts.inc
- Copyright (C) 2008 Mark J Crane
- All rights reserved.
- */
-/* ========================================================================== */
/*
+ vhosts.inc
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2008 Mark J Crane
+ Copyright (C) 2015 ESF, LLC
+ All rights reserved.
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -30,262 +27,217 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-
-//show errors
- ini_set('display_errors', '1');
- //error_reporting (E_ALL); // Report everything
- //error_reporting (E_ALL ^ E_NOTICE); // Report everything
- error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings
-
-if (!function_exists("pkg_is_service_running")) {
- function pkg_is_service_running($servicename)
- {
- exec("/bin/ps ax | awk '{ print $5 }'", $psout);
- array_shift($psout);
- foreach($psout as $line) {
- $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line)))));
- }
- if(is_service_running($servicename, $ps) or is_process_running($servicename) ) {
- return true;
- }
- else {
- return false;
- }
- }
+//sort array
+function sort_host($a, $b) {
+ return strcmp($a["host"], $b["host"]);
}
-if (!function_exists("byte_convert")) {
- function byte_convert( $bytes ) {
- if ($bytes<=0)
- return '0 Byte';
-
- $convention=1000; //[1000->10^x|1024->2^x]
- $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB');
- $e=floor(log($bytes,$convention));
- return round($bytes/pow($convention,$e),2).' '.$s[$e];
- }
+function sort_port($a, $b) {
+ return strcmp($a["port"], $b["port"]);
}
-//sort array
- function sort_host($a, $b){
- return strcmp($a["host"], $b["host"]);
- }
-
- function sort_port($a, $b){
- return strcmp($a["port"], $b["port"]);
- }
-
- function sort_ip_address($a, $b){
- return natsort($a["ipaddress"], $b["ipaddress"]);
- }
-
+function sort_ip_address($a, $b) {
+ return natsort($a["ipaddress"], $b["ipaddress"]);
+}
-//check to see if the service is installed if it is return the id
- function get_service_id ($service_array, $fieldname, $fieldvalue) {
- $x = 0;
- $id = '';
- foreach($service_array as $rowhelper) {
- if ($rowhelper[$fieldname] == $fieldvalue) {
- $id = $x; //return the id
- }
- $x++;
- }
- if (strlen($id) > 0) {
- return ($id);
- }
- else {
- return false;
+// Check to see if the service is installed if it is return the id
+function get_service_id ($service_array, $fieldname, $fieldvalue) {
+ $x = 0;
+ $id = '';
+ foreach ($service_array as $rowhelper) {
+ if ($rowhelper[$fieldname] == $fieldvalue) {
+ $id = $x; //return the id
}
+ $x++;
}
+ if (strlen($id) > 0) {
+ return ($id);
+ } else {
+ return false;
+ }
+}
-function vhosts_sync_package_php()
-{
+function vhosts_sync_package() {
global $config;
- if($config['installedpackages']['vhosts']['config'] != "") {
-
+ if ($config['installedpackages']['vhosts']['config'] != "") {
conf_mount_rw();
- config_unlock();
-
- //sort the vhosts array
- $vhostarray = $config['installedpackages']['vhosts']['config'];
- if (count(vhostarray) > 1) {
- usort($vhostarray, 'sort_ipaddress');
- usort($vhostarray, 'sort_host');
- usort($vhostarray, 'sort_port');
- }
- $vhostarray_http = '';
- $vhostarray_https = '';
- $x = 0;
- foreach($vhostarray as $rowhelper) {
- if ($rowhelper['enabled'] != "false") {
- if (strlen($rowhelper['certificate']) > 0 && strlen($rowhelper['privatekey']) > 0) {
- $vhostarray_https[$x]['host'] = $rowhelper['host'];
- $vhostarray_https[$x]['ipaddress'] = $rowhelper['ipaddress'];
- $vhostarray_https[$x]['port'] = $rowhelper['port'];
- $vhostarray_https[$x]['directory'] = $rowhelper['directory'];
- $vhostarray_https[$x]['certificate'] = $rowhelper['certificate'];
- $vhostarray_https[$x]['privatekey'] = $rowhelper['privatekey'];
- $vhostarray_https[$x]['enabled'] = $rowhelper['enabled'];
- $vhostarray_https[$x]['description'] = $rowhelper['description'];
- }
- else {
- $vhostarray_http[$x]['host'] = $rowhelper['host'];
- $vhostarray_http[$x]['ipaddress'] = $rowhelper['ipaddress'];
- $vhostarray_http[$x]['port'] = $rowhelper['port'];
- $vhostarray_http[$x]['directory'] = $rowhelper['directory'];
- $vhostarray_http[$x]['certificate'] = '';
- $vhostarray_http[$x]['privatekey'] = '';
- $vhostarray_http[$x]['enabled'] = $rowhelper['enabled'];
- $vhostarray_http[$x]['description'] = $rowhelper['description'];
- $server_port = $rowhelper['port'];
- }
- $x++;
+
+ //sort the vhosts array
+ $vhostarray = $config['installedpackages']['vhosts']['config'];
+ if (count(vhostarray) > 1) {
+ usort($vhostarray, 'sort_ipaddress');
+ usort($vhostarray, 'sort_host');
+ usort($vhostarray, 'sort_port');
+ }
+ $vhostarray_http = '';
+ $vhostarray_https = '';
+ $x = 0;
+ foreach ($vhostarray as $rowhelper) {
+ if ($rowhelper['enabled'] != "false") {
+ if (strlen($rowhelper['certificate']) > 0 && strlen($rowhelper['privatekey']) > 0) {
+ $vhostarray_https[$x]['host'] = $rowhelper['host'];
+ $vhostarray_https[$x]['ipaddress'] = $rowhelper['ipaddress'];
+ $vhostarray_https[$x]['port'] = $rowhelper['port'];
+ $vhostarray_https[$x]['directory'] = $rowhelper['directory'];
+ $vhostarray_https[$x]['certificate'] = $rowhelper['certificate'];
+ $vhostarray_https[$x]['privatekey'] = $rowhelper['privatekey'];
+ $vhostarray_https[$x]['enabled'] = $rowhelper['enabled'];
+ $vhostarray_https[$x]['description'] = $rowhelper['description'];
+ } else {
+ $vhostarray_http[$x]['host'] = $rowhelper['host'];
+ $vhostarray_http[$x]['ipaddress'] = $rowhelper['ipaddress'];
+ $vhostarray_http[$x]['port'] = $rowhelper['port'];
+ $vhostarray_http[$x]['directory'] = $rowhelper['directory'];
+ $vhostarray_http[$x]['certificate'] = '';
+ $vhostarray_http[$x]['privatekey'] = '';
+ $vhostarray_http[$x]['enabled'] = $rowhelper['enabled'];
+ $vhostarray_http[$x]['description'] = $rowhelper['description'];
+ $server_port = $rowhelper['port'];
}
+ $x++;
}
- unset($x);
+ }
+ unset($x);
- //HTTP configuration
+ // HTTP configuration
if (count($vhostarray_http) > 0) {
- $tmp = "#\n";
- $tmp .= "# lighttpd configuration file\n";
- $tmp .= "#\n";
- $tmp .= "# use a it as base for lighttpd 1.0.0 and above\n";
- $tmp .= "#\n";
- $tmp .= "############ Options you really have to take care of ####################\n";
- $tmp .= "\n";
- $tmp .= "## FreeBSD!\n";
- $tmp .= "server.event-handler = \"freebsd-kqueue\"\n";
- $tmp .= "server.network-backend = \"writev\" ## Fixes 7.x upload issues\n";
- $tmp .= "\n";
- $tmp .= "## modules to load\n";
- $tmp .= "server.modules = (\n";
- $tmp .= " \"mod_access\", \"mod_accesslog\",\n";
- $tmp .= " \"mod_fastcgi\", \"mod_cgi\",\"mod_rewrite\"\n";
- $tmp .= " )\n";
- $tmp .= "\n";
- $tmp .= "## Unused modules\n";
- $tmp .= "# \"mod_setenv\",\n";
- $tmp .= "# \"mod_compress\"\n";
- $tmp .= "# \"mod_redirect\",\n";
- $tmp .= "# \"mod_rewrite\",\n";
- $tmp .= "# \"mod_ssi\",\n";
- $tmp .= "# \"mod_usertrack\",\n";
- $tmp .= "# \"mod_expire\",\n";
- $tmp .= "# \"mod_secdownload\",\n";
- $tmp .= "# \"mod_rrdtool\",\n";
- $tmp .= "# \"mod_auth\",\n";
- $tmp .= "# \"mod_status\",\n";
- $tmp .= "# \"mod_alias\",\n";
- $tmp .= "# \"mod_proxy\",\n";
- $tmp .= "# \"mod_simple_vhost\",\n";
- $tmp .= "# \"mod_evhost\",\n";
- $tmp .= "# \"mod_userdir\",\n";
- $tmp .= "# \"mod_cgi\",\n";
- $tmp .= "# \"mod_accesslog\"\n";
- $tmp .= "\n";
- $tmp .= "## a static document-root, for virtual-hosting take look at the\n";
- $tmp .= "## server.virtual-* options\n";
- $tmp .= "server.document-root = \"/usr/local/vhosts/\"\n";
- $tmp .= "\n";
- $tmp .= "# Maximum idle time with nothing being written (php downloading)\n";
- $tmp .= "server.max-write-idle = 999\n";
- $tmp .= "\n";
- $tmp .= "## where to send error-messages to\n";
- $tmp .= "server.errorlog = \"/var/log/lighttpd.error.log\"\n";
- $tmp .= "\n";
- $tmp .= "# files to check for if .../ is requested\n";
- $tmp .= "server.indexfiles = ( \"index.php\", \"index.html\",\n";
- $tmp .= " \"index.htm\", \"default.htm\" )\n";
- $tmp .= "\n";
- $tmp .= "# mimetype mapping\n";
- $tmp .= "mimetype.assign = (\n";
- $tmp .= " \".pdf\" => \"application/pdf\",\n";
- $tmp .= " \".sig\" => \"application/pgp-signature\",\n";
- $tmp .= " \".spl\" => \"application/futuresplash\",\n";
- $tmp .= " \".class\" => \"application/octet-stream\",\n";
- $tmp .= " \".ps\" => \"application/postscript\",\n";
- $tmp .= " \".torrent\" => \"application/x-bittorrent\",\n";
- $tmp .= " \".dvi\" => \"application/x-dvi\",\n";
- $tmp .= " \".gz\" => \"application/x-gzip\",\n";
- $tmp .= " \".pac\" => \"application/x-ns-proxy-autoconfig\",\n";
- $tmp .= " \".swf\" => \"application/x-shockwave-flash\",\n";
- $tmp .= " \".tar.gz\" => \"application/x-tgz\",\n";
- $tmp .= " \".tgz\" => \"application/x-tgz\",\n";
- $tmp .= " \".tar\" => \"application/x-tar\",\n";
- $tmp .= " \".zip\" => \"application/zip\",\n";
- $tmp .= " \".mp3\" => \"audio/mpeg\",\n";
- $tmp .= " \".m3u\" => \"audio/x-mpegurl\",\n";
- $tmp .= " \".wma\" => \"audio/x-ms-wma\",\n";
- $tmp .= " \".wax\" => \"audio/x-ms-wax\",\n";
- $tmp .= " \".ogg\" => \"audio/x-wav\",\n";
- $tmp .= " \".wav\" => \"audio/x-wav\",\n";
- $tmp .= " \".gif\" => \"image/gif\",\n";
- $tmp .= " \".jpg\" => \"image/jpeg\",\n";
- $tmp .= " \".jpeg\" => \"image/jpeg\",\n";
- $tmp .= " \".png\" => \"image/png\",\n";
- $tmp .= " \".xbm\" => \"image/x-xbitmap\",\n";
- $tmp .= " \".xpm\" => \"image/x-xpixmap\",\n";
- $tmp .= " \".xwd\" => \"image/x-xwindowdump\",\n";
- $tmp .= " \".css\" => \"text/css\",\n";
- $tmp .= " \".html\" => \"text/html\",\n";
- $tmp .= " \".htm\" => \"text/html\",\n";
- $tmp .= " \".js\" => \"text/javascript\",\n";
- $tmp .= " \".asc\" => \"text/plain\",\n";
- $tmp .= " \".c\" => \"text/plain\",\n";
- $tmp .= " \".conf\" => \"text/plain\",\n";
- $tmp .= " \".text\" => \"text/plain\",\n";
- $tmp .= " \".txt\" => \"text/plain\",\n";
- $tmp .= " \".dtd\" => \"text/xml\",\n";
- $tmp .= " \".xml\" => \"text/xml\",\n";
- $tmp .= " \".mpeg\" => \"video/mpeg\",\n";
- $tmp .= " \".mpg\" => \"video/mpeg\",\n";
- $tmp .= " \".mov\" => \"video/quicktime\",\n";
- $tmp .= " \".qt\" => \"video/quicktime\",\n";
- $tmp .= " \".avi\" => \"video/x-msvideo\",\n";
- $tmp .= " \".asf\" => \"video/x-ms-asf\",\n";
- $tmp .= " \".asx\" => \"video/x-ms-asf\",\n";
- $tmp .= " \".wmv\" => \"video/x-ms-wmv\",\n";
- $tmp .= " \".bz2\" => \"application/x-bzip\",\n";
- $tmp .= " \".tbz\" => \"application/x-bzip-compressed-tar\",\n";
- $tmp .= " \".tar.bz2\" => \"application/x-bzip-compressed-tar\"\n";
- $tmp .= " )\n";
- $tmp .= "\n";
- $tmp .= "# Use the \"Content-Type\" extended attribute to obtain mime type if possible\n";
- $tmp .= "#mimetypes.use-xattr = \"enable\"\n";
- $tmp .= "\n";
- $tmp .= "#### accesslog module\n";
- $tmp .= "#accesslog.filename = \"/dev/null\"\n";
- $tmp .= "\n";
- $tmp .= "## deny access the file-extensions\n";
- $tmp .= "#\n";
- $tmp .= "# ~ is for backupfiles from vi, emacs, joe, ...\n";
- $tmp .= "# .inc is often used for code includes which should in general not be part\n";
- $tmp .= "# of the document-root\n";
- $tmp .= "url.access-deny = ( \"~\", \".db\" )\n";
- $tmp .= "\n";
- $tmp .= "\n";
- $tmp .= "######### Options that are good to be but not neccesary to be changed #######\n";
- $tmp .= "\n";
- $tmp .= "## bind to port (default: 80)\n";
- $tmp .= "server.port = $server_port\n";
- $tmp .= "\n";
- $tmp .= "#the regex method isn't working\n";
- $tmp .= "#\$HTTP[\"host\"] =~ \"(^|\\.)host01\\.com\$\" {\n";
- $tmp .= "# server.document-root = \"/usr/local/vhosts/host01\"\n";
- $tmp .= "#}\n";
- $tmp .= "\n";
+ $tmp = <<<EOF
+#
+# lighttpd configuration file
+#
+# use a it as base for lighttpd 1.0.0 and above
+#
+############ Options you really have to take care of ####################
+
+## FreeBSD!
+server.event-handler = "freebsd-kqueue"
+server.network-backend = "writev" ## Fixes 7.x upload issues
+
+## modules to load
+server.modules = (
+ "mod_access", "mod_accesslog",
+ "mod_fastcgi", "mod_cgi","mod_rewrite"
+ )
+
+## Unused modules
+# "mod_setenv",
+# "mod_compress"
+# "mod_redirect",
+# "mod_rewrite",
+# "mod_ssi",
+# "mod_usertrack",
+# "mod_expire",
+# "mod_secdownload",
+# "mod_rrdtool",
+# "mod_auth",
+# "mod_status",
+# "mod_alias",
+# "mod_proxy",
+# "mod_simple_vhost",
+# "mod_evhost",
+# "mod_userdir",
+# "mod_cgi",
+# "mod_accesslog"
+
+## a static document-root, for virtual-hosting take look at the
+## server.virtual-* options
+server.document-root = "/usr/local/vhosts/"
+
+# Maximum idle time with nothing being written (php downloading)
+server.max-write-idle = 999
+
+## where to send error-messages to
+server.errorlog = "/var/log/lighttpd.error.log"
+
+# files to check for if .../ is requested
+server.indexfiles = ( "index.php", "index.html",
+ "index.htm", "default.htm" )
+
+# mimetype mapping
+mimetype.assign = (
+ ".pdf" => "application/pdf",
+ ".sig" => "application/pgp-signature",
+ ".spl" => "application/futuresplash",
+ ".class" => "application/octet-stream",
+ ".ps" => "application/postscript",
+ ".torrent" => "application/x-bittorrent",
+ ".dvi" => "application/x-dvi",
+ ".gz" => "application/x-gzip",
+ ".pac" => "application/x-ns-proxy-autoconfig",
+ ".swf" => "application/x-shockwave-flash",
+ ".tar.gz" => "application/x-tgz",
+ ".tgz" => "application/x-tgz",
+ ".tar" => "application/x-tar",
+ ".zip" => "application/zip",
+ ".mp3" => "audio/mpeg",
+ ".m3u" => "audio/x-mpegurl",
+ ".wma" => "audio/x-ms-wma",
+ ".wax" => "audio/x-ms-wax",
+ ".ogg" => "audio/x-wav",
+ ".wav" => "audio/x-wav",
+ ".gif" => "image/gif",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".png" => "image/png",
+ ".xbm" => "image/x-xbitmap",
+ ".xpm" => "image/x-xpixmap",
+ ".xwd" => "image/x-xwindowdump",
+ ".css" => "text/css",
+ ".html" => "text/html",
+ ".htm" => "text/html",
+ ".js" => "text/javascript",
+ ".asc" => "text/plain",
+ ".c" => "text/plain",
+ ".conf" => "text/plain",
+ ".text" => "text/plain",
+ ".txt" => "text/plain",
+ ".dtd" => "text/xml",
+ ".xml" => "text/xml",
+ ".mpeg" => "video/mpeg",
+ ".mpg" => "video/mpeg",
+ ".mov" => "video/quicktime",
+ ".qt" => "video/quicktime",
+ ".avi" => "video/x-msvideo",
+ ".asf" => "video/x-ms-asf",
+ ".asx" => "video/x-ms-asf",
+ ".wmv" => "video/x-ms-wmv",
+ ".bz2" => "application/x-bzip",
+ ".tbz" => "application/x-bzip-compressed-tar",
+ ".tar.bz2" => "application/x-bzip-compressed-tar"
+ )
+
+# Use the "Content-Type" extended attribute to obtain mime type if possible
+#mimetypes.use-xattr = "enable"
+
+#### accesslog module
+#accesslog.filename = "/dev/null"
+
+## deny access the file-extensions
+#
+# ~ is for backupfiles from vi, emacs, joe, ...
+# .inc is often used for code includes which should in general not be part
+# of the document-root
+url.access-deny = ( "~", ".db" )
+
+
+######### Options that are good to be but not neccesary to be changed #######
+
+## bind to port (default: 80)
+server.port = {$server_port}
+
+EOF;
$ipaddress_previous_value = '';
$host_previous_value = '';
$port_previous_value = '';
$ipaddress_and_port_previous_value = '';
- $x=1;
- foreach($vhostarray_http as $rowhelper) {
- if ($rowhelper['enabled'] != "false") {
+ $x = 1;
+ foreach ($vhostarray_http as $rowhelper) {
+ if ($rowhelper['enabled'] != "false") {
$host = $rowhelper['host'];
$ipaddress = $rowhelper['ipaddress'];
$port = $rowhelper['port'];
@@ -297,43 +249,47 @@ function vhosts_sync_package_php()
$privatekey = base64_decode($rowhelper['privatekey']);
}
- //set directory default to the host
- if (strlen($directory) == 0) { $directory = $host; }
+ // Set directory default to the host
+ if (strlen($directory) == 0) {
+ $directory = $host;
+ }
- //if the vhost directory doesn't exist then create it
- //echo '/usr/local/vhosts/'.$directory.'<br />';
- if (!is_dir('/usr/local/vhosts/'.$directory)) {
- exec("mkdir /usr/local/vhosts/".$directory);
- }
- if (!file_exists('/usr/local/vhosts/'.$directory.'/index.php')) {
- $index_file = '/usr/local/vhosts/'.$directory.'/index.php';
- $index_tmp = "<?php\n";
- $index_tmp .= " echo phpinfo();\n";
- $index_tmp .= "?>\n";
- $fout = fopen($index_file,"w");
- fwrite($fout, $index_tmp);
- fclose($fout);
- unset($index_file);
- }
+ // If the vhost directory doesn't exist then create it
+ safe_mkdir("/usr/local/vhosts/{$directory}");
- //set the default port
- if (strlen($port) == 0) { $port = '8001'; }
+ if (!file_exists("/usr/local/vhosts/{$directory}/index.php")) {
+ $index_file = "/usr/local/vhosts/{$directory}/index.php";
+ $index_tmp = "<?php\n";
+ $index_tmp .= " echo phpinfo();\n";
+ $index_tmp .= "?>\n";
+ $fout = fopen($index_file, "w");
+ fwrite($fout, $index_tmp);
+ fclose($fout);
+ unset($index_file);
+ }
- if ($ipaddress.':'.$port != $ipaddress_and_port_previous_value) {
- if ($x > 1) { $tmp .= "}\n\n"; }
- $tmp .= "\$SERVER[\"socket\"] == \"".$ipaddress.":".$port."\" {\n";
+ // Set the default port
+ if (strlen($port) == 0) {
+ $port = '8001';
}
- $tmp .= " \$HTTP[\"host\"] == \"".$host."\" {\n";
- $tmp .= " server.document-root = \"/usr/local/vhosts/".$directory."\"\n";
+ if ($ipaddress . ':' . $port != $ipaddress_and_port_previous_value) {
+ if ($x > 1) {
+ $tmp .= "}\n\n";
+ }
+ $tmp .= "\$SERVER[\"socket\"] == \"" . $ipaddress . ":" . $port . "\" {\n";
+ }
- //enable ssl if the cert and key were both provided
+ $tmp .= " \$HTTP[\"host\"] == \"" . $host . "\" {\n";
+ $tmp .= " server.document-root = \"/usr/local/vhosts/" . $directory . "\"\n";
+
+ // Enable SSL if the cert and key were both provided
if (strlen($rowhelper['certificate']) > 0 && strlen($rowhelper['privatekey']) > 0) {
- $pem_file = "/var/etc/cert-vhosts-".$ipaddress."-".$port.".pem";
- $fout = fopen($pem_file,"w");
+ $pem_file = "/var/etc/cert-vhosts-{$ipaddress}-{$port}.pem";
+ $fout = fopen($pem_file, "w");
fwrite($fout, $certificate.PHP_EOL.$privatekey);
fclose($fout);
- $tmp .= " ssl.pemfile = \"".$pem_file."\"\n";
+ $tmp .= " ssl.pemfile = \"" . $pem_file . "\"\n";
$tmp .= " ssl.engine = \"enable\"\n";
unset($pem_file);
}
@@ -348,94 +304,58 @@ function vhosts_sync_package_php()
$x++;
}
}
- $tmp .= "}\n";
-
-
- /*
- $tmp .= "\$SERVER[\"socket\"] == \"10.7.0.1:8001\" {\n";
- $tmp .= " \$HTTP[\"host\"] == \"vhost01.com\" {\n";
- $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n";
- $tmp .= " #ssl.engine = \"enable\"\n";
- $tmp .= " server.document-root = \"/usr/local/vhosts/host01\"\n";
- $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n";
- $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n";
- $tmp .= " #server.error-handler-404 = \"/e404.php\"\n";
- $tmp .= " }\n";
- $tmp .= "\n";
- $tmp .= " \$HTTP[\"host\"] == \"vhost03.com\" {\n";
- $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n";
- $tmp .= " #ssl.engine = \"enable\"\n";
- $tmp .= " server.document-root = \"/usr/local/vhosts/host03\"\n";
- $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n";
- $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n";
- $tmp .= " #server.error-handler-404 = \"/e404.php\"\n";
- $tmp .= " }\n";
- $tmp .= "}\n";
- $tmp .= "\n";
- $tmp .= "\$SERVER[\"socket\"] == \"10.7.0.1:8002\" {\n";
- $tmp .= " \$HTTP[\"host\"] == \"vhost02.com\" {\n";
- $tmp .= " #ssl.pemfile = \"/var/www/certs/localhost.pem\"\n";
- $tmp .= " #ssl.engine = \"enable\"\n";
- $tmp .= " server.document-root = \"/usr/local/vhosts/host02\"\n";
- $tmp .= " #server.errorlog = \"/var/log/lighttpd/nixcraft/error.log\"\n";
- $tmp .= " #accesslog.filename = \"/var/log/lighttpd/nixcraft/access.log\"\n";
- $tmp .= " #server.error-handler-404 = \"/e404.php\"\n";
- $tmp .= " }\n";
- $tmp .= "}\n";
- */
- $tmp .= "\n";
- $tmp .= "## error-handler for status 404\n";
- $tmp .= "#server.error-handler-404 = \"/error-handler.html\"\n";
- $tmp .= "#server.error-handler-404 = \"/error-handler.php\"\n";
- $tmp .= "\n";
- $tmp .= "## to help the rc.scripts\n";
- $tmp .= "server.pid-file = \"/var/run/vhosts-http.pid\"\n";
- $tmp .= "\n";
- $tmp .= "## virtual directory listings\n";
- $tmp .= "server.dir-listing = \"disable\"\n";
- $tmp .= "\n";
- $tmp .= "## enable debugging\n";
- $tmp .= "debug.log-request-header = \"disable\"\n";
- $tmp .= "debug.log-response-header = \"disable\"\n";
- $tmp .= "debug.log-request-handling = \"disable\"\n";
- $tmp .= "debug.log-file-not-found = \"disable\"\n";
- $tmp .= "\n";
- $tmp .= "#### compress module\n";
- $tmp .= "#compress.cache-dir = \"/tmp/lighttpd/cache/compress/\"\n";
- $tmp .= "#compress.filetype = (\"text/plain\", \"text/html\")\n";
- $tmp .= "\n";
- $tmp .= "#server.network-backend = \"writev\"\n";
- $tmp .= "server.upload-dirs = ( \"/root/\", \"/tmp/\", \"/var/\" )\n";
- $tmp .= "server.max-request-size = 2097152\n";
- $tmp .= "\n";
- $tmp .= "#### fastcgi module\n";
- $tmp .= "## read fastcgi.txt for more info\n";
- $tmp .= "fastcgi.server = ( \".php\" =>\n";
- $tmp .= " ( \"localhost\" =>\n";
- $tmp .= " (\n";
- $tmp .= " \"socket\" => \"/tmp/php5-fastcgi.socket\",\n";
- $tmp .= " \"min-procs\" => 1,\n";
- $tmp .= " \"max-procs\" => 1,\n";
- $tmp .= " \"idle-timeout\" => 0,\n";
- $tmp .= " \"bin-environment\" => (\n";
- $tmp .= " \"PHP_FCGI_MAX_REQUESTS\" => \"500\",\n";
- $tmp .= " \"PHP_FCGI_CHILDREN\" => \"1\"\n";
- $tmp .= " ),\n";
- $tmp .= " \"bin-path\" => \"/usr/local/bin/php\"\n";
- $tmp .= " )\n";
- $tmp .= " )\n";
- $tmp .= ")\n";
- $tmp .= "\n";
- $tmp .= "#### CGI module\n";
- $tmp .= "cgi.assign = ( \".cgi\" => \"\" )\n";
-
- $fout = fopen("/var/etc/vhosts-http.conf","w");
+
+ $tmp .= <<<EOF
+}
+
+## error-handler for status 404
+#server.error-handler-404 = "/error-handler.html"
+#server.error-handler-404 = "/error-handler.php"
+
+## to help the rc.scripts
+server.pid-file = "/var/run/vhosts-http.pid"
+
+## virtual directory listings
+server.dir-listing = "disable"
+
+## enable debugging
+debug.log-request-header = "disable"
+debug.log-response-header = "disable"
+debug.log-request-handling = "disable"
+debug.log-file-not-found = "disable"
+
+#### compress module
+#compress.cache-dir = "/tmp/lighttpd/cache/compress/"
+#compress.filetype = ("text/plain", "text/html")
+
+#server.network-backend = "writev"
+server.upload-dirs = ( "/root/", "/tmp/", "/var/" )
+server.max-request-size = 2097152
+
+#### fastcgi module
+## read fastcgi.txt for more info
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "socket" => "/var/run/php-fpm.socket",
+ "broken-scriptfilename" => "enable"
+ )
+ )
+)
+
+#### CGI module
+cgi.assign = ( ".cgi" => "" )
+
+EOF;
+
+ $fout = fopen("/var/etc/vhosts-http.conf", "w");
fwrite($fout, $tmp);
unset($tmp);
fclose($fout);
- } //end (if count(vhostarray_http) > 0)
+ // END (if count(vhostarray_http) > 0)
+ }
- //HTTPS configuration
+ // HTTPS configuration
$ipaddress_previous_value = '';
$host_previous_value = '';
$port_previous_value = '';
@@ -456,330 +376,255 @@ function vhosts_sync_package_php()
$privatekey = base64_decode($rowhelper['privatekey']);
}
- //set directory default to the host
- if (strlen($directory) == 0) { $directory = $host; }
+ // Set directory default to the host
+ if (strlen($directory) == 0) {
+ $directory = $host;
+ }
- //if the vhost directory doesn't exist then create it
- //echo '/usr/local/vhosts/'.$directory.'<br />';
- if (!is_dir('/usr/local/vhosts/'.$directory)) {
- exec("mkdir /usr/local/vhosts/".$directory);
- }
- if (!file_exists('/usr/local/vhosts/'.$directory.'/index.php')) {
- $index_file = '/usr/local/vhosts/'.$directory.'/index.php';
- $index_tmp = "<?php\n";
- $index_tmp .= " echo phpinfo();\n";
- $index_tmp .= "?>\n";
- $fout = fopen($index_file,"w");
- fwrite($fout, $index_tmp);
- fclose($fout);
- unset($index_file);
- }
+ // If the vhost directory doesn't exist then create it
+ safe_mkdir("/usr/local/vhosts/{$directory}");
- //set the default port
- if (strlen($port) == 0) { $port = '443'; }
-
- $tmp = "#\n";
- $tmp .= "# lighttpd configuration file\n";
- $tmp .= "#\n";
- $tmp .= "# use a it as base for lighttpd 1.0.0 and above\n";
- $tmp .= "#\n";
- $tmp .= "############ Options you really have to take care of ####################\n";
- $tmp .= "\n";
- $tmp .= "## FreeBSD!\n";
- $tmp .= "server.event-handler = \"freebsd-kqueue\"\n";
- $tmp .= "server.network-backend = \"writev\" ## Fixes 7.x upload issues\n";
- $tmp .= "\n";
- $tmp .= "## modules to load\n";
- $tmp .= "server.modules = (\n";
- $tmp .= " \"mod_access\", \"mod_accesslog\",\n";
- $tmp .= " \"mod_fastcgi\", \"mod_cgi\",\"mod_rewrite\"\n";
- $tmp .= " )\n";
- $tmp .= "\n";
- $tmp .= "## Unused modules\n";
- $tmp .= "# \"mod_setenv\",\n";
- $tmp .= "# \"mod_compress\"\n";
- $tmp .= "# \"mod_redirect\",\n";
- $tmp .= "# \"mod_rewrite\",\n";
- $tmp .= "# \"mod_ssi\",\n";
- $tmp .= "# \"mod_usertrack\",\n";
- $tmp .= "# \"mod_expire\",\n";
- $tmp .= "# \"mod_secdownload\",\n";
- $tmp .= "# \"mod_rrdtool\",\n";
- $tmp .= "# \"mod_auth\",\n";
- $tmp .= "# \"mod_status\",\n";
- $tmp .= "# \"mod_alias\",\n";
- $tmp .= "# \"mod_proxy\",\n";
- $tmp .= "# \"mod_simple_vhost\",\n";
- $tmp .= "# \"mod_evhost\",\n";
- $tmp .= "# \"mod_userdir\",\n";
- $tmp .= "# \"mod_cgi\",\n";
- $tmp .= "# \"mod_accesslog\"\n";
- $tmp .= "\n";
- $tmp .= "## a static document-root, for virtual-hosting take look at the\n";
- $tmp .= "## server.virtual-* options\n";
- $tmp .= "\n";
- $tmp .= "## ".$description." \n\n";
- $tmp .= "server.document-root = \"/usr/local/vhosts/".$directory."\"\n";
-
- $tmp .= "\n";
- $tmp .= "# Maximum idle time with nothing being written (php downloading)\n";
- $tmp .= "server.max-write-idle = 999\n";
- $tmp .= "\n";
- $tmp .= "## where to send error-messages to\n";
- $tmp .= "server.errorlog = \"/var/log/lighttpd.error.log\"\n";
- $tmp .= "\n";
- $tmp .= "# files to check for if .../ is requested\n";
- $tmp .= "server.indexfiles = ( \"index.php\", \"index.html\",\n";
- $tmp .= " \"index.htm\", \"default.htm\" )\n";
- $tmp .= "\n";
- $tmp .= "# mimetype mapping\n";
- $tmp .= "mimetype.assign = (\n";
- $tmp .= " \".pdf\" => \"application/pdf\",\n";
- $tmp .= " \".sig\" => \"application/pgp-signature\",\n";
- $tmp .= " \".spl\" => \"application/futuresplash\",\n";
- $tmp .= " \".class\" => \"application/octet-stream\",\n";
- $tmp .= " \".ps\" => \"application/postscript\",\n";
- $tmp .= " \".torrent\" => \"application/x-bittorrent\",\n";
- $tmp .= " \".dvi\" => \"application/x-dvi\",\n";
- $tmp .= " \".gz\" => \"application/x-gzip\",\n";
- $tmp .= " \".pac\" => \"application/x-ns-proxy-autoconfig\",\n";
- $tmp .= " \".swf\" => \"application/x-shockwave-flash\",\n";
- $tmp .= " \".tar.gz\" => \"application/x-tgz\",\n";
- $tmp .= " \".tgz\" => \"application/x-tgz\",\n";
- $tmp .= " \".tar\" => \"application/x-tar\",\n";
- $tmp .= " \".zip\" => \"application/zip\",\n";
- $tmp .= " \".mp3\" => \"audio/mpeg\",\n";
- $tmp .= " \".m3u\" => \"audio/x-mpegurl\",\n";
- $tmp .= " \".wma\" => \"audio/x-ms-wma\",\n";
- $tmp .= " \".wax\" => \"audio/x-ms-wax\",\n";
- $tmp .= " \".ogg\" => \"audio/x-wav\",\n";
- $tmp .= " \".wav\" => \"audio/x-wav\",\n";
- $tmp .= " \".gif\" => \"image/gif\",\n";
- $tmp .= " \".jpg\" => \"image/jpeg\",\n";
- $tmp .= " \".jpeg\" => \"image/jpeg\",\n";
- $tmp .= " \".png\" => \"image/png\",\n";
- $tmp .= " \".xbm\" => \"image/x-xbitmap\",\n";
- $tmp .= " \".xpm\" => \"image/x-xpixmap\",\n";
- $tmp .= " \".xwd\" => \"image/x-xwindowdump\",\n";
- $tmp .= " \".css\" => \"text/css\",\n";
- $tmp .= " \".html\" => \"text/html\",\n";
- $tmp .= " \".htm\" => \"text/html\",\n";
- $tmp .= " \".js\" => \"text/javascript\",\n";
- $tmp .= " \".asc\" => \"text/plain\",\n";
- $tmp .= " \".c\" => \"text/plain\",\n";
- $tmp .= " \".conf\" => \"text/plain\",\n";
- $tmp .= " \".text\" => \"text/plain\",\n";
- $tmp .= " \".txt\" => \"text/plain\",\n";
- $tmp .= " \".dtd\" => \"text/xml\",\n";
- $tmp .= " \".xml\" => \"text/xml\",\n";
- $tmp .= " \".mpeg\" => \"video/mpeg\",\n";
- $tmp .= " \".mpg\" => \"video/mpeg\",\n";
- $tmp .= " \".mov\" => \"video/quicktime\",\n";
- $tmp .= " \".qt\" => \"video/quicktime\",\n";
- $tmp .= " \".avi\" => \"video/x-msvideo\",\n";
- $tmp .= " \".asf\" => \"video/x-ms-asf\",\n";
- $tmp .= " \".asx\" => \"video/x-ms-asf\",\n";
- $tmp .= " \".wmv\" => \"video/x-ms-wmv\",\n";
- $tmp .= " \".bz2\" => \"application/x-bzip\",\n";
- $tmp .= " \".tbz\" => \"application/x-bzip-compressed-tar\",\n";
- $tmp .= " \".tar.bz2\" => \"application/x-bzip-compressed-tar\"\n";
- $tmp .= " )\n";
- $tmp .= "\n";
- $tmp .= "# Use the \"Content-Type\" extended attribute to obtain mime type if possible\n";
- $tmp .= "#mimetypes.use-xattr = \"enable\"\n";
- $tmp .= "\n";
- $tmp .= "#### accesslog module\n";
- $tmp .= "#accesslog.filename = \"/dev/null\"\n";
- $tmp .= "\n";
- $tmp .= "## deny access the file-extensions\n";
- $tmp .= "#\n";
- $tmp .= "# ~ is for backupfiles from vi, emacs, joe, ...\n";
- $tmp .= "# .inc is often used for code includes which should in general not be part\n";
- $tmp .= "# of the document-root\n";
- $tmp .= "url.access-deny = ( \"~\", \".db\" )\n";
- $tmp .= "\n";
- $tmp .= "\n";
- $tmp .= "######### Options that are good to be but not neccesary to be changed #######\n";
- $tmp .= "\n";
- $tmp .= "## bind to port (default: 80)\n";
- $tmp .= "server.port = ".$port."\n";
- $tmp .= "\n";
- $tmp .= "#the regex method isn't working\n";
- $tmp .= "#\$HTTP[\"host\"] =~ \"(^|\\.)host01\\.com\$\" {\n";
- $tmp .= "# server.document-root = \"/usr/local/vhosts/host01\"\n";
- $tmp .= "#}\n";
- $tmp .= "\n";
-
- //enable ssl if the cert and key were both provided
- $pem_file = "/var/etc/cert-vhosts-".$ipaddress."-".$port.".pem";
- $fout = fopen($pem_file,"w");
- //echo $certificate; //exit;
- fwrite($fout, $certificate.PHP_EOL.$privatekey);
+ if (!file_exists("/usr/local/vhosts/{$directory}/index.php")) {
+ $index_file = "/usr/local/vhosts/{$directory}/index.php";
+ $index_tmp = "<?php\n";
+ $index_tmp .= " echo phpinfo();\n";
+ $index_tmp .= "?>\n";
+ $fout = fopen($index_file, "w");
+ fwrite($fout, $index_tmp);
fclose($fout);
- $tmp .= "## ssl configuration\n";
- $tmp .= "ssl.pemfile = \"".$pem_file."\"\n";
- $tmp .= "ssl.engine = \"enable\"\n";
- unset($pem_file);
+ unset($index_file);
+ }
- $tmp .= "\n";
- $tmp .= "## error-handler for status 404\n";
- $tmp .= "#server.error-handler-404 = \"/error-handler.html\"\n";
- $tmp .= "#server.error-handler-404 = \"/error-handler.php\"\n";
- $tmp .= "\n";
- $tmp .= "## to help the rc.scripts\n";
- $tmp .= "server.pid-file = \"/var/run/vhosts-".$ipaddress."-".$port."-ssl.pid\"\n";
- $tmp .= "\n";
- $tmp .= "## virtual directory listings\n";
- $tmp .= "server.dir-listing = \"disable\"\n";
- $tmp .= "\n";
- $tmp .= "## enable debugging\n";
- $tmp .= "debug.log-request-header = \"disable\"\n";
- $tmp .= "debug.log-response-header = \"disable\"\n";
- $tmp .= "debug.log-request-handling = \"disable\"\n";
- $tmp .= "debug.log-file-not-found = \"disable\"\n";
- $tmp .= "\n";
- $tmp .= "#### compress module\n";
- $tmp .= "#compress.cache-dir = \"/tmp/lighttpd/cache/compress/\"\n";
- $tmp .= "#compress.filetype = (\"text/plain\", \"text/html\")\n";
- $tmp .= "\n";
- $tmp .= "#server.network-backend = \"writev\"\n";
- $tmp .= "server.upload-dirs = ( \"/root/\", \"/tmp/\", \"/var/\" )\n";
- $tmp .= "server.max-request-size = 2097152\n";
- $tmp .= "\n";
- $tmp .= "#### fastcgi module\n";
- $tmp .= "## read fastcgi.txt for more info\n";
- $tmp .= "fastcgi.server = ( \".php\" =>\n";
- $tmp .= " ( \"localhost\" =>\n";
- $tmp .= " (\n";
- $tmp .= " \"socket\" => \"/tmp/php5-fastcgi.socket\",\n";
- $tmp .= " \"min-procs\" => 1,\n";
- $tmp .= " \"max-procs\" => 1,\n";
- $tmp .= " \"idle-timeout\" => 0,\n";
- $tmp .= " \"bin-environment\" => (\n";
- $tmp .= " \"PHP_FCGI_MAX_REQUESTS\" => \"500\",\n";
- $tmp .= " \"PHP_FCGI_CHILDREN\" => \"1\"\n";
- $tmp .= " ),\n";
- $tmp .= " \"bin-path\" => \"/usr/local/bin/php\"\n";
- $tmp .= " )\n";
- $tmp .= " )\n";
- $tmp .= ")\n";
- $tmp .= "\n";
- $tmp .= "#### CGI module\n";
- $tmp .= "cgi.assign = ( \".cgi\" => \"\" )\n";
-
- $fout = fopen("/var/etc/vhosts-".$ipaddress."-".$port."-ssl.conf","w");
- fwrite($fout, $tmp);
- unset($tmp);
+ // Set the default port
+ if (strlen($port) == 0) {
+ $port = '443';
+ }
+
+ $tmp =<<<EOF
+#
+# lighttpd configuration file
+#
+# use a it as base for lighttpd 1.0.0 and above
+#
+############ Options you really have to take care of ####################
+
+## FreeBSD!
+server.event-handler = "freebsd-kqueue"
+server.network-backend = "writev" ## Fixes 7.x upload issues
+
+## modules to load
+server.modules = (
+ "mod_access", "mod_accesslog",
+ "mod_fastcgi", "mod_cgi","mod_rewrite"
+ )
+
+## Unused modules
+# "mod_setenv",
+# "mod_compress"
+# "mod_redirect",
+# "mod_rewrite",
+# "mod_ssi",
+# "mod_usertrack",
+# "mod_expire",
+# "mod_secdownload",
+# "mod_rrdtool",
+# "mod_auth",
+# "mod_status",
+# "mod_alias",
+# "mod_proxy",
+# "mod_simple_vhost",
+# "mod_evhost",
+# "mod_userdir",
+# "mod_cgi",
+# "mod_accesslog"
+
+## a static document-root, for virtual-hosting take look at the
+## server.virtual-* options
+
+##
+
+server.document-root = "/usr/local/vhosts/"
+
+# Maximum idle time with nothing being written (php downloading)
+server.max-write-idle = 999
+
+## where to send error-messages to
+server.errorlog = "/var/log/lighttpd.error.log"
+
+# files to check for if .../ is requested
+server.indexfiles = ( "index.php", "index.html",
+ "index.htm", "default.htm" )
+
+# mimetype mapping
+mimetype.assign = (
+ ".pdf" => "application/pdf",
+ ".sig" => "application/pgp-signature",
+ ".spl" => "application/futuresplash",
+ ".class" => "application/octet-stream",
+ ".ps" => "application/postscript",
+ ".torrent" => "application/x-bittorrent",
+ ".dvi" => "application/x-dvi",
+ ".gz" => "application/x-gzip",
+ ".pac" => "application/x-ns-proxy-autoconfig",
+ ".swf" => "application/x-shockwave-flash",
+ ".tar.gz" => "application/x-tgz",
+ ".tgz" => "application/x-tgz",
+ ".tar" => "application/x-tar",
+ ".zip" => "application/zip",
+ ".mp3" => "audio/mpeg",
+ ".m3u" => "audio/x-mpegurl",
+ ".wma" => "audio/x-ms-wma",
+ ".wax" => "audio/x-ms-wax",
+ ".ogg" => "audio/x-wav",
+ ".wav" => "audio/x-wav",
+ ".gif" => "image/gif",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".png" => "image/png",
+ ".xbm" => "image/x-xbitmap",
+ ".xpm" => "image/x-xpixmap",
+ ".xwd" => "image/x-xwindowdump",
+ ".css" => "text/css",
+ ".html" => "text/html",
+ ".htm" => "text/html",
+ ".js" => "text/javascript",
+ ".asc" => "text/plain",
+ ".c" => "text/plain",
+ ".conf" => "text/plain",
+ ".text" => "text/plain",
+ ".txt" => "text/plain",
+ ".dtd" => "text/xml",
+ ".xml" => "text/xml",
+ ".mpeg" => "video/mpeg",
+ ".mpg" => "video/mpeg",
+ ".mov" => "video/quicktime",
+ ".qt" => "video/quicktime",
+ ".avi" => "video/x-msvideo",
+ ".asf" => "video/x-ms-asf",
+ ".asx" => "video/x-ms-asf",
+ ".wmv" => "video/x-ms-wmv",
+ ".bz2" => "application/x-bzip",
+ ".tbz" => "application/x-bzip-compressed-tar",
+ ".tar.bz2" => "application/x-bzip-compressed-tar"
+ )
+
+# Use the "Content-Type" extended attribute to obtain mime type if possible
+#mimetypes.use-xattr = "enable"
+
+#### accesslog module
+#accesslog.filename = "/dev/null"
+
+## deny access the file-extensions
+#
+# ~ is for backupfiles from vi, emacs, joe, ...
+# .inc is often used for code includes which should in general not be part
+# of the document-root
+url.access-deny = ( "~", ".db" )
+
+
+######### Options that are good to be but not neccesary to be changed #######
+
+## bind to port (default: 80)
+server.port = {$port}
+
+EOF;
+ // Enable SSL if the cert and key were both provided
+ $pem_file = "/var/etc/cert-vhosts-{$ipaddress}-{$port}.pem";
+ $fout = fopen($pem_file, "w");
+ fwrite($fout, $certificate.PHP_EOL.$privatekey);
fclose($fout);
+ $tmp .= "## ssl configuration\n";
+ $tmp .= "ssl.pemfile = \"" . $pem_file . "\"\n";
+ $tmp .= "ssl.engine = \"enable\"\n";
+ unset($pem_file);
- if (!function_exists('write_rcfile')) { require("/etc/inc/service-utils.inc"); }
- write_rcfile(array(
- "file" => "vhosts-".$ipaddress."-".$port."-ssl.sh",
- "start" => "/usr/local/sbin/lighttpd -f /var/etc/vhosts-".$ipaddress."-".$port."-ssl.conf",
- "stop" => "kill `cat /var/run/vhosts-".$ipaddress."-".$port."-ssl.pid`"
- )
- );
- //add or update a service
- $ent['name'] = "vhosts-ssl-$x";
- $ent['rcfile'] = "vhosts-".$ipaddress."-".$port."-ssl.sh";
- $ent['executable'] = "vhosts-".$ipaddress."-".$port."-ssl";
- $ent['description'] = "vHosts SSL, Host: $host, IP Address: ".$ipaddress.", port: ".$port." desc: ".$description;
- $ent['custom_php_service_status_command'] = "\$vhost_output=''; exec('/bin/pgrep -anf '.".escapeshellarg($ent['executable']).", \$vhost_output, \$retval); \$rc=(intval(\$retval) == 0);";
- $a_service = $config['installedpackages']['service'];
- $service_id = get_service_id ($a_service, 'name', "vhosts-ssl-$x");
- if (is_int($service_id)) {
- //update
- $a_service[$service_id] = $ent;
- }
- else {
- //add
- $a_service[] = $ent;
- }
+ $tmp .= <<<EOF
- } //if enabled
- $x++;
- } //end for each
- } //end if array count
- write_config();
- conf_mount_ro();
+## error-handler for status 404
+#server.error-handler-404 = "/error-handler.html"
+#server.error-handler-404 = "/error-handler.php"
- }
-}
+## to help the rc.scripts
+server.pid-file = "/var/run/vhosts-{$ipaddress}-{$port}-ssl.pid"
+## virtual directory listings
+server.dir-listing = "disable"
-function vhosts_sync_package() {
- global $config;
- vhosts_sync_package_php();
-}
+## enable debugging
+debug.log-request-header = "disable"
+debug.log-response-header = "disable"
+debug.log-request-handling = "disable"
+debug.log-file-not-found = "disable"
+#### compress module
+#compress.cache-dir = "/tmp/lighttpd/cache/compress/"
+#compress.filetype = ("text/plain", "text/html")
-function vhosts_install_command() {
+#server.network-backend = "writev"
+server.upload-dirs = ( "/root/", "/tmp/", "/var/" )
+server.max-request-size = 2097152
- global $config;
- conf_mount_rw();
- config_lock();
+#### fastcgi module
+## read fastcgi.txt for more info
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "socket" => "/var/run/php-fpm.socket",
+ "broken-scriptfilename" => "enable"
+ )
+ )
+)
- if (!is_dir('/usr/local/www/packages/')) {
- exec("mkdir /usr/local/www/packages/");
- }
+#### CGI module
+cgi.assign = ( ".cgi" => "" )
- if (!is_dir('/usr/local/www/packages/vhosts/')) {
- exec("mkdir /usr/local/www/packages/vhosts/");
- }
+EOF;
- if (!is_dir('/usr/local/vhosts/')) {
- exec("mkdir /usr/local/vhosts/");
- }
+ $fout = fopen("/var/etc/vhosts-{$ipaddress}-{$port}-ssl.conf", "w");
+ fwrite($fout, $tmp);
+ unset($tmp);
+ fclose($fout);
- if(stristr(php_uname('r'), '7.2') == TRUE) {
- if (!file_exists('/usr/local/php5')) {
- chdir('/usr/local/');
- exec ("fetch https://files.pfsense.org/packages/7/vhosts/php5.tar.gz");
- exec("tar zxvf /usr/local/php5.tar.gz -C /usr/local/");
- exec("rm /usr/local/php5.tar.gz");
- }
- if (!file_exists('/usr/local/lib/libxml2.so.5')) {
- chdir('/usr/local/lib/');
- exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/libxml2.so.5");
- }
- if (!file_exists('/usr/local/lib/libxml2.so')) {
- chdir('/usr/local/lib/');
- exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/libxml2.so");
- }
- if (!file_exists('/usr/local/lib/libxml2.la')) {
- chdir('/usr/local/lib/');
- exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/libxml2.la");
- }
- if (!file_exists('/usr/local/lib/libxml2.a')) {
- chdir('/usr/local/lib/');
- exec ("fetch https://files.pfsense.org/packages/7/vhosts/usr.local.lib/lib/libxml2.a");
- }
- }
- if(stristr(php_uname('r'), '8.1') == TRUE) {
- if (!file_exists('/usr/local/php5')) {
- chdir('/usr/local/');
- exec ("fetch https://files.pfsense.org/packages/8/vhosts/php5.tar.gz");
- exec("tar zxvf /usr/local/php5.tar.gz -C /usr/local/");
- exec("rm /usr/local/php5.tar.gz");
+ write_rcfile(array(
+ "file" => "vhosts-{$ipaddress}-{$port}-ssl.sh",
+ "start" => "/usr/local/sbin/lighttpd -f /var/etc/vhosts-{$ipaddress}-{$port}-ssl.conf",
+ "stop" => "kill `cat /var/run/vhosts-{$ipaddress}-{$port}-ssl.pid`"
+ )
+ );
+
+ // Add or update a service
+ $ent['name'] = "vhosts-ssl-{$x}";
+ $ent['rcfile'] = "vhosts-{$ipaddress}-{$port}-ssl.sh";
+ $ent['executable'] = "vhosts-{$ipaddress}-{$port}-ssl";
+ $ent['description'] = "vHosts SSL, Host: {$host}, IP Address: {$ipaddress}, port: {$port}, desc: {$description}";
+ $ent['custom_php_service_status_command'] = "\$vhost_output=''; exec('/bin/pgrep -anf '.".escapeshellarg($ent['executable']).", \$vhost_output, \$retval); \$rc=(intval(\$retval) == 0);";
+ $a_service = $config['installedpackages']['service'];
+ $service_id = get_service_id ($a_service, 'name', "vhosts-ssl-{$x}");
+ if (is_int($service_id)) {
+ // Update
+ $a_service[$service_id] = $ent;
+ } else {
+ // Add
+ $a_service[] = $ent;
+ }
+ // END if enabled
+ }
+ $x++;
+ // END foreach
+ }
+ // END if array count
}
+ write_config();
+ conf_mount_ro();
}
+}
- //rename PHP files from .tmp to .php
- exec("cp /tmp/vhosts_php.tmp /usr/local/www/packages/vhosts/vhosts_php.php");
- unlink_if_exists("/tmp/vhosts_php.tmp");
-
- exec("cp /tmp/vhosts_php_edit.tmp /usr/local/www/packages/vhosts/vhosts_php_edit.php");
- unlink_if_exists("/tmp/vhosts_php_edit.tmp");
-
- chdir('/tmp/');
- exec ("fetch https://packages.pfsense.org/packages/config/vhosts/system_advanced_create_certs.tmp");
- exec("cp /tmp/system_advanced_create_certs.tmp /usr/local/www/packages/vhosts/system_advanced_create_certs.php");
- unlink_if_exists("/tmp/system_advanced_create_certs.tmp");
-
- //write_config();
+function vhosts_install_command() {
+ global $config;
+ conf_mount_rw();
+ safe_mkdir("/usr/local/vhosts/");
- if (!function_exists('write_rcfile')) { require("/etc/inc/service-utils.inc"); }
write_rcfile(array(
"file" => "vhosts-http.sh",
"start" => "/usr/local/sbin/lighttpd -f /var/etc/vhosts-http.conf",
@@ -788,32 +633,17 @@ function vhosts_install_command() {
);
vhosts_sync_package();
-
- //if (pkg_is_service_running('vhosts')) {
- //documentation purposes
- //}
-
- conf_mount_ro();
- config_unlock();
-
}
-function vhosts_deinstall_command()
-{
+function vhosts_deinstall_command() {
conf_mount_rw();
- config_lock();
- $handle = popen("/usr/local/etc/rc.d/vhosts.sh stop", "r");
- unlink_if_exists("/usr/local/pkg/vhosts.xml");
- unlink_if_exists("/usr/local/pkg/vhosts.inc");
- unlink_if_exists("/usr/local/www/vhosts.inc");
+ stop_service("vhosts-http");
unlink_if_exists("/usr/local/etc/rc.d/vhosts-http.sh");
- exec ("rm /usr/local/etc/rc.d/vhosts*");
- exec ("rm /var/etc/vhosts*");
- exec("rm -R /usr/local/www/packages/vhosts");
- exec("rm -R /usr/local/php5");
+ exec("/bin/rm -f /usr/local/etc/rc.d/vhosts*");
+ exec("/bin/rm -f /var/etc/vhosts*");
+ exec("/bin/rm -rf /usr/local/www/packages/vhosts");
conf_mount_ro();
- config_unlock();
}
?>
diff --git a/config/vhosts/vhosts.xml b/config/vhosts/vhosts.xml
index 91c50079..306ccc69 100644
--- a/config/vhosts/vhosts.xml
+++ b/config/vhosts/vhosts.xml
@@ -1,52 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
-<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <copyright>
- <![CDATA[
+ <copyright>
+<![CDATA[
/* $Id$ */
-/* ========================================================================== */
+/* ====================================================================================== */
/*
- vhosts.xml
- Copyright (C) 2008 Mark J Crane
- All rights reserved.
- */
-/* ========================================================================== */
+ vhosts.xml
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2008 Mark J Crane
+ Copyright (C) 2015 ESF, LLC
+ All rights reserved.
+*/
+/* ====================================================================================== */
/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-/* ========================================================================== */
- ]]>
- </copyright>
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+/* ====================================================================================== */
+ ]]>
+ </copyright>
<description>vHosts</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
<name>vHosts Settings</name>
- <version>0.7.3</version>
- <title>Settings</title>
+ <version>0.8.0</version>
+ <title>vHosts Settings</title>
<include_file>/usr/local/pkg/vhosts.inc</include_file>
<menu>
<name>vHosts</name>
- <tooltiptext>vHosts Service settings.</tooltiptext>
+ <tooltiptext>vHosts Service Settings.</tooltiptext>
<section>Services</section>
<configfile>vhosts.xml</configfile>
<url>/packages/vhosts/vhosts_php.php</url>
@@ -55,67 +57,32 @@
<name>vhosts-http</name>
<rcfile>vhosts-http.sh</rcfile>
<executable>vhosts-http</executable>
- <description>LigHTTPD web server service. Uses PHP5 with fast cgi.</description>
+ <description>lighttpd vHosts Web Server</description>
</service>
- <tabs>
- <tab>
- <text>Settings</text>
- <url>/pkg_edit.php?xml=vhosts.xml&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>