5effc2bd7685822df276c1372dab480cff321941
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 Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

5) Written 2008-2014 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) 
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 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) {
55) 
56)   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>');
57) 
58)   output('
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

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

62) 
63)   foreach ($users as $user)
64)   {
65)     $username = $user["username"];
66)     //$username = str_replace('_', '_ ', $user['username']);
67)     $desc = '';
68)     if ($user['description']) {
69)       $desc = '<br /><span style="font-weight: normal; font-size: 80%; font-style: italic;">'.$user['description'].'</span>';
70)     } 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

74)   }
75) 
76) 
77)   $formtoken = generate_form_token('mysql_permchange');
78) 
79)   foreach($dbs as $db)
80)   {
81)     $phpmyadmin = "https://mysql.{$servers[$db['name']]}/";
82)     $desc = '';
83)     if ($db['description']) {
84)       $desc = '<br /><span style="font-weight: normal; font-size: 80%; font-style: italic;">'.$db['description'].'</span>';
85)     } 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

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

Bernd Wurst authored 11 years ago

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

97)       }
98)       
99)     }
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

101)   }
102) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

104)   
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

105) } else {
106)   output('<p><em>Sie haben bisher keine Datenbanken erstellt.</em></p>');
107) }
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) addnew('newdb', 'Neue Datenbank');
110) addnew('newuser', 'Neuer DB-Benutzer');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

111) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

113) 
114)   $myservers = array();
115)   foreach ($servers as $s) {
116)     if (! in_array($s, $myservers)) {
117)       $myservers[] = $s;
118)     }
119)   }
120) 
121)   output("<h4>Verwaltung der Datenbanken (phpMyAdmin)</h4>
122)   <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>");
123)   if (count($myservers) == 1) {
124)     output("<p><strong><a href=\"https://mysql.{$myservers[0]}/\">phpMyAdmin aufrufen</a></strong></p>");
125)   }
126)   else {
127)     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>");
128)   }
129) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

132) 
133)   $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
134) 
135) 
136) 
137)   $my_users = array();
138)   foreach ($users as $u)
139)   {
140)     $my_users[$u['username']] = $u['username'];
141)   }
142)   $form = '<div>
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

147) </div>';
148) 
149) 
150)   output('<h4>Passwort ändern</h4>
151)   <p>Hier können Sie das Passwort eines MySQL-Benutzeraccounts ändern bzw. neu setzen</p>
152) 
153)   '.html_form('mysql_databases', 'save', 'action=change_pw', $form).'<br />');
154) 
155) 
Bernd Wurst Zeige reduzierte Seite wenn...

Bernd Wurst authored 11 years ago

156) }