d557cea97936e3e438de1d50de9216d911bc11a7
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) $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)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

23)     check_form_token('imap_accounts_edit');
bernd 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)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

50)     check_form_token('imap_accounts_create');
bernd 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) {
76)   output('<h3>E-Mail-Account anlegen</h3>
77) <p>Hier k&ouml;nnen Sie ein neues POP3/IMAP-Konto anlegen.</p>
78)   <form action="accounts.php?action=save&'.$param.'" method="post">
bernd XSRF-kram fixed

bernd authored 16 years ago

79)   '.generate_form_token('imap_accounts_create').'
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

88)     if (count($domains) > 0)
89)       output('<option>----------------------------</option>');
90)     foreach ($domains as $dom)
bernd Domain-Klasse benutzen

bernd authored 16 years ago

91)       output('<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>');
bernd webinterface => /webinterface

bernd authored 17 years ago

92)     output('</select></td>
93) 
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>
108)   <p><input type="submit" name="create" value="Anlegen" /><br />
109)   </form>
110)   ');
111) }
112) elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '')
113) {
114)   if ($_POST['confirm'] == 'yes')
115)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

116)     check_form_token('imap_accounts_delete');
bernd webinterface => /webinterface

bernd authored 17 years ago

117)     delete_mailaccount($_GET['account']);
118)     if (! $debugmode)
119)       header('Location: accounts.php');
120)     die();
121)   }
122)   else
123)   {
124)     output('<h3>E-Mail-Account l&ouml;schen</h3>
125)     <p>Soll der folgende Account wirklich gel&ouml;scht werden?</p>
126)     ');
127)     $_GET['account'] = (int) $_GET['account'];
128)     $account = get_mailaccount($_GET['account']);
129)     $enabled = ($account['enabled'] ? 'Ja' : 'Nein');
130)     output('<form action="accounts.php?action=delete&amp;account='.$_GET['account'].'&amp;'.$param.'" method="post">
bernd XSRF-kram fixed

bernd authored 16 years ago

131)     '.generate_form_token('imap_accounts_delete').'
bernd webinterface => /webinterface

bernd authored 17 years ago

132)     <table style="margin-bottom: 1em;">
133)     <tr><td>Benutzername:</td>
134)       <td>'.$account['account'].'</td>
135)     </tr>
136)     <tr><td>Mailbox:</td>
137)       <td>'.$account['mailbox'].'</td>
138)     </tr>
139)     <tr><td>Konto aktiv:</td>
140)       <td>'.$enabled.'</td>
141)   </table>
142)   <p><input type="hidden" name="confirm" value="yes" />
143)     <input type="submit" value="Wirklich l&ouml;schen" />
144)   </p>
145)   </form>
146)   ');
147)   }
148) }
149) elseif (isset($_GET['edit']))
150) {
151)   output('<h3>E-Mail-Account bearbeiten</h3>
152) <p>Hier k&ouml;nnen Sie die Einstellungen des IMAP-Kontos bearbeiten.</p>
153) ');
154)   $_GET['edit'] = (int) $_GET['edit'];
155)   $account = get_mailaccount($_GET['edit']);
156)   list($username, $domain) = explode('@', $account['account'], 2);
157)   $enabled = ($account['enabled'] ? ' checked="checked"' : '');
158)   output('<form action="accounts.php?action=save&amp;id='.$_GET['edit'].'&amp;'.$param.'" method="post">
bernd XSRF-kram fixed

bernd authored 16 years ago

159)   '.generate_form_token('imap_accounts_edit').'
bernd webinterface => /webinterface

bernd authored 17 years ago

160)   <table style="margin-bottom: 1em;">
161)   <tr><th>Einstellung:</th><th>alter Wert:</th><th>neuer Wert:</th><th>&nbsp;</th></tr>
162)   <tr><td>Benutzername:</td><td><input type="text" id="old_account" name="old_account" value="'.$account['account'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
163)           <td><input type="text" id="user" name="user" value="'.$username.'" />@<select name="domain" id="domain" size="1">
164)     <option value="schokokeks.org">schokokeks.org</option>
165)     ');
bernd Domain-Klasse benutzen

bernd authored 16 years ago

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

bernd authored 17 years ago

167)     if (count($domains) > 0)
168)       output('<option>----------------------------</option>');
169)     foreach ($domains as $dom)
bernd Domain-Klasse benutzen

bernd authored 16 years ago

170)       if ($domain == $dom->fqdn)
171)         output('<option value="'.$dom->fqdn.'" selected="selected">'.$dom->fqdn.'</option>');
bernd webinterface => /webinterface

bernd authored 17 years ago

172)       else
bernd Domain-Klasse benutzen

bernd authored 16 years ago

173)         output('<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>');
bernd webinterface => /webinterface

bernd authored 17 years ago

174) 
175)     output('</select></td>
176)           <td><input type="button" onclick="document.getElementById(\'user\').value = \''.$username.'\' ; document.getElementById(\'domain\').value = \''.$domain.'\'" value="Zeile zur&uuml;cksetzen" /></td></tr>
177)   <tr><td>Mailbox:</td><td><input type="text" id="old_mailbox" name="old_mailbox" value="'.$account['mailbox'].'" readonly="readonly" style="background-color: #C0C0C0;" /></td>
178)           <td><input type="text" id="mailbox" name="mailbox" value="'.$account['mailbox'].'" /></td>
179)           <td><input type="button" onclick="document.getElementById(\'mailbox\').value = document.getElementById(\'old_mailbox\').value" value="Zeile zur&uuml;cksetzen" /></td></tr>
180)   <tr><td>Passwort:</td><td><i>nicht angezeigt</i></td>
181)           <td><input type="password" id="password" name="password" value="" /></td>
182)           <td><input type="button" onclick="document.getElementById(\'password\').value = \'\'" value="Zeile zur&uuml;cksetzen" /></td></tr>
183)   <tr><td>Konto aktiv:</td>
184)     <td>&nbsp;</td>
185)     <td><input type="checkbox" id="enabled" name="enabled" value="true"'.$enabled.' /></td>
186)     <td>&nbsp;</td></tr>
187)   </table>
188)   <p><input type="submit" value="&Auml;nderungen speichern" /><br />
189)   Hinweis: Das Passwort wird nur ge&auml;ndert, wenn Sie auf dieser Seite eines eingeben. Geben Sie keines an, wird das bisherige beibehalten!</p>
190)   </form>
191)   ');
192) 
193) }
194) else
195) {
196)   output('<h3>E-Mail-Accounts</h3>
197) <p>Folgende POP3/IMAP-Konten sind eingerichtet:</p>
198) <table style="margin-bottom: 1em;">
199) <tr><th>Benutzername:</th><th>Mailbox-Pfad:</th><th>aktiv</th><th>&nbsp;</th></tr>
200) ');
201) 
202)         foreach (mailaccounts($user['uid']) as $account)
203)         {
204)                 $mailbox = $account['mailbox'];
205)                 if (empty($mailbox))
206)                         $mailbox = '<i>nicht festgelegt</i>';
207)                 output('<tr>
208)             <td>'.$account['account'].'</td>
209)             <td>'.$mailbox.'</td>
210)             <td><b>'.($account['enabled'] ? 'Ja' : 'Nein').'</b></td>
bernd XML-Fehler

bernd authored 16 years ago

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