aed08fe4c892152b0281d89dc06a08b1e0a9e231
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 15 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 15 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

73) {
bernd Falscher CSRF-Schutz

bernd authored 16 years ago

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

bernd authored 17 years ago

75)   /* Eine neue Datenbank */
76)   if ($_POST['new_db'] != '')
77)   {
78)     create_mysql_database($_POST['new_db']);
79)     if (isset($_POST['access']['new']))
80)     {
81)       $_POST['access'][$_POST['new_db']] = array();
82)       foreach ($users as $user)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

83)         $user = $user['username'];
bernd webinterface => /webinterface

bernd authored 17 years ago

84)         if (in_array($user, $_POST['access']['new']))
85)           array_push($_POST['access'][$_POST['new_db']], $user);
86)       if (($_POST['new_user'] != '') and (in_array('new', $_POST['access']['new'])))
87)         array_push($_POST['access'][$_POST['new_db']], $_POST['new_user']);
88)     }
89)   }
90) 
91)   /* Ein neuer Account soll angelegt werden */
92)   if ($_POST['new_user'] != '')
93)   {
94)     create_mysql_account($_POST['new_user']);
95)     foreach ($dbs as $db)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

96)       $db = $db['name'];
bernd webinterface => /webinterface

bernd authored 17 years ago

97)       if (isset($_POST['access'][$db]) and (in_array('new', $_POST['access'][$db])))
98)         array_push($_POST['access'][$db], $_POST['new_user']);
99)   }
100)   
101)   if (($_POST['new_user'] != '') or ($_POST['new_db'] != ''))
102)   {
103)     $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
104)     $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
105)   }
106) 
107)   foreach ($dbs as $db)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

108)   {
109)     $db = $db['name'];
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 15 years ago

111)     {
112)       $user = $user['username'];
bernd webinterface => /webinterface

bernd authored 17 years ago

113)       if (! isset($_POST['access'][$db]))
114)         set_mysql_access($db, $user, false);
115)       else
116)         set_mysql_access($db, $user, in_array($user, $_POST['access'][$db]));
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

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

bernd authored 17 years ago

119)   $mysql_access = NULL;
120) }
121) 
122) if ($output_something)
123) {
124) 
125)   output('<h3>MySQL-Datenbanken</h3>
126)   <p>Hier können Sie Ihre MySQL-Datenbanken verwalten. Die Einstellungen werden mit einer leichten Verzögerung (maximal 1 Minute) in das System übertragen. Bitte beachten Sie, dass neue Zugänge also nicht umgehend funktionieren.</p>
127)   <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

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

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

hanno authored 16 years ago

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

bernd authored 17 years ago

131)   <table>
bernd Entities repariert

bernd authored 16 years ago

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

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

bernd authored 17 years ago

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

bernd authored 15 years ago

136)   {
bernd Zeige Erstellungsdatum von...

bernd authored 14 years ago

137)     $desc = ($user['description'] ? $user['description'].' (Erstellt: '.$user['created'].')' : 'Erstellt: '.$user['created']);
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

138)     $form .= "<th><span title=\"{$desc}\">{$user['username']}</span><br />".internal_link("", "<img src=\"{$prefix}images/delete.png\" title=\"Benutzer »{$user['username']}« löschen\" alt=\"löschen\" />", "action=delete_user&user={$user['username']}")."</th>";
139)   }
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

140)   $form .= '<th><input type="text" name="new_user" size="10" value="" /></th></tr>
141) ';
bernd webinterface => /webinterface

bernd authored 17 years ago

142) 
bernd Fix bug #636

bernd authored 14 years ago

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

bernd authored 17 years ago

144) 
145)   foreach($dbs as $db)
146)   {
bernd Zeige Erstellungsdatum von...

bernd authored 14 years ago

147)     $desc = ($db['description'] ? $db['description'].' (Erstellt: '.$db['created'].')' : 'Erstellt: '.$db['created']);
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

148)     $form .= "<tr><td style=\"border: 0px; font-weight: bold; text-align: right;\"><span title=\"{$desc}\">{$db['name']}</span>&#160;".internal_link("", "<img src=\"{$prefix}images/delete.png\" title=\"Datenbank »{$db['name']}« löschen\" alt=\"löschen\" />", "action=delete_db&db={$db['name']}")."</td>";
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 15 years ago

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

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

bernd authored 17 years ago

152)   }
153) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

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

bernd authored 16 years ago

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

hanno authored 16 years ago

161) 
162)   
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 17 years ago

164) 
165)   $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
166) 
167) 
bernd passwort-ändern wieder repa...

bernd authored 15 years ago

168) 
169)   $my_users = array();
170)   foreach ($users as $u)
171)   {
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 15 years ago

176)   &#160;&#160;&#160;
177)   <label for="password">Passwort:</label>&#160;<input type="password" name="mysql_password" id="password" />
178)   &#160;&#160;<input type="submit" value="Setzen" />
179) </div>';
180) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

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

bernd authored 15 years ago

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