dolibarr  16.0.5
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 
25 if (! defined('CSRFCHECK_WITH_TOKEN')) {
26  define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
27 }
28 
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("admin", "other"));
36 
37 $action = GETPOST('action', 'aZ09');
38 
39 if (!$user->admin) {
41 }
42 
43 if (GETPOST('msg', 'alpha')) {
44  setEventMessages(GETPOST('msg', 'alpha'), null, 'errors');
45 }
46 
47 
48 $urldolibarr = 'https://www.dolibarr.org/downloads/';
49 $dolibarrroot = preg_replace('/([\\/]+)$/i', '', DOL_DOCUMENT_ROOT);
50 $dolibarrroot = preg_replace('/([^\\/]+)$/i', '', $dolibarrroot);
51 $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
52 
53 $sfurl = '';
54 $version = '0.0';
55 
56 
57 /*
58  * Actions
59  */
60 
61 if ($action == 'getlastversion') {
62  $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss');
63  //var_dump($result['content']);
64  if (function_exists('simplexml_load_string')) {
65  $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
66  } else {
67  $sfurl = 'xml_not_available';
68  }
69 }
70 
71 
72 /*
73  * View
74  */
75 
76 $wikihelp = 'EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalación_-_Actualización';
77 llxHeader('', $langs->trans("Upgrade"), $wikihelp);
78 
79 print load_fiche_titre($langs->trans("Upgrade"), '', 'title_setup');
80 
81 print '<br>';
82 
83 print $langs->trans("CurrentVersion").' : <strong>'.DOL_VERSION.'</strong><br>';
84 
85 if (function_exists('curl_init')) {
86  $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10;
87 
88  if ($action == 'getlastversion') {
89  if ($sfurl == 'xml_not_available') {
90  $langs->load("errors");
91  print $langs->trans("LastStableVersion").' : <b class="error">'.$langs->trans("ErrorFunctionNotAvailableInPHP", 'simplexml_load_string').'</b><br>';
92  } elseif ($sfurl) {
93  $i = 0;
94  while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) {
95  $title = $sfurl->channel[0]->item[$i]->title;
96  if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) {
97  $newversion = $reg[1];
98  $newversionarray = explode('.', $newversion);
99  $versionarray = explode('.', $version);
100  //var_dump($newversionarray);var_dump($versionarray);
101  if (versioncompare($newversionarray, $versionarray) > 0) {
102  $version = $newversion;
103  }
104  }
105  $i++;
106  }
107 
108  // Show version
109  print $langs->trans("LastStableVersion").' : <b>'.(($version != '0.0') ? $version : $langs->trans("Unknown")).'</b><br>';
110  } else {
111  print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("UpdateServerOffline").'</b><br>';
112  }
113  } else {
114  print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion&token='.newToken().'" class="button smallpaddingimp">'.$langs->trans("Check").'</a><br>';
115  }
116 }
117 
118 print '<br>';
119 print '<br>';
120 
121 // Upgrade
122 print $langs->trans("Upgrade").'<br>';
123 print '<hr>';
124 print $langs->trans("ThisIsProcessToFollow").'<br>';
125 print '<b>'.$langs->trans("StepNb", 1).'</b>: ';
126 $fullurl = '<a href="'.$urldolibarr.'" target="_blank" rel="noopener noreferrer">'.$urldolibarr.'</a>';
127 print str_replace('{s}', $fullurl, $langs->trans("DownloadPackageFromWebSite", '{s}')).'<br>';
128 print '<b>'.$langs->trans("StepNb", 2).'</b>: ';
129 print str_replace('{s}', $dolibarrroot, $langs->trans("UnpackPackageInDolibarrRoot", '{s}')).'<br>';
130 print '<b>'.$langs->trans("StepNb", 3).'</b>: ';
131 print $langs->trans("RemoveLock", $dolibarrdataroot.'/install.lock').'<br>';
132 print '<b>'.$langs->trans("StepNb", 4).'</b>: ';
133 $fullurl = '<a href="'.DOL_URL_ROOT.'/install/" target="_blank" rel="noopener noreferrer">'.DOL_URL_ROOT.'/install/</a>';
134 print str_replace('{s}', $fullurl, $langs->trans("CallUpdatePage", '{s}')).'<br>';
135 print '<b>'.$langs->trans("StepNb", 5).'</b>: ';
136 print $langs->trans("RestoreLock", $dolibarrdataroot.'/install.lock').'<br>';
137 
138 print '<br>';
139 print '<br>';
140 
141 
142 
143 
144 
145 print $langs->trans("AddExtensionThemeModuleOrOther").'<br>';
146 print '<hr>';
147 $texttoshow = $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', '{s2}');
148 $texttoshow = str_replace('{s2}', img_picto('', 'tools', 'class="pictofixedwidth"').$langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"), $texttoshow);
149 print $texttoshow;
150 
151 // End of page
152 llxFooter();
153 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
versioncompare
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition: admin.lib.php:66
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
getURLContent
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).
Definition: geturl.lib.php:41
img_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)
Definition: functions.lib.php:3880
$wikihelp
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:72
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59