Start with:

<pre>
<? print_r($_SERVER) ?>
</pre>

have a look through the array, to find the values you need to test on... something like

$_SERVER['HTTP_HOST'] => mydomain.com is what I would use, but your srver may do different things.

So, then we can test/compare that value to the one you're allowing:

<?
$allowedDomain = 'mydomain.com';
if($_SERVER['HTTP_HOST'] != $allowedDomain)
        {
        echo "wrong domain";
        exit;
        }
else
        {
        // the rest of the page goes here
        }
?>


Of course, what's stopping someone from changing the value of $allowedDomain??
It depends on why you want to restrict, and how important it is.


My other thought is that you could take $_SERVER['HTTP_HOST'], submit it to a script on another domain, and check for validity that way.

But again, what's stopping the owner of the script from modifying/removing those lines? Nothing -- unless you encode your entire script with something like zend encoder.


It depends what you're trying to achieve.



Justin French



On Saturday, July 19, 2003, at 02:00 AM, Ryan A wrote:


Hi,
I want to make sure my scripts can be executed on only one domain (or
localhost/ 127.0.0.1)...it should not matter if its
http://somesite.com/myscript.php
 or http://somesite.com/~blah/myscript.php
 or http://blah.somesite.commyscript.php
 or http://somesite.com/1/2/asdf/234/myscript.php

It should only work on "somsite.com"

Any ideas on how i can do this? I've seen this done on some old perl scripts
but how in php?


Kindly help.

Thanks,
-Ryan



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

---
[This E-mail scanned for viruses]




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to