fileconf.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. *
  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 information required to build Dolibarr htdocs/conf/conf.php file (will be written to disk on next page step1)
  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->loadLangs(array("install", "errors"));
  34. dolibarr_install_syslog("- fileconf: entering fileconf.php page");
  35. // You can force preselected values of the config step of Dolibarr by adding a file
  36. // install.forced.php into directory htdocs/install (This is the case with some wizard
  37. // installer like DoliWamp, DoliMamp or DoliBuntu).
  38. // We first init "forced values" to nothing.
  39. if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block vars specific to distrib, 2 to block all technical parameters
  40. if (! isset($force_install_type)) $force_install_type='';
  41. if (! isset($force_install_dbserver)) $force_install_dbserver='';
  42. if (! isset($force_install_port)) $force_install_port='';
  43. if (! isset($force_install_database)) $force_install_database='';
  44. if (! isset($force_install_prefix)) $force_install_prefix='';
  45. if (! isset($force_install_createdatabase)) $force_install_createdatabase='';
  46. if (! isset($force_install_databaselogin)) $force_install_databaselogin='';
  47. if (! isset($force_install_databasepass)) $force_install_databasepass='';
  48. if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin='';
  49. if (! isset($force_install_databaserootpass)) $force_install_databaserootpass='';
  50. // Now we load forced values from install.forced.php file.
  51. $useforcedwizard=false;
  52. $forcedfile="./install.forced.php";
  53. if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; // Must be after inc.php
  54. if (@file_exists($forcedfile)) {
  55. $useforcedwizard = true;
  56. include_once $forcedfile;
  57. }
  58. /*
  59. * View
  60. */
  61. session_start(); // To be able to keep info into session (used for not losing pass during navigation. pass must not transit through parmaeters)
  62. pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY)?'':$force_dolibarr_js_JQUERY.'/'), 'main-inside-bis');
  63. // Test if we can run a first install process
  64. if (! is_writable($conffile))
  65. {
  66. print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
  67. dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING);
  68. dolibarr_install_syslog("- fileconf: end");
  69. pFooter(1,$setuplang,'jscheckparam');
  70. exit;
  71. }
  72. if (! empty($force_install_message))
  73. {
  74. print '<div><br>'.$langs->trans($force_install_message).'</div>';
  75. /*print '<script type="text/javascript">';
  76. print ' jQuery(document).ready(function() {
  77. jQuery("#linktoshowtechnicalparam").click(function() {
  78. jQuery(".hidewhenedit").hide();
  79. jQuery(".hidewhennoedit").show();
  80. });';
  81. if ($force_install_noedit) print 'jQuery(".hidewhennoedit").hide();';
  82. print '});';
  83. print '</script>';
  84. print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">'.$langs->trans("ShowEditTechnicalParameters").'</a><br>';
  85. */
  86. }
  87. ?>
  88. <div>
  89. <table class="nobordernopadding<?php if ($force_install_noedit) print ' hidewhennoedit'; ?>">
  90. <tr>
  91. <td colspan="3" class="label">
  92. <h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/globe.svg" width="20" alt="webserver"> <?php echo $langs->trans("WebServer"); ?></h3>
  93. </td>
  94. </tr>
  95. <!-- Documents root $dolibarr_main_document_root -->
  96. <tr>
  97. <td class="label"><label for="main_dir"><b><?php print $langs->trans("WebPagesDirectory"); ?></b></label></td>
  98. <?php
  99. if (empty($dolibarr_main_url_root)) {
  100. $dolibarr_main_document_root = detect_dolibarr_main_document_root();
  101. }
  102. ?>
  103. <td class="label">
  104. <input type="text"
  105. class="minwidth300"
  106. id="main_dir"
  107. name="main_dir"
  108. value="<?php print $dolibarr_main_document_root ?>"
  109. <?php if (!empty($force_install_noedit)) {
  110. print ' disabled';
  111. } ?>
  112. >
  113. </td>
  114. <td class="comment"><?php
  115. print $langs->trans("WithNoSlashAtTheEnd")."<br>";
  116. print $langs->trans("Examples").":<br>";
  117. ?>
  118. <ul>
  119. <li>/var/www/dolibarr/htdocs</li>
  120. <li>C:/wwwroot/dolibarr/htdocs</li>
  121. </ul>
  122. </td>
  123. </tr>
  124. <!-- Documents URL $dolibarr_main_data_root -->
  125. <tr>
  126. <td class="label"><label for="main_data_dir"><b><?php print $langs->trans("DocumentsDirectory"); ?></b></label></td>
  127. <?php
  128. $dolibarr_main_data_root = @$force_install_main_data_root;
  129. if (empty($dolibarr_main_data_root)) {
  130. $dolibarr_main_data_root = detect_dolibarr_main_data_root($dolibarr_main_document_root);
  131. }
  132. ?>
  133. <td class="label">
  134. <input type="text"
  135. class="minwidth300"
  136. id="main_data_dir"
  137. name="main_data_dir"
  138. value="<?php print $dolibarr_main_data_root ?>"
  139. <?php if (!empty($force_install_noedit)) {
  140. print ' disabled';
  141. } ?>
  142. >
  143. </td>
  144. <td class="comment"><?php
  145. print $langs->trans("WithNoSlashAtTheEnd")."<br>";
  146. print $langs->trans("DirectoryRecommendation")."<br>";
  147. print $langs->trans("Examples").":<br>";
  148. ?>
  149. <ul>
  150. <li>/var/lib/dolibarr/documents</li>
  151. <li>C:/My Documents/dolibarr/documents</li>
  152. </ul>
  153. </td>
  154. </tr>
  155. <!-- Root URL $dolibarr_main_url_root -->
  156. <?php
  157. if (empty($dolibarr_main_url_root)) {
  158. $dolibarr_main_url_root = detect_dolibarr_main_url_root();
  159. }
  160. ?>
  161. <tr>
  162. <td class="label"><label for="main_url"><b><?php echo $langs->trans("URLRoot"); ?></b></label>
  163. </td>
  164. <td class="label">
  165. <input type="text"
  166. class="minwidth300"
  167. id="main_url"
  168. name="main_url"
  169. value="<?php print $dolibarr_main_url_root; ?> "
  170. <?php if (!empty($force_install_noedit)) {
  171. print ' disabled';
  172. } ?>
  173. >
  174. </td>
  175. <td class="comment"><?php print $langs->trans("Examples").":<br>"; ?>
  176. <ul>
  177. <li>http://localhost/</li>
  178. <li>http://www.myserver.com:8180/dolibarr</li>
  179. <li>https://www.myvirtualfordolibarr.com/</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="label"><label for="main_force_https"><?php echo $langs->trans("ForceHttps"); ?></label></td>
  188. <td class="label">
  189. <input type="checkbox"
  190. id="main_force_https"
  191. name="main_force_https"
  192. <?php if (!empty($force_install_mainforcehttps)) {
  193. print ' checked';
  194. } ?>
  195. <?php if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) {
  196. print ' disabled';
  197. } ?>
  198. >
  199. </td>
  200. <td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
  201. </td>
  202. </tr>
  203. <?php
  204. }
  205. ?>
  206. <!-- Dolibarr database -->
  207. <tr>
  208. <td colspan="3" class="label"><br>
  209. <h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="webserver"> <?php echo $langs->trans("DolibarrDatabase"); ?></h3>
  210. </td>
  211. </tr>
  212. <tr>
  213. <td class="label"><label for="db_name"><b><?php echo $langs->trans("DatabaseName"); ?></b></label></td>
  214. <td class="label">
  215. <input type="text"
  216. id="db_name"
  217. name="db_name"
  218. value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
  219. <?php if ($force_install_noedit == 2 && $force_install_database !== null) {
  220. print ' disabled';
  221. } ?>
  222. >
  223. </td>
  224. <td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
  225. </tr>
  226. <?php
  227. if (!isset($dolibarr_main_db_host))
  228. {
  229. $dolibarr_main_db_host = "localhost";
  230. }
  231. ?>
  232. <tr>
  233. <!-- Driver type -->
  234. <td class="label"><label for="db_type"><b><?php echo $langs->trans("DriverType"); ?></b></label></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="label"><label for="db_host"><b><?php echo $langs->trans("DatabaseServer"); ?></b></label></td>
  299. <td class="label">
  300. <input type="text"
  301. id="db_host"
  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="label"><label for="db_port"><?php echo $langs->trans("Port"); ?></label></td>
  314. <td class="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"><label for="db_prefix"><?php echo $langs->trans("DatabasePrefix"); ?></label></td>
  329. <td class="label">
  330. <input type="text"
  331. 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("DatabasePrefixDescription"); ?></td>
  340. </tr>
  341. <tr class="hidesqlite">
  342. <td class="label"><label for="db_create_database"><?php echo $langs->trans("CreateDatabase"); ?></label></td>
  343. <td class="label">
  344. <input type="checkbox"
  345. id="db_create_database"
  346. name="db_create_database"
  347. <?php if ($force_install_createdatabase) {
  348. print ' checked';
  349. } ?>
  350. <?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) {
  351. print ' disabled';
  352. } ?>
  353. >
  354. </td>
  355. <td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?>
  356. </td>
  357. </tr>
  358. <tr class="hidesqlite">
  359. <td class="label"><label for="db_user"><b><?php echo $langs->trans("Login"); ?></b></label></td>
  360. <td class="label">
  361. <input type="text"
  362. id="db_user"
  363. name="db_user"
  364. value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
  365. <?php if ($force_install_noedit == 2 && $force_install_databaselogin !== null) {
  366. print ' disabled';
  367. } ?>
  368. >
  369. </td>
  370. <td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
  371. </tr>
  372. <tr class="hidesqlite">
  373. <td class="label"><label for="db_pass"><b><?php echo $langs->trans("Password"); ?></b></label></td>
  374. <td class="label">
  375. <input type="password"
  376. id="db_pass" autocomplete="off"
  377. name="db_pass"
  378. value="<?php
  379. // 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.
  380. $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
  381. if (!empty($dolibarr_main_prod)) {
  382. $autofill = '';
  383. }
  384. print dol_escape_htmltag($autofill);
  385. ?>"
  386. <?php if ($force_install_noedit == 2 && $force_install_databasepass !== null) {
  387. print ' disabled';
  388. } ?>
  389. >
  390. </td>
  391. <td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
  392. </tr>
  393. <tr class="hidesqlite">
  394. <td class="label"><label for="db_create_user"><?php echo $langs->trans("CreateUser"); ?></label></td>
  395. <td class="label">
  396. <input type="checkbox"
  397. id="db_create_user"
  398. name="db_create_user"
  399. <?php if (!empty($force_install_createuser)) {
  400. print ' checked';
  401. } ?>
  402. <?php if ($force_install_noedit == 2 && $force_install_createuser !== null) {
  403. print ' disabled';
  404. } ?>
  405. >
  406. </td>
  407. <td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?>
  408. </td>
  409. </tr>
  410. <!-- Super access -->
  411. <?php
  412. $force_install_databaserootlogin = parse_database_login($force_install_databaserootlogin);
  413. $force_install_databaserootpass = parse_database_pass($force_install_databaserootpass);
  414. ?>
  415. <tr class="hidesqlite hideroot">
  416. <td colspan="3" class="label"><br>
  417. <h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/shield.svg" width="20" alt="webserver"> <?php echo $langs->trans("DatabaseSuperUserAccess"); ?></h3>
  418. </td>
  419. </tr>
  420. <tr class="hidesqlite hideroot">
  421. <td class="label"><label for="db_user_root"><b><?php echo $langs->trans("Login"); ?></b></label></td>
  422. <td class="label">
  423. <input type="text"
  424. id="db_user_root"
  425. name="db_user_root"
  426. class="needroot"
  427. value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>"
  428. <?php if ($force_install_noedit > 0 && ! empty($force_install_databaserootlogin)) {
  429. print ' disabled';
  430. } ?>
  431. >
  432. </td>
  433. <td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
  434. <!--
  435. <?php echo '<br>'.$langs->trans("Examples").':<br>' ?>
  436. <ul>
  437. <li>root (Mysql)</li>
  438. <li>postgres (PostgreSql)</li>
  439. </ul>
  440. </td>
  441. -->
  442. </tr>
  443. <tr class="hidesqlite hideroot">
  444. <td class="label"><label for="db_pass_root"><b><?php echo $langs->trans("Password"); ?></b></label></td>
  445. <td class="label">
  446. <input type="password"
  447. autocomplete="off"
  448. id="db_pass_root"
  449. name="db_pass_root"
  450. class="needroot"
  451. value="<?php
  452. // 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.
  453. $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : @$db_pass_root);
  454. if (!empty($dolibarr_main_prod)) {
  455. $autofill = '';
  456. }
  457. // Do not autofill password if instance is a production instance
  458. if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"],
  459. array('127.0.0.1', 'localhost', 'localhostgit'))
  460. ) {
  461. $autofill = '';
  462. } // Do not autofill password for remote access
  463. print dol_escape_htmltag($autofill);
  464. ?>"
  465. <?php if ($force_install_noedit > 0 && ! empty($force_install_databaserootpass)) {
  466. print ' disabled'; // May be removed by javascript
  467. } ?>
  468. >
  469. </td>
  470. <td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
  471. </td>
  472. </tr>
  473. </table>
  474. </div>
  475. <script type="text/javascript">
  476. jQuery(document).ready(function() {
  477. var dbtype = jQuery("#db_type");
  478. dbtype.change(function () {
  479. if (dbtype.val() == 'sqlite' || dbtype.val() == 'sqlite3') {
  480. jQuery(".hidesqlite").hide();
  481. } else {
  482. jQuery(".hidesqlite").show();
  483. }
  484. // Automatically set default database ports and admin user
  485. if (dbtype.val() == 'mysql' || dbtype.val() == 'mysqli') {
  486. jQuery("#db_port").val(3306);
  487. jQuery("#db_user_root").val('root');
  488. } else if (dbtype.val() == 'pgsql') {
  489. jQuery("#db_port").val(5432);
  490. jQuery("#db_user_root").val('postgres');
  491. } else if (dbtype.val() == 'mssql') {
  492. jQuery("#db_port").val(1433);
  493. jQuery("#db_user_root").val('sa');
  494. }
  495. });
  496. function init_needroot()
  497. {
  498. /*alert(jQuery("#db_create_database").prop("checked")); */
  499. if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
  500. {
  501. jQuery(".hideroot").show();
  502. <?php
  503. if ($force_install_noedit == 0) { ?>
  504. jQuery(".needroot").removeAttr('disabled');
  505. <?php } ?>
  506. }
  507. else
  508. {
  509. jQuery(".hideroot").hide();
  510. jQuery(".needroot").prop('disabled', true);
  511. }
  512. }
  513. init_needroot();
  514. jQuery("#db_create_database").click(function() {
  515. init_needroot();
  516. });
  517. jQuery("#db_create_user").click(function() {
  518. init_needroot();
  519. });
  520. <?php if ($force_install_noedit == 2 && empty($force_install_databasepass)) { ?>
  521. jQuery("#db_pass").focus();
  522. <?php } ?>
  523. });
  524. function checkDatabaseName(databasename) {
  525. if (databasename.match(/[;\.]/)) { return false; }
  526. return true;
  527. }
  528. function jscheckparam()
  529. {
  530. ok=true;
  531. if (document.forminstall.main_dir.value == '')
  532. {
  533. ok=false;
  534. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
  535. }
  536. else if (document.forminstall.main_data_dir.value == '')
  537. {
  538. ok=false;
  539. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
  540. }
  541. else if (document.forminstall.main_url.value == '')
  542. {
  543. ok=false;
  544. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("URLRoot"))); ?>');
  545. }
  546. else if (document.forminstall.db_host.value == '')
  547. {
  548. ok=false;
  549. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("Server"))); ?>');
  550. }
  551. else if (document.forminstall.db_name.value == '')
  552. {
  553. ok=false;
  554. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
  555. }
  556. else if (! checkDatabaseName(document.forminstall.db_name.value))
  557. {
  558. ok=false;
  559. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorSpecialCharNotAllowedForField",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
  560. }
  561. // If create database asked
  562. else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
  563. {
  564. ok=false;
  565. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
  566. }
  567. // If create user asked
  568. else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
  569. {
  570. ok=false;
  571. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
  572. }
  573. return ok;
  574. }
  575. </script>
  576. <?php
  577. // $db->close(); Not database connexion yet
  578. dolibarr_install_syslog("- fileconf: end");
  579. pFooter($err,$setuplang,'jscheckparam');