c0d71b322d25d96ffd425f30120f12c4371406b0
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) DEBUG("GET: ".htmlentities(print_r($_GET, true))." / POST: ".htmlentities(print_r($_POST, true)));
20) if (isset($_GET['action']) && $_GET['action'] == 'save')
21) {
22)   if (isset($_GET['id']))
23)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

52)     $account = $_POST['user'].'@'.$_POST['domain'];
53)     if (isset($_POST['enabled']) && $_POST['enabled'] == 'true')
54)       $enabled = 'Y';
55)     else
56)       $enabled = 'N';
57)     $acc = array('account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
58)     if ($_POST['password'] != '')
59)       $acc['password'] = $_POST['password'];
60)     $error = check_valid($acc);
61)     if ($error != "")
62)     {
63)       input_error($error);
64)       output("");
65)     }
66)     else
67)     {
68)       create_mailaccount($acc);
69)       if (! $debugmode)
70)         header('Location: accounts.php');
71)       die(); 
72)     }
73)   }
74) }
75) elseif (isset($_GET['action']) && $_GET['action'] == 'create')
76) {
77)   output('<h3>E-Mail-Account anlegen</h3>
78) <p>Hier k&ouml;nnen Sie ein neues POP3/IMAP-Konto anlegen.</p>
79)   <form action="accounts.php?action=save&'.$param.'" method="post">
bernd XSRF-kram fixed

bernd authored 16 years ago

80)   '.generate_form_token('imap_accounts_create').'
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>
87)     ');
bernd Domain-Klasse benutzen

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

93)     output('</select></td>
94) 
95)   </tr>
96)   <tr>
97)     <td>Mailbox:</td>
98)     <td><input type="text" id="mailbox" name="mailbox" value="'.$user['homedir'].'/" /></td>
99)   </tr>
100)   <tr>
101)     <td>Passwort:</td>
102)     <td><input type="password" id="password" name="password" value="" /></td>
103)   </tr>
104)   <tr>
105)     <td>Account sofort aktivieren:</td>
106)     <td><input type="checkbox" id="enabled" name="enabled" value="true" /></td>
107)   </tr>
108)   </table>
109)   <p><input type="submit" name="create" value="Anlegen" /><br />
110)   </form>
111)   ');
112) }
113) elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '')
114) {
115)   if ($_POST['confirm'] == 'yes')
116)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

133)     <table style="margin-bottom: 1em;">
134)     <tr><td>Benutzername:</td>
135)       <td>'.$account['account'].'</td>
136)     </tr>
137)     <tr><td>Mailbox:</td>
138)       <td>'.$account['mailbox'].'</td>
139)     </tr>
140)     <tr><td>Konto aktiv:</td>
141)       <td>'.$enabled.'</td>
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>');