6e6aadbd92620c9853a1aa2ecfbf7328f48a52b3
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 5 months ago

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

Bernd Wurst authored 11 years ago

31) 
32)   function makePasswd() {
33)     var passwd = \'\';
34)     var chars = \'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\';
35)     for (i=0; i<15; i++) {
36)       var c = Math.floor(Math.random()*chars.length + 1);
37)       passwd += chars.charAt(c)
38)     }
39)     return passwd;
40)   }
41) 
42)   function setRandomPassword() 
43)   {
44)     pass = makePasswd();
45)     document.getElementById(\'newpass\').value = pass;
46)     document.getElementById(\'newpass_display\').value = pass;
47)     document.getElementById(\'newpass_display\').parentNode.style.display = \'block\';
48)   }
49) </script>');
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

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

Hanno authored 5 years ago

54)     output('
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

55)   <table>
Hanno Böck Spaces between string conca...

Hanno Böck authored 7 months ago

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

Bernd Wurst authored 11 years ago

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

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

Hanno authored 5 years ago

59)     foreach ($users as $user) {
60)         $username = $user["username"];
61)         //$username = str_replace('_', '_ ', $user['username']);
62)         $desc = '';
63)         if ($user['description']) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 7 months ago

64)             $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

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

Hanno Böck authored 7 months ago

66)         output("<th><span title=\"Erstellt: {$user['created']}\">{$username}</span>" . $desc);
67)         output("<br />" . internal_link('description', other_icon("comment.png", 'Beschreibung ändern'), "username={$username}") . "&#160;");
68)         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

69)     }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

70) 
71) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

72)     $formtoken = generate_form_token('mysql_permchange');
73) 
74)     foreach ($dbs as $db) {
75)         $phpmyadmin = "https://mysql-{$servers[$db['name']]}/";
76)         $desc = '';
77)         if ($db['description']) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 7 months ago

78)             $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

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

Hanno Böck authored 7 months ago

80)         output("<tr><td style=\"border: 0px; font-weight: bold; text-align: right;\"><span title=\"Erstellt: {$db['created']}\">{$db['name']}</span>" . $desc . "<br />");
81)         output(internal_link('description', other_icon("comment.png", 'Datenbank-Beschreibung ändern'), "db={$db['name']}") . "&#160;");
82)         output(internal_link("save", icon_delete("Datenbank »{$db['name']}« löschen"), "action=delete_db&db={$db['name']}") . "&#160;");
83)         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

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

Bernd Wurst authored 11 years ago

94)     }
95) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

99) }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

100) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

103) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 7 months ago

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

Hanno authored 5 years ago

108)             $myservers[] = $s;
109)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

110)     }
111) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

112)     output("<h4>Verwaltung der Datenbanken (phpMyAdmin)</h4>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

113)   <p><img src=\"{$prefix}images/phpmyadmin.png\" style=\"width: 120px; height: 70px; float: right;\" />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

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

Hanno Böck authored 7 months ago

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

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

122) 
123) 
124) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

126)     foreach ($users as $u) {
127)         $my_users[$u['username']] = $u['username'];
128)     }
129)     $form = '<div>
Hanno Böck Spaces between string conca...

Hanno Böck authored 7 months ago

130)   <p><label for="mysql_username">Benutzername:</label>&#160;' . html_select('mysql_username', $my_users) . '</p>
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

131)   <p><label for="newpass">Passwort:</label>&#160;<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>
132) <p style="display: none;">Automatisch erzeugtes Passwort: <input id="newpass_display" type="text" readonly="readonly" /></p>
133)   <p><input type="submit" value="Setzen" /></p>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

134) </div>';
135) 
136) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

138)   <p>Hier können Sie das Passwort eines MySQL-Benutzeraccounts ändern bzw. neu setzen</p>
139) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 7 months ago

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