I have some ideas on this but was wondering if anyone had a way to do this that was better.

Essentially, I have a situation where I don't want the user to be able to access a page via bookmark, only from a referring page within the same drupal site.

My thoughts were to use drupal_preprocess_theme, check the referring url and if the required url, then provide the full theme, if not, then serve an empty "access denied" theme.

I don't think the theme layer itself is the place to put this logic.

Is there a nice function out there that returns the referring url?

Thanks for any insight.

Comments

pbarnett’s picture

<?php $referer = getenv("HTTP_REFERER"); ?>
tpainton’s picture

Awesome. Thank you so much.

AlexanderPop’s picture

	if (isset($_SERVER['HTTP_REFERER'])) {
		//if (preg_match("/php-learb:8082/i", $_SERVER['HTTP_REFERER'])) {
		if (preg_match("~^http://php-learb:8082~i", $_SERVER['HTTP_REFERER'])) {
			print 'OMG! You totally came from my site!';
		}
		else { 
		print "Hi You came from External Source!!!";
		}
	}