当前位置: 首页>>代码示例>>PHP>>正文


PHP wfUtils::reverseLookup方法代码示例

本文整理汇总了PHP中wfUtils::reverseLookup方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::reverseLookup方法的具体用法?PHP wfUtils::reverseLookup怎么用?PHP wfUtils::reverseLookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wfUtils的用法示例。


在下文中一共展示了wfUtils::reverseLookup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: verifyCrawlerPTR

 public static function verifyCrawlerPTR($hostPattern, $IP)
 {
     global $wpdb;
     $table = $wpdb->base_prefix . 'wfCrawlers';
     $db = new wfDB();
     $IPn = wfUtils::inet_aton($IP);
     $status = $db->querySingle("select status from {$table} where IP=%s and patternSig=UNHEX(MD5('%s')) and lastUpdate > unix_timestamp() - %d", $IPn, $hostPattern, WORDFENCE_CRAWLER_VERIFY_CACHE_TIME);
     if ($status) {
         if ($status == 'verified') {
             return true;
         } else {
             return false;
         }
     }
     $wfLog = new wfLog(wfConfig::get('apiKey'), wfUtils::getWPVersion());
     $host = wfUtils::reverseLookup($IP);
     if (!$host) {
         $db->queryWrite("insert into {$table} (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'noPTR', '', 'noPTR', '');
         return false;
     }
     if (preg_match($hostPattern, $host)) {
         $resultIPs = gethostbynamel($host);
         $addrsMatch = false;
         foreach ($resultIPs as $resultIP) {
             if ($resultIP == $IP) {
                 $addrsMatch = true;
                 break;
             }
         }
         if ($addrsMatch) {
             $db->queryWrite("insert into {$table} (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'verified', $host, 'verified', $host);
             return true;
         } else {
             $db->queryWrite("insert into {$table} (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'fwdFail', $host, 'fwdFail', $host);
             return false;
         }
     } else {
         $db->queryWrite("insert into {$table} (IP, patternSig, status, lastUpdate, PTR) values (%s, UNHEX(MD5('%s')), '%s', unix_timestamp(), '%s') ON DUPLICATE KEY UPDATE status='%s', lastUpdate=unix_timestamp(), PTR='%s'", $IPn, $hostPattern, 'badPTR', $host, 'badPTR', $host);
         return false;
     }
 }
开发者ID:HandsomeDogStudio,项目名称:peanutbutterplan,代码行数:41,代码来源:wfCrawl.php

示例2: reverse_lookup

 function reverse_lookup()
 {
     $ips = explode(',', $_POST['ips']);
     $res = array();
     foreach ($ips as $ip) {
         $res[$ip] = wfUtils::reverseLookup($ip);
     }
     return array('ok' => 1, 'ips' => $res);
 }
开发者ID:jexmex,项目名称:mainwp-child,代码行数:9,代码来源:class-mainwp-child-wordfence.php

示例3: 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);
 }
开发者ID:ashenkar,项目名称:sanga,代码行数:60,代码来源:wordfenceClass.php

示例4: firewallBadIPs

 public function firewallBadIPs()
 {
     $IP = wfUtils::getIP();
     if ($this->isWhitelisted($IP)) {
         return;
     }
     $IPnum = wfUtils::inet_pton($IP);
     $hostname = null;
     //New range and UA pattern blocking:
     $r1 = $this->getDB()->querySelect("select id, blockType, blockString from " . $this->ipRangesTable);
     foreach ($r1 as $blockRec) {
         if ($blockRec['blockType'] == 'IU') {
             $ipRangeBlocked = false;
             $uaPatternBlocked = false;
             $refBlocked = false;
             $bDat = explode('|', $blockRec['blockString']);
             $ipRange = $bDat[0];
             $uaPattern = $bDat[1];
             $refPattern = isset($bDat[2]) ? $bDat[2] : '';
             if ($ipRange) {
                 list($start_range, $end_range) = explode('-', $ipRange);
                 if (preg_match('/[\\.:]/', $start_range)) {
                     $start_range = wfUtils::inet_pton($start_range);
                     $end_range = wfUtils::inet_pton($end_range);
                 } else {
                     $start_range = wfUtils::inet_pton(long2ip($start_range));
                     $end_range = wfUtils::inet_pton(long2ip($end_range));
                 }
                 if (strcmp($IPnum, $start_range) >= 0 && strcmp($IPnum, $end_range) <= 0) {
                     $ipRangeBlocked = true;
                 }
             }
             if (!empty($bDat[3])) {
                 $ipRange = true;
                 /* We reuse the ipRangeBlocked variable */
                 if ($hostname === null) {
                     $hostname = wfUtils::reverseLookup($IP);
                 }
                 if (preg_match(wfUtils::patternToRegex($bDat[3]), $hostname)) {
                     $ipRangeBlocked = true;
                 }
             }
             if ($uaPattern) {
                 if (wfUtils::isUABlocked($uaPattern)) {
                     $uaPatternBlocked = true;
                 }
             }
             if ($refPattern) {
                 if (wfUtils::isRefererBlocked($refPattern)) {
                     $refBlocked = true;
                 }
             }
             $doBlock = false;
             if ($uaPattern && $ipRange && $refPattern) {
                 if ($uaPatternBlocked && $ipRangeBlocked && $refBlocked) {
                     $doBlock = true;
                 }
             }
             if ($uaPattern && $ipRange) {
                 if ($uaPatternBlocked && $ipRangeBlocked) {
                     $doBlock = true;
                 }
             }
             if ($uaPattern && $refPattern) {
                 if ($uaPatternBlocked && $refBlocked) {
                     $doBlock = true;
                 }
             }
             if ($ipRange && $refPattern) {
                 if ($ipRangeBlocked && $refBlocked) {
                     $doBlock = true;
                 }
             } else {
                 if ($uaPattern) {
                     if ($uaPatternBlocked) {
                         $doBlock = true;
                     }
                 } else {
                     if ($ipRange) {
                         if ($ipRangeBlocked) {
                             $doBlock = true;
                         }
                     } else {
                         if ($refPattern) {
                             if ($refBlocked) {
                                 $doBlock = true;
                             }
                         }
                     }
                 }
             }
             if ($doBlock) {
                 $this->getDB()->queryWrite("update " . $this->ipRangesTable . " set totalBlocked = totalBlocked + 1, lastBlocked = unix_timestamp() where id=%d", $blockRec['id']);
                 wfActivityReport::logBlockedIP($IP);
                 $this->currentRequest->actionDescription = 'UA/Referrer/IP Range not allowed';
                 $this->do503(3600, "Advanced blocking in effect.");
             }
         }
     }
     //End range/UA blocking
//.........这里部分代码省略.........
开发者ID:ashenkar,项目名称:sanga,代码行数:101,代码来源:wfLog.php

示例5: firewallBadIPs

 public function firewallBadIPs()
 {
     $IP = wfUtils::getIP();
     if ($this->isWhitelisted($IP)) {
         return;
     }
     $IPnum = wfUtils::inet_pton($IP);
     $hostname = null;
     //New range and UA pattern blocking:
     $r1 = $this->getDB()->querySelect("select id, blockType, blockString from " . $this->ipRangesTable);
     foreach ($r1 as $blockRec) {
         if ($blockRec['blockType'] == 'IU') {
             $ipRangeBlocked = false;
             $uaPatternBlocked = false;
             $refBlocked = false;
             $bDat = explode('|', $blockRec['blockString']);
             $ipRange = $bDat[0];
             $uaPattern = $bDat[1];
             $refPattern = isset($bDat[2]) ? $bDat[2] : '';
             if ($ipRange) {
                 list($start_range, $end_range) = explode('-', $ipRange);
                 if (preg_match('/[\\.:]/', $start_range)) {
                     $start_range = wfUtils::inet_pton($start_range);
                     $end_range = wfUtils::inet_pton($end_range);
                 } else {
                     $start_range = wfUtils::inet_pton(long2ip($start_range));
                     $end_range = wfUtils::inet_pton(long2ip($end_range));
                 }
                 if (strcmp($IPnum, $start_range) >= 0 && strcmp($IPnum, $end_range) <= 0) {
                     $ipRangeBlocked = true;
                 }
             }
             if (!empty($bDat[3])) {
                 $ipRange = true;
                 /* We reuse the ipRangeBlocked variable */
                 if ($hostname === null) {
                     $hostname = wfUtils::reverseLookup($IP);
                 }
                 if (preg_match(wfUtils::patternToRegex($bDat[3]), $hostname)) {
                     $ipRangeBlocked = true;
                 }
             }
             if ($uaPattern) {
                 if (wfUtils::isUABlocked($uaPattern)) {
                     $uaPatternBlocked = true;
                 }
             }
             if ($refPattern) {
                 if (wfUtils::isRefererBlocked($refPattern)) {
                     $refBlocked = true;
                 }
             }
             $doBlock = false;
             if ($uaPattern && $ipRange && $refPattern) {
                 if ($uaPatternBlocked && $ipRangeBlocked && $refBlocked) {
                     $doBlock = true;
                 }
             }
             if ($uaPattern && $ipRange) {
                 if ($uaPatternBlocked && $ipRangeBlocked) {
                     $doBlock = true;
                 }
             }
             if ($uaPattern && $refPattern) {
                 if ($uaPatternBlocked && $refBlocked) {
                     $doBlock = true;
                 }
             }
             if ($ipRange && $refPattern) {
                 if ($ipRangeBlocked && $refBlocked) {
                     $doBlock = true;
                 }
             } else {
                 if ($uaPattern) {
                     if ($uaPatternBlocked) {
                         $doBlock = true;
                     }
                 } else {
                     if ($ipRange) {
                         if ($ipRangeBlocked) {
                             $doBlock = true;
                         }
                     } else {
                         if ($refPattern) {
                             if ($refBlocked) {
                                 $doBlock = true;
                             }
                         }
                     }
                 }
             }
             if ($doBlock) {
                 $this->getDB()->queryWrite("update " . $this->ipRangesTable . " set totalBlocked = totalBlocked + 1, lastBlocked = unix_timestamp() where id=%d", $blockRec['id']);
                 wfActivityReport::logBlockedIP($IP);
                 $this->currentRequest->actionDescription = 'UA/Referrer/IP Range not allowed';
                 $this->do503(3600, "Advanced blocking in effect.");
             }
         }
     }
     //End range/UA blocking
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:wfLog.php

示例6: 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);
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:44,代码来源:wordfenceClass.php

示例7: 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);
 }
开发者ID:Alpha7Sg,项目名称:wordpress-custom,代码行数:27,代码来源:wordfenceClass.php


注:本文中的wfUtils::reverseLookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。