Advertisement
Guest User

Scott Cariss

a guest
Jun 9th, 2011
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.66 KB | None | 0 0
  1.         /**
  2.          * Creates HTML for email and admin alert
  3.          *
  4.          * @param array $files_added Array holding any files that have been added
  5.          * @param array $files_removed Array holding any files that have been removed
  6.          * @param array $changed_files Array holding any files that have been changed
  7.          * @return string $alertMessage return formatted HTML
  8.         */
  9.         protected function format_alert($files_added, $files_removed, $changed_files) {
  10.             $alertMessage  = sprintf(__("Files Changed: %d", "wordpress-file-monitor-plus"), count($changed_files[0]))."<br />";
  11.             $alertMessage .= sprintf(__("Files Added: %d", "wordpress-file-monitor-plus"), count($files_added))."<br />";
  12.             $alertMessage .= sprintf(__("Files Removed: %d", "wordpress-file-monitor-plus"), count($files_removed))."<br />";
  13.             $alertMessage .= "<br />";
  14.  
  15.             if(1 == $this->settings['file_check_use_modified']){
  16.                 $date_format = get_option( 'date_format' );
  17.                 $time_format = get_option( 'time_format' );
  18.                 $gmt_offset = get_option( 'gmt_offset' );
  19.             }
  20.  
  21.             // Only do this if some changed files
  22.             if(count($changed_files[0]) >= 1) {
  23.                 $alertMessage .= "<strong>".__("Files Changed:", "wordpress-file-monitor-plus")."</strong>";
  24.                 $alertMessage .= "<table class='widefat' width='100%' border='1' cellspacing='0' cellpadding='2'>";
  25.                 $alertMessage .= "  <thead>";
  26.                 $alertMessage .= "  <tr>";
  27.                 $alertMessage .= "    <th width='100%'>".__("File", "wordpress-file-monitor-plus")."</th>";
  28.                
  29.                 if($this->settings['file_check_use_size'] == 1) {
  30.                     $alertMessage .= "    <th nowrap='nowrap'>".__("New Filesize", "wordpress-file-monitor-plus")."</th>";
  31.                     $alertMessage .= "    <th nowrap='nowrap'>".__("Old Filesize", "wordpress-file-monitor-plus")."</th>";
  32.                 }
  33.                
  34.                 if($this->settings['file_check_use_modified'] == 1) {
  35.                     $alertMessage .= "    <th nowrap='nowrap'>".__("New Modified", "wordpress-file-monitor-plus")."</th>";
  36.                     $alertMessage .= "    <th nowrap='nowrap'>".__("Old Modified", "wordpress-file-monitor-plus")."</th>";
  37.                 }
  38.                
  39.                 if($this->settings['file_check_use_md5'] == 1) {
  40.                     $alertMessage .= "    <th nowrap='nowrap'>".__("New Hash", "wordpress-file-monitor-plus")."</th>";
  41.                     $alertMessage .= "    <th nowrap='nowrap'>".__("Old Hash", "wordpress-file-monitor-plus")."</th>";
  42.                 }
  43.                
  44.                 $alertMessage .= "  </tr>";
  45.                 $alertMessage .= "  </thead>";
  46.                 $alertMessage .= "  <tbody>";
  47.                
  48.                 foreach($changed_files[0] as $key => $data) {
  49.                     $alertMessage .= "  <tr>";
  50.                     $alertMessage .= "    <td>".$key."</td>";
  51.                    
  52.                     if($this->settings['file_check_use_size'] == 1) {
  53.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->formatRawSize($this->newScanData[$key]["size"])."</td>";
  54.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->formatRawSize($this->oldScanData[$key]["size"])."</td>";
  55.                     }
  56.                    
  57.                     if($this->settings['file_check_use_modified'] == 1) {
  58.                         $alertMessage .= "    <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->newScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
  59.                         $alertMessage .= "    <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->oldScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
  60.                     }
  61.                    
  62.                     if($this->settings['file_check_use_md5'] == 1) {
  63.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->newScanData[$key]["md5"]."</td>";
  64.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->oldScanData[$key]["md5"]."</td>";
  65.                     }
  66.                    
  67.                     $alertMessage .= "  </tr>";
  68.                 }
  69.                
  70.                 $alertMessage .= "  </tbody>";
  71.                 $alertMessage .= "</table>";
  72.                 $alertMessage .= "<br /><br />";
  73.             } // End if changed files
  74.            
  75.             // Only do this if added files
  76.             if(count($files_added) >= 1) {
  77.                
  78.                 $alertMessage .= "<strong>".__("Files Added:", "wordpress-file-monitor-plus")."</strong>";
  79.                 $alertMessage .= "<table class='widefat' width='100%' border='1' cellspacing='0' cellpadding='2'>";
  80.                 $alertMessage .= "  <thead>";
  81.                 $alertMessage .= "  <tr>";
  82.                 $alertMessage .= "    <th width='100%'>".__("File", "wordpress-file-monitor-plus")."</th>";
  83.                
  84.                 if($this->settings['file_check_use_size'] == 1) {
  85.                     $alertMessage .= "    <th nowrap='nowrap'>".__("New Filesize", "wordpress-file-monitor-plus")."</th>";
  86.                 }
  87.                
  88.                 if($this->settings['file_check_use_modified'] == 1) {
  89.                     $alertMessage .= "    <th nowrap='nowrap'>".__("New Modified", "wordpress-file-monitor-plus")."</th>";
  90.                 }
  91.                
  92.                 if($this->settings['file_check_use_md5'] == 1) {
  93.                     $alertMessage .= "    <th nowrap='nowrap'>".__("New Hash", "wordpress-file-monitor-plus")."</th>";
  94.                 }
  95.                
  96.                 $alertMessage .= "  </tr>";
  97.                 $alertMessage .= "  </thead>";
  98.                 $alertMessage .= "  <tbody>";
  99.                
  100.                 foreach($files_added as $key => $data) {
  101.                     $alertMessage .= "  <tr>";
  102.                     $alertMessage .= "    <td>".$key."</td>";
  103.                    
  104.                     if($this->settings['file_check_use_size'] == 1) {
  105.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->formatRawSize($this->newScanData[$key]["size"])."</td>";
  106.                     }
  107.                    
  108.                     if($this->settings['file_check_use_modified'] == 1) {
  109.                         $alertMessage .= "    <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->newScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
  110.                     }
  111.                    
  112.                     if($this->settings['file_check_use_md5'] == 1) {
  113.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->newScanData[$key]["md5"]."</td>";
  114.                     }
  115.                    
  116.                     $alertMessage .= "  </tr>";
  117.                 }
  118.                
  119.                 $alertMessage .= "  </tbody>";
  120.                 $alertMessage .= "</table>";
  121.                 $alertMessage .= "<br /><br />";
  122.             } // End if added files
  123.            
  124.             // Only do this if removed files
  125.             if(count($files_removed) >= 1) {
  126.                 $alertMessage .= "<strong>".__("Files Removed:", "wordpress-file-monitor-plus")."</strong>";
  127.                 $alertMessage .= "<table class='widefat' width='100%' border='1' cellspacing='0' cellpadding='2'>";
  128.                 $alertMessage .= "  <thead>";
  129.                 $alertMessage .= "  <tr>";
  130.                 $alertMessage .= "    <th width='100%'>".__("File", "wordpress-file-monitor-plus")."</th>";
  131.                
  132.                 if($this->settings['file_check_use_size'] == 1) {
  133.                     $alertMessage .= "    <th nowrap='nowrap'>".__("Old Filesize", "wordpress-file-monitor-plus")."</th>";
  134.                 }
  135.                
  136.                 if($this->settings['file_check_use_modified'] == 1) {
  137.                     $alertMessage .= "    <th nowrap='nowrap'>".__("Old Modified", "wordpress-file-monitor-plus")."</th>";
  138.                 }
  139.                
  140.                 if($this->settings['file_check_use_md5'] == 1) {
  141.                     $alertMessage .= "    <th nowrap='nowrap'>".__("Old Hash", "wordpress-file-monitor-plus")."</th>";
  142.                 }
  143.                
  144.                 $alertMessage .= "  </tr>";
  145.                 $alertMessage .= "  </thead>";
  146.                 $alertMessage .= "  <tbody>";
  147.                
  148.                 foreach($files_removed as $key => $data) {
  149.                     $alertMessage .= "  <tr>";
  150.                     $alertMessage .= "    <td>".$key."</td>";
  151.                    
  152.                     if($this->settings['file_check_use_size'] == 1) {
  153.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->formatRawSize($this->oldScanData[$key]["size"])."</td>";
  154.                     }
  155.                    
  156.                     if($this->settings['file_check_use_modified'] == 1) {
  157.                         $alertMessage .= "    <td nowrap='nowrap'>".gmdate($date_format." ".$time_format, ($this->oldScanData[$key]["modified"] + ($gmt_offset * 3600)))."</td>";
  158.                     }
  159.                    
  160.                     if($this->settings['file_check_use_md5'] == 1) {
  161.                         $alertMessage .= "    <td nowrap='nowrap'>".$this->oldScanData[$key]["md5"]."</td>";
  162.                     }
  163.                    
  164.                     $alertMessage .= "  </tr>";
  165.                 }
  166.                
  167.                 $alertMessage .= "  </tbody>";
  168.                 $alertMessage .= "</table>";
  169.                 $alertMessage .= "<br /><br />";
  170.             } // End if removed files
  171.            
  172.             return $alertMessage;
  173.         }// End format_alert function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement