Parent Directory
|
Revision Log
Remove legacy code
| 1 | sysadm | 1.1 | <? |
| 2 | function VerifyIDCard($str) | ||
| 3 | { | ||
| 4 | $iS = 0; | ||
| 5 | $iW = array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2); | ||
| 6 | $verCode = array('1','0','X','9','8','7','6','5','4','3','2'); | ||
| 7 | |||
| 8 | if (strlen($str) != 18) | ||
| 9 | return -1; //Invalid string length | ||
| 10 | |||
| 11 | for ($i=0;$i<17;$i++) | ||
| 12 | { | ||
| 13 | $iS += intval($str[$i] - '0') * $iW[$i]; | ||
| 14 | } | ||
| 15 | |||
| 16 | $iY = $iS % 11; | ||
| 17 | |||
| 18 | if ($verCode[$iY] != $str[17]) | ||
| 19 | return 1; //Invalid card number | ||
| 20 | |||
| 21 | return 0; //Verify OK | ||
| 22 | } | ||
| 23 | ?> |
| webmaster@leafok.com | ViewVC Help |
| Powered by ViewVC 1.3.0-beta1 |