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