• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP geoip_country_code_by_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中geoip_country_code_by_name函数的典型用法代码示例。如果您正苦于以下问题:PHP geoip_country_code_by_name函数的具体用法?PHP geoip_country_code_by_name怎么用?PHP geoip_country_code_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_geodata

function get_geodata($ip)
{
    require _TRACK_LIB_PATH . "/maxmind/geoipregionvars.php";
    // названия регионов
    if (defined('_PHP5_GEOIP_ENABLED') && _PHP5_GEOIP_ENABLED || function_exists('geoip_record_by_name')) {
        $geoinfo = geoip_record_by_name($ip);
        $ispname = geoip_isp_by_name($ip);
        $cur_city = $geoinfo['city'];
        $cur_region = $geoinfo['region'];
        $cur_country = $geoinfo['country_code'];
    } else {
        require _TRACK_LIB_PATH . "/maxmind/geoip.inc.php";
        require _TRACK_LIB_PATH . "/maxmind/geoipcity.inc.php";
        $gi = geoip_open(_TRACK_STATIC_PATH . "/maxmind/MaxmindCity.dat", GEOIP_STANDARD);
        $record = geoip_record_by_addr($gi, $ip);
        $ispname = geoip_org_by_addr($gi, $ip);
        geoip_close($gi);
        $cur_city = $record->city;
        $cur_region = $record->region;
        $cur_country = $record->country_code;
        // Resolve GeoIP extension conflict
        if (function_exists('geoip_country_code_by_name') && $cur_country == '') {
            $cur_country = geoip_country_code_by_name($ip);
        }
    }
    return array('country' => $cur_country, 'region' => $cur_region, 'state' => $GEOIP_REGION_NAME[$cur_country][$cur_region], 'city' => $cur_city, 'isp' => $ispname);
}
开发者ID:conversionstudio,项目名称:cpatracker,代码行数:27,代码来源:functions.php


示例2: getMyTimezone

 public function getMyTimezone()
 {
     //return @geoip_time_zone_by_country_and_region  ( geoip_country_code_by_name('85.12.204.141'));
     $session = JFactory::getSession();
     $cart = $session->get('cart');
     $item = new stdClass();
     if (isset($cart['my_timezone']) && $cart['my_timezone']) {
         $item->my_timezone = $cart['my_timezone'];
     } else {
         if ($_SERVER['HTTP_HOST'] == 'cloudinterpreter.tst') {
             $item->my_timezone = 'Europe/Moscow';
         } else {
             $item->my_timezone = @geoip_time_zone_by_country_and_region(geoip_country_code_by_name($_SERVER['REMOTE_ADDR']));
         }
     }
     if (isset($cart['my_partner_timezone']) && $cart['my_partner_timezone']) {
         $item->my_partner_timezone = $cart['my_partner_timezone'];
     } else {
         if ($_SERVER['HTTP_HOST'] == 'cloudinterpreter.tst') {
             $item->my_partner_timezone = 'Europe/Moscow';
         } else {
             $item->my_partner_timezone = @geoip_time_zone_by_country_and_region(geoip_country_code_by_name($_SERVER['REMOTE_ADDR']));
         }
     }
     if (!$item->my_timezone) {
         $item->my_timezone = 'Europe/Moscow';
         $item->my_partner_timezone = 'Europe/Moscow';
     }
     return $item;
 }
开发者ID:rogatnev-nikita,项目名称:cloudinterpreter,代码行数:30,代码来源:frontpage.php


示例3: blockCountryView

 public function blockCountryView(Result $result)
 {
     $result->getParam('request');
     $allow = $this->preferences->get('foolfuuka.plugins.geoip_region_lock.allow_view');
     $disallow = $this->preferences->get('foolfuuka.plugins.geoip_region_lock.disallow_view');
     if ($allow || $disallow) {
         $country = strtolower(\geoip_country_code_by_name($request->getClientIp()));
     }
     if ($allow) {
         $allow = explode(',', $allow);
         foreach ($allow as $al) {
             if (strtolower(trim($al)) == $country) {
                 return null;
             }
         }
         $result->set(new Response(_i('Not available in your country.'), 403));
         return;
     }
     if ($disallow) {
         $disallow = explode(',', $disallow);
         foreach ($disallow as $disal) {
             if (strtolower(trim($disal)) == $country) {
                 $result->set(new Response(_i('Not available in your country.'), 403));
                 throw new NotFoundHttpException();
             }
         }
     }
     return null;
 }
开发者ID:procod3R,项目名称:FoolFuuka,代码行数:29,代码来源:geoip_region_lock.php


示例4: dmn_getcountry

function dmn_getcountry($mnip, &$countrycode)
{
    $mnipalone = substr($mnip, 0, strpos($mnip, ":"));
    $res = geoip_country_name_by_name($mnipalone);
    $countrycode = strtolower(geoip_country_code_by_name($mnipalone));
    return $res;
}
开发者ID:elbereth,项目名称:dashninja-ctl,代码行数:7,代码来源:dmnctl.script.inc.php


示例5: isThirdPayOn

 public function isThirdPayOn()
 {
     $countryCode = geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
     $log_array = array('type' => 'geoip country code_by name', 'msg' => $countryCode);
     log_message('gash', json_encode($log_array));
     echo $countryCode;
 }
开发者ID:helenseo,项目名称:pay,代码行数:7,代码来源:web_config.php


示例6: execute

 public function execute($sub)
 {
     global $wgOut, $wgRequest;
     global $wgLandingPageBase, $wgChapterLandingPages, $wgLandingPageDefaultTarget;
     $lang = preg_match('/^[A-Za-z-]+$/', $wgRequest->getVal('lang')) ? $wgRequest->getVal('lang') : 'en';
     $utm_source = $wgRequest->getVal('utm_source');
     $utm_medium = $wgRequest->getVal('utm_medium');
     $utm_campaign = $wgRequest->getVal('utm_campaign');
     $referrer = $wgRequest->getHeader('referer');
     $target = $wgRequest->getVal('target', null);
     if (!$target) {
         $target = $wgLandingPageDefaultTarget;
     }
     $tracking = '?' . wfArrayToCGI(array('utm_source' => "{$utm_source}", 'utm_medium' => "{$utm_medium}", 'utm_campaign' => "{$utm_campaign}", 'referrer' => "{$referrer}", 'target' => "{$target}"));
     $ip = $wgRequest->getVal('ip') ? $wgRequest->getVal('ip') : wfGetIP();
     if (IP::isValid($ip)) {
         $country = geoip_country_code_by_name($ip);
         if (is_string($country) && array_key_exists($country, $wgChapterLandingPages)) {
             $wgOut->redirect($this->getDestination($utm_source) . '/' . $wgChapterLandingPages[$country] . $tracking);
             return;
         }
     }
     // No valid IP or chapter page - let's just go for the passed in url or our fallback
     if (Http::isValidURI($target)) {
         $wgOut->redirect($target . '/' . $lang . $tracking);
         return;
     } else {
         $wgOut->redirect($wgLandingPageBase . $target . '/' . $lang . $tracking);
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:GeoLite_body.php


示例7: getIPCountry

 static function getIPCountry($ip)
 {
     if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_COUNTRY_EDITION)) {
         try {
             try {
                 return geoip_country_code_by_name($ip);
             } catch (Exception $e) {
             }
         } catch (ErrorException $e) {
         }
     }
     try {
         $country = json_decode(file_get_contents('https://freegeoip.net/json/' . $ip));
         if (isset($country) && isset($country->country_code) && $country->country_code != '') {
             return $country->country_code;
         }
     } catch (Exception $e) {
     }
     try {
         $country = json_decode(file_get_contents('http://ip-api.com/json/' . $ip));
         if (isset($country) && isset($country->countryCode) && $country->countryCode != '') {
             return $country->countryCode;
         }
     } catch (Exception $e) {
     }
     try {
         $country = trim(file_get_contents("http://api.hostip.info/country.php?ip=" . $ip));
         if ($country != 'XX') {
             return $country;
         }
     } catch (Exception $e) {
     }
     return 'XX';
 }
开发者ID:W1zzardTPU,项目名称:XenForo_TPUDetectSpamReg,代码行数:34,代码来源:IPCountry.php


示例8: getCountryByIp

 /**
  * Get the country by IP
  * Return an array with : short name, like 'us', long name, like 'United States and response like 'OK' or <error_message> '
  * @access public
  * @param string $ip
  * @return array
  */
 public function getCountryByIp($ip)
 {
     $country = array(0 => 'unknown', 1 => 'NA', 'response' => 'OK');
     if (Dot_Kernel::validIp($ip) != "public") {
         return $country;
     }
     if (extension_loaded('geoip') == false) {
         // GeoIp extension is not active
         $api = new Dot_Geoip_Country();
         $geoipPath = $this->config->resources->geoip->path;
         if (file_exists($geoipPath)) {
             $country = $api->getCountryByAddr($geoipPath, $ip);
         } else {
             $country['response'] = 'Warning: ' . $this->option->warningMessage->modGeoIp;
         }
     }
     if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_COUNTRY_EDITION) && 'unknown' == $country[0]) {
         //if GeoIP.dat file exists
         $countryCode = geoip_country_code_by_name($ip);
         $countryName = geoip_country_name_by_name($ip);
         $country[0] = $countryCode != false ? $countryCode : 'unknown';
         $country[1] = $countryName != false ? $countryName : 'NA';
     }
     if ('unknown' == $country[0]) {
         // GeoIp extension is active, but .dat files are missing
         $api = new Dot_Geoip_Country();
         $geoipPath = $this->config->resources->geoip->path;
         if (file_exists($geoipPath)) {
             $country = $api->getCountryByAddr($geoipPath, $ip);
         } else {
             $country['response'] = 'Warning: ' . $this->option->warningMessage->modGeoIp;
         }
     }
     return $country;
 }
开发者ID:sandeepdwarkapuria,项目名称:dotkernel,代码行数:42,代码来源:Geoip.php


示例9: execute

 function execute($par)
 {
     global $wgRequest, $wgOut, $wgFundraiserLPDefaults;
     // Set the country parameter
     $country = $wgRequest->getVal('country');
     // If no country was passed do a GeoIP lookup
     if (!$country) {
         if (function_exists('geoip_country_code_by_name')) {
             $ip = wfGetIP();
             if (IP::isValid($ip)) {
                 $country = geoip_country_code_by_name($ip);
             }
         }
     }
     // If country still isn't set, set it to the default
     if (!$country) {
         $country = $wgFundraiserLPDefaults['country'];
     }
     $params = array('country' => $country);
     // Pass any other params that are set
     $excludeKeys = array('country', 'title');
     foreach ($wgRequest->getValues() as $key => $value) {
         // Skip the required variables
         if (!in_array($key, $excludeKeys)) {
             $params[$key] = $value;
         }
     }
     // Redirect to FundraiserLandingPage
     $wgOut->redirect($this->getTitleFor('FundraiserLandingPage')->getLocalUrl($params));
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:FundraiserRedirector.body.php


示例10: onPreLogin

 public function onPreLogin(PlayerPreLoginEvent $event)
 {
     $p = $event->getPlayer();
     $i = $p->getAddress();
     $co = geoip_country_code_by_name($i);
     if ($this->c[$co]) {
         $p->close("", $this->reason[$co]);
         $event->setCancelled(true);
     }
 }
开发者ID:MrDoni98,项目名称:CountryBlocker,代码行数:10,代码来源:CountryBlocker.php


示例11: getCountry

 public function getCountry($visitorAddress)
 {
     if (!function_exists("geoip_country_code_by_name")) {
         // @codeCoverageIgnoreStart
         throw new \InvalidArgumentException("It seems, the geo-ip extension is not installed for php.");
         // @codeCoverageIgnoreEnd
     }
     $counrtyCode = @\geoip_country_code_by_name($visitorAddress);
     return $counrtyCode;
 }
开发者ID:azine,项目名称:geoblocking-bundle,代码行数:10,代码来源:DefaultLookupAdapter.php


示例12: login_admin

 function login_admin()
 {
     $login_success = null;
     if (isset($_POST['login'])) {
         $login = $_POST['login'];
         $this->form_validation->set_rules('login[member_code]', 'Email / Member ID', 'required');
         $this->form_validation->set_rules('login[password]', 'required');
         if ($this->form_validation->run() == FALSE) {
             $login_success = false;
             $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">' . validation_errors() . '</div>');
             $this->index();
         } else {
             // $data = array('member_code' => $login[ 'member_code' ]);
             $potential_user = $this->admin_login_model->get_user_existing_data($login['member_code']);
             if ($potential_user) {
                 $this->load->library('PBKDF2');
                 $admin = $potential_user;
                 $pbkdf2 = new PBKDF2();
                 if ($pbkdf2->validatePassword($login['password'], $admin['password'])) {
                     if ($admin['status'] == 'active') {
                         $login_success = true;
                         if (isset($login['remember_me'])) {
                             // @TODO remember me mechanism
                         }
                         $this->nativesession->set(array('is_logged_in' => true, 'is_gan_admin_logged_in' => true, 'member_id' => $admin['id'], 'member_code' => $admin['member_code'], 'account_type' => $admin['account_type']));
                         // $country_code = function_exists( 'geoip_country_code_by_name' ) ? geoip_country_code_by_name( $_SERVER[ 'REMOTE_ADDR' ] ) : '';
                         $member_id = (string) $admin['id'];
                         $member_data = array('last_login_date' => date('Y-m-d H:i:s'), 'last_login_ip' => $_SERVER['REMOTE_ADDR'], 'last_login_country' => function_exists('geoip_country_code_by_name') ? geoip_country_code_by_name($_SERVER['REMOTE_ADDR']) : '');
                         $this->admin_login_model->update_member($member_id, $member_data);
                         redirect(base_url('admin/home'));
                     } else {
                         if ($member['status'] == 'inactive') {
                             $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">It seems that your account is inactive. please contact your administrator.</div>');
                             $login_success = false;
                             redirect(base_url('login'));
                         } else {
                             $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">Your account is suspended, please contact administrator.</div>');
                             $login_success = false;
                             redirect(base_url('admin/login'));
                         }
                     }
                 } else {
                     $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">Incorrect Email/member id or password ' . $potential_user . '.</div>');
                     $login_success = false;
                     redirect(base_url('admin/login'));
                 }
             } else {
                 $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">Incorrect Member ID or Password : Acces Denied.</div>');
                 $login_success = false;
                 redirect(base_url('admin/login'));
             }
         }
     }
 }
开发者ID:kobe8bird,项目名称:gan,代码行数:54,代码来源:admin_login.php


示例13: checkGeo

 public function checkGeo()
 {
     $targetGeo = json_decode($this->target_geo);
     if ($targetGeo) {
         $clientCountry = strtolower(geoip_country_code_by_name(getClientIp()));
         if (in_array($clientCountry, $targetGeo)) {
             return true;
         }
     }
     return false;
 }
开发者ID:huycao,项目名称:yoplatform,代码行数:11,代码来源:AdBaseModel.php


示例14: getCountryCode

 public function getCountryCode()
 {
     if (empty($this->countryCode) && !YII_DEBUG) {
         if (empty(Yii::app()->request->cookies['country_code'])) {
             $this->countryCode = geoip_country_code_by_name($this->getUserHostAddress());
             Yii::app()->request->cookies['country_code'] = new CHttpCookie('country_code', $this->countryCode, array('expire' => time() + 86400));
         } else {
             $this->countryCode = Yii::app()->request->cookies['country_code'];
         }
     }
     return $this->countryCode;
 }
开发者ID:maduhu,项目名称:openbay,代码行数:12,代码来源:AHttpRequest.php


示例15: getLocation

 /**
  * Uses the GeoIP PECL module to get a visitor's location based on their IP address.
  *
  * This function will return different results based on the data available. If a city
  * database can be detected by the PECL module, it may return the country code,
  * region code, city name, area code, latitude, longitude and postal code of the visitor.
  *
  * Alternatively, if only the country database can be detected, only the country code
  * will be returned.
  *
  * The GeoIP PECL module will detect the following filenames:
  * - GeoIP.dat
  * - GeoIPCity.dat
  * - GeoIPISP.dat
  * - GeoIPOrg.dat
  *
  * Note how GeoLiteCity.dat, the name for the GeoLite city database, is not detected
  * by the PECL module.
  *
  * @param array $info Must have an 'ip' field.
  * @return array
  */
 public function getLocation($info)
 {
     $ip = $this->getIpFromInfo($info);
     $result = array();
     // get location data
     if (self::isCityDatabaseAvailable()) {
         // Must hide errors because missing IPV6:
         $location = @geoip_record_by_name($ip);
         if (!empty($location)) {
             $result[self::COUNTRY_CODE_KEY] = $location['country_code'];
             $result[self::REGION_CODE_KEY] = $location['region'];
             if ($location['region'] == "18" && $location['city'] == "Milan") {
                 $result[self::REGION_CODE_KEY] = "09";
             }
             $result[self::CITY_NAME_KEY] = utf8_encode($location['city']);
             $result[self::AREA_CODE_KEY] = $location['area_code'];
             $result[self::LATITUDE_KEY] = $location['latitude'];
             $result[self::LONGITUDE_KEY] = $location['longitude'];
             $result[self::POSTAL_CODE_KEY] = $location['postal_code'];
         }
     } else {
         if (self::isRegionDatabaseAvailable()) {
             $location = @geoip_region_by_name($ip);
             if (!empty($location)) {
                 $result[self::REGION_CODE_KEY] = $location['region'];
                 $result[self::COUNTRY_CODE_KEY] = $location['country_code'];
             }
         } else {
             $result[self::COUNTRY_CODE_KEY] = @geoip_country_code_by_name($ip);
         }
     }
     // get organization data if the org database is available
     if (self::isOrgDatabaseAvailable()) {
         $org = @geoip_org_by_name($ip);
         if ($org !== false) {
             $result[self::ORG_KEY] = utf8_encode($org);
         }
     }
     // get isp data if the isp database is available
     if (self::isISPDatabaseAvailable()) {
         $isp = @geoip_isp_by_name($ip);
         if ($isp !== false) {
             $result[self::ISP_KEY] = utf8_encode($isp);
         }
     }
     if (empty($result)) {
         return false;
     }
     $this->completeLocationResult($result);
     return $result;
 }
开发者ID:parruc,项目名称:piwik,代码行数:73,代码来源:Pecl.php


示例16: checkIp_joyspade

function checkIp_joyspade()
{
    $countryarray = array('TW', 'SG', 'MY', 'TH', 'ID', 'PH', 'BN', 'KH', 'LA', 'MM', 'VN', 'TL');
    //东南亚+台湾
    $countryCode = geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
    //"1.0.16.0" $_SERVER['REMOTE_ADDR']
    foreach ($countryarray as $country) {
        if ($countryCode == $country) {
            return;
        }
    }
    echo "<html>\n         <head><title>404 Not Found</title></head>\n         <body bgcolor=\"white\">\n         <center><h1>404 Not Found</h1></center>\n         <hr><center>nginx/1.6.0</center>\n         </body>\n         </html>\n        ";
    die;
}
开发者ID:helenseo,项目名称:pay,代码行数:14,代码来源:ipfilter.php


示例17: get_geodata

 function get_geodata($ip)
 {
     require_once _TRACK_LIB_PATH . "/maxmind/geoip.inc.php";
     require_once _TRACK_LIB_PATH . "/maxmind/geoipcity.inc.php";
     require_once _TRACK_LIB_PATH . "/maxmind/geoipregionvars.php";
     $gi = geoip_open(_TRACK_STATIC_PATH . "/maxmind/MaxmindCity.dat", GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, $ip);
     $isp = geoip_org_by_addr($gi, $ip);
     geoip_close($gi);
     $cur_country = $record->country_code;
     // Resolve GeoIP extension conflict
     if (function_exists('geoip_country_code_by_name') && $cur_country == '') {
         $cur_country = geoip_country_code_by_name($ip);
     }
     return array('country' => $cur_country, 'state' => $GEOIP_REGION_NAME[$record->country_code][$record->region], 'city' => $record->city, 'region' => $record->region, 'isp' => $isp);
 }
开发者ID:conversionstudio,项目名称:cpatracker,代码行数:16,代码来源:track_direct.php


示例18: login_member

 function login_member()
 {
     $login_success = null;
     if (isset($_POST['login'])) {
         $login = $_POST['login'];
         $data = array('member_code' => $login['member_code']);
         $potential_user = $this->member_login_model->get_user_existing_data($data);
         if ($potential_user) {
             $this->load->library('PBKDF2');
             $member = $potential_user;
             $pbkdf2 = new PBKDF2();
             if ($pbkdf2->validatePassword($login['password'], $member['password'])) {
                 if ($member['status'] != 'deactivated' && $member['status'] != 'inactive') {
                     $login_success = true;
                     if (isset($login['remember_me'])) {
                         // @TODO remember me mechanism
                     }
                     $this->nativesession->set(array('is_logged_in' => true, 'is_member_logged_in' => true, 'member_id' => $member['id'], 'member_code' => $member['member_code'], 'ms_status' => $member['status']));
                     // $country_code = function_exists( 'geoip_country_code_by_name' ) ? geoip_country_code_by_name( $_SERVER[ 'REMOTE_ADDR' ] ) : '';
                     $member_id = (string) $member['id'];
                     $member_data = array('last_login_date' => date('Y-m-d H:i:s'), 'last_login_ip' => $_SERVER['REMOTE_ADDR'], 'last_login_country' => function_exists('geoip_country_code_by_name') ? geoip_country_code_by_name($_SERVER['REMOTE_ADDR']) : '');
                     $this->member_login_model->update_member($member_id, $member_data);
                     redirect(base_url('members/home'));
                 } else {
                     if ($member['status'] == 'inactive') {
                         $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">It seems that your account is inactive. please contact your administrator.</div>');
                         $login_success = false;
                         redirect(base_url('login'));
                     } else {
                         $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">Your account is suspended, please contact administrator.</div>');
                         $login_success = false;
                         redirect(base_url('login'));
                     }
                 }
             } else {
                 $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">Incorrect Member ID or Password.</div>');
                 $login_success = false;
                 redirect(base_url('login'));
             }
         } else {
             $this->nativesession->set_flashdata('login_status', '<div class="alert alert-danger">Incorrect Member ID or Password.</div>');
             $login_success = false;
             redirect(base_url('login'));
         }
     }
 }
开发者ID:kobe8bird,项目名称:gan,代码行数:46,代码来源:member_login.php


示例19: _check_ip

 function _check_ip($ip, $ignore_ips = '', $check_type = 'force')
 {
     $masks = ['0.0.0.0/8', '10.0.0.0/8', '127.0.0.0/8', '128.0.0.0/16', '169.254.0.0/16', '172.16.0.0/12', '191.255.0.0/16', '192.0.0.0/24', '192.0.2.0/24', '192.88.99.0/24', '192.168.0.0/16', '198.18.0.0/15', '223.255.255.0/24', '224.0.0.0/4', '240.0.0.0/4', '255.255.255.255/'];
     $ip = preg_replace('/[^\\d\\.]/', ',', $ip);
     $ips = explode(',', $ip);
     foreach ((array) $ips as $item) {
         if (empty($item) || !empty($ignore_ips) && isset($ignore_ips[$item])) {
             continue;
         }
         $flag = false;
         preg_match('/([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})/', $item, $cur_ip);
         $ip = isset($cur_ip[1]) ? $cur_ip[1] : false;
         if (!$ip) {
             continue;
         }
         $flag = true;
         foreach ((array) $masks as $mask) {
             list($net_addr, $net_mask) = explode('/', $mask);
             if ($net_mask <= 0) {
                 continue;
             }
             if (empty($net_mask) && $item == $net_addr) {
                 $flag = false;
                 break;
             }
             $ip_binary_string = sprintf('%032b', ip2long($item));
             $net_binary_string = sprintf('%032b', ip2long($net_addr));
             if (substr_compare($ip_binary_string, $net_binary_string, 0, $net_mask) === 0) {
                 $flag = false;
             }
         }
         if ($flag) {
             if (function_exists('geoip_country_code_by_name') && strtoupper($check_type) == 'GEO') {
                 $test = @geoip_country_code_by_name($ip);
                 if ($test) {
                     return trim($ip);
                 }
             } else {
                 return trim($ip);
             }
         }
     }
     return false;
 }
开发者ID:yfix,项目名称:yf,代码行数:44,代码来源:yf_client_utils.class.php


示例20: requestMatchesCriteria

 /**
  * Determines if the given request matches the criteria.
  *
  * @param array|string $criteria List of criteria, format: [] with keys rule
  * and data; may be serialized
  * @param boolean $matchOnEmpty If true and there's no criteria, true is
  * returned; otherwise, false
  * @param Zend_Controller_Request_Http $request Request to check against
  *
  * @return boolean
  */
 public static function requestMatchesCriteria($criteria, $matchOnEmpty = false, Zend_Controller_Request_Http $request = null)
 {
     if (!($criteria = XenForo_Helper_Criteria::unserializeCriteria($criteria))) {
         return (bool) $matchOnEmpty;
     }
     if (!$request) {
         $request = new Zend_Controller_Request_Http();
     }
     foreach ($criteria as $criterion) {
         $data = $criterion['data'];
         switch ($criterion['rule']) {
             // contains at least x links
             case 'geoip_country':
                 if (!isset($data['countries'])) {
                     return false;
                 }
                 if (!function_exists('geoip_country_code_by_name')) {
                     return false;
                 }
                 try {
                     $country = geoip_country_code_by_name($request->getClientIp(true));
                 } catch (Exception $e) {
                     return false;
                 }
                 if (!in_array($country, $data['countries'])) {
                     return false;
                 }
                 break;
                 // user has open port
             // user has open port
             case 'open_port':
                 if (empty($data['port'])) {
                     return false;
                 }
                 if (@fsockopen($_SERVER['REMOTE_ADDR'], $data['port'], $errstr, $errno, 1)) {
                     return false;
                 }
                 break;
         }
     }
     return true;
 }
开发者ID:ThemeHouse-XF,项目名称:SpamRules,代码行数:53,代码来源:Criteria.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP geoip_country_id_by_addr函数代码示例发布时间:2022-05-15
下一篇:
PHP geoip_country_code_by_addr函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap