dolibarr 24.0.1
check.php
Go to the documentation of this file.
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 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32define('ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
33include_once 'inc.php';
55'
56@phan-var-force string $lockfile
57@phan-var-force string $lockfile2
58';
59
60$err = 0;
61$allowinstall = 0;
62$allowupgrade = false;
63$checksok = 1;
64
65$setuplang = GETPOST("selectlang", 'aZ09', 3) ? GETPOST("selectlang", 'aZ09', 3) : $langs->getDefaultLang();
66$langs->setDefaultLang($setuplang);
67
68$langs->loadLangs(array("install", "errors"));
69
70// Now we load forced/pre-set values from install.forced.php file.
71$useforcedwizard = false;
72$forcedfile = "./install.forced.php";
73if ($conffile == "/etc/dolibarr/conf.php") {
74 $forcedfile = "/etc/dolibarr/install.forced.php";
75}
76if (@file_exists($forcedfile)) {
77 $useforcedwizard = true;
78 include_once $forcedfile;
79}
80
81dolibarr_install_syslog("- check: Dolibarr install/upgrade process started");
82
83
84/*
85 * View
86 */
87
88pHeader('', ''); // No next step for navigation buttons. Next step is defined by click on links.
89
90
91print '<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
92print '<span class="inline-block valignmiddle">'.$langs->trans("MiscellaneousChecks")."</span></h3>\n";
93
94// Check browser
95$useragent = $_SERVER['HTTP_USER_AGENT'];
96if (!empty($useragent)) {
97 $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
98 $browserversion = $tmp['browserversion'];
99 $browsername = $tmp['browsername'];
100 if ($browsername == 'ie' && $browserversion < 7) {
101 print img_picto('', 'warning', 'class="pictofixedwidth warning"');
102 print $langs->trans("WarningBrowserTooOld")."<br>\n";
103 }
104}
105
106
107// Check PHP version min
108$arrayphpminversionerror = array(7, 1, 0);
109$arrayphpminversionwarning = array(7, 2, 0);
110if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) { // Minimum to use (error if lower)
111 print img_picto('', 'warning', 'class="pictofixedwidth error"');
112 print $langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
113 $checksok = 0; // 0=error, 1=warning
114} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) { // Minimum supported (warning if lower)
115 print img_picto('', 'warning', 'class="pictofixedwidth warning"');
116 print $langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
117 $checksok = 1; // 0=error, 1=warning
118} else {
119 print img_picto('', 'tick', 'class="pictofixedwidth"');
120 print $langs->trans("PHPVersion")." ".versiontostring(versionphparray());
121}
122if (empty($force_install_nophpinfo) && (!file_exists($lockfile) && !file_exists($lockfile2))) { // Do not show sensible information in update process, only in install process.
123 print ' (<a href="phpinfo.php" target="_blank" rel="noopener noreferrer">';
124 $conf->use_javascript_ajax = 1; // We suppose javascript is on for install process
125 print dolButtonToOpenUrlInDialogPopup('phpinfo', $langs->trans("MoreInformation"), $langs->trans("MoreInformation"), '/install/phpinfo.php', '', '');
126 print '</a>)';
127}
128print "<br>\n";
129
130// Check PHP version max
131$arrayphpmaxversionwarning = array(8, 5, 0);
132if (versioncompare(versionphparray(), $arrayphpmaxversionwarning) > 0 && versioncompare(versionphparray(), $arrayphpmaxversionwarning) < 3) { // Maximum to use (warning if higher)
133 print img_picto('', 'warning', 'class="pictofixedwidth error"');
134 print $langs->trans("ErrorPHPVersionTooHigh", versiontostring($arrayphpmaxversionwarning));
135 $checksok = 1; // 0=error, 1=warning
136 print "<br>\n";
137}
138
139
140// Check PHP support for $_GET and $_POST
141if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) { // We must keep $_GET and $_POST here
142 print img_picto('', 'warning', 'class="pictofixedwidth warning"');
143 print $langs->trans("PHPSupportPOSTGETKo");
144 print ' (<a href="'.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?testget=ok">'.$langs->trans("Recheck").'</a>)';
145 print "<br>\n";
146 $checksok = 0;
147} else {
148 print img_picto('', 'tick', 'class="pictofixedwidth"');
149 print $langs->trans("PHPSupportPOSTGETOk")."<br>\n";
150}
151
152
153// Check if session_id is enabled
154if (!function_exists("session_id")) {
155 print img_picto('', 'warning', 'class="pictofixedwidth error"');
156 print $langs->trans("ErrorPHPDoesNotSupportSessions")."<br>\n";
157 $checksok = 0;
158} else {
159 print img_picto('', 'tick', 'class="pictofixedwidth"');
160 print $langs->trans("PHPSupportSessions")."<br>\n";
161}
162
163$extensionok = array();
164$extensionko = array();
165
166// Check for mbstring extension
167if (!extension_loaded("mbstring")) {
168 $extensionko[] = 'MBString';
169 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
170} else {
171 $extensionok[] = 'MBString';
172}
173
174// Check for json extension
175if (!extension_loaded("json")) {
176 $extensionko[] = 'JSON';
177 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
178} else {
179 $extensionok[] = 'JSON';
180}
181
182// Check if GD is supported (we need GD for image conversion)
183if (!function_exists("imagecreate")) {
184 $extensionko[] = 'GD';
185 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
186} else {
187 $extensionok[] = 'GD';
188}
189
190// Check if Curl is supported
191if (!function_exists("curl_init")) {
192 $extensionko[] = 'Curl';
193 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
194} else {
195 $extensionok[] = 'Curl';
196}
197
198// Check if PHP calendar extension is available
199if (!function_exists("easter_date")) {
200 $extensionko[] = 'Calendar';
201} else {
202 $extensionok[] = 'Calendar';
203}
204
205// Check if Xml is supported
206if (!function_exists("simplexml_load_string")) {
207 $extensionko[] = 'Xml';
208 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
209} else {
210 $extensionok[] = 'Xml';
211}
212
213// Check if Dom is supported. Dolibarr uses DOMDocument to sanitize html, so a page can not even be rendered without it.
214if (!extension_loaded("dom")) {
215 $langs->load("errors");
216 print '<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle paddingright"> '.$langs->trans("ErrorPHPDoesNotSupport", "Dom")."<br>\n";
217 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
218} else {
219 print '<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle paddingright"> '.$langs->trans("PHPSupport", "Dom")."<br>\n";
220}
221
222// Check if UTF8 is supported
223if (!function_exists("utf8_encode")) {
224 $extensionko[] = 'UTF8';
225 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
226} else {
227 $extensionok[] = 'UTF8';
228}
229
230// Check if intl methods are supported if install is not from DoliWamp. TODO Why ?
231if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
232 if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) {
233 $extensionko[] = 'Intl';
234 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
235 } else {
236 $extensionok[] = 'Intl';
237 }
238}
239
240// Check if Imap is supported
241if (PHP_VERSION_ID <= 80300) {
242 if (!function_exists("imap_open")) {
243 $extensionko[] = 'IMAP';
244 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
245 } else {
246 $extensionok[] = 'IMAP';
247 }
248}
249
250// Check if Zip is supported
251if (!class_exists('ZipArchive')) {
252 $extensionko[] = 'ZIP';
253 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
254} else {
255 $extensionok[] = 'ZIP';
256}
257
258if (!empty($extensionok)) {
259 //print '<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle pictofixedwidth"> ';
260 print img_picto('', 'tick', 'class="pictofixedwidth"');
261 print $langs->trans("PHPSupport", '<b>'.implode(', ', $extensionok).'</b>')."<br>\n";
262}
263if (!empty($extensionko)) {
264 //print '<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle pictofixedwidth"> ';
265 print img_picto('', 'warning', 'class="pictofixedwidth error"');
266 print $langs->trans("ErrorPHPDoesNotSupport", '<b>'.implode(', ', $extensionko).'</b>')."<br>\n";
267}
268
269
270// Check memory
271$memrequiredorig = '64M';
272$memrequired = 64 * 1024 * 1024;
273$memmaxorig = @ini_get("memory_limit");
274$memmax = @ini_get("memory_limit");
275if ($memmaxorig != '') {
276 $reg = array();
277 preg_match('/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
278 if ($reg[2]) {
279 if (strtoupper($reg[2]) == 'G') {
280 $memmax = (int) $reg[1] * 1024 * 1024 * 1024;
281 }
282 if (strtoupper($reg[2]) == 'M') {
283 $memmax = (int) $reg[1] * 1024 * 1024;
284 }
285 if (strtoupper($reg[2]) == 'K') {
286 $memmax = (int) $reg[1] * 1024;
287 }
288 }
289 if ($memmax >= $memrequired || $memmax == -1) {
290 print img_picto('', 'tick', 'class="pictofixedwidth"');
291 print $langs->trans("PHPMemoryOK", $memmaxorig, $memrequiredorig)."<br>\n";
292 } else {
293 print img_picto('', 'warning', 'class="pictofixedwidth warning"');
294 print $langs->trans("PHPMemoryTooLow", $memmaxorig, $memrequiredorig)."<br>\n";
295 }
296}
297
298// If that config file is present and filled
299clearstatcache();
300if (is_readable($conffile) && filesize($conffile) > 8) {
301 dolibarr_install_syslog("check: conf file '".$conffile."' already defined");
302 $confexists = 1;
303 include_once $conffile;
304
305 $databaseok = 1;
306 if ($databaseok) {
307 // Already installed for all parts (config and database). We can propose upgrade.
308 $allowupgrade = true;
309 } else {
310 $allowupgrade = false;
311 }
312} else {
313 // If not, we create it
314 dolibarr_install_syslog("check: we try to create conf file '".$conffile."'");
315 $confexists = 0;
316
317 // First we try by copying example
318 if (@copy($conffile.".example", $conffile)) {
319 // Success
320 dolibarr_install_syslog("check: successfully copied file ".$conffile.".example into ".$conffile);
321 } else {
322 // If failed, we try to create an empty file
323 dolibarr_install_syslog("check: failed to copy file ".$conffile.".example into ".$conffile.". We try to create it.", LOG_WARNING);
324
325 $fp = @fopen($conffile, "w");
326 if ($fp) {
327 @fwrite($fp, '<?php');
328 @fwrite($fp, "\n");
329 fclose($fp);
330 } else {
331 dolibarr_install_syslog("check: failed to create a new file ".$conffile." into current dir ".getcwd().". Please check permissions.", LOG_ERR);
332 }
333 }
334
335 // First install: no upgrade necessary/required
336 $allowupgrade = false;
337}
338
339
340// File is missing and cannot be created
341if (!file_exists($conffile)) {
342 print '<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle pictofixedwidth"> ';
343 print $langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
344 print '<br><br><div class="error">';
345 print $langs->trans("YouMustCreateWithPermission", $conffiletoshow);
346 print '</div><br><br>'."\n";
347
348 print '<span class="opacitymedium">'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</span>';
349 $err++;
350} else {
351 if (dol_is_dir($conffile)) {
352 print img_picto('', 'warning', 'class="pictofixedwidth error"');
353 print $langs->trans("ConfFileMustBeAFileNotADir", $conffiletoshow);
354
355 $allowinstall = 0;
356 } elseif (!is_writable($conffile)) {
357 // File exists but cannot be modified
358 if ($confexists) {
359 print img_picto('', 'tick', 'class="pictofixedwidth"');
360 print $langs->trans("ConfFileExists", $conffiletoshow);
361 } else {
362 print img_picto('', 'tick', 'class="pictofixedwidth"');
363 print $langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
364 }
365 print "<br>";
366 print img_picto('', 'tick', 'class="pictofixedwidth warning"');
367 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
368 print "<br>\n";
369
370 $allowinstall = 0;
371 } else {
372 // File exists and can be modified
373 if ($confexists) {
374 print img_picto('', 'tick', 'class="pictofixedwidth"');
375 print $langs->trans("ConfFileExists", $conffiletoshow);
376 } else {
377 print img_picto('', 'tick', 'class="pictofixedwidth"');
378 print $langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
379 }
380 print "<br>";
381 print img_picto('', 'tick', 'class="pictofixedwidth"');
382 print $langs->trans("ConfFileIsWritable", $conffiletoshow);
383 print "<br>\n";
384
385 $allowinstall = 1;
386 }
387 print "<br>\n";
388
389 // Requirements met/all ok: display the next step button
390 if ($checksok) {
391 $ok = false;
392 $db = null;
393 $validfoundconf = false;
394
395 // Try to create db connection
396 if (file_exists($conffile)) {
397 include_once $conffile;
398 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
399 if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) {
400 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";
401 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);
402 } else {
403 $validfoundconf = true;
404
405 require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
406
407 // If password is encoded, we decode it
408 if (preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
409 require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
410 if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
411 $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 encrypted
412 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
413 } elseif (preg_match('/dolcrypt:/i', $dolibarr_main_db_pass)) {
414 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially encrypted
415 $dolibarr_main_db_pass = dolDecrypt($dolibarr_main_db_pass);
416 } else {
417 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
418 }
419 }
420
421 // $conf already created in inc.php
422 $conf->db->type = $dolibarr_main_db_type;
423 $conf->db->host = $dolibarr_main_db_host;
424 $conf->db->port = $dolibarr_main_db_port;
425 $conf->db->name = $dolibarr_main_db_name;
426 $conf->db->user = $dolibarr_main_db_user;
427 $conf->db->pass = $dolibarr_main_db_pass;
428
429 $db = getDoliDBInstance($conf->db->type, $conf->db->host, (string) $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
430 if ($db->connected && $db->database_selected) {
431 $ok = true;
432 }
433 }
434 }
435 }
436
437 $dolibarrlastupgradeversionarray = array();
438 // If database access is available, we set more variables
439 if ($db !== null && $ok) {
440 if (empty($dolibarr_main_db_encryption)) {
441 $dolibarr_main_db_encryption = 0;
442 }
443 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
444 if (empty($dolibarr_main_db_cryptkey)) {
445 $dolibarr_main_db_cryptkey = '';
446 }
447 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
448
449 $conf->setValues($db);
450 // Reset forced setup after the setValues
451 if (defined('SYSLOG_FILE')) {
452 $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
453 }
454 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
455
456 // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
457 // Version to install is DOL_VERSION
458 $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', getDolGlobalString('MAIN_VERSION_LAST_UPGRADE', getDolGlobalString('MAIN_VERSION_LAST_INSTALL')));
459 $dolibarrversiontoinstallarray = versiondolibarrarray();
460 } elseif ($validfoundconf) {
461 print 'Failed to connect with data found in the current conf.php file.<br>';
462 }
463
464 // Show title
465 if (getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') || getDolGlobalString('MAIN_VERSION_LAST_INSTALL')) {
466 print $langs->trans("VersionLastUpgrade").' <b><span class="badge-text okinversed">'.getDolGlobalString('MAIN_VERSION_LAST_UPGRADE', getDolGlobalString('MAIN_VERSION_LAST_INSTALL')).'</span></b> &nbsp; - &nbsp; ';
467 print $langs->trans("VersionProgram").' <b><span class="badge-text okinversed">'.DOL_VERSION.'</span></b>';
468 //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
469 print '<br>';
470 print '<br>';
471 } else {
472 print "<br>\n";
473 }
474
475 print '<br>';
476 print '<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
477 print '<span class="soustitre valignmiddle">'.$langs->trans("ChooseYourSetupMode").'</span></h3>';
478
479 $foundrecommandedchoice = 0;
480
481 $available_choices = array();
482 $notavailable_choices = array();
483
484 if (empty($dolibarr_main_db_host)) { // This means install process was not run
485 $foundrecommandedchoice = 1; // To show only once
486 }
487
488 // Show line of first install choice
489 $choice = '<tr class="trlineforchoice'.($foundrecommandedchoice ? ' choiceselected' : '').'">'."\n";
490 $choice .= '<td class="nowrap center firstcolumn"><b>'.$langs->trans("FreshInstall").'</b>';
491 $choice .= '</td>';
492 $choice .= '<td class="listofchoicesdesc">';
493 $choice .= $langs->trans("FreshInstallDesc");
494 if (empty($dolibarr_main_db_host)) { // This means install process was not run
495 $choice .= '<br>';
496 //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
497 $choice .= '<div class="><br>';
498 $choice .= '<div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div>';
499 $choice .= '</div>';
500 }
501
502 $choice .= '</td>';
503 $choice .= '<td class="center lastcolumn">';
504 if ($allowinstall) {
505 $choice .= '<a class="button" href="fileconf.php?selectlang='.$setuplang.'">'.$langs->trans("Start").'</a>';
506 } else {
507 $choice .= ($foundrecommandedchoice ? '<span class="warning">' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? '</span>' : '');
508 }
509 $choice .= '</td>'."\n";
510 $choice .= '</tr>'."\n";
511
512 $positionkey = ($foundrecommandedchoice ? 999 : 0);
513 if ($allowinstall) {
514 $available_choices[$positionkey] = $choice;
515 } else {
516 $notavailable_choices[$positionkey] = $choice;
517 }
518
519 // Show upgrade lines
520 $allowupgrade = true;
521 if (empty($dolibarr_main_db_host)) { // This means install process was not run
522 $allowupgrade = false;
523 }
524 if (getDolGlobalInt("MAIN_NOT_INSTALLED")) {
525 $allowupgrade = false;
526 }
527 if (GETPOST('allowupgrade')) {
528 $allowupgrade = true;
529 }
530
531 $dir = DOL_DOCUMENT_ROOT."/install/mysql/migration/"; // We use mysql migration scripts whatever is database driver
532 dolibarr_install_syslog("Scan sql files for migration files in ".$dir);
533
534 // Get files list of migration file x.y.z-a.b.c.sql into /install/mysql/migration
535 $migrationscript = array();
536 $handle = opendir($dir);
537 if (is_resource($handle)) {
538 $versiontousetoqualifyscript = preg_replace('/-.*/', '', DOL_VERSION);
539 while (($file = readdir($handle)) !== false) {
540 $reg = array();
541 if (preg_match('/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
542 //var_dump(DOL_VERSION." ".$reg[2]." ".$versiontousetoqualifyscript." ".version_compare($versiontousetoqualifyscript, $reg[2]));
543 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
544 $migrationscript[] = array('from' => $reg[1], 'to' => $reg[2]);
545 }
546 }
547 }
548 $migrationscript = dol_sort_array($migrationscript, 'from', 'asc', 1);
549 } else {
550 print '<div class="error">'.$langs->trans("ErrorCanNotReadDir", $dir).'</div>';
551 }
552
553 $count = 0;
554 foreach ($migrationscript as $migarray) {
555 $count++;
556 $recommended_choice = false;
557 $version = DOL_VERSION;
558 $versionfrom = $migarray['from'];
559 $versionto = $migarray['to'];
560 $versionarray = preg_split('/[\.-]/', $version);
561 $dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom);
562 $dolibarrversiontoarray = preg_split('/[\.-]/', $versionto);
563 // Define string newversionxxx that are used for text to show
564 $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
565 $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
566 $newversionfrombis = '';
567 if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) { // From x.y.z -> x.y.z+1
568 $newversionfrombis = ' '.$langs->trans("or").' '.$versionto;
569 }
570
571 if ($ok) {
572 if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known
573 // Now we check if this is the first qualified choice
574 if ($allowupgrade && empty($foundrecommandedchoice) &&
575 (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2)
576 ) {
577 $foundrecommandedchoice = 1; // To show only once
578 $recommended_choice = true;
579 }
580 } else {
581 // We cannot recommend a choice.
582 // A version of install may be known, but we need last upgrade.
583 }
584 }
585
586 $choice = '';
587
588 $choice .= "\n".'<!-- choice '.$count.' -->'."\n";
589 $choice .= '<tr'.($recommended_choice ? ' class="choiceselected"' : '').'>';
590 $choice .= '<td class="nowrap center firstcolumn"><span class="opacitymedium">'.$langs->trans("Upgrade").'</span><br><b>'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'</b></td>';
591 $choice .= '<td class="listofchoicesdesc">';
592 $choice .= $langs->trans("UpgradeDesc");
593
594 if ($recommended_choice) {
595 $choice .= '<br>';
596 //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
597 $choice .= '<div class=""><br>';
598 $choice .= '<div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div>';
599 if ($count < count($migarray)) { // There are other choices after
600 print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION);
601 }
602 $choice .= '</div>';
603 }
604
605 $choice .= '</td>';
606 $choice .= '<td class="center lastcolumn">';
607 if ($allowupgrade) {
608 $disabled = false;
609 if ($foundrecommandedchoice == 2) {
610 $disabled = true;
611 }
612 if ($foundrecommandedchoice == 1) {
613 $foundrecommandedchoice = 2;
614 }
615 if ($disabled) {
616 $choice .= '<span class="opacitymedium">'.$langs->trans("NotYetAvailable").'</span>';
617 } else {
618 $choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ? '_'.$versionto : '').'&amp;selectlang='.$setuplang.'&amp;versionfrom='.$versionfrom.'&amp;versionto='.$versionto.'"';
619 if ($recommended_choice) {
620 $choice .= ' title="'.dol_string_nohtmltag($langs->trans("InstallChoiceSuggested")).'"';
621 } else {
622 $choice .= ' title="'.dol_string_nohtmltag($langs->trans("MigrationAlreadyDone")).'"';
623 }
624 $choice .= '>';
625 $choice .= $langs->trans("Start");
626 $choice .= '</a>';
627 }
628 } else {
629 $choice .= $langs->trans("NotAvailable");
630 }
631 $choice .= '</td>';
632 $choice .= '</tr>'."\n";
633
634 if ($allowupgrade && $recommended_choice) {
635 $available_choices[$count] = $choice;
636 } else {
637 $notavailable_choices[$count] = $choice;
638 }
639 }
640
641 // If there is no choice at all, we show all of them.
642 if (empty($available_choices)) {
643 $available_choices = $notavailable_choices;
644 $notavailable_choices = array();
645 }
646
647 // Array of install choices
648 krsort($available_choices, SORT_NATURAL);
649 print"\n";
650 print '<table width="100%" class="listofchoices">';
651 foreach ($available_choices as $choice) {
652 print $choice;
653 }
654
655 print '</table>'."\n";
656
657 if (count($notavailable_choices)) {
658 print '<br><div id="AShowChoices" class="opacitymedium cursorpointer">';
659 print '> '.$langs->trans('ShowNotAvailableOptions').'...';
660 print '</div>';
661
662 print '<div id="navail_choices" style="display:none">';
663 print "<br>\n";
664 print '<table class="centpercent listofchoices">';
665 foreach ($notavailable_choices as $choice) {
666 print $choice;
667 }
668
669 print '</table>'."\n";
670 print '</div>';
671 }
672 }
673}
674
675print '<script type="text/javascript">
676
677$("div#AShowChoices").click(function() {
678
679 $("div#navail_choices").toggle();
680
681 if ($("div#navail_choices").css("display") == "none") {
682 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv('ShowNotAvailableOptions')).'...\');
683 } else {
684 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv('HideNotAvailableOptions')).'...\');
685 }
686
687});
688
689/*
690$(".runupgrade").click(function() {
691 return confirm("'.dol_escape_js($langs->transnoentitiesnoconv("WarningUpgrade"), 0, 1).'");
692});
693*/
694
695</script>';
696
697dolibarr_install_syslog("- check: end");
698pFooter(1); // Never display next button
versiontostring($versionarray)
Return a version in a string from a version into an array.
Definition admin.lib.php:40
versiondolibarrarray()
Return version Dolibarr.
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
Definition admin.lib.php:72
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
$conffile
dol_is_dir($folder)
Test if filename is a directory.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getBrowserInfo($user_agent)
Return information about user browser.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
Definition inc.php:551
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:645
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:709
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.