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