Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

send_integrity_failure_notices()

Description

Send notifications about file integrity failures

Parameters

ColumnTypeDefaultDescription
$failures: array get_sysvar'last_integrity_check_notify'
'1970-01-01';
$failures array Array of resources that have failed integrity check

Location

include/message_functions.php lines 1182 to 1222

Definition

 
function send_integrity_failure_notices( array $failures): void
{
    
$last_integrity_check_notify get_sysvar('last_integrity_check_notify''1970-01-01');
    if (
time()-strtotime($last_integrity_check_notify) < 24*60*60) {
        if(
'cli' == PHP_SAPI) {
            echo 
" - Skipping sending of integrity failure notifications - last sent: " $last_integrity_check_notify PHP_EOL;
        }
    } else {
        if(
'cli' == PHP_SAPI) {
            echo 
" - Sending summary messages to administrators" PHP_EOL;
        }

    
# Send notification
    
$message = new ResourceSpaceUserNotification();
    
$message->set_subject("lang_file_integrity_summary");
    
$message->set_text("lang_file_integrity_summary_failed");
    
$message->append_text("<br><br>");
    if (
count($failures) < 1000) {
        
// Show links to the resources that have failed this time.
        // If too many have failed it will still include a link to the general search for all failed resources.
        
$message->append_text("<table class='ListviewStyle'");
        
$n 1;
        foreach (
array_chunk($failures,200) as $arr_failed) {
            
$message->append_text("<tr><td class='SingleLine'><a href='");
            
$message->append_text($GLOBALS["baseurl"] . "/pages/search.php?search=!list" implode(":"$arr_failed));
            
$message->append_text("'>");
            
$message->append_text("lang_file_integrity_fail_search");
            
$message->append_text(" ({$n})");
            
$message->append_text("</a></td></tr>");
            
$n++;
            }
        
$message->append_text("</table>");
    }

    
$message->url $GLOBALS["baseurl"] . "/pages/search.php?search=!integrityfail";

    
$notify_users get_notification_users("SYSTEM_ADMIN");
    
send_user_notification($notify_users,$message);
    
set_sysvar("last_integrity_check_notify",date("Y-m-d H:i:s"));
    }
}

This article was last updated 4th May 2024 21:35 Europe/London time based on the source file dated 29th April 2024 17:05 Europe/London time.