99485df2f1408ac0a06078301f32fcdf26ac62f8
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>
bernd Entities repariert

bernd authored 16 years ago

79) <p>Hier können Sie ein neues POP3/IMAP-Konto anlegen.</p>
bernd big-fat-warning bei imap-ac...

bernd authored 16 years ago

80) <p style="border: 2px solid red; background-color: white; padding:1em;"><strong>ACHTUNG:</strong> ein POP3-/IMAP-Account ist <strong>keine E-Mail-Adresse</strong>. Wenn Sie sich nicht sicher sind, lesen Sie bitte die Anleitung <a href="https://wiki.schokokeks.org/E-Mail/Konfiguration">in unserem Wiki</a>. Sie können Ihre E-Mail-Konten auch über eine einfachere Möglichkeit verwalten, dann ist eine Einrichtung über diese Weboberfläche möglich. Die Umstellung erfolgt manuell pro Domain und kann bei den Admins angefordert werden.</p>
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

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

bernd authored 17 years ago

82)   <table style="margin-bottom: 1em;">
bernd Entities repariert

bernd authored 16 years ago

83)   <tr><th>Einstellung:</th><th>Wert:</th><th>&#160;</th></tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

84)   <tr>
85)     <td>Benutzername:</td>
86)     <td><input type="text" id="user" name="user" />@<select name="domain" size="1">
87)     <option value="schokokeks.org">schokokeks.org</option>
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

109)   $sure = user_is_sure();
110)   if ($sure === NULL)
111)   {
112)     $_GET['account'] = (int) $_GET['account'];
113)     $account = get_mailaccount($_GET['account']);
114)     $enabled = ($account['enabled'] ? 'Ja' : 'Nein');
115)     are_you_sure("action=delete&amp;account={$_GET['account']}", '
bernd Entities repariert

bernd authored 16 years ago

116)     <p>Soll der folgende Account wirklich gelöscht werden?</p>
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

117)     <table style="margin-bottom: 1em;">
118)       <tr><td>Benutzername:</td>
119)         <td>'.filter_input_general($account['account']).'</td>
120)       </tr>
121)       <tr><td>Mailbox:</td>
122)         <td>'.filter_input_general($account['mailbox']).'</td>
123)       </tr>
124)       <tr><td>Konto aktiv:</td>
125)         <td>'.$enabled.'</td>
126)       </tr>
127)     </table>
128) ');
129)   }
130)   elseif ($sure === true)
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

142)   }
143) }
144) elseif (isset($_GET['edit']))
145) {
146)   output('<h3>E-Mail-Account bearbeiten</h3>
bernd Entities repariert

bernd authored 16 years ago

147) <p>Hier können Sie die Einstellungen des IMAP-Kontos bearbeiten.</p>
bernd webinterface => /webinterface

bernd authored 17 years ago

148) ');
149)   $_GET['edit'] = (int) $_GET['edit'];
150)   $account = get_mailaccount($_GET['edit']);
151)   list($username, $domain) = explode('@', $account['account'], 2);
152)   $enabled = ($account['enabled'] ? ' checked="checked"' : '');
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

bernd authored 17 years ago

154)   <table style="margin-bottom: 1em;">
bernd Entities repariert

bernd authored 16 years ago

155)   <tr><th>Einstellung:</th><th>alter Wert:</th><th>neuer Wert:</th><th>&#160;</th></tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

156)   <tr><td>Benutzername:</td><td><input type="text" id="old_account" name="old_account" value="'.$account['account'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
157)           <td><input type="text" id="user" name="user" value="'.$username.'" />@<select name="domain" id="domain" size="1">
158)     <option value="schokokeks.org">schokokeks.org</option>
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

159)     ';
bernd Domain-Klasse benutzen

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

169)     $form .= '</select></td>
bernd Entities repariert

bernd authored 16 years ago

170)           <td><input type="button" onclick="document.getElementById(\'user\').value = \''.$username.'\' ; document.getElementById(\'domain\').value = \''.$domain.'\'" value="Zeile zurücksetzen" /></td></tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

171)   <tr><td>Mailbox:</td><td><input type="text" id="old_mailbox" name="old_mailbox" value="'.$account['mailbox'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
172)           <td><input type="text" id="mailbox" name="mailbox" value="'.$account['mailbox'].'" /></td>
bernd Entities repariert

bernd authored 16 years ago

173)           <td><input type="button" onclick="document.getElementById(\'mailbox\').value = document.getElementById(\'old_mailbox\').value" value="Zeile zurücksetzen" /></td></tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

174)   <tr><td>Passwort:</td><td><i>nicht angezeigt</i></td>
175)           <td><input type="password" id="password" name="password" value="" /></td>
bernd Entities repariert

bernd authored 16 years ago

176)           <td><input type="button" onclick="document.getElementById(\'password\').value = \'\'" value="Zeile zurücksetzen" /></td></tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

177)   <tr><td>Konto aktiv:</td>
bernd Entities repariert

bernd authored 16 years ago

178)     <td>&#160;</td>
bernd webinterface => /webinterface

bernd authored 17 years ago

179)     <td><input type="checkbox" id="enabled" name="enabled" value="true"'.$enabled.' /></td>
bernd Entities repariert

bernd authored 16 years ago

180)     <td>&#160;</td></tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

181)   </table>
bernd Entities repariert

bernd authored 16 years ago

182)   <p><input type="submit" value="Änderungen speichern" /><br />
183)   Hinweis: Das Passwort wird nur geändert, wenn Sie auf dieser Seite eines eingeben. Geben Sie keines an, wird das bisherige beibehalten!</p>
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 Entities repariert

bernd authored 16 years ago

192) <tr><th>Kontoname:</th><th>Mailbox-Pfad:</th><th>aktiv</th><th>&#160;</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 Entities repariert

bernd authored 16 years ago

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