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