View Single Post
  #45  
Old 08-08-2004, 11:15 AM
Hotte@gun Hotte@gun is offline
 
Join Date: Apr 2004
Location: Cologne, germany
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00997 seconds
  • Memory Usage 1,770KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete