dolibarr  13.0.2
inc.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
4  * Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
5  * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
6  * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
7  * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 // Just to define version DOL_VERSION
30 if (!defined('DOL_INC_FOR_VERSION_ERROR')) define('DOL_INC_FOR_VERSION_ERROR', '1');
31 require_once '../filefunc.inc.php';
32 
33 
34 
35 // Define DOL_DOCUMENT_ROOT and ADODB_PATH used for install/upgrade process
36 if (!defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
37 if (!defined('ADODB_PATH'))
38 {
39  $foundpath = DOL_DOCUMENT_ROOT.'/includes/adodbtime/';
40  if (!is_dir($foundpath)) $foundpath = '/usr/share/php/adodb/';
41  define('ADODB_PATH', $foundpath);
42 }
43 
44 require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48 require_once ADODB_PATH.'adodb-time.inc.php';
49 
50 // Avoid warnings with strict mode E_STRICT
51 $conf = new stdClass(); // instantiate $conf explicitely
52 $conf->global = new stdClass();
53 $conf->file = new stdClass();
54 $conf->db = new stdClass();
55 $conf->syslog = new stdClass();
56 
57 // Force $_REQUEST["logtohtml"]
58 $_REQUEST["logtohtml"] = 1;
59 
60 // Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
61 // et non path absolu.
62 if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
63 {
64  $_SERVER["PHP_SELF"] = $_SERVER["DOCUMENT_URI"];
65 }
66 
67 
68 $includeconferror = '';
69 
70 
71 // Define vars
72 $conffiletoshowshort = "conf.php";
73 // Define localization of conf file
74 $conffile = "../conf/conf.php";
75 $conffiletoshow = "htdocs/conf/conf.php";
76 // For debian/redhat like systems
77 //$conffile = "/etc/dolibarr/conf.php";
78 //$conffiletoshow = "/etc/dolibarr/conf.php";
79 
80 
81 // Load conf file if it is already defined
82 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
83 {
84  $result = include_once $conffile; // Load conf file
85  if ($result)
86  {
87  if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type = 'mysqli'; // For backward compatibility
88 
89  //Mysql driver support has been removed in favor of mysqli
90  if ($dolibarr_main_db_type == 'mysql') {
91  $dolibarr_main_db_type = 'mysqli';
92  }
93 
94  if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type == 'mysqli')) $dolibarr_main_db_port = '3306'; // For backward compatibility
95 
96  // Clean parameters
97  $dolibarr_main_data_root = isset($dolibarr_main_data_root) ?trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.'/../documents';
98  $dolibarr_main_url_root = isset($dolibarr_main_url_root) ?trim($dolibarr_main_url_root) : '';
99  $dolibarr_main_url_root_alt = isset($dolibarr_main_url_root_alt) ?trim($dolibarr_main_url_root_alt) : '';
100  $dolibarr_main_document_root = isset($dolibarr_main_document_root) ?trim($dolibarr_main_document_root) : '';
101  $dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) : '';
102 
103  // Remove last / or \ on directories or url value
104  if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root);
105  if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root);
106  if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root);
107  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);
108  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);
109 
110  // Create conf object
111  if (!empty($dolibarr_main_document_root))
112  {
113  $result = conf($dolibarr_main_document_root);
114  }
115  // Load database driver
116  if ($result)
117  {
118  if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type))
119  {
120  $result = include_once $dolibarr_main_document_root."/core/db/".$dolibarr_main_db_type.'.class.php';
121  if (!$result)
122  {
123  $includeconferror = 'ErrorBadValueForDolibarrMainDBType';
124  }
125  }
126  } else {
127  $includeconferror = 'ErrorBadValueForDolibarrMainDocumentRoot';
128  }
129  } else {
130  $includeconferror = 'ErrorBadFormatForConfFile';
131  }
132 }
133 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
134 
135 // Define prefix
136 if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) $dolibarr_main_db_prefix = 'llx_';
137 define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : ''));
138 
139 define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir
140 define('DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT.'/../documents'));
141 define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root
142 $uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
143 $suburi = strstr($uri, '/'); // $suburi contains url without domain
144 if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
145 define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
146 
147 
148 if (empty($conf->file->character_set_client)) $conf->file->character_set_client = "utf-8";
149 if (empty($conf->db->character_set)) $conf->db->character_set = 'utf8';
150 if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci';
151 if (empty($conf->db->dolibarr_main_db_encryption)) $conf->db->dolibarr_main_db_encryption = 0;
152 if (empty($conf->db->dolibarr_main_db_cryptkey)) $conf->db->dolibarr_main_db_cryptkey = '';
153 if (empty($conf->db->user)) $conf->db->user = '';
154 
155 // Define array of document root directories
156 $conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT);
157 if (!empty($dolibarr_main_document_root_alt))
158 {
159  // dolibarr_main_document_root_alt contains several directories
160  $values = preg_split('/[;,]/', $dolibarr_main_document_root_alt);
161  foreach ($values as $value)
162  {
163  $conf->file->dol_document_root[] = $value;
164  }
165 }
166 
167 
168 // Security check (old method, when directory is renamed /install.lock)
169 if (preg_match('/install\.lock/i', $_SERVER["SCRIPT_FILENAME"]))
170 {
171  if (!is_object($langs))
172  {
173  $langs = new Translate('..', $conf);
174  $langs->setDefaultLang('auto');
175  }
176  $langs->load("install");
177  print $langs->trans("YouTryInstallDisabledByDirLock");
178  if (!empty($dolibarr_main_url_root))
179  {
180  print 'Click on following link, <a href="'.$dolibarr_main_url_root.'/admin/index.php?mainmenu=home&leftmenu=setup'.(GETPOSTISSET("login") ? '&username='.urlencode(GETPOST("login")) : '').'">';
181  print $langs->trans("ClickHereToGoToApp");
182  print '</a>';
183  }
184  exit;
185 }
186 
187 $lockfile = DOL_DATA_ROOT.'/install.lock';
188 if (constant('DOL_DATA_ROOT') === null) {
189  // We don't have a configuration file yet
190  // Try to detect any lockfile in the default documents path
191  $lockfile = '../../documents/install.lock';
192 }
193 if (@file_exists($lockfile))
194 {
195  if (!isset($langs) || !is_object($langs))
196  {
197  $langs = new Translate('..', $conf);
198  $langs->setDefaultLang('auto');
199  }
200  $langs->load("install");
201  print $langs->trans("YouTryInstallDisabledByFileLock");
202  if (!empty($dolibarr_main_url_root))
203  {
204  print $langs->trans("ClickOnLinkOrRemoveManualy").'<br>';
205  print '<a href="'.$dolibarr_main_url_root.'/admin/index.php?mainmenu=home&leftmenu=setup'.(GETPOSTISSET("login") ? '&username='.urlencode(GETPOST("login")) : '').'">';
206  print $langs->trans("ClickHereToGoToApp");
207  print '</a>';
208  } else {
209  print 'If you always reach this page, you must remove install.lock file manually.<br>';
210  }
211  exit;
212 }
213 
214 
215 // Force usage of log file for install and upgrades
216 $conf->syslog->enabled = 1;
217 $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
218 if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
219 if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
220 {
221  if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
222  elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
223  elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
224  elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
225  elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others
226  //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
227 }
228 if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
229 if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1);
230 // We init log handler for install
231 $handlers = array('mod_syslog_file');
232 foreach ($handlers as $handler)
233 {
234  $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php';
235  if (!file_exists($file))
236  {
237  throw new Exception('Missing log handler file '.$handler.'.php');
238  }
239 
240  require_once $file;
241  $loghandlerinstance = new $handler();
242  if (!$loghandlerinstance instanceof LogHandlerInterface)
243  {
244  throw new Exception('Log handler does not extend LogHandlerInterface');
245  }
246 
247  if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance;
248 }
249 
250 // Define object $langs
251 $langs = new Translate('..', $conf);
252 if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
253 else $langs->setDefaultLang('auto');
254 
255 
262 function conf($dolibarr_main_document_root)
263 {
264  global $conf;
265  global $dolibarr_main_db_type;
266  global $dolibarr_main_db_host;
267  global $dolibarr_main_db_port;
268  global $dolibarr_main_db_name;
269  global $dolibarr_main_db_user;
270  global $dolibarr_main_db_pass;
271  global $character_set_client;
272 
273  $return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php';
274  if (!$return) return -1;
275 
276  $conf = new Conf();
277  $conf->db->type = trim($dolibarr_main_db_type);
278  $conf->db->host = trim($dolibarr_main_db_host);
279  $conf->db->port = trim($dolibarr_main_db_port);
280  $conf->db->name = trim($dolibarr_main_db_name);
281  $conf->db->user = trim($dolibarr_main_db_user);
282  $conf->db->pass = trim($dolibarr_main_db_pass);
283 
284  // Mysql driver support has been removed in favor of mysqli
285  if ($conf->db->type == 'mysql') $conf->db->type = 'mysqli';
286  if (empty($character_set_client)) $character_set_client = "UTF-8";
287  $conf->file->character_set_client = strtoupper($character_set_client);
288  if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : '');
289  $conf->db->character_set = $dolibarr_main_db_character_set;
290  if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : '');
291  $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
292  if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
293  $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
294  if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = '';
295  $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
296 
297  // Force usage of log file for install and upgrades
298  $conf->syslog->enabled = 1;
299  $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
300  if (!defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
301  if (!defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
302  {
303  if (@is_writable('/tmp')) define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
304  elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
305  elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
306  elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
307  elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others
308  //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
309  }
310  if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
311  if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1);
312  // We init log handler for install
313  $handlers = array('mod_syslog_file');
314  foreach ($handlers as $handler)
315  {
316  $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php';
317  if (!file_exists($file))
318  {
319  throw new Exception('Missing log handler file '.$handler.'.php');
320  }
321 
322  require_once $file;
323  $loghandlerinstance = new $handler();
324  if (!$loghandlerinstance instanceof LogHandlerInterface)
325  {
326  throw new Exception('Log handler does not extend LogHandlerInterface');
327  }
328 
329  if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance;
330  }
331 
332  return 1;
333 }
334 
335 
347 function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl = '', $csstable = 'main-inside')
348 {
349  global $conf;
350  global $langs;
351  $langs->load("main");
352  $langs->load("admin");
353  $langs->load("install");
354 
355  $jquerytheme = 'base';
356 
357  if ($forcejqueryurl)
358  {
359  $jQueryCustomPath = $forcejqueryurl;
360  $jQueryUiCustomPath = $forcejqueryurl;
361  } else {
362  $jQueryCustomPath = (defined('JS_JQUERY') && constant('JS_JQUERY')) ? JS_JQUERY : false;
363  $jQueryUiCustomPath = (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) ? JS_JQUERY_UI : false;
364  }
365 
366  // We force the content charset
367  header("Content-type: text/html; charset=".$conf->file->character_set_client);
368  header("X-Content-Type-Options: nosniff");
369 
370  print '<!DOCTYPE HTML>'."\n";
371  print '<html>'."\n";
372  print '<head>'."\n";
373  print '<meta charset="'.$conf->file->character_set_client.'">'."\n";
374  print '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
375  print '<meta name="generator" content="Dolibarr installer">'."\n";
376  print '<link rel="stylesheet" type="text/css" href="default.css">'."\n";
377 
378  print '<!-- Includes CSS for JQuery -->'."\n";
379  if ($jQueryUiCustomPath) print '<link rel="stylesheet" type="text/css" href="'.$jQueryUiCustomPath.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
380  else print '<link rel="stylesheet" type="text/css" href="../includes/jquery/css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
381 
382  print '<!-- Includes JS for JQuery -->'."\n";
383  if ($jQueryCustomPath) print '<script type="text/javascript" src="'.$jQueryCustomPath.'jquery.min.js"></script>'."\n";
384  else print '<script type="text/javascript" src="../includes/jquery/js/jquery.min.js"></script>'."\n";
385  if ($jQueryUiCustomPath) print '<script type="text/javascript" src="'.$jQueryUiCustomPath.'jquery-ui.min.js"></script>'."\n";
386  else print '<script type="text/javascript" src="../includes/jquery/js/jquery-ui.min.js"></script>'."\n";
387 
388  print '<title>'.$langs->trans("DolibarrSetup").'</title>'."\n";
389  print '</head>'."\n";
390 
391  print '<body>'."\n";
392 
393  print '<div class="divlogoinstall" style="text-align:center">';
394  print '<img class="imglogoinstall" src="../theme/dolibarr_logo.svg" alt="Dolibarr logo" width="300px"><br>';
395  print DOL_VERSION;
396  print '</div><br>';
397 
398  print '<span class="titre">'.$langs->trans("DolibarrSetup");
399  if ($subtitle) {
400  print ' - '.$subtitle;
401  }
402  print '</span>'."\n";
403 
404  print '<form name="forminstall" style="width: 100%" action="'.$next.'.php'.($param ? '?'.$param : '').'" method="POST"';
405  if ($next == 'step5') print ' autocomplete="off"';
406  print '>'."\n";
407  print '<input type="hidden" name="testpost" value="ok">'."\n";
408  print '<input type="hidden" name="action" value="'.$action.'">'."\n";
409 
410  print '<table class="main" width="100%"><tr><td>'."\n";
411 
412  print '<table class="'.$csstable.'" width="100%"><tr><td>'."\n";
413 }
414 
424 function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleasewait = 0)
425 {
426  global $conf, $langs;
427 
428  $langs->loadLangs(array("main", "other", "admin"));
429 
430  print '</td></tr></table>'."\n";
431  print '</td></tr></table>'."\n";
432 
433  if (!$nonext || ($nonext == '2'))
434  {
435  print '<div class="nextbutton" id="nextbutton">';
436  if ($nonext == '2')
437  {
438  print '<span class="warning">';
439  print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '');
440  print '</span>';
441  print '<br><br>';
442  }
443 
444  print '<input type="submit" '.($nonext == '2' ? 'disabled="disabled" ' : '').'value="'.$langs->trans("NextStep").' ->"';
445  if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"';
446  print '></div>';
447  if ($withpleasewait) print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>'.$langs->trans("NextStepMightLastALongTime").'<br><br><div class="blinkwait">'.$langs->trans("PleaseBePatient").'</div></div>';
448  }
449  if ($setuplang)
450  {
451  print '<input type="hidden" name="selectlang" value="'.$setuplang.'">';
452  }
453 
454  print '</form>'."\n";
455 
456  // If there is some logs in buffer to show
457  if (isset($conf->logbuffer) && count($conf->logbuffer))
458  {
459  print "\n";
460  print "<!-- Start of log output\n";
461  //print '<div class="hidden">'."\n";
462  foreach ($conf->logbuffer as $logline)
463  {
464  print $logline."<br>\n";
465  }
466  //print '</div>'."\n";
467  print "End of log output -->\n";
468  print "\n";
469  }
470 
471  print '</body>'."\n";
472  print '</html>'."\n";
473 }
474 
482 function dolibarr_install_syslog($message, $level = LOG_DEBUG)
483 {
484  if (!defined('LOG_DEBUG')) define('LOG_DEBUG', 6);
485  dol_syslog($message, $level);
486 }
487 
494 {
495  // If PHP is in CGI mode, SCRIPT_FILENAME is PHP's path.
496  // Since that's not what we want, we suggest $_SERVER["DOCUMENT_ROOT"]
497  if ($_SERVER["SCRIPT_FILENAME"] == 'php' || preg_match('/[\\/]php$/i', $_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i', $_SERVER["SCRIPT_FILENAME"]))
498  {
499  $dolibarr_main_document_root = $_SERVER["DOCUMENT_ROOT"];
500 
501  if (!preg_match('/[\\/]dolibarr[\\/]htdocs$/i', $dolibarr_main_document_root)) {
502  $dolibarr_main_document_root .= "/dolibarr/htdocs";
503  }
504  } else {
505  // We assume /install to be under /htdocs, so we get the parent directory of the current directory
506  $dolibarr_main_document_root = dirname(dirname($_SERVER["SCRIPT_FILENAME"]));
507  }
508 
509  return $dolibarr_main_document_root;
510 }
511 
518 function detect_dolibarr_main_data_root($dolibarr_main_document_root)
519 {
520  $dolibarr_main_data_root = preg_replace("/\/htdocs$/", "", $dolibarr_main_document_root);
521  $dolibarr_main_data_root .= "/documents";
522  return $dolibarr_main_data_root;
523 }
524 
531 {
532  // If defined (Ie: Apache with Linux)
533  if (isset($_SERVER["SCRIPT_URI"])) {
534  $dolibarr_main_url_root = $_SERVER["SCRIPT_URI"];
535  } // If defined (Ie: Apache with Caudium)
536  elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
537  $dolibarr_main_url_root = $_SERVER["SERVER_URL"].$_SERVER["DOCUMENT_URI"];
538  } // If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
539  else {
540  $proto = ((!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ? 'https' : 'http';
541  if (!empty($_SERVER["HTTP_HOST"])) {
542  $serverport = $_SERVER["HTTP_HOST"];
543  } elseif (!empty($_SERVER["SERVER_NAME"])) {
544  $serverport = $_SERVER["SERVER_NAME"];
545  } else {
546  $serverport = 'localhost';
547  }
548  $dolibarr_main_url_root = $proto."://".$serverport.$_SERVER["SCRIPT_NAME"];
549  }
550  // Clean proposed URL
551  // We assume /install to be under /htdocs, so we get the parent path of the current URL
552  $dolibarr_main_url_root = dirname(dirname($dolibarr_main_url_root));
553 
554  return $dolibarr_main_url_root;
555 }
556 
563 function parse_database_login($force_install_databaserootlogin)
564 {
565  return preg_replace('/__SUPERUSERLOGIN__/', 'root', $force_install_databaserootlogin);
566 }
567 
574 function parse_database_pass($force_install_databaserootpass)
575 {
576  return preg_replace('/__SUPERUSERPASSWORD__/', '', $force_install_databaserootpass);
577 }
detect_dolibarr_main_document_root()
Automatically detect Dolibarr&#39;s main document root.
Definition: inc.php:493
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
pHeader($subtitle, $next, $action= 'set', $param= '', $forcejqueryurl= '', $csstable= 'main-inside')
Show HTML header of install pages.
Definition: inc.php:347
Class to stock current configuration.
Definition: conf.class.php:33
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition: inc.php:262
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
Definition: inc.php:563
LogHandlerInterface.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition: inc.php:482
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage logging to a file.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
Definition: inc.php:574
detect_dolibarr_main_url_root()
Automatically detect Dolibarr&#39;s main URL root.
Definition: inc.php:530
Class to manage translations.
print $_SERVER["PHP_SELF"]
Edit parameters.
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr&#39;s main data root.
Definition: inc.php:518
pFooter($nonext=0, $setuplang= '', $jscheckfunction= '', $withpleasewait=0)
Print HTML footer of install pages.
Definition: inc.php:424
print
Draft customers invoices.
Definition: index.php:89
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.