96649f21ba18d07757afa9d98998f7a22c0d86a3
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) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) 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.
15) */
16) 
17) require_once('session/start.php');
18) require_once('inc/icons.php');
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 11 years ago

20) 
21) global $prefix;
22) 
23) require_once('mysql.php');
24) 
25) $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
26) $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
27) $username = $_SESSION['userinfo']['username'];
28) 
29) $section = 'mysql_overview';
30) title('Neuer MySQL-Benutzer');
31) 
32) 
33) html_header('
34) <script type="text/javascript">
35) 
36)   function makePasswd() {
37)     var passwd = \'\';
38)     var chars = \'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\';
39)     for (i=0; i<15; i++) {
40)       var c = Math.floor(Math.random()*chars.length + 1);
41)       passwd += chars.charAt(c)
42)     }
43)     return passwd;
44)   }
45) 
46)   function setRandomPassword() 
47)   {
48)     pass = makePasswd();
49)     document.getElementById(\'newpass\').value = pass;
50)     document.getElementById(\'newpass_display\').value = pass;
51)     document.getElementById(\'newpass_display\').parentNode.style.display = \'block\';
52)   }
53) </script>');
54) 
55) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 11 years ago

59) }
60) 
61) $suggestion = $username;
62) $count = 1;
63) while (in_array($suggestion, $usernames)) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

64)     $suggestion = $username.'_'.$count;
65)     $count++;
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

66) }
67) 
Bernd Wurst Zeige deutlich an, welche M...

Bernd Wurst authored 10 years ago

68) $hint = 'Der MySQL-Benutzername muss entweder <strong>'.$username.'</strong> lauten oder mit <strong>'.$username.'_</strong> beginnen.';
69) if (in_array($username, $usernames)) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

71) }
72) 
73) 
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

74) $form = '<h4>Benutzername</h4>
75) <input type="text" name="newuser" value="'.$suggestion.'" maxlength="16" />
Bernd Wurst Zeige deutlich an, welche M...

Bernd Wurst authored 10 years ago

76) <p>Bitte nur Kleinbuchstaben, Zahlen und Unterstrich verwenden. '.$hint.'</p>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

77) <p>Aufgrund einer Einschränkung des MySQL-Servers dürfen Benutzernamen nur maximal 16 Zeichen lang sein.</p>
78) <p><label for="description">Optionale Beschreibung dieses Benutzers:</label> <input type="text" name="description" id="description" /></p>
79) <h4>Passwort</h4>
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 6 years ago

84)     $form .= '<p>Auf welche der bisher vorhandenen Datenbanken darf dieser Benutzer zugreifen?</p>';
85)     foreach ($dbs as $db) {
86)         $desc = '';
87)         if ($db['description']) {
88)             $desc = ' - <em>'.$db['description'].'</em>';
89)         }
90)         $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

91)     }
92) } else {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Bernd Wurst authored 11 years ago

94) }
Hanno remove whitespace in empty...

Hanno authored 6 years ago

95)