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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.