source: github/index.php @ e0ed972

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since e0ed972 was f3b6599, checked in by thomascube <thomas@…>, 8 years ago

Added patches for default language and sorting function

  • Property mode set to 100644
File size: 9.3 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | RoundCube Webmail IMAP Client                                         |
6 | Version 0.1-20051018                                                  |
7 |                                                                       |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | Redistribution and use in source and binary forms, with or without    |
12 | modification, are permitted provided that the following conditions    |
13 | are met:                                                              |
14 |                                                                       |
15 | o Redistributions of source code must retain the above copyright      |
16 |   notice, this list of conditions and the following disclaimer.       |
17 | o Redistributions in binary form must reproduce the above copyright   |
18 |   notice, this list of conditions and the following disclaimer in the |
19 |   documentation and/or other materials provided with the distribution.|
20 | o The names of the authors may not be used to endorse or promote      |
21 |   products derived from this software without specific prior written  |
22 |   permission.                                                         |
23 |                                                                       |
24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
25 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
26 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
27 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
28 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
29 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
30 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
31 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
32 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
35 |                                                                       |
36 +-----------------------------------------------------------------------+
37 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
38 +-----------------------------------------------------------------------+
39
40 $Id$
41
42*/
43
44// define global vars
45$INSTALL_PATH = './';
46$OUTPUT_TYPE = 'html';
47$JS_OBJECT_NAME = 'rcmail';
48$CURRENT_PATH = dirname($_SERVER['SCRIPT_FILENAME']);
49
50if ($CURRENT_PATH!='')
51        $CURRENT_PATH.='/';
52       
53// set environment first
54ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.$INSTALL_PATH.PATH_SEPARATOR.$CURRENT_PATH.'program'.PATH_SEPARATOR.$CURRENT_PATH.'program/lib');
55ini_set('session.name', 'sessid');
56ini_set('session.use_cookies', 1);
57ini_set('error_reporting', E_ALL&~E_NOTICE);
58
59
60// increase maximum execution time for php scripts
61// (does not work in safe mode)
62@set_time_limit('120');
63
64
65// include base files
66require_once('include/rcube_shared.inc');
67require_once('include/rcube_imap.inc');
68require_once('include/bugs.inc');
69require_once('include/main.inc');
70require_once('include/cache.inc');
71require_once('PEAR.php');
72
73
74// set PEAR error handling
75// PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_NOTICE);
76
77
78// catch some url/post parameters
79$_auth = !empty($_POST['_auth']) ? $_POST['_auth'] : $_GET['_auth'];
80$_task = !empty($_POST['_task']) ? $_POST['_task'] : (!empty($_GET['_task']) ? $_GET['_task'] : 'mail');
81$_action = !empty($_POST['_action']) ? $_POST['_action'] : (!empty($_GET['_action']) ? $_GET['_action'] : '');
82$_framed = (!empty($_GET['_framed']) || !empty($_POST['_framed']));
83
84if (!empty($_GET['_remote']))
85  $REMOTE_REQUEST = TRUE;
86
87// start session with requested task
88rcmail_startup($_task);
89
90// set session related variables
91$COMM_PATH = sprintf('./?_auth=%s&_task=%s', $sess_auth, $_task);
92$SESS_HIDDEN_FIELD = sprintf('<input type="hidden" name="_auth" value="%s" />', $sess_auth);
93
94
95// add framed parameter
96if ($_framed)
97  {
98  $COMM_PATH .= '&_framed=1';
99  $SESS_HIDDEN_FIELD = "\n".'<input type="hidden" name="_framed" value="1" />';
100  }
101
102
103// init necessary objects for GUI
104load_gui();
105
106// error steps
107if ($_action=='error' && !empty($_GET['_code']))
108  {
109  raise_error(array('code' => hexdec($_GET['_code'])), FALSE, TRUE);
110  }
111
112
113// try to log in
114if ($_action=='login' && $_task=='mail')
115  {
116  $host = $_POST['_host'] ? $_POST['_host'] : $CONFIG['default_host'];
117 
118  // check if client supports cookies
119  if (empty($_COOKIE))
120    {
121    show_message("cookiesdisabled", 'warning');
122    }
123  else if (isset($_POST['_user']) && isset($_POST['_pass']) && rcmail_login($_POST['_user'], $_POST['_pass'], $host))
124    {
125    // send redirect
126    header("Location: $COMM_PATH");
127    exit;
128    }
129  else
130    {
131    show_message("loginfailed", 'warning');
132    $_SESSION['user_id'] = '';
133    }
134  }
135
136// end session
137else if ($_action=='logout' && isset($_SESSION['user_id']))
138  {
139  show_message('loggedout');
140  rcmail_kill_session();
141  }
142
143// check session cookie and auth string
144else if ($_action!='login' && $_auth && $sess_auth)
145  {
146  if ($_auth !== $sess_auth || $_auth != rcmail_auth_hash($_SESSION['client_id'], $_SESSION['auth_time']) ||
147      ($CONFIG['session_lifetime'] && $SESS_CHANGED + $CONFIG['session_lifetime']*60 < mktime()))
148    {
149    $message = show_message('sessionerror', 'error');
150    rcmail_kill_session();
151    }
152  }
153
154
155// log in to imap server
156if (!empty($_SESSION['user_id']) && $_task=='mail')
157  {
158  $conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']);
159  if (!$conn)
160    {
161    show_message('imaperror', 'error');
162    $_SESSION['user_id'] = '';
163    }
164  else
165    rcmail_set_imap_prop();
166  }
167
168
169// not logged in -> set task to 'login
170if (empty($_SESSION['user_id']))
171  {
172  if ($REMOTE_REQUEST)
173    {
174    $message .= "setTimeout(\"location.href='\"+this.env.comm_path+\"'\", 2000);";
175    rcube_remote_response($message);
176    }
177 
178  $_task = 'login';
179  }
180
181
182
183// set task and action to client
184$script = sprintf("%s.set_env('task', '%s');", $JS_OBJECT_NAME, $_task);
185if (!empty($_action))
186  $script .= sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action);
187
188$OUTPUT->add_script($script);
189
190
191
192// not logged in -> show login page
193if (!$_SESSION['user_id'])
194  {
195  parse_template('login');
196  exit;
197  }
198
199
200
201// include task specific files
202if ($_task=='mail')
203  {
204  include_once('program/steps/mail/func.inc');
205
206  if ($_action=='show' || $_action=='print')
207    include('program/steps/mail/show.inc');
208
209  if ($_action=='get')
210    include('program/steps/mail/get.inc');
211
212  if ($_action=='moveto' || $_action=='delete')
213    include('program/steps/mail/move_del.inc');
214
215  if ($_action=='mark')
216    include('program/steps/mail/mark.inc');
217
218  if ($_action=='viewsource')
219    include('program/steps/mail/viewsource.inc');
220
221  if ($_action=='send')
222    include('program/steps/mail/sendmail.inc');
223
224  if ($_action=='upload')
225    include('program/steps/mail/upload.inc');
226
227  if ($_action=='compose')
228    include('program/steps/mail/compose.inc');
229
230  if ($_action=='addcontact')
231    include('program/steps/mail/addcontact.inc');
232   
233  if ($_action=='list' && $_GET['_remote'])
234    include('program/steps/mail/list.inc');
235
236  // kill compose entry from session
237  if (isset($_SESSION['compose']))
238    rcmail_compose_cleanup();
239  }
240
241
242// include task specific files
243if ($_task=='addressbook')
244  {
245  include_once('program/steps/addressbook/func.inc');
246
247  if ($_action=='save')
248    include('program/steps/addressbook/save.inc');
249 
250  if ($_action=='edit' || $_action=='add')
251    include('program/steps/addressbook/edit.inc');
252 
253  if ($_action=='delete')
254    include('program/steps/addressbook/delete.inc');
255
256  if ($_action=='show')
257    include('program/steps/addressbook/show.inc'); 
258
259  if ($_action=='list' && $_GET['_remote'])
260    include('program/steps/addressbook/list.inc');
261  }
262
263
264// include task specific files
265if ($_task=='settings')
266  {
267  include_once('program/steps/settings/func.inc');
268
269  if ($_action=='save-identity')
270    include('program/steps/settings/save_identity.inc');
271
272  if ($_action=='add-identity' || $_action=='edit-identity')
273    include('program/steps/settings/edit_identity.inc');
274
275  if ($_action=='delete-identity')
276    include('program/steps/settings/delete_identity.inc');
277 
278  if ($_action=='identities')
279    include('program/steps/settings/identities.inc'); 
280
281  if ($_action=='save-prefs')
282    include('program/steps/settings/save_prefs.inc'); 
283
284  if ($_action=='folders' || $_action=='subscribe' || $_action=='unsubscribe' || $_action=='create-folder' || $_action=='delete-folder')
285    include('program/steps/settings/manage_folders.inc');
286
287  }
288
289
290// only allow these templates to be included
291$valid_tasks = array('mail','settings','addressbook');
292
293// parse main template
294if (in_array($_task, $valid_tasks))
295  parse_template($_task);
296
297
298// if we arrive here, something went wrong
299raise_error(array('code' => 404,
300                  'type' => 'php',
301                  'line' => __LINE__,
302                  'file' => __FILE__,
303                  'message' => "Invalid request"), TRUE, TRUE);
304                     
305?>
Note: See TracBrowser for help on using the repository browser.