Closed (duplicate)
Project:
SimpleFeed
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Oct 2007 at 15:37 UTC
Updated:
26 Jan 2008 at 23:51 UTC
Should add some URL verification to make sure that URL actually exists, in addition to being well formed...
// if curl exists do a request to see if the url exists out there in cyperspace
$status = array(); // http status
if (function_exists('curl_init') && LINK_CURL_CHECK) {
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // 10 seconds
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
$link_exists = curl_exec($ch);
preg_match('/HTTP\/.* ([0-9]+) .*/', $link_exists, $status);
curl_close($ch);
}
else {
$link_exists = true;
$status[1] = 1;
}
if (!$link_exists || $status[1] == 404) {
form_set_error('url', t('The URL entered appears to be invalid. Please try a different URL.'));
}
Comments
Comment #1
m3avrck commentedduplicate: http://drupal.org/node/203564