33986238e23400ebad6b51d626f4f765df94c6d2
bernd webinterface => /webinterface

bernd authored 17 years ago

1) <?php
2) 
3) require_once('session/start.php');
4) 
bernd Domain-Klasse benutzen

bernd authored 16 years ago

5) require_once('class/domain.php');
bernd 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) $title = "E-Mail-Accounts";
13) 
14) 
15) if (isset($_GET['action']) && $_GET['action'] == 'save')
16) {
17)   if (isset($_GET['id']))
18)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

19)     check_form_token('imap_accounts_edit');
bernd webinterface => /webinterface

bernd authored 17 years ago

20)     $account = $_POST['user'].'@'.$_POST['domain'];
21)     if (isset($_POST['enabled']) && $_POST['enabled'] == 'true')
22)       $enabled = 'Y';
23)     else
24)       $enabled = 'N';
25)     $acc = array('id' => $_GET['id'], 'account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
26)     if ($_POST['password'] != '')
27)       $acc['password'] = $_POST['password'];
28)     $error = check_valid($acc);
29)     if ($error != "")
30)     {
31)       input_error($error);
32)       $title = "E-Mail-Accounts";
33)       output("");
34)     }
35)     else
36)     {
37)       change_mailaccount($_GET['id'], $acc);
38)       if (! $debugmode)
39)         header('Location: accounts.php');
40)       die();
41)     }
42)   }
43)   elseif (isset($_POST['create']))
44)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

45)     check_form_token('imap_accounts_create');
bernd webinterface => /webinterface

bernd authored 17 years ago

46)     $account = $_POST['user'].'@'.$_POST['domain'];
47)     if (isset($_POST['enabled']) && $_POST['enabled'] == 'true')
48)       $enabled = 'Y';
49)     else
50)       $enabled = 'N';
51)     $acc = array('account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
52)     if ($_POST['password'] != '')
53)       $acc['password'] = $_POST['password'];
54)     $error = check_valid($acc);
55)     if ($error != "")
56)     {
57)       input_error($error);
58)       output("");
59)     }
60)     else
61)     {
62)       create_mailaccount($acc);
63)       if (! $debugmode)
64)         header('Location: accounts.php');
65)       die(); 
66)     }
67)   }
68) }
69) elseif (isset($_GET['action']) && $_GET['action'] == 'create')
70) {
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

71)   $options = '';
72)   $domains = get_domain_list($user['customerno'], $user['uid']);
73)   if (count($domains) > 0)
74)     $options .= '<option>----------------------------</option>';
75)   foreach ($domains as $dom)
76)     $options .= '<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>';
77) 
bernd webinterface => /webinterface

bernd authored 17 years ago

78)   output('<h3>E-Mail-Account anlegen</h3>
79) <p>Hier k&ouml;nnen Sie ein neues POP3/IMAP-Konto anlegen.</p>
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

80)   '.html_form('imap_accounts_create', 'accounts.php', 'action=save', '
bernd webinterface => /webinterface

bernd authored 17 years ago

81)   <table style="margin-bottom: 1em;">
82)   <tr><th>Einstellung:</th><th>Wert:</th><th>&nbsp;</th></tr>
83)   <tr>
84)     <td>Benutzername:</td>
85)     <td><input type="text" id="user" name="user" />@<select name="domain" size="1">
86)     <option value="schokokeks.org">schokokeks.org</option>
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

87)   '.$options.'
88)     </select></td>
bernd webinterface => /webinterface

bernd authored 17 years ago

89)   </tr>
90)   <tr>
91)     <td>Mailbox:</td>
92)     <td><input type="text" id="mailbox" name="mailbox" value="'.$user['homedir'].'/" /></td>
93)   </tr>
94)   <tr>
95)     <td>Passwort:</td>
96)     <td><input type="password" id="password" name="password" value="" /></td>
97)   </tr>
98)   <tr>
99)     <td>Account sofort aktivieren:</td>
100)     <td><input type="checkbox" id="enabled" name="enabled" value="true" /></td>
101)   </tr>
102)   </table>
bernd XML-Fehler

bernd authored 16 years ago

103)   <p><input type="submit" name="create" value="Anlegen" /></p>
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

104)   '));
bernd webinterface => /webinterface

bernd authored 17 years ago

105) }
106) elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '')
107) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

108)   $sure = user_is_sure();
109)   if ($sure === NULL)
110)   {
111)     $_GET['account'] = (int) $_GET['account'];
112)     $account = get_mailaccount($_GET['account']);
113)     $enabled = ($account['enabled'] ? 'Ja' : 'Nein');
114)     are_you_sure("action=delete&amp;account={$_GET['account']}", '
115)     <p>Soll der folgende Account wirklich gel&ouml;scht werden?</p>
116)     <table style="margin-bottom: 1em;">
117)       <tr><td>Benutzername:</td>
118)         <td>'.filter_input_general($account['account']).'</td>
119)       </tr>
120)       <tr><td>Mailbox:</td>
121)         <td>'.filter_input_general($account['mailbox']).'</td>
122)       </tr>
123)       <tr><td>Konto aktiv:</td>
124)         <td>'.$enabled.'</td>
125)       </tr>
126)     </table>
127) ');
128)   }
129)   elseif ($sure === true)
bernd webinterface => /webinterface

bernd authored 17 years ago

130)   {
131)     delete_mailaccount($_GET['account']);
132)     if (! $debugmode)
133)       header('Location: accounts.php');
134)     die();
135)   }
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

136)   elseif ($sure === false)
bernd webinterface => /webinterface

bernd authored 17 years ago

137)   {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

138)     if (! $debugmode)
139)       header("Location: accounts.php");
140)     die();
bernd webinterface => /webinterface

bernd authored 17 years ago

141)   }
142) }
143) elseif (isset($_GET['edit']))
144) {
145)   output('<h3>E-Mail-Account bearbeiten</h3>
146) <p>Hier k&ouml;nnen Sie die Einstellungen des IMAP-Kontos bearbeiten.</p>
147) ');
148)   $_GET['edit'] = (int) $_GET['edit'];
149)   $account = get_mailaccount($_GET['edit']);
150)   list($username, $domain) = explode('@', $account['account'], 2);
151)   $enabled = ($account['enabled'] ? ' checked="checked"' : '');
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

bernd authored 17 years ago

153)   <table style="margin-bottom: 1em;">
154)   <tr><th>Einstellung:</th><th>alter Wert:</th><th>neuer Wert:</th><th>&nbsp;</th></tr>
155)   <tr><td>Benutzername:</td><td><input type="text" id="old_account" name="old_account" value="'.$account['account'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
156)           <td><input type="text" id="user" name="user" value="'.$username.'" />@<select name="domain" id="domain" size="1">
157)     <option value="schokokeks.org">schokokeks.org</option>
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

158)     ';
bernd Domain-Klasse benutzen

bernd authored 16 years ago

159)     $domains = get_domain_list($user['customerno'], $user['uid']);
bernd webinterface => /webinterface

bernd authored 17 years ago

160)     if (count($domains) > 0)
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

161)       $form .= '<option>----------------------------</option>';
bernd webinterface => /webinterface

bernd authored 17 years ago

162)     foreach ($domains as $dom)
bernd Domain-Klasse benutzen

bernd authored 16 years ago

163)       if ($domain == $dom->fqdn)
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

164)         $form .= '<option value="'.$dom->fqdn.'" selected="selected">'.$dom->fqdn.'</option>';
bernd webinterface => /webinterface

bernd authored 17 years ago

165)       else
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

166)         $form .= '<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>';
bernd webinterface => /webinterface

bernd authored 17 years ago

167) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

168)     $form .= '</select></td>
bernd webinterface => /webinterface

bernd authored 17 years ago

169)           <td><input type="button" onclick="document.getElementById(\'user\').value = \''.$username.'\' ; document.getElementById(\'domain\').value = \''.$domain.'\'" value="Zeile zur&uuml;cksetzen" /></td></tr>
170)   <tr><td>Mailbox:</td><td><input type="text" id="old_mailbox" name="old_mailbox" value="'.$account['mailbox'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
171)           <td><input type="text" id="mailbox" name="mailbox" value="'.$account['mailbox'].'" /></td>
172)           <td><input type="button" onclick="document.getElementById(\'mailbox\').value = document.getElementById(\'old_mailbox\').value" value="Zeile zur&uuml;cksetzen" /></td></tr>
173)   <tr><td>Passwort:</td><td><i>nicht angezeigt</i></td>
174)           <td><input type="password" id="password" name="password" value="" /></td>
175)           <td><input type="button" onclick="document.getElementById(\'password\').value = \'\'" value="Zeile zur&uuml;cksetzen" /></td></tr>
176)   <tr><td>Konto aktiv:</td>
177)     <td>&nbsp;</td>
178)     <td><input type="checkbox" id="enabled" name="enabled" value="true"'.$enabled.' /></td>
179)     <td>&nbsp;</td></tr>
180)   </table>
181)   <p><input type="submit" value="&Auml;nderungen speichern" /><br />
182)   Hinweis: Das Passwort wird nur ge&auml;ndert, wenn Sie auf dieser Seite eines eingeben. Geben Sie keines an, wird das bisherige beibehalten!</p>
183)   </form>
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

184)   ';
185)   output(html_form('imap_accounts_edit', 'accounts.php', 'action=save&id='.$_GET['edit'], $form));
bernd webinterface => /webinterface

bernd authored 17 years ago

186) }
187) else
188) {
189)   output('<h3>E-Mail-Accounts</h3>
190) <p>Folgende POP3/IMAP-Konten sind eingerichtet:</p>
191) <table style="margin-bottom: 1em;">
bernd Auf die Account-Namen klick...

bernd authored 16 years ago

192) <tr><th>Kontoname:</th><th>Mailbox-Pfad:</th><th>aktiv</th><th>&nbsp;</th></tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

193) ');
194) 
195)         foreach (mailaccounts($user['uid']) as $account)
196)         {
197)                 $mailbox = $account['mailbox'];
198)                 if (empty($mailbox))
199)                         $mailbox = '<i>nicht festgelegt</i>';
200)                 output('<tr>
bernd Auf die Account-Namen klick...

bernd authored 16 years ago

201)             <td>'.internal_link('accounts.php', $account['account'], 'edit='.$account['id']).'</td>
bernd webinterface => /webinterface

bernd authored 17 years ago

202)             <td>'.$mailbox.'</td>
203)             <td><b>'.($account['enabled'] ? 'Ja' : 'Nein').'</b></td>
bernd Auf die Account-Namen klick...

bernd authored 16 years ago

204)             <td><a href="accounts.php?action=delete&amp;account='.$account['id'].'">l&ouml;schen</a></td></tr>');