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