commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
/* |
a6f90e
|
3 |
+-------------------------------------------------------------------------+ |
A |
4 |
| RoundCube Webmail IMAP Client | |
|
5 |
| Version 0.1-20080506 | |
|
6 |
| | |
|
7 |
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | |
|
8 |
| | |
|
9 |
| This program is free software; you can redistribute it and/or modify | |
|
10 |
| it under the terms of the GNU General Public License version 2 | |
|
11 |
| as published by the Free Software Foundation. | |
|
12 |
| | |
|
13 |
| This program is distributed in the hope that it will be useful, | |
|
14 |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
15 |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
16 |
| GNU General Public License for more details. | |
|
17 |
| | |
|
18 |
| You should have received a copy of the GNU General Public License along | |
|
19 |
| with this program; if not, write to the Free Software Foundation, Inc., | |
|
20 |
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
|
21 |
| | |
|
22 |
+-------------------------------------------------------------------------+ |
|
23 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
24 |
+-------------------------------------------------------------------------+ |
4e17e6
|
25 |
|
T |
26 |
$Id$ |
|
27 |
|
|
28 |
*/ |
15a9d1
|
29 |
|
47124c
|
30 |
// include environment |
T |
31 |
require_once 'program/include/iniset.php'; |
15a9d1
|
32 |
|
4e17e6
|
33 |
// define global vars |
T |
34 |
$OUTPUT_TYPE = 'html'; |
2f2f15
|
35 |
|
T |
36 |
// set output buffering |
197601
|
37 |
if ($RCMAIL->action != 'get' && $RCMAIL->action != 'viewsource') { |
2f2f15
|
38 |
// use gzip compression if supported |
03fcc1
|
39 |
if (function_exists('ob_gzhandler') |
47124c
|
40 |
&& !ini_get('zlib.output_compression') |
T |
41 |
&& ini_get('output_handler') != 'ob_gzhandler') { |
2f2f15
|
42 |
ob_start('ob_gzhandler'); |
03fcc1
|
43 |
} |
47124c
|
44 |
else { |
2f2f15
|
45 |
ob_start(); |
47124c
|
46 |
} |
f11541
|
47 |
} |
2f2f15
|
48 |
|
42b113
|
49 |
|
197601
|
50 |
// init application and start session with requested task |
T |
51 |
$RCMAIL = rcmail::get_instance(); |
4e17e6
|
52 |
|
47124c
|
53 |
// init output class |
197601
|
54 |
$OUTPUT = (!empty($_GET['_remote']) || !empty($_POST['_remote'])) ? $RCMAIL->init_json() : $RCMAIL->load_gui((!empty($_GET['_framed']) || !empty($_POST['_framed']))); |
4e17e6
|
55 |
|
8affba
|
56 |
|
T |
57 |
// check DB connections and exit on failure |
47124c
|
58 |
if ($err_str = $DB->is_error()) { |
f11541
|
59 |
raise_error(array( |
T |
60 |
'code' => 603, |
|
61 |
'type' => 'db', |
|
62 |
'message' => $err_str), FALSE, TRUE); |
|
63 |
} |
8affba
|
64 |
|
T |
65 |
|
4e17e6
|
66 |
// error steps |
197601
|
67 |
if ($RCMAIL->action=='error' && !empty($_GET['_code'])) { |
4e17e6
|
68 |
raise_error(array('code' => hexdec($_GET['_code'])), FALSE, TRUE); |
47124c
|
69 |
} |
570f0b
|
70 |
|
4e17e6
|
71 |
// try to log in |
197601
|
72 |
if ($RCMAIL->action=='login' && $RCMAIL->task=='mail') { |
1854c4
|
73 |
$host = $RCMAIL->autoselect_host(); |
4e17e6
|
74 |
|
T |
75 |
// check if client supports cookies |
47124c
|
76 |
if (empty($_COOKIE)) { |
f11541
|
77 |
$OUTPUT->show_message("cookiesdisabled", 'warning'); |
T |
78 |
} |
f15c26
|
79 |
else if ($_SESSION['temp'] && !empty($_POST['_user']) && isset($_POST['_pass']) && |
197601
|
80 |
$RCMAIL->login(trim(get_input_value('_user', RCUBE_INPUT_POST), ' '), |
47124c
|
81 |
get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1'), $host)) { |
aad6e2
|
82 |
// create new session ID |
T |
83 |
unset($_SESSION['temp']); |
|
84 |
sess_regenerate_id(); |
|
85 |
|
|
86 |
// send auth cookie if necessary |
1854c4
|
87 |
$RCMAIL->authenticate_session(); |
aad6e2
|
88 |
|
4e17e6
|
89 |
// send redirect |
197601
|
90 |
header("Location: {$RCMAIL->comm_path}"); |
4e17e6
|
91 |
exit; |
T |
92 |
} |
47124c
|
93 |
else { |
fc6725
|
94 |
$OUTPUT->show_message($IMAP->error_code == -1 ? 'imaperror' : 'loginfailed', 'warning'); |
1854c4
|
95 |
$RCMAIL->kill_session(); |
f11541
|
96 |
} |
T |
97 |
} |
4e17e6
|
98 |
|
T |
99 |
// end session |
197601
|
100 |
else if (($RCMAIL->task=='logout' || $RCMAIL->action=='logout') && isset($_SESSION['user_id'])) { |
f11541
|
101 |
$OUTPUT->show_message('loggedout'); |
1854c4
|
102 |
$RCMAIL->logout_actions(); |
T |
103 |
$RCMAIL->kill_session(); |
f11541
|
104 |
} |
4e17e6
|
105 |
|
bac7d1
|
106 |
// check session and auth cookie |
197601
|
107 |
else if ($RCMAIL->action != 'login' && $_SESSION['user_id'] && $RCMAIL->action != 'send') { |
1854c4
|
108 |
if (!$RCMAIL->authenticate_session()) { |
f11541
|
109 |
$OUTPUT->show_message('sessionerror', 'error'); |
1854c4
|
110 |
$RCMAIL->kill_session(); |
4e17e6
|
111 |
} |
f11541
|
112 |
} |
4e17e6
|
113 |
|
T |
114 |
|
|
115 |
// log in to imap server |
197601
|
116 |
if (!empty($RCMAIL->user->ID) && $RCMAIL->task == 'mail') { |
1854c4
|
117 |
if (!$RCMAIL->imap_connect()) { |
T |
118 |
$RCMAIL->kill_session(); |
47124c
|
119 |
} |
f11541
|
120 |
} |
4e17e6
|
121 |
|
T |
122 |
|
|
123 |
// not logged in -> set task to 'login |
197601
|
124 |
if (empty($RCMAIL->user->ID)) { |
f11541
|
125 |
if ($OUTPUT->ajax_call) |
T |
126 |
$OUTPUT->remote_response("setTimeout(\"location.href='\"+this.env.comm_path+\"'\", 2000);"); |
42b113
|
127 |
|
1854c4
|
128 |
$RCMAIL->set_task('login'); |
f11541
|
129 |
} |
4e17e6
|
130 |
|
T |
131 |
|
719a25
|
132 |
// check client X-header to verify request origin |
47124c
|
133 |
if ($OUTPUT->ajax_call) { |
T |
134 |
if (empty($CONFIG['devel_mode']) && !rc_request_header('X-RoundCube-Referer')) { |
719a25
|
135 |
header('HTTP/1.1 404 Not Found'); |
T |
136 |
die("Invalid Request"); |
|
137 |
} |
|
138 |
} |
|
139 |
|
4e17e6
|
140 |
|
T |
141 |
// not logged in -> show login page |
197601
|
142 |
if (empty($RCMAIL->user->ID)) { |
330127
|
143 |
// check if installer is still active |
47124c
|
144 |
if ($CONFIG['enable_installer'] && is_readable('./installer/index.php')) { |
T |
145 |
$OUTPUT->add_footer(html::div(array('style' => "background:#ef9398; border:2px solid #dc5757; padding:0.5em; margin:2em auto; width:50em"), |
|
146 |
html::tag('h2', array('style' => "margin-top:0.2em"), "Installer script is still accessible") . |
|
147 |
html::p(null, "The install script of your RoundCube installation is still stored in its default location!") . |
|
148 |
html::p(null, "Please <b>remove</b> the whole <tt>installer</tt> folder from the RoundCube directory because . |
|
149 |
these files may expose sensitive configuration data like server passwords and encryption keys |
|
150 |
to the public. Make sure you cannot access the <a href=\"./installer/\">installer script</a> from your browser.") |
|
151 |
) |
|
152 |
); |
|
153 |
} |
330127
|
154 |
|
bbf15d
|
155 |
$OUTPUT->set_env('task', 'login'); |
f11541
|
156 |
$OUTPUT->task = 'login'; |
T |
157 |
$OUTPUT->send('login'); |
4e17e6
|
158 |
exit; |
f11541
|
159 |
} |
4e17e6
|
160 |
|
T |
161 |
|
1cded8
|
162 |
// handle keep-alive signal |
197601
|
163 |
if ($RCMAIL->action=='keep-alive') { |
f11541
|
164 |
$OUTPUT->reset(); |
T |
165 |
$OUTPUT->send(''); |
1cded8
|
166 |
exit; |
f11541
|
167 |
} |
4e17e6
|
168 |
|
T |
169 |
// include task specific files |
197601
|
170 |
if ($RCMAIL->task=='mail') { |
4e17e6
|
171 |
include_once('program/steps/mail/func.inc'); |
88375f
|
172 |
|
197601
|
173 |
if ($RCMAIL->action=='show' || $RCMAIL->action=='preview' || $RCMAIL->action=='print') |
4e17e6
|
174 |
include('program/steps/mail/show.inc'); |
T |
175 |
|
197601
|
176 |
if ($RCMAIL->action=='get') |
4e17e6
|
177 |
include('program/steps/mail/get.inc'); |
T |
178 |
|
197601
|
179 |
if ($RCMAIL->action=='moveto' || $RCMAIL->action=='delete') |
4e17e6
|
180 |
include('program/steps/mail/move_del.inc'); |
T |
181 |
|
197601
|
182 |
if ($RCMAIL->action=='mark') |
4e17e6
|
183 |
include('program/steps/mail/mark.inc'); |
T |
184 |
|
197601
|
185 |
if ($RCMAIL->action=='viewsource') |
4e17e6
|
186 |
include('program/steps/mail/viewsource.inc'); |
T |
187 |
|
197601
|
188 |
if ($RCMAIL->action=='sendmdn') |
fba1f5
|
189 |
include('program/steps/mail/sendmdn.inc'); |
T |
190 |
|
197601
|
191 |
if ($RCMAIL->action=='send') |
4e17e6
|
192 |
include('program/steps/mail/sendmail.inc'); |
T |
193 |
|
197601
|
194 |
if ($RCMAIL->action=='upload') |
4e17e6
|
195 |
include('program/steps/mail/upload.inc'); |
T |
196 |
|
197601
|
197 |
if ($RCMAIL->action=='compose' || $RCMAIL->action=='remove-attachment' || $RCMAIL->action=='display-attachment') |
4e17e6
|
198 |
include('program/steps/mail/compose.inc'); |
T |
199 |
|
197601
|
200 |
if ($RCMAIL->action=='addcontact') |
4e17e6
|
201 |
include('program/steps/mail/addcontact.inc'); |
15a9d1
|
202 |
|
197601
|
203 |
if ($RCMAIL->action=='expunge' || $RCMAIL->action=='purge') |
15a9d1
|
204 |
include('program/steps/mail/folders.inc'); |
T |
205 |
|
197601
|
206 |
if ($RCMAIL->action=='check-recent') |
15a9d1
|
207 |
include('program/steps/mail/check_recent.inc'); |
T |
208 |
|
197601
|
209 |
if ($RCMAIL->action=='getunread') |
15a9d1
|
210 |
include('program/steps/mail/getunread.inc'); |
4e17e6
|
211 |
|
197601
|
212 |
if ($RCMAIL->action=='list' && isset($_REQUEST['_remote'])) |
4e17e6
|
213 |
include('program/steps/mail/list.inc'); |
T |
214 |
|
197601
|
215 |
if ($RCMAIL->action=='search') |
dd53e2
|
216 |
include('program/steps/mail/search.inc'); |
T |
217 |
|
197601
|
218 |
if ($RCMAIL->action=='spell') |
dd53e2
|
219 |
include('program/steps/mail/spell.inc'); |
4647e1
|
220 |
|
197601
|
221 |
if ($RCMAIL->action=='rss') |
88375f
|
222 |
include('program/steps/mail/rss.inc'); |
3ea0e3
|
223 |
|
01c86f
|
224 |
// make sure the message count is refreshed |
47124c
|
225 |
$IMAP->messagecount($_SESSION['mbox'], 'ALL', true); |
f11541
|
226 |
} |
4e17e6
|
227 |
|
T |
228 |
|
|
229 |
// include task specific files |
197601
|
230 |
if ($RCMAIL->task=='addressbook') { |
4e17e6
|
231 |
include_once('program/steps/addressbook/func.inc'); |
T |
232 |
|
197601
|
233 |
if ($RCMAIL->action=='save') |
4e17e6
|
234 |
include('program/steps/addressbook/save.inc'); |
T |
235 |
|
197601
|
236 |
if ($RCMAIL->action=='edit' || $RCMAIL->action=='add') |
4e17e6
|
237 |
include('program/steps/addressbook/edit.inc'); |
T |
238 |
|
197601
|
239 |
if ($RCMAIL->action=='delete') |
4e17e6
|
240 |
include('program/steps/addressbook/delete.inc'); |
T |
241 |
|
197601
|
242 |
if ($RCMAIL->action=='show') |
4e17e6
|
243 |
include('program/steps/addressbook/show.inc'); |
T |
244 |
|
197601
|
245 |
if ($RCMAIL->action=='list' && $_REQUEST['_remote']) |
4e17e6
|
246 |
include('program/steps/addressbook/list.inc'); |
d1d2c4
|
247 |
|
197601
|
248 |
if ($RCMAIL->action=='search') |
f11541
|
249 |
include('program/steps/addressbook/search.inc'); |
T |
250 |
|
197601
|
251 |
if ($RCMAIL->action=='copy') |
f11541
|
252 |
include('program/steps/addressbook/copy.inc'); |
T |
253 |
|
197601
|
254 |
if ($RCMAIL->action=='mailto') |
f11541
|
255 |
include('program/steps/addressbook/mailto.inc'); |
T |
256 |
} |
4e17e6
|
257 |
|
T |
258 |
|
|
259 |
// include task specific files |
197601
|
260 |
if ($RCMAIL->task=='settings') { |
4e17e6
|
261 |
include_once('program/steps/settings/func.inc'); |
T |
262 |
|
197601
|
263 |
if ($RCMAIL->action=='save-identity') |
4e17e6
|
264 |
include('program/steps/settings/save_identity.inc'); |
T |
265 |
|
197601
|
266 |
if ($RCMAIL->action=='add-identity' || $RCMAIL->action=='edit-identity') |
4e17e6
|
267 |
include('program/steps/settings/edit_identity.inc'); |
T |
268 |
|
197601
|
269 |
if ($RCMAIL->action=='delete-identity') |
4e17e6
|
270 |
include('program/steps/settings/delete_identity.inc'); |
T |
271 |
|
197601
|
272 |
if ($RCMAIL->action=='identities') |
4e17e6
|
273 |
include('program/steps/settings/identities.inc'); |
T |
274 |
|
197601
|
275 |
if ($RCMAIL->action=='save-prefs') |
4e17e6
|
276 |
include('program/steps/settings/save_prefs.inc'); |
T |
277 |
|
197601
|
278 |
if ($RCMAIL->action=='folders' || $RCMAIL->action=='subscribe' || $RCMAIL->action=='unsubscribe' || |
T |
279 |
$RCMAIL->action=='create-folder' || $RCMAIL->action=='rename-folder' || $RCMAIL->action=='delete-folder') |
4e17e6
|
280 |
include('program/steps/settings/manage_folders.inc'); |
f11541
|
281 |
} |
ecf759
|
282 |
|
T |
283 |
|
539cd4
|
284 |
// parse main template |
197601
|
285 |
$OUTPUT->send($RCMAIL->task); |
539cd4
|
286 |
|
T |
287 |
|
|
288 |
// if we arrive here, something went wrong |
f11541
|
289 |
raise_error(array( |
T |
290 |
'code' => 404, |
|
291 |
'type' => 'php', |
|
292 |
'line' => __LINE__, |
|
293 |
'file' => __FILE__, |
47124c
|
294 |
'message' => "Invalid request"), true, true); |
539cd4
|
295 |
|
d1d2c4
|
296 |
?> |