Forum Moderators: coopster

Message Too Old, No Replies

Use .htaccess to serve different files based on IPs

I have a software that is installed illegally, have to find a way 2 counter

         

haryanto

12:17 am on Aug 4, 2004 (gmt 0)

10+ Year Member



Hi guys I have a PHP scrip that is used illegally.
One thing about this script is, it required the user to update every now and then because it is constantly updated. This script is licensed by IPs.

So I plan to prepare a bogus script and the real script.
If the IP that requested the update file is not verified, the server will serve the bogus script. If it is verified, it will serve the real script.

I know you can deny IPs using htaccess. All I need to do is tweak the script so that instead of being denied, a bogus script is served.

And is there any other good alternatives?

Please help me fight this piracy scheme guys.
I worked hard on my script and some people are just not appreciating it.

Birdman

2:04 am on Aug 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like a job for mod_rewrite, using conditionals(AKA RewriteCond).

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^111.111.111.111$
RewriteRule ^path/to/real/update/script.php$ /path/to/bogus/script.php [L]

Be sure to test with your own ip before implementing.

Birdman

Birdman

2:10 am on Aug 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or... a PHP solution(since this is the PHP forum after all):

$losers = array("111.111.111.111", "222.222.222.222", etc...);

if ( in_array( $_SERVER["REMOTE_ADDR"], $losers ) ) {
include("thebogusscript.php")
} else {
include("therealscript.php")
}

haryanto

3:03 am on Aug 4, 2004 (gmt 0)

10+ Year Member



Birdman,

I love your solution, I would like to combine the 2 actually.
I like the first one because that is what I needed.
The second one is cool because it supports multiple IPs. They dont actually download from a PHP page so the php thing might not work. They download it from SSH using wget.

To have more IPs, do I do this?

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^111.111.111.111$
RewriteCond %{REMOTE_ADDR} ^222.222.222.222$
RewriteRule ^path/to/real/update/script.php$ /path/to/bogus/script.php [L]

The bogus script will have a hidden code to email me their IPs. ;-)

Birdman

12:58 pm on Aug 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you are close.

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^111.111.111.111$ [OR]
RewriteCond %{REMOTE_ADDR} ^222.222.222.222$ [OR]
RewriteCond %{REMOTE_ADDR} ^333.333.333.333$
RewriteRule ^path/to/real/update/script.php$ /path/to/bogus/script.php [L]

If you want to redirect a whole block, you can do things like this:

Birdman

haryanto

1:29 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



So let me make sure.
111.111.111.111, 222.222.222.222 and 333.333.333.333 will be served the bogus script right? ;-)
And does it matter if the script is .zip format? It will still work right?

Wonderful. I will add some fun popup windows that says 'Hi how are you' in the bogus scripts too! LOL

Birdman

2:03 pm on Aug 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The best way to find out is to test it on yourself. Add the code with your local ip and then try to upgrade the script.

WhosAWhata

3:04 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^(111.111.111.111¦222.222.222.222¦333.333.333.333)$
RewriteRule ^path/to/real/update/script.php$ /path/to/bogus/script.php [L]

should work as well (change the broken pipes to unbroken pipes. the servers do that)