New google images


(tlitody) #1

I’m curious how google images are now handled. Somewhere buried in the code there must something which detects the new google images prev parameter and converts it to something useable. Can you tell me where please.
One of the things I would like to do is splt google reporting into individual countries which I can do in config.php but I would also like to take a look at how google images are handled.

Thanks


(tlitody) #2

[quote=tlitody @ Nov 28 2010, 09:54 PM]I’m curious how google images are now handled. Somewhere buried in the code there must something which detects the new google images prev parameter and converts it to something useable. Can you tell me where please.
One of the things I would like to do is splt google reporting into individual countries which I can do in config.php but I would also like to take a look at how google images are handled.

Thanks[/quote]

I found it and there is a problem with the implementation.

Firstly the new google images has several possible values after the tld which are (as far as I know)

(imgres|imghp|images|imglanding)

this means some visits from google image won’t be recognised as such.

Secondly I want to report individual google countries which means the code in core/common.php which is as follows, won’t work.

 if($searchEngineName == 'Google Images'
    || ($searchEngineName == 'Google' && strpos($refererUrl, '/imgres') !== false) ) {
  $query = urldecode(trim(strtolower(self::getParameterFromQueryString($query, 'prev'))));
  $query = str_replace('&', '&', strstr($query, '?'));
  $searchEngineName = 'Google Images';
}

the first statement won’t work if anyone changes the name of the search engine such as when splitting google to report individual countries. Perhaps it would be better to look for the string “Google Images” instead of equality. The same applies with looking for Google with equality.
For eample if I split google to use “Google UK” and “Google Images UK” as my searchEngineName then above code won’t work whereas a string search for google images or google would.

How should I report this as an issue/bug/enhancement?

Thanks


(tlitody) #3

For those who may be looking to do this:

I changed code block in core/Common.php

if($searchEngineName == 'Google Images'
    || ($searchEngineName == 'Google' && strpos($refererUrl, '/imgres') !== false) ) {
  $query = urldecode(trim(strtolower(self::getParameterFromQueryString($query, 'prev'))));
  $query = str_replace('&', '&', strstr($query, '?'));
  $searchEngineName = 'Google Images';
}

replace with:

  if ( strpos(strtolower($refererHost), 'google') !== false && strpos($refererUrl, '/imgres') !== false ) 
  {
   $query = urldecode(trim(strtolower(self::getParameterFromQueryString($query, 'prev'))));
   $query = str_replace('&', '&', strstr($query, '?'));
  
   if ( strpos(strtolower($searchEngineName), 'images') === false )
   {
    $searchEngineName = $searchEngineName . ' Images';
   }    
  }

Now you can change core/DataFiles/SearchEngines.php to report individual google countries and google images for each country separately as you like.