嘗試拋棄驗證碼吧~

來源:互聯網
上載者:User

驗證碼作為防止表單垃圾資訊普遍採用的方法,一直被廣泛使用。但是同時它造成了很不好的使用者體驗,為合法使用者的正常操作帶來不便。本文介紹了一種拋棄使用驗證碼的方法,來防止自動垃圾資訊的提交。
以前見過類似的方法,這幾天開始學JQ,在中文版的《15天學會jQuery》上看到了作者有關的連結,簡單翻譯一下。

 

Make it difficult for spammers to probe our forms for weakness
Keep it easy for the “good guys” to use our contact forms
Therefore we need to avoid CAPTCHA’s
There’s research that indicates that they’re not as effective as once thought
We’ll borrow some concepts from Chris Shiflett, PHP security expert, and improve on them

使濫發垃圾郵件者(通常是自動化程式——譯者注)很難探測到我們表單的弱點
同時,保持讓“好人(指正常訪問的合法使用者——譯者注)”簡單地使用我們連絡方式的表單
因此,我們需要拋棄使用驗證碼的方法
有研究表明它們並不像當初想象的那樣有效
我們將借Chris Shiflett(PHP安全專家)的一些概念,並加以改進

 

Specifically…
1.When the contact form is loaded we’ll make an AJAX call to a PHP file
2.The PHP file will grab the current time (according to the server, not the visitor’s browser)
3.The PHP file will combine the timestamp, plus a secret word, and
generate a 32 character ‘hash’ and store it as a cookie on the
visitor’s browser
4.jQuery will receive the timestamp information from the AJAX call and store the hash or ‘token’ as a hidden form tag
5.When the form is sent for processing, the value of the timestamp will
be compared to the 32 character ‘token’ stored in the cookie
6.If the information doesn’t match, or is missing, or if the timestamp
is too old, we’ll kill execution of the form processor and a spammer
looking for easy prey will move on to another target

具體來說……
1、當連絡方式表單被載入後,我們將製造一個到PHP檔案的AJAX調用
2、該PHP檔案將取得目前時間(依靠伺服器,並不是訪問者的瀏覽器)
3、該PHP檔案將結合時間戳記,加上一個加密的字,產生一個32位的“雜湊”並把它作為cookie儲存到訪問者的瀏覽器上
4、jQuery將接收這個從AJAX調用來的時間戳記資訊,並將該雜湊值或“令牌”作為表單的隱藏標籤而儲存
5、當該表單為處理而被發送,這個時間戳記的值(表單中的——譯者注)將和儲存在cookie中的32位字元“令牌”做比較
6、如果資訊不匹配,或是丟失,又或者時間戳記到期,我們將終止表單處理的執行,同時這個濫發垃圾郵件者將把目標轉移到另一個簡單的獵物上(放棄我們這個目標——譯者注)

 

該文章是個手把手教程,上面只是前面的總述,但相信大家已經基本明白了。
不太明白的後面還有詳細步驟及,這裡就不翻譯了:)

 

原文地址:http://15daysofjquery.com/examples/contact-forms/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.