filecheck.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <?php
  2. /* Copyright (C) 2005-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  4. * Copyright (C) 2007-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015-2019 Frederic France <frederic.france@netlogic.fr>
  6. * Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/admin/system/filecheck.php
  23. * \brief Page to check Dolibarr files integrity
  24. */
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
  28. $langs->load("admin");
  29. if (!$user->admin) {
  30. accessforbidden();
  31. }
  32. $error = 0;
  33. /*
  34. * View
  35. */
  36. @set_time_limit(300);
  37. llxHeader();
  38. print load_fiche_titre($langs->trans("FileCheckDolibarr"), '', 'title_setup');
  39. print '<span class="opacitymedium">'.$langs->trans("FileCheckDesc").'</span><br><br>';
  40. // Version
  41. print '<div class="div-table-responsive-no-min">';
  42. print '<table class="noborder centpercent">';
  43. print '<tr class="liste_titre"><td>'.$langs->trans("Version").'</td><td>'.$langs->trans("Value").'</td></tr>'."\n";
  44. print '<tr class="oddeven"><td width="300">'.$langs->trans("VersionLastInstall").'</td><td>'.getDolGlobalString('MAIN_VERSION_LAST_INSTALL').'</td></tr>'."\n";
  45. print '<tr class="oddeven"><td width="300">'.$langs->trans("VersionLastUpgrade").'</td><td>'.getDolGlobalString('MAIN_VERSION_LAST_UPGRADE').'</td></tr>'."\n";
  46. print '<tr class="oddeven"><td width="300">'.$langs->trans("VersionProgram").'</td><td>'.DOL_VERSION;
  47. // If current version differs from last upgrade
  48. if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) {
  49. // Compare version with last install database version (upgrades never occured)
  50. if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) {
  51. print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL));
  52. }
  53. } else {
  54. // Compare version with last upgrade database version
  55. if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) {
  56. print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE));
  57. }
  58. }
  59. print '</td></tr>'."\n";
  60. print '</table>';
  61. print '</div>';
  62. print '<br>';
  63. // Modified or missing files
  64. $file_list = array('missing' => array(), 'updated' => array());
  65. // Local file to compare to
  66. $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));
  67. $xmlfile = DOL_DOCUMENT_ROOT.'/install/'.$xmlshortfile;
  68. if (!preg_match('/\.zip$/i', $xmlfile) && dol_is_file($xmlfile.'.zip')) {
  69. $xmlfile = $xmlfile.'.zip';
  70. }
  71. // Remote file to compare to
  72. $xmlremote = GETPOST('xmlremote', 'alphanohtml');
  73. if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
  74. $xmlremote = $conf->global->MAIN_FILECHECK_URL;
  75. }
  76. $param = 'MAIN_FILECHECK_URL_'.DOL_VERSION;
  77. if (empty($xmlremote) && !empty($conf->global->$param)) {
  78. $xmlremote = $conf->global->$param;
  79. }
  80. if (empty($xmlremote)) {
  81. $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
  82. }
  83. if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) {
  84. $langs->load("errors");
  85. setEventMessages($langs->trans("ErrorURLMustStartWithHttp", $xmlremote), '', 'errors');
  86. $error++;
  87. }
  88. // Test if remote test is ok
  89. $enableremotecheck = true;
  90. if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || !empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) {
  91. $enableremotecheck = false;
  92. }
  93. $enableremotecheck = true;
  94. print '<form name="check" action="'.$_SERVER["PHP_SELF"].'">';
  95. print '<input type="hidden" name="token" value="'.newToken().'">';
  96. print $langs->trans("MakeIntegrityAnalysisFrom").':<br>';
  97. print '<!-- for a local check target=local&xmlshortfile=... -->'."\n";
  98. if (dol_is_file($xmlfile)) {
  99. print '<input type="radio" name="target" id="checkboxlocal" value="local"'.((!GETPOST('target') || GETPOST('target') == 'local') ? 'checked="checked"' : '').'"> <label for="checkboxlocal">'.$langs->trans("LocalSignature").'</label> = ';
  100. print '<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).'">';
  101. print '<br>';
  102. } else {
  103. print '<input type="radio" name="target" id="checkboxlocal" value="local"> <label for="checkboxlocal">'.$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></label>';
  106. print '<br>';
  107. }
  108. print '<!-- for a remote target=remote&xmlremote=... -->'."\n";
  109. if ($enableremotecheck) {
  110. print '<input type="radio" name="target" id="checkboxremote" value="remote"'.(GETPOST('target') == 'remote' ? 'checked="checked"' : '').'> <label for="checkboxremote">'.$langs->trans("RemoteSignature").'</label> = ';
  111. print '<input name="xmlremote" class="flat minwidth500" value="'.dol_escape_htmltag($xmlremote).'"><br>';
  112. } else {
  113. print '<input type="radio" name="target" id="checkboxremote" value="remote" disabled="disabled"> '.$langs->trans("RemoteSignature").' = '.dol_escape_htmltag($xmlremote);
  114. if (!GETPOST('xmlremote')) {
  115. print ' <span class="warning">('.$langs->trans("FeatureAvailableOnlyOnStable").')</span>';
  116. }
  117. print '<br>';
  118. }
  119. print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans("Check").'"></div>';
  120. print '</form>';
  121. print '<br>';
  122. print '<br>';
  123. if (GETPOST('target') == 'local') {
  124. if (dol_is_file($xmlfile)) {
  125. // If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before
  126. if (preg_match('/\.zip$/i', $xmlfile)) {
  127. dol_mkdir($conf->admin->dir_temp);
  128. $xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile);
  129. $result = dol_uncompress($xmlfile, $conf->admin->dir_temp);
  130. if (empty($result['error'])) {
  131. $xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew);
  132. } else {
  133. print $langs->trans('FailedToUncompressFile').': '.$xmlfile;
  134. $error++;
  135. }
  136. }
  137. $xml = simplexml_load_file($xmlfile);
  138. if ($xml === false) {
  139. print '<div class="warning">'.$langs->trans('XmlCorrupted').': '.$xmlfile.'</span>';
  140. $error++;
  141. }
  142. } else {
  143. print '<div class="warning">'.$langs->trans('XmlNotFound').': '.$xmlfile.'</span>';
  144. $error++;
  145. }
  146. }
  147. if (GETPOST('target') == 'remote') {
  148. $xmlarray = getURLContent($xmlremote, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only. Same is used into api_setup.class.php.
  149. // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
  150. if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') {
  151. $xmlfile = $xmlarray['content'];
  152. //print "xmlfilestart".$xmlfile."xmlfileend";
  153. $xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
  154. } else {
  155. $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].(($xmlarray['http_code'] == 400 && $xmlarray['content']) ? ' '.$xmlarray['content'] : '').' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
  156. setEventMessages($errormsg, null, 'errors');
  157. $error++;
  158. }
  159. }
  160. if (empty($error) && !empty($xml)) {
  161. $checksumconcat = array();
  162. $file_list = array();
  163. $out = '';
  164. // Forced constants
  165. if (is_object($xml->dolibarr_constants[0])) {
  166. $out .= load_fiche_titre($langs->trans("ForcedConstants"));
  167. $out .= '<div class="div-table-responsive-no-min">';
  168. $out .= '<table class="noborder">';
  169. $out .= '<tr class="liste_titre">';
  170. $out .= '<td>#</td>';
  171. $out .= '<td>'.$langs->trans("Constant").'</td>';
  172. $out .= '<td class="center">'.$langs->trans("ExpectedValue").'</td>';
  173. $out .= '<td class="center">'.$langs->trans("Value").'</td>';
  174. $out .= '</tr>'."\n";
  175. $i = 0;
  176. foreach ($xml->dolibarr_constants[0]->constant as $constant) { // $constant is a simpleXMLElement
  177. $constname = $constant['name'];
  178. $constvalue = (string) $constant;
  179. $constvalue = (empty($constvalue) ? '0' : $constvalue);
  180. // Value found
  181. $value = '';
  182. if ($constname && $conf->global->$constname != '') {
  183. $value = $conf->global->$constname;
  184. }
  185. $valueforchecksum = (empty($value) ? '0' : $value);
  186. $checksumconcat[] = $valueforchecksum;
  187. $i++;
  188. $out .= '<tr class="oddeven">';
  189. $out .= '<td>'.$i.'</td>'."\n";
  190. $out .= '<td>'.dol_escape_htmltag($constname).'</td>'."\n";
  191. $out .= '<td class="center">'.dol_escape_htmltag($constvalue).'</td>'."\n";
  192. $out .= '<td class="center">'.dol_escape_htmltag($valueforchecksum).'</td>'."\n";
  193. $out .= "</tr>\n";
  194. }
  195. if ($i == 0) {
  196. $out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  197. }
  198. $out .= '</table>';
  199. $out .= '</div>';
  200. $out .= '<br>';
  201. }
  202. // Scan htdocs
  203. if (is_object($xml->dolibarr_htdocs_dir[0])) {
  204. //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit;
  205. $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']);
  206. // Define qualified files (must be same than into generate_filelist_xml.php and in api_setup.class.php)
  207. $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)$';
  208. $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)$'; // Exclude dirs
  209. $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude);
  210. // Fill file_list with files in signature, new files, modified files
  211. $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list
  212. // Complete with list of new files
  213. foreach ($scanfiles as $keyfile => $valfile) {
  214. $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
  215. if (!in_array($tmprelativefilename, $file_list['insignature'])) {
  216. $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file
  217. $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
  218. }
  219. }
  220. // Files missings
  221. $out .= load_fiche_titre($langs->trans("FilesMissing"));
  222. $out .= '<div class="div-table-responsive-no-min">';
  223. $out .= '<table class="noborder">';
  224. $out .= '<tr class="liste_titre">';
  225. $out .= '<td>#</td>';
  226. $out .= '<td>'.$langs->trans("Filename").'</td>';
  227. $out .= '<td class="right">'.$langs->trans("ExpectedSize").'</td>';
  228. $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>';
  229. $out .= '</tr>'."\n";
  230. $tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
  231. if (is_array($tmpfilelist) && count($tmpfilelist)) {
  232. $i = 0;
  233. foreach ($tmpfilelist as $file) {
  234. $i++;
  235. $out .= '<tr class="oddeven">';
  236. $out .= '<td>'.$i.'</td>'."\n";
  237. $out .= '<td>'.dol_escape_htmltag($file['filename']).'</td>'."\n";
  238. $out .= '<td class="right">';
  239. if (!empty($file['expectedsize'])) {
  240. $out .= dol_print_size($file['expectedsize']);
  241. }
  242. $out .= '</td>'."\n";
  243. $out .= '<td class="center">'.dol_escape_htmltag($file['expectedmd5']).'</td>'."\n";
  244. $out .= "</tr>\n";
  245. }
  246. } else {
  247. $out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  248. }
  249. $out .= '</table>';
  250. $out .= '</div>';
  251. $out .= '<br>';
  252. // Files modified
  253. $out .= load_fiche_titre($langs->trans("FilesModified"));
  254. $totalsize = 0;
  255. $out .= '<div class="div-table-responsive-no-min">';
  256. $out .= '<table class="noborder">';
  257. $out .= '<tr class="liste_titre">';
  258. $out .= '<td>#</td>';
  259. $out .= '<td>'.$langs->trans("Filename").'</td>';
  260. $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>';
  261. $out .= '<td class="center">'.$langs->trans("CurrentChecksum").'</td>';
  262. $out .= '<td class="right">'.$langs->trans("ExpectedSize").'</td>';
  263. $out .= '<td class="right">'.$langs->trans("CurrentSize").'</td>';
  264. $out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
  265. $out .= '</tr>'."\n";
  266. $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
  267. if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
  268. $i = 0;
  269. foreach ($tmpfilelist2 as $file) {
  270. $i++;
  271. $out .= '<tr class="oddeven">';
  272. $out .= '<td>'.$i.'</td>'."\n";
  273. $out .= '<td>'.dol_escape_htmltag($file['filename']).'</td>'."\n";
  274. $out .= '<td class="center">'.dol_escape_htmltag($file['expectedmd5']).'</td>'."\n";
  275. $out .= '<td class="center">'.dol_escape_htmltag($file['md5']).'</td>'."\n";
  276. $out .= '<td class="right">';
  277. if ($file['expectedsize']) {
  278. $out .= dol_print_size($file['expectedsize']);
  279. }
  280. $out .= '</td>'."\n";
  281. $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']);
  282. $totalsize += $size;
  283. $out .= '<td class="right">'.dol_print_size($size).'</td>'."\n";
  284. $out .= '<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n";
  285. $out .= "</tr>\n";
  286. }
  287. $out .= '<tr class="liste_total">';
  288. $out .= '<td></td>'."\n";
  289. $out .= '<td>'.$langs->trans("Total").'</td>'."\n";
  290. $out .= '<td class="center"></td>'."\n";
  291. $out .= '<td class="center"></td>'."\n";
  292. $out .= '<td class="center"></td>'."\n";
  293. $out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n";
  294. $out .= '<td class="right"></td>'."\n";
  295. $out .= "</tr>\n";
  296. } else {
  297. $out .= '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  298. }
  299. $out .= '</table>';
  300. $out .= '</div>';
  301. $out .= '<br>';
  302. // Files added
  303. $out .= load_fiche_titre($langs->trans("FilesAdded"));
  304. $totalsize = 0;
  305. $out .= '<div class="div-table-responsive-no-min">';
  306. $out .= '<table class="noborder">';
  307. $out .= '<tr class="liste_titre">';
  308. $out .= '<td>#</td>';
  309. $out .= '<td>'.$langs->trans("Filename").'</td>';
  310. $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>';
  311. $out .= '<td class="center">'.$langs->trans("CurrentChecksum").'</td>';
  312. $out .= '<td class="right">'.$langs->trans("Size").'</td>';
  313. $out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
  314. $out .= '</tr>'."\n";
  315. $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename');
  316. if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
  317. $i = 0;
  318. foreach ($tmpfilelist3 as $file) {
  319. $i++;
  320. $out .= '<tr class="oddeven">';
  321. $out .= '<td>'.$i.'</td>'."\n";
  322. $out .= '<td>'.dol_escape_htmltag($file['filename']);
  323. if (!preg_match('/^win/i', PHP_OS)) {
  324. $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename']
  325. $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i);
  326. }
  327. $out .= '</td>'."\n";
  328. $out .= '<td class="center">'.dol_escape_htmltag($file['expectedmd5']).'</td>'."\n";
  329. $out .= '<td class="center">'.dol_escape_htmltag($file['md5']).'</td>'."\n";
  330. $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']);
  331. $totalsize += $size;
  332. $out .= '<td class="right">'.dol_print_size($size).'</td>'."\n";
  333. $out .= '<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n";
  334. $out .= "</tr>\n";
  335. }
  336. $out .= '<tr class="liste_total">';
  337. $out .= '<td></td>'."\n";
  338. $out .= '<td>'.$langs->trans("Total").'</td>'."\n";
  339. $out .= '<td class="center"></td>'."\n";
  340. $out .= '<td class="center"></td>'."\n";
  341. $out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n";
  342. $out .= '<td class="right"></td>'."\n";
  343. $out .= "</tr>\n";
  344. } else {
  345. $out .= '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  346. }
  347. $out .= '</table>';
  348. $out .= '</div>';
  349. } else {
  350. print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile;
  351. $error++;
  352. }
  353. // Scan scripts
  354. /*
  355. if (is_object($xml->dolibarr_script_dir[0]))
  356. {
  357. $file_list = array();
  358. $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', ???, $checksumconcat); // Fill array $file_list
  359. }*/
  360. asort($checksumconcat); // Sort list of checksum
  361. //var_dump($checksumconcat);
  362. $checksumget = md5(join(',', $checksumconcat));
  363. $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum);
  364. //var_dump(count($file_list['added']));
  365. //var_dump($checksumget);
  366. //var_dump($checksumtoget);
  367. //var_dump($checksumget == $checksumtoget);
  368. $resultcomment = '';
  369. $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown"));
  370. if ($checksumget == $checksumtoget) {
  371. if (is_array($file_list['added']) && count($file_list['added'])) {
  372. $resultcode = 'warning';
  373. $resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
  374. $outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans($resultcomment).'</span>';
  375. } else {
  376. $resultcode = 'ok';
  377. $resultcomment = 'Success';
  378. $outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
  379. }
  380. } else {
  381. $resultcode = 'error';
  382. $resultcomment = 'Error';
  383. $outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
  384. }
  385. // Show warning
  386. if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3) && $resultcode == 'ok') {
  387. setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
  388. } else {
  389. if ($resultcode == 'warning') {
  390. setEventMessages($langs->trans($resultcomment), null, 'warnings');
  391. } else {
  392. setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'errors');
  393. }
  394. }
  395. print load_fiche_titre($langs->trans("GlobalChecksum"));
  396. print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'<br>';
  397. print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum;
  398. print '<br>';
  399. print '<br>';
  400. // Output detail
  401. print $out;
  402. }
  403. // End of page
  404. llxFooter();
  405. $db->close();
  406. exit($error);