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); }
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); }
<?php if (!$isPaid) { ?> NOTE: Upgrading to the paid version of Wordfence gives you two factor authentication (sign-in via cellphone) and country blocking which are both effective methods to block attacks. You can also schedule when your scans occur with Wordfence Premium. Click here to sign-up for the Premium version of Wordfence now. https://www.wordfence.com/wordfence-signup/ <?php } ?> Alert generated at <?php echo wfUtils::localHumanDate(); ?> <?php if ($totalCriticalIssues > 0) { ?> Critical Problems: <?php foreach ($issues as $i) { if ($i['severity'] == 1) { ?> * <?php echo $i['shortMsg']; ?>
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); }