74a5d99205ca17ae3903126bc7d7f2b15ac7bcb3
bernd webinterface => /webinterface

bernd authored 17 years ago

1) <?php
2) 
3) require_once('session/start.php');
4) 
5) require_once('domains.php');
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)     ');
88)     require_once('domains.php');
89)     $domains = get_domain_names($user['customerno'], $user['uid']);
90)     if (count($domains) > 0)
91)       output('<option>----------------------------</option>');
92)     foreach ($domains as $dom)
93)       output('<option value="'.$dom['domainname'].'">'.$dom['domainname'].'</option>');
94)     output('</select></td>
95) 
96)   </tr>
97)   <tr>
98)     <td>Mailbox:</td>
99)     <td><input type="text" id="mailbox" name="mailbox" value="'.$user['homedir'].'/" /></td>
100)   </tr>
101)   <tr>
102)     <td>Passwort:</td>
103)     <td><input type="password" id="password" name="password" value="" /></td>
104)   </tr>
105)   <tr>
106)     <td>Account sofort aktivieren:</td>
107)     <td><input type="checkbox" id="enabled" name="enabled" value="true" /></td>
108)   </tr>
109)   </table>
110)   <p><input type="submit" name="create" value="Anlegen" /><br />
111)   </form>
112)   ');
113) }
114) elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '')
115) {
116)   if ($_POST['confirm'] == 'yes')
117)   {
bernd XSRF-kram fixed

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

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

bernd authored 17 years ago

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

bernd authored 16 years ago

161)   '.generate_form_token('imap_accounts_edit').'