Jump to content

domain match


Destramic

Recommended Posts

hey guys im making a script where the user gets redirected...but im wanting to make sure the redirection is within the same domain and not being shipped off to another site when using ($_SERVER['HTTP_REFERER'])

 

now what im using seems to do the trick but im wondering if there is a better method of doing this?...i dont want to use regex either

 

thank you guys

<?php 

$match = strpos("http://127.0.0.1/login", $_SERVER['SERVER_NAME']);

if ($match && $match > 0 ||  $match === 0)
{
	echo "domain match";
}

?>
Link to comment
https://forums.phpfreaks.com/topic/293117-domain-match/
Share on other sites

I guess this depends on how are actually doing it.

 

$_SERVER['HTTP_REFERER'] can be spoofed

 

You can do a check what the ip is though

$remote_ip = $_SERVER['REMOTE_ADDR'];
if (strstr($remote_ip, ', ')) {
    $ips = explode(', ', $remote_ip);
    $remote_ip = $ips[0];
}
if($remote_ip == "192.168.1.2"){ //use servers ip
echo "from my server";
}
Link to comment
https://forums.phpfreaks.com/topic/293117-domain-match/#findComment-1499674
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.