function testIpToS() { $this->assertNotEmpty(_ip_to_s('127.0.0.1')); $this->assertEmpty(_ip_to_s('garbage')); }
function _geoip_detect2_add_data_to_cache($data, $ip) { // Don't cache for file access based sources (not worth the effort/time) $sources_not_cachable = apply_filters('geoip2_detect_sources_not_cachable', array('auto', 'manual')); if (in_array($data['extra']['source'], $sources_not_cachable)) { return; } $data['extra']['cached'] = time(); unset($data['maxmind']['queries_remaining']); $ip_s = _ip_to_s($ip); // Do not cache invalid IPs if (!$ip_s) { return; } // Do not cache error lookups (they might be temporary) if (!empty($data['extra']['error'])) { return; } set_transient('geoip_detect_c_' . $ip_s, $data, GEOIP_DETECT_READER_CACHE_TIME); }