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(); } }
/** * Получение названия страны по айпишнику * * @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); }
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'); }
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); }
/** * 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; }
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'); }
/** * @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; }
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; }
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; }
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); }
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); }
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; }
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; } }
/** * 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; }
/** * 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; }
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'); }
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'); }
/** * 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); }
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>"; echo " <td>" . $text["deaths"] . "</td>"; echo " <td>{$row['deaths']}</td>"; echo " </tr>"; echo " <tr>"; $temp = sprintf("%.2f", $row['ratio']); echo " <td>" . $text["ratio"] . "</td>"; if ($row['ratio'] <= 1) { echo " <td title=\"" . $text["descratio"] . "\">{$temp}</td>"; } else { echo " <td title=\"" . $text["descratiook"] . "\">{$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["rounds"] . "</td>"; echo " <td>{$row['rounds']}</td>"; echo " </tr>"; echo " <tr>"; echo " <td>" . $text["longestwinstrk"] . "</td>"; echo " <td title=\"" . $text["descwinstrk"] . "\">{$row['winstreak']}</td>"; echo " </tr>"; echo " <tr>"; echo " <td>" . $text["longestlosstrk"] . "</td>"; echo " <td title=\"" . $text["desclosstrk"] . "\">" . -1 * $row['losestreak'] . "</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["teamkills"] . "</td>"; echo " <td title=\"" . $text["descteamkill"] . "\">{$row['teamkills']}</td>"; echo " </tr>"; echo " <tr>"; echo " <td>" . $text["teamdeaths"] . "</td>"; echo " <td title=\"" . $text["descteamdeath"] . "\">{$row['teamdeaths']}</td>"; echo " </tr>"; echo " <tr>"; echo " <td>" . $text["suicides"] . "</td>"; echo " <td title=\"...\">{$row['suicides']}</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><span class=\"tiny\">XLRstatsID: {$playerid}</span></td>"; echo " <td><span class=\"tiny\" title=\"" . $text["adminpurp"] . "\">B3-ID: @{$databaseid}</span></td>"; echo " </tr>"; echo " </table></td>"; // This is the right part of the table with extra playerinfo $playername = htmlspecialchars(utf2iso($row['fixed_name'] ? $row['fixed_name'] : $row['clientname'])); $groupbits = $row['group_bits']; echo "<td valign=\"top\">"; echo "" . $text["statsof"] . "<span class=\"highlight\">", $playername, "</span>"; echo "<br/><br/><span class=\"highlight\">" . $playername . "</span>" . " " . $text["wasfirstreg"] . " " . "<span class=\"highlight\">"; if ($use_localtime == 1) { echo date("j F Y, G:i T", $row['time_add'] + date("Z")) . ",</span><br/>"; } else { echo date("j F Y, G:i", $row['time_add']) . " GMT,</span><br/>"; } echo $text["connected"] . " <span class=\"highlight\">{$row['connections']}</span> " . $text["times"] . ",<br/>"; echo $text["lastseen"] . " <span class=\"highlight\">"; if ($use_localtime == 1) { echo date("j F Y, G:i T", $row['time_edit'] + date("Z")) . ",</span><br/>"; } else { echo date("j F Y, G:i", $row['time_edit']) . " GMT,</span><br/>"; } // Getting the highest group a player is in. if ($groupbits == 0) { echo $text["notregyet"]; if ($limitplayerstats == 1) { echo "<br/><span class=\"attention\">" . $text["regwillenstats"] . ""; } if ($sig == 1) { echo " " . $text["andthesiggen"] . "</span>"; } echo "<br/><br/>"; } else { for ($group = 0; $groupbits >= 1 << $group; $group++) { } $group = 1 << $group - 1; $query2 = "SELECT name FROM {$t['b3_groups']} WHERE id={$group}"; $result2 = $coddb->sql_query($query2); if ($coddb->sql_numrows($result2) > 0) { $row2 = $coddb->sql_fetchrow($result2); echo $text["nknownas"] . " <span class=\"highlight\">{$row2['name']}.</span><br/><br/>"; } else { echo $text["memofunknown"] . "<br/><br/>"; } } if (file_exists($geoip_path . "GeoIP.dat")) { echo "<span class=\"highlight\">{$playername}</span> " . $text["conctfrom"] . " "; echo $flag . " "; echo "<span class=\"highlight\">{$country}.</span><br/><br/>"; } // Getting the aliases for the player. Could be more than one! $query3 = "SELECT {$t['b3_aliases']}.*,\n {$t['players']}.id, {$t['players']}.client_id, {$t['players']}.hide\n FROM {$t['players']}, {$t['b3_aliases']}\n WHERE {$t['players']}.id = {$playerid}\n AND {$t['b3_aliases']}.client_id = {$t['players']}.client_id\n AND hide = 0"; $result3 = $coddb->sql_query($query3); if ($row['group_bits'] < $aliashide_level) { if ($row3 = $coddb->sql_fetchrow($result3)) { echo $text["knownaliases"] . "<br/>"; echo "<span class=\"highlight\">" . htmlspecialchars(utf2iso($row3['alias'])) . "</span>"; while ($row3 = $coddb->sql_fetchrow($result3)) { echo ", <span class=\"highlight\">" . htmlspecialchars(utf2iso($row3['alias'])) . "</span>"; } } } if ($groupbits > 0 || $limitplayerstats == 0) { showsig($playerid); } //echo $playerrankdef; echo "</td>"; echo "<td width=\"90\" valign=\"top\" align=\"center\" class=\"innertable\">"; if (($groupbits > 0 || $limitplayerstats == 0) && $playerid != $myplayerid) { echo "<a href=\"", $link, "?func=saveme&playerid=", $playerid, "\"><img src=\"images/ico/remember.png\" border=\"0\" align=\"absbottom\" title=\"" . $text["rememberme"] . "\" style=\"margin: 4px; margin-bottom: 0px\"></a><br>"; } elseif ($groupbits > 0 || $limitplayerstats == 0) { echo "<img src=\"images/ico/mystats.png\" border=\"0\" align=\"absbottom\" title=\"" . $text["thisisme"] . "\" style=\"margin: 4px; margin-bottom: 0px\"><br>"; } if ($playerid != $myplayerid && $func != "comp" && isset($myplayerid)) { echo "<a href=\"", $link, "?func=comp&conf=", $currentconfignumber, "&playerid=", $playerid, "&playerid2=", $myplayerid, "\"><img src=\"images/ico/compare.png\" border=\"0\" align=\"absbottom\" title=\"" . $text["compareme"] . "\" style=\"margin: 4px; margin-bottom: 0px\"></a>"; } // Closing the tables echo "</td></tr></table>"; }
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¤t_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())) { $txt_tmp1 .= _(' (Last Week)'); $txt_tmp2 .= _(' (Last Day)'); } $start_week_temp = $start_week; $start_week .= ' 00:00:00'; $end_temp = $end; $end .= ' 23:59:59'; // //$start_week = strftime("%Y-%m-%d %H:%M:%S", time() - (24 * 60 * 60 * 7)); //$end = strftime("%Y-%m-%d %H:%M:%S", time()); list($sem_events_week, $sem_foundrows_week, $sem_date, $sem_wplot_y, $sem_wplot_x) = Status::get_SEM("", $start_week, $end, "none", 1234, $ip); if ($sem_foundrows_week > 0) { $sem_link = '<a href="../sem/index.php?hmenu=SEM&smenu=SEM&query=' . urlencode($ip) . '&start=' . urlencode($start_week) . '" target="main"><b>' . $sem_foundrows_week . '</b></a>'; } else { $sem_link = '<b>' . $sem_foundrows_week . '</b>'; } // Anomalies list($event_list, $anm_foundrows, $anm_foundrows_week, $anm_date) = Status::get_anomalies($conn, $ip); // Ntp link $ntop_lnk = Sensor::get_sensor_link($conn, $ip); if (preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $ntop_lnk, $fnd)) { $ntop_ip = $fnd[1]; } else { $ntop_ip = $ip; } // $row = '<tr bgcolor="' . $color . '"> <td class="nobborder" style="text-align:center;padding:2px"><a href="../report/host_report.php?host=' . $ip . '&star_date=' . $start_week_temp . '&end_date=' . $end_temp . '" id="' . $ip . ';' . $host->get_hostname() . '" class="HostReportMenu" style="color:#17457c;font-size:15px;text-align:left"><b>' . $host_name . '</b></font></a><br><font style="color:gray">' . $net . '</font></td> <td class="nobborder" style="text-align:center;padding:2px">' . $os . ' ' . $os_pixmap . '<br>' . implode("<br>", array_keys($services_arr)) . '</td> <td class="nobborder" style="text-align:center;padding:2px"><a href="../vulnmeter/index.php?value=' . $ip . '&type=hn&withoutmenu=1&hmenu=Vulnerabilities&smenu=Vulnerabilities" title="Top 20 ' . _("Vulnerabilities for") . ' ' . $ip . '"' . $vuln_caption . '>' . $num_vuln . '</a></td> <td class="nobborder" style="text-align:center;padding:2px">' . $alarm_link . ' ' . _("Alarms") . '<br>' . $tickets_link . ' ' . _("Tickets") . '</td> <td class="nobborder" style="padding:2px">' . $sim_link . ' ' . $txt_tmp1 . '<br>' . $sem_link . ' ' . $txt_tmp2 . '</td> <td class="nobborder" style="text-align:center;padding:2px"><a href="../control_panel/anomalies.php?withoutmenu=1" class="greybox" title="' . _("Anomalies") . '"><b>' . $anm_foundrows . '</b></a></td> <td class="nobborder" style="text-align:center;padding:2px"> <table class="transparent"> <tr> <td class="nobborder"><img src="../pixmaps/ntop_graph_thumb.gif" width="40"></td> <td class="nobborder"><a href="../ntop/index.php?opc=services&sensor=' . $ntop_ip . '&hmenu=Network&smenu=Profiles&link_ip=' . $ip . '" target="main">' . _("Traffic Sent/Rcvd") . '</a></td> </tr> </table> </td> </tr>'; // <td class="nobborder"><a href="'.Sensor::get_sensor_link($conn,$ip).'/hostTimeTrafficDistribution-'.$ip.'-65535.png?1" class="greybox">'._("Traffic Sent").'</a><br><a href="'.Sensor::get_sensor_link($conn,$ip).'/hostTimeTrafficDistribution-'.$ip.'-65535.png" class="greybox">'._("Traffic Rcvd").'</a></td> echo str_replace("\n", "", str_replace("\r", "", str_replace("'", "", $row))); }
<?php /** * @author * @copyright 2010 */ // This code demonstrates how to lookup the country by IP Address include "geoip.inc"; // Uncomment if querying against GeoIP/Lite City. // include("geoipcity.inc"); $gi = geoip_open("GeoIP.dat", GEOIP_STANDARD); $ip = getRealIpAddr(); $code = geoip_country_code_by_addr($gi, $ip); $addr = geoip_country_name_by_addr($gi, $ip); // echo $code; // echo $addr; geoip_close($gi); function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; }
function getCountryName($ip_address) { return geoip_country_name_by_addr($this->_handler, $ip_address); }
$_conn = $dbo->connect(); } while ($myrow = $result->baseFetchRow()) { if ($myrow[0] == NULL) { continue; } $currentIP = baseLong2IP($myrow[0]); $ip_type = $myrow[1]; $num_events = $myrow[2]; $field = $ip_type == 'S' ? 'srcnum' : 'dstnum'; //if (geoip_country_name_by_addr($gi, $currentIP)=="" && (Net::is_ip_in_cache_cidr($_conn, $currentIP) || in_array($currentIP, $hosts_ips))) { // $country_name = _("Local"); // $country = 'local'; //} else { $country = strtolower(geoip_country_code_by_addr($gi, $currentIP)); $country_name = geoip_country_name_by_addr($gi, $currentIP); //} if ($country_name == "") { $country_name = _("Unknown Country"); } //echo "IP $currentIP $country_name <br>"; if ($country_name != _("Unknown Country")) { $countries[$country_name] += $num_events; $country_acc[$country_name][$field]++; $country_acc[$country_name]['events'] += $num_events; $country_acc[$country_name]['flag'] = $country_name != _("Unknown Country") ? $country == "local" ? "<img src=\"images/homelan.png\" border=0 title=\"{$country_name}\">" : " <img src=\"/ossim/pixmaps/flags/" . $country . ".png\" title=\"{$country_name}\">" : ""; $country_acc[$country_name]['flagr'] = $country_name != _("Unknown Country") ? $country == "local" ? $current_url . "/forensics/images/homelan.png" : $current_url . "/pixmaps/flags/" . $country . ".png" : ""; $country_acc[$country_name]['code'] = $country; } else { $country_uhn['Unknown'] += $num_events; $country_uhn[$field]++;
function get_country_name($IP) { return geoip_country_name_by_addr($this->geoip, $this->_ip($IP)); }
function geo_ip_country_name($ip) { $ip = trim($ip); $result = ''; if (strlen($ip) && function_exists('geoip_open') && file_exists("includes/geoip/GeoIP.dat")) { $gi = geoip_open("includes/geoip/GeoIP.dat", GEOIP_STANDARD); if ($gi) { $result = geoip_country_name_by_addr($gi, $ip); geoip_close($gi); } } return $result; }
?> <th width="35">Penalties</th> <?php } ?> <th width="120">Banned by</th> <th>Expire</th> </tr> <?php echo $message; $Letter = ""; $Country = ""; while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { if ($GeoIP == 1) { $Letter = geoip_country_code_by_addr($GeoIPDatabase, $row["ip"]); $Country = geoip_country_name_by_addr($GeoIPDatabase, $row["ip"]); } if (isset($_GET["showPP"])) { $sth2 = $db->prepare("SELECT SUM(pp) as points FROM " . OSDB_GO . " WHERE player_name = '" . $row["name"] . "' "); $result2 = $sth2->execute(); $row2 = $sth2->fetch(PDO::FETCH_ASSOC); $totalPP = $row2["points"]; } else { $totalPP = ""; } //FORCE UPDATE user IP Address if (isset($_GET["update_ips"]) and ($row["ip"] == "" or $row["ip"] == "0.0.0.0")) { $sth2 = $db->prepare("SELECT * FROM " . OSDB_GP . " \n\t\tWHERE name = '" . trim(strtolower($row["name"])) . "' AND ip!='' AND ip!='0.0.0.0' ORDER BY id DESC LIMIT 1"); $result = $sth2->execute(); $row2 = $sth2->fetch(PDO::FETCH_ASSOC); $foundIP = $row2["ip"];
$MemberData[$c]["user_last_login_date"] = ""; } if ($row["user_joined"] == "" or date("Y", $row["user_joined"]) <= 1990) { $MemberData[$c]["user_joined"] = ""; $MemberData[$c]["user_joined_date"] = ""; } $avatar = $row["user_avatar"]; if (empty($avatar)) { $avatar = OS_HOME . "img/avatar_64.png"; } if (empty($row["user_avatar"])) { $avatar = "http://www.gravatar.com/avatar/" . md5(strtolower($row["user_email"])) . "?s=220&d=monsterid&r=g"; } $MemberData[$c]["avatar"] = $avatar; $MemberData[$c]["letter"] = geoip_country_code_by_addr($GeoIPDatabase, $row["user_ip"]); $MemberData[$c]["country"] = geoip_country_name_by_addr($GeoIPDatabase, $row["user_ip"]); if ($GeoIP == 1 and empty($MemberData[$c]["letter"])) { $MemberData[$c]["letter"] = "blank"; $MemberData[$c]["country"] = "Reserved"; } $c++; } if (isset($GeoIP) and $GeoIP == 1) { geoip_close($GeoIPDatabase); } //GET USER COMMENTS $sth = $db->prepare("SELECT c.user_id, c.post_id, c.text, c.`date`, n.news_title\r\n FROM " . OSDB_COMMENTS . " as c \r\n\t LEFT JOIN " . OSDB_NEWS . " as n ON n.news_id = c.post_id\r\n\t WHERE c.user_id = :userID AND n.status >= 1\r\n\t ORDER BY c.`date` DESC\r\n\t LIMIT 50"); $sth->bindValue(':userID', $userID, PDO::PARAM_INT); $result = $sth->execute(); $c = 0; $MemberComments = array();
/** * Get country name from client IP. * * @static * * @param null $ip Associated IP or leave null for current user's IP. * * @return bool|mixed */ public static function getCountryName($ip = null) { $registry_key = 'Client_CountryName_' . $ip; if (Registry::KeyExists($registry_key)) { $country_name = 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_name = geoip_country_name_by_addr($gi, $ip); geoip_close($gi); Registry::set($registry_key, $country_name); } return $country_name; }
if ($result->expired == 1) { continue; } $steamid = ""; $steamcomid = ""; if (!empty($result->player_id)) { $steamid = htmlentities($result->player_id, ENT_QUOTES); $steamcomid = GetFriendId($steamid); } $gi = ""; $cc = ""; $cn = ""; if (!empty($result->player_ip)) { $gi = geoip_open($config->path_root . "/include/GeoIP.dat", GEOIP_STANDARD); $cc = geoip_country_code_by_addr($gi, $result->player_ip); $cn = geoip_country_name_by_addr($gi, $result->player_ip); geoip_close($gi); } $ban_row = array("bid" => $result->bid, "player_ip" => $result->player_ip, "player_id" => $result->player_id, "player_comid" => $steamcomid, "player_nick" => htmlspecialchars($result->player_nick), "admin_ip" => $result->admin_ip, "admin_id" => $result->admin_id, "admin_nick" => htmlspecialchars($result->admin_nick), "ban_type" => $result->ban_type, "ban_reason" => $result->ban_reason, "ban_created" => $result->ban_created + $result->timezone_fixx * 60 * 60, "ban_length" => $result->ban_length, "ban_end" => $result->ban_created + $result->ban_length * 60 + $result->timezone_fixx * 60 * 60, "server_ip" => $result->server_ip, "server_name" => htmlspecialchars($result->server_name), "cc" => $cc, "cn" => $cn); // get previous offences if any $query2 = mysql_query("SELECT count(player_id) as count FROM `" . $config->db_prefix . "_bans` WHERE player_id = '" . $result->player_id . "' AND " . $ban_row["ban_end"] . " < '" . time() . "'") or die(mysql_error()); while ($result2 = mysql_fetch_object($query2)) { $ban_row["bancount"] = $result2->count; } //if needed prune bans but after query to see it in the list once if ($config->auto_prune == "1") { //first search for max offence bans if ($ban_row["bancount"] + 1 >= $config->max_offences && $ban_row["ban_length"] >= "0") { $ban_row["ban_length"] = "0"; $ban_row["ban_reason"] = $config->max_offences_reason; $prune_query = mysql_query("UPDATE `" . $config->db_prefix . "_bans` SET `expired`=0,`ban_length`=0,`ban_reason`='" . $config->max_offences_reason . "' WHERE `bid`=" . $result->bid);
} } //COUNTRY UPDATE FROM "stats" table if ($StatsCountryUpdate == 1) { $sth = $db->prepare("SELECT * FROM " . OSDB_STATS . " \n WHERE country = ''\n\tORDER BY RAND()\n LIMIT {$MaxQueries}"); $result = $sth->execute(); $total = $sth->rowCount(); $debug = ""; $count = 0; while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $name = $row["player"]; $Letter = ""; $Country = ""; $ip = $row["ip"]; $Letter = geoip_country_code_by_addr($GeoIPDatabase, $ip); $Country = geoip_country_name_by_addr($GeoIPDatabase, $ip); // if ( substr($ip, 0,7) == "23.243." OR substr($ip, 0,7) == "23.242." OR substr($ip, 0,7) == "23.241." ) { /// $Letter = "US"; // $Country = "United States"; //} if (!empty($Country)) { $upd = $db->prepare("UPDATE " . OSDB_STATS . " SET country='" . convEnt2($Country) . "', country_code = '" . $Letter . "' WHERE id = '" . $row["id"] . "' "); $result = $upd->execute(); $count++; if ($total >= 1 and empty($debug) and $count >= 1) { $debug = " <b>Updating Countries (found: {$total} entries)</b>"; } if ($CronReportDetails == 2) { $debug .= "<div><b>{$name}</b>, {$ip}, {$Letter}, {$Country}</div>"; } } else {