VHost-Edit-Seite auf JQuery umgestellt
Bernd Wurst

Bernd Wurst commited on 2014-02-08 09:38:35
Zeige 4 geänderte Dateien mit 101 Einfügungen und 93 Löschungen.

... ...
@@ -19,7 +19,7 @@ require_once('vmail.php');
19 19
 $email = filter_var($_REQUEST['target'], FILTER_VALIDATE_EMAIL);
20 20
 $type = forward_type($email);
21 21
 
22
-header("Content-Type: text/javascript");
22
+header("Content-Type: application/json");
23 23
 echo ' { "target": "'.$email.'", "type": "'.$type.'" } ';
24 24
 die();
25 25
 
... ...
@@ -38,7 +38,7 @@ foreach ($allentries as $entry) {
38 38
 
39 39
 
40 40
 
41
-header("Content-Type: text/javascript");
41
+header("Content-Type: application/json");
42 42
 echo "[\n";
43 43
 echo implode(",\n", $lines);
44 44
 echo '
... ...
@@ -0,0 +1,91 @@
1
+ 
2
+  function selectedDomain() {
3
+    return $('#domain option:selected').text();
4
+    }
5
+  
6
+
7
+  function getDefaultDocroot() {
8
+    var hostname;
9
+    if ($('#hostname').val() == '') 
10
+      hostname = selectedDomain();
11
+    else
12
+      hostname = $('#hostname').val() + '.' + selectedDomain();
13
+    return hostname + '/htdocs';
14
+  }
15
+  
16
+  function useDefaultDocroot( default_docroot ) {
17
+    var do_it = $('#use_default_docroot').prop('checked');
18
+    var inputfield = $('#docroot');
19
+    inputfield.attr('disabled', do_it);
20
+    if (do_it) {
21
+      $('#docroot').val(getDefaultDocroot());
22
+    }
23
+  }
24
+  
25
+  function showAppropriateLines() {
26
+    type = $('input[name="vhost_type"]:checked').val();
27
+    switch (type) {
28
+      case "regular":
29
+        $('#options_docroot').show();
30
+        $('#options_scriptlang').show();
31
+        $('#options_webapp').hide();
32
+        break;
33
+      case "dav":
34
+        $('#options_docroot').show();
35
+        $('#options_scriptlang').hide();
36
+        $('#options_webapp').hide();
37
+        break;
38
+      case "svn":
39
+        $('#options_docroot').hide();
40
+        $('#options_scriptlang').hide();
41
+        $('#options_webapp').hide();
42
+        break;
43
+      case "webapp":
44
+        $('#options_docroot').hide();
45
+        $('#options_scriptlang').hide();
46
+        $('#options_webapp').show();
47
+        break;
48
+    }
49
+  }
50
+
51
+
52
+  function showhsts( event ) {
53
+    var ssl = $('#ssl option:selected').val();
54
+    if (ssl == 'forward') {
55
+      $('#hsts_block').show();
56
+    } else
57
+      $('#hsts_block').hide();
58
+  }
59
+
60
+  function hsts_preset( event ) {
61
+    var seconds = $('#hsts_preset option:selected').val();
62
+    if (seconds == 'custom') {
63
+      $('#hsts_seconds').show();
64
+      if ($('#hsts').val() < 0) {
65
+        $('#hsts').val(2592000); /* 30 Tage */
66
+      }
67
+    } else {
68
+      $('#hsts_seconds').hide();
69
+      $('#hsts').val(seconds);
70
+    }
71
+  }
72
+
73
+
74
+$(function() {
75
+
76
+  $('#hostname').change(useDefaultDocroot);
77
+  $('#domain').change(useDefaultDocroot);
78
+  $('#use_default_docroot').change(useDefaultDocroot);
79
+
80
+  $('.usageoption').change(showAppropriateLines);
81
+
82
+
83
+  $('#ssl').change(showhsts);
84
+  showhsts();
85
+  if ($('#hsts_preset option:selected').val() != 'custom') {
86
+    $('#hsts_seconds').hide();
87
+  }
88
+  $('#hsts_preset').change(hsts_preset);
89
+  
90
+});
91
+
... ...
@@ -17,6 +17,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 require_once('inc/debug.php');
18 18
 require_once('inc/security.php');
19 19
 require_once('inc/jquery.php');
20
+javascript();
20 21
 
21 22
 require_once('vhosts.php');
22 23
 require_once('certs.php');
... ...
@@ -44,90 +45,6 @@ else {
44 45
   title("Subdomain bearbeiten");
45 46
 }
46 47
 
47
-html_header("<script type=\"text/javascript\">
48
- 
49
-  function selectedDomain() {
50
-    var selected;
51
-    selected=document.getElementById('domain').options.selectedIndex;
52
-    return document.getElementById('domain').options.item(selected).text;
53
-    }
54
-  
55
-  function defaultDocumentRoot() {
56
-    var hostname;
57
-    if (document.getElementById('hostname').value == '') 
58
-      hostname = selectedDomain();
59
-    else
60
-      hostname = document.getElementById('hostname').value + '.' + selectedDomain();
61
-    var default_docroot = hostname + '/htdocs';
62
-    useDefaultDocroot(default_docroot);
63
-  }
64
-  
65
-  function useDefaultDocroot( default_docroot ) {
66
-    var do_it = (document.getElementById('use_default_docroot').checked == true);
67
-    var inputfield = document.getElementById('docroot');
68
-    inputfield.disabled = do_it;
69
-    if (do_it) {
70
-      document.getElementById('docroot').value = default_docroot;
71
-    }
72
-  }
73
-  
74
-  function showAppropriateLines() {
75
-    if (document.getElementById('vhost_type_regular').checked == true) {
76
-      document.getElementById('options_docroot').style.display = 'block';
77
-      document.getElementById('options_scriptlang').style.display = 'block';
78
-      document.getElementById('options_webapp').style.display = 'none';
79
-    }
80
-    else if (document.getElementById('vhost_type_dav').checked == true) { 
81
-      document.getElementById('options_docroot').style.display = 'block';
82
-      document.getElementById('options_scriptlang').style.display = 'none';
83
-      document.getElementById('options_webapp').style.display = 'none';
84
-    }
85
-    else if (document.getElementById('vhost_type_svn').checked == true) {
86
-      document.getElementById('options_docroot').style.display = 'none';
87
-      document.getElementById('options_scriptlang').style.display = 'none';
88
-      document.getElementById('options_webapp').style.display = 'none';
89
-    }
90
-    else if (document.getElementById('vhost_type_webapp').checked == true) {
91
-      document.getElementById('options_docroot').style.display = 'none';
92
-      document.getElementById('options_scriptlang').style.display = 'none';
93
-      document.getElementById('options_webapp').style.display = 'block';
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
-
129
-  </script>");
130
-
131 48
 $defaultdocroot = $vhost['domain'];
132 49
 if (! $vhost['domain'])
133 50
   $defaultdocroot = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
... ...
@@ -169,7 +86,7 @@ foreach ($applist as $app)
169 86
 
170 87
 $form = "
171 88
 <h4 style=\"margin-top: 2em;\">Name des VHost</h4>
172
-    <div style=\"margin-left: 2em;\"><input type=\"text\" name=\"hostname\" id=\"hostname\" size=\"10\" value=\"{$vhost['hostname']}\" onkeyup=\"defaultDocumentRoot()\"  onchange=\"defaultDocumentRoot()\" /><strong>.</strong>".domainselect($vhost['domain_id'], 'onchange="defaultDocumentRoot()"');
89
+    <div style=\"margin-left: 2em;\"><input type=\"text\" name=\"hostname\" id=\"hostname\" size=\"10\" value=\"{$vhost['hostname']}\" /><strong>.</strong>".domainselect($vhost['domain_id']);
173 90
 $form .= "<br /><input type=\"checkbox\" name=\"options[]\" id=\"aliaswww\" value=\"aliaswww\" {$s}/> <label for=\"aliaswww\">Auch mit <strong>www</strong> davor.</label></div>
174 91
 
175 92
 <div class=\"vhostsidebyside\">
... ...
@@ -177,7 +94,7 @@ $form .= "<br /><input type=\"checkbox\" name=\"options[]\" id=\"aliaswww\" valu
177 94
   <h4>Optionen</h4>
178 95
   <h5>Speicherort für Dateien (»Document Root«)</h5>
179 96
   <div style=\"margin-left: 2em;\">
180
-    <input type=\"checkbox\" id=\"use_default_docroot\" name=\"use_default_docroot\" value=\"1\" onclick=\"defaultDocumentRoot()\" ".($is_default_docroot ? 'checked="checked" ' : '')."/>&#160;<label for=\"use_default_docroot\">Standardeinstellung benutzen</label><br />
97
+    <input type=\"checkbox\" id=\"use_default_docroot\" name=\"use_default_docroot\" value=\"1\" ".($is_default_docroot ? 'checked="checked" ' : '')."/>&#160;<label for=\"use_default_docroot\">Standardeinstellung benutzen</label><br />
181 98
     <strong>".$vhost['homedir']."/websites/</strong>&#160;<input type=\"text\" id=\"docroot\" name=\"docroot\" size=\"30\" value=\"".$docroot."\" ".($is_default_docroot ? 'disabled="disabled" ' : '')."/>
182 99
   </div>
183 100
 </div>
... ...
@@ -186,7 +103,7 @@ $form .= "<br /><input type=\"checkbox\" name=\"options[]\" id=\"aliaswww\" valu
186 103
 /*
187 104
  * Boolean option, to be used when only one PHP version is available
188 105
  */
189
-$have_php = ($vhost['php'] == 'php53' ? ' checked="checked" ' : '');
106
+$have_php = ($vhost['php'] == 'php55' ? ' checked="checked" ' : '');
190 107
 
191 108
 /*
192 109
 $phpoptions = "<h5>PHP</h5>
... ...
@@ -234,14 +151,14 @@ $form .= "
234 151
 $form .= "
235 152
 <h4>Verwendung</h4>
236 153
         <div style=\"margin-left: 2em;\">
237
-	  <input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_regular\" value=\"regular\" ".(($vhost_type=='regular') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_regular\">&#160;Normal (selbst Dateien hinterlegen)</label><br />
154
+	  <input class=\"usageoption\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_regular\" value=\"regular\" ".(($vhost_type=='regular') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_regular\">&#160;Normal (selbst Dateien hinterlegen)</label><br />
238 155
 ";
239 156
 if ($vhost_type=='webapp')
240 157
 {
241 158
   // Wird nur noch angezeigt wenn der Vhost schon auf webapp konfiguriert ist, ansonsten nicht.
242 159
   // Die User sollen den Webapp-Installer benutzen.
243 160
   $form .= "
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\">&#160;Eine vorgefertigte Applikation nutzen</label><br />
161
+	  <input class=\"usageoption\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_webapp\" value=\"webapp\" ".(($vhost_type=='webapp') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_webapp\">&#160;Eine vorgefertigte Applikation nutzen</label><br />
245 162
 ";
246 163
 }
247 164
 $hsts_value = $vhost['hsts'];
... ...
@@ -251,8 +168,8 @@ if (isset($hsts_preset_values[$hsts_value])) {
251 168
   $hsts_preset_value = $hsts_value;
252 169
 }
253 170
 $form .= "
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\">&#160;WebDAV</label><br />
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\">&#160;Subversion-Server</label>
171
+	  <input class=\"usageoption\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_dav\" value=\"dav\" ".(($vhost_type=='dav') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_dav\">&#160;WebDAV</label><br />
172
+	  <input class=\"usageoption\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_svn\" value=\"svn\" ".(($vhost_type=='svn') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_svn\">&#160;Subversion-Server</label>
256 173
 	</div>
257 174
 <br />
258 175
 <br />
259 176