Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Creates HTML for email and admin alert
- *
- * @param array $files_added Array holding any files that have been added
- * @param array $files_removed Array holding any files that have been removed
- * @param array $changed_files Array holding any files that have been changed
- * @return string $alertMessage return formatted HTML
- */
- protected function format_alert($files_added, $files_removed, $changed_files) {
- $alertMessage = sprintf(__("Files Changed: %d", "wordpress-file-monitor-plus"), count($changed_files[0]))."<br />";
- $alertMessage .= sprintf(__("Files Added: %d", "wordpress-file-monitor-plus"), count($files_added))."<br />";
- $alertMessage .= sprintf(__("Files Removed: %d", "wordpress-file-monitor-plus"), count($files_removed))."<br />";
- $alertMessage .= "<br />";
- if(1 == $this->settings['file_check_use_modified']){
- $date_format = get_option( 'date_format' );
- $time_format = get_option( 'time_format' );
- $gmt_offset = get_option( 'gmt_offset' );
- }
- // Only do this if some changed files
- if(count($changed_files[0]) >= 1) {
- $alertMessage .= "<strong>".__("Files Changed:", "wordpress-file-monitor-plus")."</strong>";
- $alertMessage .= "<table class='widefat' width='100%' border='1' cellspacing='0' cellpadding='2'>";
- $alertMessage .= " <thead>";
- $alertMessage .= " <tr>";
- $alertMessage .= " <th width='100%'>".__("File", "wordpress-file-monitor-plus")."</th>";
- if($this->settings['file_check_use_size'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("New Filesize", "wordpress-file-monitor-plus")."</th>";
- $alertMessage .= " <th nowrap='nowrap'>".__("Old Filesize", "wordpress-file-monitor-plus")."</th>";
- }
- if($this->settings['file_check_use_modified'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("New Modified", "wordpress-file-monitor-plus")."</th>";
- $alertMessage .= " <th nowrap='nowrap'>".__("Old Modified", "wordpress-file-monitor-plus")."</th>";
- }
- if($this->settings['file_check_use_md5'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("New Hash", "wordpress-file-monitor-plus")."</th>";
- $alertMessage .= " <th nowrap='nowrap'>".__("Old Hash", "wordpress-file-monitor-plus")."</th>";
- }
- $alertMessage .= " </tr>";
- $alertMessage .= " </thead>";
- $alertMessage .= " <tbody>";
- foreach($changed_files[0] as $key => $data) {
- $alertMessage .= " <tr>";
- $alertMessage .= " <td>".$key."</td>";
- if($this->settings['file_check_use_size'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".$this->formatRawSize($this->newScanData[$key]["size"])."</td>";
- $alertMessage .= " <td nowrap='nowrap'>".$this->formatRawSize($this->oldScanData[$key]["size"])."</td>";
- }
- if($this->settings['file_check_use_modified'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->newScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
- $alertMessage .= " <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->oldScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
- }
- if($this->settings['file_check_use_md5'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".$this->newScanData[$key]["md5"]."</td>";
- $alertMessage .= " <td nowrap='nowrap'>".$this->oldScanData[$key]["md5"]."</td>";
- }
- $alertMessage .= " </tr>";
- }
- $alertMessage .= " </tbody>";
- $alertMessage .= "</table>";
- $alertMessage .= "<br /><br />";
- } // End if changed files
- // Only do this if added files
- if(count($files_added) >= 1) {
- $alertMessage .= "<strong>".__("Files Added:", "wordpress-file-monitor-plus")."</strong>";
- $alertMessage .= "<table class='widefat' width='100%' border='1' cellspacing='0' cellpadding='2'>";
- $alertMessage .= " <thead>";
- $alertMessage .= " <tr>";
- $alertMessage .= " <th width='100%'>".__("File", "wordpress-file-monitor-plus")."</th>";
- if($this->settings['file_check_use_size'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("New Filesize", "wordpress-file-monitor-plus")."</th>";
- }
- if($this->settings['file_check_use_modified'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("New Modified", "wordpress-file-monitor-plus")."</th>";
- }
- if($this->settings['file_check_use_md5'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("New Hash", "wordpress-file-monitor-plus")."</th>";
- }
- $alertMessage .= " </tr>";
- $alertMessage .= " </thead>";
- $alertMessage .= " <tbody>";
- foreach($files_added as $key => $data) {
- $alertMessage .= " <tr>";
- $alertMessage .= " <td>".$key."</td>";
- if($this->settings['file_check_use_size'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".$this->formatRawSize($this->newScanData[$key]["size"])."</td>";
- }
- if($this->settings['file_check_use_modified'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->newScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
- }
- if($this->settings['file_check_use_md5'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".$this->newScanData[$key]["md5"]."</td>";
- }
- $alertMessage .= " </tr>";
- }
- $alertMessage .= " </tbody>";
- $alertMessage .= "</table>";
- $alertMessage .= "<br /><br />";
- } // End if added files
- // Only do this if removed files
- if(count($files_removed) >= 1) {
- $alertMessage .= "<strong>".__("Files Removed:", "wordpress-file-monitor-plus")."</strong>";
- $alertMessage .= "<table class='widefat' width='100%' border='1' cellspacing='0' cellpadding='2'>";
- $alertMessage .= " <thead>";
- $alertMessage .= " <tr>";
- $alertMessage .= " <th width='100%'>".__("File", "wordpress-file-monitor-plus")."</th>";
- if($this->settings['file_check_use_size'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("Old Filesize", "wordpress-file-monitor-plus")."</th>";
- }
- if($this->settings['file_check_use_modified'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("Old Modified", "wordpress-file-monitor-plus")."</th>";
- }
- if($this->settings['file_check_use_md5'] == 1) {
- $alertMessage .= " <th nowrap='nowrap'>".__("Old Hash", "wordpress-file-monitor-plus")."</th>";
- }
- $alertMessage .= " </tr>";
- $alertMessage .= " </thead>";
- $alertMessage .= " <tbody>";
- foreach($files_removed as $key => $data) {
- $alertMessage .= " <tr>";
- $alertMessage .= " <td>".$key."</td>";
- if($this->settings['file_check_use_size'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".$this->formatRawSize($this->oldScanData[$key]["size"])."</td>";
- }
- if($this->settings['file_check_use_modified'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->oldScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
- }
- if($this->settings['file_check_use_md5'] == 1) {
- $alertMessage .= " <td nowrap='nowrap'>".$this->oldScanData[$key]["md5"]."</td>";
- }
- $alertMessage .= " </tr>";
- }
- $alertMessage .= " </tbody>";
- $alertMessage .= "</table>";
- $alertMessage .= "<br /><br />";
- } // End if removed files
- return $alertMessage;
- }// End format_alert function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement