Front_page snippet: determining if a HOME link is internal or external for splash pages

Last modified: October 21, 2007 - 23:57

PLEASE NOTE These snippets are user submitted. Use at your own risk. For users who have setup Drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* This front_page php snippet checks to see if someone has clicked on
* a "home" link on your site or if they are clicking through
* from an external link or site.
*
* Useful for drupal sites with flash intros.
*
* Change the $yoursite value to your website address
*
* This has been tested and works with Drupal 4.5.x and Drupal 4.6.x
*
*/
$yoursite = "example.com";
// get referrer from _SERVER array
$ref = $_SERVER["HTTP_REFERER"];

// check the referrer
if  (!stristr($ref, "$yoursite"))
{
   
//Offsite referrer detected
   
print "display content for visitors clicking through from external sites";

}
else {print
"display content for internal HOME links";}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.