2015-02-19 19:59:53 +00:00
< ? php
2026-02-21 10:44:43 +00:00
/* Copyright ( C ) 2005 - 2026 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-02-19 19:59:53 +00:00
* Copyright ( C ) 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2018-10-27 12:43:12 +00:00
* Copyright ( C ) 2007 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2026-07-27 11:50:06 +00:00
* Copyright ( C ) 2015 - 2026 Frédéric France < frederic . france @ free . fr >
2018-03-09 16:56:49 +00:00
* Copyright ( C ) 2017 Nicolas ZABOURI < info @ inovea - conseil . com >
2025-03-16 19:21:22 +00:00
* Copyright ( C ) 2024 - 2025 MDW < mdeweerd @ users . noreply . github . com >
2015-02-19 19:59:53 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2015-02-19 19:59:53 +00:00
*/
/**
2025-11-02 17:56:14 +00:00
* \file htdocs / blockedlog / admin / filecheck . php
2015-02-19 19:59:53 +00:00
* \brief Page to check Dolibarr files integrity
*/
2018-03-09 21:45:16 +00:00
2022-09-07 18:08:59 +00:00
// Load Dolibarr environment
2015-02-19 19:59:53 +00:00
require '../../main.inc.php' ;
2024-11-04 22:53:20 +00:00
/**
* @ var Conf $conf
* @ var DoliDB $db
2024-11-10 22:47:14 +00:00
* @ var Form $form
2024-11-04 22:53:20 +00:00
* @ var HookManager $hookmanager
2025-10-11 11:27:16 +00:00
* @ var Societe $mysoc
2024-11-04 22:53:20 +00:00
* @ var Translate $langs
* @ var User $user
*/
2025-08-20 14:02:46 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/geturl.lib.php' ;
2026-02-17 01:51:35 +00:00
require_once DOL_DOCUMENT_ROOT . '/blockedlog/lib/blockedlog.lib.php' ;
2025-08-20 14:02:46 +00:00
2015-02-19 19:59:53 +00:00
$langs -> load ( " admin " );
2025-10-11 11:01:49 +00:00
$mode = GETPOST ( 'mode' , 'aZ09' );
2026-02-16 02:22:52 +00:00
if ( ! $user -> admin && ! $user -> hasRight ( 'bockedlog' , 'read' )) {
2020-10-31 13:32:18 +00:00
accessforbidden ();
2021-02-26 21:04:03 +00:00
}
2015-02-19 19:59:53 +00:00
2019-11-12 08:46:08 +00:00
$error = 0 ;
2015-09-13 18:25:33 +00:00
2026-02-21 10:44:43 +00:00
// Version blockedlog
2026-06-07 13:14:27 +00:00
$versionbadge = '<span class="badge-text badge-secondary">' . getBlockedLogVersionToShow ();
if ( $mysoc -> country_code == 'FR' && ! constant ( 'CERTIF_LNE' )) {
// Can add an edditional mention
$versionbadge .= ' - ' . $langs -> trans ( " NeedAThirdPartyStatement " );
}
$versionbadge .= '</span>' ;
2026-02-21 10:44:43 +00:00
2015-02-19 19:59:53 +00:00
/*
* View
*/
2018-03-09 21:45:16 +00:00
@ set_time_limit ( 300 );
2024-06-08 15:03:08 +00:00
llxHeader ( '' , '' , '' , '' , 0 , 0 , '' , '' , '' , 'mod-admin page-system_filecheck' );
2015-02-19 19:59:53 +00:00
2019-01-27 10:55:16 +00:00
print load_fiche_titre ( $langs -> trans ( " FileCheckDolibarr " ), '' , 'title_setup' );
2015-02-19 19:59:53 +00:00
2026-02-21 10:44:43 +00:00
print '<div class="opacitymedium hideonsmartphone justify">' . $langs -> trans ( " FileCheckDesc " ) . '</div>' ;
2025-11-03 11:17:16 +00:00
if ( isModEnabled ( 'blockedlog' )) {
2026-02-21 10:44:43 +00:00
print '<span class="opacitymedium">' ;
print $langs -> trans ( " DataIntegrityDesc " ) . ': ' ;
print '</span>' ;
2026-02-21 10:56:15 +00:00
print '<a href="' . DOL_URL_ROOT . '/blockedlog/admin/blockedlog_list.php">' . img_picto ( '' , 'url' , 'class="pictofixedwidth"' ) . $langs -> trans ( " BlockedLog " ) . '</a><br>' ;
2025-11-03 11:17:16 +00:00
}
2026-02-21 10:44:43 +00:00
print '<br>' ;
2016-09-26 13:24:43 +00:00
2015-02-19 19:59:53 +00:00
// Version
2017-09-08 08:09:22 +00:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 20:24:41 +00:00
print '<table class="noborder centpercent">' ;
2024-09-03 09:19:01 +00:00
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Version " ) . '</td><td></td></tr>' . " \n " ;
2025-10-20 01:35:12 +00:00
$htmltooltip = '' ;
$htmltooltip .= $langs -> trans ( " VersionLastInstall " ) . ': ' . getDolGlobalString ( 'MAIN_VERSION_LAST_INSTALL' ) . '<br>' . " \n " ;
$htmltooltip .= $langs -> trans ( " VersionLastUpgrade " ) . ': ' . getDolGlobalString ( 'MAIN_VERSION_LAST_UPGRADE' ) . '<br>' . " \n " ;
2026-02-21 10:44:43 +00:00
print '<tr class="oddeven nohover">' ;
print '<td width="300">' . $langs -> trans ( " VersionProgram " ) . '</td><td>' ;
2025-11-21 15:17:28 +00:00
print '<span class="badge-text badge-secondary valignmiddle">' . DOL_VERSION . '</span>' ;
2015-02-19 19:59:53 +00:00
// If current version differs from last upgrade
2023-10-24 15:00:13 +00:00
if ( ! getDolGlobalString ( 'MAIN_VERSION_LAST_UPGRADE' )) {
2024-01-11 08:59:52 +00:00
// Compare version with last install database version (upgrades never occurred)
2025-08-20 14:02:46 +00:00
if ( in_array ( versioncompare ( versiondolibarrarray (), preg_split ( '/[\-\.]/' , getDolGlobalString ( 'MAIN_VERSION_LAST_INSTALL' ))), array ( - 2 , - 1 , 1 , 2 ))) {
2024-01-05 03:18:53 +00:00
print ' ' . img_warning ( $langs -> trans ( " RunningUpdateProcessMayBeRequired " , DOL_VERSION , getDolGlobalString ( 'MAIN_VERSION_LAST_INSTALL' )));
2021-02-26 21:04:03 +00:00
}
2015-02-19 19:59:53 +00:00
} else {
2020-10-31 13:32:18 +00:00
// Compare version with last upgrade database version
2025-08-20 14:02:46 +00:00
if ( in_array ( versioncompare ( versiondolibarrarray (), preg_split ( '/[\-\.]/' , getDolGlobalString ( 'MAIN_VERSION_LAST_UPGRADE' ))), array ( - 2 , - 1 , 1 , 2 ))) {
2024-01-05 03:18:53 +00:00
print ' ' . img_warning ( $langs -> trans ( " RunningUpdateProcessMayBeRequired " , DOL_VERSION , getDolGlobalString ( 'MAIN_VERSION_LAST_UPGRADE' )));
2021-02-26 21:04:03 +00:00
}
2015-02-19 19:59:53 +00:00
}
2025-10-20 01:35:12 +00:00
print ' ' . $form -> textwithpicto ( '' , $htmltooltip );
2015-02-19 19:59:53 +00:00
print '</td></tr>' . " \n " ;
2026-02-21 10:44:43 +00:00
2026-06-07 13:14:27 +00:00
$showblockedlogversion = 0 ;
if ( $mysoc -> country_code == 'FR' ) {
$showblockedlogversion = 1 ;
}
2026-02-21 10:44:43 +00:00
if ( isALNERunningVersion ()) {
2026-06-07 13:14:27 +00:00
$showblockedlogversion = 1 ;
}
if ( $showblockedlogversion ) {
2026-02-21 10:44:43 +00:00
print '<tr class="oddeven nohover">' ;
print '<td width="300">' . $langs -> trans ( " VersionOfModule " , $langs -> transnoentitiesnoconv ( " BlockedLog " )) . '</td><td>' ;
print $versionbadge ;
print '</td>' ;
print '</tr>' ;
}
2015-02-19 19:59:53 +00:00
print '</table>' ;
2017-09-08 08:09:22 +00:00
print '</div>' ;
2026-02-17 01:51:35 +00:00
2026-02-21 10:44:43 +00:00
// Add a complementary optional information
2026-02-17 01:51:35 +00:00
$infotoshow = '' ;
if ( $mysoc -> country_code == 'FR' ) {
$islne = isALNEQualifiedVersion ( 1 , 1 );
if ( $islne ) {
2026-03-19 14:58:41 +00:00
if ( preg_match ( '/\-/' , getBlockedLogVersionToShow ())) {
2026-02-17 01:51:35 +00:00
// This is an alpha or beta version
2026-02-21 10:44:43 +00:00
$infotoshow = $langs -> trans ( " LNECandidateVersionForCertificationFR " , getBlockedLogVersionToShow ());
2026-02-17 01:51:35 +00:00
} else {
2026-02-21 10:44:43 +00:00
$infotoshow = $langs -> trans ( " LNECertifiedVersionFR " , getBlockedLogVersionToShow ());
2026-02-17 01:51:35 +00:00
}
} else {
2026-02-21 10:44:43 +00:00
$infotoshow = $langs -> trans ( " NotCertifiedVersionFR " , getBlockedLogVersionToShow ());
2026-02-17 01:51:35 +00:00
}
}
if ( $infotoshow ) {
print info_admin ( $infotoshow , 0 , 0 , 'info' );
}
2026-01-16 13:50:36 +00:00
print '<br><br>' ;
2015-02-19 19:59:53 +00:00
// Modified or missing files
$file_list = array ( 'missing' => array (), 'updated' => array ());
2015-06-20 12:15:32 +00:00
2017-02-09 00:07:54 +00:00
// Local file to compare to
2024-02-02 18:50:43 +00:00
$xmlshortfile = dol_sanitizeFileName ( GETPOST ( 'xmlshortfile' , 'alpha' ) ? GETPOST ( 'xmlshortfile' , 'alpha' ) : 'filelist-' . DOL_VERSION . getDolGlobalString ( 'MAIN_FILECHECK_LOCAL_SUFFIX' ) . '.xml' . getDolGlobalString ( 'MAIN_FILECHECK_LOCAL_EXT' ));
2021-07-11 00:58:18 +00:00
2021-04-07 17:38:54 +00:00
$xmlfile = DOL_DOCUMENT_ROOT . '/install/' . $xmlshortfile ;
2021-07-11 00:58:18 +00:00
if ( ! preg_match ( '/\.zip$/i' , $xmlfile ) && dol_is_file ( $xmlfile . '.zip' )) {
2024-03-12 21:21:52 +00:00
$xmlfile .= '.zip' ;
2021-07-11 00:58:18 +00:00
}
2017-02-09 00:07:54 +00:00
// Remote file to compare to
2021-04-07 17:38:54 +00:00
$xmlremote = GETPOST ( 'xmlremote' , 'alphanohtml' );
2023-10-24 15:00:13 +00:00
if ( empty ( $xmlremote ) && getDolGlobalString ( 'MAIN_FILECHECK_URL' )) {
2024-01-05 03:18:53 +00:00
$xmlremote = getDolGlobalString ( 'MAIN_FILECHECK_URL' );
2021-02-26 21:04:03 +00:00
}
2019-11-12 08:46:08 +00:00
$param = 'MAIN_FILECHECK_URL_' . DOL_VERSION ;
2023-08-05 13:44:28 +00:00
if ( empty ( $xmlremote ) && getDolGlobalString ( $param )) {
$xmlremote = getDolGlobalString ( $param );
2021-02-26 21:04:03 +00:00
}
if ( empty ( $xmlremote )) {
$xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-' . DOL_VERSION . '.xml' ;
}
2025-11-02 20:40:02 +00:00
if ( ! preg_match ( '/^https?:\/\//' , $xmlremote )) {
2021-04-07 17:38:54 +00:00
$langs -> load ( " errors " );
2022-12-28 10:41:59 +00:00
setEventMessages ( $langs -> trans ( " ErrorURLMustStartWithHttp " , $xmlremote ), null , 'errors' );
2021-04-07 17:38:54 +00:00
$error ++ ;
2022-06-26 18:27:51 +00:00
} elseif ( $xmlremote && ! preg_match ( '/\.xml$/' , $xmlremote )) {
$langs -> load ( " errors " );
2022-12-28 10:41:59 +00:00
setEventMessages ( $langs -> trans ( " ErrorURLMustEndWith " , $xmlremote , '.xml' ), null , 'errors' );
2022-06-26 18:27:51 +00:00
$error ++ ;
2021-04-07 17:38:54 +00:00
}
2016-10-09 18:19:24 +00:00
// Test if remote test is ok
2018-04-22 17:27:37 +00:00
$enableremotecheck = true ;
2023-10-24 15:00:13 +00:00
if ( preg_match ( '/beta|alpha|rc/i' , DOL_VERSION ) || getDolGlobalString ( 'MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE' )) {
2021-02-26 21:04:03 +00:00
$enableremotecheck = false ;
}
2015-06-20 12:15:32 +00:00
2025-10-17 00:31:07 +00:00
print '<form name="check" action="' . dolBuildUrl ( $_SERVER [ " PHP_SELF " ]) . '">' ;
2020-09-24 14:19:24 +00:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2025-10-21 12:41:42 +00:00
print img_picto ( '' , 'search' , 'class="pictofixedwidth"' ) . $langs -> trans ( " MakeIntegrityAnalysisFrom " ) . '...<br><br>' ;
2024-09-03 09:19:01 +00:00
print '<div class="divsection">' ;
2016-12-26 17:50:20 +00:00
print '<!-- for a local check target=local&xmlshortfile=... -->' . " \n " ;
2021-02-26 21:04:03 +00:00
if ( dol_is_file ( $xmlfile )) {
2021-04-19 11:52:12 +00:00
print '<input type="radio" name="target" id="checkboxlocal" value="local"' . (( ! GETPOST ( 'target' ) || GETPOST ( 'target' ) == 'local' ) ? 'checked="checked"' : '' ) . '"> <label for="checkboxlocal">' . $langs -> trans ( " LocalSignature " ) . '</label> = ' ;
2025-04-21 11:35:48 +00:00
print '<input name="xmlshortfile" class="flat minwidth400" value="' . dol_escape_htmltag ( $xmlshortfile ) . '" spellcheck="false">' ;
2020-10-31 13:32:18 +00:00
print '<br>' ;
2020-05-21 07:35:30 +00:00
} else {
2022-01-05 19:19:15 +00:00
print '<input type="radio" name="target" id="checkboxlocal" value="local"> <label for="checkboxlocal">' . $langs -> trans ( " LocalSignature " ) . ' = ' ;
2025-04-21 11:35:48 +00:00
print '<input name="xmlshortfile" class="flat minwidth400" value="' . dol_escape_htmltag ( $xmlshortfile ) . '" spellcheck="false">' ;
2025-10-11 11:01:49 +00:00
print '<br><span class="warning paddingtop inline-block">' . $langs -> trans ( " AvailableOnlyOnPackagedVersions " ) . '</span></label>' ;
2020-10-31 13:32:18 +00:00
print '<br>' ;
2016-09-26 13:24:43 +00:00
}
2025-02-20 18:50:49 +00:00
print '<br>' ;
2016-12-26 17:50:20 +00:00
print '<!-- for a remote target=remote&xmlremote=... -->' . " \n " ;
2021-02-26 21:04:03 +00:00
if ( $enableremotecheck ) {
2021-04-19 11:52:12 +00:00
print '<input type="radio" name="target" id="checkboxremote" value="remote"' . ( GETPOST ( 'target' ) == 'remote' ? 'checked="checked"' : '' ) . '> <label for="checkboxremote">' . $langs -> trans ( " RemoteSignature " ) . '</label> = ' ;
2025-04-21 11:35:48 +00:00
print '<input name="xmlremote" class="flat minwidth500" value="' . dol_escape_htmltag ( $xmlremote ) . '" spellcheck="false"><br>' ;
2020-05-21 07:35:30 +00:00
} else {
2022-01-05 19:19:15 +00:00
print '<input type="radio" name="target" id="checkboxremote" value="remote" disabled="disabled"> ' . $langs -> trans ( " RemoteSignature " ) . ' = ' . dol_escape_htmltag ( $xmlremote );
2021-02-26 21:04:03 +00:00
if ( ! GETPOST ( 'xmlremote' )) {
print ' <span class="warning">(' . $langs -> trans ( " FeatureAvailableOnlyOnStable " ) . ')</span>' ;
}
2020-10-31 13:32:18 +00:00
print '<br>' ;
2016-09-26 13:24:43 +00:00
}
2024-09-03 09:19:01 +00:00
print '</div>' ;
2025-10-11 11:01:49 +00:00
// Option unalterable log
print '<div class="center">' ;
if ( $mysoc -> country_code == 'FR' ) {
print '<input type="checkbox" name="mode" id="mode" value="unalterable"' . ( $mode == 'unalterable' ? ' checked="checked"' : '' ) . '>' ;
print '<label for="mode" class="opacitymedium">' . $langs -> trans ( " AnalyzeUnalterableScopeOnly " , $langs -> transnoentitiesnoconv ( " BlockedLog " )) . '</label><br>' ;
}
print '<input type="submit" name="check" class="button" value="' . $langs -> trans ( " Check " ) . '">' ;
print '</div>' ;
2016-09-26 13:24:43 +00:00
print '</form>' ;
print '<br>' ;
2016-10-09 18:19:24 +00:00
print '<br>' ;
2016-09-26 13:24:43 +00:00
2021-02-26 21:04:03 +00:00
if ( GETPOST ( 'target' ) == 'local' ) {
if ( dol_is_file ( $xmlfile )) {
2020-10-31 13:32:18 +00:00
// If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before
if ( preg_match ( '/\.zip$/i' , $xmlfile )) {
dol_mkdir ( $conf -> admin -> dir_temp );
$xmlfilenew = preg_replace ( '/\.zip$/i' , '' , $xmlfile );
$result = dol_uncompress ( $xmlfile , $conf -> admin -> dir_temp );
if ( empty ( $result [ 'error' ])) {
$xmlfile = $conf -> admin -> dir_temp . '/' . basename ( $xmlfilenew );
} else {
print $langs -> trans ( 'FailedToUncompressFile' ) . ': ' . $xmlfile ;
$error ++ ;
}
}
$xml = simplexml_load_file ( $xmlfile );
2021-07-11 01:04:06 +00:00
if ( $xml === false ) {
print '<div class="warning">' . $langs -> trans ( 'XmlCorrupted' ) . ': ' . $xmlfile . '</span>' ;
$error ++ ;
}
2020-10-31 13:32:18 +00:00
} else {
2021-04-07 17:38:54 +00:00
print '<div class="warning">' . $langs -> trans ( 'XmlNotFound' ) . ': ' . $xmlfile . '</span>' ;
2020-10-31 13:32:18 +00:00
$error ++ ;
}
2016-09-26 13:24:43 +00:00
}
2021-02-26 21:04:03 +00:00
if ( GETPOST ( 'target' ) == 'remote' ) {
2021-04-19 11:52:12 +00:00
$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.
2020-10-31 13:32:18 +00:00
// Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
2025-03-24 17:23:31 +00:00
if ( ! $xmlarray [ 'curl_error_no' ] && $xmlarray [ 'http_code' ] != 400 && $xmlarray [ 'http_code' ] != 404 ) {
2020-10-31 13:32:18 +00:00
$xmlfile = $xmlarray [ 'content' ];
//print "xmlfilestart".$xmlfile."xmlfileend";
2023-12-29 16:55:09 +00:00
if ( LIBXML_VERSION < 20900 ) {
// Avoid load of external entities (security problem).
// Required only if LIBXML_VERSION < 20900
2024-02-21 17:14:29 +00:00
// @phan-suppress-next-line PhanDeprecatedFunctionInternal
2023-12-29 16:55:09 +00:00
libxml_disable_entity_loader ( true );
}
2024-03-12 21:21:52 +00:00
$xml = simplexml_load_string ( $xmlfile , 'SimpleXMLElement' , LIBXML_NOCDATA | LIBXML_NONET );
2020-10-31 13:32:18 +00:00
} else {
2021-04-19 11:52:12 +00:00
$errormsg = $langs -> trans ( 'XmlNotFound' ) . ': ' . $xmlremote . ' - ' . $xmlarray [ 'http_code' ] . (( $xmlarray [ 'http_code' ] == 400 && $xmlarray [ 'content' ]) ? ' ' . $xmlarray [ 'content' ] : '' ) . ' ' . $xmlarray [ 'curl_error_no' ] . ' ' . $xmlarray [ 'curl_error_msg' ];
2020-10-31 13:32:18 +00:00
setEventMessages ( $errormsg , null , 'errors' );
$error ++ ;
}
2017-09-08 08:09:22 +00:00
}
2016-09-26 13:24:43 +00:00
2021-04-23 16:01:11 +00:00
if ( empty ( $error ) && ! empty ( $xml )) {
2020-10-31 13:32:18 +00:00
$checksumconcat = array ();
$file_list = array ();
$out = '' ;
2017-09-08 08:09:22 +00:00
2026-01-16 14:13:33 +00:00
$algo = ( string ) $xml [ 'algo' ]; // When file is <checksum_list attrib="val" algo="xxx">...</checksum_list>, the first tag is root of the $xml
if ( empty ( $algo )) {
//$algo = 'md5'; // For v22-
$algo = 'sha256' ; // For v23+
}
2025-12-22 03:52:12 +00:00
2020-10-31 13:32:18 +00:00
// Forced constants
2025-10-20 00:35:55 +00:00
if ( is_object ( $xml -> dolibarr_constants [ 0 ]) || $mode == 'unalterable' ) {
2020-10-31 13:32:18 +00:00
$out .= load_fiche_titre ( $langs -> trans ( " ForcedConstants " ));
2017-09-08 08:09:22 +00:00
2019-11-12 08:46:08 +00:00
$out .= '<div class="div-table-responsive-no-min">' ;
2020-10-31 13:32:18 +00:00
$out .= '<table class="noborder">' ;
$out .= '<tr class="liste_titre">' ;
$out .= '<td>#</td>' ;
2025-10-20 00:35:55 +00:00
$out .= '<td>' . $langs -> trans ( " Parameter " ) . '</td>' ;
2020-10-31 13:32:18 +00:00
$out .= '<td class="center">' . $langs -> trans ( " ExpectedValue " ) . '</td>' ;
2025-10-20 00:35:55 +00:00
$out .= '<td class="center">' . $langs -> trans ( " CurrentValue " ) . '</td>' ;
2020-10-31 13:32:18 +00:00
$out .= '</tr>' . " \n " ;
2025-10-22 12:31:04 +00:00
$i = 0 ;
2025-10-20 00:35:55 +00:00
if ( $mode == 'unalterable' ) {
2025-10-22 12:31:04 +00:00
$i ++ ;
2025-10-20 00:35:55 +00:00
$out .= '<tr class="oddeven">' ;
2025-10-22 12:31:04 +00:00
$out .= '<td>' . $i . '</td>' . " \n " ;
2025-10-20 00:35:55 +00:00
$out .= '<td>' . $langs -> trans ( " Country " ) . '</td>' . " \n " ;
2025-10-21 12:41:42 +00:00
$out .= '<td class="center"><span class="opacitymedium">' . $langs -> trans ( " YourCountryCode " ) . '</span></td>' . " \n " ;
2025-10-20 00:35:55 +00:00
$out .= '<td class="center">' . $mysoc -> country_code . '</td>' . " \n " ;
$out .= " </tr> \n " ;
2025-10-22 12:31:04 +00:00
$i ++ ;
2025-10-20 00:35:55 +00:00
$out .= '<tr class="oddeven">' ;
2025-10-22 12:31:04 +00:00
$out .= '<td>' . $i . '</td>' . " \n " ;
2025-10-21 12:41:42 +00:00
$out .= '<td>' . $langs -> trans ( " StatusOfModule " , $langs -> transnoentitiesnoconv ( " BlockedLog " )) . '</td>' . " \n " ;
$out .= '<td class="center">' . $langs -> trans ( " Enabled " ) . '</td>' . " \n " ;
$out .= '<td class="center">' ;
$out .= isModEnabled ( 'blockedlog' ) ? '<span class="ok">' . $langs -> trans ( " Enabled " ) . '</span>' : '<span class="warning">' . $langs -> trans ( " Disabled " ) . '</span>' ;
include_once DOL_DOCUMENT_ROOT . '/core/modules/modBlockedLog.class.php' ;
$objMod = new modBlockedLog ( $db );
2025-10-22 12:31:04 +00:00
/* $modulename = $objMod -> getName ();
2025-10-21 12:41:42 +00:00
$moduledesc = $objMod -> getDesc ();
$moduleauthor = $objMod -> getPublisher ();
2025-10-22 12:31:04 +00:00
$moduledir = strtolower ( preg_replace ( '/^mod/i' , '' , get_class ( $objMod ))); */
2025-10-21 12:41:42 +00:00
$const_name = 'MAIN_MODULE_' . strtoupper ( preg_replace ( '/^mod/i' , '' , get_class ( $objMod )));
2025-10-21 22:48:28 +00:00
$htmltooltip = '<span class="opacitymedium">' . $langs -> trans ( " LastActivationDate " ) . ':</span> ' ;
2025-10-21 12:41:42 +00:00
if ( getDolGlobalString ( $const_name )) {
2025-10-21 22:48:28 +00:00
$htmltooltip .= dol_print_date ( $objMod -> getLastActivationDate (), 'dayhour' );
2025-10-21 12:41:42 +00:00
} else {
2025-10-21 22:48:28 +00:00
$htmltooltip .= $langs -> trans ( " Disabled " );
2025-10-21 12:41:42 +00:00
}
$tmp = $objMod -> getLastActivationInfo ();
$authorid = ( empty ( $tmp [ 'authorid' ]) ? '' : $tmp [ 'authorid' ]);
if ( $authorid > 0 ) {
$tmpuser = new User ( $db );
$tmpuser -> fetch ( $authorid );
2025-10-21 22:48:28 +00:00
$htmltooltip .= '<br><span class="opacitymedium">' . $langs -> trans ( " LastActivationAuthor " ) . ':</span> ' ;
$htmltooltip .= $tmpuser -> getNomUrl ( 0 , 'nolink' , - 1 , 1 );
2025-10-21 12:41:42 +00:00
}
$ip = ( empty ( $tmp [ 'ip' ]) ? '' : $tmp [ 'ip' ]);
if ( $ip ) {
2025-10-21 22:48:28 +00:00
$htmltooltip .= '<br><span class="opacitymedium">' . $langs -> trans ( " LastActivationIP " ) . ':</span> ' ;
$htmltooltip .= $ip ;
2025-10-21 12:41:42 +00:00
}
$lastactivationversion = ( empty ( $tmp [ 'lastactivationversion' ]) ? '' : $tmp [ 'lastactivationversion' ]);
if ( $lastactivationversion && $lastactivationversion != 'dolibarr' ) {
2025-10-21 22:48:28 +00:00
$htmltooltip .= '<br><span class="opacitymedium">' . $langs -> trans ( " LastActivationVersion " ) . ':</span> ' ;
$htmltooltip .= $lastactivationversion ;
2025-10-21 12:41:42 +00:00
}
2025-10-21 22:48:28 +00:00
$out .= $form -> textwithpicto ( '' , $htmltooltip );
2025-10-21 12:41:42 +00:00
2025-10-21 22:48:28 +00:00
$out .= " </td> \n " ;
2025-10-20 00:35:55 +00:00
$out .= " </tr> \n " ;
}
2021-02-26 21:04:03 +00:00
foreach ( $xml -> dolibarr_constants [ 0 ] -> constant as $constant ) { // $constant is a simpleXMLElement
2025-10-11 11:01:49 +00:00
$constname = ( string ) $constant [ 'name' ];
2020-10-31 13:32:18 +00:00
$constvalue = ( string ) $constant ;
2025-10-11 11:01:49 +00:00
2020-10-31 13:32:18 +00:00
$constvalue = ( empty ( $constvalue ) ? '0' : $constvalue );
// Value found
$value = '' ;
2022-06-25 00:18:16 +00:00
if ( $constname && getDolGlobalString ( $constname ) != '' ) {
$value = getDolGlobalString ( $constname );
2021-02-26 21:04:03 +00:00
}
2020-10-31 13:32:18 +00:00
$valueforchecksum = ( empty ( $value ) ? '0' : $value );
2025-10-11 11:01:49 +00:00
$checksumconcat [ $constname ] = $valueforchecksum ;
2020-10-31 13:32:18 +00:00
$i ++ ;
2025-10-22 12:31:04 +00:00
2020-10-31 13:32:18 +00:00
$out .= '<tr class="oddeven">' ;
$out .= '<td>' . $i . '</td>' . " \n " ;
$out .= '<td>' . dol_escape_htmltag ( $constname ) . '</td>' . " \n " ;
$out .= '<td class="center">' . dol_escape_htmltag ( $constvalue ) . '</td>' . " \n " ;
$out .= '<td class="center">' . dol_escape_htmltag ( $valueforchecksum ) . '</td>' . " \n " ;
$out .= " </tr> \n " ;
}
2025-10-20 00:35:55 +00:00
if ( $i == 0 && $mode != 'unalterable' ) {
2024-08-16 14:12:05 +00:00
$out .= '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span></td></tr>' ;
2020-10-31 13:32:18 +00:00
}
$out .= '</table>' ;
$out .= '</div>' ;
$out .= '<br>' ;
}
2025-10-11 11:01:49 +00:00
$onlymodifiedorremoved = 0 ;
if ( $mode == 'unalterable' ) {
$listoffilestoanalyze = $xml -> dolibarr_unalterable_files [ 0 ];
$onlymodifiedorremoved = 1 ;
} else {
$listoffilestoanalyze = $xml -> dolibarr_htdocs_dir [ 0 ];
$onlymodifiedorremoved = 0 ;
}
2025-12-22 03:52:12 +00:00
2020-10-31 13:32:18 +00:00
// Scan htdocs
2025-10-11 11:01:49 +00:00
if ( is_object ( $listoffilestoanalyze )) {
2025-10-11 11:33:55 +00:00
// @phan-suppress-next-line PhanTypeArraySuspicious
2025-10-11 11:01:49 +00:00
$includecustom = ( empty ( $listoffilestoanalyze [ 'includecustom' ]) ? 0 : $listoffilestoanalyze [ 'includecustom' ]);
2020-10-31 13:32:18 +00:00
2021-05-10 12:33:26 +00:00
// Define qualified files (must be same than into generate_filelist_xml.php and in api_setup.class.php)
$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)$' ;
$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
2020-10-31 13:32:18 +00:00
$scanfiles = dol_dir_list ( DOL_DOCUMENT_ROOT , 'files' , 1 , $regextoinclude , $regextoexclude );
// Fill file_list with files in signature, new files, modified files
2025-10-11 11:27:16 +00:00
getFilesUpdated ( $file_list , $listoffilestoanalyze , '' , DOL_DOCUMENT_ROOT , $checksumconcat ); // Fill array $file_list
2025-12-22 03:52:12 +00:00
'@phan-var-force array{insignature:string[],missing?:array<array{filename:string,expectedhash:string,expectedsize:string,algo:string}>,updated:array<array{filename:string,expectedhash:string,expectedsize:string,hash:string,algo:string}>} $file_list' ;
2025-10-11 11:01:49 +00:00
// Complete with list of new files into $file_list['added']
2025-12-22 03:52:12 +00:00
if ( empty ( $onlymodifiedorremoved )) {
2025-10-11 11:27:16 +00:00
foreach ( $scanfiles as $valfile ) {
2025-10-11 11:01:49 +00:00
$tmprelativefilename = preg_replace ( '/^' . preg_quote ( DOL_DOCUMENT_ROOT , '/' ) . '/' , '' , $valfile [ 'fullname' ]);
if ( ! in_array ( $tmprelativefilename , $file_list [ 'insignature' ])) {
2025-12-22 03:52:12 +00:00
$hashnewfile = @ hash_file ( $algo , $valfile [ 'fullname' ]); // Can fails if we don't have permission to open/read file
$file_list [ 'added' ][] = array ( 'filename' => $tmprelativefilename , 'hash' => $hashnewfile , 'algo' => $algo );
2025-10-11 11:01:49 +00:00
}
2020-10-31 13:32:18 +00:00
}
}
2024-01-11 08:59:52 +00:00
// Files missing
2020-10-31 13:32:18 +00:00
$out .= load_fiche_titre ( $langs -> trans ( " FilesMissing " ));
2019-11-12 08:46:08 +00:00
$out .= '<div class="div-table-responsive-no-min">' ;
2020-10-31 13:32:18 +00:00
$out .= '<table class="noborder">' ;
$out .= '<tr class="liste_titre">' ;
$out .= '<td>#</td>' ;
$out .= '<td>' . $langs -> trans ( " Filename " ) . '</td>' ;
$out .= '<td class="right">' . $langs -> trans ( " ExpectedSize " ) . '</td>' ;
$out .= '<td class="center">' . $langs -> trans ( " ExpectedChecksum " ) . '</td>' ;
$out .= '</tr>' . " \n " ;
$tmpfilelist = dol_sort_array ( $file_list [ 'missing' ], 'filename' );
2021-02-26 21:04:03 +00:00
if ( is_array ( $tmpfilelist ) && count ( $tmpfilelist )) {
2020-10-31 13:32:18 +00:00
$i = 0 ;
2021-02-26 21:04:03 +00:00
foreach ( $tmpfilelist as $file ) {
2020-10-31 13:32:18 +00:00
$i ++ ;
$out .= '<tr class="oddeven">' ;
$out .= '<td>' . $i . '</td>' . " \n " ;
$out .= '<td>' . dol_escape_htmltag ( $file [ 'filename' ]) . '</td>' . " \n " ;
$out .= '<td class="right">' ;
2021-02-26 21:04:03 +00:00
if ( ! empty ( $file [ 'expectedsize' ])) {
2025-03-16 19:21:22 +00:00
$out .= dol_print_size (( int ) $file [ 'expectedsize' ]);
2021-02-26 21:04:03 +00:00
}
2020-10-31 13:32:18 +00:00
$out .= '</td>' . " \n " ;
2025-12-22 03:52:12 +00:00
$out .= '<td class="center">' . dol_escape_htmltag ( $file [ 'expectedhash' ]) . '</td>' . " \n " ;
2020-10-31 13:32:18 +00:00
$out .= " </tr> \n " ;
}
} else {
2024-08-16 14:12:05 +00:00
$out .= '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span></td></tr>' ;
2020-10-31 13:32:18 +00:00
}
$out .= '</table>' ;
$out .= '</div>' ;
$out .= '<br>' ;
// Files modified
$out .= load_fiche_titre ( $langs -> trans ( " FilesModified " ));
$totalsize = 0 ;
2019-11-12 08:46:08 +00:00
$out .= '<div class="div-table-responsive-no-min">' ;
2020-10-31 13:32:18 +00:00
$out .= '<table class="noborder">' ;
$out .= '<tr class="liste_titre">' ;
$out .= '<td>#</td>' ;
$out .= '<td>' . $langs -> trans ( " Filename " ) . '</td>' ;
$out .= '<td class="center">' . $langs -> trans ( " ExpectedChecksum " ) . '</td>' ;
$out .= '<td class="center">' . $langs -> trans ( " CurrentChecksum " ) . '</td>' ;
$out .= '<td class="right">' . $langs -> trans ( " ExpectedSize " ) . '</td>' ;
$out .= '<td class="right">' . $langs -> trans ( " CurrentSize " ) . '</td>' ;
$out .= '<td class="right">' . $langs -> trans ( " DateModification " ) . '</td>' ;
$out .= '</tr>' . " \n " ;
$tmpfilelist2 = dol_sort_array ( $file_list [ 'updated' ], 'filename' );
2021-02-26 21:04:03 +00:00
if ( is_array ( $tmpfilelist2 ) && count ( $tmpfilelist2 )) {
2020-10-31 13:32:18 +00:00
$i = 0 ;
2021-02-26 21:04:03 +00:00
foreach ( $tmpfilelist2 as $file ) {
2020-10-31 13:32:18 +00:00
$i ++ ;
$out .= '<tr class="oddeven">' ;
$out .= '<td>' . $i . '</td>' . " \n " ;
2026-07-27 11:50:06 +00:00
$out .= '<td>' . dol_escape_htmltag ( $file [ 'filename' ]);
$out .= ' <a href="#" class="showfilediff" data-file="' . dol_escape_htmltag ( $file [ 'filename' ]) . '" data-algo="' . dol_escape_htmltag ( $file [ 'algo' ]) . '" data-hash="' . dol_escape_htmltag ( $file [ 'expectedhash' ]) . '">' ;
$out .= img_picto ( $langs -> trans ( " ShowDiffWithOriginal " ), 'split' , 'class="paddingleft"' );
$out .= '</a>' ;
$out .= '</td>' . " \n " ;
2026-02-16 05:21:12 +00:00
$out .= '<td class="center" title="' . dol_escape_htmltag ( $file [ 'expectedhash' ]) . '">' . dol_escape_htmltag ( dol_trunc ( $file [ 'expectedhash' ], 16 )) . '</td>' . " \n " ;
$out .= '<td class="center" title="' . dol_escape_htmltag ( $file [ 'hash' ]) . '">' . dol_escape_htmltag ( dol_trunc ( $file [ 'hash' ], 16 )) . '</td>' . " \n " ;
2020-10-31 13:32:18 +00:00
$out .= '<td class="right">' ;
2021-02-26 21:04:03 +00:00
if ( $file [ 'expectedsize' ]) {
2025-03-16 19:21:22 +00:00
$out .= dol_print_size (( int ) $file [ 'expectedsize' ]);
2021-02-26 21:04:03 +00:00
}
2020-10-31 13:32:18 +00:00
$out .= '</td>' . " \n " ;
$size = dol_filesize ( DOL_DOCUMENT_ROOT . '/' . $file [ 'filename' ]);
$totalsize += $size ;
$out .= '<td class="right">' . dol_print_size ( $size ) . '</td>' . " \n " ;
$out .= '<td class="right">' . dol_print_date ( dol_filemtime ( DOL_DOCUMENT_ROOT . '/' . $file [ 'filename' ]), 'dayhour' ) . '</td>' . " \n " ;
$out .= " </tr> \n " ;
}
$out .= '<tr class="liste_total">' ;
$out .= '<td></td>' . " \n " ;
$out .= '<td>' . $langs -> trans ( " Total " ) . '</td>' . " \n " ;
$out .= '<td class="center"></td>' . " \n " ;
$out .= '<td class="center"></td>' . " \n " ;
$out .= '<td class="center"></td>' . " \n " ;
$out .= '<td class="right">' . dol_print_size ( $totalsize ) . '</td>' . " \n " ;
$out .= '<td class="right"></td>' . " \n " ;
$out .= " </tr> \n " ;
} else {
2024-08-16 14:12:05 +00:00
$out .= '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span></td></tr>' ;
2020-10-31 13:32:18 +00:00
}
$out .= '</table>' ;
$out .= '</div>' ;
2026-07-27 11:50:06 +00:00
// Ajax loader for the per-file diff against the original version
$out .= '<script>' . " \n " ;
$out .= 'jQuery(document).ready(function() {' . " \n " ;
$out .= ' jQuery(".showfilediff").on("click", function(e) {' . " \n " ;
$out .= ' e.preventDefault();' . " \n " ;
$out .= ' var link = jQuery(this);' . " \n " ;
$out .= ' var row = link.closest("tr");' . " \n " ;
$out .= ' var existing = row.next(".filediffrow");' . " \n " ;
$out .= ' if (existing.length) { existing.toggle(); return false; }' . " \n " ;
$out .= ' var colspan = row.children("td").length;' . " \n " ;
$out .= ' var newrow = jQuery(\'<tr class="filediffrow"><td colspan="\'+colspan+\'"><div class="filediffcontent opacitymedium">' . dol_escape_js ( $langs -> trans ( " Loading " )) . '...</div></td></tr>\');' . " \n " ;
$out .= ' row.after(newrow);' . " \n " ;
$out .= ' jQuery.get("' . dol_escape_js ( DOL_URL_ROOT ) . '/blockedlog/admin/filecheck_diff.php", { file: link.attr("data-file"), algo: link.attr("data-algo"), expectedhash: link.attr("data-hash"), token: "' . newToken () . '" }, function(data) {' . " \n " ;
$out .= ' newrow.find(".filediffcontent").removeClass("opacitymedium").html(data);' . " \n " ;
$out .= ' }).fail(function() {' . " \n " ;
$out .= ' newrow.find(".filediffcontent").html("' . dol_escape_js ( $langs -> trans ( " Error " )) . '");' . " \n " ;
$out .= ' });' . " \n " ;
$out .= ' return false;' . " \n " ;
$out .= ' });' . " \n " ;
$out .= '});' . " \n " ;
$out .= '</script>' . " \n " ;
2020-10-31 13:32:18 +00:00
$out .= '<br>' ;
// Files added
2025-10-11 11:01:49 +00:00
if ( empty ( $onlymodifiedorremoved )) {
$out .= load_fiche_titre ( $langs -> trans ( " FilesAdded " ));
$totalsize = 0 ;
$out .= '<div class="div-table-responsive-no-min">' ;
$out .= '<table class="noborder">' ;
$out .= '<tr class="liste_titre">' ;
$out .= '<td>#</td>' ;
$out .= '<td>' . $langs -> trans ( " Filename " ) . '</td>' ;
$out .= '<td class="center">' . $langs -> trans ( " ExpectedChecksum " ) . '</td>' ;
$out .= '<td class="center">' . $langs -> trans ( " CurrentChecksum " ) . '</td>' ;
$out .= '<td class="right">' . $langs -> trans ( " Size " ) . '</td>' ;
$out .= '<td class="right">' . $langs -> trans ( " DateModification " ) . '</td>' ;
$out .= '</tr>' . " \n " ;
$tmpfilelist3 = dol_sort_array ( $file_list [ 'added' ], 'filename' );
if ( is_array ( $tmpfilelist3 ) && count ( $tmpfilelist3 )) {
$i = 0 ;
foreach ( $tmpfilelist3 as $file ) {
$i ++ ;
$out .= '<tr class="oddeven">' ;
$out .= '<td>' . $i . '</td>' . " \n " ;
$out .= '<td>' . dol_escape_htmltag ( $file [ 'filename' ]);
if ( ! preg_match ( '/^win/i' , PHP_OS )) {
$htmltext = $langs -> trans ( " YouCanDeleteFileOnServerWith " , 'rm ' . DOL_DOCUMENT_ROOT . $file [ 'filename' ]); // The slash is included int file['filename']
$out .= ' ' . $form -> textwithpicto ( '' , $htmltext , 1 , 'help' , '' , 0 , 2 , 'helprm' . $i );
}
$out .= '</td>' . " \n " ;
2026-02-16 05:21:12 +00:00
$out .= '<td class="center" title="' . dol_escape_htmltag (( string ) $file [ 'expectedhash' ]) . '">' . dol_escape_htmltag ( dol_trunc (( string ) $file [ 'expectedhash' ], 16 )) . '</td>' . " \n " ; // @phan-suppress-current-line PhanTypeInvalidDimOffset
$out .= '<td class="center" title="' . dol_escape_htmltag (( string ) $file [ 'hash' ]) . '">' . dol_escape_htmltag ( dol_trunc ( $file [ 'hash' ], 16 )) . '</td>' . " \n " ;
2025-10-11 11:01:49 +00:00
$size = dol_filesize ( DOL_DOCUMENT_ROOT . '/' . $file [ 'filename' ]);
$totalsize += $size ;
$out .= '<td class="right">' . dol_print_size ( $size ) . '</td>' . " \n " ;
$out .= '<td class="right nowraponall">' . dol_print_date ( dol_filemtime ( DOL_DOCUMENT_ROOT . '/' . $file [ 'filename' ]), 'dayhour' ) . '</td>' . " \n " ;
$out .= " </tr> \n " ;
2020-10-31 13:32:18 +00:00
}
2025-10-11 11:01:49 +00:00
$out .= '<tr class="liste_total">' ;
$out .= '<td></td>' . " \n " ;
$out .= '<td>' . $langs -> trans ( " Total " ) . '</td>' . " \n " ;
$out .= '<td class="center"></td>' . " \n " ;
$out .= '<td class="center"></td>' . " \n " ;
$out .= '<td class="right">' . dol_print_size ( $totalsize ) . '</td>' . " \n " ;
$out .= '<td class="right"></td>' . " \n " ;
2020-10-31 13:32:18 +00:00
$out .= " </tr> \n " ;
2025-10-11 11:01:49 +00:00
} else {
$out .= '<tr class="oddeven"><td colspan="6"><span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span></td></tr>' ;
2020-10-31 13:32:18 +00:00
}
2025-10-11 11:01:49 +00:00
$out .= '</table>' ;
$out .= '</div>' ;
2020-10-31 13:32:18 +00:00
}
} else {
2022-06-25 00:18:16 +00:00
print '<div class="error">' ;
print 'Error: Failed to found <b>dolibarr_htdocs_dir</b> into content of XML file:<br>' . dol_escape_htmltag ( dol_trunc ( $xmlfile , 500 ));
print '</div><br>' ;
2020-10-31 13:32:18 +00:00
$error ++ ;
}
// Scan scripts
/*
2025-11-17 15:39:27 +00:00
if ( is_object ( $xml -> dolibarr_scripts_dir [ 0 ])) {
2021-02-26 21:04:03 +00:00
$file_list = array ();
$ret = getFilesUpdated ( $file_list , $xml -> dolibarr_htdocs_dir [ 0 ], '' , ? ? ? , $checksumconcat ); // Fill array $file_list
2025-12-22 03:52:12 +00:00
'@phan-var-force array{insignature:string[],missing?:array<array{filename:string,expectedhash:string,expectedsize:string,algo:string}>,updated:array<array{filename:string,expectedhash:string,expectedsize:string,hash:string,algo:string}>} $file_list' ;
2021-02-26 21:04:03 +00:00
} */
2017-09-08 08:09:22 +00:00
2025-10-11 11:01:49 +00:00
// Section Globalchecksum
2020-10-31 13:32:18 +00:00
asort ( $checksumconcat ); // Sort list of checksum
2025-10-11 11:01:49 +00:00
2025-12-22 03:52:12 +00:00
$checksumget = hash ( $algo , implode ( ',' , $checksumconcat ));
2017-01-07 14:56:04 +00:00
2025-10-11 11:01:49 +00:00
if ( $mode == 'unalterable' ) {
$nameofsection = 'dolibarr_unalterable_files_checksum' ;
$checksumtoget = trim (( string ) $xml -> dolibarr_unalterable_files_checksum );
} else {
$nameofsection = 'dolibarr_htdocs_dir_checksum' ;
$checksumtoget = trim (( string ) $xml -> dolibarr_htdocs_dir_checksum );
}
2017-12-16 16:24:23 +00:00
2021-02-20 10:46:48 +00:00
$resultcomment = '' ;
2020-10-31 13:32:18 +00:00
$outexpectedchecksum = ( $checksumtoget ? $checksumtoget : $langs -> trans ( " Unknown " ));
2025-10-21 12:41:42 +00:00
$outcurrentchecksumtext = '' ;
2021-02-26 21:04:03 +00:00
if ( $checksumget == $checksumtoget ) {
2025-10-11 11:30:12 +00:00
if ( empty ( $onlymodifiedorremoved ) && ! empty ( $file_list [ 'added' ])) {
2020-10-31 13:32:18 +00:00
$resultcode = 'warning' ;
$resultcomment = 'FileIntegrityIsOkButFilesWereAdded' ;
2025-10-11 11:01:49 +00:00
$outcurrentchecksum = $checksumget ;
2025-10-21 12:41:42 +00:00
$outcurrentchecksumtext .= img_picto ( '' , 'tick' ) . ' <span class="' . $resultcode . '">' . $langs -> trans ( $resultcomment ) . '</span>' ;
2020-10-31 13:32:18 +00:00
} else {
$resultcode = 'ok' ;
$resultcomment = 'Success' ;
2025-10-11 11:01:49 +00:00
$outcurrentchecksum = '<span class="' . $resultcode . '" title="Checksum of all current checksums concatenated separated by a comma">' . $checksumget . '</span>' ;
2025-10-22 12:41:35 +00:00
$outcurrentchecksumtext .= img_picto ( '' , 'tick' ) . ' <span class="badge badge-status4 badge-status ' . $resultcode . '">' . $langs -> trans ( $resultcomment ) . '</span>' ;
2020-10-31 13:32:18 +00:00
}
} else {
$resultcode = 'error' ;
2025-10-11 11:01:49 +00:00
$resultcomment = 'FileIntegrityIsKO' ;
$outcurrentchecksum = '<span class="' . $resultcode . '" title="Checksum of all current checksums concatenated separated by a comma">' . $checksumget . '</span>' ;
2025-10-21 12:41:42 +00:00
$outcurrentchecksumtext .= img_picto ( '' , 'error' ) . ' <span class="' . $resultcode . '">' . $langs -> trans ( $resultcomment ) . '</span>' ;
2020-10-31 13:32:18 +00:00
}
2021-02-20 10:46:48 +00:00
// Show warning
if ( empty ( $tmpfilelist ) && empty ( $tmpfilelist2 ) && empty ( $tmpfilelist3 ) && $resultcode == 'ok' ) {
setEventMessages ( $langs -> trans ( " FileIntegrityIsStrictlyConformedWithReference " ), null , 'mesgs' );
} else {
if ( $resultcode == 'warning' ) {
setEventMessages ( $langs -> trans ( $resultcomment ), null , 'warnings' );
} else {
setEventMessages ( $langs -> trans ( " FileIntegritySomeFilesWereRemovedOrModified " ), null , 'errors' );
}
}
2025-10-11 11:30:12 +00:00
$outforlistoffiles = '' ;
2025-10-11 11:01:49 +00:00
if ( $mode == 'unalterable' ) {
print load_fiche_titre ( $langs -> trans ( " UnalterableFilesChecksum " ));
// Print list of files
$outforlistoffiles = '<a href="#" onclick="console.log(\'Click\'); jQuery(\'#listofunalterablefiles\').toggle(); return false;">' . $langs -> trans ( " ShowListOfFiles " ) . '</a><br>' ;
2026-05-26 14:51:18 +00:00
$outforlistoffiles .= '<textarea id="listofunalterablefiles" class="hideobject quatrevingtpercent" rows="12" spellcheck="false">' ;
2025-10-11 11:01:49 +00:00
$i = 0 ;
foreach ( $listoffilestoanalyze as $dirtoanalyze ) {
2025-12-22 03:52:12 +00:00
$entry = array ();
if ( ! empty ( $dirtoanalyze -> md5file )) {
$entry = $dirtoanalyze -> md5file ;
$algo = 'md5' ;
} elseif ( ! empty ( $dirtoanalyze -> sha256file )) {
$entry = $dirtoanalyze -> sha256file ;
$algo = 'sha256' ;
}
foreach ( $entry as $filetoanalyze ) {
2025-10-11 11:01:49 +00:00
if ( $i ) {
$outforlistoffiles .= " \n " ;
}
$outforlistoffiles .= ( string ) $dirtoanalyze [ 'name' ];
$outforlistoffiles .= '/' ;
$outforlistoffiles .= ( string ) $filetoanalyze [ 'name' ];
$i ++ ;
}
}
$outforlistoffiles .= '</textarea>' ;
$outforlistoffiles .= '<br>' ;
} else {
print load_fiche_titre ( $langs -> trans ( " GlobalChecksum " ));
}
2025-10-21 12:41:42 +00:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder">' ;
print '<tr class="liste_titre">' ;
2026-01-16 14:13:33 +00:00
print '<td>' . $langs -> trans ( " ExpectedChecksum " ) . ' <span class="opacitymedium">(' . $algo . ')</span></td>' ;
print '<td>' . $langs -> trans ( " CurrentChecksum " ) . ' <span class="opacitymedium">(' . $algo . ')</span></td>' ;
2025-10-21 12:41:42 +00:00
print '</tr>' . " \n " ;
print '<tr><td>' ;
2025-10-11 11:01:49 +00:00
print '<span title="Checksum of all checksums in file separated by a comma and saved into ' . $nameofsection . '">' ;
print $outexpectedchecksum ;
2025-10-21 12:41:42 +00:00
print '</span>' ;
print '</td><td>' ;
print $outcurrentchecksum ;
print '</td>' ;
print '</tr>' ;
print '</table>' ;
print $outcurrentchecksumtext . '<br>' ;
2020-10-31 13:32:18 +00:00
2025-10-21 12:41:42 +00:00
print '<br>' ;
2025-10-11 11:01:49 +00:00
print $outforlistoffiles ;
2025-10-22 12:41:35 +00:00
print '<br><br>' ;
2025-10-11 11:01:49 +00:00
2020-10-31 13:32:18 +00:00
// Output detail
print $out ;
2015-06-20 12:24:22 +00:00
}
2016-09-26 13:24:43 +00:00
2018-07-28 12:29:28 +00:00
// End of page
2015-02-19 19:59:53 +00:00
llxFooter ();
$db -> close ();
2015-09-13 18:25:33 +00:00
exit ( $error );