Bernd Wurst commited on 2014-01-27 19:14:21
Zeige 4 geänderte Dateien mit 89 Einfügungen und 3 Löschungen.
... | ... |
@@ -0,0 +1,26 @@ |
1 |
+<?php |
|
2 |
+/* |
|
3 |
+This file belongs to the Webinterface of schokokeks.org Hosting |
|
4 |
+ |
|
5 |
+Written 2008-2013 by schokokeks.org Hosting, namely |
|
6 |
+ Bernd Wurst <bernd@schokokeks.org> |
|
7 |
+ Hanno Böck <hanno@schokokeks.org> |
|
8 |
+ |
|
9 |
+To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. |
|
10 |
+ |
|
11 |
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see |
|
12 |
+http://creativecommons.org/publicdomain/zero/1.0/ |
|
13 |
+ |
|
14 |
+Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code. |
|
15 |
+*/ |
|
16 |
+ |
|
17 |
+require_once('inc/base.php'); |
|
18 |
+ |
|
19 |
+$path = config('jquery_ui_path'); |
|
20 |
+html_header(' |
|
21 |
+<link rel="stylesheet" href="'.$path.'/themes/base/jquery-ui.css" /> |
|
22 |
+<script type="text/javascript" src="'.$path.'/jquery-1.9.0.js" ></script> |
|
23 |
+<script type="text/javascript" src="'.$path.'/ui/jquery-ui.js" ></script> |
|
24 |
+ |
|
25 |
+'); |
|
26 |
+ |
... | ... |
@@ -16,6 +16,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r |
16 | 16 |
|
17 | 17 |
require_once('inc/debug.php'); |
18 | 18 |
require_once('inc/security.php'); |
19 |
+require_once('inc/jquery.php'); |
|
19 | 20 |
|
20 | 21 |
require_once('vhosts.php'); |
21 | 22 |
require_once('certs.php'); |
... | ... |
@@ -92,6 +93,39 @@ html_header("<script type=\"text/javascript\"> |
92 | 93 |
document.getElementById('options_webapp').style.display = 'block'; |
93 | 94 |
} |
94 | 95 |
} |
96 |
+ |
|
97 |
+ |
|
98 |
+ function showhsts( event ) { |
|
99 |
+ var ssl = $('#ssl option:selected').val(); |
|
100 |
+ if (ssl == 'forward') { |
|
101 |
+ $('#hsts_block').show(); |
|
102 |
+ } else |
|
103 |
+ $('#hsts_block').hide(); |
|
104 |
+ } |
|
105 |
+ |
|
106 |
+ function hsts_preset( event ) { |
|
107 |
+ var seconds = $('#hsts_preset option:selected').val(); |
|
108 |
+ if (seconds == 'custom') { |
|
109 |
+ $('#hsts_seconds').show(); |
|
110 |
+ if ($('#hsts').val() < 0) { |
|
111 |
+ $('#hsts').val(2592000); /* 30 Tage */ |
|
112 |
+ } |
|
113 |
+ } else { |
|
114 |
+ $('#hsts_seconds').hide(); |
|
115 |
+ $('#hsts').val(seconds); |
|
116 |
+ } |
|
117 |
+ } |
|
118 |
+ |
|
119 |
+ $(document).ready(function(){ |
|
120 |
+ $('#ssl').change(showhsts); |
|
121 |
+ showhsts(); |
|
122 |
+ if ($('#hsts_preset option:selected').val() != 'custom') { |
|
123 |
+ $('#hsts_seconds').hide(); |
|
124 |
+ } |
|
125 |
+ $('#hsts_preset').change(hsts_preset); |
|
126 |
+ |
|
127 |
+ }) |
|
128 |
+ |
|
95 | 129 |
</script>"); |
96 | 130 |
|
97 | 131 |
$defaultdocroot = $vhost['domain']; |
... | ... |
@@ -210,6 +244,12 @@ if ($vhost_type=='webapp') |
210 | 244 |
<input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_webapp\" value=\"webapp\" ".(($vhost_type=='webapp') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_webapp\"> Eine vorgefertigte Applikation nutzen</label><br /> |
211 | 245 |
"; |
212 | 246 |
} |
247 |
+$hsts_value = $vhost['hsts']; |
|
248 |
+$hsts_preset_values = array("-1" => "aus", "86400" => "1 Tag", "2592000" => "30 Tage", "31536000" => "1 Jahr", "63072000" => "2 Jahre", "custom" => "Individuell"); |
|
249 |
+$hsts_preset_value = 'custom'; |
|
250 |
+if (isset($hsts_preset_values[$hsts_value])) { |
|
251 |
+ $hsts_preset_value = $hsts_value; |
|
252 |
+} |
|
213 | 253 |
$form .= " |
214 | 254 |
<input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_dav\" value=\"dav\" ".(($vhost_type=='dav') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_dav\"> WebDAV</label><br /> |
215 | 255 |
<input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_svn\" value=\"svn\" ".(($vhost_type=='svn') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_svn\"> Subversion-Server</label> |
... | ... |
@@ -228,7 +268,8 @@ $form .= " |
228 | 268 |
".($vhost['ssl'] == 'http' ? "<option value=\"http\" selected=\"selected\">kein SSL</option>" : '')." |
229 | 269 |
".($vhost['ssl'] == 'https' ? "<option value=\"https\" selected=\"selected\">nur SSL</option>" : '')." |
230 | 270 |
<option value=\"forward\" ".($vhost['ssl'] == 'forward' ? 'selected="selected"' : '')." >Immer auf SSL umleiten</option> |
231 |
- </select> |
|
271 |
+ </select> <span id=\"hsts_block\" style=\"padding-top: 0.2em;\"> <label for=\"hsts\"><a title=\"Mit HSTS können Sie festlegen, dass eine bestimmte Website niemals ohne Verschlüsselung aufgerufen werden soll. Zudem werden Zertifikate strenger geprüft.\" href=\"http://de.wikipedia.org/wiki/Hypertext_Transfer_Protocol_Secure#HSTS\">HSTS</a>:</label> ".html_select('hsts_preset', $hsts_preset_values, $hsts_preset_value)." <span id=\"hsts_seconds\"><input type=\"text\" name=\"hsts\" id=\"hsts\" size=\"10\" style=\"text-align: right;\" value=\"{$hsts_value}\" /> Sekunden</span> |
|
272 |
+ </span> |
|
232 | 273 |
</div> |
233 | 274 |
<h5>Logfiles <span class=\"warning\">*</span></h5> |
234 | 275 |
<div style=\"margin-left: 2em;\"> |
... | ... |
@@ -83,6 +83,7 @@ function empty_vhost() |
83 | 83 |
$vhost['php'] = 'php55'; |
84 | 84 |
$vhost['cgi'] = 1; |
85 | 85 |
$vhost['ssl'] = NULL; |
86 |
+ $vhost['hsts'] = -1; |
|
86 | 87 |
$vhost['suexec_user'] = NULL; |
87 | 88 |
$vhost['server'] = NULL; |
88 | 89 |
$vhost['logtype'] = NULL; |
... | ... |
@@ -147,6 +148,10 @@ function get_vhost_details($id) |
147 | 148 |
|
148 | 149 |
$ret = mysql_fetch_assoc($result); |
149 | 150 |
|
151 |
+ if ($ret['hsts'] === NULL) { |
|
152 |
+ DEBUG('HSTS: '.$ret['hsts']); |
|
153 |
+ $ret['hsts'] = -1; |
|
154 |
+ } |
|
150 | 155 |
$ret['server'] = $ret['server_id']; |
151 | 156 |
DEBUG($ret); |
152 | 157 |
return $ret; |
... | ... |
@@ -297,6 +302,10 @@ function save_vhost($vhost) |
297 | 302 |
$php = maybe_null($vhost['php']); |
298 | 303 |
$cgi = ($vhost['cgi'] == 1 ? 1 : 0); |
299 | 304 |
$ssl = maybe_null($vhost['ssl']); |
305 |
+ $hsts = (int) $vhost['hsts']; |
|
306 |
+ if ($hsts < 0) { |
|
307 |
+ $hsts = "NULL"; |
|
308 |
+ } |
|
300 | 309 |
$suexec_user = 'NULL'; |
301 | 310 |
|
302 | 311 |
$available_suexec = available_suexec_users(); |
... | ... |
@@ -345,11 +354,11 @@ function save_vhost($vhost) |
345 | 354 |
|
346 | 355 |
if ($id != 0) { |
347 | 356 |
logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')'); |
348 |
- db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, `suexec_user`={$suexec_user}, `server`={$server}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, autoipv6={$autoipv6}, options='{$options}', stats={$stats} WHERE id={$id} LIMIT 1"); |
|
357 |
+ db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, hsts={$hsts}, `suexec_user`={$suexec_user}, `server`={$server}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, autoipv6={$autoipv6}, options='{$options}', stats={$stats} WHERE id={$id} LIMIT 1"); |
|
349 | 358 |
} |
350 | 359 |
else { |
351 | 360 |
logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].''); |
352 |
- $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$suexec_user}, {$server}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})"); |
|
361 |
+ $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, hsts, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$hsts}, {$suexec_user}, {$server}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})"); |
|
353 | 362 |
$id = mysql_insert_id(); |
354 | 363 |
} |
355 | 364 |
$oldvhost = get_vhost_details($id); |
... | ... |
@@ -139,6 +139,15 @@ if ($_GET['action'] == 'edit') |
139 | 139 |
/* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */ |
140 | 140 |
} |
141 | 141 |
|
142 |
+ $hsts = NULL; |
|
143 |
+ if (isset($_POST['hsts'])) { |
|
144 |
+ if (is_numeric($_POST['hsts']) && (int) $_POST['hsts'] > -2) { |
|
145 |
+ $hsts = (int) $_POST['hsts']; |
|
146 |
+ } else { |
|
147 |
+ system_failure('Es wurde ein ungültiger HSTS-Wert eingegeben. Dort sind nur Sekunden erlaubt.'); |
|
148 |
+ } |
|
149 |
+ } |
|
150 |
+ |
|
142 | 151 |
$cert = (isset($_POST['cert']) ? (int) $_POST['cert'] : NULL); |
143 | 152 |
|
144 | 153 |
$ipv4 = (isset($_POST['ipv4']) ? $_POST['ipv4'] : NULL); |
... | ... |
@@ -205,6 +214,7 @@ if ($_GET['action'] == 'edit') |
205 | 214 |
$vhost['php'] = $php; |
206 | 215 |
$vhost['cgi'] = $cgi; |
207 | 216 |
$vhost['ssl'] = $ssl; |
217 |
+ $vhost['hsts'] = $hsts; |
|
208 | 218 |
$vhost['cert'] = $cert; |
209 | 219 |
$vhost['ipv4'] = $ipv4; |
210 | 220 |
$vhost['logtype'] = $logtype; |
211 | 221 |