1e60d7d8e9bc75b836735d43c47ef1680f2017f8
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) 
5) Written 2008-2013 by schokokeks.org Hosting, namely
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) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
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 Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

32) 
33) if (count($dbs) > 0 || count($users) > 0) {
34) 
35)   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>');
36) 
37)   output('
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

38)   <table>
39)   <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

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

41) 
42)   foreach ($users as $user)
43)   {
44)     $username = $user["username"];
45)     //$username = str_replace('_', '_ ', $user['username']);
46)     $desc = '';
47)     if ($user['description']) {
48)       $desc = '<br /><span style="font-weight: normal; font-size: 80%; font-style: italic;">'.$user['description'].'</span>';
49)     } 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

50)     output("<th><span title=\"Erstellt: {$user['created']}\">{$username}</span>".$desc);
51)     output("<br />".internal_link('description', other_icon("comment.png", 'Beschreibung ändern'), "username={$username}")."&#160;");
52)     output(internal_link("save", icon_delete("Benutzer »{$user['username']}« löschen"), "action=delete_user&user={$user['username']}")."</th>");
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

53)   }
54) 
55) 
56)   $formtoken = generate_form_token('mysql_permchange');
57) 
58)   foreach($dbs as $db)
59)   {
60)     $phpmyadmin = "https://mysql.{$servers[$db['name']]}/";
61)     $desc = '';
62)     if ($db['description']) {
63)       $desc = '<br /><span style="font-weight: normal; font-size: 80%; font-style: italic;">'.$db['description'].'</span>';
64)     } 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

65)     output("<tr><td style=\"border: 0px; font-weight: bold; text-align: right;\"><span title=\"Erstellt: {$db['created']}\">{$db['name']}</span>".$desc."<br />");
66)     output(internal_link('description', other_icon("comment.png", 'Datenbank-Beschreibung ändern'), "db={$db['name']}")."&#160;");
67)     output(internal_link("save", icon_delete("Datenbank »{$db['name']}« löschen"), "action=delete_db&db={$db['name']}")."&#160;");
68)     output("<a href=\"".$phpmyadmin."\">".other_icon("database_go.png", "Datenbank-Verwaltung über phpMyAdmin")."</a>");
69)     output("</td>");
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

70)     foreach ($users as $user) {
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

71)       output('<td style="text-align: center;">');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

72)       if (get_mysql_access($db['name'], $user['username'])) {
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

73)         output(internal_link('save', icon_enabled('Zugriff erlaubt; Anklicken zum Ändern'), "action=permchange&user={$user['username']}&db={$db['name']}&access=0&formtoken={$formtoken}"));
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

74)       } else {
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

75)         output(internal_link('save', icon_disabled('Zugriff verweigern; Anklicken zum Ändern'), "action=permchange&user={$user['username']}&db={$db['name']}&access=1&formtoken={$formtoken}"));
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

76)       }
77)       
78)     }
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

79)     output("</tr>\n");
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

80)   }
81) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

82)   output('</table>');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

83)   
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

84) } else {
85)   output('<p><em>Sie haben bisher keine Datenbanken erstellt.</em></p>');
86) }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

87) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

90) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

91) if (count($dbs) > 0) {
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

92) 
93)   $myservers = array();
94)   foreach ($servers as $s) {
95)     if (! in_array($s, $myservers)) {
96)       $myservers[] = $s;
97)     }
98)   }
99) 
100)   output("<h4>Verwaltung der Datenbanken (phpMyAdmin)</h4>
101)   <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>");
102)   if (count($myservers) == 1) {
103)     output("<p><strong><a href=\"https://mysql.{$myservers[0]}/\">phpMyAdmin aufrufen</a></strong></p>");
104)   }
105)   else {
106)     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>");
107)   }
108) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

109) }
110) if (count($users) > 0) {
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

111) 
112)   $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
113) 
114) 
115) 
116)   $my_users = array();
117)   foreach ($users as $u)
118)   {
119)     $my_users[$u['username']] = $u['username'];
120)   }
121)   $form = '<div>
122)   <label for="mysql_username">Benutzername:</label>&#160;'.html_select('mysql_username', $my_users).'
123)   &#160;&#160;&#160;
124)   <label for="password">Passwort:</label>&#160;<input type="password" name="mysql_password" id="password" />
125)   &#160;&#160;<input type="submit" value="Setzen" />
126) </div>';
127) 
128) 
129)   output('<h4>Passwort ändern</h4>
130)   <p>Hier können Sie das Passwort eines MySQL-Benutzeraccounts ändern bzw. neu setzen</p>
131) 
132)   '.html_form('mysql_databases', 'save', 'action=change_pw', $form).'<br />');
133) 
134) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

135) }