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