dcc202fb249a446ac15c7cf413b9f1b4a3f31b58
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('
31) <script type="text/javascript">
32) 
33)   function makePasswd() {
34)     var passwd = \'\';
35)     var chars = \'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\';
36)     for (i=0; i<15; i++) {
37)       var c = Math.floor(Math.random()*chars.length + 1);
38)       passwd += chars.charAt(c)
39)     }
40)     return passwd;
41)   }
42) 
43)   function setRandomPassword() 
44)   {
45)     pass = makePasswd();
46)     document.getElementById(\'newpass\').value = pass;
47)     document.getElementById(\'newpass_display\').value = pass;
48)     document.getElementById(\'newpass_display\').parentNode.style.display = \'block\';
49)   }
50) </script>');
51) 
52) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

63) }
64) 
Bernd Wurst Zeige deutlich an, welche M...

Bernd Wurst authored 10 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 10 years ago

68) }
69) 
70) 
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

77) <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

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

Hanno authored 5 years ago

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

88)     }
89) } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

91) }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

92)