コード例 #1
0
ファイル: codebase.php プロジェクト: phill104/branches
function plugin_geoip_flag($ip)
{
    global $CONFIG;
    $ip = $ip[1];
    $return = '';
    if ($ip != '') {
        if ($CONFIG['plugin_geoip_scope'] == '1' && file_exists("./plugins/geoip/GeoLiteCity.dat")) {
            $gi = geoip_open('plugins/geoip/GeoLiteCity.dat', GEOIP_STANDARD);
            $record = geoip_record_by_addr($gi, $ip);
            if ($record->country_code != '' && file_exists('images/flags/' . strtolower($record->country_code) . '.png') == TRUE) {
                $return = '<img src="images/flags/' . strtolower($record->country_code) . '.png" border="0" width="16" height="11" alt="" title="' . geoip_country_name_by_addr($gi, $ip) . '" style="margin-left:1px;" />';
            }
            if ($record->city != '') {
                $return .= $record->city;
            }
            geoip_close($gi);
        } else {
            $gi = geoip_open('plugins/geoip/GeoIP.dat', GEOIP_STANDARD);
            $country_code = geoip_country_code_by_addr($gi, $ip);
            if ($country_code != '' && file_exists('images/flags/' . strtolower($country_code) . '.png') == TRUE) {
                $return = '<img src="images/flags/' . strtolower($country_code) . '.png" border="0" width="16" height="11" alt="" title="' . geoip_country_name_by_addr($gi, $ip) . '" style="margin-left:1px;" />';
            }
            geoip_close($gi);
        }
    }
    return array($return);
}
コード例 #2
0
ファイル: system.php プロジェクト: pussbb/CI_DEV_CMS
 function setlang()
 {
     $CFG =& load_class('Config');
     //$OUT = &load_class('Output');
     $CFG->load('site');
     $a = explode('/', $_SERVER["REQUEST_URI"]);
     if (sizeof($a) > 0) {
         $lang = $a[1];
         if ($CFG->item('folder') == true) {
             $lang = $a[2];
         }
         switch ($lang) {
             case 'ru':
                 $CFG->set_item('language', "ru");
                 break;
             case 'en':
                 $CFG->set_item('language', "en");
                 break;
             default:
                 include BASEPATH . 'libraries/third_party/Geoip.php';
                 $country = geoip_country_code_by_addr(open_geo(), $_SERVER['REMOTE_ADDR']);
                 switch ($country) {
                     case 'RU':
                         $CFG->set_item('language', "ru");
                         break;
                     case 'UA':
                         $CFG->set_item('language', "ru");
                         break;
                     default:
                         $CFG->set_item('language', "en");
                         break;
                 }
         }
     }
 }
コード例 #3
0
ファイル: Geoip.php プロジェクト: xiaoguizhidao/MyMagento
 /**
  * Gets customer location data by ip
  *
  * @static
  * @param string $ip
  * @param array $config
  * @return array
  */
 public static function getGeoIpLocation($ip, $config)
 {
     if ($config['is_city_db_type']) {
         include_once Mage::getBaseDir() . DS . 'lib' . DS . 'GeoIP' . DS . 'geoipcity.inc';
         include_once Mage::getBaseDir() . DS . 'lib' . DS . 'GeoIP' . DS . 'geoipregionvars.php';
     } else {
         include_once Mage::getBaseDir() . DS . 'lib' . DS . 'GeoIP' . DS . 'geoip.inc';
     }
     $geoip = geoip_open($config['db_path'], GEOIP_STANDARD);
     $data = array('ip' => $ip);
     if ($config['is_city_db_type']) {
         $record = geoip_record_by_addr($geoip, $ip);
         if ($record) {
             $data['code'] = $record->country_code;
             $data['country'] = $record->country_name;
             $data['region'] = isset($GEOIP_REGION_NAME[$record->country_code][$record->region]) ? $GEOIP_REGION_NAME[$record->country_code][$record->region] : $record->region;
             $data['city'] = $record->city;
             $data['postal_code'] = $record->postal_code;
         }
     } else {
         $data['code'] = geoip_country_code_by_addr($geoip, $ip);
         $data['country'] = geoip_country_name_by_addr($geoip, $ip);
     }
     geoip_close($geoip);
     return $data;
 }
コード例 #4
0
 function testgeoipdatabase($type, $flags, $msg, $numlookups)
 {
     $gi = geoip_open($this->dbfilename[$type], $flags);
     if ($gi == null) {
         print "error: " . $this->dbfilename[$type] . " does not exist\n";
         return;
     }
     $t1 = $this->ftime();
     $i4 = 0;
     for ($i2 = 0; $i2 < $numlookups; $i2++) {
         switch ($type) {
             case GEOIP_COUNTRY_DATABASE:
                 geoip_country_code_by_addr($gi, $this->randomipaddress());
                 break;
             case GEOIP_REGION_DATABASE:
                 geoip_region_by_addr($gi, $this->randomipaddress());
                 break;
             case GEOIP_CITY_DATABASE:
                 GeoIP_record_by_addr($gi, $this->randomipaddress());
                 break;
         }
     }
     $t2 = $this->ftime();
     $t3 = $t2 - $t1;
     print $msg . "\n";
     print $numlookups . " lookups made in " . $t3 . " seconds \n";
     geoip_close($gi);
 }
コード例 #5
0
ファイル: Bootstrap.php プロジェクト: dnhsoft/swApacheGeoIP
 public function onPostDispatchIndexController(Enlight_Event_EventArgs $arguments)
 {
     $controller = $arguments->getSubject();
     $view = $controller->View();
     $view->addTemplateDir($this->Path() . 'Views/');
     $shopLang = Shopware()->Front()->Request()->getCookie('shopLang');
     //        $ip = $_SERVER['REMOTE_ADDR'];
     $ip = '195.149.248.130';
     //BG
     //        $ip = '194.50.69.124'; //DE
     //        $ip = '211.156.198.82'; //CN
     $gi = geoip_open(__DIR__ . '/GeoIp/db/GeoIP.dat', GEOIP_STANDARD);
     $countryCode = geoip_country_code_by_addr($gi, $ip);
     geoip_close($gi);
     if ($shopLang != strtolower($countryCode)) {
         $shopLang = strtolower($countryCode);
         Shopware()->Front()->Response()->setCookie('shopLang', $shopLang, 0);
         $builder = Shopware()->Container()->get('dbal_connection')->createQueryBuilder();
         $shopId = $builder->select('scs.id')->from('s_core_locales', 'scl')->innerJoin('scl', 's_core_shops', 'scs', 'scl.id = scs.locale_id')->where('scl.locale LIKE ?')->setParameter(0, $shopLang . '%')->execute()->fetch();
         if ($shopId) {
             $view->extendsTemplate('frontend/index/change_shop.tpl');
             $view->assign(array('shopId' => $shopId['id']));
         }
     }
 }
コード例 #6
0
ファイル: cpagenews.php プロジェクト: adzzie/hotel
 function readM()
 {
     include 'geoip.inc';
     $gi = geoip_open('resources/GeoIP.dat', GEOIP_STANDARD);
     $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_code'] = $country_code;
     $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_name'] = $country_name;
     // close the database
     geoip_close($gi);
     $visit = array('id' => NULL, 'negara' => $country_name, 'visit' => 'news');
     $this->model_visit->add($visit);
     $id = $this->uri->segment(4);
     if ($id == "cpagenews") {
         $bh = $this->uri->segment(6);
         redirect('user/cpagenews/ubahBhs/' . $this->uri->segment(6));
     }
     $data['title'] = "news";
     $this->load->view('user/vheader', $data);
     $bhs = $this->session->userdata('EN');
     $data['gambar'] = $this->model_gambar->getGmb();
     $data['berit'] = $this->model_berita->getByMore($id);
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['news'] = $this->model_berita->getSlideNews($bhs);
     $this->load->view('user/vmenu');
     $this->load->view('user/frontend/page/vreadmore', $data);
     $this->load->view('user/vfooter');
 }
コード例 #7
0
function wpgeoip_redirect()
{
    if (get_option('wpgeoip_no_redirect', 0) == 1 and isset($_GET['noredirect'])) {
        return false;
    }
    require_once 'geoip.inc';
    //open geoip binary database
    $gi = geoip_open(plugin_dir_path(__FILE__) . 'GeoIP.dat', GEOIP_STANDARD);
    global $wpdb;
    global $wp_query;
    global $post;
    $prefix = $wpdb->prefix;
    $postID = $post->ID;
    $catID = intval($wp_query->query_vars['cat']);
    $isHome = is_home();
    $the_page_name = '';
    //get user country
    $countryCode = geoip_country_code_by_addr($gi, WPGeoIP_getIP());
    //sitewide rule
    $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `postID` = 999999");
    if (isset($rs_redirect) and count($rs_redirect)) {
        $the_page_name = get_the_title($postID);
        $wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'SITEWIDE Redirect', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
        print '<meta http-equiv="refresh" content="0;url=' . $rs_redirect->targetURL . '"/>';
        exit;
    }
    //redirect if any rule for this country
    if ($postID != 0) {
        $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `postID` = {$postID}");
        $the_page_name = get_the_title($postID);
    }
    if ($catID != 0) {
        $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `catID` = {$catID}");
        $the_page_name = 'Category : ' . get_the_category_by_ID($catID);
    }
    if ($isHome) {
        $rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `home_rule` = 1");
        $the_page_name = 'Homepage';
    }
    if (!$rs_redirect) {
        //NOTHING TO DO
        #$wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Redirect', 'Nothing to do. No rules for Country <strong>".$countryCode."</strong>')");
    }
    if (isset($rs_redirect) and count($rs_redirect)) {
        $wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Redirect <em>" . $the_page_name . "</em>', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
        print '<meta http-equiv="refresh" content="0;url=' . $rs_redirect->targetURL . '"/>';
        exit;
    } else {
        //CHECK COUNTRIES WITHOUT REDIRECT RULES
        $mass_redirect_enabled = get_option('wpgeoip_mass_redirect');
        if ($mass_redirect_enabled != "0") {
            $mass_url = get_option('wpgeoip_mass_url');
            $wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Mass Redirect', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
            print '<meta http-equiv="refresh" content="0;url=' . $mass_url . '"/>';
            exit;
        } else {
            //NOTHING TO DO AGAINM
        }
    }
}
コード例 #8
0
ファイル: cpagegallery.php プロジェクト: adzzie/hotel
 function index()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $masuk = TRUE;
     $msk = TRUE;
     $mskC = TRUE;
     $today = date('Y-m-d');
     include 'geoip.inc';
     $gi = geoip_open('resources/GeoIP.dat', GEOIP_STANDARD);
     $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_code'] = $country_code;
     $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_name'] = $country_name;
     // close the database
     geoip_close($gi);
     $visit = array('id' => NULL, 'negara' => $country_name, 'visit' => 'gallery');
     $this->model_visit->add($visit);
     $data['title'] = "gallery";
     $bhs = $this->session->userdata('EN');
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['galeri'] = $this->model_galery->getBahasa($bhs);
     $data['gambar'] = $this->model_gambar->getGmb();
     $this->load->view('user/vheader', $data);
     $this->load->view('user/vmenu');
     $this->load->view('user/frontend/page/vgallery');
     $this->load->view('user/vfooter');
 }
コード例 #9
0
ファイル: currency.php プロジェクト: hungnv0789/vhtm
/**
 * Fetch the currency code to use based on the current visitors IP address. This function will perform a
 * GeoIP based lookup of the current visitors IP address and if possible, find a matching currency.
 *
 * @return mixed False if a currency cannot be found, else the currency ID if a matching currency was found.
 */
function GetCurrencyByIP()
{
	require_once ISC_BASE_PATH."/lib/geoip/geoip.php";
	$geoIp = @geoip_open(ISC_BASE_PATH."/lib/geoip/GeoIP.dat", GEOIP_STANDARD);
	if(!$geoIp) {
		return false;
	}
	$code = geoip_country_code_by_addr($geoIp, GetIP());
	if(!$code) {
		return false;
	}

	$query = "
		SELECT currencyid
		FROM [|PREFIX|]currencies cu
		LEFT JOIN [|PREFIX|]countries co ON cu.currencycountryid = co.countryid
		LEFT JOIN (
			SELECT r.couregid, c.countryiso2
			FROM [|PREFIX|]countries c
			JOIN [|PREFIX|]country_regions r ON c.countrycouregid = r.couregid
		) cr ON cu.currencycouregid = cr.couregid
		WHERE
			(
				co.countryiso2 = '" . $GLOBALS['ISC_CLASS_DB']->Quote($code) . "' OR
				cr.countryiso2 = '" . $GLOBALS['ISC_CLASS_DB']->Quote($code) . "'
			) AND
			cu.currencystatus = 1
		LIMIT 1
	";
	return $GLOBALS['ISC_CLASS_DB']->FetchOne($query, 'currencyid');
}
コード例 #10
0
ファイル: in.php プロジェクト: conjuringtricks/Tinba
function GetCountry($bot_ip)
{
    $GI = geoip_open('includes/GeoIP.dat', GEOIP_STANDARD);
    $bot_country = geoip_country_code_by_addr($GI, $bot_ip);
    geoip_close($GI);
    return $bot_country;
}
コード例 #11
0
ファイル: index.php プロジェクト: dz00te/nethserver-phonehome
 public function add_info($uuid, $release)
 {
     // get ip from remote address
     $ip = $_SERVER['REMOTE_ADDR'];
     // get geodata
     $gi = geoip_open("/usr/share/GeoIP/GeoIP.dat", GEOIP_STANDARD);
     // get country code from ip
     $country_code = geoip_country_code_by_addr($gi, $ip);
     // get country name from ip
     $country_name = geoip_country_name_by_addr($gi, $ip);
     try {
         // get connession
         $conn = new PDO("mysql:host=" . $GLOBALS['$dbhost'] . ";dbname=" . $GLOBALS['$dbname'] . "", $GLOBALS['$dbuser'], $GLOBALS['$dbpass']);
         // set the PDO error mode to exception
         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         // insert query
         $sql = "REPLACE INTO phone_home_tb (uuid,\n                                            release_tag,\n                                            ip,\n                                            country_code,\n                                            country_name,\n                                            reg_date)\n                VALUES (:uuid,\n                        :release,\n                        :ip,\n                        :country_code,\n                        :country_name,\n                        NOW())";
         // prepare statement
         $stmt = $conn->prepare($sql);
         // execute query
         $stmt->execute(array(':uuid' => $uuid, ':release' => $release, ':ip' => $ip, ':country_code' => $country_code, ':country_name' => $country_name));
         // close connession
         $conn = null;
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
 }
コード例 #12
0
	/**
	 * Return in lower case the country code from an ip
	 *
	 * @param	$ip		IP to scan
	 * @return	string	Country code (two letters)
	 */
	function getCountryCodeFromIP($ip)
	{
		if (empty($this->gi))
		{
			return '';
		}
		return strtolower(geoip_country_code_by_addr($this->gi, $ip));
	}
コード例 #13
0
ファイル: ip2cc.php プロジェクト: jiangyu7408/notification
 function ip2cc($ip)
 {
     static $gi = null;
     if ($gi === null) {
         $gi = geoip_open(__DIR__ . '/geoip/GeoIP.dat', GEOIP_STANDARD);
     }
     return geoip_country_code_by_addr($gi, $ip);
 }
コード例 #14
0
ファイル: geoip_helper.php プロジェクト: skybee/france
function get_country()
{
    include "application/helpers/geoip/files/geoip.inc";
    $gi = geoip_open("application/helpers/geoip/files/GeoIP.dat", GEOIP_STANDARD);
    $country_code = geoip_country_code_by_addr($gi, $_SERVER['HTTP_X_REAL_IP']);
    geoip_close($gi);
    return $country_code;
}
コード例 #15
0
 /**
  * @param null $address
  * @return bool|string
  */
 public function country_code($address = null)
 {
     $countryCode = geoip_country_code_by_addr($this->gi, $address);
     if ($countryCode == null) {
         $countryCode = '-';
     }
     return $countryCode;
 }
コード例 #16
0
function country_from_ip($addr)
{
    // Switch GEOIP_SHARED_MEMORY for better perfs
    // (or a thousand times better, GeoIP C library binding for PHP)
    $gi = geoip_open('data/GeoIP.dat', GEOIP_STANDARD);
    $country = geoip_country_code_by_addr($gi, $addr);
    geoip_close($gi);
    return $country;
}
コード例 #17
0
/**
 * Получение страны по айпишнику
 *
 * @param string $ip_address
 */
function get_country_by_ip($ip_address)
{
    $obj =& get_instance();
    static $gi = null;
    if (null === $gi) {
        require_once APPPATH . 'libraries/geoip.php';
        $gi = geoip_open($obj->config->item('path_to_files') . 'GeoIP.dat', GEOIP_STANDARD);
    }
    return geoip_country_code_by_addr($gi, $ip_address);
}
コード例 #18
0
ファイル: functions.php プロジェクト: sucof/footlocker
/**
* Функция определения страны бота
*/
function get_country($ip)
{
    $gi = geoip_open("includes/geoip.dat", GEOIP_STANDARD);
    $id = geoip_country_code_by_addr($gi, $ip);
    if (empty($id)) {
        $id = "xx";
    }
    geoip_close($gi);
    return $id;
}
コード例 #19
0
ファイル: cart_model.php プロジェクト: Gninety/Microweber
 function __construct()
 {
     parent::Model();
     $country_name = CI::library('session')->userdata('country_name');
     if (strval(trim($country_name)) == '') {
         if (!defined('USER_COUNTRY_NAME')) {
             if (is_file(BASEPATH . 'libraries/maxmind/geoip.inc') == true) {
                 include BASEPATH . 'libraries/maxmind/geoip.inc';
                 $handle = geoip_open(BASEPATH . "libraries/maxmind/GeoIP.dat", GEOIP_STANDARD);
                 //var_Dump($_SERVER ["REMOTE_ADDR"]);
                 if ($_SERVER["REMOTE_ADDR"] == '::1') {
                     $ip = '77.70.8.202';
                 } else {
                     $ip = $_SERVER["REMOTE_ADDR"];
                 }
                 $the_user_coutry = geoip_country_code_by_addr($handle, $ip);
                 $the_user_coutry_name = geoip_country_name_by_addr($handle, $ip);
                 //var_dump( $the_user_coutry);
                 define("USER_COUNTRY", $the_user_coutry);
                 define("USER_COUNTRY_NAME", $the_user_coutry_name);
                 geoip_close($handle);
             } else {
                 //exit('need geo ip');
             }
         }
         //var_dump(USER_COUNTRY);
         CI::library('session')->set_userdata('country_name', USER_COUNTRY_NAME);
     }
     //print(USER_COUNTRY);
     //print(USER_COUNTRY_NAME);
     $shop_currency = CI::library('session')->userdata('shop_currency');
     $country_name = CI::library('session')->userdata('country_name');
     if (strval($country_name) == '') {
         CI::library('session')->set_userdata('country_name', USER_COUNTRY_NAME);
     }
     $shop_currency = CI::library('session')->userdata('shop_currency');
     //print $shop_currency;
     if (strval($shop_currency) == '') {
         switch (strtolower(USER_COUNTRY)) {
             case 'uk':
                 $this->currencyChangeSessionData("GBP");
                 break;
             case 'us':
             case 'usa':
                 $this->currencyChangeSessionData("USD");
                 break;
             default:
                 $this->currencyChangeSessionData("EUR");
                 break;
         }
     }
     $shop_currency = CI::library('session')->userdata('shop_currency');
     //	print $shop_currency;
 }
コード例 #20
0
 public function get_geo_code_country($ip_address)
 {
     require_once ROOT . "geoip.inc";
     $gi = geoip_open(ROOT . "GeoLiteIPCountry.dat", GEOIP_STANDARD);
     $record = geoip_country_code_by_addr($gi, $ip_address);
     geoip_close($gi);
     if (!empty($record)) {
         return $record;
     } else {
         return null;
     }
 }
コード例 #21
0
ファイル: job_search.php プロジェクト: pamalite/yel
 private function log_search_criteria()
 {
     $gi = geoip_open($GLOBALS['maxmind_geoip_data_file'], GEOIP_STANDARD);
     $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     geoip_close($gi);
     if (empty($country) || is_null($country)) {
         $country = '??';
     }
     $query = "INSERT INTO search_log SET \n                  from_ip_address = '" . $_SERVER['REMOTE_ADDR'] . "', \n                  from_country = '" . $country . "', \n                  keywords = '" . sanitize($this->keywords) . "', \n                  filter_industry = " . $this->industry . ", \n                  filter_country_code = '" . $this->country_code . "', \n                  searched_on = NOW()";
     $mysqli = Database::connect();
     return $mysqli->execute($query);
 }
コード例 #22
0
 private function _baseData()
 {
     $result = array('shipping' => array('country_id' => null, 'city' => null, 'region_id' => null, 'postcode' => null), 'billing' => array('country_id' => null, 'city' => null, 'region_id' => null, 'postcode' => null), 'equal' => true);
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     $addresses = $customer->getAddresses();
     if (!$customer || !$addresses) {
         $result['equal'] = true;
         if (Mage::getStoreConfig('checkoutsimplificado/geo_ip/country')) {
             $geoip = geoip_open(Mage::getBaseDir('lib') . DS . 'MaxMind/GeoIP/data/' . Mage::getStoreConfig('checkoutsimplificado/geo_ip/country_file'), GEOIP_STANDARD);
             $country_id = geoip_country_code_by_addr($geoip, Mage::helper('core/http')->getRemoteAddr());
             $result['shipping']['country_id'] = $country_id;
             $result['billing']['country_id'] = $country_id;
             geoip_close($geoip);
         }
         if (Mage::getStoreConfig('checkoutsimplificado/geo_ip/city')) {
             $geoip = geoip_open(Mage::getBaseDir('lib') . DS . 'MaxMind/GeoIP/data/' . Mage::getStoreConfig('checkoutsimplificado/geo_ip/city_file'), GEOIP_STANDARD);
             $record = geoip_record_by_addr($geoip, Mage::helper('core/http')->getRemoteAddr());
             $result['shipping']['city'] = $record->city;
             $result['billing']['city'] = $record->city;
             $result['shipping']['postcode'] = $record->postal_code;
             $result['billing']['postcode'] = $record->postal_code;
             geoip_close($geoip);
         }
         if (empty($result['shipping']['country_id'])) {
             $country_id = Mage::getStoreConfig('checkoutsimplificado/general/country');
             $result['shipping']['country_id'] = $country_id;
             $result['billing']['country_id'] = $country_id;
         }
     } else {
         $bill_addr = $customer->getPrimaryBillingAddress();
         if (!$bill_addr) {
             foreach ($addresses as $address) {
                 $bill_addr = $address;
                 break;
             }
         }
         $ship_addr = $customer->getPrimaryShippingAddress();
         if (!$ship_addr) {
             foreach ($addresses as $address) {
                 $ship_addr = $address;
                 break;
             }
         }
         $result['shipping']['country_id'] = $ship_addr->getCountryId();
         $result['billing']['country_id'] = $bill_addr->getCountryId();
         $eq = false;
         if ($ship_addr->getId() === $bill_addr->getId()) {
             $eq = true;
         }
         $result['equal'] = $eq;
     }
     return $result;
 }
コード例 #23
0
ファイル: function_misc.php プロジェクト: v998/discuzx-en
function convertip_geo($ip = '', $ipdatafile = '')
{
    require_once DISCUZ_ROOT . './source/function/geoip.inc';
    $gi = geoip_open($ipdatafile, GEOIP_STANDARD);
    $country = geoip_country_code_by_addr($gi, $ip);
    geoip_close($gi);
    if ($country) {
        return lang('country', $country);
    } else {
        return lang('country', '??');
    }
}
コード例 #24
0
ファイル: cpagehome.php プロジェクト: adzzie/hotel
 function index()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $masuk = TRUE;
     $msk = TRUE;
     $mskC = TRUE;
     $today = date('Y-m-d');
     include 'geoip.inc';
     $gi = geoip_open('resources/GeoIP.dat', GEOIP_STANDARD);
     $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_code'] = $country_code;
     $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_name'] = $country_name;
     // close the database
     geoip_close($gi);
     $visit = array('id' => NULL, 'negara' => $country_name, 'visit' => 'home');
     $this->model_visit->add($visit);
     foreach ($this->model_conter->getAll() as $r) {
         if ($ip == $r->ip && $today == $r->tanggal) {
             $masuk = FALSE;
         }
     }
     foreach ($this->model_conter->getAll2() as $r) {
         if ($today == $r->tanggal) {
             $msk = FALSE;
         }
     }
     foreach ($this->model_conter->getAllC() as $r) {
         if ($country_name == $r->negara) {
             $mskC = FALSE;
         }
     }
     $konter = array('total' => $this->model_conter->counN($country_name));
     $this->model_conter->edit($konter, $country_name);
     if ($msk) {
         $konter2 = array('id' => NULL, 'tanggal' => $today);
         $this->model_conter->addR($konter2);
     }
     if ($mskC) {
         $ni = array('id' => NULL, 'negara' => $country_name, 'total' => 1);
         $this->model_conter->addC($ni);
     }
     if ($masuk) {
         $konter = array('idcounter' => NULL, 'tanggal' => $today, 'ip' => $ip, 'negara' => $country_name);
         $this->model_conter->add($konter);
     }
     $data['title'] = "home page";
     $bhs = $this->session->userdata('EN');
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['news'] = $this->model_berita->getSlideNews($bhs);
     $this->load->view('user/vcontent_rev', $data);
 }
コード例 #25
0
function google_apis_fix($buffer)
{
    $geoData = geoip_open(PLUGIN_PATH . 'geo/GeoIP.dat', GEOIP_STANDARD);
    $countryCode = geoip_country_code_by_addr($geoData, $_SERVER['REMOTE_ADDR']);
    geoip_close($geoData);
    if ($countryCode === 'CN' || $countryCode === '') {
        return preg_replace_callback('|(https*:)*//(.*).googleapis.com/|', function ($matches) {
            return 'http://' . $matches[2] . '.useso.com/';
        }, $buffer);
    } else {
        return $buffer;
    }
}
 /**
  * Returns a WPML-compatible country code from an IP address
  *
  * @param $ip
  * @param bool $as_json
  * @return string
  */
 function ip_to_wpml_country_code($ip, $as_json = true)
 {
     //This returns empty string if something went wrong
     $country_code = @geoip_country_code_by_addr($this->db, $ip);
     //Try to match against language mappings
     foreach ($this->language_mappings as $maxmind_code => $wpml_code) {
         if ($maxmind_code == $country_code) {
             return $this->return_country_code($wpml_code);
         }
     }
     //We didn't match anything, return the default code
     return $this->return_country_code($this->default_language);
 }
コード例 #27
0
function main()
{
    global $country, $ip, $currentTime;
    $currentTime = mktime();
    $gi = geoip_open("geo/geoip/GeoIP.dat", GEOIP_STANDARD);
    $ip = $_SERVER["REMOTE_ADDR"];
    $country = geoip_country_code_by_addr($gi, $ip);
    geoip_close($gi);
    setcookie("geo", $country, time() + 15552000, "/", $base . $domain, 0);
    //6 month cookie
    connect();
    displayClientWebSite($ip, $country, $currentTime);
}
コード例 #28
0
ファイル: cpagewelcome.php プロジェクト: adzzie/hotel
 function index()
 {
     include 'geoip.inc';
     $gi = geoip_open('resources/GeoIP.dat', GEOIP_STANDARD);
     $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_code'] = $country_code;
     $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_name'] = $country_name;
     // close the database
     geoip_close($gi);
     $visit = array('id' => NULL, 'negara' => $country_name, 'visit' => 'welcome');
     $this->model_visit->add($visit);
     $data['gambar'] = $this->model_gambar->getAll();
     $this->load->view('user/frontend/page/vwelcome', $data);
 }
コード例 #29
0
ファイル: Popup.php プロジェクト: technomagegithub/colb2b
 public function getCountry($ipAddress)
 {
     // get the country of the IP from the MAXMIND
     $country = "";
     include_once "geoip.inc.php";
     // read GeoIP database
     $handle = geoip_open("GeoIP.dat", GEOIP_STANDARD);
     // map IP to country
     $country = geoip_country_code_by_addr($handle, $ipAddress);
     // close database handler
     geoip_close($handle);
     if ($country == "" || empty($country)) {
         $country = "Unknown";
     }
     return $country;
 }
コード例 #30
0
ファイル: Client.php プロジェクト: ninodafonte/SIFO
 /**
  * Get 2 letter country code from client IP.
  *
  * @static
  *
  * @param null $ip Associated IP or leave null for current user's IP.
  *
  * @return bool|mixed
  */
 public static function getCountryCode($ip = null)
 {
     $registry_key = 'Client_CountryCode_' . $ip;
     if (Registry::KeyExists($registry_key)) {
         $country_code = Registry::get($registry_key);
     } else {
         if (null == $ip) {
             $ip = self::getIP();
         }
         require_once ROOT_PATH . '/libs/GeoIP-Lite/geoip.php';
         $gi = geoip_open(ROOT_PATH . '/libs/GeoIP-Lite/GeoIP.dat', GEOIP_MEMORY_CACHE);
         $country_code = geoip_country_code_by_addr($gi, $ip);
         geoip_close($gi);
         Registry::set($registry_key, $country_code);
     }
     return $country_code;
 }