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; }
function mymail_ip2City($ip = '', $get = NULL) { if (!mymail_option('trackcities')) { return 'unknown'; } if (empty($ip)) { $ip = mymail_get_ip(); } require_once MYMAIL_DIR . '/classes/libs/Ip2City.php'; $i = new Ip2City(); $code = $i->get($ip, $get); return $code ? $code : 'unknown'; }
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; }