Browse code

IP-Adressen aktivieren

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1440 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on27/07/2009 08:14:28
Showing3 changed files
... ...
@@ -238,7 +238,7 @@ if (count($ipaddrs) || count($certs))
238 238
       ".html_select('cert', $certselect, $vhost['certid'])."
239 239
       </div>";
240 240
   }
241
- /* if (count($ipaddrs))
241
+  if (count($ipaddrs))
242 242
   {
243 243
     $ipselect = array(0 => 'System-Standard');
244 244
     foreach ($ipaddrs AS $i)
... ...
@@ -248,9 +248,9 @@ if (count($ipaddrs) || count($certs))
248 248
     $form .= "
249 249
       <h5>IP-Adresse</h5>
250 250
       <div style=\"margin-left: 2em;\">
251
-      ".html_select('ipaddr', $ipselect, $vhost['ipaddr'])."
251
+      ".html_select('ipv4', $ipselect, $vhost['ipv4'])."
252 252
       </div>";
253
-  } */
253
+  } 
254 254
   $form .= "</div>";
255 255
 }
256 256
 
... ...
@@ -37,6 +37,7 @@ function empty_vhost()
37 37
   $vhost['webapp_id'] = NULL;
38 38
   
39 39
   $vhost['cert'] = NULL;
40
+  $vhost['ipv4'] = NULL;
40 41
 
41 42
   $vhost['options'] = '';
42 43
   return $vhost;
... ...
@@ -217,17 +218,23 @@ function save_vhost($vhost)
217 218
   foreach ($certs as $c)
218 219
     if ($c['id'] == $vhost['cert'])
219 220
       $cert = $c['id'];
220
-
221 221
   if ($cert == 0)
222 222
     $cert = 'NULL';
223 223
 
224
+  $ipv4 = 'NULL';
225
+  $ipv4_avail = user_ipaddrs();
226
+  if (in_array($vhost['ipv4'], $ipv4_avail))
227
+  {
228
+    $ipv4 = maybe_null($vhost['ipv4']);
229
+  }
230
+
224 231
   if ($id != 0) {
225 232
     logger('modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
226
-    db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, `ssl`={$ssl}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, options='{$options}' WHERE id={$id} LIMIT 1");
233
+    db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, `ssl`={$ssl}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, options='{$options}' WHERE id={$id} LIMIT 1");
227 234
   }
228 235
   else {
229 236
     logger('modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
230
-    $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, `ssl`, logtype, errorlog, certid, options) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$ssl}, {$logtype}, {$errorlog}, {$cert}, '{$options}')");
237
+    $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, `ssl`, logtype, errorlog, certid, ipv4, options) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$ssl}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, '{$options}')");
231 238
     $id = mysql_insert_id();
232 239
   }
233 240
   $oldvhost = get_vhost_details($id);
... ...
@@ -103,6 +103,8 @@ if ($_GET['action'] == 'edit')
103 103
 
104 104
   $cert = (int) $_POST['cert'];
105 105
 
106
+  $ipv4 = $_POST['ipv4'];
107
+
106 108
   $logtype = '';
107 109
   switch ($_POST['logtype']) {
108 110
     case 'anonymous':
... ...
@@ -141,6 +143,7 @@ if ($_GET['action'] == 'edit')
141 143
   $vhost['php'] = $php;
142 144
   $vhost['ssl'] = $ssl;
143 145
   $vhost['cert'] = $cert;
146
+  $vhost['ipv4'] = $ipv4;
144 147
   $vhost['logtype'] = $logtype;
145 148
   $vhost['errorlog'] = $errorlog; 
146 149
   $vhost['options'] = $options;