354c05a4ddd678c49bcbba458bffa7d13482139a
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

1) <?php
2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

5) Written by schokokeks.org Hosting, namely
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

9) This code is published under a 0BSD license.
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

10) 
11) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
12) */
13) 
14) require_once('session/start.php');
15) require_once('inc/icons.php');
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

16) require_role([ROLE_SYSTEMUSER]);
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

17) 
18) global $prefix;
19) 
20) require_once('mysql.php');
21) 
22) $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
23) $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
24) $username = $_SESSION['userinfo']['username'];
25) 
26) $section = 'mysql_overview';
27) title('Neue MySQL-Datenbank');
28) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

29) $dbnames = [];
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

30) foreach ($dbs as $db) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

31)     $dbnames[] = $db['name'];
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

32) }
33) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

34) $suggestion = $username . '_1';
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

35) $count = 2;
36) while (in_array($suggestion, $dbnames)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

37)     $suggestion = $username . '_' . $count;
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

38)     $count++;
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

39) }
40) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

41) $hint = 'Der Datenbankname muss mit <strong>' . $username . '_</strong> beginnen.';
Bernd Wurst Zeige deutlich an, welche M...

Bernd Wurst authored 10 years ago

42) 
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

43) $form = '<h4>Name der neuen Datenbank</h4>
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

44) <input type="text" name="newdb" value="' . $suggestion . '" />
45) <p>Bitte nur Kleinbuchstaben, Zahlen und Unterstrich verwenden. ' . $hint . '</p>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

46) <p><label for="description">Optionale Beschreibung dieser Datenbank:</label> <input type="text" name="description" id="description" /></p>
47) ';
48) if (count(additional_servers()) > 0) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

49)     $form .= '<h4>Server</h4>';
50)     $form .= '<p>Auf welchem Server soll diese Datenbank eingerichtet werden?</p>';
51)     $available_servers = additional_servers();
52)     $available_servers[] = my_server_id();
53)     $available_servers = array_unique($available_servers);
Hanno remove whitespace in empty...

Hanno authored 5 years ago

54) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

55)     $selectable_servers = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

56)     $all_servers = server_names();
57)     foreach ($all_servers as $id => $fqdn) {
58)         if (in_array($id, $available_servers)) {
59)             $selectable_servers[$id] = $fqdn;
60)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

61)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

62)     $form .= html_select('server', $selectable_servers, my_server_id());
63)     $form .= '<p>Alle Benutzer die auf diese Datenbank zugreifen dürfen, werden automatisch auf dem passenden Server eingerichtet</p>';
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

64) }
65) if (count($users) > 0) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

66)     $form .= '<h4>Berechtigungen</h4>';
67)     $form .= '<p>Welche der bisher vorhandenen Datenbank-Benutzer dürfen auf diese Datenbank zugreifen?</p>';
68)     foreach ($users as $user) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

69)         $form .= '<p><input type="checkbox" id="access_' . $user['username'] . '" name="access[]" value="' . $user['username'] . '" /> <label for="access_' . $user['username'] . '">' . $user['username'] . '</label></p>';
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

70)     }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

71) }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

72)