Status
Not open for further replies.

Kedon

Member
10
2013
0
0
Hey my good people.

i'm looking for a php code that will check referring URL, if it sees restricted words, then that referring URL will not see popunders on the current page they got referred to.
 
6 comments
PHP:
$words = array('word', 'another', 'third', 'etc');
$regex = '/(' . implode('|', $words) . ')/'; //  '/(word|another|third|etc)/'
if (preg_match($regex, $_SERVER['HTTP_REFERER']) === 1) {
  // restriced word found
} else {
  // restricted word not found, do stuff
}


Just keep in mind that
the REFERER is sent by the client's browser as part of the HTTP protocol, and is therefore unreliable. It might not be there, it might be forged, you just can't trust it if it's for security reasons.
 
PHP:
$words = array('word', 'another', 'third', 'etc');
$regex = '/(' . implode('|', $words) . ')/'; //  '/(word|another|third|etc)/'
if (preg_match($regex, $_SERVER['HTTP_REFERER']) === 1) {
  // restriced word found
} else {
  // restricted word not found, do stuff
}


Just keep in mind that
the REFERER is sent by the client's browser as part of the HTTP protocol, and is therefore unreliable. It might not be there, it might be forged, you just can't trust it if it's for security reasons.

Have any idea how i can apply this code in a .js popunder code?
 
In a .js you can't. You can insert the js code/link into the IF statement in a PHP file:
PHP:
<?php $words = array('word', 'another', 'third', 'etc');
$regex = '/(' . implode('|', $words) . ')/';
if (preg_match($regex, $_SERVER['HTTP_REFERER']) === 1) {
  // restriced word found, do nothing
} else {
  // restricted word not found, add that JS
?>
  <script type="text/javascript" src="yourscript.js"></script>
<?php
} ?>
 
Status
Not open for further replies.
Back
Top