dolibarr  16.0.5
step1.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6  * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2015-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 define('DONOTLOADCONF', 1); // To avoid loading conf by file inc.php
30 
31 include 'inc.php';
32 
33 global $langs;
34 
35 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]);
36 $setuplang = GETPOST('selectlang', 'aZ09', 3) ?GETPOST('selectlang', 'aZ09', 3) : (empty($argv[2]) ? 'auto' : $argv[2]);
37 $langs->setDefaultLang($setuplang);
38 
39 $langs->loadLangs(array("admin", "install", "errors"));
40 
41 // Dolibarr pages directory
42 $main_dir = GETPOST('main_dir') ?GETPOST('main_dir') : (empty($argv[3]) ? '' : $argv[3]);
43 // Directory for generated documents (invoices, orders, ecm, etc...)
44 $main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : (empty($argv[4]) ? ($main_dir.'/documents') : $argv[4]);
45 // Dolibarr root URL
46 $main_url = GETPOST('main_url') ?GETPOST('main_url') : (empty($argv[5]) ? '' : $argv[5]);
47 // Database login information
48 $userroot = GETPOST('db_user_root', 'alpha') ?GETPOST('db_user_root', 'alpha') : (empty($argv[6]) ? '' : $argv[6]);
49 $passroot = GETPOST('db_pass_root', 'none') ?GETPOST('db_pass_root', 'none') : (empty($argv[7]) ? '' : $argv[7]);
50 // Database server
51 $db_type = GETPOST('db_type', 'aZ09') ?GETPOST('db_type', 'aZ09') : (empty($argv[8]) ? '' : $argv[8]);
52 $db_host = GETPOST('db_host', 'alpha') ?GETPOST('db_host', 'alpha') : (empty($argv[9]) ? '' : $argv[9]);
53 $db_name = GETPOST('db_name', 'aZ09') ?GETPOST('db_name', 'aZ09') : (empty($argv[10]) ? '' : $argv[10]);
54 $db_user = GETPOST('db_user', 'alpha') ?GETPOST('db_user', 'alpha') : (empty($argv[11]) ? '' : $argv[11]);
55 $db_pass = GETPOST('db_pass', 'none') ?GETPOST('db_pass', 'none') : (empty($argv[12]) ? '' : $argv[12]);
56 $db_port = GETPOST('db_port', 'int') ?GETPOST('db_port', 'int') : (empty($argv[13]) ? '' : $argv[13]);
57 $db_prefix = GETPOST('db_prefix', 'aZ09') ?GETPOST('db_prefix', 'aZ09') : (empty($argv[14]) ? '' : $argv[14]);
58 $db_create_database = GETPOST('db_create_database', 'alpha') ?GETPOST('db_create_database', 'alpha') : (empty($argv[15]) ? '' : $argv[15]);
59 $db_create_user = GETPOST('db_create_user', 'alpha') ?GETPOST('db_create_user', 'alpha') : (empty($argv[16]) ? '' : $argv[16]);
60 // Force https
61 $main_force_https = ((GETPOST("main_force_https", 'alpha') && (GETPOST("main_force_https", 'alpha') == "on" || GETPOST("main_force_https", 'alpha') == 1)) ? '1' : '0');
62 // Use alternative directory
63 $main_use_alt_dir = ((GETPOST("main_use_alt_dir", 'alpha') == '' || (GETPOST("main_use_alt_dir", 'alpha') == "on" || GETPOST("main_use_alt_dir", 'alpha') == 1)) ? '' : '//');
64 // Alternative root directory name
65 $main_alt_dir_name = ((GETPOST("main_alt_dir_name", 'alpha') && GETPOST("main_alt_dir_name", 'alpha') != '') ? GETPOST("main_alt_dir_name", 'alpha') : 'custom');
66 
67 $dolibarr_main_distrib = 'standard';
68 
69 session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters)
70 
71 // Save a flag to tell to restore input value if we go back
72 $_SESSION['dol_save_pass'] = $db_pass;
73 //$_SESSION['dol_save_passroot']=$passroot;
74 
75 // Now we load forced values from install.forced.php file.
76 $useforcedwizard = false;
77 $forcedfile = "./install.forced.php";
78 if ($conffile == "/etc/dolibarr/conf.php") {
79  $forcedfile = "/etc/dolibarr/install.forced.php";
80 }
81 if (@file_exists($forcedfile)) {
82  $useforcedwizard = true;
83  include_once $forcedfile;
84  // If forced install is enabled, replace the post values. These are empty because form fields are disabled.
85  if ($force_install_noedit) {
87  if (!empty($argv[1])) {
88  $main_dir = $argv[1]; // override when executing the script in command line
89  }
90  if (!empty($force_install_main_data_root)) {
91  $main_data_dir = $force_install_main_data_root;
92  } else {
93  $main_data_dir = detect_dolibarr_main_data_root($main_dir);
94  }
95  $main_url = detect_dolibarr_main_url_root();
96 
97  if (!empty($force_install_databaserootlogin)) {
98  $userroot = parse_database_login($force_install_databaserootlogin);
99  }
100  if (!empty($force_install_databaserootpass)) {
101  $passroot = parse_database_pass($force_install_databaserootpass);
102  }
103  }
104  if ($force_install_noedit == 2) {
105  if (!empty($force_install_type)) {
106  $db_type = $force_install_type;
107  }
108  if (!empty($force_install_dbserver)) {
109  $db_host = $force_install_dbserver;
110  }
111  if (!empty($force_install_database)) {
112  $db_name = $force_install_database;
113  }
114  if (!empty($force_install_databaselogin)) {
115  $db_user = $force_install_databaselogin;
116  }
117  if (!empty($force_install_databasepass)) {
118  $db_pass = $force_install_databasepass;
119  }
120  if (!empty($force_install_port)) {
121  $db_port = $force_install_port;
122  }
123  if (!empty($force_install_prefix)) {
124  $db_prefix = $force_install_prefix;
125  }
126  if (!empty($force_install_createdatabase)) {
127  $db_create_database = $force_install_createdatabase;
128  }
129  if (!empty($force_install_createuser)) {
130  $db_create_user = $force_install_createuser;
131  }
132  if (!empty($force_install_mainforcehttps)) {
133  $main_force_https = $force_install_mainforcehttps;
134  }
135  }
136 
137  if (!empty($force_install_distrib)) {
138  $dolibarr_main_distrib = $force_install_distrib;
139  }
140 }
141 
142 
143 $error = 0;
144 
145 
146 /*
147  * View
148  */
149 
150 dolibarr_install_syslog("--- step1: entering step1.php page");
151 
152 pHeader($langs->trans("ConfigurationFile"), "step2");
153 
154 // Test if we can run a first install process
155 if (!is_writable($conffile)) {
156  print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
157  pFooter(1, $setuplang, 'jscheckparam');
158  exit;
159 }
160 
161 
162 // Check parameters
163 $is_sqlite = false;
164 if (empty($db_type)) {
165  print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseType")).'</div>';
166  $error++;
167 } else {
168  $is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3');
169 }
170 if (empty($db_host) && !$is_sqlite) {
171  print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Server")).'</div>';
172  $error++;
173 }
174 if (empty($db_name)) {
175  print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseName")).'</div>';
176  $error++;
177 }
178 if (empty($db_user) && !$is_sqlite) {
179  print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")).'</div>';
180  $error++;
181 }
182 if (!empty($db_port) && !is_numeric($db_port)) {
183  print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $db_port, $langs->transnoentities("Port")).'</div>';
184  $error++;
185 }
186 if (!empty($db_prefix) && !preg_match('/^[a-z0-9]+_$/i', $db_prefix)) {
187  print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $db_prefix, $langs->transnoentities("DatabasePrefix")).'</div>';
188  $error++;
189 }
190 
191 
192 // Remove last / into dans main_dir
193 if (substr($main_dir, dol_strlen($main_dir) - 1) == "/") {
194  $main_dir = substr($main_dir, 0, dol_strlen($main_dir) - 1);
195 }
196 
197 // Remove last / into dans main_url
198 if (!empty($main_url) && substr($main_url, dol_strlen($main_url) - 1) == "/") {
199  $main_url = substr($main_url, 0, dol_strlen($main_url) - 1);
200 }
201 
202 if (!dol_is_dir($main_dir.'/core/db/')) {
203  print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $main_dir, $langs->transnoentitiesnoconv("WebPagesDirectory")).'</div>';
204  print '<br>';
205  //print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
206  print $langs->trans("ErrorGoBackAndCorrectParameters");
207  $error++;
208 }
209 
210 // Test database connection
211 if (!$error) {
212  $result = @include_once $main_dir."/core/db/".$db_type.'.class.php';
213  if ($result) {
214  // If we require database or user creation we need to connect as root, so we need root login credentials
215  if (!empty($db_create_database) && !$userroot) {
216  print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).'</div>';
217  print '<br>';
218  print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
219  print $langs->trans("ErrorGoBackAndCorrectParameters");
220  $error++;
221  }
222  if (!empty($db_create_user) && !$userroot) {
223  print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect", $db_user).'</div>';
224  print '<br>';
225  print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
226  print $langs->trans("ErrorGoBackAndCorrectParameters");
227  $error++;
228  }
229 
230  // If we need root access
231  if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
232  $databasefortest = $db_name;
233  if (!empty($db_create_database)) {
234  if ($db_type == 'mysql' || $db_type == 'mysqli') {
235  $databasefortest = 'mysql';
236  } elseif ($db_type == 'pgsql') {
237  $databasefortest = 'postgres';
238  } else {
239  $databasefortest = 'master';
240  }
241  }
242 
243  $db = getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port);
244 
245  dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
246  //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
247 
248  if (empty($db_create_database) && $db->connected && !$db->database_selected) {
249  print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound", $db_name).'</div>';
250  print '<br>';
251  if (!$db->connected) {
252  print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
253  }
254  print $langs->trans("ErrorGoBackAndCorrectParameters");
255  $error++;
256  } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
257  // Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
258  if ($db->error == "No such file or directory") {
259  print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
260  } else {
261  print '<div class="error">'.$db->error.'</div>';
262  }
263  if (!$db->connected) {
264  print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
265  }
266  //print '<a href="#" onClick="javascript: history.back();">';
267  print $langs->trans("ErrorGoBackAndCorrectParameters");
268  //print '</a>';
269  $error++;
270  }
271  }
272 
273  // If we need simple access
274  if (!$error && (empty($db_create_database) && empty($db_create_user))) {
275  $db = getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
276 
277  if ($db->error) {
278  print '<div class="error">'.$db->error.'</div>';
279  if (!$db->connected) {
280  print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
281  }
282  //print '<a href="#" onClick="javascript: history.back();">';
283  print $langs->trans("ErrorGoBackAndCorrectParameters");
284  //print '</a>';
285  $error++;
286  }
287  }
288  } else {
289  print "<br>\nFailed to include_once(\"".$main_dir."/core/db/".$db_type.".class.php\")<br>\n";
290  print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter", $langs->transnoentities("WebPagesDirectory")).'</div>';
291  //print '<a href="#" onClick="javascript: history.back();">';
292  print $langs->trans("ErrorGoBackAndCorrectParameters");
293  //print '</a>';
294  $error++;
295  }
296 } else {
297  if (isset($db)) {
298  print $db->lasterror();
299  }
300  if (isset($db) && !$db->connected) {
301  print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
302  }
303  print $langs->trans("ErrorGoBackAndCorrectParameters");
304  $error++;
305 }
306 
307 if (!$error && $db->connected) {
308  if (!empty($db_create_database)) {
309  $result = $db->select_db($db_name);
310  if ($result) {
311  print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'</div>';
312  print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
313  print $langs->trans("ErrorGoBackAndCorrectParameters");
314  $error++;
315  }
316  }
317 }
318 
319 // Define $defaultCharacterSet and $defaultDBSortingCollation
320 if (!$error && $db->connected) {
321  if (!empty($db_create_database)) { // If we create database, we force default value
322  // Default values come from the database handler
323 
324  $defaultCharacterSet = $db->forcecharset;
325  $defaultDBSortingCollation = $db->forcecollate;
326  } else // If already created, we take current value
327  {
328  $defaultCharacterSet = $db->getDefaultCharacterSetDatabase();
329  $defaultDBSortingCollation = $db->getDefaultCollationDatabase();
330  }
331 
332  // Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
333  // TODO Remove this when utf8mb4 is supported
334  if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci') {
335  $defaultCharacterSet = 'utf8';
336  $defaultDBSortingCollation = 'utf8_unicode_ci';
337  }
338 
339  print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
340  print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.'">';
341  $db_character_set = $defaultCharacterSet;
342  $db_collation = $defaultDBSortingCollation;
343  dolibarr_install_syslog("step1: db_character_set=".$db_character_set." db_collation=".$db_collation);
344 }
345 
346 
347 // Create config file
348 if (!$error && $db->connected && $action == "set") {
349  umask(0);
350  if (is_array($_POST)) {
351  foreach ($_POST as $key => $value) {
352  if (!preg_match('/^db_pass/i', $key)) {
353  dolibarr_install_syslog("step1: choice for ".$key." = ".$value);
354  }
355  }
356  }
357 
358  // Show title of step
359  print '<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans("ConfigurationFile").'</h3>';
360  print '<table cellspacing="0" width="100%" cellpadding="1" border="0">';
361 
362  // Check parameter main_dir
363  if (!$error) {
364  if (!is_dir($main_dir)) {
365  dolibarr_install_syslog("step1: directory '".$main_dir."' is unavailable or can't be accessed");
366 
367  print "<tr><td>";
368  print $langs->trans("ErrorDirDoesNotExists", $main_dir).'<br>';
369  print $langs->trans("ErrorWrongValueForParameter", $langs->transnoentitiesnoconv("WebPagesDirectory")).'<br>';
370  print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
371  print '</td><td>';
372  print $langs->trans("Error");
373  print "</td></tr>";
374  $error++;
375  }
376  }
377 
378  if (!$error) {
379  dolibarr_install_syslog("step1: directory '".$main_dir."' exists");
380  }
381 
382 
383  // Create subdirectory main_data_dir
384  if (!$error) {
385  // Create directory for documents
386  if (!is_dir($main_data_dir)) {
387  dol_mkdir($main_data_dir);
388  }
389 
390  if (!is_dir($main_data_dir)) {
391  print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
392  print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
393  print '</td><td>';
394  print '<span class="error">'.$langs->trans("Error").'</span>';
395  print "</td></tr>";
396  print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
397  $error++;
398  } else {
399  // Create .htaccess file in document directory
400  $pathhtaccess = $main_data_dir.'/.htaccess';
401  if (!file_exists($pathhtaccess)) {
402  dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '".$main_data_dir."'");
403  $handlehtaccess = @fopen($pathhtaccess, 'w');
404  if ($handlehtaccess) {
405  fwrite($handlehtaccess, 'Order allow,deny'."\n");
406  fwrite($handlehtaccess, 'Deny from all'."\n");
407 
408  fclose($handlehtaccess);
409  dolibarr_install_syslog("step1: .htaccess file created");
410  }
411  }
412 
413  // Documents are stored above the web pages root to prevent being downloaded without authentification
414  $dir = array();
415  $dir[] = $main_data_dir."/mycompany";
416  $dir[] = $main_data_dir."/medias";
417  $dir[] = $main_data_dir."/users";
418  $dir[] = $main_data_dir."/facture";
419  $dir[] = $main_data_dir."/propale";
420  $dir[] = $main_data_dir."/ficheinter";
421  $dir[] = $main_data_dir."/produit";
422  $dir[] = $main_data_dir."/doctemplates";
423 
424  // Loop on each directory of dir [] to create them if they do not exist
425  $num = count($dir);
426  for ($i = 0; $i < $num; $i++) {
427  if (is_dir($dir[$i])) {
428  dolibarr_install_syslog("step1: directory '".$dir[$i]."' exists");
429  } else {
430  if (dol_mkdir($dir[$i]) < 0) {
431  print "<tr><td>";
432  print "Failed to create directory: ".$dir[$i];
433  print '</td><td>';
434  print $langs->trans("Error");
435  print "</td></tr>";
436  $error++;
437  } else {
438  dolibarr_install_syslog("step1: directory '".$dir[$i]."' created");
439  }
440  }
441  }
442 
443  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
444 
445  // Copy directory medias
446  $srcroot = $main_dir.'/install/medias';
447  $destroot = $main_data_dir.'/medias';
448  dolCopyDir($srcroot, $destroot, 0, 0);
449 
450  if ($error) {
451  print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
452  print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
453  print '</td><td>';
454  print '<span class="error">'.$langs->trans("Error").'</span>';
455  print "</td></tr>";
456  print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
457  } else {
458  //ODT templates
459  $srcroot = $main_dir.'/install/doctemplates';
460  $destroot = $main_data_dir.'/doctemplates';
461  $docs = array(
462  'contracts' => 'contract',
463  'invoices' => 'invoice',
464  'orders' => 'order',
465  'products' => 'product',
466  'projects' => 'project',
467  'proposals' => 'proposal',
468  'shipments' => 'shipment',
469  'supplier_proposals' => 'supplier_proposal',
470  'tasks' => 'task_summary',
471  'thirdparties' => 'thirdparty',
472  'usergroups' => 'usergroups',
473  'users' => 'user',
474  );
475  foreach ($docs as $cursordir => $cursorfile) {
476  $src = $srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
477  $dirodt = $destroot.'/'.$cursordir;
478  $dest = $dirodt.'/template_'.$cursorfile.'.odt';
479 
480  dol_mkdir($dirodt);
481  $result = dol_copy($src, $dest, 0, 0);
482  if ($result < 0) {
483  print '<tr><td colspan="2"><br>'.$langs->trans('ErrorFailToCopyFile', $src, $dest).'</td></tr>';
484  }
485  }
486  }
487  }
488  }
489 
490  // Table prefix
491  $main_db_prefix = (!empty($db_prefix) ? $db_prefix : 'llx_');
492 
493  // Write conf file on disk
494  if (!$error) {
495  // Save old conf file on disk
496  if (file_exists("$conffile")) {
497  // We must ignore errors as an existing old file may already exist and not be replaceable or
498  // the installer (like for ubuntu) may not have permission to create another file than conf.php.
499  // Also no other process must be able to read file or we expose the new file, so content with password.
500  @dol_copy($conffile, $conffile.'.old', '0400');
501  }
502 
503  $error += write_conf_file($conffile);
504  }
505 
506  // Create database and admin user database
507  if (!$error) {
508  // We reload configuration file
509  conf($dolibarr_main_document_root);
510 
511  print '<tr><td>';
512  print $langs->trans("ConfFileReload");
513  print '</td>';
514  print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
515 
516  // Create database user if requested
517  if (isset($db_create_user) && ($db_create_user == "1" || $db_create_user == "on")) {
518  dolibarr_install_syslog("step1: create database user: ".$dolibarr_main_db_user);
519 
520  //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
521  $databasefortest = $conf->db->name;
522  if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') {
523  $databasefortest = 'mysql';
524  } elseif ($conf->db->type == 'pgsql') {
525  $databasefortest = 'postgres';
526  } elseif ($conf->db->type == 'mssql') {
527  $databasefortest = 'master';
528  }
529 
530  // Check database connection
531 
532  $db = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, $conf->db->port);
533 
534  if ($db->error) {
535  print '<div class="error">'.$db->error.'</div>';
536  $error++;
537  }
538 
539  if (!$error) {
540  if ($db->connected) {
541  $resultbis = 1;
542 
543  if (empty($dolibarr_main_db_pass)) {
544  dolibarr_install_syslog("step1: failed to create user, password is empty", LOG_ERR);
545  print '<tr><td>';
546  print $langs->trans("UserCreation").' : ';
547  print $dolibarr_main_db_user;
548  print '</td>';
549  print '<td>'.$langs->trans("Error").": A password for database user is mandatory.</td></tr>";
550  } else {
551  // Create user
552  $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
553 
554  // Create user bis
555  if ($databasefortest == 'mysql') {
556  if (!in_array($dolibarr_main_db_host, array('127.0.0.1', '::1', 'localhost', 'localhost.local'))) {
557  $resultbis = $db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
558  }
559  }
560 
561  if ($result > 0 && $resultbis > 0) {
562  print '<tr><td>';
563  print $langs->trans("UserCreation").' : ';
564  print $dolibarr_main_db_user;
565  print '</td>';
566  print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
567  } else {
568  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
569  || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
570  || $db->errno() == 'DB_ERROR_USER_ALREADY_EXISTS') {
571  dolibarr_install_syslog("step1: user already exists");
572  print '<tr><td>';
573  print $langs->trans("UserCreation").' : ';
574  print $dolibarr_main_db_user;
575  print '</td>';
576  print '<td>'.$langs->trans("LoginAlreadyExists").'</td></tr>';
577  } else {
578  dolibarr_install_syslog("step1: failed to create user", LOG_ERR);
579  print '<tr><td>';
580  print $langs->trans("UserCreation").' : ';
581  print $dolibarr_main_db_user;
582  print '</td>';
583  print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error().($db->error ? '. '.$db->error : '')."</td></tr>";
584  }
585  }
586  }
587 
588  $db->close();
589  } else {
590  print '<tr><td>';
591  print $langs->trans("UserCreation").' : ';
592  print $dolibarr_main_db_user;
593  print '</td>';
594  print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
595  print '</tr>';
596 
597  // warning message due to connection failure
598  print '<tr><td colspan="2"><br>';
599  print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
600  print '<br>';
601  print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
602  print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
603  print '</td></tr>';
604 
605  $error++;
606  }
607  }
608  } // end of user account creation
609 
610 
611  // If database creation was asked, we create it
612  if (!$error && (isset($db_create_database) && ($db_create_database == "1" || $db_create_database == "on"))) {
613  dolibarr_install_syslog("step1: create database: ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user);
614  $newdb = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, '', $conf->db->port);
615  //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit;
616 
617  if ($newdb->connected) {
618  $result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
619 
620  if ($result) {
621  print '<tr><td>';
622  print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
623  print $dolibarr_main_db_name;
624  print '</td>';
625  print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
626 
627  $newdb->select_db($dolibarr_main_db_name);
628  $check1 = $newdb->getDefaultCharacterSetDatabase();
629  $check2 = $newdb->getDefaultCollationDatabase();
630  dolibarr_install_syslog('step1: new database is using charset='.$check1.' collation='.$check2);
631 
632  // If values differs, we save conf file again
633  //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('step1: value for character_set is not the one asked for database creation', LOG_WARNING);
634  //if ($check2 != $dolibarr_main_db_collation) dolibarr_install_syslog('step1: value for collation is not the one asked for database creation', LOG_WARNING);
635  } else {
636  // warning message
637  print '<tr><td colspan="2"><br>';
638  print $langs->trans("ErrorFailedToCreateDatabase", $dolibarr_main_db_name).'<br>';
639  print $newdb->lasterror().'<br>';
640  print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate");
641  print '<br>';
642  print '</td></tr>';
643 
644  dolibarr_install_syslog('step1: failed to create database '.$dolibarr_main_db_name.' '.$newdb->lasterrno().' '.$newdb->lasterror(), LOG_ERR);
645  $error++;
646  }
647  $newdb->close();
648  } else {
649  print '<tr><td>';
650  print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
651  print $dolibarr_main_db_name;
652  print '</td>';
653  print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
654  print '</tr>';
655 
656  // warning message
657  print '<tr><td colspan="2"><br>';
658  print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
659  print '<br>';
660  print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
661  print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
662  print '</td></tr>';
663 
664  $error++;
665  }
666  } // end of create database
667 
668 
669  // We test access with dolibarr database user (not admin)
670  if (!$error) {
671  dolibarr_install_syslog("step1: connection type=".$conf->db->type." on host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name);
672  //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
673 
674  $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
675 
676  if ($db->connected) {
677  dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." ok");
678  print "<tr><td>";
679  print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
680  print $dolibarr_main_db_host;
681  print "</td><td>";
682  print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
683  print "</td></tr>";
684 
685  // server access ok, basic access ok
686  if ($db->database_selected) {
687  dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." ok");
688  print "<tr><td>";
689  print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
690  print $dolibarr_main_db_name;
691  print "</td><td>";
692  print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
693  print "</td></tr>";
694 
695  $error = 0;
696  } else {
697  dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." failed", LOG_ERR);
698  print "<tr><td>";
699  print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
700  print $dolibarr_main_db_name;
701  print '</td><td>';
702  print '<img src="../theme/eldy/img/error.png" alt="Error">';
703  print "</td></tr>";
704 
705  // warning message
706  print '<tr><td colspan="2"><br>';
707  print $langs->trans('CheckThatDatabasenameIsCorrect', $dolibarr_main_db_name).'<br>';
708  print $langs->trans('IfAlreadyExistsCheckOption').'<br>';
709  print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
710  print '</td></tr>';
711 
712  $error++;
713  }
714  } else {
715  dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." failed", LOG_ERR);
716  print "<tr><td>";
717  print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
718  print $dolibarr_main_db_host;
719  print '</td><td>';
720  print '<img src="../theme/eldy/img/error.png" alt="Error">';
721  print "</td></tr>";
722 
723  // warning message
724  print '<tr><td colspan="2"><br>';
725  print $langs->trans("ErrorConnection", $conf->db->host, $conf->db->name, $conf->db->user);
726  print $langs->trans('IfLoginDoesNotExistsCheckCreateUser').'<br>';
727  print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
728  print '</td></tr>';
729 
730  $error++;
731  }
732  }
733  }
734 
735  print '</table>';
736 }
737 
738 ?>
739 
740 <script type="text/javascript">
741 function jsinfo()
742 {
743  ok=true;
744 
745  //alert('<?php echo dol_escape_js($langs->transnoentities("NextStepMightLastALongTime")); ?>');
746 
747  document.getElementById('nextbutton').style.visibility="hidden";
748  document.getElementById('pleasewait').style.visibility="visible";
749 
750  return ok;
751 }
752 </script>
753 
754 <?php
755 
756 $ret = 0;
757 if ($error && isset($argv[1])) {
758  $ret = 1;
759 }
760 dolibarr_install_syslog("Exit ".$ret);
761 
762 dolibarr_install_syslog("--- step1: end");
763 
764 pFooter($error ? 1 : 0, $setuplang, 'jsinfo', 1);
765 
766 // Return code if ran from command line
767 if ($ret) {
768  exit($ret);
769 }
770 
771 
779 function write_main_file($mainfile, $main_dir)
780 {
781  $fp = @fopen("$mainfile", "w");
782  if ($fp) {
783  clearstatcache();
784  fputs($fp, '<?php'."\n");
785  fputs($fp, "// Wrapper to include main into htdocs\n");
786  fputs($fp, "include_once '".$main_dir."/main.inc.php';\n");
787  fclose($fp);
788  }
789 }
790 
791 
799 function write_master_file($masterfile, $main_dir)
800 {
801  $fp = @fopen("$masterfile", "w");
802  if ($fp) {
803  clearstatcache();
804  fputs($fp, '<?php'."\n");
805  fputs($fp, "// Wrapper to include master into htdocs\n");
806  fputs($fp, "include_once '".$main_dir."/master.inc.php';\n");
807  fclose($fp);
808  }
809 }
810 
811 
818 function write_conf_file($conffile)
819 {
820  global $conf, $langs;
821  global $main_url, $main_dir, $main_data_dir, $main_force_https, $main_use_alt_dir, $main_alt_dir_name, $main_db_prefix;
822  global $dolibarr_main_url_root, $dolibarr_main_document_root, $dolibarr_main_data_root, $dolibarr_main_db_host;
823  global $dolibarr_main_db_port, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass;
824  global $dolibarr_main_db_type, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_authentication;
825  global $dolibarr_main_distrib;
826  global $db_host, $db_port, $db_name, $db_user, $db_pass, $db_type, $db_character_set, $db_collation;
827  global $conffile, $conffiletoshow, $conffiletoshowshort;
828  global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH;
829  global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
830  global $force_dolibarr_lib_GEOIP_PATH;
831  global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
832  global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI;
833  global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
834 
835  $error = 0;
836 
837  $key = md5(uniqid(mt_rand(), true)); // Generate random hash
838 
839  $fp = fopen("$conffile", "w");
840  if ($fp) {
841  clearstatcache();
842 
843  fputs($fp, '<?php'."\n");
844  fputs($fp, '//'."\n");
845  fputs($fp, '// File generated by Dolibarr installer '.DOL_VERSION.' on '.dol_print_date(dol_now(), '')."\n");
846  fputs($fp, '//'."\n");
847  fputs($fp, '// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.' file'."\n");
848  fputs($fp, '// and explanations for all possibles parameters.'."\n");
849  fputs($fp, '//'."\n");
850 
851  fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'", "\'", trim($main_url)).'\';');
852  fputs($fp, "\n");
853 
854  fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'", "\'", trim($main_dir)).'\';');
855  fputs($fp, "\n");
856 
857  fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'", "\'", trim("/".$main_alt_dir_name)).'\';');
858  fputs($fp, "\n");
859 
860  fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'", "\'", trim($main_dir."/".$main_alt_dir_name)).'\';');
861  fputs($fp, "\n");
862 
863  fputs($fp, '$dolibarr_main_data_root=\''.str_replace("'", "\'", trim($main_data_dir)).'\';');
864  fputs($fp, "\n");
865 
866  fputs($fp, '$dolibarr_main_db_host=\''.str_replace("'", "\'", trim($db_host)).'\';');
867  fputs($fp, "\n");
868 
869  fputs($fp, '$dolibarr_main_db_port=\''.str_replace("'", "\'", trim($db_port)).'\';');
870  fputs($fp, "\n");
871 
872  fputs($fp, '$dolibarr_main_db_name=\''.str_replace("'", "\'", trim($db_name)).'\';');
873  fputs($fp, "\n");
874 
875  fputs($fp, '$dolibarr_main_db_prefix=\''.str_replace("'", "\'", trim($main_db_prefix)).'\';');
876  fputs($fp, "\n");
877 
878  fputs($fp, '$dolibarr_main_db_user=\''.str_replace("'", "\'", trim($db_user)).'\';');
879  fputs($fp, "\n");
880  fputs($fp, '$dolibarr_main_db_pass=\''.str_replace("'", "\'", trim($db_pass)).'\';');
881  fputs($fp, "\n");
882 
883  fputs($fp, '$dolibarr_main_db_type=\''.str_replace("'", "\'", trim($db_type)).'\';');
884  fputs($fp, "\n");
885 
886  fputs($fp, '$dolibarr_main_db_character_set=\''.str_replace("'", "\'", trim($db_character_set)).'\';');
887  fputs($fp, "\n");
888 
889  fputs($fp, '$dolibarr_main_db_collation=\''.str_replace("'", "\'", trim($db_collation)).'\';');
890  fputs($fp, "\n");
891 
892  // Authentication
893  fputs($fp, '// Authentication settings');
894  fputs($fp, "\n");
895 
896  fputs($fp, '$dolibarr_main_authentication=\'dolibarr\';');
897  fputs($fp, "\n\n");
898 
899  fputs($fp, '//$dolibarr_main_demo=\'autologin,autopass\';');
900  fputs($fp, "\n");
901 
902  fputs($fp, '// Security settings');
903  fputs($fp, "\n");
904 
905  fputs($fp, '$dolibarr_main_prod=\'0\';');
906  fputs($fp, "\n");
907 
908  fputs($fp, '$dolibarr_main_force_https=\''.$main_force_https.'\';');
909  fputs($fp, "\n");
910 
911  fputs($fp, '$dolibarr_main_restrict_os_commands=\'mysqldump, mysql, pg_dump, pgrestore\';');
912  fputs($fp, "\n");
913 
914  fputs($fp, '$dolibarr_nocsrfcheck=\'0\';');
915  fputs($fp, "\n");
916 
917  fputs($fp, '$dolibarr_main_instance_unique_id=\''.$key.'\';');
918  fputs($fp, "\n");
919 
920  fputs($fp, '$dolibarr_mailing_limit_sendbyweb=\'0\';');
921  fputs($fp, "\n");
922  fputs($fp, '$dolibarr_mailing_limit_sendbycli=\'0\';');
923  fputs($fp, "\n");
924 
925  // Write params to overwrites default lib path
926  fputs($fp, "\n");
927  if (empty($force_dolibarr_lib_FPDF_PATH)) {
928  fputs($fp, '//'); $force_dolibarr_lib_FPDF_PATH = '';
929  }
930  fputs($fp, '$dolibarr_lib_FPDF_PATH=\''.$force_dolibarr_lib_FPDF_PATH.'\';');
931  fputs($fp, "\n");
932  if (empty($force_dolibarr_lib_TCPDF_PATH)) {
933  fputs($fp, '//'); $force_dolibarr_lib_TCPDF_PATH = '';
934  }
935  fputs($fp, '$dolibarr_lib_TCPDF_PATH=\''.$force_dolibarr_lib_TCPDF_PATH.'\';');
936  fputs($fp, "\n");
937  if (empty($force_dolibarr_lib_FPDI_PATH)) {
938  fputs($fp, '//'); $force_dolibarr_lib_FPDI_PATH = '';
939  }
940  fputs($fp, '$dolibarr_lib_FPDI_PATH=\''.$force_dolibarr_lib_FPDI_PATH.'\';');
941  fputs($fp, "\n");
942  if (empty($force_dolibarr_lib_TCPDI_PATH)) {
943  fputs($fp, '//'); $force_dolibarr_lib_TCPDI_PATH = '';
944  }
945  fputs($fp, '$dolibarr_lib_TCPDI_PATH=\''.$force_dolibarr_lib_TCPDI_PATH.'\';');
946  fputs($fp, "\n");
947  if (empty($force_dolibarr_lib_ADODB_PATH)) {
948  fputs($fp, '//'); $force_dolibarr_lib_ADODB_PATH = '';
949  }
950  fputs($fp, '$dolibarr_lib_ADODB_PATH=\''.$force_dolibarr_lib_ADODB_PATH.'\';');
951  fputs($fp, "\n");
952  if (empty($force_dolibarr_lib_GEOIP_PATH)) {
953  fputs($fp, '//'); $force_dolibarr_lib_GEOIP_PATH = '';
954  }
955  fputs($fp, '$dolibarr_lib_GEOIP_PATH=\''.$force_dolibarr_lib_GEOIP_PATH.'\';');
956  fputs($fp, "\n");
957  if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
958  fputs($fp, '//'); $force_dolibarr_lib_NUSOAP_PATH = '';
959  }
960  fputs($fp, '$dolibarr_lib_NUSOAP_PATH=\''.$force_dolibarr_lib_NUSOAP_PATH.'\';');
961  fputs($fp, "\n");
962  if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
963  fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATH = '';
964  }
965  fputs($fp, '$dolibarr_lib_ODTPHP_PATH=\''.$force_dolibarr_lib_ODTPHP_PATH.'\';');
966  fputs($fp, "\n");
967  if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
968  fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP = '';
969  }
970  fputs($fp, '$dolibarr_lib_ODTPHP_PATHTOPCLZIP=\''.$force_dolibarr_lib_ODTPHP_PATHTOPCLZIP.'\';');
971  fputs($fp, "\n");
972  if (empty($force_dolibarr_js_CKEDITOR)) {
973  fputs($fp, '//'); $force_dolibarr_js_CKEDITOR = '';
974  }
975  fputs($fp, '$dolibarr_js_CKEDITOR=\''.$force_dolibarr_js_CKEDITOR.'\';');
976  fputs($fp, "\n");
977  if (empty($force_dolibarr_js_JQUERY)) {
978  fputs($fp, '//'); $force_dolibarr_js_JQUERY = '';
979  }
980  fputs($fp, '$dolibarr_js_JQUERY=\''.$force_dolibarr_js_JQUERY.'\';');
981  fputs($fp, "\n");
982  if (empty($force_dolibarr_js_JQUERY_UI)) {
983  fputs($fp, '//'); $force_dolibarr_js_JQUERY_UI = '';
984  }
985  fputs($fp, '$dolibarr_js_JQUERY_UI=\''.$force_dolibarr_js_JQUERY_UI.'\';');
986  fputs($fp, "\n");
987 
988  // Write params to overwrites default font path
989  fputs($fp, "\n");
990  if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
991  fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF = '';
992  }
993  fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF=\''.$force_dolibarr_font_DOL_DEFAULT_TTF.'\';');
994  fputs($fp, "\n");
995  if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
996  fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD = '';
997  }
998  fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.$force_dolibarr_font_DOL_DEFAULT_TTF_BOLD.'\';');
999  fputs($fp, "\n");
1000 
1001  // Other
1002  fputs($fp, '$dolibarr_main_distrib=\''.str_replace("'", "\'", trim($dolibarr_main_distrib)).'\';');
1003  fputs($fp, "\n");
1004 
1005  fclose($fp);
1006 
1007  if (file_exists("$conffile")) {
1008  include $conffile; // force config reload, do not put include_once
1009  conf($dolibarr_main_document_root);
1010 
1011  print "<tr><td>";
1012  print $langs->trans("SaveConfigurationFile");
1013  print ' <strong>'.$conffile.'</strong>';
1014  print "</td><td>";
1015  print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
1016  print "</td></tr>";
1017  } else {
1018  $error++;
1019  }
1020  }
1021 
1022  return $error;
1023 }
detect_dolibarr_main_data_root
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
Definition: inc.php:596
detect_dolibarr_main_url_root
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
Definition: inc.php:608
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
detect_dolibarr_main_document_root
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.
Definition: inc.php:572
getDoliDBInstance
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
Definition: functions.lib.php:122
parse_database_pass
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
Definition: inc.php:652
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
parse_database_login
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
Definition: inc.php:641
dol_copy
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
Definition: files.lib.php:703
dolibarr_install_syslog
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition: inc.php:559
dolCopyDir
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0)
Copy a dir to another dir.
Definition: files.lib.php:762
write_main_file
if($ret) write_main_file($mainfile, $main_dir)
Create main file.
Definition: step1.php:779
write_master_file
write_master_file($masterfile, $main_dir)
Create master file.
Definition: step1.php:799
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
conf
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition: inc.php:300
pHeader
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
Definition: inc.php:409
pFooter
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition: inc.php:498
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3747
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
dol_is_dir
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:447
write_conf_file
write_conf_file($conffile)
Save configuration file.
Definition: step1.php:818
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119