5bdbcb674e48b19cd1cc9052dabaf77a2cd6e0de
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();
83)       foreach ($users as $user)
bernd * Erlaube Beschreibung zu D...

bernd authored 15 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

bernd authored 17 years ago

120)   $mysql_access = NULL;
121) }
122) 
123) if ($output_something)
124) {
125) 
126)   output('<h3>MySQL-Datenbanken</h3>
127)   <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>
128)   <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

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

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

hanno authored 16 years ago

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

bernd authored 17 years ago

132)   <table>
bernd Entities repariert

bernd authored 16 years ago

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

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

bernd authored 17 years ago

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

bernd authored 15 years ago

137)   {
bernd Benutzername am _ auftrenne...

bernd authored 14 years ago

138)     $username = str_replace('_', '_ ', $user['username']);
bernd Zeige Erstellungsdatum von...

bernd authored 14 years ago

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

bernd authored 14 years ago

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

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

bernd authored 14 years ago

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

143) ';
bernd webinterface => /webinterface

bernd authored 17 years ago

144) 
bernd Fix bug #636

bernd authored 14 years ago

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

bernd authored 17 years ago

146) 
147)   foreach($dbs as $db)
148)   {
bernd Zeige Erstellungsdatum von...

bernd authored 14 years ago

149)     $desc = ($db['description'] ? $db['description'].' (Erstellt: '.$db['created'].')' : 'Erstellt: '.$db['created']);
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

150)     $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']}")."</td>";
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 15 years ago

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

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

bernd authored 17 years ago

154)   }
155) 
hanno MySQL-Modul auf html_form()...

hanno authored 16 years ago

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

bernd authored 14 years ago

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

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

bernd authored 15 years ago

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

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

bernd authored 16 years ago

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

hanno authored 16 years ago

163) 
164)   
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 17 years ago

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

bernd authored 15 years ago

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

bernd authored 15 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 15 years ago

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

hanno authored 16 years ago

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

bernd authored 15 years ago

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