Ermögliche das Auswählen des Servers in den VHost-Einstellungen
Bernd Wurst

Bernd Wurst commited on 2013-01-18 10:24:55
Zeige 4 geänderte Dateien mit 42 Einfügungen und 2 Löschungen.

... ...
@@ -247,6 +247,20 @@ $form .= "
247 247
 $ipaddrs = user_ipaddrs();
248 248
 $certs = user_certs();
249 249
 $available_users = available_suexec_users();
250
+$available_servers = additional_servers();
251
+$available_servers[] = my_server_id();
252
+$available_servers = array_unique($available_servers);
253
+
254
+$selectable_servers = array();
255
+$all_servers = server_names();
256
+foreach ($all_servers as $id => $fqdn) {
257
+  if (in_array($id, $available_servers)) {
258
+    $selectable_servers[$id] = $fqdn;
259
+  }
260
+}
261
+if (!$vhost['server']) {
262
+  $vhost['server'] = my_server_id();
263
+}
250 264
 
251 265
 $extended = '';
252 266
   if (count($certs))
... ...
@@ -288,6 +302,15 @@ $extended = '';
288 302
       ".html_select('suexec_user', $userselect, $vhost['suexec_user'])."
289 303
       </div>";
290 304
   }
305
+  if (count($available_servers))
306
+  {
307
+    $extended .= "
308
+      <h5>Einrichten auf Server</h5>
309
+      <div style=\"margin-left: 2em;\">
310
+      ".html_select('server', $selectable_servers, $vhost['server'])."
311
+      </div>";
312
+
313
+  }
291 314
 if ($have_v6) 
292 315
 {
293 316
   $ipv6_address = '';
... ...
@@ -76,6 +76,7 @@ function empty_vhost()
76 76
   $vhost['cgi'] = 1;
77 77
   $vhost['ssl'] = NULL;
78 78
   $vhost['suexec_user'] = NULL;
79
+  $vhost['server'] = NULL;
79 80
   $vhost['logtype'] = NULL;
80 81
   $vhost['errorlog'] = 0;
81 82
   $vhost['is_dav'] = 0;
... ...
@@ -263,6 +264,15 @@ function save_vhost($vhost)
263 264
     if ($u['uid'] == $vhost['suexec_user'])
264 265
       $suexec_user = $u['uid'];
265 266
 
267
+  $server = 'NULL';
268
+  $available_servers = additional_servers();
269
+  if (in_array($vhost['server'], $available_servers)) {
270
+    $server = (int) $vhost['server'];
271
+  }
272
+  if ($server == my_server_id()) {
273
+    $server = 'NULL';
274
+  }
275
+
266 276
   $logtype = maybe_null($vhost['logtype']);
267 277
   $errorlog = (int) $vhost['errorlog'];
268 278
   if ($vhost['is_svn']) {
... ...
@@ -295,11 +305,11 @@ function save_vhost($vhost)
295 305
 
296 306
   if ($id != 0) {
297 307
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
298
-    db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, `suexec_user`={$suexec_user}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, autoipv6={$autoipv6}, options='{$options}', stats={$stats} WHERE id={$id} LIMIT 1");
308
+    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");
299 309
   }
300 310
   else {
301 311
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
302
-    $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, `suexec_user`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$suexec_user}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})");
312
+    $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})");
303 313
     $id = mysql_insert_id();
304 314
   }
305 315
   $oldvhost = get_vhost_details($id);
... ...
@@ -95,6 +95,9 @@ if ($_GET['action'] == 'edit')
95 95
   if (isset($_POST['suexec_user']))
96 96
     $vhost['suexec_user'] = $_POST['suexec_user'];
97 97
 
98
+  if (isset($_POST['server']))
99
+    $vhost['server'] = $_POST['server'];
100
+
98 101
   if ($_POST['vhost_type'] == 'regular') {
99 102
     $vhost['is_dav'] = 0;
100 103
     $vhost['is_svn'] = 0;
... ...
@@ -36,6 +36,10 @@ $vhosts = list_vhosts();
36 36
 
37 37
 if (count($vhosts) > 0)
38 38
 {
39
+  if (count($vhosts) > 10) {
40
+    addnew('edit', 'Neue Domain bzw. Subdomain einrichten');
41
+    addnew('../webapps/install', 'Neue Domain bzw. Subdomain mit vorinstallierter Web-Anwendung einrichten');
42
+  }
39 43
   output("<table><tr><th>(Sub-)Domain</th><th></th><th>Zusätzliche Alias-Namen</th><th>Protokoll</th><th>SSL</th><th>PHP</th><th>Lokaler Pfad<sup>*</sup></th></tr>\n");
40 44
 
41 45
   $even = True;
42 46