b7ca59f52afc76387cb454dbc9110c8bb66ef350
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('Neuer MySQL-Benutzer');
28) 
29) 
30) html_header('
Hanno Böck W3C validator warnt bei typ...

Hanno Böck authored 4 months ago

31) <script>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

32) 
33)   function makePasswd() {
Hanno Böck Random-Passwort in Javascri...

Hanno Böck authored 4 months ago

34)     const pwchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
35)     const limit = 256 - (256 % pwchars.length);
36) 
37)     let passwd = "";
38)     let randval;
39)     for (let i = 0; i < 15; i++) {
40)       do {
41)         randval = window.crypto.getRandomValues(new Uint8Array(1))[0];
42)       } while (randval >= limit);
43)       passwd += pwchars[randval % pwchars.length];
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

44)     }
45)     return passwd;
46)   }
47) 
Hanno Böck Random-Passwort in Javascri...

Hanno Böck authored 4 months ago

48)   function setRandomPassword()
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

49)   {
50)     pass = makePasswd();
51)     document.getElementById(\'newpass\').value = pass;
52)     document.getElementById(\'newpass_display\').value = pass;
53)     document.getElementById(\'newpass_display\').parentNode.style.display = \'block\';
54)   }
55) </script>');
56) 
57) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

58) $usernames = [];
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

59) foreach ($users as $user) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

60)     $usernames[] = $user['username'];
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

61) }
62) 
63) $suggestion = $username;
64) $count = 1;
65) while (in_array($suggestion, $usernames)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

68) }
69) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

70) $hint = 'Der MySQL-Benutzername muss entweder <strong>' . $username . '</strong> lauten oder mit <strong>' . $username . '_</strong> beginnen.';
Bernd Wurst Zeige deutlich an, welche M...

Bernd Wurst authored 10 years ago

71) if (in_array($username, $usernames)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

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

Bernd Wurst authored 10 years ago

73) }
74) 
75) 
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

76) $form = '<h4>Benutzername</h4>
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

77) <input type="text" name="newuser" value="' . $suggestion . '" maxlength="16" />
78) <p>Bitte nur Kleinbuchstaben, Zahlen und Unterstrich verwenden. ' . $hint . '</p>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

79) <p>Aufgrund einer Einschränkung des MySQL-Servers dürfen Benutzernamen nur maximal 16 Zeichen lang sein.</p>
80) <p><label for="description">Optionale Beschreibung dieses Benutzers:</label> <input type="text" name="description" id="description" /></p>
81) <h4>Passwort</h4>
Hanno Böck Add autocomplete to mysql p...

Hanno Böck authored 3 months ago

82) <p><input onchange="document.getElementById(\'newpass_display\').parentNode.style.display=\'none\'" type="password" name="newpass" id="newpass" value="" autocomplete="new-password"> <button type="button" onclick="setRandomPassword()">Passwort erzeugen</button></p>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

83) <p style="display: none;">Automatisch erzeugtes Passwort: <input id="newpass_display" type="text" readonly="readonly" /></p>
84) <h4>Berechtigungen</h4>';
85) if (count($dbs) > 0) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

86)     $form .= '<p>Auf welche der bisher vorhandenen Datenbanken darf dieser Benutzer zugreifen?</p>';
87)     foreach ($dbs as $db) {
88)         $desc = '';
89)         if ($db['description']) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

90)             $desc = ' - <em>' . $db['description'] . '</em>';
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

91)         }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

92)         $form .= '<p><input type="checkbox" id="access_' . $db['name'] . '" name="access[]" value="' . $db['name'] . '" /> <label for="access_' . $db['name'] . '">' . $db['name'] . $desc . '</label></p>';
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

93)     }
94) } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

95)     $form .= '<p><em>Bisher gibt es noch keine Datenbanken.</em></p>';
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

96) }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

97)