PDA

View Full Version : Which hook i need to choose for do this?


SnakeV
08-17-2009, 11:06 PM
Hello,

I'm trying to setup a code for display ads only for visitors that come from a search engine.

This is the code that i need to put for check if a visitor come from a search engine or not it this:
$ref = $_SERVER['HTTP_REFERER'];
$SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
foreach ($SE as $source) {
if (strpos($ref,$source)!==false) {
setcookie("sevisitor", 1, time()+3600, "/", ".YOURDOMAIN.com");
$sevisitor=true;
}
}
function fromasearchengine(){
global $sevisitor;
if ($sevisitor==true || $_COOKIE["sevisitor"]==1) {
return true;
}
return false;
}

I want it to be displayed in Showthread.

Which hook i need to choose?.

Thanks!!

Lynne
08-17-2009, 11:18 PM
If you turn on debug mode, you will see a list of the plugins used on page on the bottom. You'll want to pick a hook that is used before whatever hook you use for the ads. You can always pick a global_* hook and then put a condition around it to only do the code if you are on the showthread page (THIS_SCRIPT == 'showthread').