check.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <?php
  2. /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2013-2014 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  8. * Copyright (C) 2015-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/check.php
  25. * \ingroup install
  26. * \brief Test if file conf can be modified and if does not exists, test if install process can create it
  27. */
  28. include_once 'inc.php';
  29. global $langs;
  30. $err = 0;
  31. $allowinstall = 0;
  32. $allowupgrade = false;
  33. $checksok = 1;
  34. $setuplang=GETPOST("selectlang",'az09',3)?GETPOST("selectlang",'az09',3):$langs->getDefaultLang();
  35. $langs->setDefaultLang($setuplang);
  36. $langs->load("install");
  37. // Now we load forced/pre-set values from install.forced.php file.
  38. $useforcedwizard=false;
  39. $forcedfile="./install.forced.php";
  40. if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
  41. if (@file_exists($forcedfile)) {
  42. $useforcedwizard = true;
  43. include_once $forcedfile;
  44. }
  45. dolibarr_install_syslog("- check: Dolibarr install/upgrade process started");
  46. /*
  47. * View
  48. */
  49. pHeader('',''); // No next step for navigation buttons. Next step is defined by click on links.
  50. //print "<br>\n";
  51. //print $langs->trans("InstallEasy")."<br><br>\n";
  52. print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> '.$langs->trans("MiscellaneousChecks").":</h3>\n";
  53. // Check browser
  54. $useragent=$_SERVER['HTTP_USER_AGENT'];
  55. if (! empty($useragent))
  56. {
  57. $tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
  58. $browserversion=$tmp['browserversion'];
  59. $browsername=$tmp['browsername'];
  60. if ($browsername == 'ie' && $browserversion < 7) print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("WarningBrowserTooOld")."<br>\n";
  61. }
  62. // Check PHP version
  63. $arrayphpminversionerror = array(5,4,0);
  64. $arrayphpminversionwarning = array(5,4,0);
  65. if (versioncompare(versionphparray(),$arrayphpminversionerror) < 0) // Minimum to use (error if lower)
  66. {
  67. print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
  68. $checksok=0; // 0=error, 1=warning
  69. }
  70. else if (versioncompare(versionphparray(),$arrayphpminversionwarning) < 0) // Minimum supported (warning if lower)
  71. {
  72. print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow",versiontostring($arrayphpminversionwarning));
  73. $checksok=0; // 0=error, 1=warning
  74. }
  75. else
  76. {
  77. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPVersion")." ".versiontostring(versionphparray());
  78. }
  79. if (empty($force_install_nophpinfo)) print ' (<a href="phpinfo.php" target="_blank">'.$langs->trans("MoreInformation").'</a>)';
  80. print "<br>\n";
  81. // Check PHP support for $_POST
  82. if (! isset($_GET["testget"]) && ! isset($_POST["testpost"]))
  83. {
  84. print '<img src="../theme/eldy/img/warning.png" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
  85. print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
  86. print "<br>\n";
  87. $checksok=0;
  88. }
  89. else
  90. {
  91. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPSupportPOSTGETOk")."<br>\n";
  92. }
  93. // Check if sessions enabled
  94. if (! function_exists("session_id"))
  95. {
  96. print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions")."<br>\n";
  97. $checksok=0;
  98. }
  99. else
  100. {
  101. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPSupportSessions")."<br>\n";
  102. }
  103. // Check if GD supported (we need GD for image conversion)
  104. if (! function_exists("imagecreate"))
  105. {
  106. $langs->load("errors");
  107. print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportGD")."<br>\n";
  108. // $checksok=0; // If image ko, just warning. So check must still be 1 (otherwise no way to install)
  109. }
  110. else
  111. {
  112. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPSupportGD")."<br>\n";
  113. }
  114. // Check if Curl supported
  115. if (! function_exists("curl_init"))
  116. {
  117. $langs->load("errors");
  118. print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportCurl")."<br>\n";
  119. // $checksok=0; // If image ko, just warning. So check must still be 1 (otherwise no way to install)
  120. }
  121. else
  122. {
  123. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPSupportCurl")."<br>\n";
  124. }
  125. // Check if UTF8 supported
  126. if (! function_exists("utf8_encode"))
  127. {
  128. $langs->load("errors");
  129. print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."<br>\n";
  130. // $checksok=0; // If image ko, just warning. So check must still be 1 (otherwise no way to install)
  131. }
  132. else
  133. {
  134. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPSupportUTF8")."<br>\n";
  135. }
  136. // Check memory
  137. $memrequiredorig='64M';
  138. $memrequired=64*1024*1024;
  139. $memmaxorig=@ini_get("memory_limit");
  140. $memmax=@ini_get("memory_limit");
  141. if ($memmaxorig != '')
  142. {
  143. preg_match('/([0-9]+)([a-zA-Z]*)/i',$memmax,$reg);
  144. if ($reg[2])
  145. {
  146. if (strtoupper($reg[2]) == 'G') $memmax=$reg[1]*1024*1024*1024;
  147. if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024;
  148. if (strtoupper($reg[2]) == 'K') $memmax=$reg[1]*1024;
  149. }
  150. if ($memmax >= $memrequired || $memmax == -1)
  151. {
  152. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("PHPMemoryOK",$memmaxorig,$memrequiredorig)."<br>\n";
  153. }
  154. else
  155. {
  156. print '<img src="../theme/eldy/img/warning.png" alt="Warning"> '.$langs->trans("PHPMemoryTooLow",$memmaxorig,$memrequiredorig)."<br>\n";
  157. }
  158. }
  159. // If config file present and filled
  160. clearstatcache();
  161. if (is_readable($conffile) && filesize($conffile) > 8)
  162. {
  163. dolibarr_install_syslog("check: conf file '" . $conffile . "' already defined");
  164. $confexists=1;
  165. include_once $conffile;
  166. $databaseok=1;
  167. if ($databaseok)
  168. {
  169. // Already installed for all parts (config and database). We can propose upgrade.
  170. $allowupgrade=true;
  171. }
  172. else
  173. {
  174. $allowupgrade=false;
  175. }
  176. }
  177. else
  178. {
  179. // If not, we create it
  180. dolibarr_install_syslog("check: we try to create conf file '" . $conffile . "'");
  181. $confexists=0;
  182. // First we try by copying example
  183. if (@copy($conffile.".example", $conffile))
  184. {
  185. // Success
  186. dolibarr_install_syslog("check: successfully copied file " . $conffile . ".example into " . $conffile);
  187. }
  188. else
  189. {
  190. // If failed, we try to create an empty file
  191. dolibarr_install_syslog("check: failed to copy file " . $conffile . ".example into " . $conffile . ". We try to create it.", LOG_WARNING);
  192. $fp = @fopen($conffile, "w");
  193. if ($fp)
  194. {
  195. @fwrite($fp, '<?php');
  196. @fputs($fp,"\n");
  197. fclose($fp);
  198. }
  199. else dolibarr_install_syslog("check: failed to create a new file " . $conffile . " into current dir " . getcwd() . ". Please check permissions.", LOG_ERR);
  200. }
  201. // First install: no upgrade necessary/required
  202. $allowupgrade=false;
  203. }
  204. // File is missing and cannot be created
  205. if (! file_exists($conffile))
  206. {
  207. print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated",$conffiletoshow);
  208. print "<br><br>";
  209. print $langs->trans("YouMustCreateWithPermission",$conffiletoshow);
  210. print "<br><br>";
  211. print $langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok');
  212. $err++;
  213. }
  214. else
  215. {
  216. if (dol_is_dir($conffile))
  217. {
  218. print '<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans("ConfFileMustBeAFileNotADir",$conffiletoshow);
  219. $allowinstall=0;
  220. }
  221. // File exists but cannot be modified
  222. elseif (!is_writable($conffile))
  223. {
  224. if ($confexists)
  225. {
  226. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileExists",$conffiletoshow);
  227. }
  228. else
  229. {
  230. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileCouldBeCreated",$conffiletoshow);
  231. }
  232. print "<br>";
  233. print '<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans("ConfFileIsNotWritable",$conffiletoshow);
  234. print "<br>\n";
  235. $allowinstall=0;
  236. }
  237. // File exists and can be modified
  238. else
  239. {
  240. if ($confexists)
  241. {
  242. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileExists",$conffiletoshow);
  243. }
  244. else
  245. {
  246. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileCouldBeCreated",$conffiletoshow);
  247. }
  248. print "<br>";
  249. print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileIsWritable",$conffiletoshow);
  250. print "<br>\n";
  251. $allowinstall=1;
  252. }
  253. print "<br>\n";
  254. // Requirements met/all ok: display the next step button
  255. if ($checksok)
  256. {
  257. $ok=0;
  258. // Try to create db connection
  259. if (file_exists($conffile))
  260. {
  261. include_once $conffile;
  262. if (! empty($dolibarr_main_db_type) && ! empty($dolibarr_main_document_root))
  263. {
  264. if (! file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php"))
  265. {
  266. print '<span class="error">A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file.</span><br>'."\n";
  267. dol_syslog("A '" . $conffiletoshow . "' file exists with a dolibarr_main_document_root to " . $dolibarr_main_document_root . " that seems wrong. Try to fix or remove the '" . $conffiletoshow . "' file.", LOG_WARNING);
  268. }
  269. else
  270. {
  271. require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
  272. // If password is encoded, we decode it
  273. if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
  274. {
  275. require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
  276. if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
  277. {
  278. $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted
  279. $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
  280. }
  281. else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
  282. }
  283. // $conf already created in inc.php
  284. $conf->db->type = $dolibarr_main_db_type;
  285. $conf->db->host = $dolibarr_main_db_host;
  286. $conf->db->port = $dolibarr_main_db_port;
  287. $conf->db->name = $dolibarr_main_db_name;
  288. $conf->db->user = $dolibarr_main_db_user;
  289. $conf->db->pass = $dolibarr_main_db_pass;
  290. $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
  291. if ($db->connected && $db->database_selected)
  292. {
  293. $ok=true;
  294. }
  295. }
  296. }
  297. }
  298. // If database access is available, we set more variables
  299. if ($ok)
  300. {
  301. if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
  302. $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
  303. if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
  304. $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
  305. $conf->setValues($db);
  306. // Reset forced setup after the setValues
  307. if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE');
  308. $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
  309. // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
  310. // Version to install is DOL_VERSION
  311. $dolibarrlastupgradeversionarray=preg_split('/[\.-]/',isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:''));
  312. $dolibarrversiontoinstallarray=versiondolibarrarray();
  313. }
  314. // Show title
  315. if (! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ! empty($conf->global->MAIN_VERSION_LAST_INSTALL))
  316. {
  317. print $langs->trans("VersionLastUpgrade").': <b><span class="ok">'.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).'</span></b><br>';
  318. print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b>';
  319. //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
  320. print '<br>';
  321. print '<br>';
  322. }
  323. else print "<br>\n";
  324. print $langs->trans("InstallEasy")." ";
  325. print $langs->trans("ChooseYourSetupMode");
  326. print '<br>';
  327. $foundrecommandedchoice=0;
  328. $available_choices = array();
  329. $notavailable_choices = array();
  330. // Show first install line
  331. $choice = "\n".'<tr><td class="nowrap center"><b>'.$langs->trans("FreshInstall").'</b>';
  332. $choice .= '</td>';
  333. $choice .= '<td class="listofchoicesdesc">';
  334. $choice .= $langs->trans("FreshInstallDesc");
  335. if (empty($dolibarr_main_db_host)) // This means install process was not run
  336. {
  337. $choice .= '<br>';
  338. //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
  339. $choice .= '<div class="center"><div class="ok">'.$langs->trans("InstallChoiceSuggested").'</div></div>';
  340. // <img src="../theme/eldy/img/tick.png" alt="Ok"> ';
  341. $foundrecommandedchoice=1; // To show only once
  342. }
  343. $choice .= '</td>';
  344. $choice .= '<td class="center">';
  345. if ($allowinstall)
  346. {
  347. $choice .= '<a class="button" href="fileconf.php?selectlang='.$setuplang.'">'.$langs->trans("Start").'</a>';
  348. }
  349. else
  350. {
  351. $choice .= $langs->trans("InstallNotAllowed");
  352. }
  353. $choice .= '</td>';
  354. $choice .= '</tr>'."\n";
  355. if ($allowinstall) {
  356. $available_choices[] = $choice;
  357. } else {
  358. $notavailable_choices[] = $choice;
  359. }
  360. // Show upgrade lines
  361. $allowupgrade=true;
  362. if (empty($dolibarr_main_db_host)) // This means install process was not run
  363. {
  364. $allowupgrade=false;
  365. }
  366. if (defined("MAIN_NOT_INSTALLED")) $allowupgrade=false;
  367. if (GETPOST('allowupgrade')) $allowupgrade=true;
  368. $migrationscript=array( array('from'=>'3.0.0', 'to'=>'3.1.0'),
  369. array('from'=>'3.1.0', 'to'=>'3.2.0'),
  370. array('from'=>'3.2.0', 'to'=>'3.3.0'),
  371. array('from'=>'3.3.0', 'to'=>'3.4.0'),
  372. array('from'=>'3.4.0', 'to'=>'3.5.0'),
  373. array('from'=>'3.5.0', 'to'=>'3.6.0'),
  374. array('from'=>'3.6.0', 'to'=>'3.7.0'),
  375. array('from'=>'3.7.0', 'to'=>'3.8.0'),
  376. array('from'=>'3.8.0', 'to'=>'3.9.0'),
  377. array('from'=>'3.9.0', 'to'=>'4.0.0'),
  378. array('from'=>'4.0.0', 'to'=>'5.0.0'),
  379. array('from'=>'5.0.0', 'to'=>'6.0.0'),
  380. array('from'=>'6.0.0', 'to'=>'7.0.0'),
  381. array('from'=>'7.0.0', 'to'=>'8.0.0'),
  382. array('from'=>'8.0.0', 'to'=>'9.0.0')
  383. );
  384. $count=0;
  385. foreach ($migrationscript as $migarray)
  386. {
  387. $choice = '';
  388. $count++;
  389. $recommended_choice = false;
  390. $version=DOL_VERSION;
  391. $versionfrom=$migarray['from'];
  392. $versionto=$migarray['to'];
  393. $versionarray=preg_split('/[\.-]/',$version);
  394. $dolibarrversionfromarray=preg_split('/[\.-]/',$versionfrom);
  395. $dolibarrversiontoarray=preg_split('/[\.-]/',$versionto);
  396. // Define string newversionxxx that are used for text to show
  397. $newversionfrom=preg_replace('/(\.[0-9]+)$/i','.*',$versionfrom);
  398. $newversionto=preg_replace('/(\.[0-9]+)$/i','.*',$versionto);
  399. $newversionfrombis='';
  400. if (versioncompare($dolibarrversiontoarray,$versionarray) < -2) // From x.y.z -> x.y.z+1
  401. {
  402. $newversionfrombis=' '.$langs->trans("or").' '.$versionto;
  403. }
  404. if ($ok)
  405. {
  406. if (count($dolibarrlastupgradeversionarray) >= 2) // If database access is available and last upgrade version is known
  407. {
  408. // Now we check if this is the first qualified choice
  409. if ($allowupgrade && empty($foundrecommandedchoice) &&
  410. (versioncompare($dolibarrversiontoarray,$dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray,$versionarray) < -2)
  411. )
  412. {
  413. $foundrecommandedchoice=1; // To show only once
  414. $recommended_choice = true;
  415. }
  416. }
  417. else {
  418. // We cannot recommend a choice.
  419. // A version of install may be known, but we need last upgrade.
  420. }
  421. }
  422. $choice .= "\n".'<tr'.($recommended_choice ? ' class="choiceselected"' : '').'>';
  423. $choice .= '<td class="nowrap center"><b>'.$langs->trans("Upgrade").'<br>'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'</b></td>';
  424. $choice .= '<td class="listofchoicesdesc">';
  425. $choice .= $langs->trans("UpgradeDesc");
  426. if ($recommended_choice)
  427. {
  428. $choice .= '<br>';
  429. //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
  430. $choice .= '<div class="center">';
  431. $choice .= '<div class="ok">'.$langs->trans("InstallChoiceSuggested").'</div>';
  432. if ($count < count($migarray)) // There are other choices after
  433. {
  434. print $langs->trans("MigrateIsDoneStepByStep",DOL_VERSION);
  435. }
  436. $choice .= '</div>';
  437. }
  438. $choice .= '</td>';
  439. $choice .= '<td class="center">';
  440. if ($allowupgrade)
  441. {
  442. $disabled=false;
  443. if ($foundrecommandedchoice == 2)
  444. {
  445. $disabled=true;
  446. }
  447. if ($foundrecommandedchoice == 1)
  448. {
  449. $foundrecommandedchoice = 2;
  450. }
  451. if ($disabled)
  452. {
  453. $choice .= '<span class="button">'.$langs->trans("NotAvailable").'</span>';
  454. }
  455. else
  456. {
  457. $choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count<count($migrationscript)?'_'.$versionto:'').'&amp;selectlang='.$setuplang.'&amp;versionfrom='.$versionfrom.'&amp;versionto='.$versionto.'">'.$langs->trans("Start").'</a>';
  458. }
  459. }
  460. else
  461. {
  462. $choice .= $langs->trans("NotAvailable");
  463. }
  464. $choice .= '</td>';
  465. $choice .= '</tr>'."\n";
  466. if ($allowupgrade) {
  467. $available_choices[] = $choice;
  468. } else {
  469. $notavailable_choices[] = $choice;
  470. }
  471. }
  472. // If there is no choice at all, we show all of them.
  473. if (empty($available_choices))
  474. {
  475. $available_choices=$notavailable_choices;
  476. $notavailable_choices=array();
  477. }
  478. // Array of install choices
  479. print"\n";
  480. print '<table width="100%" class="listofchoices">';
  481. foreach ($available_choices as $choice) {
  482. print $choice;
  483. }
  484. print '</table>'."\n";
  485. if (count($notavailable_choices)) {
  486. print '<br><div id="AShowChoices" style="opacity: 0.5">';
  487. print '<img id="availchoice" src="../theme/eldy/img/1downarrow.png"> '.$langs->trans('ShowNotAvailableOptions').'...';
  488. print '</div>';
  489. print '<div id="navail_choices" style="display:none">';
  490. print "<br>\n";
  491. print '<table width="100%" class="listofchoices">';
  492. foreach ($notavailable_choices as $choice) {
  493. print $choice;
  494. }
  495. print '</table>'."\n";
  496. print '</div>';
  497. }
  498. }
  499. }
  500. print '<script type="text/javascript">
  501. $("div#AShowChoices").click(function() {
  502. $("div#navail_choices").toggle();
  503. if ($("div#navail_choices").css("display") == "none") {
  504. $(this).text("'.$langs->trans('ShowNotAvailableOptions').'...");
  505. } else {
  506. $(this).text("'.$langs->trans('HideNotAvailableOptions').'...");
  507. }
  508. });
  509. /*
  510. $(".runupgrade").click(function() {
  511. return confirm("'.dol_escape_js($langs->transnoentitiesnoconv("WarningUpgrade"), 0, 1).'");
  512. });
  513. */
  514. </script>';
  515. dolibarr_install_syslog("- check: end");
  516. pFooter(1); // Never display next button