Location: PHPKode > scripts > License management script > licence.inc.php
<?php
/*
=============================================================
Script Name               : license management class
Auther                    : Payam khaninajad
Contact                   : hide@address.com
Follow me on twitter      : http://twitter.com/khaninajad
Location                  : Iran-Azarbayjan 
Year                      : 2010-12-19
Version                   : 1.0
=============================================================
Class File 
*/
class licence
{
    // get host name
    function get_host_name() 
    {
        return $_SERVER['HTTP_HOST'];
    }
    // get host ip
    function get_ip_address() 
    {
        return $_SERVER['REMOTE_ADDR'];
    }
    // it used for generate serial you can remove it
	function validate_my_licence_for_test($num) 
	{
		$site=$this->get_host_name();
		$ip=$this->get_ip_address();
		$sitestring=$this->generate_string($site);
		$ipstring=$this->generate_string($ip);
		$numstring=$this->generate_string($num);
		$mylicanece=$sitestring."-".$ipstring."-".$numstring;
		return $mylicanece;
	}
    // it is main function to licence process
    // you can encode your page with base64 function 
    // php.net/manual/en/function.base64-encode.php
    // php.net/manual/en/function.base64-decode.php
	function validate_my_licence($num,$serial) 
	{
		$site=$this->get_host_name();
		$ip=$this->get_ip_address();
		$sitestring=$this->generate_string($site);
		$ipstring=$this->generate_string($ip);
		$numstring=$this->generate_string($num);
		$mylicanece=$sitestring."-".$ipstring."-".$numstring;
		if((strcmp($mylicanece,$serial))==0) 
		{
		return 0;
		}
		else 
		{
		return 1;
		}
	}
    // generate your own serial 
    // write your own serial :D
	function generate_string($string)
	{
		$ascii=NULL;
		$serial=NULL;
		$secret_num=1;
		for ($i = 0; $i < strlen($string); $i++)
			{
				$ascii .= $secret_num+ ord($string[$i]);
			}
		$ascii=substr($ascii,0,20);
		for ($i = 0; $i < strlen($ascii); $i+=2)
			{
				$string=substr($ascii,$i,2);
					switch($string) 
					{
						case $string>122:
						$string-=40;
						break;
						case $string<=48:
						$string+=40;
						break;
					}
				$serial .= chr($string);
			}	
		return $serial;
	}

}
?>
Return current item: License management script