Hello PhPBuilder Members,
I would like to know if this is suitable for checking for a valid licence. in this serial it expires in 1 weeks time but it also checks that the host it is registered for is the same as in the key.
The licence_key in this script is first of the host which has been encoded and the second part is the time in which it is valid till.
licenceKey.php
<?php
$GLOBALS['LICENCE_KEY'] = "bG9jYWxob3N0-1223803563";
function serialChk(){
$KEY = $GLOBALS['LICENCE_KEY'];
$KEY = explode("-", $KEY);
$HOST_KEY = base64_decode($KEY[0]);
$DATE_EXPIRE = date("d-m-Y", $KEY[1]);
$NOW = date("d-m-Y");
if($DATE_EXPIRE <= $NOW){
return "INVALID_KEY";
}
if($HOST_KEY != $_SERVER['HTTP_HOST']){
return "INVALID_HOST";
}
return true;
}
?>
keygen.php
echo base64_encode($_SERVER['HTTP_HOST']).'-'.strtotime("+1 week");
This works but I would like to know if this is good enough