29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
48llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-system_filecheck');
50print
load_fiche_titre($langs->trans(
"FileCheckDolibarr"),
'',
'title_setup');
52print
'<span class="opacitymedium">'.$langs->trans(
"FileCheckDesc").
'</span><br><br>';
55print
'<div class="div-table-responsive-no-min">';
56print
'<table class="noborder centpercent">';
57print
'<tr class="liste_titre"><td>'.$langs->trans(
"Version").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>'.
"\n";
58print
'<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionLastInstall").
'</td><td>'.
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL').
'</td></tr>'.
"\n";
59print
'<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionLastUpgrade").
'</td><td>'.
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE').
'</td></tr>'.
"\n";
60print
'<tr class="oddeven"><td width="300">'.$langs->trans(
"VersionProgram").
'</td><td>'.DOL_VERSION;
65 print
' '.img_warning($langs->trans(
"RunningUpdateProcessMayBeRequired", DOL_VERSION,
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL')));
69 if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) {
70 print
' '.img_warning($langs->trans(
"RunningUpdateProcessMayBeRequired", DOL_VERSION,
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE')));
73print
'</td></tr>'.
"\n";
80$file_list = array(
'missing' => array(),
'updated' => array());
85$xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
86if (!preg_match(
'/\.zip$/i', $xmlfile) &&
dol_is_file($xmlfile.
'.zip')) {
91$xmlremote =
GETPOST(
'xmlremote',
'alphanohtml');
95$param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
99if (empty($xmlremote)) {
100 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
102if ($xmlremote && !preg_match(
'/^https?:\/\//', $xmlremote)) {
103 $langs->load(
"errors");
104 setEventMessages($langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote),
null,
'errors');
106} elseif ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
107 $langs->load(
"errors");
108 setEventMessages($langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'),
null,
'errors');
113$enableremotecheck =
true;
114if (preg_match(
'/beta|alpha|rc/i', DOL_VERSION) ||
getDolGlobalString(
'MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE')) {
115 $enableremotecheck =
false;
117$enableremotecheck =
true;
119print
'<form name="check" action="'.$_SERVER[
"PHP_SELF"].
'">';
120print
'<input type="hidden" name="token" value="'.newToken().
'">';
121print $langs->trans(
"MakeIntegrityAnalysisFrom").
':<br>';
122print
'<!-- for a local check target=local&xmlshortfile=... -->'.
"\n";
124 print
'<input type="radio" name="target" id="checkboxlocal" value="local"'.((!
GETPOST(
'target') ||
GETPOST(
'target') ==
'local') ?
'checked="checked"' :
'').
'"> <label for="checkboxlocal">'.$langs->trans(
"LocalSignature").
'</label> = ';
125 print
'<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).
'">';
128 print
'<input type="radio" name="target" id="checkboxlocal" value="local"> <label for="checkboxlocal">'.$langs->trans(
"LocalSignature").
' = ';
129 print
'<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).
'">';
130 print
' <span class="warning">('.$langs->trans(
"AvailableOnlyOnPackagedVersions").
')</span></label>';
133print
'<!-- for a remote target=remote&xmlremote=... -->'.
"\n";
134if ($enableremotecheck) {
135 print
'<input type="radio" name="target" id="checkboxremote" value="remote"'.(GETPOST(
'target') ==
'remote' ?
'checked="checked"' :
'').
'> <label for="checkboxremote">'.$langs->trans(
"RemoteSignature").
'</label> = ';
136 print
'<input name="xmlremote" class="flat minwidth500" value="'.dol_escape_htmltag($xmlremote).
'"><br>';
138 print
'<input type="radio" name="target" id="checkboxremote" value="remote" disabled="disabled"> '.$langs->trans(
"RemoteSignature").
' = '.
dol_escape_htmltag($xmlremote);
140 print
' <span class="warning">('.$langs->trans(
"FeatureAvailableOnlyOnStable").
')</span>';
144print
'<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans(
"Check").
'"></div>';
149if (
GETPOST(
'target') ==
'local') {
152 if (preg_match(
'/\.zip$/i', $xmlfile)) {
154 $xmlfilenew = preg_replace(
'/\.zip$/i',
'', $xmlfile);
156 if (empty($result[
'error'])) {
157 $xmlfile = $conf->admin->dir_temp.
'/'.basename($xmlfilenew);
159 print $langs->trans(
'FailedToUncompressFile').
': '.$xmlfile;
163 $xml = simplexml_load_file($xmlfile);
164 if ($xml ===
false) {
165 print
'<div class="warning">'.$langs->trans(
'XmlCorrupted').
': '.$xmlfile.
'</span>';
169 print
'<div class="warning">'.$langs->trans(
'XmlNotFound').
': '.$xmlfile.
'</span>';
173if (
GETPOST(
'target') ==
'remote') {
174 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
177 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404') {
178 $xmlfile = $xmlarray[
'content'];
180 if (LIBXML_VERSION < 20900) {
184 libxml_disable_entity_loader(
true);
187 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NONET);
189 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
196if (empty($error) && !empty($xml)) {
197 $checksumconcat = array();
198 $file_list = array();
202 if (is_object($xml->dolibarr_constants[0])) {
205 $out .=
'<div class="div-table-responsive-no-min">';
206 $out .=
'<table class="noborder">';
207 $out .=
'<tr class="liste_titre">';
208 $out .=
'<td>#</td>';
209 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
210 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
211 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
212 $out .=
'</tr>'.
"\n";
215 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
216 $constname = $constant[
'name'];
217 $constvalue = (string) $constant;
218 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
224 $valueforchecksum = (empty($value) ?
'0' : $value);
226 $checksumconcat[] = $valueforchecksum;
229 $out .=
'<tr class="oddeven">';
230 $out .=
'<td>'.$i.
'</td>'.
"\n";
231 $out .=
'<td>'.dol_escape_htmltag($constname).
'</td>'.
"\n";
232 $out .=
'<td class="center">'.dol_escape_htmltag($constvalue).
'</td>'.
"\n";
233 $out .=
'<td class="center">'.dol_escape_htmltag($valueforchecksum).
'</td>'.
"\n";
238 $out .=
'<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
247 if (is_object($xml->dolibarr_htdocs_dir[0])) {
249 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
252 $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)$';
253 $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)$';
254 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
257 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
259 foreach ($scanfiles as $keyfile => $valfile) {
260 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
261 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
262 $md5newfile = @md5_file($valfile[
'fullname']);
263 $file_list[
'added'][] = array(
'filename' => $tmprelativefilename,
'md5' => $md5newfile);
270 $out .=
'<div class="div-table-responsive-no-min">';
271 $out .=
'<table class="noborder">';
272 $out .=
'<tr class="liste_titre">';
273 $out .=
'<td>#</td>';
274 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
275 $out .=
'<td class="right">'.$langs->trans(
"ExpectedSize").
'</td>';
276 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
277 $out .=
'</tr>'.
"\n";
279 if (is_array($tmpfilelist) && count($tmpfilelist)) {
281 foreach ($tmpfilelist as $file) {
283 $out .=
'<tr class="oddeven">';
284 $out .=
'<td>'.$i.
'</td>'.
"\n";
285 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
286 $out .=
'<td class="right">';
287 if (!empty($file[
'expectedsize'])) {
290 $out .=
'</td>'.
"\n";
291 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
295 $out .=
'<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
306 $out .=
'<div class="div-table-responsive-no-min">';
307 $out .=
'<table class="noborder">';
308 $out .=
'<tr class="liste_titre">';
309 $out .=
'<td>#</td>';
310 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
311 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
312 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
313 $out .=
'<td class="right">'.$langs->trans(
"ExpectedSize").
'</td>';
314 $out .=
'<td class="right">'.$langs->trans(
"CurrentSize").
'</td>';
315 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
316 $out .=
'</tr>'.
"\n";
317 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
318 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
320 foreach ($tmpfilelist2 as $file) {
322 $out .=
'<tr class="oddeven">';
323 $out .=
'<td>'.$i.
'</td>'.
"\n";
324 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
325 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
326 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'md5']).
'</td>'.
"\n";
327 $out .=
'<td class="right">';
328 if ($file[
'expectedsize']) {
331 $out .=
'</td>'.
"\n";
332 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
334 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
335 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
338 $out .=
'<tr class="liste_total">';
339 $out .=
'<td></td>'.
"\n";
340 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
341 $out .=
'<td class="center"></td>'.
"\n";
342 $out .=
'<td class="center"></td>'.
"\n";
343 $out .=
'<td class="center"></td>'.
"\n";
344 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
345 $out .=
'<td class="right"></td>'.
"\n";
348 $out .=
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
359 $out .=
'<div class="div-table-responsive-no-min">';
360 $out .=
'<table class="noborder">';
361 $out .=
'<tr class="liste_titre">';
362 $out .=
'<td>#</td>';
363 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
364 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
365 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
366 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
367 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
368 $out .=
'</tr>'.
"\n";
370 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
372 foreach ($tmpfilelist3 as $file) {
374 $out .=
'<tr class="oddeven">';
375 $out .=
'<td>'.$i.
'</td>'.
"\n";
376 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']);
377 if (!preg_match(
'/^win/i', PHP_OS)) {
378 $htmltext = $langs->trans(
"YouCanDeleteFileOnServerWith",
'rm '.DOL_DOCUMENT_ROOT.$file[
'filename']);
379 $out .=
' '.$form->textwithpicto(
'', $htmltext, 1,
'help',
'', 0, 2,
'helprm'.$i);
381 $out .=
'</td>'.
"\n";
382 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'expectedmd5']).
'</td>'.
"\n";
383 $out .=
'<td class="center">'.dol_escape_htmltag($file[
'md5']).
'</td>'.
"\n";
384 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
386 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
387 $out .=
'<td class="right nowraponall">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
390 $out .=
'<tr class="liste_total">';
391 $out .=
'<td></td>'.
"\n";
392 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
393 $out .=
'<td class="center"></td>'.
"\n";
394 $out .=
'<td class="center"></td>'.
"\n";
395 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
396 $out .=
'<td class="right"></td>'.
"\n";
399 $out .=
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
404 print
'<div class="error">';
405 print
'Error: Failed to found <b>dolibarr_htdocs_dir</b> into content of XML file:<br>'.dol_escape_htmltag(
dol_trunc($xmlfile, 500));
420 asort($checksumconcat);
422 $checksumget = md5(implode(
',', $checksumconcat));
423 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
432 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
433 if ($checksumget == $checksumtoget) {
434 if (is_array($file_list[
'added']) && count($file_list[
'added'])) {
435 $resultcode =
'warning';
436 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
437 $outcurrentchecksum = $checksumget.
' - <span class="'.$resultcode.
'">'.$langs->trans($resultcomment).
'</span>';
440 $resultcomment =
'Success';
441 $outcurrentchecksum =
'<span class="'.$resultcode.
'">'.$checksumget.
'</span>';
444 $resultcode =
'error';
445 $resultcomment =
'Error';
446 $outcurrentchecksum =
'<span class="'.$resultcode.
'">'.$checksumget.
'</span>';
450 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3) && $resultcode ==
'ok') {
451 setEventMessages($langs->trans(
"FileIntegrityIsStrictlyConformedWithReference"),
null,
'mesgs');
453 if ($resultcode ==
'warning') {
456 setEventMessages($langs->trans(
"FileIntegritySomeFilesWereRemovedOrModified"),
null,
'errors');
461 print $langs->trans(
"ExpectedChecksum").
' = '.$outexpectedchecksum.
'<br>';
462 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($utf8_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 formatted size.
load_fiche_titre($title, $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 the value of a given key, which produces ascending (default) or descending out...
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.