dolibarr 21.0.0-beta
update.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
26if (! defined('CSRFCHECK_WITH_TOKEN')) {
27 define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
28}
29
30// Load Dolibarr environment
31require '../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
35
44// Load translation files required by the page
45$langs->loadLangs(array("admin", "other"));
46
47$action = GETPOST('action', 'aZ09');
48
49if (!$user->admin) {
51}
52
53if (GETPOST('msg', 'alpha')) {
54 setEventMessages(GETPOST('msg', 'alpha'), null, 'errors');
55}
56
57
58$urldolibarr = 'https://www.dolibarr.org/downloads/';
59$dolibarrroot = preg_replace('/([\\/]+)$/i', '', DOL_DOCUMENT_ROOT);
60$dolibarrroot = preg_replace('/([^\\/]+)$/i', '', $dolibarrroot);
61$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
62
63$sfurl = '';
64$version = '0.0';
65
66
67/*
68 * Actions
69 */
70
71if ($action == 'getlastversion') {
72 $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss');
73 //var_dump($result['content']);
74 if (function_exists('simplexml_load_string')) {
75 if (LIBXML_VERSION < 20900) {
76 // Avoid load of external entities (security problem).
77 // Required only if LIBXML_VERSION < 20900
78 // @phan-suppress-next-line PhanDeprecatedFunctionInternal
79 libxml_disable_entity_loader(true);
80 }
81
82 $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
83 } else {
84 $sfurl = 'xml_not_available';
85 }
86}
87
88
89/*
90 * View
91 */
92
93$wikihelp = 'EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalación_-_Actualización';
94llxHeader('', $langs->trans("Upgrade"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-tools_update');
95
96print load_fiche_titre($langs->trans("Upgrade"), '', 'title_setup');
97
98print '<br>';
99
100print $langs->trans("CurrentVersion").' : <strong>'.DOL_VERSION.'</strong><br>';
101
102if (function_exists('curl_init')) {
103 $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10;
104
105 if ($action == 'getlastversion') {
106 if ($sfurl == 'xml_not_available') {
107 $langs->load("errors");
108 print $langs->trans("LastStableVersion").' : <b class="error">'.$langs->trans("ErrorFunctionNotAvailableInPHP", 'simplexml_load_string').'</b><br>';
109 } elseif ($sfurl) {
110 $i = 0;
111 while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) {
112 $title = $sfurl->channel[0]->item[$i]->title;
113 if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) {
114 $newversion = $reg[1];
115 $newversionarray = explode('.', $newversion);
116 $versionarray = explode('.', $version);
117 //var_dump($newversionarray);var_dump($versionarray);
118 if (versioncompare($newversionarray, $versionarray) > 0) {
119 $version = $newversion;
120 }
121 }
122 $i++;
123 }
124
125 // Show version
126 print $langs->trans("LastStableVersion").' : <b>'.(($version != '0.0') ? $version : $langs->trans("Unknown")).'</b><br>';
127 } else {
128 print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("UpdateServerOffline").'</b><br>';
129 }
130 } else {
131 print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion&token='.newToken().'" class="button smallpaddingimp">'.$langs->trans("Check").'</a><br>';
132 }
133}
134
135print '<br>';
136print '<br>';
137
138// Upgrade
139print $langs->trans("Upgrade").'<br>';
140print '<hr>';
141print $langs->trans("ThisIsProcessToFollow").'<br>';
142print '<b>'.$langs->trans("StepNb", 1).'</b>: ';
143$fullurl = '<a href="'.$urldolibarr.'" target="_blank" rel="noopener noreferrer">'.$urldolibarr.'</a>';
144print str_replace('{s}', $fullurl, $langs->trans("DownloadPackageFromWebSite", '{s}')).'<br>';
145print '<b>'.$langs->trans("StepNb", 2).'</b>: ';
146print str_replace('{s}', $dolibarrroot, $langs->trans("UnpackPackageInDolibarrRoot", '{s}')).'<br>';
147print '<b>'.$langs->trans("StepNb", 3).'</b>: ';
148print $langs->trans("RemoveLock", $dolibarrdataroot.'/install.lock').'<br>';
149print '<b>'.$langs->trans("StepNb", 4).'</b>: ';
150$fullurl = '<a href="'.DOL_URL_ROOT.'/install/" target="_blank" rel="noopener noreferrer">'.DOL_URL_ROOT.'/install/</a>';
151print str_replace('{s}', $fullurl, $langs->trans("CallUpdatePage", '{s}')).'<br>';
152print '<b>'.$langs->trans("StepNb", 5).'</b>: ';
153print $langs->trans("RestoreLock", $dolibarrdataroot.'/install.lock').'<br>';
154
155print '<br>';
156print '<br>';
157
158
159
160
161
162print $langs->trans("AddExtensionThemeModuleOrOther").'<br>';
163print '<hr>';
164$texttoshow = $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', '{s2}');
165$texttoshow = str_replace('{s2}', img_picto('', 'tools', 'class="pictofixedwidth"').$langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"), $texttoshow);
166print $texttoshow;
167
168// End of page
169llxFooter();
170$db->close();
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition admin.lib.php:69
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.