php_check_passport 0.1

Disclaimer!!!
We take no responsibility for the use of this software as a age verification
mechanism. We know the system has its flaws. We know of programs that generate
fake password ids that pass validation and know that it is easy to write such
a generator following the documentation.




These functions validate a passport ID, check if the passport has expired and return
the age of the holder.

The reason for implementing these functions is to provide a quick check on the age
of the user, before allowing him to access content that is restricted to certain
age groups. 





Settings

There are two settings that can be changed. Unfortunaly the years are only given as
two digit numbers. Therefor we have to guess the century to get the expiration and
age of the holder right.

$php_passport_min_holder_age 
This is the minimum age a passport holder can have. Please note that for passport
holders older than this value plus 99 incorrect ages will be returned. The default
is set to 10.

$php_passport_max_ttl
This variable holds the maximum number of years a passport can exist before it
expires. This also means that passports older than 99 minus this value will not
be recognized as expired. The default value is set to 30 years.





How to use php_password_check

There are two functions provided by php_passport_check

1. php_passport_check_checkid($id)

This is the function you normally want to call. It will validate a given passport 
id and return an array.
array (
	"status" => true|false,
	"error_code" => INVALID_NUMBER|PASSPORT_EXPIRED
	"age" => age
}

status		true if the number is correct and the passport has not expired,
			else false

error_code	if the passport number is not valid it returns "INVALID_NUMBER"
			if the passport has expired it returns "PASSPORT_EXPIRED"

age			if the passport number is valid this is the age of the holder in
			years.
			Note: age is also returned if the number is valid, but the passport
			has expired.


2. php_passport_check_checksum($s)

This function is called internally, but may be useful if you wish to generate
a checksum over a part of the number yourself.
It returns the checksum over the number passed or -1 if a non numeric value is
passed.			

			

