function leaflet_more_maps_check_url in Leaflet More Maps 7
A way to test if a URL returns an OK (200) response.
Thanks www.drupal.org/u/n20
Parameters
string $test_url:
Return value
boolean
1 call to leaflet_more_maps_check_url()
- leaflet_more_maps_admin_configure in ./
leaflet_more_maps.admin.inc - Configure leaflet more maps.
File
- ./
leaflet_more_maps.admin.inc, line 148 - Menu callback for Leaflet More Maps admin configuration.
Code
function leaflet_more_maps_check_url($test_url) {
$agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $test_url);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
return $info['http_code'] == 200;
}