29 include_once
'inc.php';
35 $allowupgrade =
false;
38 $setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) : $langs->getDefaultLang();
39 $langs->setDefaultLang($setuplang);
41 $langs->load(
"install");
44 $useforcedwizard =
false;
45 $forcedfile =
"./install.forced.php";
46 if ($conffile ==
"/etc/dolibarr/conf.php") $forcedfile =
"/etc/dolibarr/install.forced.php";
47 if (@file_exists($forcedfile)) {
48 $useforcedwizard =
true;
49 include_once $forcedfile;
65 print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> '.$langs->trans(
"MiscellaneousChecks").
":</h3>\n";
68 $useragent =
$_SERVER[
'HTTP_USER_AGENT'];
69 if (!empty($useragent))
72 $browserversion = $tmp[
'browserversion'];
73 $browsername = $tmp[
'browsername'];
74 if ($browsername ==
'ie' && $browserversion < 7)
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"WarningBrowserTooOld").
"<br>\n";
79 $arrayphpminversionerror = array(5, 5, 0);
80 $arrayphpminversionwarning = array(5, 6, 0);
83 print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionerror));
87 print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionwarning));
92 if (empty($force_install_nophpinfo))
print ' (<a href="phpinfo.php" target="_blank">'.$langs->trans(
"MoreInformation").
'</a>)';
97 if (!isset($_GET[
"testget"]) && !isset($_POST[
"testpost"]))
99 print '<img src="../theme/eldy/img/warning.png" alt="Warning"> '.$langs->trans(
"PHPSupportPOSTGETKo");
100 print ' (<a href="'.$_SERVER[
"PHP_SELF"].
'?testget=ok">'.$langs->trans(
"Recheck").
'</a>)';
104 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupportPOSTGETOk").
"<br>\n";
109 if (!function_exists(
"session_id"))
111 print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans(
"ErrorPHPDoesNotSupportSessions").
"<br>\n";
114 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupportSessions").
"<br>\n";
119 if (!function_exists(
"imagecreate"))
121 $langs->load(
"errors");
122 print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"ErrorPHPDoesNotSupportGD").
"<br>\n";
125 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupport",
"GD").
"<br>\n";
130 if (!function_exists(
"curl_init"))
132 $langs->load(
"errors");
133 print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"ErrorPHPDoesNotSupportCurl").
"<br>\n";
136 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupport",
"Curl").
"<br>\n";
140 if (!function_exists(
"easter_date"))
142 print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"ErrorPHPDoesNotSupportCalendar").
"<br>\n";
144 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupport",
"Calendar").
"<br>\n";
149 if (!function_exists(
"utf8_encode"))
151 $langs->load(
"errors");
152 print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"ErrorPHPDoesNotSupportUTF8").
"<br>\n";
155 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupport",
"UTF8").
"<br>\n";
160 if (empty(
$_SERVER[
"SERVER_ADMIN"]) ||
$_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost')
162 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region"))
164 $langs->load(
"errors");
165 print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"ErrorPHPDoesNotSupportIntl").
"<br>\n";
168 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupport",
"Intl").
"<br>\n";
172 if (!class_exists(
'ZipArchive'))
174 $langs->load(
"errors");
175 print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"ZIP").
"<br>\n";
178 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPSupport",
"ZIP").
"<br>\n";
182 $memrequiredorig =
'64M';
183 $memrequired = 64 * 1024 * 1024;
184 $memmaxorig = @ini_get(
"memory_limit");
185 $memmax = @ini_get(
"memory_limit");
186 if ($memmaxorig !=
'')
188 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
191 if (strtoupper($reg[2]) ==
'G') $memmax = $reg[1] * 1024 * 1024 * 1024;
192 if (strtoupper($reg[2]) ==
'M') $memmax = $reg[1] * 1024 * 1024;
193 if (strtoupper($reg[2]) ==
'K') $memmax = $reg[1] * 1024;
195 if ($memmax >= $memrequired || $memmax == -1)
197 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
199 print '<img src="../theme/eldy/img/warning.png" alt="Warning"> '.$langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
206 if (is_readable($conffile) && filesize($conffile) > 8)
210 include_once $conffile;
216 $allowupgrade =
true;
218 $allowupgrade =
false;
226 if (@copy($conffile.
".example", $conffile))
232 dolibarr_install_syslog(
"check: failed to copy file ".$conffile.
".example into ".$conffile.
". We try to create it.", LOG_WARNING);
234 $fp = @fopen($conffile,
"w");
237 @fwrite($fp,
'<?php');
240 }
else dolibarr_install_syslog(
"check: failed to create a new file ".$conffile.
" into current dir ".getcwd().
". Please check permissions.", LOG_ERR);
244 $allowupgrade =
false;
250 if (!file_exists($conffile))
252 print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
254 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
257 print $langs->trans(
"CorrectProblemAndReloadPage",
$_SERVER[
'PHP_SELF'].
'?testget=ok');
262 print '<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
267 elseif (!is_writable($conffile))
271 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
273 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
276 print '<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
285 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
287 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
290 print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileIsWritable", $conffiletoshow);
303 if (file_exists($conffile))
305 include_once $conffile;
306 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root))
308 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php"))
310 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";
311 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);
313 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
316 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
318 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
319 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass))
321 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
322 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
323 }
else $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
327 $conf->db->type = $dolibarr_main_db_type;
328 $conf->db->host = $dolibarr_main_db_host;
329 $conf->db->port = $dolibarr_main_db_port;
330 $conf->db->name = $dolibarr_main_db_name;
331 $conf->db->user = $dolibarr_main_db_user;
332 $conf->db->pass = $dolibarr_main_db_pass;
333 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
334 if ($db->connected && $db->database_selected)
345 if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
346 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
347 if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey =
'';
348 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
350 $conf->setValues($db);
352 if (defined(
'SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
353 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
357 $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 :
''));
362 if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL))
364 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).
'</span></b> - ';
365 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
369 }
else print "<br>\n";
372 print '<h3><span class="soustitre">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
374 $foundrecommandedchoice = 0;
376 $available_choices = array();
377 $notavailable_choices = array();
379 if (empty($dolibarr_main_db_host))
381 $foundrecommandedchoice = 1;
385 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
386 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"FreshInstall").
'</b>';
388 $choice .=
'<td class="listofchoicesdesc">';
389 $choice .= $langs->trans(
"FreshInstallDesc");
390 if (empty($dolibarr_main_db_host))
394 $choice .=
'<div class="center"><div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div></div>';
399 $choice .=
'<td class="center">';
402 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
404 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
406 $choice .=
'</td>'.
"\n";
407 $choice .=
'</tr>'.
"\n";
409 $positionkey = ($foundrecommandedchoice ? 999 : 0);
411 $available_choices[$positionkey] = $choice;
413 $notavailable_choices[$positionkey] = $choice;
417 $allowupgrade =
true;
418 if (empty($dolibarr_main_db_host))
420 $allowupgrade =
false;
422 if (defined(
"MAIN_NOT_INSTALLED")) $allowupgrade =
false;
423 if (
GETPOST(
'allowupgrade')) $allowupgrade =
true;
424 $migrationscript = array(array(
'from'=>
'3.0.0',
'to'=>
'3.1.0'),
425 array(
'from'=>
'3.1.0',
'to'=>
'3.2.0'),
426 array(
'from'=>
'3.2.0',
'to'=>
'3.3.0'),
427 array(
'from'=>
'3.3.0',
'to'=>
'3.4.0'),
428 array(
'from'=>
'3.4.0',
'to'=>
'3.5.0'),
429 array(
'from'=>
'3.5.0',
'to'=>
'3.6.0'),
430 array(
'from'=>
'3.6.0',
'to'=>
'3.7.0'),
431 array(
'from'=>
'3.7.0',
'to'=>
'3.8.0'),
432 array(
'from'=>
'3.8.0',
'to'=>
'3.9.0'),
433 array(
'from'=>
'3.9.0',
'to'=>
'4.0.0'),
434 array(
'from'=>
'4.0.0',
'to'=>
'5.0.0'),
435 array(
'from'=>
'5.0.0',
'to'=>
'6.0.0'),
436 array(
'from'=>
'6.0.0',
'to'=>
'7.0.0'),
437 array(
'from'=>
'7.0.0',
'to'=>
'8.0.0'),
438 array(
'from'=>
'8.0.0',
'to'=>
'9.0.0'),
439 array(
'from'=>
'9.0.0',
'to'=>
'10.0.0'),
440 array(
'from'=>
'10.0.0',
'to'=>
'11.0.0'),
441 array(
'from'=>
'11.0.0',
'to'=>
'12.0.0'),
442 array(
'from'=>
'12.0.0',
'to'=>
'13.0.0')
446 foreach ($migrationscript as $migarray)
451 $recommended_choice =
false;
452 $version = DOL_VERSION;
453 $versionfrom = $migarray[
'from'];
454 $versionto = $migarray[
'to'];
455 $versionarray = preg_split(
'/[\.-]/', $version);
456 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
457 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
459 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
460 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
461 $newversionfrombis =
'';
464 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
469 if (count($dolibarrlastupgradeversionarray) >= 2)
472 if ($allowupgrade && empty($foundrecommandedchoice) &&
473 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
476 $foundrecommandedchoice = 1;
477 $recommended_choice =
true;
485 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
486 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
487 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"Upgrade").
'<br>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
488 $choice .=
'<td class="listofchoicesdesc">';
489 $choice .= $langs->trans(
"UpgradeDesc");
491 if ($recommended_choice)
495 $choice .=
'<div class="center">';
496 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
497 if ($count < count($migarray))
499 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
505 $choice .=
'<td class="center">';
509 if ($foundrecommandedchoice == 2)
513 if ($foundrecommandedchoice == 1)
515 $foundrecommandedchoice = 2;
519 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
521 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'">'.$langs->trans(
"Start").
'</a>';
524 $choice .= $langs->trans(
"NotAvailable");
527 $choice .=
'</tr>'.
"\n";
530 $available_choices[$count] = $choice;
532 $notavailable_choices[$count] = $choice;
537 if (empty($available_choices))
539 $available_choices = $notavailable_choices;
540 $notavailable_choices = array();
544 krsort($available_choices, SORT_NATURAL);
546 print '<table width="100%" class="listofchoices">';
547 foreach ($available_choices as $choice) {
551 print '</table>'.
"\n";
553 if (count($notavailable_choices)) {
554 print '<br><div id="AShowChoices" style="opacity: 0.5">';
555 print '> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
558 print '<div id="navail_choices" style="display:none">';
560 print '<table width="100%" class="listofchoices">';
561 foreach ($notavailable_choices as $choice) {
565 print '</table>'.
"\n";
571 print '<script type="text/javascript">
573 $("div#AShowChoices").click(function() {
575 $("div#navail_choices").toggle();
577 if ($("div#navail_choices").css("display") == "none") {
578 $(this).text("> '.$langs->trans(
'ShowNotAvailableOptions').
'...");
580 $(this).text("'.$langs->trans(
'HideNotAvailableOptions').
'...");
586 $(".runupgrade").click(function() {
587 return confirm("'.
dol_escape_js($langs->transnoentitiesnoconv(
"WarningUpgrade"), 0, 1).
'");
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
pHeader($subtitle, $next, $action= 'set', $param= '', $forcejqueryurl= '', $csstable= 'main-inside')
Show HTML header of install pages.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
dol_decode($chain, $key= '1')
Decode a base 64 encoded + specific delta change.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
versiondolibarrarray()
Return version Dolibarr.
dol_is_dir($folder)
Test if filename is a directory.
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
getBrowserInfo($user_agent)
Return information about user browser.
print $_SERVER["PHP_SELF"]
Edit parameters.
pFooter($nonext=0, $setuplang= '', $jscheckfunction= '', $withpleasewait=0)
Print HTML footer of install pages.
print
Draft customers invoices.
versionphparray()
Return version PHP.