Another way to check if the file linked exists ins another function (i think you can use it in other linking, too)
Code:
//this function checks a link at 404 error
function is_404($url) {
$a = parse_url($url);
$sock = fsockopen($a['host'], empty($a['port']) ? 80 : $a['port']);
if(!$sock) {
return true;
} else {
preg_match("'\w+://[^/]+(.*)'", $url, $matches);
fputs($sock, 'HEAD ' . $matches[1] . " HTTP/1.0\r\nHost: " . $a['host'] . "\r\n\r\n");
preg_match("'(\w+)/([^ ]+) (\d+) (.*)'", $data = fread($sock, 4096), $matches);
fclose($sock);
if($matches[3] == '404') {
return true;
} else {
return false;
}
}
}
Then i modified the handle_bbcode_img_match
Code:
// this is only called by handle_bbcode_img
function handle_bbcode_img_match($link)
{
// IMPORTANT - REPLACE THE FOLLOWING 2 VARIALBS WITH YOUR INFORMATION
$img_replacement = "images/misc/button_imagebig.gif"; // This is the button/image that will be displayed instead of the big image.
$img_max_width = 600; // This is the maximum width that an image is allowed to be viewed safely.
$link = strip_smilies(str_replace('\\"', '"', $link));
// remove double spaces -- fixes issues with wordwrap
$link = str_replace(' ', '', $link);
if('!is_404') {
$img_width = @getimagesize($link);
if ($img_width[0] > $img_max_width) {
srand((double)microtime()*1000000);
$number = rand(10,100);
$inp_string = "<a href=\"javascript:toggle_imgview('bigimg".$number."')\"><img src=\"".$img_replacement."\" alt=\"\" border=\"0\" /></a><br />\n";
$inp_string .= "<div style=\"position:absolute;display:none;z-index:1;\" id=\"bigimg".$number."\"><img src=\"".$link."\" border=\"0\" alt=\"\" /></div>";
return $inp_string;
} else {
return '<img src="' . $link . '" border="0" alt="" />';
}
} else {
return '<img src="/cg/images/misc/404.gif" width="150" height="50" border="0" alt="Bitte editieren Sie diesen Link" />';
}
}
So i am able to send a special Image as notification that the Links isnt correct.
I will attach the GERMAN images at this post. Just put the to you /forum/images/misc/ folder (or whatever place you specified)