Thomas Bruederli
2013-04-15 a7db8f93ef4824ead7b646fa8543940c4adf5d55
commit | author | age
47124c 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
197601 5  | program/include/iniset.php                                            |
47124c 6  |                                                                       |
e019f2 7  | This file is part of the Roundcube Webmail client                     |
2c6aea 8  | Copyright (C) 2008-2013, The Roundcube Dev Team                       |
7fe381 9  |                                                                       |
T 10  | Licensed under the GNU General Public License version 3 or            |
11  | any later version with exceptions for skins & plugins.                |
12  | See the README file for a full license statement.                     |
47124c 13  |                                                                       |
T 14  | PURPOSE:                                                              |
f707fe 15  |   Setup the application environment required to process               |
47124c 16  |   any request.                                                        |
T 17  +-----------------------------------------------------------------------+
18  | Author: Till Klampaeckel <till@php.net>                               |
19  |         Thomas Bruederli <roundcube@gmail.com>                        |
20  +-----------------------------------------------------------------------+
21 */
22
fdbe5a 23 // application constants
a7db8f 24 define('RCMAIL_VERSION', '0.9.0');
fdbe5a 25 define('RCMAIL_START', microtime(true));
TB 26
0b6d02 27 $config = array(
AM 28     // Some users are not using Installer, so we'll check some
29     // critical PHP settings here. Only these, which doesn't provide
30     // an error/warning in the logs later. See (#1486307).
cd96fd 31     'suhosin.session.encrypt' => 0,
0b6d02 32     'session.auto_start'      => 0,
AM 33     'file_uploads'            => 1,
cd96fd 34 );
0b6d02 35 foreach ($config as $optname => $optval) {
AM 36     if ($optval != ini_get($optname) && @ini_set($optname, $optval) === false) {
5261ce 37         die("ERROR: Wrong '$optname' option value and it wasn't possible to set it to required value ($optval).\n"
f707fe 38             ."Check your PHP configuration (including php_admin_flag).");
cd96fd 39     }
A 40 }
47124c 41
T 42 if (!defined('INSTALL_PATH')) {
2eb794 43     define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
47124c 44 }
T 45
4859fe 46 if (!defined('RCMAIL_CONFIG_DIR')) {
T 47     define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
47124c 48 }
T 49
9be2f4 50 if (!defined('RCUBE_LOCALIZATION_DIR')) {
TB 51     define('RCUBE_LOCALIZATION_DIR', INSTALL_PATH . 'program/localization/');
52 }
53
54 define('RCUBE_INSTALL_PATH', INSTALL_PATH);
592668 55 define('RCUBE_CONFIG_DIR',  RCMAIL_CONFIG_DIR.'/');
9be2f4 56
TB 57
47124c 58 // RC include folders MUST be included FIRST to avoid other
T 59 // possible not compatible libraries (i.e PEAR) to be included
60 // instead the ones provided by RC
926948 61 $include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
47124c 62 $include_path.= ini_get('include_path');
T 63
64 if (set_include_path($include_path) === false) {
e93c72 65     die("Fatal error: ini_set/set_include_path does not work.");
47124c 66 }
T 67
68 // increase maximum execution time for php scripts
69 // (does not work in safe mode)
6d479a 70 @set_time_limit(120);
47124c 71
f707fe 72 // include Roundcube Framework
ba6f21 73 require_once 'Roundcube/bootstrap.php';
AM 74
60226a 75 // register autoloader for rcmail app classes
TB 76 spl_autoload_register('rcmail_autoload');
47124c 77
0c2596 78 // backward compatybility (to be removed)
15cf4f 79 require_once INSTALL_PATH . 'program/include/bc.php';
60226a 80
TB 81
82 /**
83  * PHP5 autoloader routine for dynamic class loading
84  */
85 function rcmail_autoload($classname)
86 {
87     if (strpos($classname, 'rcmail') === 0) {
88         $filepath = INSTALL_PATH . "program/include/$classname.php";
89         if (is_readable($filepath)) {
90             include_once $filepath;
91             return true;
92         }
93     }
94
95     return false;
96 }
97