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