dolibarr 24.0.0-beta
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 UTF8 is supported
214if (!function_exists("utf8_encode")) {
215 $extensionko[] = 'UTF8';
216 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
217} else {
218 $extensionok[] = 'UTF8';
219}
220
221// Check if intl methods are supported if install is not from DoliWamp. TODO Why ?
222if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
223 if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) {
224 $extensionko[] = 'Intl';
225 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
226 } else {
227 $extensionok[] = 'Intl';
228 }
229}
230
231// Check if Imap is supported
232if (PHP_VERSION_ID <= 80300) {
233 if (!function_exists("imap_open")) {
234 $extensionko[] = 'IMAP';
235 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
236 } else {
237 $extensionok[] = 'IMAP';
238 }
239}
240
241// Check if Zip is supported
242if (!class_exists('ZipArchive')) {
243 $extensionko[] = 'ZIP';
244 // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
245} else {
246 $extensionok[] = 'ZIP';
247}
248
249if (!empty($extensionok)) {
250 //print '<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle pictofixedwidth"> ';
251 print img_picto('', 'tick', 'class="pictofixedwidth"');
252 print $langs->trans("PHPSupport", '<b>'.implode(', ', $extensionok).'</b>')."<br>\n";
253}
254if (!empty($extensionko)) {
255 //print '<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle pictofixedwidth"> ';
256 print img_picto('', 'warning', 'class="pictofixedwidth error"');
257 print $langs->trans("ErrorPHPDoesNotSupport", '<b>'.implode(', ', $extensionko).'</b>')."<br>\n";
258}
259
260
261// Check memory
262$memrequiredorig = '64M';
263$memrequired = 64 * 1024 * 1024;
264$memmaxorig = @ini_get("memory_limit");
265$memmax = @ini_get("memory_limit");
266if ($memmaxorig != '') {
267 $reg = array();
268 preg_match('/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
269 if ($reg[2]) {
270 if (strtoupper($reg[2]) == 'G') {
271 $memmax = (int) $reg[1] * 1024 * 1024 * 1024;
272 }
273 if (strtoupper($reg[2]) == 'M') {
274 $memmax = (int) $reg[1] * 1024 * 1024;
275 }
276 if (strtoupper($reg[2]) == 'K') {
277 $memmax = (int) $reg[1] * 1024;
278 }
279 }
280 if ($memmax >= $memrequired || $memmax == -1) {
281 print img_picto('', 'tick', 'class="pictofixedwidth"');
282 print $langs->trans("PHPMemoryOK", $memmaxorig, $memrequiredorig)."<br>\n";
283 } else {
284 print img_picto('', 'warning', 'class="pictofixedwidth warning"');
285 print $langs->trans("PHPMemoryTooLow", $memmaxorig, $memrequiredorig)."<br>\n";
286 }
287}
288
289// If that config file is present and filled
290clearstatcache();
291if (is_readable($conffile) && filesize($conffile) > 8) {
292 dolibarr_install_syslog("check: conf file '".$conffile."' already defined");
293 $confexists = 1;
294 include_once $conffile;
295
296 $databaseok = 1;
297 if ($databaseok) {
298 // Already installed for all parts (config and database). We can propose upgrade.
299 $allowupgrade = true;
300 } else {
301 $allowupgrade = false;
302 }
303} else {
304 // If not, we create it
305 dolibarr_install_syslog("check: we try to create conf file '".$conffile."'");
306 $confexists = 0;
307
308 // First we try by copying example
309 if (@copy($conffile.".example", $conffile)) {
310 // Success
311 dolibarr_install_syslog("check: successfully copied file ".$conffile.".example into ".$conffile);
312 } else {
313 // If failed, we try to create an empty file
314 dolibarr_install_syslog("check: failed to copy file ".$conffile.".example into ".$conffile.". We try to create it.", LOG_WARNING);
315
316 $fp = @fopen($conffile, "w");
317 if ($fp) {
318 @fwrite($fp, '<?php');
319 @fwrite($fp, "\n");
320 fclose($fp);
321 } else {
322 dolibarr_install_syslog("check: failed to create a new file ".$conffile." into current dir ".getcwd().". Please check permissions.", LOG_ERR);
323 }
324 }
325
326 // First install: no upgrade necessary/required
327 $allowupgrade = false;
328}
329
330
331// File is missing and cannot be created
332if (!file_exists($conffile)) {
333 print '<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle pictofixedwidth"> ';
334 print $langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
335 print '<br><br><div class="error">';
336 print $langs->trans("YouMustCreateWithPermission", $conffiletoshow);
337 print '</div><br><br>'."\n";
338
339 print '<span class="opacitymedium">'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</span>';
340 $err++;
341} else {
342 if (dol_is_dir($conffile)) {
343 print img_picto('', 'warning', 'class="pictofixedwidth error"');
344 print $langs->trans("ConfFileMustBeAFileNotADir", $conffiletoshow);
345
346 $allowinstall = 0;
347 } elseif (!is_writable($conffile)) {
348 // File exists but cannot be modified
349 if ($confexists) {
350 print img_picto('', 'tick', 'class="pictofixedwidth"');
351 print $langs->trans("ConfFileExists", $conffiletoshow);
352 } else {
353 print img_picto('', 'tick', 'class="pictofixedwidth"');
354 print $langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
355 }
356 print "<br>";
357 print img_picto('', 'tick', 'class="pictofixedwidth warning"');
358 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
359 print "<br>\n";
360
361 $allowinstall = 0;
362 } else {
363 // File exists and can be modified
364 if ($confexists) {
365 print img_picto('', 'tick', 'class="pictofixedwidth"');
366 print $langs->trans("ConfFileExists", $conffiletoshow);
367 } else {
368 print img_picto('', 'tick', 'class="pictofixedwidth"');
369 print $langs->trans("ConfFileCouldBeCreated", $conffiletoshow);
370 }
371 print "<br>";
372 print img_picto('', 'tick', 'class="pictofixedwidth"');
373 print $langs->trans("ConfFileIsWritable", $conffiletoshow);
374 print "<br>\n";
375
376 $allowinstall = 1;
377 }
378 print "<br>\n";
379
380 // Requirements met/all ok: display the next step button
381 if ($checksok) {
382 $ok = false;
383 $db = null;
384 $validfoundconf = false;
385
386 // Try to create db connection
387 if (file_exists($conffile)) {
388 include_once $conffile;
389 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
390 if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) {
391 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";
392 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);
393 } else {
394 $validfoundconf = true;
395
396 require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
397
398 // If password is encoded, we decode it
399 if (preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
400 require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
401 if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
402 $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
403 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
404 } elseif (preg_match('/dolcrypt:/i', $dolibarr_main_db_pass)) {
405 $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
406 $dolibarr_main_db_pass = dolDecrypt($dolibarr_main_db_pass);
407 } else {
408 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
409 }
410 }
411
412 // $conf already created in inc.php
413 $conf->db->type = $dolibarr_main_db_type;
414 $conf->db->host = $dolibarr_main_db_host;
415 $conf->db->port = $dolibarr_main_db_port;
416 $conf->db->name = $dolibarr_main_db_name;
417 $conf->db->user = $dolibarr_main_db_user;
418 $conf->db->pass = $dolibarr_main_db_pass;
419
420 $db = getDoliDBInstance($conf->db->type, $conf->db->host, (string) $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
421 if ($db->connected && $db->database_selected) {
422 $ok = true;
423 }
424 }
425 }
426 }
427
428 $dolibarrlastupgradeversionarray = array();
429 // If database access is available, we set more variables
430 if ($db !== null && $ok) {
431 if (empty($dolibarr_main_db_encryption)) {
432 $dolibarr_main_db_encryption = 0;
433 }
434 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
435 if (empty($dolibarr_main_db_cryptkey)) {
436 $dolibarr_main_db_cryptkey = '';
437 }
438 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
439
440 $conf->setValues($db);
441 // Reset forced setup after the setValues
442 if (defined('SYSLOG_FILE')) {
443 $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
444 }
445 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
446
447 // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
448 // Version to install is DOL_VERSION
449 $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', getDolGlobalString('MAIN_VERSION_LAST_UPGRADE', getDolGlobalString('MAIN_VERSION_LAST_INSTALL')));
450 $dolibarrversiontoinstallarray = versiondolibarrarray();
451 } elseif ($validfoundconf) {
452 print 'Failed to connect with data found int the current conf.php file.<br>';
453 }
454
455 // Show title
456 if (getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') || getDolGlobalString('MAIN_VERSION_LAST_INSTALL')) {
457 print $langs->trans("VersionLastUpgrade").' <b><span class="badge-text okinversed">'.getDolGlobalString('MAIN_VERSION_LAST_UPGRADE', getDolGlobalString('MAIN_VERSION_LAST_INSTALL')).'</span></b> &nbsp; - &nbsp; ';
458 print $langs->trans("VersionProgram").' <b><span class="badge-text okinversed">'.DOL_VERSION.'</span></b>';
459 //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
460 print '<br>';
461 print '<br>';
462 } else {
463 print "<br>\n";
464 }
465
466 print '<br>';
467 print '<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
468 print '<span class="soustitre valignmiddle">'.$langs->trans("ChooseYourSetupMode").'</span></h3>';
469
470 $foundrecommandedchoice = 0;
471
472 $available_choices = array();
473 $notavailable_choices = array();
474
475 if (empty($dolibarr_main_db_host)) { // This means install process was not run
476 $foundrecommandedchoice = 1; // To show only once
477 }
478
479 // Show line of first install choice
480 $choice = '<tr class="trlineforchoice'.($foundrecommandedchoice ? ' choiceselected' : '').'">'."\n";
481 $choice .= '<td class="nowrap center firstcolumn"><b>'.$langs->trans("FreshInstall").'</b>';
482 $choice .= '</td>';
483 $choice .= '<td class="listofchoicesdesc">';
484 $choice .= $langs->trans("FreshInstallDesc");
485 if (empty($dolibarr_main_db_host)) { // This means install process was not run
486 $choice .= '<br>';
487 //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
488 $choice .= '<div class="><br>';
489 $choice .= '<div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div>';
490 $choice .= '</div>';
491 }
492
493 $choice .= '</td>';
494 $choice .= '<td class="center lastcolumn">';
495 if ($allowinstall) {
496 $choice .= '<a class="button" href="fileconf.php?selectlang='.$setuplang.'">'.$langs->trans("Start").'</a>';
497 } else {
498 $choice .= ($foundrecommandedchoice ? '<span class="warning">' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? '</span>' : '');
499 }
500 $choice .= '</td>'."\n";
501 $choice .= '</tr>'."\n";
502
503 $positionkey = ($foundrecommandedchoice ? 999 : 0);
504 if ($allowinstall) {
505 $available_choices[$positionkey] = $choice;
506 } else {
507 $notavailable_choices[$positionkey] = $choice;
508 }
509
510 // Show upgrade lines
511 $allowupgrade = true;
512 if (empty($dolibarr_main_db_host)) { // This means install process was not run
513 $allowupgrade = false;
514 }
515 if (getDolGlobalInt("MAIN_NOT_INSTALLED")) {
516 $allowupgrade = false;
517 }
518 if (GETPOST('allowupgrade')) {
519 $allowupgrade = true;
520 }
521
522 $dir = DOL_DOCUMENT_ROOT."/install/mysql/migration/"; // We use mysql migration scripts whatever is database driver
523 dolibarr_install_syslog("Scan sql files for migration files in ".$dir);
524
525 // Get files list of migration file x.y.z-a.b.c.sql into /install/mysql/migration
526 $migrationscript = array();
527 $handle = opendir($dir);
528 if (is_resource($handle)) {
529 $versiontousetoqualifyscript = preg_replace('/-.*/', '', DOL_VERSION);
530 while (($file = readdir($handle)) !== false) {
531 $reg = array();
532 if (preg_match('/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
533 //var_dump(DOL_VERSION." ".$reg[2]." ".$versiontousetoqualifyscript." ".version_compare($versiontousetoqualifyscript, $reg[2]));
534 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
535 $migrationscript[] = array('from' => $reg[1], 'to' => $reg[2]);
536 }
537 }
538 }
539 $migrationscript = dol_sort_array($migrationscript, 'from', 'asc', 1);
540 } else {
541 print '<div class="error">'.$langs->trans("ErrorCanNotReadDir", $dir).'</div>';
542 }
543
544 $count = 0;
545 foreach ($migrationscript as $migarray) {
546 $count++;
547 $recommended_choice = false;
548 $version = DOL_VERSION;
549 $versionfrom = $migarray['from'];
550 $versionto = $migarray['to'];
551 $versionarray = preg_split('/[\.-]/', $version);
552 $dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom);
553 $dolibarrversiontoarray = preg_split('/[\.-]/', $versionto);
554 // Define string newversionxxx that are used for text to show
555 $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
556 $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
557 $newversionfrombis = '';
558 if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) { // From x.y.z -> x.y.z+1
559 $newversionfrombis = ' '.$langs->trans("or").' '.$versionto;
560 }
561
562 if ($ok) {
563 if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known
564 // Now we check if this is the first qualified choice
565 if ($allowupgrade && empty($foundrecommandedchoice) &&
566 (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2)
567 ) {
568 $foundrecommandedchoice = 1; // To show only once
569 $recommended_choice = true;
570 }
571 } else {
572 // We cannot recommend a choice.
573 // A version of install may be known, but we need last upgrade.
574 }
575 }
576
577 $choice = '';
578
579 $choice .= "\n".'<!-- choice '.$count.' -->'."\n";
580 $choice .= '<tr'.($recommended_choice ? ' class="choiceselected"' : '').'>';
581 $choice .= '<td class="nowrap center firstcolumn"><span class="opacitymedium">'.$langs->trans("Upgrade").'</span><br><b>'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'</b></td>';
582 $choice .= '<td class="listofchoicesdesc">';
583 $choice .= $langs->trans("UpgradeDesc");
584
585 if ($recommended_choice) {
586 $choice .= '<br>';
587 //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
588 $choice .= '<div class=""><br>';
589 $choice .= '<div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div>';
590 if ($count < count($migarray)) { // There are other choices after
591 print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION);
592 }
593 $choice .= '</div>';
594 }
595
596 $choice .= '</td>';
597 $choice .= '<td class="center lastcolumn">';
598 if ($allowupgrade) {
599 $disabled = false;
600 if ($foundrecommandedchoice == 2) {
601 $disabled = true;
602 }
603 if ($foundrecommandedchoice == 1) {
604 $foundrecommandedchoice = 2;
605 }
606 if ($disabled) {
607 $choice .= '<span class="opacitymedium">'.$langs->trans("NotYetAvailable").'</span>';
608 } else {
609 $choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ? '_'.$versionto : '').'&amp;selectlang='.$setuplang.'&amp;versionfrom='.$versionfrom.'&amp;versionto='.$versionto.'"';
610 if ($recommended_choice) {
611 $choice .= ' title="'.dol_string_nohtmltag($langs->trans("InstallChoiceSuggested")).'"';
612 } else {
613 $choice .= ' title="'.dol_string_nohtmltag($langs->trans("MigrationAlreadyDone")).'"';
614 }
615 $choice .= '>';
616 $choice .= $langs->trans("Start");
617 $choice .= '</a>';
618 }
619 } else {
620 $choice .= $langs->trans("NotAvailable");
621 }
622 $choice .= '</td>';
623 $choice .= '</tr>'."\n";
624
625 if ($allowupgrade && $recommended_choice) {
626 $available_choices[$count] = $choice;
627 } else {
628 $notavailable_choices[$count] = $choice;
629 }
630 }
631
632 // If there is no choice at all, we show all of them.
633 if (empty($available_choices)) {
634 $available_choices = $notavailable_choices;
635 $notavailable_choices = array();
636 }
637
638 // Array of install choices
639 krsort($available_choices, SORT_NATURAL);
640 print"\n";
641 print '<table width="100%" class="listofchoices">';
642 foreach ($available_choices as $choice) {
643 print $choice;
644 }
645
646 print '</table>'."\n";
647
648 if (count($notavailable_choices)) {
649 print '<br><div id="AShowChoices" class="opacitymedium cursorpointer">';
650 print '> '.$langs->trans('ShowNotAvailableOptions').'...';
651 print '</div>';
652
653 print '<div id="navail_choices" style="display:none">';
654 print "<br>\n";
655 print '<table class="centpercent listofchoices">';
656 foreach ($notavailable_choices as $choice) {
657 print $choice;
658 }
659
660 print '</table>'."\n";
661 print '</div>';
662 }
663 }
664}
665
666print '<script type="text/javascript">
667
668$("div#AShowChoices").click(function() {
669
670 $("div#navail_choices").toggle();
671
672 if ($("div#navail_choices").css("display") == "none") {
673 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv('ShowNotAvailableOptions')).'...\');
674 } else {
675 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv('HideNotAvailableOptions')).'...\');
676 }
677
678});
679
680/*
681$(".runupgrade").click(function() {
682 return confirm("'.dol_escape_js($langs->transnoentitiesnoconv("WarningUpgrade"), 0, 1).'");
683});
684*/
685
686</script>';
687
688dolibarr_install_syslog("- check: end");
689pFooter(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...
getBrowserInfo($user_agent)
Return information about user browser.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:541
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:635
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:699
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.