dolibarr 23.0.3
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-2025 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 $validfoundconf = false;
384
385 // Try to create db connection
386 if (file_exists($conffile)) {
387 include_once $conffile;
388 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
389 if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) {
390 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";
391 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);
392 } else {
393 $validfoundconf = true;
394
395 require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
396
397 // If password is encoded, we decode it
398 if (preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
399 require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
400 if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
401 $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
402 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
403 } elseif (preg_match('/dolcrypt:/i', $dolibarr_main_db_pass)) {
404 $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
405 $dolibarr_main_db_pass = dolDecrypt($dolibarr_main_db_pass);
406 } else {
407 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
408 }
409 }
410
411 // $conf already created in inc.php
412 $conf->db->type = $dolibarr_main_db_type;
413 $conf->db->host = $dolibarr_main_db_host;
414 $conf->db->port = $dolibarr_main_db_port;
415 $conf->db->name = $dolibarr_main_db_name;
416 $conf->db->user = $dolibarr_main_db_user;
417 $conf->db->pass = $dolibarr_main_db_pass;
418
419 $db = getDoliDBInstance($conf->db->type, $conf->db->host, (string) $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
420 if ($db->connected && $db->database_selected) {
421 $ok = true;
422 }
423 }
424 }
425 }
426
427 $dolibarrlastupgradeversionarray = array();
428 // If database access is available, we set more variables
429 if ($ok) {
430 if (empty($dolibarr_main_db_encryption)) {
431 $dolibarr_main_db_encryption = 0;
432 }
433 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
434 if (empty($dolibarr_main_db_cryptkey)) {
435 $dolibarr_main_db_cryptkey = '';
436 }
437 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
438
439 $conf->setValues($db);
440 // Reset forced setup after the setValues
441 if (defined('SYSLOG_FILE')) {
442 $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
443 }
444 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
445
446 // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
447 // Version to install is DOL_VERSION
448 $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', getDolGlobalString('MAIN_VERSION_LAST_UPGRADE', getDolGlobalString('MAIN_VERSION_LAST_INSTALL')));
449 $dolibarrversiontoinstallarray = versiondolibarrarray();
450 } elseif ($validfoundconf) {
451 print 'Failed to connect with data found int the current conf.php file.<br>';
452 }
453
454 // Show title
455 if (getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') || getDolGlobalString('MAIN_VERSION_LAST_INSTALL')) {
456 print $langs->trans("VersionLastUpgrade").' <b><span class="badge-text okinversed">'.getDolGlobalString('MAIN_VERSION_LAST_UPGRADE', getDolGlobalString('MAIN_VERSION_LAST_INSTALL')).'</span></b> &nbsp; - &nbsp; ';
457 print $langs->trans("VersionProgram").' <b><span class="badge-text okinversed">'.DOL_VERSION.'</span></b>';
458 //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
459 print '<br>';
460 print '<br>';
461 } else {
462 print "<br>\n";
463 }
464
465 print '<br>';
466 print '<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
467 print '<span class="soustitre valignmiddle">'.$langs->trans("ChooseYourSetupMode").'</span></h3>';
468
469 $foundrecommandedchoice = 0;
470
471 $available_choices = array();
472 $notavailable_choices = array();
473
474 if (empty($dolibarr_main_db_host)) { // This means install process was not run
475 $foundrecommandedchoice = 1; // To show only once
476 }
477
478 // Show line of first install choice
479 $choice = '<tr class="trlineforchoice'.($foundrecommandedchoice ? ' choiceselected' : '').'">'."\n";
480 $choice .= '<td class="nowrap center firstcolumn"><b>'.$langs->trans("FreshInstall").'</b>';
481 $choice .= '</td>';
482 $choice .= '<td class="listofchoicesdesc">';
483 $choice .= $langs->trans("FreshInstallDesc");
484 if (empty($dolibarr_main_db_host)) { // This means install process was not run
485 $choice .= '<br>';
486 //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
487 $choice .= '<div class="><br>';
488 $choice .= '<div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div>';
489 $choice .= '</div>';
490 }
491
492 $choice .= '</td>';
493 $choice .= '<td class="center lastcolumn">';
494 if ($allowinstall) {
495 $choice .= '<a class="button" href="fileconf.php?selectlang='.$setuplang.'">'.$langs->trans("Start").'</a>';
496 } else {
497 $choice .= ($foundrecommandedchoice ? '<span class="warning">' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? '</span>' : '');
498 }
499 $choice .= '</td>'."\n";
500 $choice .= '</tr>'."\n";
501
502 $positionkey = ($foundrecommandedchoice ? 999 : 0);
503 if ($allowinstall) {
504 $available_choices[$positionkey] = $choice;
505 } else {
506 $notavailable_choices[$positionkey] = $choice;
507 }
508
509 // Show upgrade lines
510 $allowupgrade = true;
511 if (empty($dolibarr_main_db_host)) { // This means install process was not run
512 $allowupgrade = false;
513 }
514 if (getDolGlobalInt("MAIN_NOT_INSTALLED")) {
515 $allowupgrade = false;
516 }
517 if (GETPOST('allowupgrade')) {
518 $allowupgrade = true;
519 }
520
521 $dir = DOL_DOCUMENT_ROOT."/install/mysql/migration/"; // We use mysql migration scripts whatever is database driver
522 dolibarr_install_syslog("Scan sql files for migration files in ".$dir);
523
524 // Get files list of migration file x.y.z-a.b.c.sql into /install/mysql/migration
525 $migrationscript = array();
526 $handle = opendir($dir);
527 if (is_resource($handle)) {
528 $versiontousetoqualifyscript = preg_replace('/-.*/', '', DOL_VERSION);
529 while (($file = readdir($handle)) !== false) {
530 $reg = array();
531 if (preg_match('/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
532 //var_dump(DOL_VERSION." ".$reg[2]." ".$versiontousetoqualifyscript." ".version_compare($versiontousetoqualifyscript, $reg[2]));
533 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
534 $migrationscript[] = array('from' => $reg[1], 'to' => $reg[2]);
535 }
536 }
537 }
538 $migrationscript = dol_sort_array($migrationscript, 'from', 'asc', 1);
539 } else {
540 print '<div class="error">'.$langs->trans("ErrorCanNotReadDir", $dir).'</div>';
541 }
542
543 $count = 0;
544 foreach ($migrationscript as $migarray) {
545 $count++;
546 $recommended_choice = false;
547 $version = DOL_VERSION;
548 $versionfrom = $migarray['from'];
549 $versionto = $migarray['to'];
550 $versionarray = preg_split('/[\.-]/', $version);
551 $dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom);
552 $dolibarrversiontoarray = preg_split('/[\.-]/', $versionto);
553 // Define string newversionxxx that are used for text to show
554 $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
555 $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
556 $newversionfrombis = '';
557 if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) { // From x.y.z -> x.y.z+1
558 $newversionfrombis = ' '.$langs->trans("or").' '.$versionto;
559 }
560
561 if ($ok) {
562 if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known
563 // Now we check if this is the first qualified choice
564 if ($allowupgrade && empty($foundrecommandedchoice) &&
565 (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2)
566 ) {
567 $foundrecommandedchoice = 1; // To show only once
568 $recommended_choice = true;
569 }
570 } else {
571 // We cannot recommend a choice.
572 // A version of install may be known, but we need last upgrade.
573 }
574 }
575
576 $choice = '';
577
578 $choice .= "\n".'<!-- choice '.$count.' -->'."\n";
579 $choice .= '<tr'.($recommended_choice ? ' class="choiceselected"' : '').'>';
580 $choice .= '<td class="nowrap center firstcolumn"><span class="opacitymedium">'.$langs->trans("Upgrade").'</span><br><b>'.$newversionfrom.$newversionfrombis.' -> '.$newversionto.'</b></td>';
581 $choice .= '<td class="listofchoicesdesc">';
582 $choice .= $langs->trans("UpgradeDesc");
583
584 if ($recommended_choice) {
585 $choice .= '<br>';
586 //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
587 $choice .= '<div class=""><br>';
588 $choice .= '<div class="ok suggestedchoice">'.$langs->trans("InstallChoiceSuggested").'</div>';
589 if ($count < count($migarray)) { // There are other choices after
590 print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION);
591 }
592 $choice .= '</div>';
593 }
594
595 $choice .= '</td>';
596 $choice .= '<td class="center lastcolumn">';
597 if ($allowupgrade) {
598 $disabled = false;
599 if ($foundrecommandedchoice == 2) {
600 $disabled = true;
601 }
602 if ($foundrecommandedchoice == 1) {
603 $foundrecommandedchoice = 2;
604 }
605 if ($disabled) {
606 $choice .= '<span class="opacitymedium">'.$langs->trans("NotYetAvailable").'</span>';
607 } else {
608 $choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ? '_'.$versionto : '').'&amp;selectlang='.$setuplang.'&amp;versionfrom='.$versionfrom.'&amp;versionto='.$versionto.'"';
609 if ($recommended_choice) {
610 $choice .= ' title="'.dol_string_nohtmltag($langs->trans("InstallChoiceSuggested")).'"';
611 } else {
612 $choice .= ' title="'.dol_string_nohtmltag($langs->trans("MigrationAlreadyDone")).'"';
613 }
614 $choice .= '>';
615 $choice .= $langs->trans("Start");
616 $choice .= '</a>';
617 }
618 } else {
619 $choice .= $langs->trans("NotAvailable");
620 }
621 $choice .= '</td>';
622 $choice .= '</tr>'."\n";
623
624 if ($allowupgrade && $recommended_choice) {
625 $available_choices[$count] = $choice;
626 } else {
627 $notavailable_choices[$count] = $choice;
628 }
629 }
630
631 // If there is no choice at all, we show all of them.
632 if (empty($available_choices)) {
633 $available_choices = $notavailable_choices;
634 $notavailable_choices = array();
635 }
636
637 // Array of install choices
638 krsort($available_choices, SORT_NATURAL);
639 print"\n";
640 print '<table width="100%" class="listofchoices">';
641 foreach ($available_choices as $choice) {
642 print $choice;
643 }
644
645 print '</table>'."\n";
646
647 if (count($notavailable_choices)) {
648 print '<br><div id="AShowChoices" class="opacitymedium cursorpointer">';
649 print '> '.$langs->trans('ShowNotAvailableOptions').'...';
650 print '</div>';
651
652 print '<div id="navail_choices" style="display:none">';
653 print "<br>\n";
654 print '<table class="centpercent listofchoices">';
655 foreach ($notavailable_choices as $choice) {
656 print $choice;
657 }
658
659 print '</table>'."\n";
660 print '</div>';
661 }
662 }
663}
664
665print '<script type="text/javascript">
666
667$("div#AShowChoices").click(function() {
668
669 $("div#navail_choices").toggle();
670
671 if ($("div#navail_choices").css("display") == "none") {
672 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv('ShowNotAvailableOptions')).'...\');
673 } else {
674 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv('HideNotAvailableOptions')).'...\');
675 }
676
677});
678
679/*
680$(".runupgrade").click(function() {
681 return confirm("'.dol_escape_js($langs->transnoentitiesnoconv("WarningUpgrade"), 0, 1).'");
682});
683*/
684
685</script>';
686
687dolibarr_install_syslog("- check: end");
688pFooter(1); // Never display next button
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
Definition admin.lib.php:39
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:71
$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='')
Decode a string with a symmetric encryption.