toufik toufik wrote:
"Justin Koivisto" <sp**@koivi.com> wrote in message
news:tx*****************@news7.onvoy.net...
toufik toufik wrote:
I'm looking for a php code that I can use to generate lience key that is
activated between 2 dates.
Any hint please.
More information needed... You'll need a database with 3 fields, key,
start, end. Beyond that, we'd need to know what you are trying to
accomplish.
Thanks Justin,
What I need execaly, is how can secure my key, so that my customer couldn't
create it himself.
All this because the customer can see the source code.
OK, so what you are doing (as an example) is:
1. Selling useage licenses to some PHP scripts for a client
2. You only want the licenses to work for a certain date range (like
from now until a year from now)
3. Clients will need to pay fees to renew the license or the scripts
stop working.
There are a few ways you can do this. First the paranoid license keeper way:
You will need to have some kind of permanent database set up. Use 3 fields:
id - varchar(32),
startdate - timestamp,
enddate - timestamp
Then, in the application that uses the licenses:
<?php
$q="SELECT count(*) FROM script_licenses WHERE id = ".
"'$customer_code' AND startdate >= '".time()."' ".
"AND enddate <= '".time()."'";
// do the query, get result into $result
// if the entered license is good, the result should be 1
// if not, it should be 0
?>
You'll want to do that only once per request or session so you don't
slow down the client site too much, and keep your database server from
getting pounded too hard.
OK, that's really all I can think of right at this moment. However, you
should be able to set up a file that contains some kind of encrypted
string that contains the start and end dates that the script will run
for. Of course, by giving the client a file that has the keys, they may
be able to decode it by searching the source code.
Also, one thing you may want to look into is Turck MM Cache and its
encoding:
http://turck-mmcache.sourceforge.net/index_old.html
I've yet to have a chance to play with it, but it does look a bit
promising. I know that the server-side install only took a few minutes. ;)
--
Justin Koivisto -
sp**@koivi.com http://www.koivi.com