Recent Topics

1 Aug 20, 2005 15:56    

Hi

I always need to tag my images with the full URL, which is creating havok with my traffic reports. The blog operates from the domain root, so technically image/image.jog should work. But when I do this, B2 has a fit (plus, while it's nice that it checks your tags, it gives me no url feedback, so I can't see how the link is directing incorrectly).

How do you display an image in B2 without including the entire site address?

thanks

3 Aug 20, 2005 17:03

I'd love to, but my B2 stats and my Webalizer stats don't add up. I suspect B2 is using every image reference as a new visit plus using absolute urls might be pushing up my bandwidth. My blog is consuming a lot of bandwidth and I want to curb this.

4 Aug 20, 2005 18:04

I've never heard of every absolute url image being counted as a separate hit or using more bandwidth than a relative url. You might check with your host about that. I use absolute urls, and they don't show up in my b2 stats. Now, when the file isn't there, your .htaccess file might redirect to b2evolution, causing a stat log.

5 Aug 25, 2005 23:45

Absolute URLs will not affect your bandwidth. The browser will request and download the same file (using the same bandwidth) regardless of the type of URL used.

I can't say for sure how the b2evolution stats are compiled, but it doesn't make sense that an absolute URL would make a difference there, either.

6 Mar 24, 2006 23:18

What about URLs relative to the site root, as in "/homepage/images/clock.jpg". That is a vild URL, but when I preview a post with an image path like that it gives me an error:

Found invalid URL: Invalid URL

One way around this - in evocore/_misc.funcs.php replace the original validate_url function with this:

{
	global $debug, $Debuglog;

	if( empty($url) )
	{ // Empty URL, no problem
		return false;
	}

	// minimum length: http://az.fr/
	if( strlen($url) < 13 )
	{ // URL too short!
		$Debuglog->add( 'URL &laquo;'.$url.';&raquo; is too short!', 'error' );
		return T_('Invalid URL');
	}

	
	$pattern_url = '<^                             # start 
		(                                          # there may not be a scheme if the URL is relative to the site root which is OK 
			(                                      # 
				([a-z][a-z0-9+.\-]*)               # scheme 
				:[0-9]*                            # port optionally 
				//                                 # allow absolute URLs only 
			)                                      # 
			|                                      #
			/                                      # or URLs relative to site root 
		)                                          # 
		[a-z0-9][a-z0-9~+.\-_,:;/\\\\*]*           # Don t allow anything too funky like entities 
		([?#][a-z0-9~+.\-_,:;/\\\\%&=?#*\ \[\]]*)? # 
		$>ix';
	if( ! preg_match($pattern_url, $url, $matches) )
	{ // Cannot vaidate URL structure
		$Debuglog->add( 'URL &laquo;'.$url.';&raquo; does not match url pattern!', 'error' );
		return T_('Invalid URL &laquo;'.$url.';&raquo; ');
	}

	$scheme = ( ( isset( $matches[3] ) ) ? strtolower($matches[3]) : '' );
	if( !in_array( $scheme, $allowed_uri_scheme ) )
	{ // Scheme not allowed
		return T_('URI scheme &laquo;'.$scheme.';&raquo; not allowed');
	}

	// Search for blocked URLs:
	if( $block = antispam_check($url) )
	{
		if( $debug ) return 'URL &laquo;'.$url.';&raquo; refused. Debug info: blacklisted word: ['.$block.']';
		return T_('URL &laquo;'.$url.';&raquo; not allowed');
	}

	return false; // OK
}

Then in conf/_formatting.php add an empty string to the $comments_allowed_uri_scheme array:

$comments_allowed_uri_scheme = array
(
	'',        # allow URLs relative to site root
	'http',
	'https',
	'ftp',
	'gopher',
	'nntp',
	'news',
	'mailto',
	'irc',
	'aim',
	'icq'
);


Form is loading...