Esempio n. 1
0
 public function emailNewIssues()
 {
     $level = wfConfig::getAlertLevel();
     $emails = wfConfig::getAlertEmails();
     $shortSiteURL = preg_replace('/^https?:\\/\\//i', '', site_url());
     $subject = "[Wordfence Alert] Problems found on {$shortSiteURL}";
     if (sizeof($emails) < 1) {
         return;
     }
     if ($level < 1) {
         return;
     }
     if ($level == 2 && $this->totalCriticalIssues < 1 && $this->totalWarningIssues < 1) {
         return;
     }
     if ($level == 1 && $this->totalCriticalIssues < 1) {
         return;
     }
     $emailedIssues = wfConfig::get_ser('emailedIssuesList', array());
     if (!is_array($emailedIssues)) {
         $emailedIssues = array();
     }
     $finalIssues = array();
     foreach ($this->newIssues as $newIssue) {
         $alreadyEmailed = false;
         foreach ($emailedIssues as $emailedIssue) {
             if ($newIssue['ignoreP'] == $emailedIssue['ignoreP'] || $newIssue['ignoreC'] == $emailedIssue['ignoreC']) {
                 $alreadyEmailed = true;
                 break;
             }
         }
         if (!$alreadyEmailed) {
             $finalIssues[] = $newIssue;
         }
     }
     if (sizeof($finalIssues) < 1) {
         return;
     }
     $totalWarningIssues = 0;
     $totalCriticalIssues = 0;
     foreach ($finalIssues as $i) {
         $emailedIssues[] = array('ignoreC' => $i['ignoreC'], 'ignoreP' => $i['ignoreP']);
         if ($i['severity'] == 1) {
             $totalCriticalIssues++;
         } else {
             if ($i['severity'] == 2) {
                 $totalWarningIssues++;
             }
         }
     }
     wfConfig::set_ser('emailedIssuesList', $emailedIssues);
     if ($level == 2 && $totalCriticalIssues < 1 && $totalWarningIssues < 1) {
         return;
     }
     if ($level == 1 && $totalCriticalIssues < 1) {
         return;
     }
     $content = wfUtils::tmpl('email_newIssues.php', array('isPaid' => wfConfig::get('isPaid'), 'issues' => $finalIssues, 'totalCriticalIssues' => $totalCriticalIssues, 'totalWarningIssues' => $totalWarningIssues, 'level' => $level));
     wp_mail(implode(',', $emails), $subject, $content, 'Content-type: text/html');
 }
Esempio n. 2
0
 public function emailNewIssues()
 {
     $level = wfConfig::getAlertLevel();
     $emails = wfConfig::getAlertEmails();
     $subject = "[Wordfence Alert] Problems found on " . get_bloginfo('name', 'raw');
     if (sizeof($emails) < 1) {
         return;
     }
     if ($level < 1) {
         return;
     }
     if ($level == 2 && $this->totalCriticalIssues < 1 && $this->totalWarningIssues < 1) {
         return;
     }
     if ($level == 1 && $this->totalCriticalIssues < 1) {
         return;
     }
     $emailedIssues = wfConfig::get_ser('emailedIssuesList', array());
     if (!is_array($emailedIssues)) {
         $emailedIssues = array();
     }
     $finalIssues = array();
     foreach ($this->newIssues as $newIssue) {
         $alreadyEmailed = false;
         foreach ($emailedIssues as $emailedIssue) {
             if ($newIssue['ignoreP'] == $emailedIssue['ignoreP'] || $newIssue['ignoreC'] == $emailedIssue['ignoreC']) {
                 $alreadyEmailed = true;
                 break;
             }
         }
         if (!$alreadyEmailed) {
             $finalIssues[] = $newIssue;
         }
     }
     if (sizeof($finalIssues) < 1) {
         return;
     }
     $totalWarningIssues = 0;
     $totalCriticalIssues = 0;
     foreach ($finalIssues as $i) {
         $emailedIssues[] = array('ignoreC' => $i['ignoreC'], 'ignoreP' => $i['ignoreP']);
         if ($i['severity'] == 1) {
             $totalCriticalIssues++;
         } else {
             if ($i['severity'] == 2) {
                 $totalWarningIssues++;
             }
         }
     }
     wfConfig::set_ser('emailedIssuesList', $emailedIssues);
     if ($level == 2 && $totalCriticalIssues < 1 && $totalWarningIssues < 1) {
         return;
     }
     if ($level == 1 && $totalCriticalIssues < 1) {
         return;
     }
     $content = wfUtils::tmpl('email_newIssues.php', array('issues' => $finalIssues, 'totalCriticalIssues' => $totalCriticalIssues, 'totalWarningIssues' => $totalWarningIssues, 'level' => $level));
     wp_mail(implode(',', $emails), $subject, $content);
 }
Esempio n. 3
0
 /**
  * Send out the report and reschedule the next report's cron job.
  */
 public static function executeCronJob()
 {
     $report = new self();
     $report->sendReportViaEmail(wfConfig::getAlertEmails());
     self::scheduleCronJob();
 }
			                        target="_blank" class="wfhelp"></a></h2>

			<p style="width: 600px;">
				Wordfence works great out of the box for most websites. Simply install Wordfence and your site and
				content is protected. For finer granularity of control, we have provided advanced options.
			</p>
		</div>
		<div id="wfConfigAdvanced">
			<table class="wfConfigForm">
				<tr>
					<td colspan="2"><h3 class="wfConfigHeading">Alerts<a
								href="http://docs.wordfence.com/en/Wordfence_options#Alerts" target="_blank"
								class="wfhelp"></a></h3></td>
				</tr>
				<?php 
$emails = wfConfig::getAlertEmails();
if (sizeof($emails) < 1) {
    echo "<tr><th colspan=\"2\" style=\"color: #F00;\">You have not configured an email to receive alerts yet. Set this up under \"Basic Options\" above.</th></tr>\n";
}
?>
				<tr>
					<th>Email me when Wordfence is automatically updated</th>
					<td><input type="checkbox" id="alertOn_update" class="wfConfigElem" name="alertOn_update"
					           value="1" <?php 
$w->cb('alertOn_update');
?>
/>&nbsp;If you have automatic updates
						enabled (see above), you'll get an email when an update occurs.
					</td>
				</tr>
				<tr>
Esempio n. 5
0
 public static function alert($subject, $alertMsg, $IP)
 {
     wfConfig::inc('totalAlertsSent');
     $emails = wfConfig::getAlertEmails();
     if (sizeof($emails) < 1) {
         return;
     }
     $IPMsg = "";
     if ($IP) {
         $IPMsg = "User IP: {$IP}\n";
         $reverse = wfUtils::reverseLookup($IP);
         if ($reverse) {
             $IPMsg .= "User hostname: " . $reverse . "\n";
         }
         $userLoc = wfUtils::getIPGeo($IP);
         if ($userLoc) {
             $IPMsg .= "User location: ";
             if ($userLoc['city']) {
                 $IPMsg .= $userLoc['city'] . ', ';
             }
             $IPMsg .= $userLoc['countryName'] . "\n";
         }
     }
     $content = wfUtils::tmpl('email_genericAlert.php', array('isPaid' => wfConfig::get('isPaid'), 'subject' => $subject, 'blogName' => get_bloginfo('name', 'raw'), 'adminURL' => get_admin_url(), 'alertMsg' => $alertMsg, 'IPMsg' => $IPMsg, 'date' => wfUtils::localHumanDate(), 'myHomeURL' => self::getMyHomeURL(), 'myOptionsURL' => self::getMyOptionsURL()));
     $shortSiteURL = preg_replace('/^https?:\\/\\//i', '', site_url());
     $subject = "[Wordfence Alert] {$shortSiteURL} " . $subject;
     $sendMax = wfConfig::get('alert_maxHourly', 0);
     if ($sendMax > 0) {
         $sendArr = wfConfig::get_ser('alertFreqTrack', array());
         if (!is_array($sendArr)) {
             $sendArr = array();
         }
         $minuteTime = floor(time() / 60);
         $totalSent = 0;
         for ($i = $minuteTime; $i > $minuteTime - 60; $i--) {
             $totalSent += isset($sendArr[$i]) ? $sendArr[$i] : 0;
         }
         if ($totalSent >= $sendMax) {
             return;
         }
         $sendArr[$minuteTime] = isset($sendArr[$minuteTime]) ? $sendArr[$minuteTime] + 1 : 1;
         wfConfig::set_ser('alertFreqTrack', $sendArr);
     }
     //Prevent duplicate emails within 1 hour:
     $hash = md5(implode(',', $emails) . ':' . $subject . ':' . $alertMsg . ':' . $IP);
     //Hex
     $lastHash = wfConfig::get('lastEmailHash', false);
     if ($lastHash) {
         $lastHashDat = explode(':', $lastHash);
         //[time, hash]
         if (time() - $lastHashDat[0] < 3600) {
             if ($lastHashDat[1] == $hash) {
                 return;
                 //Don't send because this email is identical to the previous email which was sent within the last hour.
             }
         }
     }
     wfConfig::set('lastEmailHash', time() . ':' . $hash);
     wp_mail(implode(',', $emails), $subject, $content);
 }
Esempio n. 6
0
 public function emailNewIssues()
 {
     $level = wfConfig::getAlertLevel();
     $emails = wfConfig::getAlertEmails();
     $shortSiteURL = preg_replace('/^https?:\\/\\//i', '', site_url());
     $subject = "[Wordfence Alert] Problems found on {$shortSiteURL}";
     if (sizeof($emails) < 1) {
         return;
     }
     if ($level < 1) {
         return;
     }
     if ($level == 2 && $this->totalCriticalIssues < 1 && $this->totalWarningIssues < 1) {
         return;
     }
     if ($level == 1 && $this->totalCriticalIssues < 1) {
         return;
     }
     $emailedIssues = wfConfig::get_ser('emailedIssuesList', array());
     if (!is_array($emailedIssues)) {
         $emailedIssues = array();
     }
     $finalIssues = array();
     foreach ($this->newIssues as $newIssue) {
         $alreadyEmailed = false;
         foreach ($emailedIssues as $emailedIssue) {
             if ($newIssue['ignoreP'] == $emailedIssue['ignoreP'] || $newIssue['ignoreC'] == $emailedIssue['ignoreC']) {
                 $alreadyEmailed = true;
                 break;
             }
         }
         if (!$alreadyEmailed) {
             $finalIssues[] = $newIssue;
         }
     }
     if (sizeof($finalIssues) < 1) {
         return;
     }
     $totalWarningIssues = 0;
     $totalCriticalIssues = 0;
     foreach ($finalIssues as $i) {
         $emailedIssues[] = array('ignoreC' => $i['ignoreC'], 'ignoreP' => $i['ignoreP']);
         if ($i['severity'] == 1) {
             $totalCriticalIssues++;
         } else {
             if ($i['severity'] == 2) {
                 $totalWarningIssues++;
             }
         }
     }
     wfConfig::set_ser('emailedIssuesList', $emailedIssues);
     if ($level == 2 && $totalCriticalIssues < 1 && $totalWarningIssues < 1) {
         return;
     }
     if ($level == 1 && $totalCriticalIssues < 1) {
         return;
     }
     $content = wfUtils::tmpl('email_newIssues.php', array('isPaid' => wfConfig::get('isPaid'), 'issues' => $finalIssues, 'totalCriticalIssues' => $totalCriticalIssues, 'totalWarningIssues' => $totalWarningIssues, 'level' => $level));
     require_once ABSPATH . WPINC . '/class-phpmailer.php';
     require_once ABSPATH . WPINC . '/class-smtp.php';
     $mail = new PHPMailer();
     // Get the site domain and get rid of www.
     $from_email = 'wordpress@' . preg_replace('/^(https?:\\/\\/(www.)?)(.+?)(\\/)?$/', '$3', site_url());
     $mail->From = apply_filters('wp_mail_from', $from_email);
     $mail->FromName = apply_filters('wp_mail_from_name', 'Wordfence');
     foreach ($emails as $email) {
         try {
             $mail->addAddress($email);
         } catch (phpmailerException $e) {
         }
     }
     $mail->Subject = $subject;
     $mail->msgHTML($content);
     try {
         $mail->send();
     } catch (phpmailerException $e) {
         // use wp_mail if there's a problem (which uses PHPMailer anyways :P)
         wp_mail(implode(',', $emails), $subject, strip_tags($content));
     }
 }
Esempio n. 7
0
 public static function alert($subject, $alertMsg, $IP)
 {
     $emails = wfConfig::getAlertEmails();
     if (sizeof($emails) < 1) {
         return;
     }
     $IPMsg = "";
     if ($IP) {
         $IPMsg = "User IP: {$IP}\n";
         $reverse = wfUtils::reverseLookup($IP);
         if ($reverse) {
             $IPMsg .= "User hostname: " . $reverse . "\n";
         }
         $userLoc = wfUtils::getIPGeo($IP);
         if ($userLoc) {
             $IPMsg .= "User location: ";
             if ($userLoc['city']) {
                 $IPMsg .= $userLoc['city'] . ', ';
             }
             $IPMsg .= $userLoc['countryName'] . "\n";
         }
     }
     $content = wfUtils::tmpl('email_genericAlert.php', array('isPaid' => wfConfig::get('isPaid'), 'subject' => $subject, 'blogName' => get_bloginfo('name', 'raw'), 'adminURL' => get_admin_url(), 'alertMsg' => $alertMsg, 'IPMsg' => $IPMsg, 'date' => wfUtils::localHumanDate(), 'myHomeURL' => self::getMyHomeURL(), 'myOptionsURL' => self::getMyOptionsURL()));
     $shortSiteURL = preg_replace('/^https?:\\/\\//i', '', site_url());
     $subject = "[Wordfence Alert] {$shortSiteURL} " . $subject;
     $sendMax = wfConfig::get('alert_maxHourly', 0);
     if ($sendMax > 0) {
         $sendArr = wfConfig::get_ser('alertFreqTrack', array());
         if (!is_array($sendArr)) {
             $sendArr = array();
         }
         $minuteTime = floor(time() / 60);
         $totalSent = 0;
         for ($i = $minuteTime; $i > $minuteTime - 60; $i--) {
             $totalSent += isset($sendArr[$i]) ? $sendArr[$i] : 0;
         }
         if ($totalSent >= $sendMax) {
             return;
         }
         $sendArr[$minuteTime] = isset($sendArr[$minuteTime]) ? $sendArr[$minuteTime] + 1 : 1;
         wfConfig::set_ser('alertFreqTrack', $sendArr);
     }
     wp_mail(implode(',', $emails), $subject, $content);
 }
 public static function alert($subject, $alertMsg, $IP)
 {
     $IPMsg = "";
     if ($IP) {
         $IPMsg = "User IP: {$IP}\n";
         $reverse = wfUtils::reverseLookup($IP);
         if ($reverse) {
             $IPMsg .= "User hostname: " . $reverse . "\n";
         }
         $userLoc = wfUtils::getIPGeo($IP);
         if ($userLoc) {
             $IPMsg .= "User location: ";
             if ($userLoc['city']) {
                 $IPMsg .= $userLoc['city'] . ', ';
             }
             $IPMsg .= $userLoc['countryName'] . "\n";
         }
     }
     $content = wfUtils::tmpl('email_genericAlert.php', array('subject' => $subject, 'blogName' => get_bloginfo('name', 'raw'), 'alertMsg' => $alertMsg, 'IPMsg' => $IPMsg, 'date' => wfUtils::localHumanDate(), 'myHomeURL' => self::getMyHomeURL(), 'myOptionsURL' => self::getMyOptionsURL()));
     $emails = wfConfig::getAlertEmails();
     if (sizeof($emails) < 1) {
         return;
     }
     $shortSiteURL = preg_replace('/^https?:\\/\\//i', '', site_url());
     $subject = "[Wordfence Alert] {$shortSiteURL} " . $subject;
     wp_mail(implode(',', $emails), $subject, $content);
 }