Update codingstyle according to latest PHP CS Fixer 2.14.2
Hanno

Hanno commited on 2019-03-28 18:56:56
Zeige 1 geänderte Dateien mit 1295 Einfügungen und 0 Löschungen.

  • d1 0000000..01835bb
... ...
@@ -0,0 +1,1295 @@
1
+   1) modules/index/certsave.php
2
+      ---------- begin diff ----------
3
+--- Original
4
++++ New
5
+@@ @@
6
+     add_clientcert(
7
+-
8
+-      $_SESSION['clientcert_cert'],
9
+-
10
+-      $_SESSION['clientcert_dn'],
11
+-
12
+-      $_SESSION['clientcert_issuer'],
13
+-                 $_SESSION['clientcert_serial'],
14
+-
15
+-      $_SESSION['clientcert_valid_from'],
16
+-
17
+-      $_SESSION['clientcert_valid_until']
18
++        $_SESSION['clientcert_cert'],
19
++        $_SESSION['clientcert_dn'],
20
++        $_SESSION['clientcert_issuer'],
21
++        $_SESSION['clientcert_serial'],
22
++        $_SESSION['clientcert_valid_from'],
23
++        $_SESSION['clientcert_valid_until']
24
+ 
25
+   );
26
+ 
27
+     // Räume session auf
28
+     unset($_SESSION['clientcert_cert']);
29
+     unset($_SESSION['clientcert_dn']);
30
+     unset($_SESSION['clientcert_issuer']);
31
+     unset($_SESSION['clientcert_serial']);
32
+     unset($_SESSION['clientcert_valid_from']);
33
+     unset($_SESSION['clientcert_valid_until']);
34
+     header('Location: cert');
35
+ } elseif ($_GET['action'] == 'delete') {
36
+     $cert = get_cert_by_id($_GET['id']);
37
+     if (! $cert) {
38
+         system_failure('no ID');
39
+     }
40
+     $username = null;
41
+     if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
42
+         $username = $_SESSION['userinfo']['username'];
43
+         if (isset($_SESSION['subuser'])) {
44
+             $username = $_SESSION['subuser'];
45
+         }
46
+     } elseif ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
47
+         $username = $_SESSION['mailaccount'];
48
+     }
49
+     if (! ($cert['username'] == $username)) {
50
+         system_failure('Das Zertifikat ist nicht für Ihren Zugang eingerichtet');
51
+     }
52
+     $sure = user_is_sure();
53
+     if ($sure === null) {
54
+         are_you_sure("action=delete&id={$cert['id']}", filter_input_general("Möchten Sie das Zertifikat »{$cert['dn']}« (Seriennummer {$cert['serial']}, Gültig von {$cert['valid_from']} bis {$cert['valid_until']}) wirklich löschen?"));
55
+     } elseif ($sure === true) {
56
+         delete_clientcert($cert['id']);
57
+         if (! $debugmode) {
58
+             header("Location: cert");
59
+         }
60
+     } elseif ($sure === false) {
61
+         if (! $debugmode) {
62
+             header("Location: cert");
63
+         }
64
+     }
65
+ } else {
66
+     system_failure('Kein Kommando');
67
+ }
68
+ 
69
+
70
+      ----------- end diff -----------
71
+
72
+   2) modules/index/include/x509.php
73
+      ---------- begin diff ----------
74
+--- Original
75
++++ New
76
+@@ @@
77
+     db_query(
78
+-      "DELETE FROM system.clientcert WHERE id=:id AND type=:type AND username=:username",
79
+-           array(":id" => $id, ":type" => $type, ":username" => $username)
80
++        "DELETE FROM system.clientcert WHERE id=:id AND type=:type AND username=:username",
81
++        array(":id" => $id, ":type" => $type, ":username" => $username)
82
+   );
83
+ }
84
+ 
85
+
86
+      ----------- end diff -----------
87
+
88
+   3) modules/vhosts/include/vhosts.php
89
+      ---------- begin diff ----------
90
+--- Original
91
++++ New
92
+@@ @@
93
+         $domainlist = get_domain_list(
94
+-        $_SESSION['customerinfo']['customerno'],
95
+-                                  $_SESSION['userinfo']['uid']
96
++            $_SESSION['customerinfo']['customerno'],
97
++            $_SESSION['userinfo']['uid']
98
+     );
99
+     }
100
+     $selected = (int) $selected;
101
+ 
102
+     $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
103
+     $found = false;
104
+     foreach ($domainlist as $dom) {
105
+         $s = '';
106
+         if ($selected == $dom->id) {
107
+             $s = ' selected="selected" ';
108
+             $found = true;
109
+         }
110
+         $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
111
+     }
112
+     $userdomain = userdomain();
113
+     $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
114
+     if ($userdomain) {
115
+         $s = ($selected == -1 ? ' selected="selected"' : '');
116
+         $ret .= ' <option value="-1"'.$s.'>'.$_SESSION['userinfo']['username'].'.'.$userdomain['name'].'</option>';
117
+     }
118
+     if ($selected == -2) {
119
+         $s = ($selected == -2 ? ' selected="selected"' : '');
120
+         $ret .= ' <option value="-2"'.$s.'>'.$_SESSION['userinfo']['username'].'.'.config('masterdomain').' (Bitte nicht mehr benutzen!)</option>';
121
+         if ($selected > 0 and ! $found) {
122
+             system_failure("Hier wird eine Domain benutzt, die nicht zu diesem Benutzeraccount gehört. Bearbeiten würde Daten zerstören!");
123
+         }
124
+     }
125
+     $ret .= '</select>';
126
+     return $ret;
127
+ }
128
+ 
129
+ 
130
+ 
131
+ function get_vhost_details($id)
132
+ {
133
+     DEBUG("Lese #{$id}...");
134
+     $id = (int) $id;
135
+     $uid = (int) $_SESSION['userinfo']['uid'];
136
+     $result = db_query("SELECT vh.*,IF(dav.id IS NULL OR dav.type='svn', 0, 1) AS is_dav,IF(dav.id IS NULL OR dav.type='dav', 0, 1) AS is_svn, IF(webapps.id IS NULL, 0, 1) AS is_webapp FROM vhosts.v_vhost AS vh LEFT JOIN vhosts.dav ON (dav.vhost=vh.id) LEFT JOIN vhosts.webapps ON (webapps.vhost = vh.id) WHERE uid=:uid AND vh.id=:id", array(":uid" => $uid, ":id" => $id));
137
+     if ($result->rowCount() != 1) {
138
+         system_failure('Interner Fehler beim Auslesen der Daten');
139
+     }
140
+ 
141
+     $ret = $result->fetch();
142
+ 
143
+     if ($ret['domain_id'] === null) {
144
+         $ret['domain_id'] = -2;
145
+     }
146
+     $ret['cert'] = $ret['certid'];
147
+     $userdomain = userdomain();
148
+     if ($ret['domain_id'] == $userdomain['id']) {
149
+         $user = $_SESSION['userinfo']['username'];
150
+         $ret['domain_id'] = -1;
151
+         if ($ret['hostname'] == $user) {
152
+             $ret['hostname'] = null;
153
+         } elseif (substr($ret['hostname'], -strlen($user), strlen($user)) == $user) {
154
+             $ret['hostname'] = substr($ret['hostname'], 0, -strlen($user)-1); // Punkt mit entfernen!
155
+         } else {
156
+             system_failure('Userdomain ohne Username!');
157
+         }
158
+     }
159
+     if ($ret['hsts'] === null) {
160
+         DEBUG('HSTS: '.$ret['hsts']);
161
+         $ret['hsts'] = -1;
162
+     }
163
+     $ret['server'] = $ret['server_id'];
164
+     DEBUG($ret);
165
+     return $ret;
166
+ }
167
+ 
168
+ 
169
+ function get_aliases($vhost)
170
+ {
171
+     $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost=?", array($vhost));
172
+     $ret = array();
173
+     while ($item = $result->fetch()) {
174
+         array_push($ret, $item);
175
+     }
176
+     return $ret;
177
+ }
178
+ 
179
+ 
180
+ 
181
+ function get_all_aliases($vhost)
182
+ {
183
+     //$vhost = get_vhost_details( (int) $vhost );
184
+     $aliases = get_aliases($vhost['id']);
185
+     $ret = array();
186
+     if (strstr($vhost['options'], 'aliaswww')) {
187
+         array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : null)));
188
+     }
189
+     foreach ($aliases as $item) {
190
+         array_push($ret, $item);
191
+         if (strstr($item['options'], 'aliaswww')) {
192
+             array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : null)));
193
+         }
194
+     }
195
+     return $ret;
196
+ }
197
+ 
198
+ 
199
+ function list_available_webapps()
200
+ {
201
+     $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
202
+     $ret = array();
203
+     while ($item = $result->fetch()) {
204
+         array_push($ret, $item);
205
+     }
206
+     return $ret;
207
+ }
208
+ 
209
+ 
210
+ function delete_vhost($id)
211
+ {
212
+     $id = (int) $id;
213
+     if ($id == 0) {
214
+         system_failure("id == 0");
215
+     }
216
+     $vhost = get_vhost_details($id);
217
+     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
218
+     db_query("DELETE FROM vhosts.vhost WHERE id=?", array($vhost['id']));
219
+ }
220
+ 
221
+ 
222
+ 
223
+ function make_svn_vhost($id)
224
+ {
225
+     $id = (int) $id;
226
+     if ($id == 0) {
227
+         system_failure("id == 0");
228
+     }
229
+     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
230
+     db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES (?, 'svn')", array($id));
231
+     db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
232
+ }
233
+ 
234
+ function make_dav_vhost($id)
235
+ {
236
+     $id = (int) $id;
237
+     if ($id == 0) {
238
+         system_failure("id == 0");
239
+     }
240
+     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
241
+     db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES (?, 'dav', 'nouserfile')", array($id));
242
+     db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
243
+ }
244
+ 
245
+ function make_regular_vhost($id)
246
+ {
247
+     $id = (int) $id;
248
+     if ($id == 0) {
249
+         system_failure("id == 0");
250
+     }
251
+     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
252
+     db_query("DELETE FROM vhosts.dav WHERE vhost=?", array($id));
253
+     db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
254
+ }
255
+ 
256
+ 
257
+ function make_webapp_vhost($id, $webapp)
258
+ {
259
+     $id = (int) $id;
260
+     $webapp = (int) $webapp;
261
+     if ($id == 0) {
262
+         system_failure("id == 0");
263
+     }
264
+     $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id=?", array($webapp));
265
+     if ($result->rowCount() == 0) {
266
+         system_failure("webapp-id invalid");
267
+     }
268
+     $webapp_name = $result->fetch(PDO::FETCH_OBJ)->displayname;
269
+     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
270
+     db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES (?, ?)", array($id, $webapp));
271
+     mail('webapps-setup@schokokeks.org', 'setup', 'setup');
272
+ }
273
+ 
274
+ 
275
+ function check_hostname_collision($hostname, $domain)
276
+ {
277
+     $uid = (int) $_SESSION['userinfo']['uid'];
278
+     # Neuer vhost => Prüfe Duplikat
279
+     $args = array(":hostname" => $hostname, ":domain" => $domain, ":uid" => $uid);
280
+     $domaincheck = "domain=:domain";
281
+     if ($domain == -1) {
282
+         $userdomain = userdomain();
283
+         if ($hostname) {
284
+             $hostname .= ".".$_SESSION['userinfo']['username'];
285
+         }
286
+         $args[":domain"] = $userdomain['id'];
287
+     }
288
+     if ($domain == -2) {
289
+         unset($args[":domain"]);
290
+         $domaincheck = "domain IS NULL";
291
+     }
292
+     $hostnamecheck = "hostname=:hostname";
293
+     if (! $hostname) {
294
+         $hostnamecheck = "hostname IS NULL";
295
+         unset($args[":hostname"]);
296
+     }
297
+     $result = db_query("SELECT id FROM vhosts.vhost WHERE {$hostnamecheck} AND {$domaincheck} AND user=:uid", $args);
298
+     if ($result->rowCount() > 0) {
299
+         system_failure('Eine Konfiguration mit diesem Namen gibt es bereits.');
300
+     }
301
+     if ($domain <= -1) {
302
+         return ;
303
+     }
304
+     unset($args[":uid"]);
305
+     $result = db_query("SELECT id, vhost FROM vhosts.v_alias WHERE {$hostnamecheck} AND {$domaincheck}", $args);
306
+     if ($result->rowCount() > 0) {
307
+         $data = $result->fetch();
308
+         $vh = get_vhost_details($data['vhost']);
309
+         system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
310
+     }
311
+ }
312
+ 
313
+ function save_vhost($vhost)
314
+ {
315
+     if (! is_array($vhost)) {
316
+         system_failure('$vhost kein array!');
317
+     }
318
+     $id = (int) $vhost['id'];
319
+     $hostname = $vhost['hostname'];
320
+     $domain = (int) $vhost['domain_id'];
321
+     if ($domain == 0) {
322
+         system_failure('$domain == 0');
323
+     }
324
+     if ($vhost['domain_id'] == -2) {
325
+         $domain = null;
326
+     }
327
+     if ($id == 0) {
328
+         check_hostname_collision($vhost['hostname'], $vhost['domain_id']);
329
+     }
330
+     $hsts = (int) $vhost['hsts'];
331
+     if ($hsts < 0) {
332
+         $hsts = null;
333
+     }
334
+     $suexec_user = null;
335
+ 
336
+     $available_suexec = available_suexec_users();
337
+     foreach ($available_suexec as $u) {
338
+         if ($u['uid'] == $vhost['suexec_user']) {
339
+             $suexec_user = $u['uid'];
340
+         }
341
+     }
342
+ 
343
+     $server = null;
344
+     $available_servers = additional_servers();
345
+     if (in_array($vhost['server'], $available_servers)) {
346
+         $server = (int) $vhost['server'];
347
+     }
348
+     if ($server == my_server_id()) {
349
+         $server = null;
350
+     }
351
+ 
352
+     if ($vhost['is_svn']) {
353
+         if (! $vhost['options']) {
354
+             $vhost['options']='nodocroot';
355
+         } else {
356
+             $vhost['options'].=",nodocroot";
357
+         }
358
+     }
359
+ 
360
+     $cert = null;
361
+     $certs = user_certs();
362
+     foreach ($certs as $c) {
363
+         if ($c['id'] == $vhost['cert']) {
364
+             $cert = $c['id'];
365
+         }
366
+     }
367
+ 
368
+     $ipv4 = null;
369
+     $ipv4_avail = user_ipaddrs();
370
+     if (in_array($vhost['ipv4'], $ipv4_avail)) {
371
+         $ipv4 = $vhost['ipv4'];
372
+     }
373
+ 
374
+     $autoipv6 = 1;
375
+     if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
376
+         $autoipv6 = $vhost['autoipv6'];
377
+     }
378
+ 
379
+     if (!($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'http' ||
380
+         $vhost['ssl'] == 'https')) {
381
+         $vhost['ssl'] = null;
382
+     }
383
+ 
384
+     $args = array(":hostname" => ($hostname ? $hostname : null),
385
+                 ":domain" => $domain,
386
+                 ":docroot" => ($vhost['docroot'] ? $vhost['docroot'] : null),
387
+                 ":php" => $vhost['php'],
388
+                 ":cgi" => ($vhost['cgi'] == 1 ? 1 : 0),
389
+                 ":ssl" => $vhost['ssl'],
390
+                 ":hsts" => $hsts,
391
+                 ":suexec_user" => $suexec_user,
392
+                 ":server" => $server,
393
+                 ":logtype" => ($vhost['logtype'] ? $vhost['logtype'] : null),
394
+                 ":errorlog" => (int) $vhost['errorlog'],
395
+                 ":cert" => $cert,
396
+                 ":ipv4" => $ipv4,
397
+                 ":autoipv6" => $autoipv6,
398
+                 ":options" => $vhost['options'],
399
+                 ":stats" => ($vhost['stats'] ? $vhost['stats'] : null),
400
+                 ":id" => $id);
401
+     if ($id != 0) {
402
+         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
403
+         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", $args);
404
+     } else {
405
+         $args[":user"] = $_SESSION['userinfo']['uid'];
406
+         unset($args[":id"]);
407
+         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
408
+         $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 ".
409
+                        "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options, :stats)", $args, true);
410
+         $id = db_insert_id();
411
+     }
412
+     $oldvhost = get_vhost_details($id);
413
+     /*
414
+       these vars may be 0 or 1.
415
+       So newval > oldval means that it has been switched on yet.
416
+     */
417
+     if ($vhost['is_dav'] > $oldvhost['is_dav']) {
418
+         make_dav_vhost($id);
419
+     } elseif ($vhost['is_svn'] > $oldvhost['is_svn']) {
420
+         make_svn_vhost($id);
421
+     } elseif ($vhost['is_webapp'] > $oldvhost['is_webapp']) {
422
+         make_webapp_vhost($id, $vhost['webapp_id']);
423
+     } elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0) {
424
+         make_regular_vhost($id);
425
+     }
426
+ }
427
+ 
428
+ 
429
+ function get_alias_details($id)
430
+ {
431
+     $id = (int) $id;
432
+     $uid = (int) $_SESSION['userinfo']['uid'];
433
+     $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", array($id));
434
+ 
435
+     if ($result->rowCount() != 1) {
436
+         system_failure('Interner Fehler beim Auslesen der Alias-Daten');
437
+     }
438
+ 
439
+     $alias = $result->fetch();
440
+ 
441
+     if ($alias['domain_id'] == null) {
442
+         $alias['domain_id'] = -1;
443
+     }
444
+ 
445
+     /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
446
+     get_vhost_details((int) $alias['vhost']);
447
+ 
448
+     return $alias;
449
+ }
450
+ 
451
+ 
452
+ function delete_alias($id)
453
+ {
454
+     $id = (int) $id;
455
+     $alias = get_alias_details($id);
456
+ 
457
+     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Removing alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
458
+     db_query("DELETE FROM vhosts.alias WHERE id=?", array($id));
459
+ }
460
+ 
461
+ function save_alias($alias)
462
+ {
463
+     if (! is_array($alias)) {
464
+         system_failure('$alias kein array!');
465
+     }
466
+     $id = (isset($alias['id']) ? (int) $alias['id'] : 0);
467
+     $domain = (int) $alias['domain_id'];
468
+     if ($domain == 0) {
469
+         system_failure('$domain == 0');
470
+     }
471
+     if ($alias['domain_id'] == -2) {
472
+         $domain = null;
473
+     }
474
+     $vhost = get_vhost_details((int) $alias['vhost']);
475
+     if (! $alias['hostname']) {
476
+         $alias['hostname'] = null;
477
+     }
478
+     $args = array(":hostname" => $alias['hostname'],
479
+                 ":domain" => $domain,
480
+                 ":vhost" => $vhost['id'],
481
+                 ":options" => $alias['options'],
482
+                 ":id" => $id);
483
+     if ($id == 0) {
484
+         unset($args[":id"]);
485
+         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
486
+         db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES (:hostname, :domain, :vhost, :options)", $args, true);
487
+     } else {
488
+         unset($args[":vhost"]);
489
+         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
490
+         db_query("UPDATE vhosts.alias SET hostname=:hostname, domain=:domain, options=:options WHERE id=:id", $args, true);
491
+     }
492
+ }
493
+ 
494
+ 
495
+ function available_suexec_users()
496
+ {
497
+     $uid = (int) $_SESSION['userinfo']['uid'];
498
+     $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser=?", array($uid));
499
+     $ret = array();
500
+     while ($i = $result->fetch()) {
501
+         $ret[] = $i;
502
+     }
503
+     DEBUG('available suexec-users:');
504
+     DEBUG($ret);
505
+     return $ret;
506
+ }
507
+ 
508
+ 
509
+ function user_ipaddrs()
510
+ {
511
+     $uid = (int) $_SESSION['userinfo']['uid'];
512
+     $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid=?", array($uid));
513
+     $ret = array();
514
+     while ($i = $result->fetch()) {
515
+         $ret[] = $i['ipaddr'];
516
+     }
517
+     DEBUG($ret);
518
+     return $ret;
519
+ }
520
+ 
521
+
522
+      ----------- end diff -----------
523
+
524
+   4) modules/vhosts/include/certs.php
525
+      ---------- begin diff ----------
526
+--- Original
527
++++ New
528
+@@ @@
529
+     db_query(
530
+-      "INSERT INTO vhosts.certs (uid, subject, cn, san, valid_from, valid_until, chain, cert, `key`) VALUES (:uid, :subject, :cn, :san, :valid_from, :valid_until, :chain, :cert, :key)",
531
++        "INSERT INTO vhosts.certs (uid, subject, cn, san, valid_from, valid_until, chain, cert, `key`) VALUES (:uid, :subject, :cn, :san, :valid_from, :valid_until, :chain, :cert, :key)",
532
+@@ @@
533
+     db_query(
534
+-      "INSERT INTO vhosts.csr (uid, hostname, san, bits, `replace`, csr, `key`) VALUES (:uid, :cn, :san, :bits, :replace, :csr, :key)",
535
+-           array(":uid" => $uid, ":cn" => $cn, ":san" => $san, ":bits" => $bits,
536
++        "INSERT INTO vhosts.csr (uid, hostname, san, bits, `replace`, csr, `key`) VALUES (:uid, :cn, :san, :bits, :replace, :csr, :key)",
537
++        array(":uid" => $uid, ":cn" => $cn, ":san" => $san, ":bits" => $bits,
538
+                  ":replace" => $replace, ":csr" => $csr, ":key" => $key)
539
+   );
540
+     $id = db_insert_id();
541
+     return $id;
542
+ }
543
+ 
544
+
545
+      ----------- end diff -----------
546
+
547
+   5) modules/domains/include/domains.php
548
+      ---------- begin diff ----------
549
+--- Original
550
++++ New
551
+@@ @@
552
+         "UPDATE kundendaten.domains SET status='pretransfer', dns=1 WHERE id=? AND kunde=?",
553
+-            array($domain, $cid)
554
++        array($domain, $cid)
555
+@@ @@
556
+         "UPDATE kundendaten.domains SET status='prereg', dns=1 WHERE id=? AND kunde=?",
557
+-            array($domain, $cid)
558
++        array($domain, $cid)
559
+     );
560
+ }
561
+ 
562
+ 
563
+ function insert_domain_external($domain, $dns = false, $mail = true)
564
+ {
565
+     $cid = (int) $_SESSION['customerinfo']['customerno'];
566
+     $uid = (int) $_SESSION['userinfo']['uid'];
567
+     require_once("domainapi.php");
568
+     $info = api_domain_available($domain);
569
+     if (in_array($info['status'], array('nameContainsForbiddenCharacter', 'suffixDoesNotExist'))) {
570
+         system_failure("Diese Domain scheint ungültig zu sein!");
571
+     }
572
+     $tld = $info['domainSuffix'];
573
+     $domainname = str_replace(".$tld", "", $info['domainNameUnicode']);
574
+     logger(LOG_WARNING, 'modules/domains/include/domains', 'domains', 'Inserting external domain '.$info['domainNameUnicode']." DNS:{$dns} / Mail:{$mail}");
575
+ 
576
+     db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
577
+         ('external', ?, ?, ?, ?, 'external', 'other', 0, ?, 1)", array($cid, $uid, $domainname, $tld, ($mail ? 'auto' : 'none')));
578
+     $id = db_insert_id();
579
+     if ($dns) {
580
+         db_query("UPDATE kundendaten.domains SET dns=1 WHERE id=?", array($id));
581
+     }
582
+     if ($mail) {
583
+         $vmailserver = (int) $_SESSION['userinfo']['server'];
584
+         db_query("INSERT INTO mail.virtual_mail_domains (domain, server) VALUES (?, ?)", array($id, $vmailserver));
585
+     }
586
+     return $id;
587
+ }
588
+ 
589
+ function delete_domain($id)
590
+ {
591
+     $cid = (int) $_SESSION['customerinfo']['customerno'];
592
+     logger(LOG_WARNING, 'modules/domains/include/domains', 'domains', 'Deleting domain '.$id);
593
+     db_query("DELETE FROM kundendaten.domains WHERE id=? AND kunde=?", array($id, $cid));
594
+ }
595
+ 
596
+
597
+      ----------- end diff -----------
598
+
599
+   6) modules/dns/include/dnsinclude.php
600
+      ---------- begin diff ----------
601
+--- Original
602
++++ New
603
+@@ @@
604
+     db_query(
605
+-      "INSERT INTO dns.dyndns (uid, handle, password, sshkey) VALUES ".
606
++        "INSERT INTO dns.dyndns (uid, handle, password, sshkey) VALUES ".
607
+            "(:uid, :handle, :pwhash, :sshkey)",
608
+-           array(":uid" => $uid, ":handle" => $handle, ":pwhash" => $pwhash, ":sshkey" => $sshkey)
609
++        array(":uid" => $uid, ":handle" => $handle, ":pwhash" => $pwhash, ":sshkey" => $sshkey)
610
+@@ @@
611
+         db_query(
612
+-        "UPDATE dns.custom_records SET hostname=:newhostname WHERE ".
613
++            "UPDATE dns.custom_records SET hostname=:newhostname WHERE ".
614
+              "hostname=:oldhostname AND domain=:dom AND dyndns=:dyndns AND ip IS NULL",
615
+-             array(":dom" => $masterdomain->id, ":newhostname" => filter_input_hostname($handle).'.'.$_SESSION['userinfo']['username'],
616
++            array(":dom" => $masterdomain->id, ":newhostname" => filter_input_hostname($handle).'.'.$_SESSION['userinfo']['username'],
617
+                    ":oldhostname" => $oldaccount['handle'].'.'.$_SESSION['userinfo']['username'],  ":dyndns" => $id)
618
+     );
619
+     }
620
+ 
621
+     $args = array(":handle" => $handle, ":sshkey" => $sshkey, ":id" => $id);
622
+     $pwhash = null;
623
+     if ($password_http && $password_http != '************') {
624
+         $args[":pwhash"] = "{SHA}".base64_encode(sha1($password_http, true));
625
+         db_query("UPDATE dns.dyndns SET handle=:handle, password=:pwhash, sshkey=:sshkey WHERE id=:id", $args);
626
+     } else {
627
+         db_query("UPDATE dns.dyndns SET handle=:handle, sshkey=:sshkey WHERE id=:id", $args);
628
+     }
629
+     logger(LOG_INFO, "modules/dns/include/dnsinclude", "dyndns", "edited account »{$id}«");
630
+ }
631
+ 
632
+ 
633
+ function delete_dyndns_account($id)
634
+ {
635
+     $id = (int) $id;
636
+ 
637
+     db_query("DELETE FROM dns.dyndns WHERE id=?", array($id));
638
+     logger(LOG_INFO, "modules/dns/include/dnsinclude", "dyndns", "deleted account »{$id}«");
639
+ }
640
+ 
641
+ 
642
+ function get_dyndns_records($id)
643
+ {
644
+     $id = (int) $id;
645
+     $result = db_query("SELECT hostname, domain, type, ttl, lastchange, id FROM dns.custom_records WHERE dyndns=?", array($id));
646
+     $data = array();
647
+     while ($entry = $result->fetch()) {
648
+         $dom = new Domain((int) $entry['domain']);
649
+         if ($dom->fqdn != config('masterdomain') && $dom->fqdn != config('user_vhosts_domain')) {
650
+             $dom->ensure_userdomain();
651
+         }
652
+         $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn;
653
+         if (! $entry['hostname']) {
654
+             $entry['fqdn'] = $dom->fqdn;
655
+         }
656
+         array_push($data, $entry);
657
+     }
658
+     DEBUG($data);
659
+     return $data;
660
+ }
661
+ 
662
+ $valid_record_types = array('a', 'aaaa', 'mx', 'ns', 'spf', 'txt', 'cname', 'ptr', 'srv', 'raw', 'sshfp', 'caa');
663
+ 
664
+ 
665
+ function blank_dns_record($type)
666
+ {
667
+     global $valid_record_types;
668
+     if (!in_array(strtolower($type), $valid_record_types)) {
669
+         system_failure('invalid type: '.$type);
670
+     }
671
+     $rec = array('hostname' => null,
672
+                'domain' => 0,
673
+                'type' => strtolower($type),
674
+                'ttl' => 3600,
675
+                'ip' => null,
676
+                'dyndns' => null,
677
+                'data' => null,
678
+                'spec' => null);
679
+     if (strtolower($type) == 'mx') {
680
+         $rec['data'] = config('default_mx');
681
+         $rec['spec'] = '5';
682
+     }
683
+     return $rec;
684
+ }
685
+ 
686
+ function get_dns_record($id)
687
+ {
688
+     $id = (int) $id;
689
+     $result = db_query("SELECT hostname, domain, type, ip, dyndns, spec, data, ttl FROM dns.custom_records WHERE id=?", array($id));
690
+     if ($result->rowCount() != 1) {
691
+         system_failure('illegal ID');
692
+     }
693
+     $data = $result->fetch();
694
+     $dom = new Domain((int) $data['domain']);
695
+     $dom->ensure_userdomain();
696
+     DEBUG($data);
697
+     return $data;
698
+ }
699
+ 
700
+ 
701
+ function get_domain_records($dom)
702
+ {
703
+     $dom = (int) $dom;
704
+     $result = db_query("SELECT hostname, domain, type, ip, dyndns, spec, data, ttl, id FROM dns.custom_records WHERE domain=?", array($dom));
705
+     $data = array();
706
+     while ($entry = $result->fetch()) {
707
+         $dom = new Domain((int) $entry['domain']);
708
+         $dom->ensure_userdomain();
709
+         $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn;
710
+         if (! $entry['hostname']) {
711
+             $entry['fqdn'] = $dom->fqdn;
712
+         }
713
+         array_push($data, $entry);
714
+     }
715
+     DEBUG($data);
716
+     return $data;
717
+ }
718
+ 
719
+ function get_domain_auto_records($domainname)
720
+ {
721
+     $result = db_query("SELECT hostname, domain, CONCAT_WS('.', hostname, domain) AS fqdn, type, ip, spec, data, ttl FROM dns.tmp_autorecords WHERE domain=?", array($domainname));
722
+     $data = array();
723
+     while ($entry = $result->fetch()) {
724
+         array_push($data, $entry);
725
+     }
726
+     DEBUG($data);
727
+     return $data;
728
+ }
729
+ 
730
+ 
731
+ $implemented_record_types = array('a', 'aaaa', 'mx', 'spf', 'txt', 'cname', 'ptr', 'srv', 'ns', 'sshfp', 'caa');
732
+ 
733
+ function save_dns_record($id, $record)
734
+ {
735
+     global $valid_record_types;
736
+     global $implemented_record_types;
737
+     $record['type'] = strtolower($record['type']);
738
+     if (!in_array($record['type'], $valid_record_types)) {
739
+         system_failure('invalid type: '.$record['type']);
740
+     }
741
+     if (!in_array($record['type'], $implemented_record_types)) {
742
+         system_failure('record type '.$record['type'].' not implemented at the moment.');
743
+     }
744
+     $dom = new Domain((int) $record['domain']);
745
+     $dom->ensure_userdomain();
746
+     if (! $dom->id) {
747
+         system_failure('invalid domain');
748
+     }
749
+     if ($record['hostname'] == '') {
750
+         $record['hostname'] = null;
751
+     }
752
+     verify_input_hostname($record['hostname'], true);
753
+     verify_input_recorddata($record['data']);
754
+     if ($record['ttl'] &&  (int) $record['ttl'] < 1) {
755
+         system_failure('Fehler bei TTL');
756
+     }
757
+     switch ($record['type']) {
758
+     case 'a':
759
+       if ($record['dyndns']) {
760
+           get_dyndns_account($record['dyndns']);
761
+           $record['ip'] = null;
762
+       } else {
763
+           verify_input_ipv4($record['ip']);
764
+           $record['data'] = null;
765
+           $record['spec'] = null;
766
+       }
767
+       break;
768
+     case 'aaaa':
769
+       if ($record['dyndns']) {
770
+           get_dyndns_account($record['dyndns']);
771
+           $record['ip'] = null;
772
+       } else {
773
+           $record['dyndns'] = null;
774
+           verify_input_ipv6($record['ip']);
775
+           $record['data'] = null;
776
+           $record['spec'] = null;
777
+       }
778
+       break;
779
+     case 'mx':
780
+       $record['dyndns'] = null;
781
+       $record['spec'] = (int) $record['spec'];
782
+       if ($record['spec'] < 0) {
783
+           system_failure("invalid priority");
784
+       }
785
+       verify_input_hostname($record['data']);
786
+       if (! $record['data']) {
787
+           system_failure('MX hostname missing');
788
+       }
789
+       $record['ip'] = null;
790
+       break;
791
+     case 'ptr':
792
+     case 'ns':
793
+       if (!$record['hostname']) {
794
+           system_failure("Die angestrebte Konfiguration wird nicht funktionieren, Speichern wurde daher verweigert.");
795
+       }
796
+       // no break
797
+     case 'cname':
798
+       $record['dyndns'] = null;
799
+       $record['spec'] = null;
800
+       $record['ip'] = null;
801
+       verify_input_hostname($record['data']);
802
+       if (! $record['data']) {
803
+           system_failure('destination host missing');
804
+       }
805
+       break;
806
+ 
807
+     case 'spf':
808
+     case 'txt':
809
+       $record['dyndns'] = null;
810
+       $record['spec'] = null;
811
+       $record['ip'] = null;
812
+       if (! $record['data']) {
813
+           system_failure('text entry missing');
814
+       }
815
+       break;
816
+ 
817
+     case 'sshfp':
818
+       $record['dyndns'] = null;
819
+       $record['spec'] = max((int) $record['spec'], 1);
820
+       $record['ip'] = null;
821
+       if (! $record['data']) {
822
+           system_failure('text entry missing');
823
+       }
824
+       break;
825
+ 
826
+     case 'caa':
827
+       $record['dyndns'] = null;
828
+       $record['ip'] = null;
829
+       if (! $record['data']) {
830
+           system_failure('text entry missing');
831
+       }
832
+       break;
833
+ 
834
+     case 'srv':
835
+       system_failure('not implemented yet');
836
+       // no break
837
+     default:
838
+       system_failure('Not implemented');
839
+   }
840
+     $id = (int) $id;
841
+     $args = array(":domain" => $dom->id,
842
+                 ":hostname" => $record['hostname'],
843
+                 ":type" => $record['type'],
844
+                 ":ttl" => ($record['ttl'] == 0 ? null : (int) $record['ttl']),
845
+                 ":ip" => $record['ip'],
846
+                 ":dyndns" => $record['dyndns'],
847
+                 ":data" => $record['data'],
848
+                 ":spec" => $record['spec']);
849
+     if ($id) {
850
+         $args[":id"] = $id;
851
+         db_query("UPDATE dns.custom_records SET hostname=:hostname, domain=:domain, type=:type, ttl=:ttl, ip=:ip, dyndns=:dyndns, data=:data, spec=:spec WHERE id=:id", $args);
852
+     } else {
853
+         db_query("INSERT INTO dns.custom_records (hostname, domain, type, ttl, ip, dyndns, data, spec) VALUES (:hostname, :domain, :type, :ttl, :ip, :dyndns, :data, :spec)", $args);
854
+     }
855
+ }
856
+ 
857
+ 
858
+ function delete_dns_record($id)
859
+ {
860
+     $id = (int) $id;
861
+     // Diese Funktion prüft, ob der Eintrag einer eigenen Domain gehört
862
+     $record = get_dns_record($id);
863
+     db_query("DELETE FROM dns.custom_records WHERE id=?", array($id));
864
+ }
865
+ 
866
+ 
867
+ function convert_from_autorecords($domainid)
868
+ {
869
+     $dom = new Domain((int) $domainid);
870
+     $dom->ensure_userdomain();
871
+     $dom = $dom->id;
872
+ 
873
+     db_query("INSERT IGNORE INTO dns.custom_records SELECT r.id, r.lastchange, type, d.id, hostname, ip, NULL AS dyndns, data, spec, ttl FROM dns.v_tmptable_allrecords AS r INNER JOIN dns.v_domains AS d ON (d.name=r.domain) WHERE d.id=?", array($dom));
874
+     disable_autorecords($dom);
875
+     db_query("UPDATE dns.dnsstatus SET status='outdated'");
876
+     warning("Die automatischen Einträge werden in Kürze abgeschaltet, bitte haben Sie einen Moment Geduld.");
877
+ }
878
+ 
879
+ 
880
+ function enable_autorecords($domainid)
881
+ {
882
+     $dom = new Domain((int) $domainid);
883
+     $dom->ensure_userdomain();
884
+     $dom = $dom->id;
885
+ 
886
+     db_query("UPDATE kundendaten.domains SET autodns=1 WHERE id=?", array($dom));
887
+     db_query("DELETE FROM dns.custom_records WHERE type='ns' AND domain=? AND hostname IS NULL", array($dom));
888
+     warning("Die automatischen Einträge werden in Kürze aktiviert, bitte haben Sie einen Moment Geduld.");
889
+ }
890
+ 
891
+ function disable_autorecords($domainid)
892
+ {
893
+     $dom = new Domain((int) $domainid);
894
+     $dom->ensure_userdomain();
895
+     $dom = $dom->id;
896
+ 
897
+     db_query("UPDATE kundendaten.domains SET autodns=0 WHERE id=?", array($dom));
898
+ }
899
+ 
900
+ 
901
+ function domain_is_maildomain($domain)
902
+ {
903
+     $domain = (int) $domain;
904
+     $result = db_query("SELECT mail FROM kundendaten.domains WHERE id=?", array($domain));
905
+     $dom = $result->fetch();
906
+     return ($dom['mail'] != 'none');
907
+ }
908
+ 
909
+ 
910
+ $own_ns = array();
911
+ 
912
+ function own_ns()
913
+ {
914
+     global $own_ns;
915
+ 
916
+     if (count($own_ns) < 1) {
917
+         $auth = dns_get_record(config('masterdomain'), DNS_NS);
918
+         foreach ($auth as $ns) {
919
+             $own_ns[] = $ns['target'];
920
+         }
921
+     }
922
+ 
923
+     return $own_ns;
924
+ }
925
+ 
926
+ 
927
+ $tld_ns = array();
928
+ 
929
+ function check_dns($domainname, $tld)
930
+ {
931
+     global $tld_ns;
932
+     $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
933
+ 
934
+     if (! isset($tld_ns[$tld])) {
935
+         $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns '.$tld.'.');
936
+         $line = explode("\n", $resp, 2)[0];
937
+         $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $line);
938
+         $tld_ns[$tld] = $NS;
939
+     }
940
+ 
941
+     $resp = shell_exec('dig @'.$tld_ns[$tld].' +noall +authority -t ns '.$domain.'.');
942
+     $line = explode("\n", $resp, 2)[0];
943
+     if (preg_match('/^.*\\sIN\\s+NS\\s+/', $line) === 0) {
944
+         return "NXDOMAIN";
945
+     }
946
+     $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+).$/", '\1', $line);
947
+ 
948
+     $own_ns = own_ns();
949
+ 
950
+     if (in_array($NS, $own_ns)) {
951
+         return true;
952
+     }
953
+     return $NS;
954
+ }
955
+ 
956
+ function remove_from_dns($dom)
957
+ {
958
+     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
959
+     $current = null;
960
+     foreach ($domains as $d) {
961
+         if ($d->id == $dom && $d->dns == 1) {
962
+             $current = $d;
963
+             break;
964
+         }
965
+     }
966
+     if (! $current) {
967
+         system_failure("Domain nicht gefunden!");
968
+     }
969
+     db_query("UPDATE kundendaten.domains SET dns=0 WHERE id=?", array($current->id));
970
+ }
971
+ 
972
+ function add_to_dns($dom)
973
+ {
974
+     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
975
+     $current = null;
976
+     foreach ($domains as $d) {
977
+         if ($d->id == $dom && $d->dns == 0) {
978
+             $current = $d;
979
+             break;
980
+         }
981
+     }
982
+     if (! $current) {
983
+         system_failure("Domain nicht gefunden!");
984
+     }
985
+     db_query("UPDATE kundendaten.domains SET dns=1, autodns=1 WHERE id=?", array($current->id));
986
+ }
987
+ 
988
+
989
+      ----------- end diff -----------
990
+
991
+   7) modules/invoice/include/invoice.php
992
+      ---------- begin diff ----------
993
+--- Original
994
++++ New
995
+@@ @@
996
+     db_query(
997
+-      "INSERT INTO kundendaten.sepamandat (mandatsreferenz, glaeubiger_id, kunde, erteilt, medium, gueltig_ab, kontoinhaber, adresse, iban, bic, bankname) VALUES (:referenz, :glaeubiger_id, :cid, :today, 'online', :gueltig_ab, :name, :adresse, :iban, :bic, :bankname)",
998
+-          array(":referenz" => $referenz, ":glaeubiger_id" => $glaeubiger_id, ":cid" => $cid,
999
++        "INSERT INTO kundendaten.sepamandat (mandatsreferenz, glaeubiger_id, kunde, erteilt, medium, gueltig_ab, kontoinhaber, adresse, iban, bic, bankname) VALUES (:referenz, :glaeubiger_id, :cid, :today, 'online', :gueltig_ab, :name, :adresse, :iban, :bic, :bankname)",
1000
++        array(":referenz" => $referenz, ":glaeubiger_id" => $glaeubiger_id, ":cid" => $cid,
1001
+                 ":today" => $today, ":gueltig_ab" => $gueltig_ab, ":name" => $name, ":adresse" => $adresse,
1002
+                 ":iban" => $iban, ":bic" => $bic, ":bankname" => $bankname)
1003
+   );
1004
+ }
1005
+ 
1006
+ 
1007
+ 
1008
+ function get_bank_info($iban)
1009
+ {
1010
+     if (strlen($iban) != 22 || substr($iban, 0, 2) != 'DE') {
1011
+         // Geht nur bei deutschen IBANs
1012
+         echo 'Fehler!';
1013
+         echo '$iban = '.$iban;
1014
+         echo 'strlen($iban): '.strlen($iban);
1015
+         echo 'substr($iban, 0, 2): '.substr($iban, 0, 2);
1016
+         return null;
1017
+     }
1018
+     $blz = substr($iban, 4, 8);
1019
+     // FIXME: Liste der BLZs muss vorhanden sein!
1020
+     $bankinfofile = dirname(__FILE__).'/bankinfo.txt';
1021
+     $f = file($bankinfofile);
1022
+     $match = '';
1023
+     foreach ($f as $line) {
1024
+         if (substr($line, 0, 9) == $blz.'1') {
1025
+             $match = $line;
1026
+             break;
1027
+         }
1028
+     }
1029
+     $bank = array();
1030
+     $bank['name'] = iconv('latin1', 'utf8', chop(substr($match, 9, 58)));
1031
+     $bank['bic'] = chop(substr($match, 139, 11));
1032
+     return $bank;
1033
+ }
1034
+ 
1035
+ 
1036
+ function find_iban($blz, $kto)
1037
+ {
1038
+     $iban = sprintf('DE00%08s%010s', $blz, $kto);
1039
+     $iban = iban_set_checksum($iban);
1040
+     return $iban;
1041
+ }
1042
+ 
1043
+ 
1044
+ function get_customerquota()
1045
+ {
1046
+     $cid = (int) $_SESSION['customerinfo']['customerno'];
1047
+     $result = db_query("SELECT quota FROM system.customerquota WHERE cid=:cid", array(":cid" => $cid));
1048
+     $data = $result->fetch();
1049
+     return $data["quota"];
1050
+ }
1051
+ 
1052
+ function save_more_storage($items, $storage)
1053
+ {
1054
+     $cid = (int) $_SESSION['customerinfo']['customerno'];
1055
+ 
1056
+     $queries = array();
1057
+ 
1058
+     if ($storage < 1024 || $storage > 10240) {
1059
+         input_error('Speicherplatz nicht im erwarteten Bereich');
1060
+     }
1061
+     $oldcustomerquota = get_customerquota();
1062
+     if ($oldcustomerquota > 102400) {
1063
+         # Über 100 GB soll die Automatik nichts machen
1064
+         system_failure("Ihr Speicherplatz kann über diese Funktion nicht weiter erhöht werden. Bitte wenden Sie sich an die Administratoren.");
1065
+     }
1066
+     $result = db_query("SELECT quota FROM system.customerquota WHERE cid=:cid AND lastchange > CURDATE()", array(":cid" => $cid));
1067
+     if ($result->rowcount() > 0) {
1068
+         system_failure("Ihr Speicherplatz wurde heute bereits verändert. Sie können dies nur einmal am Tag machen.");
1069
+     }
1070
+ 
1071
+     $queries[] = array("UPDATE system.customerquota SET quota=quota+:storage WHERE cid=:cid", array(":storage" => $storage, ":cid" => $cid));
1072
+ 
1073
+     foreach ($items as $data) {
1074
+         if ($data['anzahl'] == 0) {
1075
+             continue;
1076
+         }
1077
+         $data['kunde'] = $cid;
1078
+         $data['notizen'] = 'Bestellt via Webinterface';
1079
+         if (!isset($data['anzahl']) ||
1080
+         !isset($data['beschreibung']) ||
1081
+         !isset($data['datum']) ||
1082
+         !array_key_exists('kuendigungsdatum', $data) ||
1083
+         !isset($data['betrag']) ||
1084
+         !isset($data['monate'])) {
1085
+             DEBUG($data);
1086
+             input_error("Ungültige Daten");
1087
+             return;
1088
+         }
1089
+ 
1090
+         $param = array();
1091
+         foreach ($data as $k => $v) {
1092
+             $param[':'.$k] = $v;
1093
+         }
1094
+ 
1095
+         $queries[] = array("INSERT INTO kundendaten.leistungen (kunde,periodisch,beschreibung,datum,kuendigungsdatum,betrag,brutto,monate,anzahl,notizen) VALUES ".
1096
+                        "(:kunde,1,:beschreibung,:datum,:kuendigungsdatum,:betrag,:brutto,:monate,:anzahl,:notizen)", $param);
1097
+     }
1098
+ 
1099
+     if (count($queries) < 2) {
1100
+         system_failure("irgendwas stimmt jetzt nicht");
1101
+     }
1102
+ 
1103
+     foreach ($queries as $q) {
1104
+         db_query($q[0], $q[1]);
1105
+     }
1106
+     $allstorage = $oldcustomerquota+$storage;
1107
+     $emailaddr = $_SESSION['customerinfo']['email'];
1108
+     $message = "Hallo,\n\nsoeben wurde im Webinterface von ".config('company_name')." eine Bestellung über zusätzlichen Speicherplatz ausgeführt.\nSollten Sie diese Bestellung nicht getätigt haben, antworten Sie bitte auf diese E-Mail um unseren Support zu erreichen.\n\nBei dieser Bestellung wurden {$storage} MB zusätzlicher Speicherplatz bestellt. Ihnen stehen ab sofort insgesamt {$allstorage} MB zur Verfügung.\n\nIhre Kundennummer: {$_SESSION['customerinfo']['customerno']} ({$_SESSION['customerinfo']['name']})\n";
1109
+     mail($emailaddr, 'Auftragsbestätigung: Mehr Speicherplatz bei schokokeks.org', $message, "X-schokokeks-org-message: notify\nFrom: ".config('company_name').' <'.config('adminmail').">\nBcc: ".config('adminmail')."\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n");
1110
+ }
1111
+ 
1112
+
1113
+      ----------- end diff -----------
1114
+
1115
+   8) themes/default/page.tpl.php
1116
+      ---------- begin diff ----------
1117
+--- Original
1118
++++ New
1119
+@@ @@
1120
+ 
1121
+-<?php 
1122
++<?php
1123
+@@ @@
1124
+ 
1125
+-<?php 
1126
++<?php
1127
+ if ($headline) {
1128
+     echo "<h3 class=\"headline\">$headline</h3>";
1129
+ }
1130
+ ?>
1131
+ 
1132
+ <?php echo $content; ?>
1133
+ 
1134
+ <?php if ($footnotes) {
1135
+     echo '<div class="footnotes">';
1136
+     foreach ($footnotes as $num => $explaination) {
1137
+         echo '<p>'.str_repeat('*', $num+1).': '.$explaination.'</p>';
1138
+     }
1139
+     echo '</div>';
1140
+ } ?>
1141
+ </div>
1142
+ <div class="foot">
1143
+ <p>Sollten Sie auf dieser Administrations-Oberfläche ein Problem entdecken oder Hilfe benötigen, schreiben Sie bitte eine einfache eMail an <a href="mailto:root@schokokeks.org">root@schokokeks.org</a>. Unser <a href="https://schokokeks.org/kontakt">Impressum</a> finden Sie auf der <a href="https://schokokeks.org/">öffentlichen Seite</a>. Lizenzinformationen zu diesem Webinterface und verwendeten Rechten finden Sie <a href="<?php echo $BASE_PATH; ?>go/about/about">indem Sie hier klicken</a>.</p>
1144
+ 
1145
+ </div>
1146
+ 
1147
+ 
1148
+ </body>
1149
+ </html>
1150
+ 
1151
+
1152
+      ----------- end diff -----------
1153
+
1154
+   9) themes/default/page-webmailtotp-login.tpl.php
1155
+      ---------- begin diff ----------
1156
+--- Original
1157
++++ New
1158
+@@ @@
1159
+ 
1160
+-<?php 
1161
++<?php
1162
+ if ($title) {
1163
+     echo "<title>$title - Administration</title>";
1164
+ } else {
1165
+     echo "<title>Administration</title>";
1166
+ }
1167
+ ?>
1168
+ <link rel="stylesheet" href="<?php echo $THEME_PATH; ?>style.css" type="text/css" media="screen" title="Normal" />
1169
+ <link rel="shortcut icon" href="<?php echo $THEME_PATH; ?>favicon.ico" type="image/x-icon" />
1170
+ <?php echo $html_header; ?>
1171
+ </head>
1172
+ 
1173
+ <body onload="javascript:document.getElementById('code').focus();">
1174
+ <div><a href="#content" style="display: none;">Zum Inhalt</a></div>
1175
+ 
1176
+ <div class="menu">
1177
+ <a href="<?php echo $BASE_PATH; ?>"><img src="<?php echo $THEME_PATH; ?>images/schokokeks.png" width="190" height="141" alt="schokokeks.org Hosting" /></a>
1178
+ 
1179
+ <?php echo $menu; ?>
1180
+ 
1181
+ <?php echo $userinfo; ?>
1182
+ 
1183
+ </div>
1184
+ 
1185
+ <div class="content">
1186
+ <a id="content" style="display: none"> </a>
1187
+ 
1188
+ <?php
1189
+ if ($messages) {
1190
+     echo $messages;
1191
+ }
1192
+ ?>
1193
+ 
1194
+ <h3 class="headline">Sicherheits-Code</h3>
1195
+ <p>Ihr Zugang ist mit Zwei-Faktor-Anmeldung geschützt. Sie müssen daher jetzt noch den aktuellsten Code Ihres TOTP-Geräts eingeben.</p>
1196
+ <form action="" method="post">
1197
+ <p><label for="code" class="login_label">Google-Authenticator-Code:</label> <input type="text" id="code" name="webinterface_totpcode" size="20" /></p>
1198
+ <p><span class="login_label">&#160;</span> <input type="submit" value="Prüfen" /></p>
1199
+ </form>
1200
+ 
1201
+ </div>
1202
+ 
1203
+ <div class="foot">
1204
+ <p>Sollten Sie auf dieser Administrations-Oberfläche ein Problem entdecken oder Hilfe benötigen, schreiben Sie bitte eine einfache eMail an <a href="mailto:root@schokokeks.org">root@schokokeks.org</a>. Unser <a href="https://schokokeks.org/kontakt">Impressum</a> finden Sie auf der <a href="https://schokokeks.org/">öffentlichen Seite</a>. Lizenzinformationen zu diesem Webinterface und verwendeten Rechten finden Sie <a href="../../images/about.php">indem Sie hier klicken</a>.</p>
1205
+ 
1206
+ </div>
1207
+ 
1208
+ 
1209
+ </body>
1210
+ </html>
1211
+ 
1212
+
1213
+      ----------- end diff -----------
1214
+
1215
+  10) themes/default/page-login.tpl.php
1216
+      ---------- begin diff ----------
1217
+--- Original
1218
++++ New
1219
+@@ @@
1220
+ 
1221
+-<?php 
1222
++<?php
1223
+ if ($title) {
1224
+     echo "<title>$title - Administration</title>";
1225
+ } else {
1226
+     echo "<title>Administration</title>";
1227
+ }
1228
+ ?>
1229
+ <link rel="stylesheet" href="<?php echo $THEME_PATH; ?>style.css" type="text/css" media="screen" title="Normal" />
1230
+ <link rel="shortcut icon" href="<?php echo $THEME_PATH; ?>favicon.ico" type="image/x-icon" />
1231
+ <?php echo $html_header; ?>
1232
+ <script type="text/javascript" src="<?php echo $THEME_PATH; ?>script.js"></script>
1233
+ </head>
1234
+ 
1235
+ <body onload="javascript:document.getElementById('username').focus();">
1236
+ <div><a href="#content" style="display: none;">Zum Inhalt</a></div>
1237
+ 
1238
+ <a href="javascript:void(0);" class="menuicon" id="showmenu" onclick="showMenu()"><img src="<?php echo $THEME_PATH; ?>images/bars.svg"><span id="showmenutext">Menü</span></a>
1239
+ <a href="<?php echo $BASE_PATH; ?>" class="logo"><img src="<?php echo $THEME_PATH; ?>images/schokokeks.png" width="190" height="141" alt="schokokeks.org Hosting" /></a>
1240
+ <div class="sidebar" id="sidebar">
1241
+ 
1242
+ <div class="menu">
1243
+ <?php echo $menu; ?>
1244
+ </div>
1245
+ <div class="userinfo">
1246
+ <?php echo $userinfo; ?>
1247
+ </div>
1248
+ </div>
1249
+ 
1250
+ <div class="content">
1251
+ <a id="content" style="display: none"> </a>
1252
+ 
1253
+ <?php
1254
+ if ($messages) {
1255
+     echo $messages;
1256
+ }
1257
+ ?>
1258
+ 
1259
+ <h3 class="headline">schokokeks.org Hosting Webinterface</h3>
1260
+ <p>Auf dieser Seite können Sie diverse Einstellungen Ihres Accounts auf schokokeks.org Hosting festlegen. Sofern Sie noch kein Kunde von schokokeks.org Hosting sind, können Sie diese Seite nicht benutzen. Besuchen Sie in diesem Fall bitte unsere <a href="https://schokokeks.org">öffentliche Seite</a>.</p>
1261
+ <form action="" method="post">
1262
+ <p class="login_field"><label for="username" class="login_label">Benutzername oder E-Mail-Adresse:</label> <input type="text" id="username" name="webinterface_username" size="30" /></p>
1263
+ <p class="login_field"><label for="password" class="login_label">Passwort:</label> <input type="password" id="password" name="webinterface_password" size="30" /></p>
1264
+ <p><span class="login_label">&#160;</span> <input type="submit" value="Anmelden" /></p>
1265
+ </form>
1266
+ <p>Sie können sich hier mit Ihrem System-Benutzernamen, Ihrer E-Mail-Adresse oder Ihrer Kundennummer (jeweils mit zugehörigem Passwort) anmelden. Je nach gewählten Daten erhalten Sie unterschiedliche Zugriffsrechte.</p>
1267
+ <?php /* <p>Sollten Sie Ihr Benutzer-Passwort nicht mehr kennen, wenden Sie sich bitte an den Support. Passwörter für E-Mail-Konten kann der Eigentümer des Benutzeraccounts neu setzen.</p> */ ?>
1268
+ <p><a href="<?php echo $BASE_PATH; ?>go/index/lost_password">Sollten Sie Ihr Kunden-Passwort nicht mehr kennen, klicken Sie bitte hier.</a> Passwörter für E-Mail-Konten kann der Eigentümer des Benutzeraccounts neu setzen.</p>
1269
+ 
1270
+ <p><em><a href="../../certlogin/?destination=go/<?php echo $go; ?>"  >Mit einem Client-Zertifikat anmelden</a></em> (<a href="../../go/index/certinfo"  >Wie geht das?</a>)</p>
1271
+ 
1272
+ 
1273
+ <?php if ($footnotes) {
1274
+     echo '<div class="footnotes">';
1275
+     foreach ($footnotes as $num => $explaination) {
1276
+         echo '<p>'.str_repeat('*', $num+1).': '.$explaination.'</p>';
1277
+     }
1278
+     echo '</div>';
1279
+ } ?>
1280
+ </div>
1281
+ 
1282
+ <div class="foot">
1283
+ <p>Sollten Sie auf dieser Administrations-Oberfläche ein Problem entdecken oder Hilfe benötigen, schreiben Sie bitte eine einfache eMail an <a href="mailto:root@schokokeks.org">root@schokokeks.org</a>. Unser <a href="https://schokokeks.org/kontakt">Impressum</a> finden Sie auf der <a href="https://schokokeks.org/">öffentlichen Seite</a>. Lizenzinformationen zu diesem Webinterface und verwendeten Rechten finden Sie <a href="../../images/about.php">indem Sie hier klicken</a>.</p>
1284
+ 
1285
+ </div>
1286
+ 
1287
+ 
1288
+ </body>
1289
+ </html>
1290
+ 
1291
+
1292
+      ----------- end diff -----------
1293
+
1294
+
1295
+Checked all files in 0.260 seconds, 14.000 MB memory used
0 1296