d0416d23b70a701e7c12b884bd947d4c670cc50e
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 5 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');
19) require_role(array(ROLE_SYSTEMUSER));
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']);
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

28) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

29) title("MySQL-Datenbanken");
30) 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

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

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

Hanno authored 5 years ago

57)     output('
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

58)   <table>
59)   <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

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

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

Hanno authored 5 years ago

62)     foreach ($users as $user) {
63)         $username = $user["username"];
64)         //$username = str_replace('_', '_ ', $user['username']);
65)         $desc = '';
66)         if ($user['description']) {
67)             $desc = '<br /><span style="font-weight: normal; font-size: 80%; font-style: italic;">'.$user['description'].'</span>';
68)         }
69)         output("<th><span title=\"Erstellt: {$user['created']}\">{$username}</span>".$desc);
70)         output("<br />".internal_link('description', other_icon("comment.png", 'Beschreibung ändern'), "username={$username}")."&#160;");
71)         output(internal_link("save", icon_delete("Benutzer »{$user['username']}« löschen"), "action=delete_user&user={$user['username']}")."</th>");
72)     }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

73) 
74) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

75)     $formtoken = generate_form_token('mysql_permchange');
76) 
77)     foreach ($dbs as $db) {
78)         $phpmyadmin = "https://mysql-{$servers[$db['name']]}/";
79)         $desc = '';
80)         if ($db['description']) {
81)             $desc = '<br /><span style="font-weight: normal; font-size: 80%; font-style: italic;">'.$db['description'].'</span>';
82)         }
83)         output("<tr><td style=\"border: 0px; font-weight: bold; text-align: right;\"><span title=\"Erstellt: {$db['created']}\">{$db['name']}</span>".$desc."<br />");
84)         output(internal_link('description', other_icon("comment.png", 'Datenbank-Beschreibung ändern'), "db={$db['name']}")."&#160;");
85)         output(internal_link("save", icon_delete("Datenbank »{$db['name']}« löschen"), "action=delete_db&db={$db['name']}")."&#160;");
86)         output("<a href=\"".$phpmyadmin."\">".other_icon("database_go.png", "Datenbank-Verwaltung über phpMyAdmin")."</a>");
87)         output("</td>");
88)         foreach ($users as $user) {
89)             output('<td style="text-align: center;">');
90)             if (get_mysql_access($db['name'], $user['username'])) {
91)                 output(internal_link('save', icon_enabled('Zugriff erlaubt; Anklicken zum Ändern'), "action=permchange&user={$user['username']}&db={$db['name']}&access=0&formtoken={$formtoken}"));
92)             } else {
93)                 output(internal_link('save', icon_disabled('Zugriff verweigern; Anklicken zum Ändern'), "action=permchange&user={$user['username']}&db={$db['name']}&access=1&formtoken={$formtoken}"));
94)             }
95)         }
96)         output("</tr>\n");
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

102) }
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) addnew('newdb', 'Neue Datenbank');
105) addnew('newuser', 'Neuer DB-Benutzer');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

106) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

107) if (count($dbs) > 0) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

108)     $myservers = array();
109)     foreach ($servers as $s) {
110)         if (! in_array($s, $myservers)) {
111)             $myservers[] = $s;
112)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

113)     }
114) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

117)     if (count($myservers) == 1) {
118)         output("<p><strong><a href=\"https://mysql-{$myservers[0]}/\">phpMyAdmin aufrufen</a></strong></p>");
119)     } else {
120)         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>");
121)     }
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

125) 
126) 
127) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

128)     $my_users = array();
129)     foreach ($users as $u) {
130)         $my_users[$u['username']] = $u['username'];
131)     }
132)     $form = '<div>
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

133)   <p><label for="mysql_username">Benutzername:</label>&#160;'.html_select('mysql_username', $my_users).'</p>
134)   <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>
135) <p style="display: none;">Automatisch erzeugtes Passwort: <input id="newpass_display" type="text" readonly="readonly" /></p>
136)   <p><input type="submit" value="Setzen" /></p>
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

141)   <p>Hier können Sie das Passwort eines MySQL-Benutzeraccounts ändern bzw. neu setzen</p>
142) 
143)   '.html_form('mysql_databases', 'save', 'action=change_pw', $form).'<br />');