filecheck.php 19 KB

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