source: subversion/branches/release-0.6/program/include/iniset.php @ 5235

Last change on this file since 5235 was 5235, checked in by alec, 21 months ago
  • Applied fixes from trunk up to r5232
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/include/iniset.php                                            |
6 |                                                                       |
7 | This file is part of the Roundcube Webmail client                     |
8 | Copyright (C) 2008-2011, The Roundcube Dev Team                       |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Setup the application envoronment required to process               |
13 |   any request.                                                        |
14 +-----------------------------------------------------------------------+
15 | Author: Till Klampaeckel <till@php.net>                               |
16 |         Thomas Bruederli <roundcube@gmail.com>                        |
17 +-----------------------------------------------------------------------+
18
19 $Id$
20
21*/
22
23// Some users are not using Installer, so we'll check some
24// critical PHP settings here. Only these, which doesn't provide
25// an error/warning in the logs later. See (#1486307).
26$crit_opts = array(
27    'mbstring.func_overload' => 0,
28    'suhosin.session.encrypt' => 0,
29    'session.auto_start' => 0,
30    'file_uploads' => 1,
31    'magic_quotes_runtime' => 0,
32);
33foreach ($crit_opts as $optname => $optval) {
34    if ($optval != ini_get($optname)) {
35        die("ERROR: Wrong '$optname' option value. Read REQUIREMENTS section in INSTALL file or use Roundcube Installer, please!");
36    }
37}
38
39// application constants
40define('RCMAIL_VERSION', '0.6-beta');
41define('RCMAIL_CHARSET', 'UTF-8');
42define('JS_OBJECT_NAME', 'rcmail');
43define('RCMAIL_START', microtime(true));
44
45if (!defined('INSTALL_PATH')) {
46    define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
47}
48
49if (!defined('RCMAIL_CONFIG_DIR')) {
50    define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
51}
52
53// make sure path_separator is defined
54if (!defined('PATH_SEPARATOR')) {
55    define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');
56}
57
58// RC include folders MUST be included FIRST to avoid other
59// possible not compatible libraries (i.e PEAR) to be included
60// instead the ones provided by RC
61$include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
62$include_path.= ini_get('include_path');
63
64if (set_include_path($include_path) === false) {
65    die("Fatal error: ini_set/set_include_path does not work.");
66}
67
68ini_set('error_reporting', E_ALL&~E_NOTICE);
69
70// increase maximum execution time for php scripts
71// (does not work in safe mode)
72@set_time_limit(120);
73
74// set internal encoding for mbstring extension
75if (extension_loaded('mbstring')) {
76    mb_internal_encoding(RCMAIL_CHARSET);
77    @mb_regex_encoding(RCMAIL_CHARSET);
78}
79
80/**
81 * Use PHP5 autoload for dynamic class loading
82 *
83 * @todo Make Zend, PEAR etc play with this
84 * @todo Make our classes conform to a more straight forward CS.
85 */
86function rcube_autoload($classname)
87{
88    $filename = preg_replace(
89        array(
90            '/MDB2_(.+)/',
91            '/Mail_(.+)/',
92            '/Net_(.+)/',
93            '/Auth_(.+)/',
94            '/^html_.+/',
95            '/^utf8$/',
96        ),
97        array(
98            'MDB2/\\1',
99            'Mail/\\1',
100            'Net/\\1',
101            'Auth/\\1',
102            'html',
103            'utf8.class',
104        ),
105        $classname
106    );
107
108    if ($fp = @fopen("$filename.php", 'r', true)) {
109        fclose($fp);
110        include_once("$filename.php");
111        return true;
112    }
113
114    return false;
115}
116
117spl_autoload_register('rcube_autoload');
118
119/**
120 * Local callback function for PEAR errors
121 */
122function rcube_pear_error($err)
123{
124    error_log(sprintf("%s (%s): %s",
125        $err->getMessage(),
126        $err->getCode(),
127        $err->getUserinfo()), 0);
128}
129
130// set PEAR error handling (will also load the PEAR main class)
131PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');
132
133// include global functions
134require_once INSTALL_PATH . 'program/include/main.inc';
135require_once INSTALL_PATH . 'program/include/rcube_shared.inc';
Note: See TracBrowser for help on using the repository browser.