fileconf.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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@capnetworks.com>
  8. * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/install/fileconf.php
  25. * \ingroup install
  26. * \brief Ask all informations required to build Dolibarr htdocs/conf/conf.php file (will be wrote on disk on next page)
  27. */
  28. include_once 'inc.php';
  29. global $langs;
  30. $err=0;
  31. $setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):(isset($_GET["lang"])?$_GET["lang"]:'auto');
  32. $langs->setDefaultLang($setuplang);
  33. $langs->load("install");
  34. $langs->load("errors");
  35. dolibarr_install_syslog("--- fileconf: entering fileconf.php page");
  36. // You can force preselected values of the config step of Dolibarr by adding a file
  37. // install.forced.php into directory htdocs/install (This is the case with some wizard
  38. // installer like DoliWamp, DoliMamp or DoliBuntu).
  39. // We first init "forced values" to nothing.
  40. if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block vars specific to distrib, 2 to block all technical parameters
  41. if (! isset($force_install_type)) $force_install_type='';
  42. if (! isset($force_install_dbserver)) $force_install_dbserver='';
  43. if (! isset($force_install_port)) $force_install_port='';
  44. if (! isset($force_install_database)) $force_install_database='';
  45. if (! isset($force_install_prefix)) $force_install_prefix='';
  46. if (! isset($force_install_createdatabase)) $force_install_createdatabase='';
  47. if (! isset($force_install_databaselogin)) $force_install_databaselogin='';
  48. if (! isset($force_install_databasepass)) $force_install_databasepass='';
  49. if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin='';
  50. if (! isset($force_install_databaserootpass)) $force_install_databaserootpass='';
  51. // Now we load forced value from install.forced.php file.
  52. $useforcedwizard=false;
  53. $forcedfile="./install.forced.php";
  54. if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; // Must be after inc.php
  55. if (@file_exists($forcedfile)) {
  56. $useforcedwizard = true;
  57. include_once $forcedfile;
  58. }
  59. /*
  60. * View
  61. */
  62. session_start(); // To be able to keep info into session (used for not loosing pass during navigation. pass must not transit throug parmaeters)
  63. pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY)?'':$force_dolibarr_js_JQUERY.'/'), 'main-inside-bis');
  64. // Test if we can run a first install process
  65. if (! is_writable($conffile))
  66. {
  67. print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
  68. dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING);
  69. dolibarr_install_syslog("--- fileconf: end");
  70. pFooter(1,$setuplang,'jscheckparam');
  71. exit;
  72. }
  73. if (! empty($force_install_message))
  74. {
  75. print '<div><br>'.$langs->trans($force_install_message).'</div>';
  76. /*print '<script type="text/javascript">';
  77. print ' jQuery(document).ready(function() {
  78. jQuery("#linktoshowtechnicalparam").click(function() {
  79. jQuery(".hidewhenedit").hide();
  80. jQuery(".hidewhennoedit").show();
  81. });';
  82. if ($force_install_noedit) print 'jQuery(".hidewhennoedit").hide();';
  83. print '});';
  84. print '</script>';
  85. print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">'.$langs->trans("ShowEditTechnicalParameters").'</a><br>';
  86. */
  87. }
  88. ?>
  89. <div>
  90. <table class="nobordernopadding<?php if ($force_install_noedit) print ' hidewhennoedit'; ?>">
  91. <tr>
  92. <td colspan="3" class="label">
  93. <h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/globe.svg" width="20" alt="webserver"> <?php echo $langs->trans("WebServer"); ?></h3>
  94. </td>
  95. </tr>
  96. <!-- Documents root $dolibarr_main_document_root -->
  97. <tr>
  98. <?php
  99. print '<td class="tdtop label"><b>';
  100. print $langs->trans("WebPagesDirectory");
  101. print "</b></td>";
  102. if (empty($dolibarr_main_url_root)) {
  103. $dolibarr_main_document_root = detect_dolibarr_main_document_root();
  104. }
  105. ?>
  106. <td class="label tdtop">
  107. <input type="text"
  108. class="minwidth300"
  109. value="<?php print $dolibarr_main_document_root ?>"
  110. name="main_dir"
  111. <?php if (!empty($force_install_noedit)) {
  112. print ' disabled';
  113. } ?>
  114. >
  115. </td>
  116. <td class="comment"><?php
  117. print $langs->trans("WithNoSlashAtTheEnd")."<br>";
  118. print $langs->trans("Examples").":<br>";
  119. ?>
  120. <ul>
  121. <li>/var/www/dolibarr/htdocs</li>
  122. <li>C:/wwwroot/dolibarr/htdocs</li>
  123. </ul>
  124. </td>
  125. </tr>
  126. <!-- Documents URL $dolibarr_main_data_root -->
  127. <tr>
  128. <td class="tdtop label"><b> <?php print $langs->trans("DocumentsDirectory"); ?></b>
  129. </td>
  130. <?php
  131. $dolibarr_main_data_root = @$force_install_main_data_root;
  132. if (empty($dolibarr_main_data_root)) {
  133. $dolibarr_main_data_root = detect_dolibarr_main_data_root($dolibarr_main_document_root);
  134. }
  135. ?>
  136. <td class="label tdtop">
  137. <input type="text"
  138. class="minwidth300"
  139. value="<?php print $dolibarr_main_data_root ?>"
  140. name="main_data_dir"
  141. <?php if (!empty($force_install_noedit)) {
  142. print ' disabled';
  143. } ?>
  144. >
  145. </td>
  146. <td class="comment"><?php
  147. print $langs->trans("WithNoSlashAtTheEnd")."<br>";
  148. print $langs->trans("DirectoryRecommendation")."<br>";
  149. print $langs->trans("Examples").":<br>";
  150. ?>
  151. <ul>
  152. <li>/var/lib/dolibarr/documents</li>
  153. <li>C:/My Documents/dolibarr/</li>
  154. </ul>
  155. </td>
  156. </tr>
  157. <!-- Root URL $dolibarr_main_url_root -->
  158. <?php
  159. if (empty($dolibarr_main_url_root)) {
  160. $dolibarr_main_url_root = detect_dolibarr_main_url_root();
  161. }
  162. ?>
  163. <tr>
  164. <td class="tdtop label"><b> <?php echo $langs->trans("URLRoot"); ?></b>
  165. </td>
  166. <td class="tdtop label">
  167. <input type="text"
  168. class="minwidth300"
  169. name="main_url"
  170. value="<?php print $dolibarr_main_url_root; ?> "
  171. <?php if (!empty($force_install_noedit)) {
  172. print ' disabled';
  173. } ?>
  174. >
  175. </td>
  176. <td class="comment"><?php print $langs->trans("Examples").":<br>"; ?>
  177. <ul>
  178. <li>http://localhost/</li>
  179. <li>http://www.myserver.com:8180/dolibarr</li>
  180. </ul>
  181. </td>
  182. </tr>
  183. <?php
  184. if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://"
  185. ?>
  186. <tr>
  187. <td class="tdtop label"><?php echo $langs->trans("ForceHttps"); ?></td>
  188. <td class="label tdtop">
  189. <input type="checkbox"
  190. name="main_force_https"
  191. <?php if (!empty($force_install_mainforcehttps)) {
  192. print ' checked';
  193. } ?>
  194. <?php if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) {
  195. print ' disabled';
  196. } ?>
  197. >
  198. </td>
  199. <td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
  200. </td>
  201. </tr>
  202. <?php
  203. }
  204. ?>
  205. <!-- Dolibarr database -->
  206. <tr>
  207. <td colspan="3" class="label"><br>
  208. <h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/database.svg" width="20" alt="webserver"> <?php echo $langs->trans("DolibarrDatabase"); ?></h3>
  209. </td>
  210. </tr>
  211. <tr>
  212. <td class="label tdtop"><b> <?php echo $langs->trans("DatabaseName"); ?>
  213. </b></td>
  214. <td class="label tdtop">
  215. <input type="text" id="db_name"
  216. name="db_name"
  217. value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
  218. <?php if ($force_install_noedit == 2 && $force_install_database !== null) {
  219. print ' disabled';
  220. } ?>
  221. >
  222. </td>
  223. <td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
  224. </tr>
  225. <?php
  226. if (!isset($dolibarr_main_db_host))
  227. {
  228. $dolibarr_main_db_host = "localhost";
  229. }
  230. ?>
  231. <tr>
  232. <!-- Driver type -->
  233. <td class="tdtop label"><b> <?php echo $langs->trans("DriverType"); ?>
  234. </b></td>
  235. <td class="label">
  236. <?php
  237. $defaultype=! empty($dolibarr_main_db_type)?$dolibarr_main_db_type:($force_install_type?$force_install_type:'mysqli');
  238. $modules = array();
  239. $nbok = $nbko = 0;
  240. $option='';
  241. // Scan les drivers
  242. $dir=DOL_DOCUMENT_ROOT.'/core/db';
  243. $handle=opendir($dir);
  244. if (is_resource($handle))
  245. {
  246. while (($file = readdir($handle))!==false)
  247. {
  248. if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i',$file,$reg))
  249. {
  250. $type=$reg[1];
  251. if ($type === 'DoliDB') continue; // Skip abstract class
  252. $class='DoliDB'.ucfirst($type);
  253. include_once $dir."/".$file;
  254. if ($type == 'sqlite') 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)
  255. if ($type == 'sqlite3') 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)
  256. // Version min of database
  257. $versionbasemin=explode('.',$class::VERSIONMIN);
  258. $note='('.$class::LABEL.' >= '.$class::VERSIONMIN.')';
  259. // Switch to mysql if mysqli is not present
  260. if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';
  261. // Show line into list
  262. if ($type=='mysql') { $testfunction='mysql_connect'; $testclass=''; }
  263. if ($type=='mysqli') { $testfunction='mysqli_connect'; $testclass=''; }
  264. if ($type=='pgsql') { $testfunction='pg_connect'; $testclass=''; }
  265. if ($type=='mssql') { $testfunction='mssql_connect'; $testclass=''; }
  266. if ($type=='sqlite') { $testfunction=''; $testclass='PDO'; }
  267. if ($type=='sqlite3') { $testfunction=''; $testclass='SQLite3'; }
  268. $option.='<option value="'.$type.'"'.($defaultype == $type?' selected':'');
  269. if ($testfunction && ! function_exists($testfunction)) $option.=' disabled';
  270. if ($testclass && ! class_exists($testclass)) $option.=' disabled';
  271. $option.='>';
  272. $option.=$type.'&nbsp; &nbsp;';
  273. if ($note) $option.=' '.$note;
  274. // Deprecated and experimental
  275. if ($type=='mysql') $option.=' ' . $langs->trans("Deprecated");
  276. elseif ($type=='mssql') $option.=' '.$langs->trans("VersionExperimental");
  277. elseif ($type=='sqlite') $option.=' '.$langs->trans("VersionExperimental");
  278. elseif ($type=='sqlite3') $option.=' '.$langs->trans("VersionExperimental");
  279. // No available
  280. elseif (! function_exists($testfunction)) $option.=' - '.$langs->trans("FunctionNotAvailableInThisPHP");
  281. $option.='</option>';
  282. }
  283. }
  284. }
  285. ?>
  286. <select id="db_type"
  287. name="db_type"
  288. <?php if ($force_install_noedit == 2 && $force_install_type !== null) {
  289. print ' disabled';
  290. } ?>
  291. >
  292. <?php print $option; ?>
  293. </select>
  294. </td>
  295. <td class="comment"><?php echo $langs->trans("DatabaseType"); ?></td>
  296. </tr>
  297. <tr class="hidesqlite">
  298. <td class="tdtop label"><b> <?php echo $langs->trans("DatabaseServer"); ?>
  299. </b></td>
  300. <td class="tdtop label">
  301. <input type="text"
  302. name="db_host"
  303. value="<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
  304. <?php if ($force_install_noedit == 2 && $force_install_dbserver !== null) {
  305. print ' disabled';
  306. } ?>
  307. >
  308. </td>
  309. <td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
  310. </td>
  311. </tr>
  312. <tr class="hidesqlite">
  313. <td class="tdtop label"><?php echo $langs->trans("Port"); ?></td>
  314. <td class="tdtop label">
  315. <input type="text"
  316. name="db_port"
  317. id="db_port"
  318. value="<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
  319. <?php if ($force_install_noedit == 2 && $force_install_port !== null) {
  320. print ' disabled';
  321. } ?>
  322. >
  323. </td>
  324. <td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
  325. </td>
  326. </tr>
  327. <tr class="hidesqlite">
  328. <td class="label tdtop"><?php echo $langs->trans("DatabasePrefix"); ?>
  329. </td>
  330. <td class="label tdtop">
  331. <input type="text" id="db_prefix"
  332. name="db_prefix"
  333. value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
  334. <?php if ($force_install_noedit == 2 && $force_install_prefix !== null) {
  335. print ' disabled';
  336. } ?>
  337. >
  338. </td>
  339. <td class="comment"><?php echo $langs->trans("DatabasePrefix"); ?></td>
  340. </tr>
  341. <tr class="hidesqlite">
  342. <td class="label tdtop"><?php echo $langs->trans("CreateDatabase"); ?>
  343. </td>
  344. <td class="label tdtop">
  345. <input type="checkbox"
  346. id="db_create_database"
  347. name="db_create_database"
  348. <?php if ($force_install_createdatabase) {
  349. print ' checked';
  350. } ?>
  351. <?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) {
  352. print ' disabled';
  353. } ?>
  354. >
  355. </td>
  356. <td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?>
  357. </td>
  358. </tr>
  359. <tr class="hidesqlite">
  360. <td class="label tdtop"><b><?php echo $langs->trans("Login"); ?></b>
  361. </td>
  362. <td class="label tdtop">
  363. <input type="text" id="db_user"
  364. name="db_user"
  365. value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
  366. <?php if ($force_install_noedit == 2 && $force_install_databaselogin !== null) {
  367. print ' disabled';
  368. } ?>
  369. >
  370. </td>
  371. <td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
  372. </tr>
  373. <tr class="hidesqlite">
  374. <td class="label tdtop"><b><?php echo $langs->trans("Password"); ?></b>
  375. </td>
  376. <td class="label tdtop">
  377. <input type="password" id="db_pass" autocomplete="off"
  378. name="db_pass"
  379. value="<?php
  380. // We don't want to set password. It will be extracted from the forced install file at step1.
  381. $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : '');
  382. if (!empty($dolibarr_main_prod)) {
  383. $autofill = '';
  384. }
  385. print dol_escape_htmltag($autofill);
  386. ?>"
  387. <?php if ($force_install_noedit == 2 && $force_install_databasepass !== null) {
  388. print ' disabled';
  389. } ?>
  390. >
  391. </td>
  392. <td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
  393. </tr>
  394. <tr class="hidesqlite">
  395. <td class="label tdtop"><?php echo $langs->trans("CreateUser"); ?>
  396. </td>
  397. <td class="label tdtop">
  398. <input type="checkbox"
  399. id="db_create_user" name="db_create_user"
  400. <?php if (!empty($force_install_createuser)) {
  401. print ' checked';
  402. } ?>
  403. <?php if ($force_install_noedit == 2 && $force_install_createuser !== null) {
  404. print ' disabled';
  405. } ?>
  406. >
  407. </td>
  408. <td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?>
  409. </td>
  410. </tr>
  411. <!-- Super access -->
  412. <?php
  413. $force_install_databaserootlogin = parse_database_login($force_install_databaserootlogin);
  414. $force_install_databaserootpass = parse_database_pass($force_install_databaserootpass);
  415. ?>
  416. <tr class="hidesqlite hideroot">
  417. <td colspan="3" class="label"><br>
  418. <h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/shield.svg" width="20" alt="webserver"> <?php echo $langs->trans("DatabaseSuperUserAccess"); ?></h3>
  419. </td>
  420. </tr>
  421. <tr class="hidesqlite hideroot">
  422. <td class="label tdtop"><b><?php echo $langs->trans("Login"); ?></b></td>
  423. <td class="label tdtop">
  424. <input type="text"
  425. id="db_user_root"
  426. name="db_user_root"
  427. class="needroot"
  428. value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>"
  429. <?php if ($force_install_noedit == 2 && $force_install_databaserootlogin !== null) {
  430. print ' disabled';
  431. } ?>
  432. >
  433. </td>
  434. <td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
  435. <!--
  436. <?php echo '<br>'.$langs->trans("Examples").':<br>' ?>
  437. <ul>
  438. <li>root (Mysql)</li>
  439. <li>postgres (PostgreSql)</li>
  440. </ul>
  441. </td>
  442. -->
  443. </tr>
  444. <tr class="hidesqlite hideroot">
  445. <td class="label tdtop"><b><?php echo $langs->trans("Password"); ?></b>
  446. </td>
  447. <td class="label tdtop">
  448. <input type="password"
  449. autocomplete="off"
  450. id="db_pass_root"
  451. name="db_pass_root"
  452. class="needroot"
  453. value="<?php
  454. // We don't want to set password. It will be extracted from the forced install file at step1.
  455. $autofill = ((!empty($force_install_database_rootpass)) ? '' : @$db_pass_root);
  456. if (!empty($dolibarr_main_prod)) {
  457. $autofill = '';
  458. } // Do not autofill password if instance is a production instance
  459. if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"],
  460. array('127.0.0.1', 'localhost'))
  461. ) {
  462. $autofill = '';
  463. } // Do not autofill password for remote access
  464. print dol_escape_htmltag($autofill);
  465. ?>"
  466. <?php if ($force_install_noedit == 2 && $force_install_databaserootpass !== null) {
  467. print ' disabled';
  468. } ?>
  469. >
  470. </td>
  471. <td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
  472. </td>
  473. </tr>
  474. </table>
  475. </div>
  476. <script type="text/javascript">
  477. jQuery(document).ready(function() {
  478. var dbtype = jQuery("#db_type");
  479. dbtype.change(function () {
  480. if (dbtype.val() == 'sqlite' || dbtype.val() == 'sqlite3') {
  481. jQuery(".hidesqlite").hide();
  482. } else {
  483. jQuery(".hidesqlite").show();
  484. }
  485. // Automatically set default database ports and admin user
  486. if (dbtype.val() == 'mysql' || dbtype.val() == 'mysqli') {
  487. jQuery("#db_port").val(3306);
  488. jQuery("#db_user_root").val('root');
  489. } else if (dbtype.val() == 'pgsql') {
  490. jQuery("#db_port").val(5432);
  491. jQuery("#db_user_root").val('postgres');
  492. } else if (dbtype.val() == 'mssql') {
  493. jQuery("#db_port").val(1433);
  494. jQuery("#db_user_root").val('sa');
  495. }
  496. });
  497. function init_needroot()
  498. {
  499. /*alert(jQuery("#db_create_database").prop("checked")); */
  500. if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
  501. {
  502. jQuery(".hideroot").show();
  503. jQuery(".needroot").removeAttr('disabled');
  504. }
  505. else
  506. {
  507. jQuery(".hideroot").hide();
  508. jQuery(".needroot").prop('disabled', true);
  509. }
  510. }
  511. init_needroot();
  512. jQuery("#db_create_database").click(function() {
  513. init_needroot();
  514. });
  515. jQuery("#db_create_user").click(function() {
  516. init_needroot();
  517. });
  518. <?php if ($force_install_noedit == 2 && empty($force_install_databasepass)) { ?>
  519. jQuery("#db_pass").focus();
  520. <?php } ?>
  521. });
  522. function checkDatabaseName(databasename) {
  523. if (databasename.match(/[;\.]/)) { return false; }
  524. return true;
  525. }
  526. function jscheckparam()
  527. {
  528. ok=true;
  529. if (document.forminstall.main_dir.value == '')
  530. {
  531. ok=false;
  532. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
  533. }
  534. else if (document.forminstall.main_data_dir.value == '')
  535. {
  536. ok=false;
  537. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
  538. }
  539. else if (document.forminstall.main_url.value == '')
  540. {
  541. ok=false;
  542. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("URLRoot"))); ?>');
  543. }
  544. else if (document.forminstall.db_host.value == '')
  545. {
  546. ok=false;
  547. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("Server"))); ?>');
  548. }
  549. else if (document.forminstall.db_name.value == '')
  550. {
  551. ok=false;
  552. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
  553. }
  554. else if (! checkDatabaseName(document.forminstall.db_name.value))
  555. {
  556. ok=false;
  557. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorSpecialCharNotAllowedForField",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
  558. }
  559. // If create database asked
  560. else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
  561. {
  562. ok=false;
  563. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
  564. }
  565. // If create user asked
  566. else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
  567. {
  568. ok=false;
  569. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
  570. }
  571. return ok;
  572. }
  573. </script>
  574. <?php
  575. // $db->close(); Not database connexion yet
  576. dolibarr_install_syslog("--- fileconf: end");
  577. pFooter($err,$setuplang,'jscheckparam');