-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
inc.php
250 lines (211 loc) · 9.58 KB
/
inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/support/inc.php
* \ingroup core
* \brief File that define environment for support pages
*/
// Define DOL_DOCUMENT_ROOT
if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Avoid warnings with strict mode E_STRICT
$conf = new stdClass(); // instantiate $conf explicitely
$conf->global = new stdClass();
$conf->file = new stdClass();
$conf->db = new stdClass();
$conf->syslog = new stdClass();
// Force $_REQUEST["logtohtml"]
$_REQUEST["logtohtml"]=1;
// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu.
if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
{
$_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"];
}
$includeconferror='';
// Define vars
$conffiletoshowshort = "conf.php";
// Define localization of conf file
$conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems
//$conffile = "/etc/dolibarr/conf.php";
//$conffiletoshow = "/etc/dolibarr/conf.php";
// Load conf file if it is already defined
if (! defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just <?php in first line
{
$result=include_once $conffile; // Load conf file
if ($result)
{
if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
//Mysql driver support has been removed in favor of mysqli
if ($dolibarr_main_db_type == 'mysql') {
$dolibarr_main_db_type = 'mysqli';
}
if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type=='mysqli')) $dolibarr_main_db_port='3306'; // For backward compatibility
// Clean parameters
$dolibarr_main_data_root =isset($dolibarr_main_data_root)?trim($dolibarr_main_data_root):'';
$dolibarr_main_url_root =isset($dolibarr_main_url_root)?trim($dolibarr_main_url_root):'';
$dolibarr_main_url_root_alt =isset($dolibarr_main_url_root_alt)?trim($dolibarr_main_url_root_alt):'';
$dolibarr_main_document_root =isset($dolibarr_main_document_root)?trim($dolibarr_main_document_root):'';
$dolibarr_main_document_root_alt=isset($dolibarr_main_document_root_alt)?trim($dolibarr_main_document_root_alt):'';
// Remove last / or \ on directories or url value
if (! empty($dolibarr_main_document_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root)) $dolibarr_main_document_root=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
if (! empty($dolibarr_main_url_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root)) $dolibarr_main_url_root=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root);
if (! empty($dolibarr_main_data_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_data_root)) $dolibarr_main_data_root=preg_replace('/[\\/]+$/','',$dolibarr_main_data_root);
if (! empty($dolibarr_main_document_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root_alt);
if (! empty($dolibarr_main_url_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root_alt);
// Create conf object
if (! empty($dolibarr_main_document_root))
{
$result=conf($dolibarr_main_document_root);
}
// Load database driver
if ($result)
{
if (! empty($dolibarr_main_document_root) && ! empty($dolibarr_main_db_type))
{
$result=include_once $dolibarr_main_document_root . "/core/db/".$dolibarr_main_db_type.'.class.php';
if (! $result)
{
$includeconferror='ErrorBadValueForDolibarrMainDBType';
}
}
}
else
{
$includeconferror='ErrorBadValueForDolibarrMainDocumentRoot';
}
}
else
{
$includeconferror='ErrorBadFormatForConfFile';
}
}
$conf->global->MAIN_LOGTOHTML = 1;
// Define prefix
if (! isset($dolibarr_main_db_prefix) || ! $dolibarr_main_db_prefix) $dolibarr_main_db_prefix='llx_';
define('MAIN_DB_PREFIX',(isset($dolibarr_main_db_prefix)?$dolibarr_main_db_prefix:''));
define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir
define('DOL_DATA_ROOT',(isset($dolibarr_main_data_root)?$dolibarr_main_data_root:''));
define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root)?$dolibarr_main_url_root:'')); // URL relative root
$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
if (empty($character_set_client)) $character_set_client="UTF-8";
$conf->file->character_set_client=strtoupper($character_set_client);
if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set=($conf->db->type=='mysql'?'latin1':''); // Old installation
$conf->db->character_set=$dolibarr_main_db_character_set;
if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation=($conf->db->type=='mysql'?'latin1_swedish_ci':''); // Old installation
$conf->db->dolibarr_main_db_collation=$dolibarr_main_db_collation;
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
if (empty($conf->db->user)) $conf->db->user='';
// Defini objet langs
$langs = new Translate('..',$conf);
if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang'));
else $langs->setDefaultLang('auto');
$bc[false]=' class="bg1"';
$bc[true]=' class="bg2"';
/**
* Load conf file (file must exists)
*
* @param string $dolibarr_main_document_root Root directory of Dolibarr bin files
* @return int <0 if KO, >0 if OK
*/
function conf($dolibarr_main_document_root)
{
global $conf;
global $dolibarr_main_db_type;
global $dolibarr_main_db_host;
global $dolibarr_main_db_port;
global $dolibarr_main_db_name;
global $dolibarr_main_db_user;
global $dolibarr_main_db_pass;
global $character_set_client;
$return=include_once $dolibarr_main_document_root.'/core/class/conf.class.php';
if (! $return) return -1;
$conf=new Conf();
$conf->db->type = trim($dolibarr_main_db_type);
$conf->db->host = trim($dolibarr_main_db_host);
$conf->db->port = trim($dolibarr_main_db_port);
$conf->db->name = trim($dolibarr_main_db_name);
$conf->db->user = trim($dolibarr_main_db_user);
$conf->db->pass = trim($dolibarr_main_db_pass);
if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation='utf8_unicode_ci';
return 1;
}
/**
* Show HTML header
*
* @param string $soutitre Title
* @param string $next Next
* @param string $action Action code
* @return void
*/
function pHeader($soutitre,$next,$action='none')
{
global $conf;
global $langs;
$langs->load("main");
$langs->load("admin");
// On force contenu dans format sortie
header("Content-type: text/html; charset=".$conf->file->character_set_client);
header("X-Content-Type-Options: nosniff");
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
print '<html manifest="'.DOL_URL_ROOT.'/cache.manifest">'."\n";
print '<head>'."\n";
print '<meta http-equiv="content-type" content="text/html; charset='.$conf->file->character_set_client.'">'."\n";
print '<meta name="robots" content="index,follow">'."\n";
print '<meta name="keywords" content="help, center, dolibarr, doliwamp">'."\n";
print '<meta name="description" content="Dolibarr help center">'."\n";
print '<link rel="stylesheet" type="text/css" href="default.css">'."\n";
print '<title>'.$langs->trans("DolibarrHelpCenter").'</title>'."\n";
print '</head>'."\n";
print '<body>'."\n";
print '<table class="noborder" summary="helpcentertitle"><tr valign="middle">';
print '<td width="20">';
print '<img src="helpcenter.png" alt="logohelpcenter">';
print '</td>';
print '<td>';
print '<span class="titre">'.$soutitre.'</span>'."\n";
print '</td></tr></table>';
}
/**
* Print HTML footer
*
* @param integer $nonext No button "Next step"
* @param string $setuplang Language code
* @return void
*/
function pFooter($nonext=0,$setuplang='')
{
global $langs;
$langs->load("main");
$langs->load("admin");
print '</body>'."\n";
print '</html>'."\n";
}