It's is interesting that it treats the browsers opera, chrome and safari as being bots and doesn't serve them the malware.
So it must be targeting IE and Firefox.
Also it looks like the writer of this code may not be a native English speaker as there are multiple spelling and grammar mistakes in the comments.
A search for the phrase "Looks for google serch bot" comes up with a fair number of results dating back to at least 2010.
What you need to determine is how your site was compromised in the first place allowing them to add the PHP script. It looks like a fair number of the sites that were infected were Wordpress ones possibly using this vulnerability.