9e72630c219258ccea648f94c5f5a4bd028db9c4
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']);
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

24) $servers = servers_for_databases();
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

25) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

26) title("MySQL-Datenbanken");
27) output('<p>Hier können Sie den Zugriff auf Ihre MySQL-Datenbanken verwalten. Die Einstellungen werden mit einer leichten Verzögerung (maximal 5 Minuten) in das System übertragen. Bitte beachten Sie, dass neue Zugänge also nicht umgehend funktionieren.</p>');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

28) 
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

29) html_header('
Hanno Böck W3C validator warnt bei typ...

Hanno Böck authored 4 months ago

30) <script>
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

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

Hanno Böck authored 4 months ago

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

Bernd Wurst authored 11 years ago

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

Hanno Böck authored 4 months ago

47)   function setRandomPassword()
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

48)   {
49)     pass = makePasswd();
50)     document.getElementById(\'newpass\').value = pass;
51)     document.getElementById(\'newpass_display\').value = pass;
52)     document.getElementById(\'newpass_display\').parentNode.style.display = \'block\';
53)   }
54) </script>');
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

55) 
56) if (count($dbs) > 0 || count($users) > 0) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

57)     output('<p><strong>Hinweis:</strong> In dieser Matrix sehen Sie links die Datenbanken und oben die Benutzer, die Sie eingerichtet haben. In der Übersicht ist dargestellt, welcher Benutzer auf welche Datenbank Zugriff erhält. Klicken Sie auf die Symbole um die Zugriffsrechte zu ändern.</p>');
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

58) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

59)     output('
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

60)   <table>
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 3 months ago

61)   <tr><th>&#160;</th><th style="background-color: #729bb3; color: #fff;padding: 0.2em;" colspan="' . count($users) . '">Benutzerkonten</th></tr>
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

62)   <tr><th style="background-color: #729bb3; color: #fff;padding: 0.2em; text-align: left;">Datenbanken</th>');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

63) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

64)     foreach ($users as $user) {
65)         $username = $user["username"];
66)         //$username = str_replace('_', '_ ', $user['username']);
67)         $desc = '';
68)         if ($user['description']) {
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 3 months ago

69)             $desc = '<br><span style="font-weight: normal; font-size: 80%; font-style: italic;">' . filter_output_html($user['description']) . '</span>';
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

71)         output("<th><span title=\"Erstellt: {$user['created']}\">{$username}</span>" . $desc);
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 3 months ago

72)         output("<br>" . internal_link('description', other_icon("comment.png", 'Beschreibung ändern'), "username={$username}") . "&#160;");
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

73)         output(internal_link("save", icon_delete("Benutzer »{$user['username']}« löschen"), "action=delete_user&user={$user['username']}") . "</th>");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

74)     }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

75) 
76) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

77)     $formtoken = generate_form_token('mysql_permchange');
78) 
79)     foreach ($dbs as $db) {
80)         $phpmyadmin = "https://mysql-{$servers[$db['name']]}/";
81)         $desc = '';
82)         if ($db['description']) {
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 3 months ago

83)             $desc = '<br><span style="font-weight: normal; font-size: 80%; font-style: italic;">' . filter_output_html($db['description']) . '</span>';
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

84)         }
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 3 months ago

85)         output("<tr><td style=\"border: 0px; font-weight: bold; text-align: right;\"><span title=\"Erstellt: {$db['created']}\">{$db['name']}</span>" . $desc . "<br>");
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

86)         output(internal_link('description', other_icon("comment.png", 'Datenbank-Beschreibung ändern'), "db={$db['name']}") . "&#160;");
87)         output(internal_link("save", icon_delete("Datenbank »{$db['name']}« löschen"), "action=delete_db&db={$db['name']}") . "&#160;");
88)         output("<a href=\"" . $phpmyadmin . "\">" . other_icon("database_go.png", "Datenbank-Verwaltung über phpMyAdmin") . "</a>");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

89)         output("</td>");
90)         foreach ($users as $user) {
91)             output('<td style="text-align: center;">');
92)             if (get_mysql_access($db['name'], $user['username'])) {
93)                 output(internal_link('save', icon_enabled('Zugriff erlaubt; Anklicken zum Ändern'), "action=permchange&user={$user['username']}&db={$db['name']}&access=0&formtoken={$formtoken}"));
94)             } else {
95)                 output(internal_link('save', icon_disabled('Zugriff verweigern; Anklicken zum Ändern'), "action=permchange&user={$user['username']}&db={$db['name']}&access=1&formtoken={$formtoken}"));
96)             }
97)         }
98)         output("</tr>\n");
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

99)     }
100) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

101)     output('</table>');
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

103)     output('<p><em>Sie haben bisher keine Datenbanken erstellt.</em></p>');
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

104) }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

105) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

106) addnew('newdb', 'Neue Datenbank');
107) addnew('newuser', 'Neuer DB-Benutzer');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

108) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

109) if (count($dbs) > 0) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

110)     $myservers = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

111)     foreach ($servers as $s) {
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

112)         if (!in_array($s, $myservers)) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

113)             $myservers[] = $s;
114)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

115)     }
116) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

117)     output("<h4>Verwaltung der Datenbanken (phpMyAdmin)</h4>
Hanno Böck add alt tag to image

Hanno Böck authored 3 months ago

118)   <p><img src=\"{$prefix}images/phpmyadmin.png\" style=\"width: 120px; height: 70px; float: right;\" alt=\"phpMyAdmin Logo\">Zur Verwaltung der Datenbank-Inhalte stellen wir Ihnen eine stets aktualisierte Version von phpMyAdmin zur Verfügung.</p>");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

119)     if (count($myservers) == 1) {
120)         output("<p><strong><a href=\"https://mysql-{$myservers[0]}/\">phpMyAdmin aufrufen</a></strong></p>");
121)     } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

122)         output("<p><em>Ihre Datenbanken befinden sich auf unterschiedlichen Servern, daher müssen Sie die jeweils passende Adresse für phpMyAdmin benutzen. Klicken Sie auf das Symbol " . other_icon("database_go.png", "Datenbank-Verwaltung über phpMyAdmin") . " oben neben der jeweiligen Datenbank.</em></p>");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

123)     }
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

126)     $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

127) 
128) 
129) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

130)     $my_users = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

131)     foreach ($users as $u) {
132)         $my_users[$u['username']] = $u['username'];
133)     }
134)     $form = '<div>
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

135)   <p><label for="mysql_username">Benutzername:</label>&#160;' . html_select('mysql_username', $my_users) . '</p>
Hanno Böck Add autocomplete to mysql p...

Hanno Böck authored 3 months ago

136)   <p><label for="newpass">Passwort:</label>&#160;<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>
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 3 months ago

137) <p style="display: none;">Automatisch erzeugtes Passwort: <input id="newpass_display" type="text" readonly="readonly"></p>
Hanno Böck Add autocomplete to mysql p...

Hanno Böck authored 3 months ago

138)   <p><input type="submit" value="Setzen"></p>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

139) </div>';
140) 
141) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

142)     output('<h4>Passwort ändern</h4>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

143)   <p>Hier können Sie das Passwort eines MySQL-Benutzeraccounts ändern bzw. neu setzen</p>
144) 
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 3 months ago

145)   ' . html_form('mysql_databases', 'save', 'action=change_pw', $form) . '<br>');