public static function resolve($url) { // Reset IP address and transport layer delete_site_option(AI1WM_URL_IP); delete_site_option(AI1WM_URL_TRANSPORT); // Set secret $secret_key = get_site_option(AI1WM_SECRET_KEY, false, false); // Set scheme $scheme = parse_url($url, PHP_URL_SCHEME); // Set host name $host = parse_url($url, PHP_URL_HOST); // Set server IP address if (!empty($_SERVER['SERVER_ADDR'])) { $ip = $_SERVER['SERVER_ADDR']; } else { if (!empty($_SERVER['LOCAL_ADDR'])) { $ip = $_SERVER['LOCAL_ADDR']; } else { $ip = '127.0.0.1'; } } // Set domain IP address $domain = gethostbyname($host); // HTTP resolve foreach (array('ai1wm', 'curl') as $transport) { foreach (array($ip, $domain, $host) as $ip) { // Set transport Ai1wm_Http::$transports = array($transport); // HTTP request Ai1wm_Http::request($url, $ip, array('secret_key' => $secret_key, 'url_ip' => $ip, 'url_transport' => $transport)); // HTTP response for ($i = 0; $i < 5; $i++, sleep(1)) { // Clear WP notoptions cache wp_cache_delete('notoptions', 'options'); // Clear WP options cache wp_cache_flush(); // Is valid transport layer? if (get_site_option(AI1WM_URL_IP, false, false) && get_site_option(AI1WM_URL_TRANSPORT, false, false)) { return; } } } } // No connection throw new Ai1wm_Http_Exception(__('There was a problem while reaching your server.<br />' . 'Contact <a href="mailto:support@servmask.com">support@servmask.com</a> for assistance.', AI1WM_PLUGIN_NAME)); }