KoderyBeta

If Parent Domain is in array

Category: PHP - Owner: PaulDavis - Owner ID: 1

If the iFrame is on a page where the URL is in the array...

http://stackoverflow.com/questions/2781608

Sub-domains need to be declared too.

<?php

	$allowed_domains = array('codebymonkey.com'); // Seperate keys with a comma : ('domain.com','name.com','here.com')

	$allowed = false;
	foreach ($allowed_domains as $a) {
		if (preg_match("@https?://$a/.*@", $_SERVER['HTTP_REFERER'])) {
			$allowed = true;
		} 
	}

	if ($allowed) {
		echo "Nice domain";
	} else {
		echo "Ugly domain";
	}

?>