|
|
|
<?
function prestoLUHN($ccn="",$alt="0")
{
// pre-validations
$ccn = ereg_replace("[^[:digit:]]+", "", $ccn);
if ((strlen($ccn) < 1)) return FALSE;
// Mapping: Double-then-SumOfDigits (0123456789) => (0246813579)
for($i=0;$i<=9;$i++) $v[$i] = (($i*2)<9) ? ($i*2):($i*2)-9;
// Initial value of $alt (Alternation Pattern) determines which digits are transformed by $v[] during checksum calculation
// 0 = apply transform to even-numbered digits from LSD-to-MSD (Conventional LUHNMod10)
// 1 = apply transform to odd-numbered digits from LSD-to-MSD (alternative)
$checksum = 0;
// Calculate checksum from the end of the string (the low-order digit) to beginning of string
for($i = strlen($ccn)-1; $i >= 0; $i--)
{
$digit = substr($ccn, $i, 1);
$checksum += $alt ? $v[$digit] : $digit;
$alt ^= 1;
}
// return the checksum descrimination result
return !($checksum % 10);
// Mon 03 Jan 2000, Doug Preston (presto@readynet.net)
};
?>
|
|
| an example of the cyberlib payment class Categories : PHP, PHP Classes, Ecommerce, Credit Cards | | | gpg encryption. 99% of it will apply to PGP.
Categories : Credit Cards, Authentication, Ecommerce, Misc | | | Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers. Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms | | | ECHOcart - Open Source Shopping Cart Categories : PHP, Credit Cards, Ecommerce | | | Credit Card validation routine. Uses MOD 10 to check if credit card number is valid. Categories : Ecommerce, Credit Cards, PHP, Complete Programs | | | After discovering some credit card validation routines didnt work - here is one that I found works with all the numbers I have tried so far Categories : Credit Cards, Ecommerce, PHP | | | credit card security code Categories : PHP, Credit Cards, PHP Classes, Credit Cards | | | A set of functions to check the validity of a credit card number. Categories : Ecommerce, Credit Cards, PHP | | | Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate. Categories : Authentication, PHP | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Basic Authentication with sessions Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions | | | PCAC (pretty cool auction client), auction client server applications Categories : PHP, MySQL, Ecommerce | | | ECHO-Perl Module Credit Card, Check and ACH Transaction Processor Categories : Perl, Cybercash, Classes and Objects, Ecommerce, Credit Cards | | | Simple Password example Categories : PHP, Authentication, Security, HTTP | |
|
|
|