Jump to content


- - - - -
Photo

[3.1.0] Facebook "Like" button doesn't correctly like URL / only "Likes" root URL


There is an issue when using the Facebook LIKE button on forums not using .htaccess based FURLs.

The issue is cause because the link structure is:

index.php?/topic/1234-topic-title

Facebook encodes the slash to %2F on anything in the query string. I have written a patch to get around this issue:

Download the zip and upload the contents over your live copy:

Zip: http://www.invisionp.../310patches.zip

Alternatively, you may manually patch admin/sources/base/ipsRegistry.php

Function: _furlInit()

if ( is_array( self::$_seoTemplates ) AND count( self::$_seoTemplates ) )
			{ 
				if ( !isset( $_SERVER['REQUEST_URI'] ) )
				{
					$_SERVER['REQUEST_URI'] = substr( $_SERVER['PHP_SELF'], 1 );
					
					if ( isset( $_SERVER['QUERY_STRING'] ) )
					{ 
						/* Ok, can't use bot detection as that is set up later, so this should do it
						   Basically facebook bot encodes all / to %2F after query string, so LIKE button
						   returns board index and when clicking link from FB brings up board index as URL is ?%2Ftopic%2F4314-test-digest%2F */
						if ( substr( $_SERVER['QUERY_STRING'], 0, 3 ) == '%2F' )
						{
							$_SERVER['QUERY_STRING'] = str_replace( '%2F', '/', $_SERVER['QUERY_STRING'] );
						}
						
						$_SERVER['REQUEST_URI']	.= '?' . $_SERVER['QUERY_STRING'];
					}
				}
				else
				{
					if ( isset( $_SERVER['QUERY_STRING'] ) )
					{ 
						/* Facebook thing */
						if ( substr( $_SERVER['QUERY_STRING'], 0, 3 ) == '%2F' )
						{
							$_SERVER['REQUEST_URI'] = str_replace( '%2F', '/', $_SERVER['REQUEST_URI'] );
						}
					}
				}
				
				$uri = $_SERVER['REQUEST_URI']  ? $_SERVER['REQUEST_URI']  : @getenv('REQUEST_URI');
				
				/* Bug 21295 - remove known URL from test URI */
				$_t      = @parse_url( ipsRegistry::$settings['board_url'] );
				$_toTest = ( $_t['path'] AND $_t['path'] != '/' ) ? preg_replace( "#^{$_t['path']}#", '', $uri ) : str_replace( $_t['scheme'] . '://' . $_t['host'], '', $uri );
				$_toTest = str_replace( '/index.php?', '', $_toTest );



0 Comments


Developer Docs · Error Codes