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

Last change on this file since 5076 was 5076, checked in by thomasb, 21 months ago

Remove development stuff and update versions

  • 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);
32foreach ($crit_opts as $optname => $optval) {
33    if ($optval != ini_get($optname)) {
34        die("ERROR: Wrong '$optname' option value. Read REQUIREMENTS section in INSTALL file or use Roundcube Installer, please!");
35    }
36}
37
38// application constants
39define('RCMAIL_VERSION', '0.6-beta');
40define('RCMAIL_CHARSET', 'UTF-8');
41define('JS_OBJECT_NAME', 'rcmail');
42define('RCMAIL_START', microtime(true));
43
44if (!defined('INSTALL_PATH')) {
45    define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
46}
47
48if (!defined('RCMAIL_CONFIG_DIR')) {
49    define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
50}
51
52// make sure path_separator is defined
53if (!defined('PATH_SEPARATOR')) {
54    define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');
55}
56
57// RC include folders MUST be included FIRST to avoid other
58// possible not compatible libraries (i.e PEAR) to be included
59// instead the ones provided by RC
60$include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
61$include_path.= ini_get('include_path');
62
63if (set_include_path($include_path) === false) {
64    die("Fatal error: ini_set/set_include_path does not work.");
65}
66
67ini_set('error_reporting', E_ALL&~E_NOTICE);
68
69// increase maximum execution time for php scripts
70// (does not work in safe mode)
71@set_time_limit(120);
72
73// set internal encoding for mbstring extension
74if (extension_loaded('mbstring')) {
75    mb_internal_encoding(RCMAIL_CHARSET);
76    @mb_regex_encoding(RCMAIL_CHARSET);
77}
78
79/**
80 * Use PHP5 autoload for dynamic class loading
81 *
82 * @todo Make Zend, PEAR etc play with this
83 * @todo Make our classes conform to a more straight forward CS.
84 */
85function rcube_autoload($classname)
86{
87    $filename = preg_replace(
88        array(
89            '/MDB2_(.+)/',
90            '/Mail_(.+)/',
91            '/Net_(.+)/',
92            '/Auth_(.+)/',
93            '/^html_.+/',
94            '/^utf8$/',
95        ),
96        array(
97            'MDB2/\\1',
98            'Mail/\\1',
99            'Net/\\1',
100            'Auth/\\1',
101            'html',
102            'utf8.class',
103        ),
104        $classname
105    );
106
107    if ($fp = @fopen("$filename.php", 'r', true)) {
108        fclose($fp);
109        include_once("$filename.php");
110        return true;
111    }
112
113    return false;
114}
115
116spl_autoload_register('rcube_autoload');
117
118/**
119 * Local callback function for PEAR errors
120 */
121function rcube_pear_error($err)
122{
123    error_log(sprintf("%s (%s): %s",
124        $err->getMessage(),
125        $err->getCode(),
126        $err->getUserinfo()), 0);
127}
128
129// set PEAR error handling (will also load the PEAR main class)
130PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');
131
132// include global functions
133require_once INSTALL_PATH . 'program/include/main.inc';
134require_once INSTALL_PATH . 'program/include/rcube_shared.inc';
Note: See TracBrowser for help on using the repository browser.