webinterface => /webinterface
bernd authored 17 years ago
|
1) <?php
2)
3) require_once('session/start.php');
4)
|
Domain-Klasse benutzen
bernd authored 17 years ago
|
5) require_once('class/domain.php');
|
webinterface => /webinterface
bernd authored 17 years ago
|
6) require_once('mailaccounts.php');
7)
8) require_role(ROLE_SYSTEMUSER);
9)
10) $user = $_SESSION['userinfo'];
11)
12) $param = '';
13) if ($debugmode)
14) $param="debug";
15)
16) $title = "E-Mail-Accounts";
17)
18)
19) if (isset($_GET['action']) && $_GET['action'] == 'save')
20) {
21) if (isset($_GET['id']))
22) {
|
XSRF-kram fixed
bernd authored 17 years ago
|
23) check_form_token('imap_accounts_edit');
|
webinterface => /webinterface
bernd authored 17 years ago
|
24) $account = $_POST['user'].'@'.$_POST['domain'];
25) if (isset($_POST['enabled']) && $_POST['enabled'] == 'true')
26) $enabled = 'Y';
27) else
28) $enabled = 'N';
29) $acc = array('id' => $_GET['id'], 'account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
30) if ($_POST['password'] != '')
31) $acc['password'] = $_POST['password'];
32) $error = check_valid($acc);
33) if ($error != "")
34) {
35) input_error($error);
36) $section = "mail";
37) $title = "E-Mail-Accounts";
38) output("");
39) }
40) else
41) {
42) change_mailaccount($_GET['id'], $acc);
43) if (! $debugmode)
44) header('Location: accounts.php');
45) die();
46) }
47) }
48) elseif (isset($_POST['create']))
49) {
|
XSRF-kram fixed
bernd authored 17 years ago
|
50) check_form_token('imap_accounts_create');
|
webinterface => /webinterface
bernd authored 17 years ago
|
51) $account = $_POST['user'].'@'.$_POST['domain'];
52) if (isset($_POST['enabled']) && $_POST['enabled'] == 'true')
53) $enabled = 'Y';
54) else
55) $enabled = 'N';
56) $acc = array('account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
57) if ($_POST['password'] != '')
58) $acc['password'] = $_POST['password'];
59) $error = check_valid($acc);
60) if ($error != "")
61) {
62) input_error($error);
63) output("");
64) }
65) else
66) {
67) create_mailaccount($acc);
68) if (! $debugmode)
69) header('Location: accounts.php');
70) die();
71) }
72) }
73) }
74) elseif (isset($_GET['action']) && $_GET['action'] == 'create')
75) {
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
76) $options = '';
77) $domains = get_domain_list($user['customerno'], $user['uid']);
78) if (count($domains) > 0)
79) $options .= '<option>----------------------------</option>';
80) foreach ($domains as $dom)
81) $options .= '<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>';
82)
|
webinterface => /webinterface
bernd authored 17 years ago
|
83) output('<h3>E-Mail-Account anlegen</h3>
84) <p>Hier können Sie ein neues POP3/IMAP-Konto anlegen.</p>
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
85) '.html_form('imap_accounts_create', 'accounts.php', 'action=save', '
|
webinterface => /webinterface
bernd authored 17 years ago
|
86) <table style="margin-bottom: 1em;">
87) <tr><th>Einstellung:</th><th>Wert:</th><th> </th></tr>
88) <tr>
89) <td>Benutzername:</td>
90) <td><input type="text" id="user" name="user" />@<select name="domain" size="1">
91) <option value="schokokeks.org">schokokeks.org</option>
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
92) '.$options.'
93) </select></td>
|
webinterface => /webinterface
bernd authored 17 years ago
|
94) </tr>
95) <tr>
96) <td>Mailbox:</td>
97) <td><input type="text" id="mailbox" name="mailbox" value="'.$user['homedir'].'/" /></td>
98) </tr>
99) <tr>
100) <td>Passwort:</td>
101) <td><input type="password" id="password" name="password" value="" /></td>
102) </tr>
103) <tr>
104) <td>Account sofort aktivieren:</td>
105) <td><input type="checkbox" id="enabled" name="enabled" value="true" /></td>
106) </tr>
107) </table>
|
XML-Fehler
bernd authored 17 years ago
|
108) <p><input type="submit" name="create" value="Anlegen" /></p>
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
109) '));
|
webinterface => /webinterface
bernd authored 17 years ago
|
110) }
111) elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '')
112) {
113) if ($_POST['confirm'] == 'yes')
114) {
|
XSRF-kram fixed
bernd authored 17 years ago
|
115) check_form_token('imap_accounts_delete');
|
webinterface => /webinterface
bernd authored 17 years ago
|
116) delete_mailaccount($_GET['account']);
117) if (! $debugmode)
118) header('Location: accounts.php');
119) die();
120) }
121) else
122) {
123) output('<h3>E-Mail-Account löschen</h3>
124) <p>Soll der folgende Account wirklich gelöscht werden?</p>
125) ');
126) $_GET['account'] = (int) $_GET['account'];
127) $account = get_mailaccount($_GET['account']);
128) $enabled = ($account['enabled'] ? 'Ja' : 'Nein');
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
129) output(html_form('imap_accounts_delete', "accounts.php", "action=delete&account=".$_GET['account'],
130) '<table style="margin-bottom: 1em;">
|
webinterface => /webinterface
bernd authored 17 years ago
|
131) <tr><td>Benutzername:</td>
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
132) <td>'.filter_input_general($account['account']).'</td>
|
webinterface => /webinterface
bernd authored 17 years ago
|
133) </tr>
134) <tr><td>Mailbox:</td>
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
135) <td>'.filter_input_general($account['mailbox']).'</td>
|
webinterface => /webinterface
bernd authored 17 years ago
|
136) </tr>
137) <tr><td>Konto aktiv:</td>
138) <td>'.$enabled.'</td>
|
XML-Fehler
bernd authored 17 years ago
|
139) </tr>
|
webinterface => /webinterface
bernd authored 17 years ago
|
140) </table>
141) <p><input type="hidden" name="confirm" value="yes" />
142) <input type="submit" value="Wirklich löschen" />
143) </p>
|
XSS/CSRF-Bugs behoben
bernd authored 17 years ago
|
144) '));
|
webinterface => /webinterface
bernd authored 17 years ago
|
145) }
146) }
147) elseif (isset($_GET['edit']))
148) {
149) output('<h3>E-Mail-Account bearbeiten</h3>
150) <p>Hier können Sie die Einstellungen des IMAP-Kontos bearbeiten.</p>
151) ');
152) $_GET['edit'] = (int) $_GET['edit'];
153) $account = get_mailaccount($_GET['edit']);
154) list($username, $domain) = explode('@', $account['account'], 2);
155) $enabled = ($account['enabled'] ? ' checked="checked"' : '');
156) output('<form action="accounts.php?action=save&id='.$_GET['edit'].'&'.$param.'" method="post">
|
XSRF-kram fixed
bernd authored 17 years ago
|
157) '.generate_form_token('imap_accounts_edit').'
|
webinterface => /webinterface
bernd authored 17 years ago
|
158) <table style="margin-bottom: 1em;">
159) <tr><th>Einstellung:</th><th>alter Wert:</th><th>neuer Wert:</th><th> </th></tr>
160) <tr><td>Benutzername:</td><td><input type="text" id="old_account" name="old_account" value="'.$account['account'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
161) <td><input type="text" id="user" name="user" value="'.$username.'" />@<select name="domain" id="domain" size="1">
162) <option value="schokokeks.org">schokokeks.org</option>
163) ');
|
Domain-Klasse benutzen
bernd authored 17 years ago
|
164) $domains = get_domain_list($user['customerno'], $user['uid']);
|
webinterface => /webinterface
bernd authored 17 years ago
|
165) if (count($domains) > 0)
166) output('<option>----------------------------</option>');
167) foreach ($domains as $dom)
|
Domain-Klasse benutzen
bernd authored 17 years ago
|
168) if ($domain == $dom->fqdn)
169) output('<option value="'.$dom->fqdn.'" selected="selected">'.$dom->fqdn.'</option>');
|
webinterface => /webinterface
bernd authored 17 years ago
|
170) else
|
Domain-Klasse benutzen
bernd authored 17 years ago
|
171) output('<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>');
|
webinterface => /webinterface
bernd authored 17 years ago
|
172)
173) output('</select></td>
174) <td><input type="button" onclick="document.getElementById(\'user\').value = \''.$username.'\' ; document.getElementById(\'domain\').value = \''.$domain.'\'" value="Zeile zurücksetzen" /></td></tr>
175) <tr><td>Mailbox:</td><td><input type="text" id="old_mailbox" name="old_mailbox" value="'.$account['mailbox'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
176) <td><input type="text" id="mailbox" name="mailbox" value="'.$account['mailbox'].'" /></td>
177) <td><input type="button" onclick="document.getElementById(\'mailbox\').value = document.getElementById(\'old_mailbox\').value" value="Zeile zurücksetzen" /></td></tr>
178) <tr><td>Passwort:</td><td><i>nicht angezeigt</i></td>
179) <td><input type="password" id="password" name="password" value="" /></td>
180) <td><input type="button" onclick="document.getElementById(\'password\').value = \'\'" value="Zeile zurücksetzen" /></td></tr>
181) <tr><td>Konto aktiv:</td>
182) <td> </td>
183) <td><input type="checkbox" id="enabled" name="enabled" value="true"'.$enabled.' /></td>
184) <td> </td></tr>
185) </table>
186) <p><input type="submit" value="Änderungen speichern" /><br />
187) Hinweis: Das Passwort wird nur geändert, wenn Sie auf dieser Seite eines eingeben. Geben Sie keines an, wird das bisherige beibehalten!</p>
188) </form>
189) ');
190)
191) }
192) else
193) {
194) output('<h3>E-Mail-Accounts</h3>
195) <p>Folgende POP3/IMAP-Konten sind eingerichtet:</p>
196) <table style="margin-bottom: 1em;">
197) <tr><th>Benutzername:</th><th>Mailbox-Pfad:</th><th>aktiv</th><th> </th></tr>
198) ');
199)
200) foreach (mailaccounts($user['uid']) as $account)
201) {
202) $mailbox = $account['mailbox'];
203) if (empty($mailbox))
204) $mailbox = '<i>nicht festgelegt</i>';
205) output('<tr>
206) <td>'.$account['account'].'</td>
207) <td>'.$mailbox.'</td>
208) <td><b>'.($account['enabled'] ? 'Ja' : 'Nein').'</b></td>
|
XML-Fehler
bernd authored 17 years ago
|
209) <td><a href="accounts.php?edit='.$account['id'].'">bearbeiten</a></td><td><a href="accounts.php?action=delete&account='.$account['id'].'">löschen</a></td></tr>');
|