Jump to content

Locking a script to a certain directory


idiotstrike

Recommended Posts

Hello.

I'm trying to allow a script to be run only in a certain defined directory on a defined host. What I use now is something like this:

 

$host = $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
$key = 'site.com/directory';

$works = stristr( $host, $key );

 

This works quite well. The only problem, while being a huge problem at the same time is this will return 1 even if it's in a directory like site.com/directory/something_else. What would be the best way to avoid this? I was thinking about finding whether a certain file( for example /core/class/class.mysql.php ) is located within the root directory and not further, but I'm not sure how to do this.

 

I don't want to use neither protocol nor www in the $host variable because users can just go to the website without the protocol or www. and that will result in returning 0.

 

 

If I'm being not clear here, here's an example:

The user gets the application and installs it on site.com/directory. His license allows him to install it only to that directory, which is okay. But he decides to install several more copies in directories like site.com/directory/something_else or whatever. I want to avoid this.

Link to comment
https://forums.phpfreaks.com/topic/262691-locking-a-script-to-a-certain-directory/
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.