dolibarr 23.0.3
fileconf.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
7 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33include_once 'inc.php';
47'
48@phan-var-force string $dolibarr_main_db_host
49@phan-var-force string $dolibarr_main_db_port
50@phan-var-force string $dolibarr_main_db_name
51@phan-var-force string $dolibarr_main_db_user
52@phan-var-force string $dolibarr_main_db_pass
53@phan-var-force string $dolibarr_main_db_encrypted_pass
54@phan-var-force string $conffile
55@phan-var-force string $conffiletoshow
56@phan-var-force ?bool $force_install_
57@phan-var-force ?string $force_install_packager
58@phan-var-force ?string $force_install_message
59@phan-var-force ?string $force_install_main_data_root
60@phan-var-force ?int<0,2> $force_install_noedit
61@phan-var-force ?string $force_install_type
62@phan-var-force ?string $force_install_dbserver
63@phan-var-force ?string $force_install_port
64@phan-var-force ?string $force_install_database
65@phan-var-force ?string $force_install_prefix
66@phan-var-force ?string $force_install_createdatabase
67@phan-var-force ?string $force_install_databaselogin
68@phan-var-force ?string $force_install_databasepass
69@phan-var-force ?string $force_install_databaserootlogin
70@phan-var-force ?string $force_install_databaserootpass
71@phan-var-force ?string $force_install_dolibarrlogin
72@phan-var-force ?string $force_install_nophpinfo
73@phan-var-force ?string $force_install_lockinstall
74@phan-var-force ?string $force_install_distrib
75@phan-var-force ?string $db_user_root
76@phan-var-force ?string $db_pass_root
77';
78
79$err = 0;
80
81$setuplang = GETPOST("selectlang", 'alpha', 3) ? GETPOST("selectlang", 'alpha', 3) : (GETPOST('lang', 'alpha', 1) ? GETPOST('lang', 'alpha', 1) : 'auto');
82$langs->setDefaultLang($setuplang);
83
84$langs->loadLangs(array("install", "errors", "admin"));
85
86dolibarr_install_syslog("- fileconf: entering fileconf.php page");
87
88// You can force preselected values of the config step of Dolibarr by adding a file
89// install.forced.php into directory htdocs/install (This is the case with some wizard
90// installer like DoliWamp, DoliMamp or DoliBuntu).
91// We first init "forced values" to nothing.
92if (!isset($force_install_distrib)) {
93 $force_install_distrib = 'undefined';
94}
95if (!isset($force_install_noedit)) {
96 $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters, 3 to block all technical parameters excepted main_url
97}
98if (!isset($force_install_type)) {
99 $force_install_type = '';
100}
101if (!isset($force_install_dbserver)) {
102 $force_install_dbserver = '';
103}
104if (!isset($force_install_port)) {
105 $force_install_port = '';
106}
107if (!isset($force_install_database)) {
108 $force_install_database = '';
109}
110if (!isset($force_install_prefix)) {
111 $force_install_prefix = '';
112}
113if (!isset($force_install_createdatabase)) {
114 $force_install_createdatabase = '';
115}
116if (!isset($force_install_databaselogin)) {
117 $force_install_databaselogin = '';
118}
119if (!isset($force_install_databasepass)) {
120 $force_install_databasepass = '';
121}
122if (!isset($force_install_databaserootlogin)) {
123 $force_install_databaserootlogin = '';
124}
125if (!isset($force_install_databaserootpass)) {
126 $force_install_databaserootpass = '';
127}
128// Now we load forced values from install.forced.php file.
129$useforcedwizard = false;
130$forcedfile = "./install.forced.php";
131if ($conffile == "/etc/dolibarr/conf.php") {
132 $forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php
133}
134if (@file_exists($forcedfile)) {
135 $useforcedwizard = true;
136 include_once $forcedfile;
137}
138
139
140
141/*
142 * View
143 */
144
145session_start(); // To be able to keep info into session (used for not losing pass during navigation. pass must not transit through parameters)
146
147pHeader($langs->trans("DolibarrSetup").' - '.$langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY) ? '' : $force_dolibarr_js_JQUERY.'/'), 'main-inside-bis');
148
149// Test if we can run a first install process
150if (!is_writable($conffile)) {
151 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
152 dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING);
153 dolibarr_install_syslog("- fileconf: end");
154 pFooter(1, $setuplang, 'jscheckparam');
155 exit;
156}
157
158if (!empty($force_install_distrib)) {
159 print '<!-- $force_install_distrib = '.dol_escape_htmltag($force_install_distrib).' -->';
160}
161
162if (!empty($force_install_message)) {
163 print '<div><br>'.$langs->trans($force_install_message).'</div>';
164
165 /*print '<script type="text/javascript">';
166 print ' jQuery(document).ready(function() {
167 jQuery("#linktoshowtechnicalparam").click(function() {
168 jQuery(".hidewhenedit").hide();
169 jQuery(".hidewhennoedit").show();
170 });';
171 if ($force_install_noedit) print 'jQuery(".hidewhennoedit").hide();';
172 print '});';
173 print '</script>';
174
175 print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">'.$langs->trans("ShowEditTechnicalParameters").'</a><br>';
176 */
177}
178
179?>
180<div>
181
182
183<table class="nobordernopadding<?php if ($force_install_noedit) {
184 print ' hidewhennoedit';
185 } ?>">
186
187 <tr>
188 <td colspan="3" class="label">
189 <h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/globe.svg" width="20" alt="webserver"> <?php echo $langs->trans("WebServer"); ?></h3>
190 </td>
191 </tr>
192
193 <!-- Documents root $dolibarr_main_document_root -->
194 <tr>
195 <td class="label"><label for="main_dir"><b><?php print $langs->trans("WebPagesDirectory"); ?></b></label></td>
196<?php
197if (empty($dolibarr_main_document_root)) {
198 $dolibarr_main_document_root = GETPOSTISSET('main_dir') ? GETPOST('main_dir') : detect_dolibarr_main_document_root();
199}
200?>
201 <td class="label">
202 <input type="text" class="minwidth300" id="main_dir"
203 name="main_dir"
204 value="<?php print $dolibarr_main_document_root ?>"
205<?php
206if (!empty($force_install_noedit)) {
207 print ' disabled';
208}
209?>
210 >
211 </td>
212 <td class="comment"><?php
213 print '<span class="opacitymedium">'.$langs->trans("WithNoSlashAtTheEnd")."</span><br>";
214 print $langs->trans("Examples").":<br>";
215 ?>
216 <ul>
217 <li>/var/www/dolibarr/htdocs</li>
218 <li>C:/wwwroot/dolibarr/htdocs</li>
219 </ul>
220 </td>
221 </tr>
222
223 <!-- Documents URL $dolibarr_main_data_root -->
224 <tr>
225 <td class="label"><label for="main_data_dir"><b><?php print $langs->trans("DocumentsDirectory"); ?></b></label></td>
226 <?php
227 if (!empty($force_install_main_data_root)) {
228 $dolibarr_main_data_root = @$force_install_main_data_root;
229 }
230 if (empty($dolibarr_main_data_root)) {
231 $dolibarr_main_data_root = GETPOSTISSET('main_data_dir') ? GETPOST('main_data_dir') : detect_dolibarr_main_data_root($dolibarr_main_document_root);
232 }
233 ?>
234 <td class="label">
235 <input type="text"
236 class="minwidth300"
237 id="main_data_dir"
238 name="main_data_dir"
239 value="<?php print $dolibarr_main_data_root ?>"
240<?php if (!empty($force_install_noedit)) {
241 print ' disabled';
242} ?>
243 >
244 </td>
245 <td class="comment"><?php
246 print '<span class="opacitymedium">'.$langs->trans("WithNoSlashAtTheEnd")."</span><br>";
247 print $langs->trans("DirectoryRecommendation")."<br>";
248 print $langs->trans("Examples").":<br>";
249 ?>
250 <ul>
251 <li>/var/lib/dolibarr/documents</li>
252 <li>C:/My Documents/dolibarr/documents</li>
253 </ul>
254 </td>
255 </tr>
256
257 <!-- Root URL $dolibarr_main_url_root -->
258 <?php
259 if (empty($dolibarr_main_url_root)) {
260 $dolibarr_main_url_root = GETPOSTISSET('main_url') ? GETPOST('main_url') : detect_dolibarr_main_url_root();
262 }
263 ?>
264 <tr>
265 <td class="label"><label for="main_url"><b><?php echo $langs->trans("URLRoot"); ?></b></label>
266 </td>
267 <td class="label">
268 <input type="text"
269 class="minwidth300"
270 id="main_url"
271 name="main_url"
272 value="<?php print $dolibarr_main_url_root; ?>"
273<?php if (!empty($force_install_noedit) && $force_install_noedit != 3) {
274 print ' disabled';
275}
276?>
277 >
278 </td>
279 <td class="comment"><?php print $langs->trans("Examples").":<br>"; ?>
280 <ul>
281 <li>http://localhost/</li>
282 <li>http://www.myserver.com:8180/dolibarr</li>
283 <li>https://www.myvirtualfordolibarr.com/</li>
284 </ul>
285 </td>
286 </tr>
287
288 <?php
289 if (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://"
290 ?>
291 <tr>
292 <td class="label"><label for="main_force_https"><?php echo $langs->trans("ForceHttps"); ?></label></td>
293 <td class="label">
294 <input type="checkbox"
295 id="main_force_https"
296 name="main_force_https"
297 <?php if (!empty($force_install_mainforcehttps)) {
298 print ' checked';
299 } ?>
300 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_mainforcehttps !== null) {
301 print ' disabled';
302 } ?>
303 >
304 </td>
305 <td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
306 </td>
307
308 </tr>
309 <?php
310 }
311 ?>
312
313 <!-- Dolibarr database -->
314
315 <tr>
316 <td colspan="3" class="label"><br>
317 <h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/database.svg" width="20" alt="webserver"> <?php echo $langs->trans("DolibarrDatabase"); ?></h3>
318 </td>
319 </tr>
320
321 <tr>
322 <td class="label"><label for="db_name"><b><?php echo $langs->trans("DatabaseName"); ?></b></label></td>
323 <td class="label">
324 <input type="text"
325 id="db_name"
326 name="db_name"
327 value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
328 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_database !== null) {
329 print ' disabled';
330 } ?>
331 >
332 </td>
333 <td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
334 </tr>
335
336
337 <?php
338 if (!isset($dolibarr_main_db_host)) {
339 $dolibarr_main_db_host = "localhost";
340 }
341 if (!isset($dolibarr_main_db_port)) {
342 $dolibarr_main_db_port = "";
343 }
344 if (!isset($dolibarr_main_db_user)) {
345 $dolibarr_main_db_user = "";
346 }
347
348 ?>
349 <tr>
350 <!-- Driver type -->
351 <td class="label"><label for="db_type"><b><?php echo $langs->trans("DriverType"); ?></b></label></td>
352
353 <td class="label">
354 <?php
355
356 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ? 'mysqli' : $force_install_type);
357
358 $modules = array();
359 $nbok = $nbko = 0;
360 $option = '';
361
362 // Scan les drivers
363 $dir = DOL_DOCUMENT_ROOT.'/core/db';
364 $handle = opendir($dir);
365 if (is_resource($handle)) {
366 while (($file = readdir($handle)) !== false) {
367 if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg)) {
368 $type = $reg[1];
369 if ($type === 'DoliDB') {
370 continue; // Skip abstract class
371 }
372 $class = 'DoliDB'.ucfirst($type);
373 include_once $dir."/".$file;
374
375 if ($type == 'sqlite') {
376 continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
377 }
378 if ($type == 'sqlite3') {
379 continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
380 }
381
382 // Version min of database
383 $note = '('.$class::LABEL.' >= '.$class::VERSIONMIN.')';
384
385 // Switch to mysql if mysqli is not present
386 if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) {
387 $defaultype = 'mysql';
388 }
389
390 $testclass = '';
391 $testfunction = null;
392 // Show line into list
393 if ($type == 'mysql') {
394 $testfunction = 'mysql_connect';
395 $testclass = '';
396 }
397 if ($type == 'mysqli') {
398 $testfunction = 'mysqli_connect';
399 $testclass = '';
400 }
401 if ($type == 'pgsql') {
402 $testfunction = 'pg_connect';
403 $testclass = '';
404 }
405 if ($type == 'mssql') {
406 $testfunction = 'mssql_connect';
407 $testclass = '';
408 }
409 if ($type == 'sqlite') {
410 $testfunction = '';
411 $testclass = 'PDO';
412 }
413 if ($type == 'sqlite3') {
414 $testfunction = '';
415 $testclass = 'SQLite3';
416 }
417 $option .= '<option value="'.$type.'"'.($defaultype == $type ? ' selected' : '');
418 if ($testfunction && !function_exists($testfunction)) {
419 $option .= ' disabled';
420 }
421 if ($testclass && !class_exists($testclass)) {
422 $option .= ' disabled';
423 }
424 $option .= '>';
425 $option .= $type.'&nbsp; &nbsp;';
426 if ($note) {
427 $option .= ' '.$note;
428 }
429 // Deprecated and experimental
430 if ($type == 'mysql') {
431 $option .= ' '.$langs->trans("Deprecated");
432 } elseif ($type == 'mssql') {
433 $option .= ' '.$langs->trans("VersionExperimental");
434 } elseif ($type == 'sqlite') {
435 $option .= ' '.$langs->trans("VersionExperimental");
436 } elseif ($type == 'sqlite3') {
437 $option .= ' '.$langs->trans("VersionExperimental");
438 } elseif ($testfunction === null || !function_exists($testfunction)) {
439 // None available
440 $option .= ' - '.$langs->trans("FunctionNotAvailableInThisPHP");
441 }
442 $option .= '</option>';
443 }
444 }
445 }
446 ?>
447 <select id="db_type"
448 name="db_type"
449 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_type !== null) {
450 print ' disabled';
451 } ?>
452 >
453 <?php print $option; ?>
454 </select>
455
456 </td>
457 <td class="comment"><?php echo $langs->trans("DatabaseType"); ?></td>
458
459 </tr>
460
461 <tr class="hidesqlite">
462 <td class="label"><label for="db_host"><b><?php echo $langs->trans("DatabaseServer"); ?></b></label></td>
463 <td class="label">
464 <input type="text"
465 id="db_host"
466 name="db_host"
467 value="<?php print(!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
468 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_dbserver !== null) {
469 print ' disabled';
470 } ?>
471 >
472 </td>
473 <td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
474 </td>
475
476 </tr>
477
478 <tr class="hidesqlite">
479 <td class="label"><label for="db_port"><?php echo $langs->trans("Port"); ?></label></td>
480 <td class="label">
481 <input type="text" class="width75"
482 name="db_port"
483 id="db_port"
484 value="<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
485 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_port !== null) {
486 print ' disabled';
487 } ?>
488 >
489 </td>
490 <td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
491 </td>
492
493 </tr>
494
495 <tr class="hidesqlite">
496 <td class="label"><label for="db_prefix"><?php echo $langs->trans("DatabasePrefix"); ?></label></td>
497 <td class="label">
498 <input type="text"
499 id="db_prefix"
500 name="db_prefix"
501 value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
502 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_prefix !== null) {
503 print ' disabled';
504 } ?>
505 >
506 </td>
507 <td class="comment"><?php echo $langs->trans("DatabasePrefixDescription"); ?></td>
508 </tr>
509
510 <tr class="hidesqlite">
511 <td class="label"><label for="db_create_database"><?php echo $langs->trans("CreateDatabase"); ?></label></td>
512 <td class="label">
513 <input type="checkbox"
514 id="db_create_database"
515 name="db_create_database"
516 value="on"
517 <?php
518 $checked = 0;
519 if ($force_install_createdatabase) {
520 $checked = 1;
521 print ' checked';
522 } ?>
523 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createdatabase !== null) {
524 print ' disabled';
525 } ?>
526 >
527 </td>
528 <td class="comment">
529 <?php echo $langs->trans("CheckToCreateDatabase"); ?>
530 </td>
531 </tr>
532
533 <tr class="hidesqlite">
534 <td class="label"><label for="db_user"><b><?php echo $langs->trans("Login"); ?></b></label></td>
535 <td class="label">
536 <input type="text"
537 id="db_user"
538 name="db_user"
539 value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
540 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databaselogin !== null) {
541 print ' disabled';
542 } ?>
543 >
544 </td>
545 <td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
546 </tr>
547
548 <tr class="hidesqlite">
549 <td class="label"><label for="db_pass"><b><?php echo $langs->trans("Password"); ?></b></label></td>
550 <td class="label">
551 <input type="password" class="text-security"
552 id="db_pass" autocomplete="off"
553 name="db_pass"
554 value="<?php
555 // If $force_install_databasepass is on, we don't want to set password, we just show '***'. Real value will be extracted from the forced install file at step1.
556 // @phan-suppress-next-line PhanParamSuspiciousOrder
557 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
558 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
559 $autofill = '';
560 }
561 print dol_escape_htmltag($autofill);
562 ?>"
563 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databasepass !== null) {
564 print ' disabled';
565 } ?>
566 >
567 </td>
568 <td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
569 </tr>
570
571 <tr class="hidesqlite">
572 <td class="label"><label for="db_create_user"><?php echo $langs->trans("CreateUser"); ?></label></td>
573 <td class="label">
574 <input type="checkbox"
575 id="db_create_user"
576 name="db_create_user"
577 value="on"
578 <?php
579 $checked = 0;
580 if (!empty($force_install_createuser)) {
581 $checked = 1;
582 print ' checked';
583 } ?>
584 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createuser !== null) {
585 print ' disabled';
586 } ?>
587 >
588 </td>
589 <td class="comment">
590 <?php echo $langs->trans("CheckToCreateUser"); ?>
591 </td>
592 </tr>
593
594
595 <!-- Super access -->
596 <?php
597 $force_install_databaserootlogin = parse_database_login($force_install_databaserootlogin);
598 $force_install_databaserootpass = parse_database_pass($force_install_databaserootpass);
599 ?>
600 <tr class="hidesqlite hideroot">
601 <td colspan="3" class="label"><br>
602 <h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/shield.svg" width="20" alt="webserver"> <?php echo $langs->trans("DatabaseSuperUserAccess"); ?></h3>
603 </td>
604 </tr>
605
606 <tr class="hidesqlite hideroot">
607 <td class="label"><label for="db_user_root"><b><?php echo $langs->trans("Login"); ?></b></label></td>
608 <td class="label">
609 <input type="text"
610 id="db_user_root"
611 name="db_user_root"
612 class="needroot"
613 value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : (GETPOSTISSET('db_user_root') ? GETPOST('db_user_root') : (isset($db_user_root) ? $db_user_root : '')); ?>"
614 <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
615 print ' disabled';
616 } ?>
617 >
618 </td>
619 <td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
620 <!--
621 <?php echo '<br>'.$langs->trans("Examples").':<br>' ?>
622 <ul>
623 <li>root (Mysql)</li>
624 <li>postgres (PostgreSql)</li>
625 </ul>
626 </td>
627 -->
628
629 </tr>
630 <tr class="hidesqlite hideroot">
631 <td class="label"><label for="db_pass_root"><b><?php echo $langs->trans("Password"); ?></b></label></td>
632 <td class="label">
633 <input type="password"
634 autocomplete="off"
635 id="db_pass_root"
636 name="db_pass_root"
637 class="needroot text-security"
638 value="<?php
639 // If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1.
640 // @phan-suppress-next-line PhanParamSuspiciousOrder
641 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
642 if (!empty($dolibarr_main_prod)) {
643 $autofill = '';
644 }
645 // Do not autofill password if instance is a production instance
646 if (!empty($_SERVER["SERVER_NAME"]) && !in_array(
647 $_SERVER["SERVER_NAME"],
648 array('127.0.0.1', 'localhost', 'localhostgit')
649 )
650 ) {
651 $autofill = '';
652 } // Do not autofill password for remote access
653 print dol_escape_htmltag($autofill);
654 ?>"
655 <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
656 print ' disabled'; /* May be removed by javascript*/
657 } ?>
658 >
659 </td>
660 <td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
661 </td>
662 </tr>
663
664</table>
665</div>
666
667
668<script type="text/javascript">
669function init_needroot()
670{
671 console.log("init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
672 console.log(jQuery("#db_create_database").is(":checked"));
673 console.log(jQuery("#db_create_user").is(":checked"));
674
675 if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
676 {
677 console.log("init_needroot show root section");
678 jQuery(".hideroot").show();
679 <?php
680 if (empty($force_install_noedit)) { ?>
681 jQuery(".needroot").removeAttr('disabled');
682 <?php } ?>
683 }
684 else
685 {
686 console.log("init_needroot hide root section");
687 jQuery(".hideroot").hide();
688 jQuery(".needroot").prop('disabled', true);
689 }
690}
691
692function checkDatabaseName(databasename) {
693 if (databasename.match(/[;\.]/)) { return false; }
694 return true;
695}
696
697function jscheckparam()
698{
699 console.log("Click on jscheckparam");
700
701 var ok = true;
702
703 if (document.forminstall.main_dir.value == '')
704 {
705 ok=false;
706 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
707 }
708 else if (document.forminstall.main_data_dir.value == '')
709 {
710 ok=false;
711 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
712 }
713 else if (document.forminstall.main_url.value == '')
714 {
715 ok=false;
716 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
717 }
718 else if (document.forminstall.db_host.value == '')
719 {
720 ok=false;
721 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
722 }
723 else if (document.forminstall.db_name.value == '')
724 {
725 ok=false;
726 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
727 }
728 else if (! checkDatabaseName(document.forminstall.db_name.value))
729 {
730 ok=false;
731 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
732 }
733 // If create database asked
734 else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
735 {
736 ok=false;
737 alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
738 init_needroot();
739 }
740 // If create user asked
741 else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
742 {
743 ok=false;
744 alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
745 init_needroot();
746 }
747
748 return ok;
749}
750
751
752jQuery(document).ready(function() { // TODO Test $( window ).load(function() to see if the init_needroot work better after a back
753
754 var dbtype = jQuery("#db_type");
755
756 dbtype.change(function () {
757 if (dbtype.val() == 'sqlite' || dbtype.val() == 'sqlite3') {
758 jQuery(".hidesqlite").hide();
759 } else {
760 jQuery(".hidesqlite").show();
761 }
762
763 // Automatically set default database ports and admin user
764 if (dbtype.val() == 'mysql' || dbtype.val() == 'mysqli') {
765 jQuery("#db_port").val(3306);
766 jQuery("#db_user_root").val('root');
767 } else if (dbtype.val() == 'pgsql') {
768 jQuery("#db_port").val(5432);
769 jQuery("#db_user_root").val('postgres');
770 } else if (dbtype.val() == 'mssql') {
771 jQuery("#db_port").val(1433);
772 jQuery("#db_user_root").val('sa');
773 }
774
775 });
776
777 jQuery("#db_create_database").click(function() {
778 console.log("click on db_create_database");
779 init_needroot();
780 });
781 jQuery("#db_create_user").click(function() {
782 console.log("click on db_create_user");
783 init_needroot();
784 });
785 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && empty($force_install_databasepass)) { ?>
786 jQuery("#db_pass").focus();
787 <?php } ?>
788
789 init_needroot();
790});
791</script>
792
793
794<?php
795
796// $db->close(); Not database connection yet
797
798dolibarr_install_syslog("- fileconf: end");
799
800pFooter($err, $setuplang, 'jscheckparam');
global $dolibarr_main_url_root
API class for receive files.
$conffile
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
treeview li table
No Email.
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
Definition inc.php:541
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
Definition inc.php:736
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:635
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
Definition inc.php:780
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
Definition inc.php:791
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:699
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
Definition inc.php:747
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.
Definition inc.php:712
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Abort invoice creation with a given error message.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:125
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:128