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

PHP geoip_country_name_by_addr函数代码示例

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

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



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

示例1: add_info

 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();
     }
 }
开发者ID:dz00te,项目名称:nethserver-phonehome,代码行数:27,代码来源:index.php


示例2: get_country_name_by_ip

/**
 * Получение названия страны по айпишнику
 *
 * @param string $ip_address
 */
function get_country_name_by_ip($ip_address)
{
    $obj =& get_instance();
    require_once APPPATH . 'libraries/geoip.php';
    $gi = geoip_open($obj->config->item('path_to_files') . 'GeoIP.dat', GEOIP_STANDARD);
    return geoip_country_name_by_addr($gi, $ip_address);
}
开发者ID:sabril-2t,项目名称:Open-Ad-Server,代码行数:12,代码来源:location_helper.php


示例3: index

 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');
 }
开发者ID:adzzie,项目名称:hotel,代码行数:27,代码来源:cpagegallery.php


示例4: plugin_geoip_flag

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);
}
开发者ID:phill104,项目名称:branches,代码行数:27,代码来源:codebase.php


示例5: getGeoIpLocation

 /**
  * 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;
 }
开发者ID:xiaoguizhidao,项目名称:MyMagento,代码行数:34,代码来源:Geoip.php


示例6: readM

 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');
 }
开发者ID:adzzie,项目名称:hotel,代码行数:28,代码来源:cpagenews.php


示例7: country_name

 /**
  * @param null $address
  * @return bool|string
  */
 public function country_name($address = null)
 {
     $countryName = geoip_country_name_by_addr($this->gi, $address);
     if ($countryName == null) {
         $countryName = 'Unknown';
     }
     return $countryName;
 }
开发者ID:sh1omi,项目名称:xlrstats-web-v3,代码行数:12,代码来源:GeoIPComponent.php


示例8: __construct

 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;
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:54,代码来源:cart_model.php


示例9: getCountry

 function getCountry($ip)
 {
     if (strpos($ip, ":") === false) {
         $gi = geoip_open($this->ipv4DatabasePath, GEOIP_STANDARD);
         $country = geoip_country_name_by_addr($gi, $ip);
     } else {
         $gi = geoip_open($this->ipv6DatabasePath, GEOIP_STANDARD);
         $country = geoip_country_name_by_addr_v6($gi, $ip);
     }
     geoip_close($gi);
     return $country;
 }
开发者ID:JS-Apps-Team-Sazerac,项目名称:Sazerac-Analytics,代码行数:12,代码来源:VisitorInfoGrabber.php


示例10: index

 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);
 }
开发者ID:adzzie,项目名称:hotel,代码行数:52,代码来源:cpagehome.php


示例11: index

 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);
 }
开发者ID:adzzie,项目名称:hotel,代码行数:15,代码来源:cpagewelcome.php


示例12: arprice_Shortcode

 function arprice_Shortcode($atts)
 {
     global $wpdb, $arprice_analytics;
     if (!extension_loaded('geoip')) {
         include PRICINGTABLE_INC_DIR . '/geoip.inc';
     }
     extract(shortcode_atts(array('id' => '1'), $atts));
     $table_id = $atts['id'];
     if ($table_id == "") {
         $table_id = 1;
     }
     $result = $wpdb->get_row($wpdb->prepare("select * from " . $wpdb->prefix . "arp_arprice where ID=%d", $table_id));
     $pricetable_name = $result->table_name;
     if ($pricetable_name == "") {
         return "Please Select Valid Pricing Table";
     } else {
         if ($result->status != 'published') {
             return "Please Select Valid Pricing Table";
         }
     }
     $file_url = PRICINGTABLE_INC_DIR . "/GeoIP.dat";
     if (!extension_loaded('geoip')) {
         $gi = geoip_open($file_url, GEOIP_STANDARD);
         $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     } else {
         $country_name = "";
     }
     $d = date("Y/m/d H:i:s");
     $brow = $_SERVER['HTTP_USER_AGENT'];
     $pageurl = $_SERVER['REQUEST_URI'];
     $ref = $_SERVER['HTTP_REFERER'];
     $ip = $_SERVER['REMOTE_ADDR'];
     $ses_id = session_id();
     $browser = $arprice_analytics->getBrowser($brow);
     $sel = $wpdb->get_row($wpdb->prepare("SELECT tracking_id, session_id FROM " . $wpdb->prefix . "arp_arprice_analytics WHERE pricing_table_id = " . $table_id . " AND session_id = %s", $ses_id));
     if ($sel) {
         require_once PRICINGTABLE_DIR . '/core/views/arprice_front.php';
         $contents = arp_get_pricing_table_string($table_id);
         $contents = apply_filters('arp_predisplay_pricingtable', $contents, $table_id);
         return $contents;
     }
     $res = $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "arp_arprice_analytics (pricing_table_id,browser_info,browser_name,browser_version,page_url,referer,ip_address,country_name,session_id,added_date ) VALUES (%d,%s,%s,%s,%s,%s,%s,%s,%s,%s)", $table_id, $brow, $browser['browser_name'], $browser['version'], $pageurl, $ref, $ip, $country_name, $ses_id, $d));
     require_once PRICINGTABLE_DIR . '/core/views/arprice_front.php';
     $contents = arp_get_pricing_table_string($table_id);
     $contents = apply_filters('arp_predisplay_pricingtable', $contents, $table_id);
     return $contents;
 }
开发者ID:prosenjit-itobuz,项目名称:upages,代码行数:47,代码来源:class.arprice_analytics.php


示例13: country_flag

function country_flag($ip)
{
    global $geoip_path;
    if (file_exists($geoip_path . "GeoIP.dat")) {
        $geocountry = $geoip_path . "GeoIP.dat";
        $gi = geoip_open($geocountry, GEOIP_STANDARD);
        $countryid = strtolower(geoip_country_code_by_addr($gi, $ip));
        $country = geoip_country_name_by_addr($gi, $ip);
        if (!is_null($countryid) and $countryid != "") {
            $flag = "<img src=\"images/flags/" . $countryid . ".gif\" title=\"" . $country . "\" alt=\"" . $country . "\">";
        } else {
            $flag = "<img width=\"16\" height=\"11\" src=\"images/spacer.gif\" title=\"" . $country . "\" alt=\"" . $country . "\">";
        }
        geoip_close($gi);
        return $flag;
    }
}
开发者ID:redrock,项目名称:xlrstats-web-v2,代码行数:17,代码来源:func-awardlogic.php


示例14: location_update

 /**
  * Update Visitor info to include country and city
  */
 public static function location_update()
 {
     $db = JFactory::getDbo();
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (file_exists(JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geolitecity.dat')) {
         if (filesize(JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geolitecity.dat') != 0) {
             if (!function_exists('GeoIP_record_by_addr')) {
                 include JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geoipcity.inc';
             }
             $geoip = geoip_open(JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geolitecity.dat', GEOIP_STANDARD);
             $query = $db->getQuery(true);
             $query->select('id, ip');
             $query->from($db->quoteName('#__cwtraffic'));
             $query->where('country_code = "" OR country_code is null');
             $db->setQuery($query);
             foreach ($db->loadObjectList() as $row) {
                 $country_code = strtolower(geoip_country_code_by_addr($geoip, $row->ip));
                 $country_name = geoip_country_name_by_addr($geoip, $row->ip);
                 $addr = GeoIP_record_by_addr($geoip, $row->ip);
                 if (!empty($addr)) {
                     $city = $addr->city;
                 }
                 if ($country_code != '' && $country_name != '') {
                     $query = $db->getQuery(true);
                     $query->update('#__cwtraffic');
                     $query->set('country_code = ' . $db->quote($country_code));
                     $query->set('country_name = ' . $db->quote($country_name));
                     $query->set('city = ' . $db->quote($city));
                     $query->where('id = ' . $row->id);
                     $db->setQuery($query);
                     $db->query();
                 }
             }
             geoip_close($geoip);
             $query = $db->getQuery(true);
             $query->update('#__cwtraffic');
             $query->set('city = NULL');
             $query->where('city = ""');
             $db->setQuery($query);
             $db->query();
         }
     }
     return;
 }
开发者ID:Rikisha,项目名称:proj,代码行数:49,代码来源:celtawebtraffic.php


示例15: getCountryData

 /**
  * Find users country.
  *
  * Attempt to get the country the user is from.  returns unknown if its not
  * able to match something.
  *
  * @param string $ipAddress the ip address to check against
  * @param bool $code get the country code or not
  *
  * @return array the data requested
  */
 public function getCountryData($ipAddress = null, $code = false)
 {
     if (!$ipAddress) {
         $ipAddress = $this->__getIpAddress();
     }
     $data = $this->__loadFile();
     if (!$data) {
         return $this->__emptyCountry;
     }
     $return = array('country' => geoip_country_name_by_addr($data, $ipAddress), 'country_code' => geoip_country_code_by_addr($data, $ipAddress), 'country_id' => geoip_country_id_by_addr($data, $ipAddress), 'city' => null, 'ip_address' => $ipAddress);
     if (empty($return['country']) && $ipAddress == '127.0.0.1') {
         $return['country'] = 'localhost';
         $return['city'] = 'localhost';
     }
     geoip_close($data);
     unset($data);
     return $return;
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:29,代码来源:IpLocation.php


示例16: index

 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' => 'reservasi');
     $this->model_visit->add($visit);
     $data['title'] = "reservation";
     $data['msg'] = "";
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['gambar'] = $this->model_gambar->getGmb();
     $this->load->view('user/vheader', $data);
     $this->load->view('user/vmenu');
     $this->load->view('user/frontend/page/vreservation');
     $this->load->view('user/vfooter');
 }
开发者ID:adzzie,项目名称:hotel,代码行数:21,代码来源:cpagereservation.php


示例17: index

 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' => 'paket');
     $this->model_visit->add($visit);
     $data['title'] = "packages tour";
     $bhs = $this->session->userdata('EN');
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['wisata'] = $this->model_pt->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/vpack');
     $this->load->view('user/vfooter');
 }
开发者ID:adzzie,项目名称:hotel,代码行数:22,代码来源:cpagepack.php


示例18: getCountryData

 /**
  * Find users country.
  *
  * Attempt to get the country the user is from.  returns unknown if its not
  * able to match something.
  */
 public function getCountryData($ipAddress = null, $code = false)
 {
     if (!$ipAddress) {
         $ipAddress = $this->RequestHandler->getClientIP();
         if (!$ipAddress) {
             return $this->__emptyCountry;
         }
     }
     App::import('Lib', 'Libs.Geoip/inc.php');
     if (!is_file($this->countryDataFile)) {
         return $this->__emptyCountry;
     }
     $data = geoip_open($this->countryDataFile, GEOIP_STANDARD);
     $country = geoip_country_name_by_addr($data, $ipAddress);
     $country = empty($country) ? 'Unknown' : $country;
     if ($code) {
         $code = geoip_country_code_by_addr($data, $ipAddress);
         $code = empty($code) ? 'Unknown' : $code;
     }
     geoip_close($data);
     return array('country' => $country, 'country_code' => $code);
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:28,代码来源:GeoLocationComponent.php


示例19: player_short

function player_short($playerid, $dbID = false)
{
    global $coddb;
    global $separatorline;
    global $t;
    // table names from config
    global $aliashide_level;
    global $use_localtime;
    global $geoip_path;
    global $groupbits;
    global $limitplayerstats;
    global $sig;
    global $maxdays;
    global $minkills;
    global $minrounds;
    global $exclude_ban;
    global $myplayerid;
    global $func;
    global $currentconfignumber;
    global $text;
    if ($dbID == false) {
        $query = "SELECT {$t['b3_clients']}.name as clientname, {$t['b3_clients']}.time_add, {$t['b3_clients']}.ip,\n          {$t['b3_clients']}.id as databaseid, {$t['b3_clients']}.time_edit, {$t['b3_clients']}.connections,\n          {$t['b3_clients']}.group_bits,\n          {$t['players']}.*\n          FROM {$t['b3_clients']}, {$t['players']}\n          WHERE {$t['players']}.id = {$playerid}\n          AND ({$t['b3_clients']}.id = {$t['players']}.client_id)\n          AND hide = 0\n          LIMIT 1";
    } else {
        $query = "SELECT {$t['b3_clients']}.name as clientname, {$t['b3_clients']}.time_add, {$t['b3_clients']}.ip,\n              {$t['b3_clients']}.id as databaseid, {$t['b3_clients']}.time_edit, {$t['b3_clients']}.connections,\n              {$t['b3_clients']}.group_bits,\n              {$t['players']}.*\n              FROM {$t['b3_clients']}, {$t['players']}\n              WHERE {$t['players']}.client_id = {$playerid}\n              AND ({$t['b3_clients']}.id = {$t['players']}.client_id)\n              AND hide = 0\n              LIMIT 1";
    }
    $result = $coddb->sql_query($query);
    $row = $coddb->sql_fetchrow($result);
    if ($row == false) {
        return;
    }
    $databaseid = $row['databaseid'];
    $playerskill = $row['skill'];
    $playerid = $row['id'];
    $link = baselink();
    $current_time = time();
    $timelimit = $maxdays * 60 * 60 * 24;
    $coddb->sql_query("START TRANSACTION");
    $coddb->sql_query("BEGIN");
    $coddb->sql_query("SET @place = 0");
    $query4 = "select * from (\n               SELECT @place := @place + 1 AS place, {$t['players']}.id\n\n               FROM {$t['players']}, {$t['b3_clients']}\n            WHERE {$t['b3_clients']}.id = {$t['players']}.client_id\n                AND (({$t['players']}.kills > {$minkills})\n                    OR ({$t['players']}.rounds > {$minrounds}))\n                AND ({$t['players']}.hide = 0)\n                AND ({$current_time} - {$t['b3_clients']}.time_edit  < {$timelimit})";
    if ($exclude_ban) {
        $query4 .= " AND {$t['b3_clients']}.id NOT IN (\n        SELECT distinct(target.id)\n        FROM {$t['b3_penalties']} as penalties, {$t['b3_clients']} as target\n        WHERE (penalties.type = 'Ban' OR penalties.type = 'TempBan')\n        AND inactive = 0\n        AND penalties.client_id = target.id\n        AND ( penalties.time_expire = -1 OR penalties.time_expire > UNIX_TIMESTAMP(NOW()) )\n      )";
    }
    $query4 .= "     ORDER BY {$t['players']}.skill DESC\n            ) derivated_table\n            where id = {$playerid}";
    $result4 = $coddb->sql_query($query4);
    $row4 = $coddb->sql_fetchrow($result4);
    $coddb->sql_query("ROLLBACK");
    $playerrank = $row4['place'] ? $row4['place'] : "n.a.";
    /*if ($row4['place'] == "")
        $playerrank = "n.a.";
      else 
        $playerrank = $row4['place'];*/
    if ($playerrank == "n.a." && ($row['kills'] <= $minkills || $row['rounds'] <= $minrounds || $current_time - $row4['time_edit'] >= $timelimit)) {
        //$playerrankdef = $text["playerrankdefinactive"];
        $playerrankdef = $text["playerrankdef"];
        if ($row['kills'] <= $minkills) {
            $playerrankdef .= $text["playerrankdefa"];
        }
        if ($row['rounds'] <= $minrounds) {
            $playerrankdef .= $text["playerrankdefb"];
        }
        if ($current_time - $row4['time_edit'] < $timelimit) {
            $playerrankdef .= $text["playerrankdefc"];
        }
    } elseif ($playerrank == 1) {
        $playerrankdef = $text["congrats"];
    } else {
        $playerrankdef = $text["trytobetop"];
    }
    if (file_exists($geoip_path . "GeoIP.dat")) {
        $geocountry = $geoip_path . "GeoIP.dat";
        $ip = $row['ip'];
        $gi = geoip_open($geocountry, GEOIP_STANDARD);
        $countryid = strtolower(geoip_country_code_by_addr($gi, $ip));
        $country = geoip_country_name_by_addr($gi, $ip);
        if (!is_null($countryid) and $countryid != "") {
            $flag = "<img src=\"images/flags/" . $countryid . ".gif\" title=\"" . $country . "\" alt=\"" . $country . "\">";
        } else {
            $flag = "<img width=\"16\" height=\"11\" src=\"images/spacer.gif\" title=\"" . $country . "\" alt=\"" . $country . "\">";
        }
        geoip_close($gi);
    }
    echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"outertable\">";
    echo "  <tr>";
    echo "    <td width=\"300\" valign=\"top\" class=\"innertable\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"innertable\">";
    echo "      <tr>";
    echo "        <td class=\"attention\">" . $text["topskillrank"] . "</td>";
    echo "        <td class=\"attention\" title=\"{$playerrankdef}\">{$playerrank}</td>";
    echo "      </tr>";
    echo "      <tr>";
    $temp = sprintf("%.1f", $row['skill']);
    echo "        <td class=\"attention\">" . $text["skill"] . "</td>";
    echo "        <td class=\"attention\" title=\"" . $text["descskill"] . "\">{$temp}</td>";
    echo "      </tr>";
    echo "     <tr><td colspan=\"2\" class=\"outertable\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" alt=\"\"></td></tr>";
    echo "      <tr>";
    echo "        <td>" . $text["kills"] . "</td>";
    echo "        <td>{$row['kills']}</td>";
    echo "      </tr>";
    echo "      <tr>";
//.........这里部分代码省略.........
开发者ID:redrock,项目名称:xlrstats-web-v2,代码行数:101,代码来源:func-sectionlogic.php


示例20: host_row_basic

function host_row_basic($host, $conn, $criterias, $has_criterias, $networks, $hosts_ips, $i)
{
    require_once "classes/Sensor.inc";
    $color = $i % 2 == 0 ? "#F2F2F2" : "#FFFFFF";
    $ip = $host->get_ip();
    $host_name = $ip != $host->get_hostname() ? $host->get_hostname() . " ({$ip})" : $ip;
    $gi = geoip_open("/usr/share/geoip/GeoIP.dat", GEOIP_STANDARD);
    $country = strtolower(geoip_country_code_by_addr($gi, $ip));
    $country_name = geoip_country_name_by_addr($gi, $ip);
    geoip_close($gi);
    if ($country) {
        $country_img = " <img src=\"../pixmaps/flags/" . $country . ".png\" alt=\"{$country_name}\" title=\"{$country_name}\">";
    } else {
        $country_img = "";
    }
    //$homelan = (Net::isIpInNet($ip, $networks) || in_array($ip, $hosts_ips)) ? " <a href=\"javascript:;\" class=\"scriptinfo\" style=\"text-decoration:none\" ip=\"".$ip."\"><img src=\"../forensics/images/homelan.png\" border=0></a>" : "";
    // Network
    require_once 'classes/Net.inc';
    $netname = Net::GetClosestNet($conn, $ip);
    if ($netname != false) {
        $ips = Net::get_ips_by_name($conn, $netname);
        $net = "<b>{$netname}</b> ({$ips})";
    } else {
        $net = "<i>" . _("Asset Unknown") . "</i>";
    }
    // Inventory
    $os_data = Host_os::get_ip_data($conn, $ip);
    if ($os_data["os"] != "") {
        $os = $os_data["os"];
        $os_pixmap = Host_os::get_os_pixmap($conn, $ip);
    } else {
        $os = _("OS Unknown");
        $os_pixmap = "";
    }
    require_once 'classes/Host_services.inc';
    $services = Host_services::get_ip_data($conn, $ip, 0);
    $services_arr = array();
    foreach ($services as $serv) {
        $services_arr[$serv['service']]++;
    }
    // Vulnerabilities
    require_once 'classes/Status.inc';
    list($vuln_list, $num_vuln, $vuln_highrisk, $vuln_risknum) = Status::get_vul_events($conn, $ip);
    $vuln_list_str = "";
    $v = 0;
    foreach ($vuln_list as $vuln) {
        if ($v++ < 20) {
            $vuln_list_str .= $vuln['name'] . "<br>";
        }
    }
    $vuln_list_str = str_replace("\"", "", $vuln_list_str);
    $vuln_caption = $num_vuln > 0 ? ' class="greybox_caption" data="' . $vuln_list_str . '"' : ' class="greybox"';
    // Incidents
    $sql = "SELECT count(*) as num FROM alarm WHERE src_ip=INET_ATON(\"{$ip}\") OR dst_ip=INET_ATON(\"{$ip}\")";
    if (!($rs =& $conn->Execute($sql))) {
        $num_alarms = _("Error in Query: {$sql}");
    } else {
        if (!$rs->EOF) {
            $num_alarms = $rs->fields['num'];
        }
    }
    if ($num_alarms > 0) {
        $alarm_link = '<a href="../control_panel/alarm_console.php?&hide_closed=1&hmenu=Alarms&smenu=Alarms&src_ip=' . $ip . '&dst_ip=' . $ip . '" target="main"><b>' . $num_alarms . '</b></a>';
    } else {
        $alarm_link = '<b>' . $num_alarms . '</b>';
    }
    $sql = "SELECT count(*) as num FROM incident_alarm WHERE src_ips=\"{$ip}\" OR dst_ips=\"{$ip}\"";
    if (!($rs =& $conn->Execute($sql))) {
        $num_tickets = _("Error in Query: {$sql}");
    } else {
        if (!$rs->EOF) {
            $num_tickets = $rs->fields['num'];
        }
    }
    if ($num_tickets > 0) {
        $tickets_link = '<a href="../incidents/index.php?status=Open&hmenu=Tickets&smenu=Tickets&with_text=' . $ip . '" target="main"><b>' . $num_tickets . '</b></a>';
    } else {
        $tickets_link = '<b>' . $num_tickets . '</b>';
    }
    // Events
    list($sim_events, $sim_foundrows, $sim_highrisk, $sim_risknum, $sim_date) = Status::get_SIM_light($ip, $ip);
    if ($sim_foundrows > 0) {
        $sim_link = '<a href="../forensics/base_qry_main.php?&num_result_rows=-1&submit=Query+DB&current_view=-1&sort_order=time_d&ip=' . $ip . '&date_range=week&hmenu=Forensics&smenu=Forensics" target="main"><b>' . $sim_foundrows . '</b></a>';
    } else {
        $sim_link = '<b>' . $sim_foundrows . '</b>';
    }
    //
    $txt_tmp1 = _('Events in the SIEM');
    $txt_tmp2 = _('Events in the logger');
    if ($_SESSION['inventory_search']['date_from'] != "" && $_SESSION['inventory_search']['date_from'] != '1700-01-01') {
        $start_week = $_SESSION['inventory_search']['date_from'];
    } else {
        $start_week = strftime("%Y-%m-%d", time() - 24 * 60 * 60 * 1);
    }
    if ($_SESSION['inventory_search']['date_to'] != "" && $_SESSION['inventory_search']['date_to'] != '3000-01-01') {
        $end = $_SESSION['inventory_search']['date_to'];
    } else {
        $end = strftime("%Y-%m-%d", time());
    }
    if ($start_week == strftime("%Y-%m-%d", time() - 24 * 60 * 60 * 1) && $end == strftime("%Y-%m-%d", time())) {
//.........这里部分代码省略.........
开发者ID:jhbsz,项目名称:ossimTest,代码行数:101,代码来源:functions.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP geoip_country_name_by_name函数代码示例发布时间:2022-05-15
下一篇:
PHP geoip_country_id_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