f12aba6daa6e2848a8ed60ea57b26874d6675f52
bernd webinterface => /webinterface

bernd authored 17 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 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) */
bernd webinterface => /webinterface

bernd authored 17 years ago

16) 
17) require_once('session/start.php');
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

18) require_once('inc/icons.php');
bernd webinterface => /webinterface

bernd authored 17 years ago

19) require_role(array(ROLE_SYSTEMUSER));
20) 
21) global $prefix;
22) 
23) require_once('mysql.php');
24) 
25) $output_something = true;
26) 
27) 
28) if (isset($_GET['action']))
29)   switch ($_GET['action'])
30)   {
31)     case 'delete_db':
bernd Fix of bugs #554 and #553

bernd authored 15 years ago

32)       if (! has_mysql_database($_GET['db']))
33)         system_failure('Ungültige Datenbank');
bernd webinterface => /webinterface

bernd authored 17 years ago

34)       $sure = user_is_sure();
35)       if ($sure === NULL)
36)       {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

37)         are_you_sure("action=delete_db&db={$_GET['db']}", "Möchten Sie die Datenbank »{$_GET['db']}« wirklich löschen?");
bernd webinterface => /webinterface

bernd authored 17 years ago

38)         $output_something = false;
39)       }
40)       elseif ($sure === true)
41)       {
42)         delete_mysql_database($_GET['db']);
43)         header("Location: ?");
44)         $output_something = false;
45)       }
46)       elseif ($sure === false)
47)       {
48)         header("Location: ?");
49)         $output_something = false;
50)       }
51)       break;
52)     case 'delete_user':
bernd use html_select, fix databa...

bernd authored 15 years ago

53)       if (! has_mysql_user($_GET['user']))
bernd Fix of bugs #554 and #553

bernd authored 15 years ago

54)         system_failure('Ungültiger Benutzer');
bernd webinterface => /webinterface

bernd authored 17 years ago

55)       $sure = user_is_sure();
56)       if ($sure === NULL)
57)       {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

58)         are_you_sure("action=delete_user&user={$_GET['user']}", "Möchten Sie den Benutzer »{$_GET['user']}« wirklich löschen?");
bernd webinterface => /webinterface

bernd authored 17 years ago

59)         $output_something = false;
60)       }
61)       elseif ($sure === true)
62)       {
63)         delete_mysql_account($_GET['user']);
64)         header("Location: ?");
65)         $output_something = false;
66)       }
67)       elseif ($sure === false)
68)       {
69)         header("Location: ?");
70)         $output_something = false;
71)       }
72)       break;
73)     case 'change_pw':
bernd Falscher CSRF-Schutz

bernd authored 16 years ago

74)       check_form_token('mysql_databases');
bernd webinterface => /webinterface

bernd authored 17 years ago

75)       set_mysql_password($_POST['mysql_username'], $_POST['mysql_password']);
76)       header("Location: ?");
77)       $output_something = false;
78)       break;
79)     default:
80)       system_failure("Diese Funktion scheint noch nicht eingebaut zu sein!");
81)   }
82) 
83) 
84) $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
85) $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
86) 
bernd auch ohne vergebene Rechte...

bernd authored 16 years ago

87) if (isset($_POST['accesseditor']))
bernd webinterface => /webinterface

bernd authored 17 years ago

88) {
bernd Falscher CSRF-Schutz

bernd authored 16 years ago

89)   check_form_token('mysql_databases');
bernd webinterface => /webinterface

bernd authored 17 years ago

90)   /* Eine neue Datenbank */
91)   if ($_POST['new_db'] != '')
92)   {
93)     create_mysql_database($_POST['new_db']);
94)     if (isset($_POST['access']['new']))
95)     {
96)       $_POST['access'][$_POST['new_db']] = array();
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

97)       foreach ($users as $user) {
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

98)         $user = $user['username'];
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

99)         if (in_array($user, $_POST['access']['new'])) {
bernd webinterface => /webinterface

bernd authored 17 years ago

100)           array_push($_POST['access'][$_POST['new_db']], $user);
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

101)         }
102)       }
bernd webinterface => /webinterface

bernd authored 17 years ago

103)       if (($_POST['new_user'] != '') and (in_array('new', $_POST['access']['new'])))
104)         array_push($_POST['access'][$_POST['new_db']], $_POST['new_user']);
105)     }
106)   }
107) 
108)   /* Ein neuer Account soll angelegt werden */
109)   if ($_POST['new_user'] != '')
110)   {
111)     create_mysql_account($_POST['new_user']);
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

112)     foreach ($dbs as $db) {
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

113)       $db = $db['name'];
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

114)       if (isset($_POST['access'][$db]) and (in_array('new', $_POST['access'][$db]))) {
bernd webinterface => /webinterface

bernd authored 17 years ago

115)         array_push($_POST['access'][$db], $_POST['new_user']);
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

116)       }
117)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

118)   }
119)   
120)   if (($_POST['new_user'] != '') or ($_POST['new_db'] != ''))
121)   {
122)     $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
123)     $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
124)   }
125) 
126)   foreach ($dbs as $db)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

127)   {
128)     $db = $db['name'];
bernd webinterface => /webinterface

bernd authored 17 years ago

129)     foreach ($users as $user)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

130)     {
131)       $user = $user['username'];
bernd webinterface => /webinterface

bernd authored 17 years ago

132)       if (! isset($_POST['access'][$db]))
133)         set_mysql_access($db, $user, false);
134)       else
135)         set_mysql_access($db, $user, in_array($user, $_POST['access'][$db]));
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

136)     }
137)   }
bernd webinterface => /webinterface

bernd authored 17 years ago

138)   $mysql_access = NULL;
139) }
140) 
141) if ($output_something)
142) {
bernd Benutze überall title() sta...

bernd authored 13 years ago

143)   title("MySQL-Datenbanken");
bernd Link zu phpMyAdmin prominen...

bernd authored 13 years ago

144)   output('<p>Hier können Sie 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 webinterface => /webinterface

bernd authored 17 years ago

145)   <p><strong>Hinweis:</strong> In dieser Matrix sehen Sie links die Datenbanken und oben die Benutzer, die Sie eingerichtet haben.
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

146)   In die leeren Eingabefelder können Sie den Namen eines neuen Benutzers bzw. einer neuen Datenbank eintragen. Sofern Sie noch keine Datenbank(en) oder Benutzer eingerichtet haben, erscheinen nur die Eingabefelder. Vergessen Sie nicht, nach der Erstellung eines neuen Benutzerkontos dem betreffenden Benutzer ein Passwort zu setzen (s. unten auf dieser Seite). Der Name von Datenbanken und Datenbank-Benutzern muss mit dem Namen des System-Benutzeraccounts übereinstimmen oder mit diesem und einem nachfolgenden Unterstrich beginnen. Z.B. kann der System-Benutzer <em>bernd</em> die MySQL-Accounts <em>bernd</em> und <em>bernd_2</em> erzeugen. Aufgrund einer Beschränkung des MySQL-Servers dürfen Benutzernamen allerdings zur Zeit nur 16 Zeichen lang sein.</p>');
bernd webinterface => /webinterface

bernd authored 17 years ago

147) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

148)   $form = '
bernd webinterface => /webinterface

bernd authored 17 years ago

149)   <table>
bernd Entities repariert

bernd authored 16 years ago

150)   <tr><th>&#160;</th><th style="background-color: #729bb3; color: #fff;padding: 0.2em;" colspan="'.(count($users)+1).'">Benutzerkonten</th></tr>
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

151)   <tr><th style="background-color: #729bb3; color: #fff;padding: 0.2em; text-align: left;">Datenbanken</th>';
bernd webinterface => /webinterface

bernd authored 17 years ago

152) 
153)   foreach ($users as $user)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

154)   {
bernd Zeige Link zum phpMyAdmin i...

bernd authored 13 years ago

155)     $username = $user["username"];
156)     //$username = str_replace('_', '_ ', $user['username']);
bernd Zeige Erstellungsdatum von...

bernd authored 14 years ago

157)     $desc = ($user['description'] ? $user['description'].' (Erstellt: '.$user['created'].')' : 'Erstellt: '.$user['created']);
bernd Benutzername am _ auftrenne...

bernd authored 14 years ago

158)     $form .= "<th><span title=\"{$desc}\">{$username}</span><br />".internal_link("", icon_delete("Benutzer »{$user['username']}« löschen"), "action=delete_user&user={$user['username']}")."</th>";
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

159)   }
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

160)   $form .= '<th><input type="text" name="new_user" size="10" value="" /><br />'.icon_add().'</th></tr>
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

161) ';
bernd webinterface => /webinterface

bernd authored 17 years ago

162) 
bernd Fix bug #636

bernd authored 14 years ago

163)   array_push($users, array('username' => "new", 'description' => NULL));
bernd webinterface => /webinterface

bernd authored 17 years ago

164) 
bernd Link zu phpMyAdmin prominen...

bernd authored 13 years ago

165)   $servers = servers_for_databases();
166) 
bernd webinterface => /webinterface

bernd authored 17 years ago

167)   foreach($dbs as $db)
168)   {
bernd Link zu phpMyAdmin prominen...

bernd authored 13 years ago

169)     $phpmyadmin = "https://mysql.{$servers[$db['name']]}/";
bernd Zeige Erstellungsdatum von...

bernd authored 14 years ago

170)     $desc = ($db['description'] ? $db['description'].' (Erstellt: '.$db['created'].')' : 'Erstellt: '.$db['created']);
bernd Zeige Link zum phpMyAdmin i...

bernd authored 13 years ago

171)     $form .= "<tr><td style=\"border: 0px; font-weight: bold; text-align: right;\"><span title=\"{$desc}\">{$db['name']}</span>&#160;".internal_link("", icon_delete("Datenbank »{$db['name']}« löschen"), "action=delete_db&db={$db['name']}")."&#160;<a href=\"".$phpmyadmin."\">".other_icon("database_go.png", "Datenbank-Verwaltung über phpMyAdmin")."</a></td>";
bernd webinterface => /webinterface

bernd authored 17 years ago

172)     foreach ($users as $user)
bernd Damn.

bernd authored 15 years ago

173)       $form .= '<td style="text-align: center;"><input type="checkbox" id="'.$db['name'].'_'.$user['username'].'" name="access['.$db['name'].'][]" value="'.$user['username'].'" '.(get_mysql_access($db['name'], $user['username']) ? 'checked="checked" ' : '')." /></td>";
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

174)     $form .= "</tr>\n";
bernd webinterface => /webinterface

bernd authored 17 years ago

175)   }
176) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

177)   $form .= '
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

178)   <tr><td style="border: 0px; font-weight: bold; text-align: right;"><input type="text" name="new_db" size="15" value="" />'.icon_add().'</td>';
bernd webinterface => /webinterface

bernd authored 17 years ago

179)   foreach ($users as $user)
bernd Damn.

bernd authored 15 years ago

180)     $form .= '<td style="text-align: center;"><input type="checkbox" id="new_'.$user['username'].'" name="access[new][]" value="'.$user['username'].'" /></td>';
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

181)   $form .= '</tr>
182)   </table>
bernd auch ohne vergebene Rechte...

bernd authored 16 years ago

183)   <p><input type="submit" name="accesseditor" value="Speichern" /></p>';
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

184) 
185)   
bernd eliminate .php extensions f...

bernd authored 15 years ago

186)   output(html_form('mysql_databases', 'databases', '', $form));
bernd webinterface => /webinterface

bernd authored 17 years ago

187) 
bernd Link zu phpMyAdmin prominen...

bernd authored 13 years ago

188)   $myservers = array();
189)   foreach ($servers as $s) {
190)     if (! in_array($s, $myservers)) {
191)       $myservers[] = $s;
192)     }
193)   }
194) 
195)   output("<h4>Verwaltung der Datenbanken (phpMyAdmin)</h4>
196)   <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>");
197)   if (count($myservers) == 1) {
198)     output("<p><strong><a href=\"https://mysql.{$myservers[0]}/\">phpMyAdmin aufrufen</a></strong></p>");
199)   }
200)   else {
201)     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>");
202)   }
203) 
204) 
bernd webinterface => /webinterface

bernd authored 17 years ago

205)   $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
206) 
207) 
bernd passwort-ändern wieder repa...

bernd authored 15 years ago

208) 
209)   $my_users = array();
210)   foreach ($users as $u)
211)   {
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

212)     $my_users[$u['username']] = $u['username'];
bernd passwort-ändern wieder repa...

bernd authored 15 years ago

213)   }
bernd Viele XHTML-Fehler korrigie...

bernd authored 16 years ago

214)   $form = '<div>
bernd passwort-ändern wieder repa...

bernd authored 15 years ago

215)   <label for="mysql_username">Benutzername:</label>&#160;'.html_select('mysql_username', $my_users).'
bernd use html_select, fix databa...

bernd authored 15 years ago

216)   &#160;&#160;&#160;
217)   <label for="password">Passwort:</label>&#160;<input type="password" name="mysql_password" id="password" />
218)   &#160;&#160;<input type="submit" value="Setzen" />
219) </div>';
220) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

221) 
222)   output('<h4>Passwort ändern</h4>
223)   <p>Hier können Sie das Passwort eines MySQL-Benutzeraccounts ändern bzw. neu setzen</p>
224) 
bernd use html_select, fix databa...

bernd authored 15 years ago

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