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