27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
31 $langs->load(
"admin");
49 print '<span class="opacitymedium">'.$langs->trans(
"FileCheckDesc").
'</span><br><br>';
52 print '<div class="div-table-responsive-no-min">';
53 print '<table class="noborder centpercent">';
54 print '<tr class="liste_titre"><td>'.$langs->trans(
"Version").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>'.
"\n";
55 print '<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionLastInstall").
'</td><td>'.$conf->global->MAIN_VERSION_LAST_INSTALL.
'</td></tr>'.
"\n";
56 print '<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionLastUpgrade").
'</td><td>'.$conf->global->MAIN_VERSION_LAST_UPGRADE.
'</td></tr>'.
"\n";
57 print '<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionProgram").
'</td><td>'.DOL_VERSION;
59 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) {
61 if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL)
62 print ' '.img_warning($langs->trans(
"RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL));
65 if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE)
66 print ' '.img_warning($langs->trans(
"RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE));
68 print '</td></tr>'.
"\n";
75 $file_list = array(
'missing' => array(),
'updated' => array());
78 $xmlshortfile =
GETPOST(
'xmlshortfile',
'alpha') ?
GETPOST(
'xmlshortfile',
'alpha') :
'/install/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);
79 $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
81 $xmlremote =
GETPOST(
'xmlremote');
82 if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL;
83 $param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
84 if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param;
85 if (empty($xmlremote)) $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
89 $enableremotecheck =
true;
90 if (preg_match(
'/beta|alpha|rc/i', DOL_VERSION) || !empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck =
false;
91 $enableremotecheck =
true;
93 print '<form name="check" action="'.$_SERVER[
"PHP_SELF"].
'">';
94 print '<input type="hidden" name="token" value="'.newToken().
'">';
95 print $langs->trans(
"MakeIntegrityAnalysisFrom").
':<br>';
96 print '<!-- for a local check target=local&xmlshortfile=... -->'.
"\n";
99 print '<input type="radio" name="target" value="local"'.((!
GETPOST(
'target') ||
GETPOST(
'target') ==
'local') ?
'checked="checked"' :
'').
'"> '.$langs->trans(
"LocalSignature").
' = ';
100 print '<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).
'">';
103 print '<input type="radio" name="target" value="local"> '.$langs->trans(
"LocalSignature").
' = ';
104 print '<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).
'">';
105 print ' <span class="warning">('.$langs->trans(
"AvailableOnlyOnPackagedVersions").
')</span>';
108 print '<!-- for a remote target=remote&xmlremote=... -->'.
"\n";
109 if ($enableremotecheck)
111 print '<input type="radio" name="target" value="remote"'.(GETPOST(
'target') ==
'remote' ?
'checked="checked"' :
'').
'> '.$langs->trans(
"RemoteSignature").
' = ';
112 print '<input name="xmlremote" class="flat minwidth400" value="'.dol_escape_htmltag($xmlremote).
'"><br>';
114 print '<input type="radio" name="target" value="remote" disabled="disabled"> '.$langs->trans(
"RemoteSignature").
' = '.$xmlremote;
115 if (!
GETPOST(
'xmlremote'))
print ' <span class="warning">('.$langs->trans(
"FeatureAvailableOnlyOnStable").
')</span>';
118 print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans(
"Check").
'"></div>';
123 if (
GETPOST(
'target') ==
'local')
128 if (preg_match(
'/\.zip$/i', $xmlfile)) {
130 $xmlfilenew = preg_replace(
'/\.zip$/i',
'', $xmlfile);
132 if (empty($result[
'error'])) {
133 $xmlfile = $conf->admin->dir_temp.
'/'.basename($xmlfilenew);
135 print $langs->trans(
'FailedToUncompressFile').
': '.$xmlfile;
139 $xml = simplexml_load_file($xmlfile);
141 print $langs->trans(
'XmlNotFound').
': '.$xmlfile;
145 if (
GETPOST(
'target') ==
'remote')
150 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404')
152 $xmlfile = $xmlarray[
'content'];
154 $xml = simplexml_load_string($xmlfile);
156 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
165 $checksumconcat = array();
166 $file_list = array();
170 if (is_object($xml->dolibarr_constants[0]))
174 $out .=
'<div class="div-table-responsive-no-min">';
175 $out .=
'<table class="noborder">';
176 $out .=
'<tr class="liste_titre">';
177 $out .=
'<td>#</td>';
178 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
179 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
180 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
181 $out .=
'</tr>'.
"\n";
184 foreach ($xml->dolibarr_constants[0]->constant as $constant)
186 $constname = $constant[
'name'];
187 $constvalue = (string) $constant;
188 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
191 if ($constname && $conf->global->$constname !=
'') $value = $conf->global->$constname;
192 $valueforchecksum = (empty($value) ?
'0' : $value);
194 $checksumconcat[] = $valueforchecksum;
197 $out .=
'<tr class="oddeven">';
198 $out .=
'<td>'.$i.
'</td>'.
"\n";
199 $out .=
'<td>'.dol_escape_htmltag($constname).
'</td>'.
"\n";
200 $out .=
'<td class="center">'.dol_escape_htmltag($constvalue).
'</td>'.
"\n";
201 $out .=
'<td class="center">'.dol_escape_htmltag($valueforchecksum).
'</td>'.
"\n";
207 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
216 if (is_object($xml->dolibarr_htdocs_dir[0]))
219 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
222 $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|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
223 $regextoexclude =
'('.($includecustom ?
'' :
'custom|').
'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$';
224 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
227 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
229 foreach ($scanfiles as $keyfile => $valfile)
231 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
232 if (!in_array($tmprelativefilename, $file_list[
'insignature']))
234 $md5newfile = @md5_file($valfile[
'fullname']);
235 $file_list[
'added'][] = array(
'filename'=>$tmprelativefilename,
'md5'=>$md5newfile);
242 $out .=
'<div class="div-table-responsive-no-min">';
243 $out .=
'<table class="noborder">';
244 $out .=
'<tr class="liste_titre">';
245 $out .=
'<td>#</td>';
246 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
247 $out .=
'<td class="right">'.$langs->trans(
"ExpectedSize").
'</td>';
248 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
249 $out .=
'</tr>'.
"\n";
251 if (is_array($tmpfilelist) && count($tmpfilelist))
254 foreach ($tmpfilelist as $file)
257 $out .=
'<tr class="oddeven">';
258 $out .=
'<td>'.$i.
'</td>'.
"\n";
259 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
260 $out .=
'<td class="right">';
261 if (!empty($file[
'expectedsize'])) $out .=
dol_print_size($file[
'expectedsize']);
262 $out .=
'</td>'.
"\n";
263 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
267 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
278 $out .=
'<div class="div-table-responsive-no-min">';
279 $out .=
'<table class="noborder">';
280 $out .=
'<tr class="liste_titre">';
281 $out .=
'<td>#</td>';
282 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
283 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
284 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
285 $out .=
'<td class="right">'.$langs->trans(
"ExpectedSize").
'</td>';
286 $out .=
'<td class="right">'.$langs->trans(
"CurrentSize").
'</td>';
287 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
288 $out .=
'</tr>'.
"\n";
289 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
290 if (is_array($tmpfilelist2) && count($tmpfilelist2))
293 foreach ($tmpfilelist2 as $file)
296 $out .=
'<tr class="oddeven">';
297 $out .=
'<td>'.$i.
'</td>'.
"\n";
298 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
299 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
300 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'md5']).
'</td>'.
"\n";
301 $out .=
'<td class="right">';
302 if ($file[
'expectedsize']) $out .=
dol_print_size($file[
'expectedsize']);
303 $out .=
'</td>'.
"\n";
304 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
306 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
307 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
310 $out .=
'<tr class="liste_total">';
311 $out .=
'<td></td>'.
"\n";
312 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
313 $out .=
'<td class="center"></td>'.
"\n";
314 $out .=
'<td class="center"></td>'.
"\n";
315 $out .=
'<td class="center"></td>'.
"\n";
316 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
317 $out .=
'<td class="right"></td>'.
"\n";
320 $out .=
'<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
331 $out .=
'<div class="div-table-responsive-no-min">';
332 $out .=
'<table class="noborder">';
333 $out .=
'<tr class="liste_titre">';
334 $out .=
'<td>#</td>';
335 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
336 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
337 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
338 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
339 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
340 $out .=
'</tr>'.
"\n";
342 if (is_array($tmpfilelist3) && count($tmpfilelist3))
345 foreach ($tmpfilelist3 as $file)
348 $out .=
'<tr class="oddeven">';
349 $out .=
'<td>'.$i.
'</td>'.
"\n";
350 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']);
351 if (!preg_match(
'/^win/i', PHP_OS)) {
352 $htmltext = $langs->trans(
"YouCanDeleteFileOnServerWith",
'rm '.DOL_DOCUMENT_ROOT.$file[
'filename']);
353 $out .=
' '.$form->textwithpicto(
'', $htmltext, 1,
'help',
'', 0, 2,
'helprm'.$i);
355 $out .=
'</td>'.
"\n";
356 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
357 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'md5']).
'</td>'.
"\n";
358 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
360 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
361 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
364 $out .=
'<tr class="liste_total">';
365 $out .=
'<td></td>'.
"\n";
366 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
367 $out .=
'<td class="center"></td>'.
"\n";
368 $out .=
'<td class="center"></td>'.
"\n";
369 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
370 $out .=
'<td class="right"></td>'.
"\n";
373 $out .=
'<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
378 print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile;
392 asort($checksumconcat);
394 $checksumget = md5(join(
',', $checksumconcat));
395 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
404 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
405 if ($checksumget == $checksumtoget)
407 if (count($file_list[
'added']))
409 $resultcode =
'warning';
410 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
411 $outcurrentchecksum = $checksumget.
' - <span class="'.$resultcode.
'">'.$langs->trans($resultcomment).
'</span>';
414 $resultcomment =
'Success';
415 $outcurrentchecksum =
'<span class="'.$resultcode.
'">'.$checksumget.
'</span>';
418 $resultcode =
'error';
419 $resultcomment =
'Error';
420 $outcurrentchecksum =
'<span class="'.$resultcode.
'">'.$checksumget.
'</span>';
424 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3) && $resultcode ==
'ok') {
425 setEventMessages($langs->trans(
"FileIntegrityIsStrictlyConformedWithReference"), null,
'mesgs');
427 if ($resultcode ==
'warning') {
430 setEventMessages($langs->trans(
"FileIntegritySomeFilesWereRemovedOrModified"), null,
'errors');
435 print $langs->trans(
"ExpectedChecksum").
' = '.$outexpectedchecksum.
'<br>';
436 print $langs->trans(
"CurrentChecksum").
' = '.$outcurrentchecksum;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path= '', $pathref= '', &$checksumconcat=array())
Function to get list of updated or modified files.
dol_filesize($pathoffile)
Return size of a file.
getURLContent($url, $postorget= 'GET', $param= '', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0)
Function to get a content from an URL (use proxy if proxy defined).
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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 ...
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
dol_is_file($pathoffile)
Return if path is a file.
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...
dol_uncompress($inputfile, $outputdir)
Uncompress a file.
print
Draft customers invoices.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_filemtime($pathoffile)
Return time of a file.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)