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


PHP wfUtils::inet_aton方法代码示例

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


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

 public static function wfsnIsBlocked($IP, $type)
 {
     try {
         $result = wp_remote_get(WORDFENCE_HACKATTEMPT_URL . 'hackAttempt/?k=' . rawurlencode(wfConfig::get('apiKey')) . '&IP=' . rawurlencode(filter_var($IP, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? wfUtils::inet_aton($IP) : wfUtils::inet_pton($IP)) . '&t=' . rawurlencode($type), array('timeout' => 3, 'user-agent' => "Wordfence.com UA " . (defined('WORDFENCE_VERSION') ? WORDFENCE_VERSION : '[Unknown version]')));
         if (is_wp_error($result)) {
             return false;
         }
         if (preg_match('/BLOCKED:(\\d+)/', $result['body'], $matches) && !self::getLog()->isWhitelisted($IP)) {
             return $matches[1];
         }
         return false;
     } catch (Exception $err) {
         return false;
     }
 }
开发者ID:ashenkar,项目名称:sanga,代码行数:15,代码来源:wordfenceClass.php

示例3: reverseLookup

 public static function reverseLookup($IP)
 {
     $db = new wfDB();
     global $wpdb;
     $reverseTable = $wpdb->base_prefix . 'wfReverseCache';
     $IPn = wfUtils::inet_aton($IP);
     $host = $db->querySingle("select host from " . $reverseTable . " where IP=%s and unix_timestamp() - lastUpdate < %d", $IPn, WORDFENCE_REVERSE_LOOKUP_CACHE_TIME);
     if (!$host) {
         $ptr = implode(".", array_reverse(explode(".", $IP))) . ".in-addr.arpa";
         $host = @dns_get_record($ptr, DNS_PTR);
         if ($host == null) {
             $host = 'NONE';
         } else {
             $host = $host[0]['target'];
         }
         $db->queryWrite("insert into " . $reverseTable . " (IP, host, lastUpdate) values (%s, '%s', unix_timestamp()) ON DUPLICATE KEY UPDATE host='%s', lastUpdate=unix_timestamp()", $IPn, $host, $host);
     }
     if ($host == 'NONE') {
         return '';
     } else {
         return $host;
     }
 }
开发者ID:mariuskarma,项目名称:wp,代码行数:23,代码来源:wfUtils.php

示例4: wfsnIsBlocked

 public static function wfsnIsBlocked($IP, $type)
 {
     $wfdb = new wfDB();
     global $wpdb;
     $p = $wpdb->base_prefix;
     $cachedRecord = $wfdb->querySingleRec("SELECT id, body FROM {$p}wfSNIPCache WHERE IP = '%s' AND expiration > NOW()", $IP);
     if (isset($cachedRecord)) {
         $wfdb->queryWriteIgnoreError("UPDATE {$p}wfSNIPCache SET count = count + 1 WHERE id = %d", $cachedRecord['id']);
         if (preg_match('/BLOCKED:(\\d+)/', $cachedRecord['body'], $matches) && !self::getLog()->isWhitelisted($IP)) {
             return $matches[1];
         }
         return false;
     }
     try {
         $result = wp_remote_get(WORDFENCE_HACKATTEMPT_URL . 'hackAttempt/?k=' . rawurlencode(wfConfig::get('apiKey')) . '&IP=' . rawurlencode(filter_var($IP, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? wfUtils::inet_aton($IP) : wfUtils::inet_pton($IP)) . '&t=' . rawurlencode($type), array('timeout' => 3, 'user-agent' => "Wordfence.com UA " . (defined('WORDFENCE_VERSION') ? WORDFENCE_VERSION : '[Unknown version]')));
         if (is_wp_error($result)) {
             return false;
         }
         $wfdb->queryWriteIgnoreError("INSERT INTO {$p}wfSNIPCache (IP, expiration, body) VALUES ('%s', DATE_ADD(NOW(), INTERVAL %d SECOND), '%s')", $IP, 30, $result['body']);
         self::wfsnScheduleBatchReportFailedAttempts();
         if (preg_match('/BLOCKED:(\\d+)/', $result['body'], $matches) && !self::getLog()->isWhitelisted($IP)) {
             return $matches[1];
         }
         return false;
     } catch (Exception $err) {
         return false;
     }
 }
开发者ID:Jerram-Marketing,项目名称:Gummer-Co,代码行数:28,代码来源:wordfenceClass.php

示例5: ajax_blockIPUARange_callback

 public static function ajax_blockIPUARange_callback()
 {
     $ipRange = trim($_POST['ipRange']);
     $uaRange = trim($_POST['uaRange']);
     $reason = trim($_POST['reason']);
     if (preg_match('/\\|+/', $ipRange . $uaRange)) {
         return array('err' => 1, 'errorMsg' => "You are not allowed to include a pipe character \"|\" in your IP range or browser pattern");
     }
     if (!$ipRange && wfUtils::isUABlocked($uaRange)) {
         return array('err' => 1, 'errorMsg' => "The browser pattern you specified will block you from your own website. We have not accepted this pattern to protect you from being blocked.");
     }
     if ($ipRange && !preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\-\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $ipRange)) {
         return array('err' => 1, 'errorMsg' => "The IP range you specified is not valid. Please specify an IP range like the following example: \"1.2.3.4 - 1.2.3.8\" without quotes.");
     }
     if ($ipRange) {
         $ips = explode('-', $ipRange);
         $ip1 = wfUtils::inet_aton($ips[0]);
         $ip2 = wfUtils::inet_aton($ips[1]);
         if ($ip1 >= $ip2) {
             return array('err' => 1, 'errorMsg' => "The first IP address in your range must be less than the second IP address in your range.");
         }
         $clientIP = wfUtils::inet_aton(wfUtils::getIP());
         if ($ip1 <= $clientIP && $ip2 >= $clientIP) {
             return array('err' => 1, 'errorMsg' => "You are trying to block yourself. Your IP address is " . htmlentities(wfUtils::getIP()) . " which falls into the range " . htmlentities($ipRange) . ". This blocking action has been cancelled so that you don't block yourself from your website.");
         }
         $ipRange = $ip1 . '-' . $ip2;
     }
     $range = $ipRange . '|' . $uaRange;
     self::getLog()->blockRange('IU', $range, $reason);
     return array('ok' => 1);
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:31,代码来源:wordfenceClass.php

示例6: takeBlockingAction

 private function takeBlockingAction($configVar, $reason)
 {
     if ($this->googleSafetyCheckOK()) {
         $action = wfConfig::get($configVar . '_action');
         if (!$action) {
             //error_log("Wordfence action missing for configVar: $configVar");
             return;
         }
         $secsToGo = 0;
         if ($action == 'block') {
             $IP = wfUtils::getIP();
             $this->blockIP($IP, $reason);
             $secsToGo = wfConfig::get('blockedTime');
             //Moved the following code AFTER the block to prevent multiple emails.
             if (wfConfig::get('alertOn_block')) {
                 wordfence::alert("Blocking IP {$IP}", "Wordfence has blocked IP address {$IP}.\nThe reason is: \"{$reason}\".", $IP);
             }
             wordfence::status(2, 'info', "Blocking IP {$IP}. {$reason}");
         } else {
             if ($action == 'throttle') {
                 $IP = wfUtils::getIP();
                 $this->getDB()->queryWrite("insert into " . $this->throttleTable . " (IP, startTime, endTime, timesThrottled, lastReason) values (%s, unix_timestamp(), unix_timestamp(), 1, '%s') ON DUPLICATE KEY UPDATE endTime=unix_timestamp(), timesThrottled = timesThrottled + 1, lastReason='%s'", wfUtils::inet_aton($IP), $reason, $reason);
                 wordfence::status(2, 'info', "Throttling IP {$IP}. {$reason}");
                 $secsToGo = 60;
             }
         }
         $this->do503($secsToGo, $reason);
     } else {
         return;
     }
 }
开发者ID:roycocup,项目名称:enclothed,代码行数:31,代码来源:wfLog.php


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