1 | djbrain | 44355 |
2 | subofferul | 5220 |
3 | robica | 4610 |
4 | krystyana84 | 3980 |
5 | elena2008 | 2690 |
Membri inscrisi | 96837 |
Intrebari | 35959 |
Raspunsuri | 164755 |
MODUL ?? SAU SCRIPT de
dacia1980
|
|||||||||
se POATE MODIFICA INCIT SA PROCESEZE O PLATA ACUMA EL CE FACE DE FAPT <?php // // // **************************************************** // THIS IS A PHP PORT OF PERL CC VALIDATION SCRIPT // // If you want the PERL version of this script, goto // www.planetsourcecode.com and search for // // "Credit Card Format Validation Script" // // **************************************************** // // // Feel free to use this script all you want, for commercial use, // non-commecial use, whatever. // // All I ask is that you keep name up there at the top of the // script! =P // // I wrote this out of necessity one night after about 12 cups of // jasmine tea, and I wasn't really in the mood to comment code, // but I think any absolutely necessary comments are there. // // Enjoy! // // // // // Use: IsCCNumberValid($ccNumber, $cardType); // If you pass cardType as 0, it will check to see if the given // number is valid for any card type. // Ex: IsCCNumberValid("4111111111111111", 0); // // Return Values: 1 'Number Is Valid // 0 'Number Is Invalid // // // Card Types: // MASTERCARD.....................1 // VISA...........................2 // AMEX...........................3 // Diners Club / Carte Blanche....4 // Discover.......................5 // enRoute........................6 // JCB............................7 // // // // // // If you specify the card type, it will see if the number is valid for // that particular card type, otherwise, it will see if the number fits // any of the credit card types. Since most credit card processing // companies don't r==uire you to have the credit card type, it is // generally easier just to pass the number, and not the type. But, if // you feel that you want to take the time to gather that one extra field // and pass it to this function, then by all means do so! =) // // $MCRD = 1; $VISA = 2; $AMEX = 3; $DCCB = 4; $DISC = 5; $ENRT = 6; $JCBC = 7; $retval = 0; function IsCCNumberValid($ccNumber, $cardType) { if($cardType) { if($cardType == $MCRD){$retval = isMCRD($ccNumber);} elseif($cardType == $VISA){$retval = isVISA($ccNumber);} elseif($cardType == $AMEX){$retval = isAMEX($ccNumber);} elseif($cardType == $DCCB){$retval = isDCCB($ccNumber);} elseif($cardType == $DISC){$retval = isDISC($ccNumber);} elseif($cardType == $ENRT){$retval = isENRT($ccNumber);} elseif($cardType == $JCBC){$retval = isJCBC($ccNumber);} } else { if(!$retval){$retval = isMCRD($ccNumber);} if(!$retval){$retval = isVISA($ccNumber);} if(!$retval){$retval = isAMEX($ccNumber);} if(!$retval){$retval = isDCCB($ccNumber);} if(!$retval){$retval = isDISC($ccNumber);} if(!$retval){$retval = isENRT($ccNumber);} if(!$retval){$retval = isJCBC($ccNumber);} } return $retval; } function isMCRD($ccNum) { $preFix = substr($ccNum, 0, 2); if($preFix == 51 || $preFix == 52 || $preFix == 53 || $preFix == 54 || $preFix == 55) { if(strlen($ccNum) == 16){return modTen($ccNum);} } else { return 0; } } function isVISA($ccNum) { $preFix = substr($ccNum, 0, 1); if($preFix == 4){ if(strlen($ccNum) == 13 || strlen($ccNum) == 16){ return modTen($ccNum);}} else { return 0; } } function isAMEX($ccNum) { $preFix = substr($ccNum, 0, 2); if($preFix == 34 || $preFix == 37){ if(strlen($ccNum) == 15){ return modTen($ccNum);}} else { return 0; } } function isDCCB($ccNum) { $preFix = substr($ccNum, 0, 3); if($preFix == 300 || $preFix == 301 || $preFix == 302 || $preFix == 303 || $preFix == 304 || $preFix == 305) { if(strlen($ccNum) == 14){return modTen($ccNum);} } else { return 0; } $preFix = substr($ccNum, 0, 2); if($preFix == 36 || $preFix == 38){ if(strlen($ccNum) == 14){ return modTen($ccNum);}} else { return 0; } } function isDISC($ccNum) { $preFix = substr($ccNum, 0, 4); if($preFix == 6011){ if(length($ccNum) == 16){ return modTen($ccNum);}} else { return 0; } } function isENRT($ccNum) { $preFix = substr($ccNum, 0, 4); if($preFix == 2014 || $preFix == 2149){ if(length($ccNum) == 15){ return 1;}} else { return 0; } } function isJCBC($ccNum) { $preFix = substr($ccNum, 0, 1); if($preFix == 3){ if(length($ccNum) == 15 || length($ccNum) == 16){ return modTen($ccNum);}} else { return 0; } $preFix = substr($ccNum, 0, 4); if($preFix == 1800 || $preFix == 2131){ if(length($ccNum) == 15 || length($ccNum) == 16){ return modTen($ccNum);}} else { return 0; } } function modTen($ccNum) { $numLen = strlen($ccNum); for($x = $numLen; $x > 0; $x-=2){$tot+=substr($ccNum, $x - 1, 1);} for($x = $numLen - 1; $x > 0; $x-=2) { $y = substr($ccNum, $x - 1, 1) * 2; if(strlen($y) == '1'){$tot+=$y;} if(strlen($y) == '2'){$tot+=substr($y, 0, 1); $tot+=substr($y, 1, 1); } } if(substr($tot, strlen($tot) - 1, 1) == '0'){return 1;} else{return 0;} } ?> |
Tags:
|
||||||||
|
Comentariul lui:
12-09-2011 16:17:28
Data:
|
||||||
|
||||||
* | Comentariu | Voturi: | 1 Voteaza |
Link sponsorizat | |
Comentariul lui:
12-09-2011 16:17:43
Data:
|
||||||
|
||||||
* | Comentariu | Voturi: | 3 Voteaza |
Comentariul lui:
12-09-2011 17:06:48
Data:
|
||||||
|
||||||
* | Comentariul autorului |
Link sponsorizat | |
Comentariul lui:
12-09-2011 17:32:35
Data:
|
||||||
|
||||||
* | Raspuns acceptat | Voturi: | 3 Voteaza |
Comentariul lui:
25-09-2011 15:19:06
Data:
|
||||||
|
||||||
* | Comentariu | Voturi: | 1 Voteaza |
Link sponsorizat | ||
|