




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、php實現(xiàn)通用的信用卡驗證類_ 這篇文章主要介紹了php實現(xiàn)通用的信用卡驗證類,涉及信用卡的規(guī)章與php字符串操作的相關(guān)技巧,具有肯定參考借鑒價值,文中有英文原文說明說明,有助于更直觀的了解源碼相關(guān)信息,需要的伴侶可以參考下 本文實例講解并描述了php實現(xiàn)通用的信用卡驗證類。分享給大家供大家參考。 原文說明如下: Credit Card Validation Solution (PHP Edition) Version 3.5 Description Credit Card Validation Solution uses a four step process to ensure credi
2、t card numbers are keyed in correctly. This procedure accurately checks cards from American Express, Australian BankCard, Carte Blache, Diners Club, Discover/Novus, JCB, MasterCard and Visa. For more information, please read the comments in the code itself. Installation Instructions Select the text
3、between the two lines indicated, below. Copy the text. Open up a text editor. Paste the text. Save that file. When saving it, make sure to: save it in a directory on your webserver, and name it with an extension that your server will recognize needs parsing by PHP. To see it in action, open up that
4、file in your web browswer. 具體代碼如下: ?php # - # Credit Card Validation Solution, version 3.5 PHP Edition # 25 May 2021 # # COPYRIGHT NOTICE: # a) This code is property of The Analysis and Solutions Company. # b) It is being distributed free of charge and on an as is basis. # c) Use of this code, or an
5、y part thereof, is contingent upon leaving # this copyright notice, name and address information in tact. # d) Written permission must be obtained from us before this code, or any # part thereof, is sold or used in a product which is sold. # e) By using this code, you accept full responsibility for
6、its use # and will not hold the Analysis and Solutions Company, its employees # or officers liable for damages of any sort. # f) This code is not to be used for illegal purposes. # g) Please email us any revisions made to this code. # # Copyright 2021 # The Analysis and Solutions Company # - # # DES
7、CRIPTION: # Credit Card Validation Solution uses a four step process to ensure # credit card numbers are keyed in correctly. This procedure accurately # checks cards from American Express, Australian BankCard, Carte Blache, # Diners Club, Discover/Novus, JCB, MasterCard and Visa. # # CAUTION: # CCVS
8、 uses exact number ranges as part of the validation process. These # ranges are current as of 20 October 1999. If presently undefined ranges # come into use in the future, this program will improperly deject card # numbers in such ranges, rendering an error message entitled Potential # Card Type Dis
9、crepancy. If this happens while entering a card type # you KNOW are valid, please contact us so we can update the ranges. # # POTENTIAL CUSTOMIZATIONS: # * If you dont accept some of these card types, edit Step 2, using pound # signs # to comment out the elseif, $CardName and $ShouldLength # lines i
10、n question. # * Additional card types can be added by inserting new elseif, # $CardName and $ShouldLength lines in Step 2. # * The three functions here can be called by other PHP documents to check # any number. # # CREDITS: # We learned of the Mod 10 Algorithm in some Perl code, entitled # The Vali
11、dator, available on Matts Script Archive, #. That code was # written by David Paris, who based it on material Melvyn Myers reposted # from an unknown author. Paris credits Aries Solis for tracking down the # data underlying the algorithm. At the same time, our code bears no # resemblance to its pred
12、ecessors. CCValidationSolution was first written # for Visual Basic, on which Allen Browne and Rico Zschau assisted. # Neil Fraser helped prune down the OnlyNumericSolution() for Perl. function CCValidationSolution ($Number) global $CardName; # 1) Get rid of spaces and non-numeric characters. $Numbe
13、r = OnlyNumericSolution($Number); # 2) Do the first four digits fit within proper ranges? # If so, whos the card issuer and how long should the number be? $NumberLeft = substr($Number, 0, 4); $NumberLength = strlen($Number); if ($NumberLeft = 3000 and $NumberLeft = 3059) $CardName = Diners Club; $Sh
14、ouldLength = 14; elseif ($NumberLeft = 3600 and $NumberLeft = 3699) $CardName = Diners Club; $ShouldLength = 14; elseif ($NumberLeft = 3800 and $NumberLeft = 3889) $CardName = Diners Club; $ShouldLength = 14; elseif ($NumberLeft = 3400 and $NumberLeft = 3499) $CardName = American Express; $ShouldLen
15、gth = 15; elseif ($NumberLeft = 3700 and $NumberLeft = 3799) $CardName = American Express; $ShouldLength = 15; elseif ($NumberLeft = 3528 and $NumberLeft = 3589) $CardName = JCB; $ShouldLength = 16; elseif ($NumberLeft = 3890 and $NumberLeft = 3899) $CardName = Carte Blache; $ShouldLength = 14; else
16、if ($NumberLeft = 4000 and $NumberLeft = 4999) $CardName = Visa; if ($NumberLength 14) $ShouldLength = 16; elseif ($NumberLength 14) $ShouldLength = 13; else echo br /emThe Visa number entered, $Number, in is 14 digits long.br /Visa cards usually have 16 digits, though some have 13.br /Please check
17、the number and try again./embr /n; return FALSE; elseif ($NumberLeft = 5100 and $NumberLeft = 5599) $CardName = MasterCard; $ShouldLength = 16; elseif ($NumberLeft = 5610) $CardName = Australian BankCard; $ShouldLength = 16; elseif ($NumberLeft = 6011) $CardName = Discover/Novus; $ShouldLength = 16;
18、 else echo br /emThe first four digits of the number entered are $NumberLeft. br /If thats correct, we dont accept that type of credit card.br /If its wrong, please try again./embr /n; return FALSE; # 3) Is the number the right length? if ($NumberLength $ShouldLength) $Missing = $NumberLength - $Sho
19、uldLength; if ($Missing 0) echo br /emThe $CardName number entered, $Number, is missing . abs($Missing) . digit(s).br /Please check the number and try again./embr /n; else echo br /emThe $CardName number entered, $Number, has $Missing too many digit(s).br /Please check the number and try again./embr
20、 /n; return FALSE; # 4) Does the number pass the Mod 10 Algorithm Checksum? if (Mod10Solution($Number) = TRUE) return TRUE; else echo br /emThe $CardName number entered, $Number, is invalid.br /Please check the number and try again./embr /n; return FALSE; function OnlyNumericSolution ($Number) # Rem
21、ove any non numeric characters. # Ensure number is no more than 19 characters long. return substr( ereg_replace( 0-9, , $Number) , 0, 19); function Mod10Solution ($Number) $NumberLength = strlen($Number); $Checksum = 0; # Add even digits in even length strings # or odd digits in odd length strings.
22、for ($Location = 1 - ($NumberLength % 2); $Location $NumberLength; $Location += 2) $Checksum += substr($Number, $Location, 1); # Analyze odd digits in even length strings # or even digits in odd length strings. for ($Location = ($NumberLength % 2); $Location $NumberLength; $Location += 2) $Digit = s
23、ubstr($Number, $Location, 1) * 2; if ($Digit 10) $Checksum += $Digit; else $Checksum += $Digit - 9; # Is the checksum divisible by ten? return ($Checksum % 10 = 0); # - BEGIN SAMPLE USER INTERFACE SECTION - # # This section provides a simple sample user interface for the # Credit Card Validation functi
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- DB3709T 038-2025泰山茶 山地低產(chǎn)茶園提升改造技術(shù)規(guī)程
- 海南九樂再生資源回收與利用有限公司水穩(wěn)站項目環(huán)評報告表
- 項目資金評分表
- 海航技術(shù)附件維修事業(yè)部??趶?fù)材車間新租賃廠房及APU新試車臺項目環(huán)評報告表
- 店鋪硅酸鈣板施工方案
- 隔墻板做磚胎膜的施工方案
- 福建省泉州市2025屆高中畢業(yè)班質(zhì)量監(jiān)測 (三)物理試題(含答案)
- 地板磚鋪設(shè)施工方案
- 2024-2025學(xué)年下學(xué)期高二語文第三單元A卷
- 數(shù)控加工工藝與編程技術(shù)基礎(chǔ) 教案 模塊一 任務(wù)2 初識數(shù)控加工工藝
- 小兒鋅缺乏癥剖析
- 古風(fēng)集市策劃方案
- 道路危險貨物運輸安全培訓(xùn)課件
- 社會工作綜合能力初級講義課件
- 青春期心理健康講座課件
- 《廣聯(lián)達培訓(xùn)教程》課件
- 兒童流感的防治和預(yù)防措施
- 美業(yè)招商課件
- 城市災(zāi)害學(xué)課件-地質(zhì)災(zāi)害(1)課件
- 面密度儀設(shè)備原理培訓(xùn)課件
- 鑄件(原材料)材質(zhì)報告
評論
0/150
提交評論