domain = NULL ==> user-subdomain
bernd

bernd commited on 2007-08-20 13:02:02
Zeige 3 geänderte Dateien mit 24 Einfügungen und 17 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@636 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -54,6 +54,8 @@ output("<script type=\"text/javascript\">
54 54
   </script>");
55 55
 
56 56
 $defaultdocroot = $vhost['domain'];
57
+if (! $vhost['domain'])
58
+  $defaultdocroot = $_SESSION['userinfo']['username'].'.schokokeks.org';
57 59
 if ($vhost['hostname'])
58 60
   $defaultdocroot = $vhost['hostname'].'.'.$defaultdocroot;
59 61
 
... ...
@@ -22,12 +22,8 @@ function empty_vhost()
22 22
 {
23 23
   $vhost['hostname'] = '';
24 24
   
25
-  $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
26
-                                $_SESSION['userinfo']['uid']);
27
-  $dom = $domainlist[0];
28
-
29
-  $vhost['domain_id'] = $dom->id;
30
-  $vhost['domain'] = $dom->fqdn;
25
+  $vhost['domain_id'] = -1;
26
+  $vhost['domain'] = $_SESSION['userinfo']['username'].'.schokokeks.org';
31 27
   
32 28
   $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
33 29
   $vhost['docroot'] = NULL;
... ...
@@ -43,12 +39,8 @@ function empty_alias()
43 39
 {
44 40
   $alias['hostname'] = '';
45 41
   
46
-  $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
47
-                                $_SESSION['userinfo']['uid']);
48
-  $dom = $domainlist[0];
49
-
50
-  $alias['domain_id'] = $dom->id;
51
-  $alias['domain'] = $dom->fqdn;
42
+  $alias['domain_id'] = -1;
43
+  $alias['domain'] = $_SESSION['userinfo']['username'].'.schokokeks.org';
52 44
   
53 45
   $alias['options'] = '';
54 46
   return $alias;
... ...
@@ -64,6 +56,8 @@ function domainselect($selected = NULL, $selectattribute = '')
64 56
   $selected = (int) $selected;
65 57
 
66 58
   $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
59
+  $ret .= ' <option value="-1">'.$_SESSION['userinfo']['username'].'.schokokeks.org</option>';
60
+  $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
67 61
   foreach ($domainlist as $dom)
68 62
   {
69 63
     $s = ($selected == $dom->id) ? ' selected="selected" ': '';
... ...
@@ -137,6 +131,8 @@ function save_vhost($vhost)
137 131
   $domain = (int) $vhost['domainid'];
138 132
   if ($domain == 0)
139 133
     system_failure('$domain == 0');
134
+  if ($vhost['domainid'] == -1)
135
+    $domain = 'NULL';
140 136
   $docroot = maybe_null($vhost['docroot']);
141 137
   $php = maybe_null($vhost['php']);
142 138
   $logtype = maybe_null($vhost['logtype']);
... ...
@@ -164,6 +160,9 @@ function get_alias_details($id)
164 160
   
165 161
   $alias = mysql_fetch_assoc($result);
166 162
   
163
+  if ($alias['domain_id'] == NULL)
164
+    $alias['domain_id'] = -1;
165
+
167 166
   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
168 167
   get_vhost_details( (int) $alias['vhost'] );
169 168
 
... ...
@@ -189,6 +188,8 @@ function save_alias($alias)
189 188
   $domain = (int) $alias['domainid'];
190 189
   if ($domain == 0)
191 190
     system_failure('$domain == 0');
191
+  if ($alias['domainid'] == -1)
192
+    $domain = 'NULL';
192 193
   $vhost = get_vhost_details( (int) $alias['vhost']);
193 194
   $options = mysql_real_escape_string( $alias['options'] );
194 195
   if ($id == 0) {
... ...
@@ -23,10 +23,14 @@ if ($_GET['action'] == 'edit')
23 23
   DEBUG($vhost);
24 24
 
25 25
   $hostname = filter_input_hostname($_POST['hostname']);
26
+
27
+  $domainid = (int) $_POST['domain'];
28
+  if ($domainid != -1) {
26 29
     $domain = new Domain( (int) $_POST['domain'] );
27 30
     if ($domain->useraccount != $_SESSION['userinfo']['uid'])
28 31
       system_failure('Ungültige Domain');
29
-
32
+    $domainid = $domain->id;
33
+  }
30 34
 
31 35
   if (! is_array($_POST['options']))
32 36
     $_POST['options'] = array();
... ...
@@ -84,7 +88,7 @@ if ($_GET['action'] == 'edit')
84 88
   DEBUG('New options: '.$options);
85 89
 
86 90
   $vhost['hostname'] = $hostname;
87
-  $vhost['domainid'] = $domain->id;
91
+  $vhost['domainid'] = $domainid;
88 92
   $vhost['docroot'] = $docroot;
89 93
   $vhost['php'] = $php;
90 94
   $vhost['logtype'] = $logtype;
... ...
@@ -145,11 +149,11 @@ elseif ($_GET['action'] == 'deletealias')
145 149
   
146 150
   $alias = get_alias_details( (int) $_GET['alias'] );
147 151
   DEBUG($alias);
148
-  $alias_string = ((strlen($alias['hostname']) > 0) ? $alias['hostname'].'.' : '').$alias['domain'];
152
+  $alias_string = $alias['fqdn'];
149 153
   
150 154
   $vhost = get_vhost_details( $alias['vhost'] );
151 155
   DEBUG($vhost);
152
-  $vhost_string = ((strlen($vhost['hostname']) > 0) ? $vhost['hostname'].'.' : '').$vhost['domain'];
156
+  $vhost_string = $vhost['fqdn'];
153 157
   
154 158
   $sure = user_is_sure();
155 159
   if ($sure === NULL)
... ...
@@ -174,7 +178,7 @@ elseif ($_GET['action'] == 'delete')
174 178
   $section = 'vhosts_vhosts';
175 179
   
176 180
   $vhost = get_vhost_details( (int) $_GET['vhost'] );
177
-  $vhost_string = ((strlen($vhost['hostname']) > 0) ? $vhost['hostname'].'.' : '').$vhost['domain'];
181
+  $vhost_string = $vhost['fqdn'];
178 182
   
179 183
   $sure = user_is_sure();
180 184
   if ($sure === NULL)
181 185