step2.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2015 Cedric GROSS <c.gross@kreiz-it.fr>
  5. * Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/install/step2.php
  22. * \ingroup install
  23. * \brief Create tables, primary keys, foreign keys, indexes and functions into database and then load reference data
  24. */
  25. include 'inc.php';
  26. require_once $dolibarr_main_document_root.'/core/class/conf.class.php';
  27. require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
  28. global $langs;
  29. $step = 2;
  30. $ok = 0;
  31. // Cette page peut etre longue. On augmente le delai autorise.
  32. // Ne fonctionne que si on est pas en safe_mode.
  33. $err=error_reporting();
  34. error_reporting(0); // Disable all errors
  35. //error_reporting(E_ALL);
  36. @set_time_limit(900); // Need 900 on some OS like Windows 7/64
  37. error_reporting($err);
  38. $action=GETPOST('action','aZ09')?GETPOST('action','aZ09'):(empty($argv[1])?'':$argv[1]);
  39. $setuplang=GETPOST('selectlang','aZ09',3)?GETPOST('selectlang','aZ09',3):(empty($argv[2])?'auto':$argv[2]);
  40. $langs->setDefaultLang($setuplang);
  41. $langs->loadLangs(array("admin", "install"));
  42. $choix=0;
  43. if ($dolibarr_main_db_type == "mysqli") $choix=1;
  44. if ($dolibarr_main_db_type == "pgsql") $choix=2;
  45. if ($dolibarr_main_db_type == "mssql") $choix=3;
  46. if ($dolibarr_main_db_type == "sqlite") $choix=4;
  47. if ($dolibarr_main_db_type == "sqlite3") $choix=5;
  48. //if (empty($choix)) dol_print_error('','Database type '.$dolibarr_main_db_type.' not supported into step2.php page');
  49. // Now we load forced values from install.forced.php file.
  50. $useforcedwizard=false;
  51. $forcedfile="./install.forced.php";
  52. if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
  53. if (@file_exists($forcedfile)) {
  54. $useforcedwizard = true;
  55. include_once $forcedfile;
  56. }
  57. dolibarr_install_syslog("- step2: entering step2.php page");
  58. /*
  59. * View
  60. */
  61. pHeader($langs->trans("CreateDatabaseObjects"),"step4");
  62. // Test if we can run a first install process
  63. if (! is_writable($conffile))
  64. {
  65. print $langs->trans("ConfFileIsNotWritable",$conffiletoshow);
  66. pFooter(1,$setuplang,'jscheckparam');
  67. exit;
  68. }
  69. if ($action == "set")
  70. {
  71. print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans("Database").'</h3>';
  72. print '<table cellspacing="0" style="padding: 4px 4px 4px 0" border="0" width="100%">';
  73. $error=0;
  74. $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
  75. if ($db->connected)
  76. {
  77. print "<tr><td>";
  78. print $langs->trans("ServerConnection")." : ".$conf->db->host.'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  79. $ok = 1 ;
  80. }
  81. else
  82. {
  83. print "<tr><td>Failed to connect to server : ".$conf->db->host.'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
  84. }
  85. if ($ok)
  86. {
  87. if($db->database_selected)
  88. {
  89. dolibarr_install_syslog("step2: successful connection to database: " . $conf->db->name);
  90. }
  91. else
  92. {
  93. dolibarr_install_syslog("step2: failed connection to database :" . $conf->db->name, LOG_ERR);
  94. print "<tr><td>Failed to select database ".$conf->db->name.'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
  95. $ok = 0 ;
  96. }
  97. }
  98. // Affiche version
  99. if ($ok)
  100. {
  101. $version=$db->getVersion();
  102. $versionarray=$db->getVersionArray();
  103. print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
  104. print '<td>'.$version.'</td></tr>';
  105. //print '<td align="right">'.join('.',$versionarray).'</td></tr>';
  106. print '<tr><td>'.$langs->trans("DatabaseName").'</td>';
  107. print '<td>'.$db->database_name.'</td></tr>';
  108. //print '<td align="right">'.join('.',$versionarray).'</td></tr>';
  109. }
  110. $requestnb=0;
  111. // To disable some code, so you can call step2 with url like
  112. // http://localhost/dolibarrnew/install/step2.php?action=set&createtables=0&createkeys=0&createfunctions=0&createdata=llx_20_c_departements
  113. $createtables=isset($_GET['createtables'])?GETPOST('createtables'):1;
  114. $createkeys=isset($_GET['createkeys'])?GETPOST('createkeys'):1;
  115. $createfunctions=isset($_GET['createfunctions'])?GETPOST('createfunction'):1;
  116. $createdata=isset($_GET['createdata'])?GETPOST('createdata'):1;
  117. // To say sql requests are escaped for mysql so we need to unescape them
  118. $db->unescapeslashquot=true;
  119. /**************************************************************************************
  120. *
  121. * Chargement fichiers tables/*.sql (non *.key.sql)
  122. * A faire avant les fichiers *.key.sql
  123. *
  124. ***************************************************************************************/
  125. if ($ok && $createtables)
  126. {
  127. // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
  128. $dir = "mysql/tables/";
  129. $ok = 0;
  130. $handle=opendir($dir);
  131. dolibarr_install_syslog("step2: open tables directory " . $dir . " handle=" . $handle);
  132. $tablefound = 0;
  133. $tabledata=array();
  134. if (is_resource($handle))
  135. {
  136. while (($file = readdir($handle))!==false)
  137. {
  138. if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file))
  139. {
  140. $tablefound++;
  141. $tabledata[]=$file;
  142. }
  143. }
  144. closedir($handle);
  145. }
  146. // Sort list of sql files on alphabetical order (load order is important)
  147. sort($tabledata);
  148. foreach($tabledata as $file)
  149. {
  150. $name = substr($file, 0, dol_strlen($file) - 4);
  151. $buffer = '';
  152. $fp = fopen($dir.$file,"r");
  153. if ($fp)
  154. {
  155. while (!feof($fp))
  156. {
  157. $buf = fgets($fp, 4096);
  158. if (substr($buf, 0, 2) <> '--')
  159. {
  160. $buf=preg_replace('/--(.+)*/','',$buf);
  161. $buffer .= $buf;
  162. }
  163. }
  164. fclose($fp);
  165. $buffer=trim($buffer);
  166. if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
  167. {
  168. $buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer);
  169. }
  170. else
  171. {
  172. // Keyword ENGINE is MySQL-specific, so scrub it for
  173. // other database types (mssql, pgsql)
  174. $buffer=preg_replace('/type=innodb/i','',$buffer);
  175. $buffer=preg_replace('/ENGINE=innodb/i','',$buffer);
  176. }
  177. // Replace the prefix tables
  178. if ($dolibarr_main_db_prefix != 'llx_')
  179. {
  180. $buffer=preg_replace('/llx_/i',$dolibarr_main_db_prefix,$buffer);
  181. }
  182. //print "<tr><td>Creation de la table $name/td>";
  183. $requestnb++;
  184. dolibarr_install_syslog("step2: request: " . $buffer);
  185. $resql=$db->query($buffer,0,'dml');
  186. if ($resql)
  187. {
  188. // print "<td>OK requete ==== $buffer</td></tr>";
  189. $db->free($resql);
  190. }
  191. else
  192. {
  193. if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
  194. $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
  195. {
  196. //print "<td>Deja existante</td></tr>";
  197. }
  198. else
  199. {
  200. print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name);
  201. print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.' <br>Executed query : '.$db->lastquery;
  202. print "\n</td>";
  203. print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
  204. $error++;
  205. }
  206. }
  207. }
  208. else
  209. {
  210. print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name);
  211. print "</td>";
  212. print '<td><span class="error">'.$langs->trans("Error").' Failed to open file '.$dir.$file.'</span></td></tr>';
  213. $error++;
  214. dolibarr_install_syslog("step2: failed to open file " . $dir . $file, LOG_ERR);
  215. }
  216. }
  217. if ($tablefound)
  218. {
  219. if ($error == 0)
  220. {
  221. print '<tr><td>';
  222. print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  223. $ok = 1;
  224. }
  225. }
  226. else
  227. {
  228. print '<tr><td>'.$langs->trans("ErrorFailedToFindSomeFiles",$dir).'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
  229. dolibarr_install_syslog("step2: failed to find files to create database in directory " . $dir, LOG_ERR);
  230. }
  231. }
  232. /***************************************************************************************
  233. *
  234. * Chargement fichiers tables/*.key.sql
  235. * A faire apres les fichiers *.sql
  236. *
  237. ***************************************************************************************/
  238. if ($ok && $createkeys)
  239. {
  240. // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
  241. $dir = "mysql/tables/";
  242. $okkeys = 0;
  243. $handle=opendir($dir);
  244. dolibarr_install_syslog("step2: open keys directory " . $dir . " handle=" . $handle);
  245. $tablefound = 0;
  246. $tabledata=array();
  247. if (is_resource($handle))
  248. {
  249. while (($file = readdir($handle))!==false)
  250. {
  251. if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file))
  252. {
  253. $tablefound++;
  254. $tabledata[]=$file;
  255. }
  256. }
  257. closedir($handle);
  258. }
  259. // Sort list of sql files on alphabetical order (load order is important)
  260. sort($tabledata);
  261. foreach($tabledata as $file)
  262. {
  263. $name = substr($file, 0, dol_strlen($file) - 4);
  264. //print "<tr><td>Creation de la table $name</td>";
  265. $buffer = '';
  266. $fp = fopen($dir.$file,"r");
  267. if ($fp)
  268. {
  269. while (!feof($fp))
  270. {
  271. $buf = fgets($fp, 4096);
  272. // Cas special de lignes autorisees pour certaines versions uniquement
  273. if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i',$buf,$reg))
  274. {
  275. $versioncommande=explode('.',$reg[1]);
  276. //print var_dump($versioncommande);
  277. //print var_dump($versionarray);
  278. if (count($versioncommande) && count($versionarray)
  279. && versioncompare($versioncommande,$versionarray) <= 0)
  280. {
  281. // Version qualified, delete SQL comments
  282. $buf=preg_replace('/^--\sV([0-9\.]+)/i','',$buf);
  283. //print "Ligne $i qualifiee par version: ".$buf.'<br>';
  284. }
  285. }
  286. if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i',$buf,$reg))
  287. {
  288. $versioncommande=explode('.',$reg[1]);
  289. //print var_dump($versioncommande);
  290. //print var_dump($versionarray);
  291. if (count($versioncommande) && count($versionarray)
  292. && versioncompare($versioncommande,$versionarray) <= 0)
  293. {
  294. // Version qualified, delete SQL comments
  295. $buf=preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i','',$buf);
  296. //print "Ligne $i qualifiee par version: ".$buf.'<br>';
  297. }
  298. }
  299. // Ajout ligne si non commentaire
  300. if (! preg_match('/^--/i',$buf)) $buffer .= $buf;
  301. }
  302. fclose($fp);
  303. // Si plusieurs requetes, on boucle sur chaque
  304. $listesql=explode(';',$buffer);
  305. foreach ($listesql as $req)
  306. {
  307. $buffer=trim($req);
  308. if ($buffer)
  309. {
  310. // Replace the prefix tables
  311. if ($dolibarr_main_db_prefix != 'llx_')
  312. {
  313. $buffer=preg_replace('/llx_/i',$dolibarr_main_db_prefix,$buffer);
  314. }
  315. //print "<tr><td>Creation des cles et index de la table $name: '$buffer'</td>";
  316. $requestnb++;
  317. dolibarr_install_syslog("step2: request: " . $buffer);
  318. $resql=$db->query($buffer,0,'dml');
  319. if ($resql)
  320. {
  321. //print "<td>OK requete ==== $buffer</td></tr>";
  322. $db->free($resql);
  323. }
  324. else
  325. {
  326. if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
  327. $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
  328. $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
  329. $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
  330. preg_match('/duplicate key name/i',$db->error()))
  331. {
  332. //print "<td>Deja existante</td></tr>";
  333. $key_exists = 1;
  334. }
  335. else
  336. {
  337. print "<tr><td>".$langs->trans("CreateOtherKeysForTable",$name);
  338. print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
  339. print "\n</td>";
  340. print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
  341. $error++;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. else
  348. {
  349. print "<tr><td>".$langs->trans("CreateOtherKeysForTable",$name);
  350. print "</td>";
  351. print '<td><span class="error">'.$langs->trans("Error")." Failed to open file ".$dir.$file."</span></td></tr>";
  352. $error++;
  353. dolibarr_install_syslog("step2: failed to open file " . $dir . $file, LOG_ERR);
  354. }
  355. }
  356. if ($tablefound && $error == 0)
  357. {
  358. print '<tr><td>';
  359. print $langs->trans("OtherKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  360. $okkeys = 1;
  361. }
  362. }
  363. /***************************************************************************************
  364. *
  365. * Chargement fichier functions.sql
  366. *
  367. ***************************************************************************************/
  368. if ($ok && $createfunctions)
  369. {
  370. // For this file, we use a directory according to database type
  371. if ($choix==1) $dir = "mysql/functions/";
  372. elseif ($choix==2) $dir = "pgsql/functions/";
  373. elseif ($choix==3) $dir = "mssql/functions/";
  374. elseif ($choix==4) { $dir = "sqlite3/functions/"; }
  375. // Creation donnees
  376. $file = "functions.sql";
  377. if (file_exists($dir.$file))
  378. {
  379. $fp = fopen($dir.$file,"r");
  380. dolibarr_install_syslog("step2: open function file " . $dir . $file . " handle=" . $fp);
  381. if ($fp)
  382. {
  383. $buffer='';
  384. while (!feof($fp))
  385. {
  386. $buf = fgets($fp, 4096);
  387. if (substr($buf, 0, 2) <> '--')
  388. {
  389. $buffer .= $buf."§";
  390. }
  391. }
  392. fclose($fp);
  393. }
  394. //$buffer=preg_replace('/;\';/',";'§",$buffer);
  395. // If several requests, we loop on each of them
  396. $listesql=explode('§',$buffer);
  397. foreach ($listesql as $buffer)
  398. {
  399. $buffer=trim($buffer);
  400. if ($buffer)
  401. {
  402. dolibarr_install_syslog("step2: request: " . $buffer);
  403. print "<!-- Insert line : ".$buffer."<br>-->\n";
  404. $resql=$db->query($buffer,0,'dml');
  405. if ($resql)
  406. {
  407. $ok = 1;
  408. $db->free($resql);
  409. }
  410. else
  411. {
  412. if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
  413. || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
  414. {
  415. //print "Insert line : ".$buffer."<br>\n";
  416. }
  417. else
  418. {
  419. $ok = 0;
  420. print "<tr><td>".$langs->trans("FunctionsCreation");
  421. print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
  422. print "\n</td>";
  423. print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
  424. $error++;
  425. }
  426. }
  427. }
  428. }
  429. print "<tr><td>".$langs->trans("FunctionsCreation")."</td>";
  430. if ($ok)
  431. {
  432. print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  433. }
  434. else
  435. {
  436. print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
  437. $ok = 1 ;
  438. }
  439. }
  440. }
  441. /***************************************************************************************
  442. *
  443. * Load files data/*.sql
  444. *
  445. ***************************************************************************************/
  446. if ($ok && $createdata)
  447. {
  448. // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
  449. $dir = "mysql/data/";
  450. // Insert data
  451. $handle=opendir($dir);
  452. dolibarr_install_syslog("step2: open directory data " . $dir . " handle=" . $handle);
  453. $tablefound = 0;
  454. $tabledata=array();
  455. if (is_resource($handle))
  456. {
  457. while (($file = readdir($handle))!==false)
  458. {
  459. if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file))
  460. {
  461. if (preg_match('/^llx_accounting_account_/',$file)) continue; // We discard data file of chart of account. Will be loaded when a chart is selected.
  462. //print 'x'.$file.'-'.$createdata.'<br>';
  463. if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i',$file))
  464. {
  465. $tablefound++;
  466. $tabledata[]=$file;
  467. }
  468. }
  469. }
  470. closedir($handle);
  471. }
  472. // Sort list of data files on alphabetical order (load order is important)
  473. sort($tabledata);
  474. foreach($tabledata as $file)
  475. {
  476. $name = substr($file, 0, dol_strlen($file) - 4);
  477. $fp = fopen($dir.$file,"r");
  478. dolibarr_install_syslog("step2: open data file " . $dir . $file . " handle=" . $fp);
  479. if ($fp)
  480. {
  481. $arrayofrequests=array();
  482. $linefound=0;
  483. $linegroup=0;
  484. $sizeofgroup=1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1.
  485. // Load all requests
  486. while (!feof($fp))
  487. {
  488. $buffer = fgets($fp, 4096);
  489. $buffer = trim($buffer);
  490. if ($buffer)
  491. {
  492. if (substr($buffer, 0, 2) == '--') continue;
  493. if ($linefound && ($linefound % $sizeofgroup) == 0)
  494. {
  495. $linegroup++;
  496. }
  497. if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup]=$buffer;
  498. else $arrayofrequests[$linegroup].=" ".$buffer;
  499. $linefound++;
  500. }
  501. }
  502. fclose($fp);
  503. dolibarr_install_syslog("step2: found " . $linefound . " records, defined " . count($arrayofrequests) . " group(s).");
  504. $okallfile=1;
  505. $db->begin();
  506. // We loop on each requests of file
  507. foreach($arrayofrequests as $buffer)
  508. {
  509. // Replace the prefix tables
  510. if ($dolibarr_main_db_prefix != 'llx_')
  511. {
  512. $buffer=preg_replace('/llx_/i',$dolibarr_main_db_prefix,$buffer);
  513. }
  514. //dolibarr_install_syslog("step2: request: " . $buffer);
  515. $resql=$db->query($buffer,1);
  516. if ($resql)
  517. {
  518. //$db->free($resql); // Not required as request we launch here does not return memory needs.
  519. }
  520. else
  521. {
  522. if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
  523. {
  524. //print "<tr><td>Insertion ligne : $buffer</td><td>";
  525. }
  526. else
  527. {
  528. $ok = 0;
  529. $okallfile = 0;
  530. print '<span class="error">'.$langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."</span><br>";
  531. }
  532. }
  533. }
  534. if ($okallfile) $db->commit();
  535. else $db->rollback();
  536. }
  537. }
  538. print "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
  539. if ($ok)
  540. {
  541. print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
  542. }
  543. else
  544. {
  545. print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
  546. $ok = 1; // Data loading are not blocking errors
  547. }
  548. }
  549. print '</table>';
  550. }
  551. else
  552. {
  553. print 'Parameter action=set not defined';
  554. }
  555. $ret=0;
  556. if (!$ok && isset($argv[1])) $ret=1;
  557. dolibarr_install_syslog("Exit ".$ret);
  558. dolibarr_install_syslog("- step2: end");
  559. pFooter($ok?0:1,$setuplang);
  560. if (isset($db) && is_object($db)) $db->close();
  561. // Return code if ran from command line
  562. if ($ret) exit($ret);