function mymail_ip2Country($ip = '', $get = 'code') { if (!mymail_option('trackcountries')) { return 'unknown'; } if (empty($ip)) { $ip = mymail_get_ip(); } require_once MYMAIL_DIR . '/classes/libs/Ip2Country.php'; $i = new Ip2Country(); $code = $i->get($ip, $get); return $code ? $code : 'unknown'; }
/** * Convenience alias function for getting the full country name instead of the country code * * @param null $ipAddress Optinoal * * @return string The name of the country where the IP address is from */ public static function getFull($ipAddress = null) { return Ip2Country::get($ipAddress, 'country_name'); }
?> "></div></td> <td><span class="verybold"><?php echo $this->campaign_data['hardbounces']; ?> </span> <?php echo _n('bounce', 'bounces', $this->campaign_data['hardbounces'], 'mymail'); ?> </td> </tr> </table> <?php if (mymail_option('trackcountries') && $this->campaign_data['countries']) { require_once MYMAIL_DIR . '/classes/libs/Ip2Country.php'; $ip2Country = new Ip2Country(); ?> <div id="countries_wrap"> <div id="countries_map"></div> <a class="zoomout button" title="<?php _e('back to world view', 'mymail'); ?> "> </a> <div id="mapinfo"></div> <div id="countries_table"> <table class="wp-list-table widefat"> <tbody> <?php $k = 0; arsort($this->campaign_data['countries']); foreach ($this->campaign_data['countries'] as $countrycode => $count) {
public function ajax_load_geo_data() { $return['success'] = false; $type = esc_attr($_POST['type']); if ($type == 'country') { require_once MYMAIL_DIR . '/classes/libs/Ip2Country.php'; $ip2Country = new Ip2Country(); $result = $ip2Country->renew(true); if (is_wp_error($result)) { $return['msg'] = __('Couldn\'t load Country DB', 'mymail'); } else { $return['success'] = true; $return['msg'] = __('Country DB successfully loaded!', 'mymail'); $return['path'] = $result; $return['buttontext'] = __('Update Country Database', 'mymail'); mymail_update_option('countries_db', $result); } } else { if ($type == 'city') { require_once MYMAIL_DIR . '/classes/libs/Ip2City.php'; $ip2City = new Ip2City(); $result = $ip2City->renew(true); if (is_wp_error($result)) { $return['msg'] = __('Couldn\'t load City DB', 'mymail'); } else { $return['success'] = true; $return['msg'] = __('City DB successfully loaded!', 'mymail'); $return['path'] = $result; $return['buttontext'] = __('Update City Database', 'mymail'); mymail_update_option('cities_db', $result); } } else { $return['msg'] = 'not allowed'; } } echo json_encode($return); exit; }
public function renew_ips($force = false) { $success = true; if (mymail_option('trackcountries')) { //get new ip database require_once MYMAIL_DIR . '/classes/libs/Ip2Country.php'; $ip2Country = new Ip2Country(); $success = $success && $ip2Country->renew($force); } if (mymail_option('trackcities')) { //get new ip database require_once MYMAIL_DIR . '/classes/libs/Ip2City.php'; $Ip2City = new Ip2City(); $success = $success && $Ip2City->renew($force); } return $success; }
/** * Include IP2Country.php file * and load ip2country.dat file * */ public function loadIp2Country() { include_once Mage::getBaseDir() . '/var/geoip/ip2country/Ip2Country.php'; $ipc = new Ip2Country(Mage::getBaseDir() . '/var/geoip/ip2country/ip2country.dat'); $ipc->preload(); return $ipc; }