I have a script that tests whether a link exists, and I also want it to tell me what type of file is being linked to. So far I can only get it to tell whether a link exists, the part that parses the file doesn't work. This is what I have so far:
<?
$fp = @fopen($link, "r");
if (!$fp) { echo "<p>The link is dead!</p>"; exit;}
else { fclose($fp); echo "<p>The link is working!</p>";}
$fp = @fopen($photo_url, "r");
if (!$fp) { echo "<p>The photo url is dead!</p>"; exit;}
else { fclose($fp); echo "<p>The photo url is working!</p>";}
$allowed_types = array("image/gif", "image/jpeg");
if(!in_array($link,$allowed_types))
{
echo "<p>You can only link to jpegs or gifs, please go back and correct your link</p>";
}
else { echo "<p>You've linked to the right type of file.</p>";}
if (empty($photo_url) || empty($link) || empty($email)){echo "<p>Go back and
fill out the form</p>";}
elseif( !eregi("[a-z0-9]+([_\.-][a-z0-9]+)"
."@([a-z0-9]+([.-][a-z0-9]+))$",
$email, $regs) )
{
echo "Error: '$email' isn't a valid mail address!\n";
}
elseif( gethostbyname($regs[2]) == $regs[2] )
{
echo "Error: Can't find the host '$regs[2]'!
\n";
} else { echo "<p>great your email is valid!</p>";}
?>