dfd9e7d37ccab790cc6a30f7e91c72c7a1137336
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>
bernd XML-Fehler

bernd authored 16 years ago

141)     </tr>
bernd webinterface => /webinterface

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

173)       else
bernd Domain-Klasse benutzen

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

212)             <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></tr>');