Log in

View Full Version : Protection Function



egturnkey
08-15-2009, 06:15 PM
Hello Dear Friends,


Consider we have an php file called

index.php

how can i add a code to (index.php) so that when it excute (run) on any website for example (anysite.com)

it call an text file (license.txt) which is on my server and also in same time it record the URL of the (index.php) in another text file (record.txt)


WHAT FOR


it someone open ( index.php) it will record in a text file on my server the URL
if it was licensed then it will be okay and if not
then i remove the ( license.txt) and then index.php won't work


I've made the following code but it give some problems


on my server both
track.php and empty counter.txt



<?php
$url = @$_GET['url'];
$path = @$_GET['path'];
$entry_line = "$url | $path
"; //give ENTER to break into new line in text file
$fp = fopen("counter.txt","a");
fputs($fp,$entry_line);
fclose($fp);
?>


and the tacking code inside index.php


$f = @fopen("xxxxxxxxxxxxxxxxxxx/track.php?url=$_SERVER[HTTP_HOST]&path=$_SERVER[SCRIPT_FILENAME]","r");
@fread($f,10);
@fclose($f);

where xxxxxxxxxxxxxx is my website which i do stored the text file


PROBLEMS

1- It makes the website running so slow
2- it keeps store the URL everytime it open i mean has no overwrite option if same URL

My needs

any simple idea that makes me able to do the following

- know what url using the script ( index.php )
- if i changed license.txt , it won't load ( index.php ) or give warrning MSG not licensed please buy license


thanks in advance

it really will helps me a lot

Bungeebones
08-15-2009, 07:59 PM
Maybe try some of the built in PHP $SERVER functions such as $_SERVER['PATH_INFO']). It might be faster