30define(
'ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
31include_once
'inc.php';
40$setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) : $langs->getDefaultLang();
41$langs->setDefaultLang($setuplang);
43$langs->load(
"install");
46$useforcedwizard =
false;
47$forcedfile =
"./install.forced.php";
48if ($conffile ==
"/etc/dolibarr/conf.php") {
49 $forcedfile =
"/etc/dolibarr/install.forced.php";
51if (@file_exists($forcedfile)) {
52 $useforcedwizard =
true;
53 include_once $forcedfile;
69print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> ';
70print
'<span class="inline-block">'.$langs->trans(
"MiscellaneousChecks").
"</span></h3>\n";
73$useragent = $_SERVER[
'HTTP_USER_AGENT'];
74if (!empty($useragent)) {
76 $browserversion = $tmp[
'browserversion'];
77 $browsername = $tmp[
'browsername'];
78 if ($browsername ==
'ie' && $browserversion < 7) {
79 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"WarningBrowserTooOld").
"<br>\n";
85$arrayphpminversionerror = array(7, 0, 0);
86$arrayphpminversionwarning = array(7, 1, 0);
88 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionerror));
91 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionwarning));
96if (empty($force_install_nophpinfo)) {
97 print
' (<a href="phpinfo.php" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MoreInformation").
'</a>)';
102$arrayphpmaxversionwarning = array(8, 2, 0);
104 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooHigh",
versiontostring($arrayphpmaxversionwarning));
111if (!isset($_GET[
"testget"]) && !isset($_POST[
"testpost"])) {
112 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETKo");
113 print
' (<a href="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'?testget=ok">'.$langs->trans(
"Recheck").
'</a>)';
117 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETOk").
"<br>\n";
122if (!function_exists(
"session_id")) {
123 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupportSessions").
"<br>\n";
126 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportSessions").
"<br>\n";
131if (!extension_loaded(
"mbstring")) {
132 $langs->load(
"errors");
133 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"MBString").
"<br>\n";
136 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"MBString").
"<br>\n";
140if (!extension_loaded(
"json")) {
141 $langs->load(
"errors");
142 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"JSON").
"<br>\n";
145 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"JSON").
"<br>\n";
149if (!function_exists(
"imagecreate")) {
150 $langs->load(
"errors");
151 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"GD").
"<br>\n";
154 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"GD").
"<br>\n";
158if (!function_exists(
"curl_init")) {
159 $langs->load(
"errors");
160 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Curl").
"<br>\n";
163 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Curl").
"<br>\n";
167if (!function_exists(
"easter_date")) {
168 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Calendar").
"<br>\n";
170 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Calendar").
"<br>\n";
174if (!function_exists(
"simplexml_load_string")) {
175 $langs->load(
"errors");
176 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Xml").
"<br>\n";
179 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Xml").
"<br>\n";
183if (!function_exists(
"utf8_encode")) {
184 $langs->load(
"errors");
185 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"UTF8").
"<br>\n";
188 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"UTF8").
"<br>\n";
192if (empty($_SERVER[
"SERVER_ADMIN"]) || $_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost') {
193 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region")) {
194 $langs->load(
"errors");
195 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Intl").
"<br>\n";
198 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Intl").
"<br>\n";
203if (PHP_VERSION_ID <= 80300) {
204 if (!function_exists(
"imap_open")) {
205 $langs->load(
"errors");
206 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"IMAP").
"<br>\n";
209 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"IMAP").
"<br>\n";
214if (!class_exists(
'ZipArchive')) {
215 $langs->load(
"errors");
216 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"ZIP").
"<br>\n";
219 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"ZIP").
"<br>\n";
223$memrequiredorig =
'64M';
224$memrequired = 64 * 1024 * 1024;
225$memmaxorig = @ini_get(
"memory_limit");
226$memmax = @ini_get(
"memory_limit");
227if ($memmaxorig !=
'') {
228 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
230 if (strtoupper($reg[2]) ==
'G') {
231 $memmax = $reg[1] * 1024 * 1024 * 1024;
233 if (strtoupper($reg[2]) ==
'M') {
234 $memmax = $reg[1] * 1024 * 1024;
236 if (strtoupper($reg[2]) ==
'K') {
237 $memmax = $reg[1] * 1024;
240 if ($memmax >= $memrequired || $memmax == -1) {
241 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
243 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
250if (is_readable($conffile) && filesize($conffile) > 8) {
253 include_once $conffile;
258 $allowupgrade =
true;
260 $allowupgrade =
false;
268 if (@copy($conffile.
".example", $conffile)) {
273 dolibarr_install_syslog(
"check: failed to copy file ".$conffile.
".example into ".$conffile.
". We try to create it.", LOG_WARNING);
275 $fp = @fopen($conffile,
"w");
277 @fwrite($fp,
'<?php');
281 dolibarr_install_syslog(
"check: failed to create a new file ".$conffile.
" into current dir ".getcwd().
". Please check permissions.", LOG_ERR);
286 $allowupgrade =
false;
292if (!file_exists($conffile)) {
293 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
294 print
'<br><br><div class="error">';
295 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
296 print
'</div><br><br>'.
"\n";
298 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
302 print
'<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
305 } elseif (!is_writable($conffile)) {
308 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
310 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
313 print
'<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
320 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
322 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
325 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileIsWritable", $conffiletoshow);
337 if (file_exists($conffile)) {
338 include_once $conffile;
339 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
340 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
341 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";
342 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);
344 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
347 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
348 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
349 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
350 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
351 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
353 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
358 $conf->db->type = $dolibarr_main_db_type;
359 $conf->db->host = $dolibarr_main_db_host;
360 $conf->db->port = $dolibarr_main_db_port;
361 $conf->db->name = $dolibarr_main_db_name;
362 $conf->db->user = $dolibarr_main_db_user;
363 $conf->db->pass = $dolibarr_main_db_pass;
364 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (
int) $conf->db->port);
365 if ($db->connected && $db->database_selected) {
374 if (empty($dolibarr_main_db_encryption)) {
375 $dolibarr_main_db_encryption = 0;
377 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
378 if (empty($dolibarr_main_db_cryptkey)) {
379 $dolibarr_main_db_cryptkey =
'';
381 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
383 $conf->setValues($db);
385 if (defined(
'SYSLOG_FILE')) {
386 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
388 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
392 $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 :
''));
398 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.(!
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE') ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).
'</span></b> - ';
399 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
408 print
'<h3><span class="soustitre">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
410 $foundrecommandedchoice = 0;
412 $available_choices = array();
413 $notavailable_choices = array();
415 if (empty($dolibarr_main_db_host)) {
416 $foundrecommandedchoice = 1;
420 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
421 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"FreshInstall").
'</b>';
423 $choice .=
'<td class="listofchoicesdesc">';
424 $choice .= $langs->trans(
"FreshInstallDesc");
425 if (empty($dolibarr_main_db_host)) {
428 $choice .=
'<div class="center"><div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div></div>';
433 $choice .=
'<td class="center">';
435 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
437 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
439 $choice .=
'</td>'.
"\n";
440 $choice .=
'</tr>'.
"\n";
442 $positionkey = ($foundrecommandedchoice ? 999 : 0);
444 $available_choices[$positionkey] = $choice;
446 $notavailable_choices[$positionkey] = $choice;
450 $allowupgrade =
true;
451 if (empty($dolibarr_main_db_host)) {
452 $allowupgrade =
false;
455 $allowupgrade =
false;
458 $allowupgrade =
true;
461 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
465 $migrationscript = array();
466 $handle = opendir($dir);
467 if (is_resource($handle)) {
468 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
469 while (($file = readdir($handle)) !==
false) {
471 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
473 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
474 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
478 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
480 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
484 foreach ($migrationscript as $migarray) {
488 $recommended_choice =
false;
489 $version = DOL_VERSION;
490 $versionfrom = $migarray[
'from'];
491 $versionto = $migarray[
'to'];
492 $versionarray = preg_split(
'/[\.-]/', $version);
493 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
494 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
496 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
497 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
498 $newversionfrombis =
'';
499 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
500 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
504 if (count($dolibarrlastupgradeversionarray) >= 2) {
506 if ($allowupgrade && empty($foundrecommandedchoice) &&
507 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
509 $foundrecommandedchoice = 1;
510 $recommended_choice =
true;
518 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
519 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
520 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"Upgrade").
'<br>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
521 $choice .=
'<td class="listofchoicesdesc">';
522 $choice .= $langs->trans(
"UpgradeDesc");
524 if ($recommended_choice) {
527 $choice .=
'<div class="center">';
528 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
529 if ($count < count($migarray)) {
530 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
536 $choice .=
'<td class="center">';
539 if ($foundrecommandedchoice == 2) {
542 if ($foundrecommandedchoice == 1) {
543 $foundrecommandedchoice = 2;
546 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
548 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'">'.$langs->trans(
"Start").
'</a>';
551 $choice .= $langs->trans(
"NotAvailable");
554 $choice .=
'</tr>'.
"\n";
557 $available_choices[$count] = $choice;
559 $notavailable_choices[$count] = $choice;
564 if (empty($available_choices)) {
565 $available_choices = $notavailable_choices;
566 $notavailable_choices = array();
570 krsort($available_choices, SORT_NATURAL);
572 print
'<table width="100%" class="listofchoices">';
573 foreach ($available_choices as $choice) {
577 print
'</table>'.
"\n";
579 if (count($notavailable_choices)) {
580 print
'<br><div id="AShowChoices" style="opacity: 0.5">';
581 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
584 print
'<div id="navail_choices" style="display:none">';
586 print
'<table width="100%" class="listofchoices">';
587 foreach ($notavailable_choices as $choice) {
591 print
'</table>'.
"\n";
597print
'<script type="text/javascript">
599$("div#AShowChoices").click(function() {
601 $("div#navail_choices").toggle();
603 if ($("div#navail_choices").css("display") == "none") {
604 $(this).text("> '.$langs->trans(
'ShowNotAvailableOptions').
'...");
606 $(this).text("'.$langs->trans(
'HideNotAvailableOptions').
'...");
612$(".runupgrade").click(function() {
613 return confirm("'.
dol_escape_js($langs->transnoentitiesnoconv(
"WarningUpgrade"), 0, 1).
'");
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
versiondolibarrarray()
Return version Dolibarr.
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
dol_is_dir($folder)
Test if filename is a directory.
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 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.
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.