1aaaa700cdfda9c1e0bd92741205d07d8e0132de
bernd webinterface => /webinterface

bernd authored 17 years ago

1) <?php
2) 
3) require_once('session/start.php');
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

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

bernd authored 17 years ago

5) require_role(array(ROLE_SYSTEMUSER));
6) 
7) global $prefix;
8) 
9) require_once('mysql.php');
10) 
11) $output_something = true;
12) 
13) 
14) if (isset($_GET['action']))
15)   switch ($_GET['action'])
16)   {
17)     case 'delete_db':
bernd Fix of bugs #554 and #553

bernd authored 15 years ago

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

bernd authored 17 years ago

20)       $sure = user_is_sure();
21)       if ($sure === NULL)
22)       {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

24)         $output_something = false;
25)       }
26)       elseif ($sure === true)
27)       {
28)         delete_mysql_database($_GET['db']);
29)         header("Location: ?");
30)         $output_something = false;
31)       }
32)       elseif ($sure === false)
33)       {
34)         header("Location: ?");
35)         $output_something = false;
36)       }
37)       break;
38)     case 'delete_user':
bernd use html_select, fix databa...

bernd authored 15 years ago

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

bernd authored 15 years ago

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

bernd authored 17 years ago

41)       $sure = user_is_sure();
42)       if ($sure === NULL)
43)       {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

45)         $output_something = false;
46)       }
47)       elseif ($sure === true)
48)       {
49)         delete_mysql_account($_GET['user']);
50)         header("Location: ?");
51)         $output_something = false;
52)       }
53)       elseif ($sure === false)
54)       {
55)         header("Location: ?");
56)         $output_something = false;
57)       }
58)       break;
59)     case 'change_pw':
bernd Falscher CSRF-Schutz

bernd authored 16 years ago

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

bernd authored 17 years ago

61)       set_mysql_password($_POST['mysql_username'], $_POST['mysql_password']);
62)       header("Location: ?");
63)       $output_something = false;
64)       break;
65)     default:
66)       system_failure("Diese Funktion scheint noch nicht eingebaut zu sein!");
67)   }
68) 
69) 
70) $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
71) $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
72) 
bernd auch ohne vergebene Rechte...

bernd authored 16 years ago

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

bernd authored 17 years ago

74) {
bernd Falscher CSRF-Schutz

bernd authored 16 years ago

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

bernd authored 17 years ago

76)   /* Eine neue Datenbank */
77)   if ($_POST['new_db'] != '')
78)   {
79)     create_mysql_database($_POST['new_db']);
80)     if (isset($_POST['access']['new']))
81)     {
82)       $_POST['access'][$_POST['new_db']] = array();
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

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

bernd authored 15 years ago

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

bernd authored 13 years ago

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

bernd authored 17 years ago

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

bernd authored 13 years ago

87)         }
88)       }
bernd webinterface => /webinterface

bernd authored 17 years ago

89)       if (($_POST['new_user'] != '') and (in_array('new', $_POST['access']['new'])))
90)         array_push($_POST['access'][$_POST['new_db']], $_POST['new_user']);
91)     }
92)   }
93) 
94)   /* Ein neuer Account soll angelegt werden */
95)   if ($_POST['new_user'] != '')
96)   {
97)     create_mysql_account($_POST['new_user']);
bernd Fehlende geschweifte Klamme...

bernd authored 13 years ago

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

bernd authored 15 years ago

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

bernd authored 13 years ago

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

bernd authored 17 years ago

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

bernd authored 13 years ago

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

bernd authored 17 years ago

104)   }
105)   
106)   if (($_POST['new_user'] != '') or ($_POST['new_db'] != ''))
107)   {
108)     $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
109)     $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
110)   }
111) 
112)   foreach ($dbs as $db)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

113)   {
114)     $db = $db['name'];
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 15 years ago

116)     {
117)       $user = $user['username'];
bernd webinterface => /webinterface

bernd authored 17 years ago

118)       if (! isset($_POST['access'][$db]))
119)         set_mysql_access($db, $user, false);
120)       else
121)         set_mysql_access($db, $user, in_array($user, $_POST['access'][$db]));
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

122)     }
123)   }
bernd webinterface => /webinterface

bernd authored 17 years ago

124)   $mysql_access = NULL;
125) }
126) 
127) if ($output_something)
128) {
bernd Benutze überall title() sta...

bernd authored 13 years ago

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

bernd authored 13 years ago

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

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

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

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

hanno authored 16 years ago

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

bernd authored 17 years ago

135)   <table>
bernd Entities repariert

bernd authored 16 years ago

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

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

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

bernd authored 14 years ago

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

147) ';
bernd webinterface => /webinterface

bernd authored 17 years ago

148) 
bernd Fix bug #636

bernd authored 14 years ago

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

bernd authored 17 years ago

150) 
bernd Link zu phpMyAdmin prominen...

bernd authored 13 years ago

151)   $servers = servers_for_databases();
152) 
bernd webinterface => /webinterface

bernd authored 17 years ago

153)   foreach($dbs as $db)
154)   {
bernd Link zu phpMyAdmin prominen...

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

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

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

bernd authored 15 years ago

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

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

bernd authored 17 years ago

161)   }
162) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

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

bernd authored 14 years ago

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

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

bernd authored 15 years ago

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

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

bernd authored 16 years ago

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

hanno authored 16 years ago

170) 
171)   
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 17 years ago

173) 
bernd Link zu phpMyAdmin prominen...

bernd authored 13 years ago

174)   $myservers = array();
175)   foreach ($servers as $s) {
176)     if (! in_array($s, $myservers)) {
177)       $myservers[] = $s;
178)     }
179)   }
180) 
181)   output("<h4>Verwaltung der Datenbanken (phpMyAdmin)</h4>
182)   <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>");
183)   if (count($myservers) == 1) {
184)     output("<p><strong><a href=\"https://mysql.{$myservers[0]}/\">phpMyAdmin aufrufen</a></strong></p>");
185)   }
186)   else {
187)     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>");
188)   }
189) 
190) 
bernd webinterface => /webinterface

bernd authored 17 years ago

191)   $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
192) 
193) 
bernd passwort-ändern wieder repa...

bernd authored 15 years ago

194) 
195)   $my_users = array();
196)   foreach ($users as $u)
197)   {
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 15 years ago

202)   &#160;&#160;&#160;
203)   <label for="password">Passwort:</label>&#160;<input type="password" name="mysql_password" id="password" />
204)   &#160;&#160;<input type="submit" value="Setzen" />
205) </div>';
206) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

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

bernd authored 15 years ago

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