本文整理汇总了PHP中wfUtils::getIPGeo方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::getIPGeo方法的具体用法?PHP wfUtils::getIPGeo怎么用?PHP wfUtils::getIPGeo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfUtils
的用法示例。
在下文中一共展示了wfUtils::getIPGeo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: alert
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);
}
示例2: alert
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);
}
示例3: rs_wpss_wf_geoiploc
function rs_wpss_wf_geoiploc($ip = NULL, $disp = FALSE)
{
/***
* If WordFence installed, get GEO IP Location data
* Added 1.9.5.2
***/
global $wpss_geoiploc_data, $wpss_geolocation;
if (class_exists('wfUtils') && rs_wpss_is_plugin_active('wordfence/wordfence.php')) {
/* $start = microtime(TRUE); */
if (empty($ip)) {
$ip = rs_wpss_get_ip_addr();
}
if (empty($_SESSION['wpss_geoiploc_data_' . WPSS_HASH]) && empty($wpss_geoiploc_data) || (empty($_SESSION['wpss_geolocation_' . WPSS_HASH]) && empty($wpss_geolocation) || empty($_SESSION['wpss_geoiploc_ip_' . WPSS_HASH]) || $_SESSION['wpss_geoiploc_ip_' . WPSS_HASH] !== $ip)) {
$wpss_geoiploc_data = wfUtils::getIPGeo($ip);
/***
* $wpss_geoiploc_data = array( 'IP' => $ip, 'city' => $city, 'region' => $region, 'countryName' => $countryName, 'countryCode' => $countryCode, 'lat' => $lat, 'lon' => $long );
***/
if (empty($wpss_geoiploc_data) || !is_array($wpss_geoiploc_data)) {
return '';
}
extract($wpss_geoiploc_data);
$city_region = !empty($city) && !empty($region) ? ' - ' . $city . ', ' . $region : '';
$_SESSION['wpss_geoiploc_ip_' . WPSS_HASH] = $ip;
if (FALSE === $disp) {
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
}
}
if (TRUE === $disp) {
if (!empty($_SESSION['wpss_geolocation_' . WPSS_HASH])) {
$wpss_geolocation = $_SESSION['wpss_geolocation_' . WPSS_HASH];
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geolocation;
} elseif (!empty($wpss_geolocation)) {
$_SESSION['wpss_geolocation_' . WPSS_HASH] = $wpss_geolocation;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geolocation;
} else {
$wpss_geolocation = $countryCode . ' - ' . $countryName . $city_region;
$_SESSION['wpss_geolocation_' . WPSS_HASH] = $wpss_geolocation;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geolocation;
}
} else {
if (!empty($_SESSION['wpss_geoiploc_data_' . WPSS_HASH])) {
$wpss_geoiploc_data = $_SESSION['wpss_geoiploc_data_' . WPSS_HASH];
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
} elseif (!empty($wpss_geoiploc_data)) {
$_SESSION['wpss_geoiploc_data_' . WPSS_HASH] = $wpss_geoiploc_data;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
} else {
$wpss_geoiploc_data = $countryCode . ' - ' . $countryName . $city_region;
$_SESSION['wpss_geoiploc_data_' . WPSS_HASH] = $wpss_geoiploc_data;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
}
}
}
return '';
}
示例4: alert
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);
}