step1.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. <?php
  2. /* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  5. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  6. * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
  7. * Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/install/step1.php
  24. * \ingroup install
  25. * \brief Build conf file on disk
  26. */
  27. define('DONOTLOADCONF', 1); // To avoid loading conf by file inc.php
  28. include 'inc.php';
  29. global $langs;
  30. $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]);
  31. $setuplang = GETPOST('selectlang', 'aZ09', 3) ?GETPOST('selectlang', 'aZ09', 3) : (empty($argv[2]) ? 'auto' : $argv[2]);
  32. $langs->setDefaultLang($setuplang);
  33. $langs->loadLangs(array("admin", "install", "errors"));
  34. // Dolibarr pages directory
  35. $main_dir = GETPOST('main_dir') ?GETPOST('main_dir') : (empty($argv[3]) ? '' : $argv[3]);
  36. // Directory for generated documents (invoices, orders, ecm, etc...)
  37. $main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : (empty($argv[4]) ? ($main_dir.'/documents') : $argv[4]);
  38. // Dolibarr root URL
  39. $main_url = GETPOST('main_url') ?GETPOST('main_url') : (empty($argv[5]) ? '' : $argv[5]);
  40. // Database login information
  41. $userroot = GETPOST('db_user_root', 'alpha') ?GETPOST('db_user_root', 'alpha') : (empty($argv[6]) ? '' : $argv[6]);
  42. $passroot = GETPOST('db_pass_root', 'none') ?GETPOST('db_pass_root', 'none') : (empty($argv[7]) ? '' : $argv[7]);
  43. // Database server
  44. $db_type = GETPOST('db_type', 'aZ09') ?GETPOST('db_type', 'aZ09') : (empty($argv[8]) ? '' : $argv[8]);
  45. $db_host = GETPOST('db_host', 'alpha') ?GETPOST('db_host', 'alpha') : (empty($argv[9]) ? '' : $argv[9]);
  46. $db_name = GETPOST('db_name', 'aZ09') ?GETPOST('db_name', 'aZ09') : (empty($argv[10]) ? '' : $argv[10]);
  47. $db_user = GETPOST('db_user', 'alpha') ?GETPOST('db_user', 'alpha') : (empty($argv[11]) ? '' : $argv[11]);
  48. $db_pass = GETPOST('db_pass', 'none') ?GETPOST('db_pass', 'none') : (empty($argv[12]) ? '' : $argv[12]);
  49. $db_port = GETPOST('db_port', 'int') ?GETPOST('db_port', 'int') : (empty($argv[13]) ? '' : $argv[13]);
  50. $db_prefix = GETPOST('db_prefix', 'aZ09') ?GETPOST('db_prefix', 'aZ09') : (empty($argv[14]) ? '' : $argv[14]);
  51. $db_create_database = GETPOST('db_create_database', 'alpha') ?GETPOST('db_create_database', 'alpha') : (empty($argv[15]) ? '' : $argv[15]);
  52. $db_create_user = GETPOST('db_create_user', 'alpha') ?GETPOST('db_create_user', 'alpha') : (empty($argv[16]) ? '' : $argv[16]);
  53. // Force https
  54. $main_force_https = ((GETPOST("main_force_https", 'alpha') && (GETPOST("main_force_https", 'alpha') == "on" || GETPOST("main_force_https", 'alpha') == 1)) ? '1' : '0');
  55. // Use alternative directory
  56. $main_use_alt_dir = ((GETPOST("main_use_alt_dir", 'alpha') == '' || (GETPOST("main_use_alt_dir", 'alpha') == "on" || GETPOST("main_use_alt_dir", 'alpha') == 1)) ? '' : '//');
  57. // Alternative root directory name
  58. $main_alt_dir_name = ((GETPOST("main_alt_dir_name", 'alpha') && GETPOST("main_alt_dir_name", 'alpha') != '') ? GETPOST("main_alt_dir_name", 'alpha') : 'custom');
  59. $dolibarr_main_distrib = 'standard';
  60. session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters)
  61. // Save a flag to tell to restore input value if we go back
  62. $_SESSION['dol_save_pass'] = $db_pass;
  63. //$_SESSION['dol_save_passroot']=$passroot;
  64. // Now we load forced values from install.forced.php file.
  65. $useforcedwizard = false;
  66. $forcedfile = "./install.forced.php";
  67. if ($conffile == "/etc/dolibarr/conf.php") {
  68. $forcedfile = "/etc/dolibarr/install.forced.php";
  69. }
  70. if (@file_exists($forcedfile)) {
  71. $useforcedwizard = true;
  72. include_once $forcedfile;
  73. // If forced install is enabled, replace the post values. These are empty because form fields are disabled.
  74. if ($force_install_noedit) {
  75. $main_dir = detect_dolibarr_main_document_root();
  76. if (!empty($argv[1])) {
  77. $main_dir = $argv[1]; // override when executing the script in command line
  78. }
  79. if (!empty($force_install_main_data_root)) {
  80. $main_data_dir = $force_install_main_data_root;
  81. } else {
  82. $main_data_dir = detect_dolibarr_main_data_root($main_dir);
  83. }
  84. $main_url = detect_dolibarr_main_url_root();
  85. if (!empty($force_install_databaserootlogin)) {
  86. $userroot = parse_database_login($force_install_databaserootlogin);
  87. }
  88. if (!empty($force_install_databaserootpass)) {
  89. $passroot = parse_database_pass($force_install_databaserootpass);
  90. }
  91. }
  92. if ($force_install_noedit == 2) {
  93. if (!empty($force_install_type)) {
  94. $db_type = $force_install_type;
  95. }
  96. if (!empty($force_install_dbserver)) {
  97. $db_host = $force_install_dbserver;
  98. }
  99. if (!empty($force_install_database)) {
  100. $db_name = $force_install_database;
  101. }
  102. if (!empty($force_install_databaselogin)) {
  103. $db_user = $force_install_databaselogin;
  104. }
  105. if (!empty($force_install_databasepass)) {
  106. $db_pass = $force_install_databasepass;
  107. }
  108. if (!empty($force_install_port)) {
  109. $db_port = $force_install_port;
  110. }
  111. if (!empty($force_install_prefix)) {
  112. $db_prefix = $force_install_prefix;
  113. }
  114. if (!empty($force_install_createdatabase)) {
  115. $db_create_database = $force_install_createdatabase;
  116. }
  117. if (!empty($force_install_createuser)) {
  118. $db_create_user = $force_install_createuser;
  119. }
  120. if (!empty($force_install_mainforcehttps)) {
  121. $main_force_https = $force_install_mainforcehttps;
  122. }
  123. }
  124. if (!empty($force_install_distrib)) {
  125. $dolibarr_main_distrib = $force_install_distrib;
  126. }
  127. }
  128. $error = 0;
  129. /*
  130. * View
  131. */
  132. dolibarr_install_syslog("--- step1: entering step1.php page");
  133. pHeader($langs->trans("ConfigurationFile"), "step2");
  134. // Test if we can run a first install process
  135. if (!is_writable($conffile)) {
  136. print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
  137. pFooter(1, $setuplang, 'jscheckparam');
  138. exit;
  139. }
  140. // Check parameters
  141. $is_sqlite = false;
  142. if (empty($db_type)) {
  143. print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseType")).'</div>';
  144. $error++;
  145. } else {
  146. $is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3');
  147. }
  148. if (empty($db_host) && !$is_sqlite) {
  149. print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Server")).'</div>';
  150. $error++;
  151. }
  152. if (empty($db_name)) {
  153. print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseName")).'</div>';
  154. $error++;
  155. }
  156. if (empty($db_user) && !$is_sqlite) {
  157. print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")).'</div>';
  158. $error++;
  159. }
  160. if (!empty($db_port) && !is_numeric($db_port)) {
  161. print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $db_port, $langs->transnoentities("Port")).'</div>';
  162. $error++;
  163. }
  164. if (!empty($db_prefix) && !preg_match('/^[a-z0-9]+_$/i', $db_prefix)) {
  165. print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $db_prefix, $langs->transnoentities("DatabasePrefix")).'</div>';
  166. $error++;
  167. }
  168. // Remove last / into dans main_dir
  169. if (substr($main_dir, dol_strlen($main_dir) - 1) == "/") {
  170. $main_dir = substr($main_dir, 0, dol_strlen($main_dir) - 1);
  171. }
  172. // Remove last / into dans main_url
  173. if (!empty($main_url) && substr($main_url, dol_strlen($main_url) - 1) == "/") {
  174. $main_url = substr($main_url, 0, dol_strlen($main_url) - 1);
  175. }
  176. if (!dol_is_dir($main_dir.'/core/db/')) {
  177. print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $main_dir, $langs->transnoentitiesnoconv("WebPagesDirectory")).'</div>';
  178. print '<br>';
  179. //print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  180. print $langs->trans("ErrorGoBackAndCorrectParameters");
  181. $error++;
  182. }
  183. // Test database connection
  184. if (!$error) {
  185. $result = @include_once $main_dir."/core/db/".$db_type.'.class.php';
  186. if ($result) {
  187. // If we require database or user creation we need to connect as root, so we need root login credentials
  188. if (!empty($db_create_database) && !$userroot) {
  189. print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).'</div>';
  190. print '<br>';
  191. print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  192. print $langs->trans("ErrorGoBackAndCorrectParameters");
  193. $error++;
  194. }
  195. if (!empty($db_create_user) && !$userroot) {
  196. print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect", $db_user).'</div>';
  197. print '<br>';
  198. print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  199. print $langs->trans("ErrorGoBackAndCorrectParameters");
  200. $error++;
  201. }
  202. // If we need root access
  203. if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
  204. $databasefortest = $db_name;
  205. if (!empty($db_create_database)) {
  206. if ($db_type == 'mysql' || $db_type == 'mysqli') {
  207. $databasefortest = 'mysql';
  208. } elseif ($db_type == 'pgsql') {
  209. $databasefortest = 'postgres';
  210. } else {
  211. $databasefortest = 'master';
  212. }
  213. }
  214. $db = getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port);
  215. dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
  216. //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
  217. if (empty($db_create_database) && $db->connected && !$db->database_selected) {
  218. print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound", $db_name).'</div>';
  219. print '<br>';
  220. if (!$db->connected) {
  221. print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
  222. }
  223. print $langs->trans("ErrorGoBackAndCorrectParameters");
  224. $error++;
  225. } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
  226. // Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
  227. if ($db->error == "No such file or directory") {
  228. print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
  229. } else {
  230. print '<div class="error">'.$db->error.'</div>';
  231. }
  232. if (!$db->connected) {
  233. print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  234. }
  235. //print '<a href="#" onClick="javascript: history.back();">';
  236. print $langs->trans("ErrorGoBackAndCorrectParameters");
  237. //print '</a>';
  238. $error++;
  239. }
  240. }
  241. // If we need simple access
  242. if (!$error && (empty($db_create_database) && empty($db_create_user))) {
  243. $db = getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
  244. if ($db->error) {
  245. print '<div class="error">'.$db->error.'</div>';
  246. if (!$db->connected) {
  247. print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  248. }
  249. //print '<a href="#" onClick="javascript: history.back();">';
  250. print $langs->trans("ErrorGoBackAndCorrectParameters");
  251. //print '</a>';
  252. $error++;
  253. }
  254. }
  255. } else {
  256. print "<br>\nFailed to include_once(\"".$main_dir."/core/db/".$db_type.".class.php\")<br>\n";
  257. print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter", $langs->transnoentities("WebPagesDirectory")).'</div>';
  258. //print '<a href="#" onClick="javascript: history.back();">';
  259. print $langs->trans("ErrorGoBackAndCorrectParameters");
  260. //print '</a>';
  261. $error++;
  262. }
  263. } else {
  264. if (isset($db)) {
  265. print $db->lasterror();
  266. }
  267. if (isset($db) && !$db->connected) {
  268. print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  269. }
  270. print $langs->trans("ErrorGoBackAndCorrectParameters");
  271. $error++;
  272. }
  273. if (!$error && $db->connected) {
  274. if (!empty($db_create_database)) {
  275. $result = $db->select_db($db_name);
  276. if ($result) {
  277. print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'</div>';
  278. print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
  279. print $langs->trans("ErrorGoBackAndCorrectParameters");
  280. $error++;
  281. }
  282. }
  283. }
  284. // Define $defaultCharacterSet and $defaultDBSortingCollation
  285. if (!$error && $db->connected) {
  286. if (!empty($db_create_database)) { // If we create database, we force default value
  287. // Default values come from the database handler
  288. $defaultCharacterSet = $db->forcecharset;
  289. $defaultDBSortingCollation = $db->forcecollate;
  290. } else // If already created, we take current value
  291. {
  292. $defaultCharacterSet = $db->getDefaultCharacterSetDatabase();
  293. $defaultDBSortingCollation = $db->getDefaultCollationDatabase();
  294. }
  295. // Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
  296. // TODO Remove this when utf8mb4 is supported
  297. if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci') {
  298. $defaultCharacterSet = 'utf8';
  299. $defaultDBSortingCollation = 'utf8_unicode_ci';
  300. }
  301. print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
  302. print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.'">';
  303. $db_character_set = $defaultCharacterSet;
  304. $db_collation = $defaultDBSortingCollation;
  305. dolibarr_install_syslog("step1: db_character_set=".$db_character_set." db_collation=".$db_collation);
  306. }
  307. // Create config file
  308. if (!$error && $db->connected && $action == "set") {
  309. umask(0);
  310. if (is_array($_POST)) {
  311. foreach ($_POST as $key => $value) {
  312. if (!preg_match('/^db_pass/i', $key)) {
  313. dolibarr_install_syslog("step1: choice for ".$key." = ".$value);
  314. }
  315. }
  316. }
  317. // Show title of step
  318. print '<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans("ConfigurationFile").'</h3>';
  319. print '<table cellspacing="0" width="100%" cellpadding="1" border="0">';
  320. // Check parameter main_dir
  321. if (!$error) {
  322. if (!is_dir($main_dir)) {
  323. dolibarr_install_syslog("step1: directory '".$main_dir."' is unavailable or can't be accessed");
  324. print "<tr><td>";
  325. print $langs->trans("ErrorDirDoesNotExists", $main_dir).'<br>';
  326. print $langs->trans("ErrorWrongValueForParameter", $langs->transnoentitiesnoconv("WebPagesDirectory")).'<br>';
  327. print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
  328. print '</td><td>';
  329. print $langs->trans("Error");
  330. print "</td></tr>";
  331. $error++;
  332. }
  333. }
  334. if (!$error) {
  335. dolibarr_install_syslog("step1: directory '".$main_dir."' exists");
  336. }
  337. // Create subdirectory main_data_dir
  338. if (!$error) {
  339. // Create directory for documents
  340. if (!is_dir($main_data_dir)) {
  341. dol_mkdir($main_data_dir);
  342. }
  343. if (!is_dir($main_data_dir)) {
  344. print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
  345. print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
  346. print '</td><td>';
  347. print '<span class="error">'.$langs->trans("Error").'</span>';
  348. print "</td></tr>";
  349. print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
  350. $error++;
  351. } else {
  352. // Create .htaccess file in document directory
  353. $pathhtaccess = $main_data_dir.'/.htaccess';
  354. if (!file_exists($pathhtaccess)) {
  355. dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '".$main_data_dir."'");
  356. $handlehtaccess = @fopen($pathhtaccess, 'w');
  357. if ($handlehtaccess) {
  358. fwrite($handlehtaccess, 'Order allow,deny'."\n");
  359. fwrite($handlehtaccess, 'Deny from all'."\n");
  360. fclose($handlehtaccess);
  361. dolibarr_install_syslog("step1: .htaccess file created");
  362. }
  363. }
  364. // Documents are stored above the web pages root to prevent being downloaded without authentification
  365. $dir = array();
  366. $dir[] = $main_data_dir."/mycompany";
  367. $dir[] = $main_data_dir."/medias";
  368. $dir[] = $main_data_dir."/users";
  369. $dir[] = $main_data_dir."/facture";
  370. $dir[] = $main_data_dir."/propale";
  371. $dir[] = $main_data_dir."/ficheinter";
  372. $dir[] = $main_data_dir."/produit";
  373. $dir[] = $main_data_dir."/doctemplates";
  374. // Loop on each directory of dir [] to create them if they do not exist
  375. $num = count($dir);
  376. for ($i = 0; $i < $num; $i++) {
  377. if (is_dir($dir[$i])) {
  378. dolibarr_install_syslog("step1: directory '".$dir[$i]."' exists");
  379. } else {
  380. if (dol_mkdir($dir[$i]) < 0) {
  381. print "<tr><td>";
  382. print "Failed to create directory: ".$dir[$i];
  383. print '</td><td>';
  384. print $langs->trans("Error");
  385. print "</td></tr>";
  386. $error++;
  387. } else {
  388. dolibarr_install_syslog("step1: directory '".$dir[$i]."' created");
  389. }
  390. }
  391. }
  392. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  393. // Copy directory medias
  394. $srcroot = $main_dir.'/install/medias';
  395. $destroot = $main_data_dir.'/medias';
  396. dolCopyDir($srcroot, $destroot, 0, 0);
  397. if ($error) {
  398. print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
  399. print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
  400. print '</td><td>';
  401. print '<span class="error">'.$langs->trans("Error").'</span>';
  402. print "</td></tr>";
  403. print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
  404. } else {
  405. //ODT templates
  406. $srcroot = $main_dir.'/install/doctemplates';
  407. $destroot = $main_data_dir.'/doctemplates';
  408. $docs = array(
  409. 'contracts' => 'contract',
  410. 'invoices' => 'invoice',
  411. 'orders' => 'order',
  412. 'products' => 'product',
  413. 'projects' => 'project',
  414. 'proposals' => 'proposal',
  415. 'shipments' => 'shipment',
  416. 'supplier_proposals' => 'supplier_proposal',
  417. 'tasks' => 'task_summary',
  418. 'thirdparties' => 'thirdparty',
  419. 'usergroups' => 'usergroups',
  420. 'users' => 'user',
  421. );
  422. foreach ($docs as $cursordir => $cursorfile) {
  423. $src = $srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
  424. $dirodt = $destroot.'/'.$cursordir;
  425. $dest = $dirodt.'/template_'.$cursorfile.'.odt';
  426. dol_mkdir($dirodt);
  427. $result = dol_copy($src, $dest, 0, 0);
  428. if ($result < 0) {
  429. print '<tr><td colspan="2"><br>'.$langs->trans('ErrorFailToCopyFile', $src, $dest).'</td></tr>';
  430. }
  431. }
  432. }
  433. }
  434. }
  435. // Table prefix
  436. $main_db_prefix = (!empty($db_prefix) ? $db_prefix : 'llx_');
  437. // Write conf file on disk
  438. if (!$error) {
  439. // Save old conf file on disk
  440. if (file_exists("$conffile")) {
  441. // We must ignore errors as an existing old file may already exist and not be replaceable or
  442. // the installer (like for ubuntu) may not have permission to create another file than conf.php.
  443. // Also no other process must be able to read file or we expose the new file, so content with password.
  444. @dol_copy($conffile, $conffile.'.old', '0400');
  445. }
  446. $error += write_conf_file($conffile);
  447. }
  448. // Create database and admin user database
  449. if (!$error) {
  450. // We reload configuration file
  451. conf($dolibarr_main_document_root);
  452. print '<tr><td>';
  453. print $langs->trans("ConfFileReload");
  454. print '</td>';
  455. print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  456. // Create database user if requested
  457. if (isset($db_create_user) && ($db_create_user == "1" || $db_create_user == "on")) {
  458. dolibarr_install_syslog("step1: create database user: ".$dolibarr_main_db_user);
  459. //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
  460. $databasefortest = $conf->db->name;
  461. if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') {
  462. $databasefortest = 'mysql';
  463. } elseif ($conf->db->type == 'pgsql') {
  464. $databasefortest = 'postgres';
  465. } elseif ($conf->db->type == 'mssql') {
  466. $databasefortest = 'master';
  467. }
  468. // Check database connection
  469. $db = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, $conf->db->port);
  470. if ($db->error) {
  471. print '<div class="error">'.$db->error.'</div>';
  472. $error++;
  473. }
  474. if (!$error) {
  475. if ($db->connected) {
  476. $resultbis = 1;
  477. if (empty($dolibarr_main_db_pass)) {
  478. dolibarr_install_syslog("step1: failed to create user, password is empty", LOG_ERR);
  479. print '<tr><td>';
  480. print $langs->trans("UserCreation").' : ';
  481. print $dolibarr_main_db_user;
  482. print '</td>';
  483. print '<td>'.$langs->trans("Error").": A password for database user is mandatory.</td></tr>";
  484. } else {
  485. // Create user
  486. $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
  487. // Create user bis
  488. if ($databasefortest == 'mysql') {
  489. if (!in_array($dolibarr_main_db_host, array('127.0.0.1', '::1', 'localhost', 'localhost.local'))) {
  490. $resultbis = $db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
  491. }
  492. }
  493. if ($result > 0 && $resultbis > 0) {
  494. print '<tr><td>';
  495. print $langs->trans("UserCreation").' : ';
  496. print $dolibarr_main_db_user;
  497. print '</td>';
  498. print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  499. } else {
  500. if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
  501. || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
  502. || $db->errno() == 'DB_ERROR_USER_ALREADY_EXISTS') {
  503. dolibarr_install_syslog("step1: user already exists");
  504. print '<tr><td>';
  505. print $langs->trans("UserCreation").' : ';
  506. print $dolibarr_main_db_user;
  507. print '</td>';
  508. print '<td>'.$langs->trans("LoginAlreadyExists").'</td></tr>';
  509. } else {
  510. dolibarr_install_syslog("step1: failed to create user", LOG_ERR);
  511. print '<tr><td>';
  512. print $langs->trans("UserCreation").' : ';
  513. print $dolibarr_main_db_user;
  514. print '</td>';
  515. print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error().($db->error ? '. '.$db->error : '')."</td></tr>";
  516. }
  517. }
  518. }
  519. $db->close();
  520. } else {
  521. print '<tr><td>';
  522. print $langs->trans("UserCreation").' : ';
  523. print $dolibarr_main_db_user;
  524. print '</td>';
  525. print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
  526. print '</tr>';
  527. // warning message due to connection failure
  528. print '<tr><td colspan="2"><br>';
  529. print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
  530. print '<br>';
  531. print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  532. print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
  533. print '</td></tr>';
  534. $error++;
  535. }
  536. }
  537. } // end of user account creation
  538. // If database creation was asked, we create it
  539. if (!$error && (isset($db_create_database) && ($db_create_database == "1" || $db_create_database == "on"))) {
  540. dolibarr_install_syslog("step1: create database: ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user);
  541. $newdb = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, '', $conf->db->port);
  542. //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit;
  543. if ($newdb->connected) {
  544. $result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
  545. if ($result) {
  546. print '<tr><td>';
  547. print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
  548. print $dolibarr_main_db_name;
  549. print '</td>';
  550. print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  551. $newdb->select_db($dolibarr_main_db_name);
  552. $check1 = $newdb->getDefaultCharacterSetDatabase();
  553. $check2 = $newdb->getDefaultCollationDatabase();
  554. dolibarr_install_syslog('step1: new database is using charset='.$check1.' collation='.$check2);
  555. // If values differs, we save conf file again
  556. //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('step1: value for character_set is not the one asked for database creation', LOG_WARNING);
  557. //if ($check2 != $dolibarr_main_db_collation) dolibarr_install_syslog('step1: value for collation is not the one asked for database creation', LOG_WARNING);
  558. } else {
  559. // warning message
  560. print '<tr><td colspan="2"><br>';
  561. print $langs->trans("ErrorFailedToCreateDatabase", $dolibarr_main_db_name).'<br>';
  562. print $newdb->lasterror().'<br>';
  563. print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate");
  564. print '<br>';
  565. print '</td></tr>';
  566. dolibarr_install_syslog('step1: failed to create database '.$dolibarr_main_db_name.' '.$newdb->lasterrno().' '.$newdb->lasterror(), LOG_ERR);
  567. $error++;
  568. }
  569. $newdb->close();
  570. } else {
  571. print '<tr><td>';
  572. print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
  573. print $dolibarr_main_db_name;
  574. print '</td>';
  575. print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
  576. print '</tr>';
  577. // warning message
  578. print '<tr><td colspan="2"><br>';
  579. print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
  580. print '<br>';
  581. print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
  582. print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
  583. print '</td></tr>';
  584. $error++;
  585. }
  586. } // end of create database
  587. // We test access with dolibarr database user (not admin)
  588. if (!$error) {
  589. dolibarr_install_syslog("step1: connection type=".$conf->db->type." on host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name);
  590. //print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
  591. $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
  592. if ($db->connected) {
  593. dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." ok");
  594. print "<tr><td>";
  595. print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
  596. print $dolibarr_main_db_host;
  597. print "</td><td>";
  598. print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
  599. print "</td></tr>";
  600. // server access ok, basic access ok
  601. if ($db->database_selected) {
  602. dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." ok");
  603. print "<tr><td>";
  604. print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
  605. print $dolibarr_main_db_name;
  606. print "</td><td>";
  607. print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
  608. print "</td></tr>";
  609. $error = 0;
  610. } else {
  611. dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." failed", LOG_ERR);
  612. print "<tr><td>";
  613. print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
  614. print $dolibarr_main_db_name;
  615. print '</td><td>';
  616. print '<img src="../theme/eldy/img/error.png" alt="Error">';
  617. print "</td></tr>";
  618. // warning message
  619. print '<tr><td colspan="2"><br>';
  620. print $langs->trans('CheckThatDatabasenameIsCorrect', $dolibarr_main_db_name).'<br>';
  621. print $langs->trans('IfAlreadyExistsCheckOption').'<br>';
  622. print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
  623. print '</td></tr>';
  624. $error++;
  625. }
  626. } else {
  627. dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." failed", LOG_ERR);
  628. print "<tr><td>";
  629. print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
  630. print $dolibarr_main_db_host;
  631. print '</td><td>';
  632. print '<img src="../theme/eldy/img/error.png" alt="Error">';
  633. print "</td></tr>";
  634. // warning message
  635. print '<tr><td colspan="2"><br>';
  636. print $langs->trans("ErrorConnection", $conf->db->host, $conf->db->name, $conf->db->user);
  637. print $langs->trans('IfLoginDoesNotExistsCheckCreateUser').'<br>';
  638. print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
  639. print '</td></tr>';
  640. $error++;
  641. }
  642. }
  643. }
  644. print '</table>';
  645. }
  646. ?>
  647. <script type="text/javascript">
  648. function jsinfo()
  649. {
  650. ok=true;
  651. //alert('<?php echo dol_escape_js($langs->transnoentities("NextStepMightLastALongTime")); ?>');
  652. document.getElementById('nextbutton').style.visibility="hidden";
  653. document.getElementById('pleasewait').style.visibility="visible";
  654. return ok;
  655. }
  656. </script>
  657. <?php
  658. $ret = 0;
  659. if ($error && isset($argv[1])) {
  660. $ret = 1;
  661. }
  662. dolibarr_install_syslog("Exit ".$ret);
  663. dolibarr_install_syslog("--- step1: end");
  664. pFooter($error ? 1 : 0, $setuplang, 'jsinfo', 1);
  665. // Return code if ran from command line
  666. if ($ret) {
  667. exit($ret);
  668. }
  669. /**
  670. * Create main file. No particular permissions are set by installer.
  671. *
  672. * @param string $mainfile Full path name of main file to generate/update
  673. * @param string $main_dir Full path name to main.inc.php file
  674. * @return void
  675. */
  676. function write_main_file($mainfile, $main_dir)
  677. {
  678. $fp = @fopen("$mainfile", "w");
  679. if ($fp) {
  680. clearstatcache();
  681. fputs($fp, '<?php'."\n");
  682. fputs($fp, "// Wrapper to include main into htdocs\n");
  683. fputs($fp, "include_once '".$main_dir."/main.inc.php';\n");
  684. fclose($fp);
  685. }
  686. }
  687. /**
  688. * Create master file. No particular permissions are set by installer.
  689. *
  690. * @param string $masterfile Full path name of master file to generate/update
  691. * @param string $main_dir Full path name to master.inc.php file
  692. * @return void
  693. */
  694. function write_master_file($masterfile, $main_dir)
  695. {
  696. $fp = @fopen("$masterfile", "w");
  697. if ($fp) {
  698. clearstatcache();
  699. fputs($fp, '<?php'."\n");
  700. fputs($fp, "// Wrapper to include master into htdocs\n");
  701. fputs($fp, "include_once '".$main_dir."/master.inc.php';\n");
  702. fclose($fp);
  703. }
  704. }
  705. /**
  706. * Save configuration file. No particular permissions are set by installer.
  707. *
  708. * @param string $conffile Path to conf file to generate/update
  709. * @return integer
  710. */
  711. function write_conf_file($conffile)
  712. {
  713. global $conf, $langs;
  714. global $main_url, $main_dir, $main_data_dir, $main_force_https, $main_use_alt_dir, $main_alt_dir_name, $main_db_prefix;
  715. global $dolibarr_main_url_root, $dolibarr_main_document_root, $dolibarr_main_data_root, $dolibarr_main_db_host;
  716. global $dolibarr_main_db_port, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass;
  717. global $dolibarr_main_db_type, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_authentication;
  718. global $dolibarr_main_distrib;
  719. global $db_host, $db_port, $db_name, $db_user, $db_pass, $db_type, $db_character_set, $db_collation;
  720. global $conffile, $conffiletoshow, $conffiletoshowshort;
  721. global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH;
  722. global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
  723. global $force_dolibarr_lib_GEOIP_PATH;
  724. global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
  725. global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI;
  726. global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
  727. $error = 0;
  728. $key = md5(uniqid(mt_rand(), true)); // Generate random hash
  729. $fp = fopen("$conffile", "w");
  730. if ($fp) {
  731. clearstatcache();
  732. fputs($fp, '<?php'."\n");
  733. fputs($fp, '//'."\n");
  734. fputs($fp, '// File generated by Dolibarr installer '.DOL_VERSION.' on '.dol_print_date(dol_now(), '')."\n");
  735. fputs($fp, '//'."\n");
  736. fputs($fp, '// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.' file'."\n");
  737. fputs($fp, '// and explanations for all possibles parameters.'."\n");
  738. fputs($fp, '//'."\n");
  739. fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'", "\'", trim($main_url)).'\';');
  740. fputs($fp, "\n");
  741. fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'", "\'", trim($main_dir)).'\';');
  742. fputs($fp, "\n");
  743. fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'", "\'", trim("/".$main_alt_dir_name)).'\';');
  744. fputs($fp, "\n");
  745. fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'", "\'", trim($main_dir."/".$main_alt_dir_name)).'\';');
  746. fputs($fp, "\n");
  747. fputs($fp, '$dolibarr_main_data_root=\''.str_replace("'", "\'", trim($main_data_dir)).'\';');
  748. fputs($fp, "\n");
  749. fputs($fp, '$dolibarr_main_db_host=\''.str_replace("'", "\'", trim($db_host)).'\';');
  750. fputs($fp, "\n");
  751. fputs($fp, '$dolibarr_main_db_port=\''.str_replace("'", "\'", trim($db_port)).'\';');
  752. fputs($fp, "\n");
  753. fputs($fp, '$dolibarr_main_db_name=\''.str_replace("'", "\'", trim($db_name)).'\';');
  754. fputs($fp, "\n");
  755. fputs($fp, '$dolibarr_main_db_prefix=\''.str_replace("'", "\'", trim($main_db_prefix)).'\';');
  756. fputs($fp, "\n");
  757. fputs($fp, '$dolibarr_main_db_user=\''.str_replace("'", "\'", trim($db_user)).'\';');
  758. fputs($fp, "\n");
  759. fputs($fp, '$dolibarr_main_db_pass=\''.str_replace("'", "\'", trim($db_pass)).'\';');
  760. fputs($fp, "\n");
  761. fputs($fp, '$dolibarr_main_db_type=\''.str_replace("'", "\'", trim($db_type)).'\';');
  762. fputs($fp, "\n");
  763. fputs($fp, '$dolibarr_main_db_character_set=\''.str_replace("'", "\'", trim($db_character_set)).'\';');
  764. fputs($fp, "\n");
  765. fputs($fp, '$dolibarr_main_db_collation=\''.str_replace("'", "\'", trim($db_collation)).'\';');
  766. fputs($fp, "\n");
  767. // Authentication
  768. fputs($fp, '// Authentication settings');
  769. fputs($fp, "\n");
  770. fputs($fp, '$dolibarr_main_authentication=\'dolibarr\';');
  771. fputs($fp, "\n\n");
  772. fputs($fp, '//$dolibarr_main_demo=\'autologin,autopass\';');
  773. fputs($fp, "\n");
  774. fputs($fp, '// Security settings');
  775. fputs($fp, "\n");
  776. fputs($fp, '$dolibarr_main_prod=\'0\';');
  777. fputs($fp, "\n");
  778. fputs($fp, '$dolibarr_main_force_https=\''.$main_force_https.'\';');
  779. fputs($fp, "\n");
  780. fputs($fp, '$dolibarr_main_restrict_os_commands=\'mysqldump, mysql, pg_dump, pgrestore\';');
  781. fputs($fp, "\n");
  782. fputs($fp, '$dolibarr_nocsrfcheck=\'0\';');
  783. fputs($fp, "\n");
  784. fputs($fp, '$dolibarr_main_instance_unique_id=\''.$key.'\';');
  785. fputs($fp, "\n");
  786. fputs($fp, '$dolibarr_mailing_limit_sendbyweb=\'0\';');
  787. fputs($fp, "\n");
  788. fputs($fp, '$dolibarr_mailing_limit_sendbycli=\'0\';');
  789. fputs($fp, "\n");
  790. // Write params to overwrites default lib path
  791. fputs($fp, "\n");
  792. if (empty($force_dolibarr_lib_FPDF_PATH)) {
  793. fputs($fp, '//'); $force_dolibarr_lib_FPDF_PATH = '';
  794. }
  795. fputs($fp, '$dolibarr_lib_FPDF_PATH=\''.$force_dolibarr_lib_FPDF_PATH.'\';');
  796. fputs($fp, "\n");
  797. if (empty($force_dolibarr_lib_TCPDF_PATH)) {
  798. fputs($fp, '//'); $force_dolibarr_lib_TCPDF_PATH = '';
  799. }
  800. fputs($fp, '$dolibarr_lib_TCPDF_PATH=\''.$force_dolibarr_lib_TCPDF_PATH.'\';');
  801. fputs($fp, "\n");
  802. if (empty($force_dolibarr_lib_FPDI_PATH)) {
  803. fputs($fp, '//'); $force_dolibarr_lib_FPDI_PATH = '';
  804. }
  805. fputs($fp, '$dolibarr_lib_FPDI_PATH=\''.$force_dolibarr_lib_FPDI_PATH.'\';');
  806. fputs($fp, "\n");
  807. if (empty($force_dolibarr_lib_TCPDI_PATH)) {
  808. fputs($fp, '//'); $force_dolibarr_lib_TCPDI_PATH = '';
  809. }
  810. fputs($fp, '$dolibarr_lib_TCPDI_PATH=\''.$force_dolibarr_lib_TCPDI_PATH.'\';');
  811. fputs($fp, "\n");
  812. if (empty($force_dolibarr_lib_ADODB_PATH)) {
  813. fputs($fp, '//'); $force_dolibarr_lib_ADODB_PATH = '';
  814. }
  815. fputs($fp, '$dolibarr_lib_ADODB_PATH=\''.$force_dolibarr_lib_ADODB_PATH.'\';');
  816. fputs($fp, "\n");
  817. if (empty($force_dolibarr_lib_GEOIP_PATH)) {
  818. fputs($fp, '//'); $force_dolibarr_lib_GEOIP_PATH = '';
  819. }
  820. fputs($fp, '$dolibarr_lib_GEOIP_PATH=\''.$force_dolibarr_lib_GEOIP_PATH.'\';');
  821. fputs($fp, "\n");
  822. if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
  823. fputs($fp, '//'); $force_dolibarr_lib_NUSOAP_PATH = '';
  824. }
  825. fputs($fp, '$dolibarr_lib_NUSOAP_PATH=\''.$force_dolibarr_lib_NUSOAP_PATH.'\';');
  826. fputs($fp, "\n");
  827. if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
  828. fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATH = '';
  829. }
  830. fputs($fp, '$dolibarr_lib_ODTPHP_PATH=\''.$force_dolibarr_lib_ODTPHP_PATH.'\';');
  831. fputs($fp, "\n");
  832. if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
  833. fputs($fp, '//'); $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP = '';
  834. }
  835. fputs($fp, '$dolibarr_lib_ODTPHP_PATHTOPCLZIP=\''.$force_dolibarr_lib_ODTPHP_PATHTOPCLZIP.'\';');
  836. fputs($fp, "\n");
  837. if (empty($force_dolibarr_js_CKEDITOR)) {
  838. fputs($fp, '//'); $force_dolibarr_js_CKEDITOR = '';
  839. }
  840. fputs($fp, '$dolibarr_js_CKEDITOR=\''.$force_dolibarr_js_CKEDITOR.'\';');
  841. fputs($fp, "\n");
  842. if (empty($force_dolibarr_js_JQUERY)) {
  843. fputs($fp, '//'); $force_dolibarr_js_JQUERY = '';
  844. }
  845. fputs($fp, '$dolibarr_js_JQUERY=\''.$force_dolibarr_js_JQUERY.'\';');
  846. fputs($fp, "\n");
  847. if (empty($force_dolibarr_js_JQUERY_UI)) {
  848. fputs($fp, '//'); $force_dolibarr_js_JQUERY_UI = '';
  849. }
  850. fputs($fp, '$dolibarr_js_JQUERY_UI=\''.$force_dolibarr_js_JQUERY_UI.'\';');
  851. fputs($fp, "\n");
  852. // Write params to overwrites default font path
  853. fputs($fp, "\n");
  854. if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
  855. fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF = '';
  856. }
  857. fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF=\''.$force_dolibarr_font_DOL_DEFAULT_TTF.'\';');
  858. fputs($fp, "\n");
  859. if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
  860. fputs($fp, '//'); $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD = '';
  861. }
  862. fputs($fp, '$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.$force_dolibarr_font_DOL_DEFAULT_TTF_BOLD.'\';');
  863. fputs($fp, "\n");
  864. // Other
  865. fputs($fp, '$dolibarr_main_distrib=\''.str_replace("'", "\'", trim($dolibarr_main_distrib)).'\';');
  866. fputs($fp, "\n");
  867. fclose($fp);
  868. if (file_exists("$conffile")) {
  869. include $conffile; // force config reload, do not put include_once
  870. conf($dolibarr_main_document_root);
  871. print "<tr><td>";
  872. print $langs->trans("SaveConfigurationFile");
  873. print ' <strong>'.$conffile.'</strong>';
  874. print "</td><td>";
  875. print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
  876. print "</td></tr>";
  877. } else {
  878. $error++;
  879. }
  880. }
  881. return $error;
  882. }