Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 174 lines (156 sloc) 8.363 kb
20991ab @eldy Fix: Another try to make usage of alt feature working.
eldy authored
1 <?PHP
2 /* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
4 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7 * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
8 * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
9 * Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
10 * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27 /**
28 * \file htdocs/filefunc.inc.php
29 * \ingroup core
30 * \brief File that include conf.php file and functions.lib.php
31 * \version $Id$
32 */
33
34 define('DOL_VERSION','3.0.0-alpha'); // Also defined in htdocs/install/inc.php (Ex: x.y.z-alpha, x.y.z)
35 define('EURO',chr(128));
36
37 // Definition des constantes syslog
38 if (function_exists("define_syslog_variables"))
39 {
40 if (version_compare(PHP_VERSION, '5.3.0', '<'))
41 {
42 define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
43 }
44 }
45 else
46 {
47 // Pour PHP sans syslog (comme sous Windows)
48 define('LOG_EMERG',0);
49 define('LOG_ALERT',1);
50 define('LOG_CRIT',2);
51 define('LOG_ERR',3);
52 define('LOG_WARNING',4);
53 define('LOG_NOTICE',5);
54 define('LOG_INFO',6);
55 define('LOG_DEBUG',7);
56 }
57
58
59 // Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)
60 error_reporting(E_ALL ^ E_NOTICE);
61 //error_reporting(E_ALL);
62
63
64 // Include configuration
65 $result=@include_once("conf/conf.php");
66 if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session
67 {
68 header("Location: install/index.php");
69 exit;
70 }
71
72 if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port=0; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql'
73 if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql'
74 if (empty($dolibarr_main_db_prefix)) $dolibarr_main_db_prefix='llx_';
75 if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set='latin1'; // Old installation
76 if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation='latin1_swedish_ci'; // Old installation
77 if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
78 if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
79 if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users=0;
80 if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb=0;
81 if (empty($force_charset_do_notuse)) $force_charset_do_notuse='UTF-8';
82
83 // Security: CSRF protection
84 // This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST'])
85 // when we post forms (we allow GET to allow direct link to access a particular page).
86 if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET' && ! empty($_SERVER['HTTP_HOST']) && ! empty($_SERVER['HTTP_REFERER']) && ! preg_match('/'.preg_quote($_SERVER['HTTP_HOST'],'/').'/i', $_SERVER['HTTP_REFERER']))
87 {
88 //print 'HTTP_POST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
89 print "Access refused by CSRF protection in main.inc.php.\n";
90 print "If you access your server behind a proxy using url rewriting, you might add the line \$dolibarr_nocsrfcheck=1 into your conf.php file.\n";
91 die;
92 }
93 if (empty($dolibarr_main_db_host))
94 {
95 print 'Dolibarr setup was run but was not completed.<br>'."\n";
96 print 'Please, click <a href="install/index.php">here to finish Dolibarr install process</a> ...'."\n";
97 die;
98 }
99 if (empty($dolibarr_main_url_root))
100 {
101 print 'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'."\n";
102 print 'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'."\n";
103 die;
104 }
105 if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql'
106 if (empty($dolibarr_main_data_root))
107 {
108 // Si repertoire documents non defini, on utilise celui par defaut
109 $dolibarr_main_data_root=str_replace("/htdocs","",$dolibarr_main_document_root);
110 $dolibarr_main_data_root.="/documents";
111 }
112
113 // Define some constants
b934bee @eldy Fix: Definition of alt url should use same syntax than main url (so f…
eldy authored
114 define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir (defined only for some code that want to be compatible with old versions without this parameter)
20991ab @eldy Fix: Another try to make usage of alt feature working.
eldy authored
115 define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem data (documents)
116 define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem core php (htdocs)
b934bee @eldy Fix: Definition of alt url should use same syntax than main url (so f…
eldy authored
117 if (! empty($dolibarr_main_document_root_alt))
118 {
119 define('DOL_DOCUMENT_ROOT_ALT', $dolibarr_main_document_root_alt); // Filesystem paths to alternate core php (alternate htdocs)
120 }
20991ab @eldy Fix: Another try to make usage of alt feature working.
eldy authored
121 // If dolibarr_main_url_root = auto (Hidden feature for developers only), we try to forge it.
122 if ($dolibarr_main_url_root == 'auto' && ! empty($_SERVER["SCRIPT_URL"]) && ! empty($_SERVER["SCRIPT_URI"]))
123 {
124 $dolibarr_main_url_root=str_replace($_SERVER["SCRIPT_URL"],'',$_SERVER["SCRIPT_URI"]);
125 }
b934bee @eldy Fix: Definition of alt url should use same syntax than main url (so f…
eldy authored
126 define('DOL_MAIN_URL_ROOT', $dolibarr_main_url_root); // URL absolute root
20991ab @eldy Fix: Another try to make usage of alt feature working.
eldy authored
127 $uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
128 $suburi = strstr($uri, '/'); // $suburi contains url without domain
129 if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
130 define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
b934bee @eldy Fix: Definition of alt url should use same syntax than main url (so f…
eldy authored
131 if (! empty($dolibarr_main_url_root_alt))
132 {
133 define('DOL_MAIN_URL_ROOT_ALT', $dolibarr_main_url_root_alt); // URL absolute root
134 $uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT_ALT')); // $uri contains url without http*
135 $suburi = strstr($uri, '/'); // $suburi contains url without domain
136 if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
137 define('DOL_URL_ROOT_ALT', $suburi); // URL relative root ('', '/dolibarr', ...)
138 }
139 if (! empty($dolibarr_main_url_root_static)) define('DOL_URL_ROOT_FULL_STATIC', $dolibarr_main_url_root_static); // Used to put static images on another domain
20991ab @eldy Fix: Another try to make usage of alt feature working.
eldy authored
140 // Define prefix
141 if (isset($_SERVER["LLX_DBNAME"])) $dolibarr_main_db_prefix=$_SERVER["LLX_DBNAME"];
142 define('MAIN_DB_PREFIX',$dolibarr_main_db_prefix);
143
144
145 /*
146 * Include functions
147 */
148
149 if (! file_exists(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"))
150 {
151 print "Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
152 print "Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
153 exit;
154 }
155
156 include_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); // Need 970ko memory (1.1 in 2.2)
157
158
159 // If password is encoded, we decode it
160 if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
161 {
162 require_once(DOL_DOCUMENT_ROOT ."/lib/security.lib.php");
163 if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
164 {
165 $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
166 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
167 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
168 }
169 else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
170 }
171 //print memory_get_usage();
172
173 ?>
Something went wrong with that request. Please try again.