28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
49print
load_fiche_titre($langs->trans(
"FileCheckDolibarr"),
'',
'title_setup');
51print
'<span class="opacitymedium">'.$langs->trans(
"FileCheckDesc").
'</span><br><br>';
54print
'<div class="div-table-responsive-no-min">';
55print
'<table class="noborder centpercent">';
56print
'<tr class="liste_titre"><td>'.$langs->trans(
"Version").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>'.
"\n";
57print
'<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionLastInstall").
'</td><td>'.
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL').
'</td></tr>'.
"\n";
58print
'<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionLastUpgrade").
'</td><td>'.
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE').
'</td></tr>'.
"\n";
59print
'<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionProgram").
'</td><td>'.DOL_VERSION;
61if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) {
63 if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) {
64 print
' '.img_warning($langs->trans(
"RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL));
68 if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) {
69 print
' '.img_warning($langs->trans(
"RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE));
72print
'</td></tr>'.
"\n";
79$file_list = array(
'missing' => array(),
'updated' => array());
82$xmlshortfile =
dol_sanitizeFileName(
GETPOST(
'xmlshortfile',
'alpha') ?
GETPOST(
'xmlshortfile',
'alpha') :
'filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ?
'' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).
'.xml'.(empty($conf->global->MAIN_FILECHECK_LOCAL_EXT) ?
'' : $conf->global->MAIN_FILECHECK_LOCAL_EXT));
84$xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
85if (!preg_match(
'/\.zip$/i', $xmlfile) &&
dol_is_file($xmlfile.
'.zip')) {
86 $xmlfile = $xmlfile.
'.zip';
90$xmlremote =
GETPOST(
'xmlremote',
'alphanohtml');
91if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
92 $xmlremote = $conf->global->MAIN_FILECHECK_URL;
94$param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
95if (empty($xmlremote) && !empty($conf->global->$param)) {
96 $xmlremote = $conf->global->$param;
98if (empty($xmlremote)) {
99 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
101if ($xmlremote && !preg_match(
'/^https?:\/\//', $xmlremote)) {
102 $langs->load(
"errors");
103 setEventMessages($langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote),
null,
'errors');
105} elseif ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
106 $langs->load(
"errors");
107 setEventMessages($langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'),
null,
'errors');
112$enableremotecheck =
true;
113if (preg_match(
'/beta|alpha|rc/i', DOL_VERSION) || !empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) {
114 $enableremotecheck =
false;
116$enableremotecheck =
true;
118print
'<form name="check" action="'.$_SERVER[
"PHP_SELF"].
'">';
119print
'<input type="hidden" name="token" value="'.newToken().
'">';
120print $langs->trans(
"MakeIntegrityAnalysisFrom").
':<br>';
121print
'<!-- for a local check target=local&xmlshortfile=... -->'.
"\n";
123 print
'<input type="radio" name="target" id="checkboxlocal" value="local"'.((!
GETPOST(
'target') ||
GETPOST(
'target') ==
'local') ?
'checked="checked"' :
'').
'"> <label for="checkboxlocal">'.$langs->trans(
"LocalSignature").
'</label> = ';
124 print
'<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).
'">';
127 print
'<input type="radio" name="target" id="checkboxlocal" value="local"> <label for="checkboxlocal">'.$langs->trans(
"LocalSignature").
' = ';
128 print
'<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).
'">';
129 print
' <span class="warning">('.$langs->trans(
"AvailableOnlyOnPackagedVersions").
')</span></label>';
132print
'<!-- for a remote target=remote&xmlremote=... -->'.
"\n";
133if ($enableremotecheck) {
134 print
'<input type="radio" name="target" id="checkboxremote" value="remote"'.(GETPOST(
'target') ==
'remote' ?
'checked="checked"' :
'').
'> <label for="checkboxremote">'.$langs->trans(
"RemoteSignature").
'</label> = ';
135 print
'<input name="xmlremote" class="flat minwidth500" value="'.dol_escape_htmltag($xmlremote).
'"><br>';
137 print
'<input type="radio" name="target" id="checkboxremote" value="remote" disabled="disabled"> '.$langs->trans(
"RemoteSignature").
' = '.
dol_escape_htmltag($xmlremote);
139 print
' <span class="warning">('.$langs->trans(
"FeatureAvailableOnlyOnStable").
')</span>';
143print
'<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans(
"Check").
'"></div>';
148if (
GETPOST(
'target') ==
'local') {
151 if (preg_match(
'/\.zip$/i', $xmlfile)) {
153 $xmlfilenew = preg_replace(
'/\.zip$/i',
'', $xmlfile);
155 if (empty($result[
'error'])) {
156 $xmlfile = $conf->admin->dir_temp.
'/'.basename($xmlfilenew);
158 print $langs->trans(
'FailedToUncompressFile').
': '.$xmlfile;
162 $xml = simplexml_load_file($xmlfile);
163 if ($xml ===
false) {
164 print
'<div class="warning">'.$langs->trans(
'XmlCorrupted').
': '.$xmlfile.
'</span>';
168 print
'<div class="warning">'.$langs->trans(
'XmlNotFound').
': '.$xmlfile.
'</span>';
172if (
GETPOST(
'target') ==
'remote') {
173 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
176 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404') {
177 $xmlfile = $xmlarray[
'content'];
179 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
181 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
188if (empty($error) && !empty($xml)) {
189 $checksumconcat = array();
190 $file_list = array();
194 if (is_object($xml->dolibarr_constants[0])) {
197 $out .=
'<div class="div-table-responsive-no-min">';
198 $out .=
'<table class="noborder">';
199 $out .=
'<tr class="liste_titre">';
200 $out .=
'<td>#</td>';
201 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
202 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
203 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
204 $out .=
'</tr>'.
"\n";
207 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
208 $constname = $constant[
'name'];
209 $constvalue = (string) $constant;
210 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
216 $valueforchecksum = (empty($value) ?
'0' : $value);
218 $checksumconcat[] = $valueforchecksum;
221 $out .=
'<tr class="oddeven">';
222 $out .=
'<td>'.$i.
'</td>'.
"\n";
223 $out .=
'<td>'.dol_escape_htmltag($constname).
'</td>'.
"\n";
224 $out .=
'<td class="center">'.dol_escape_htmltag($constvalue).
'</td>'.
"\n";
225 $out .=
'<td class="center">'.dol_escape_htmltag($valueforchecksum).
'</td>'.
"\n";
230 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
239 if (is_object($xml->dolibarr_htdocs_dir[0])) {
241 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
244 $regextoinclude =
'\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|bak|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
245 $regextoexclude =
'('.($includecustom ?
'' :
'custom|').
'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$';
246 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
249 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
251 foreach ($scanfiles as $keyfile => $valfile) {
252 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
253 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
254 $md5newfile = @md5_file($valfile[
'fullname']);
255 $file_list[
'added'][] = array(
'filename'=>$tmprelativefilename,
'md5'=>$md5newfile);
262 $out .=
'<div class="div-table-responsive-no-min">';
263 $out .=
'<table class="noborder">';
264 $out .=
'<tr class="liste_titre">';
265 $out .=
'<td>#</td>';
266 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
267 $out .=
'<td class="right">'.$langs->trans(
"ExpectedSize").
'</td>';
268 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
269 $out .=
'</tr>'.
"\n";
271 if (is_array($tmpfilelist) && count($tmpfilelist)) {
273 foreach ($tmpfilelist as $file) {
275 $out .=
'<tr class="oddeven">';
276 $out .=
'<td>'.$i.
'</td>'.
"\n";
277 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
278 $out .=
'<td class="right">';
279 if (!empty($file[
'expectedsize'])) {
282 $out .=
'</td>'.
"\n";
283 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
287 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
298 $out .=
'<div class="div-table-responsive-no-min">';
299 $out .=
'<table class="noborder">';
300 $out .=
'<tr class="liste_titre">';
301 $out .=
'<td>#</td>';
302 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
303 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
304 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
305 $out .=
'<td class="right">'.$langs->trans(
"ExpectedSize").
'</td>';
306 $out .=
'<td class="right">'.$langs->trans(
"CurrentSize").
'</td>';
307 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
308 $out .=
'</tr>'.
"\n";
309 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
310 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
312 foreach ($tmpfilelist2 as $file) {
314 $out .=
'<tr class="oddeven">';
315 $out .=
'<td>'.$i.
'</td>'.
"\n";
316 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
317 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
318 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'md5']).
'</td>'.
"\n";
319 $out .=
'<td class="right">';
320 if ($file[
'expectedsize']) {
323 $out .=
'</td>'.
"\n";
324 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
326 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
327 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
330 $out .=
'<tr class="liste_total">';
331 $out .=
'<td></td>'.
"\n";
332 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
333 $out .=
'<td class="center"></td>'.
"\n";
334 $out .=
'<td class="center"></td>'.
"\n";
335 $out .=
'<td class="center"></td>'.
"\n";
336 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
337 $out .=
'<td class="right"></td>'.
"\n";
340 $out .=
'<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
351 $out .=
'<div class="div-table-responsive-no-min">';
352 $out .=
'<table class="noborder">';
353 $out .=
'<tr class="liste_titre">';
354 $out .=
'<td>#</td>';
355 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
356 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
357 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
358 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
359 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
360 $out .=
'</tr>'.
"\n";
362 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
364 foreach ($tmpfilelist3 as $file) {
366 $out .=
'<tr class="oddeven">';
367 $out .=
'<td>'.$i.
'</td>'.
"\n";
368 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']);
369 if (!preg_match(
'/^win/i', PHP_OS)) {
370 $htmltext = $langs->trans(
"YouCanDeleteFileOnServerWith",
'rm '.DOL_DOCUMENT_ROOT.$file[
'filename']);
371 $out .=
' '.$form->textwithpicto(
'', $htmltext, 1,
'help',
'', 0, 2,
'helprm'.$i);
373 $out .=
'</td>'.
"\n";
374 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
375 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'md5']).
'</td>'.
"\n";
376 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
378 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
379 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
382 $out .=
'<tr class="liste_total">';
383 $out .=
'<td></td>'.
"\n";
384 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
385 $out .=
'<td class="center"></td>'.
"\n";
386 $out .=
'<td class="center"></td>'.
"\n";
387 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
388 $out .=
'<td class="right"></td>'.
"\n";
391 $out .=
'<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
396 print
'<div class="error">';
397 print
'Error: Failed to found <b>dolibarr_htdocs_dir</b> into content of XML file:<br>'.dol_escape_htmltag(
dol_trunc($xmlfile, 500));
412 asort($checksumconcat);
414 $checksumget = md5(join(
',', $checksumconcat));
415 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
424 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
425 if ($checksumget == $checksumtoget) {
426 if (is_array($file_list[
'added']) && count($file_list[
'added'])) {
427 $resultcode =
'warning';
428 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
429 $outcurrentchecksum = $checksumget.
' - <span class="'.$resultcode.
'">'.$langs->trans($resultcomment).
'</span>';
432 $resultcomment =
'Success';
433 $outcurrentchecksum =
'<span class="'.$resultcode.
'">'.$checksumget.
'</span>';
436 $resultcode =
'error';
437 $resultcomment =
'Error';
438 $outcurrentchecksum =
'<span class="'.$resultcode.
'">'.$checksumget.
'</span>';
442 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3) && $resultcode ==
'ok') {
443 setEventMessages($langs->trans(
"FileIntegrityIsStrictlyConformedWithReference"),
null,
'mesgs');
445 if ($resultcode ==
'warning') {
448 setEventMessages($langs->trans(
"FileIntegritySomeFilesWereRemovedOrModified"),
null,
'errors');
453 print $langs->trans(
"ExpectedChecksum").
' = '.$outexpectedchecksum.
'<br>';
454 print $langs->trans(
"CurrentChecksum").
' = '.$outcurrentchecksum;
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path='', $pathref='', &$checksumconcat=array())
Function to get list of updated or modified files.
dol_filemtime($pathoffile)
Return time of a file.
dol_filesize($pathoffile)
Return size of a file.
dol_uncompress($inputfile, $outputdir)
Uncompress a file.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.