aboutsummaryrefslogtreecommitdiffstats
path: root/config/vhosts
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-08-13 00:04:43 +0200
committerdoktornotor <notordoktor@gmail.com>2015-08-13 00:04:43 +0200
commit3722623f0c5b34a9ca454cd528db10c3ac44ec5c (patch)
tree495e30326837de84293d4b976b8cde1cce81cb34 /config/vhosts
parente5853e24acee900322f8909fea9d8b6ee8e5535f (diff)
downloadpfsense-packages-3722623f0c5b34a9ca454cd528db10c3ac44ec5c.tar.gz
pfsense-packages-3722623f0c5b34a9ca454cd528db10c3ac44ec5c.tar.bz2
pfsense-packages-3722623f0c5b34a9ca454cd528db10c3ac44ec5c.zip
vhosts - rewrite garbage package
Diffstat (limited to 'config/vhosts')
-rw-r--r--config/vhosts/vhosts_php_edit.php313
1 files changed, 144 insertions, 169 deletions
diff --git a/config/vhosts/vhosts_php_edit.php b/config/vhosts/vhosts_php_edit.php
index 8760686e..cb5a330f 100644
--- a/config/vhosts/vhosts_php_edit.php
+++ b/config/vhosts/vhosts_php_edit.php
@@ -1,21 +1,21 @@
-<?php
-/* $Id$ */
+<?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
@@ -27,7 +27,6 @@
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");
@@ -44,15 +43,16 @@ $a_service = $config['installedpackages']['service'];
if ($_GET['act'] == "del") {
if ($_GET['type'] == 'php') {
if ($a_vhosts[$_GET['id']]) {
- //get vhost info
+ // Get vhost info
$x = 0;
$y = 0;
- foreach($a_vhosts as $rowhelper) {
+ foreach ($a_vhosts as $rowhelper) {
if (strlen($rowhelper['certificate']) > 0) {
$y++;
}
if ($_GET['id'] == $x) {
- $id = $x; //return the id
+ // Return the id
+ $id = $x;
$host = $rowhelper['host'];
$ipaddress = $rowhelper['ipaddress'];
$port = $rowhelper['port'];
@@ -60,29 +60,27 @@ if ($_GET['act'] == "del") {
if (strlen($rowhelper['certificate']) > 0) {
$ssl = true;
$ssl_id = $y;
- }
- else {
+ } 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]);
- }
+ // 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");
@@ -121,25 +119,22 @@ if ($_POST) {
if (strlen($_POST['certificate']) > 0) {
$ent['certificate'] = base64_encode($_POST['certificate']);
- }
- else {
+ } else {
$ent['certificate'] = '';
}
if (strlen($_POST['privatekey']) > 0) {
$ent['privatekey'] = base64_encode($_POST['privatekey']);
- }
- else {
+ } else {
$ent['privatekey'] = '';
}
$ent['enabled'] = $_POST['enabled'];
$ent['description'] = $_POST['description'];
if (isset($id) && $a_vhosts[$id]) {
- //update
- $a_vhosts[$id] = $ent;
- }
- else {
- //add
+ // Update
+ $a_vhosts[$id] = $ent;
+ } else {
+ // Add
$a_vhosts[] = $ent;
}
@@ -151,32 +146,37 @@ if ($_POST) {
}
}
+$pgtitle = "vHosts: Edit";
include("head.inc");
?>
-<script type="text/javascript" language="JavaScript">
-
+<script type="text/javascript">
+//<![CDATA[
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 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"); ?>
-<p class="pgtitle">vHosts: Edit</p>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
<div id="mainlevel">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -190,131 +190,106 @@ function show_advanced_config() {
?>
</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>
- -->
+<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 " <option></option>\n";
+ <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 " <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";
+ 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";
+ 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>
+ </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>