I used to get so much spam in my mailbox everyday that I was spending more time deleting it then I was adding new content, maintaining sites, or starting new sites combined (typical story right). मैं अपने मेलबॉक्स में हर रोज कि मैं तो मैं, नई सामग्री जोड़ने की गई साइटों को बनाए रखने, या नई साइटें (विशिष्ट कहानी सही) संयुक्त शुरू इसे हटाने और समय खर्च कर रहा था इतना स्पैम पाने के लिए इस्तेमाल किया. Some of your website spam is not preventable, or, it is preventable, but at the cost of usability and/or good information getting caught in the “bad stuff” as well. कुछ अपनी वेबसाइट स्पैम की, या, यह निवारणीय है, निवारण नहीं है, लेकिन प्रयोज्य और / या अच्छी जानकारी "बुरी चीजें में" के रूप में अच्छी तरह से पकड़ा जा रही की कीमत पर.

No doubt, if you’re serious about web development you’re going to be creating and interacting with forms on a regular basis. इसमें कोई संदेह नहीं है, अगर आप वेब के विकास के बारे में आप पैदा होने का और एक नियमित आधार पर रूपों के साथ बातचीत जा रहे हैं गंभीर हो. Especially with this new web 2.0 attitude every has…gee wiz, what’s that? विशेष रूप से इस नई वेब हर क्या है ... आगे बढ़ना wiz, है 2.0 दृष्टिकोण के साथ कि?

CAPTCHA कॅप्चा
CAPTCHA is the number one method most people are using to prevent spam today. कॅप्चा एक विधि ज्यादातर लोग आज स्पैम रोकने के लिए प्रयोग कर रहे हैं वह संख्या है. What is it? यह क्या है?

“A CAPTCHA is a challenge response test used on computers to check if the user is human. "एक कॅप्चा एक चुनौती प्रतिक्रिया परीक्षण कंप्यूटर पर जाँच करने के लिए प्रयोग किया जाता यदि उपयोगकर्ता मानव है. A common kind of CAPTCHA that is used on websites requires that the visitor type the letters and numbers of a distorted image. कि आगंतुक प्रकार के पत्र और एक विकृत छवि की संख्या कॅप्चा की है कि वेबसाइटों पर इस्तेमाल किया जाता है एक आम तरह की आवश्यकता होती है. This method is based on the fact that is difficult for computers to extract the text from the image while it is very easy for humans.” - captchacreator.com जबकि यह बहुत मनुष्यों के लिए आसान है के लिए कंप्यूटर की छवि से मूल पाठ इस प्रकार निकालने के लिए यह विधि है कि मुश्किल है इस तथ्य पर आधारित है. "- Captchacreator.com

Here’sa few resources to scripts so you’ll be able to implement that functionality into your own forms: लिपियों के लिए Here'sa कुछ संसाधनों ताकि आप अपने रूपों में है कि कार्यशीलता को लागू करने में सक्षम हो जाएगा:

Escape Data - Prevent SQL Injections भागने डेटा - sql इंजेक्शन रोकें
Capcha is usless if you’re leaving your form unprotected from attack. अगर आप अपने फार्म हमले से असुरक्षित जा रहे हैं Capcha usless है. Remember to filter post strings with addslashes() or mysql_real_escape_string() . Addslashes के साथ फिल्टर पोस्ट तार करने के लिए याद है () या mysql_real_escape_string ().

Also take a look at these functions for other similar kind of checks that might be useful: यह भी जाँच के अन्य समान प्रकार के लिए उपयोगी हो सकता है कि इन कार्यों को देखो:

  • htmlspecialchars() - Escapes the following characters: &,’,”,>,< ...that is the ampersand, single quote, double quote, less than, and greater than symbols. htmlspecialchars () - निम्न वर्ण पलायन: &,',",>,< ... कि ampersand, एकल उद्धरण, दोहरे उद्धरण, से भी कम है, और प्रतीकों से अधिक है.
  • strip_tags() - Strips out all HTML and PHP code from the given string. strip_tags () को दी स्ट्रिंग से - स्ट्रिप्स बाहर सभी HTML और php code.
  • htmlentities() - Converts ALL characters to their HTML entities equivalent (this is a more catch all version of htmlspecialchars). htmlentities () - धर्मान्तरित ALL अक्षर अपने HTML संस्थाओं समकक्ष (इस करने के लिए एक अधिक htmlspecialchars के सभी संस्करण पकड़) है.
  • urlencode() - Encodes the URL to pass strings on a GET method. urlencode () - एक विधि प्राप्त पर तार पारित करने के लिए यूआरएल Encodes. As I mentioned, don’t use GET with forms. जैसा कि मैंने उल्लेख किया, स्वरूपों के साथ प्रयोग नहीं करते. This is useful when you’re passing user input variables for other reasons. यह तब होता है जब आप अन्य कारणों से उपयोगकर्ता इनपुट चर गुजर रहे हैं उपयोगी है.

Remember, once you convert data like this using one of the above functions, you can undo it for readability and output by using its reverse function. urlencode() for example has urldecode() to undo its actions so you can begin using the string as you would have before the encode. याद है, एक बार आप इस उपर्युक्त कार्यों का एक का उपयोग कर की तरह डेटा convert, तुम पठनीयता और उत्पादन के लिए (उदाहरण के लिए) urldecode है इसके विपरीत कार्य करती हैं. Urlencode का उपयोग करके () ताकि आप स्ट्रिंग के रूप में उपयोग कर शुरू कर सकते हैं अपने कार्यों पर पानी फेर करने के लिए इसे पूर्ववत करें कर सकते हैं आप इस से पहले सांकेतिक शब्दों में बदलना होगा.

Check Request Method जाँच का अनुरोध विधि
Throw an if statement around your existing form processor that checks to see if data is coming from the globals post variable. एक तो अपने मौजूदा फार्म का प्रोसेसर के चारों ओर कथन है कि जाँच अगर डेटा को globals पोस्ट चर से आ रही है देखने के लिए फेंको. If not, then the user is not accessing your form the way you designed it to be used. है, तो उपयोगकर्ता आपके प्रपत्र आप इसे इस्तेमाल किया जा करने के लिए डिज़ाइन तक पहुँचने का रास्ता नहीं है अगर नहीं.

  1. <?php
  2. if ( $_SERVER [ ‘REQUEST_METHOD’ ] == ‘POST’ ) {
  3. //typical form processes
  4. } else {
  5. echo "The form can not be used like that" ; फार्म का echo "The form can not be used like that" ;
  6. }
  7. ?>

Change this to GET if you’re using that instead. अगर आपको लगता है कि बजाय प्रयोग कर रहे हैं इस बदलें प्राप्त करने के लिए. However, I would high recommend you never use that method as it is more insecure. हालांकि, मैं उच्च के रूप में इसे और अधिक असुरक्षित है आपको लगता है कि विधि का प्रयोग कभी नहीं सुझा सकता है.

Check Request Source जाँच का अनुरोध स्रोत
You should also check to see if the request is originating from your own server. आप भी अगर इस अनुरोध को अपने खुद के सर्वर से प्रारंभिक है देखने के लिए जाँच करनी चाहिए. This is a very common method of form abuse which doesn’t necessarily mean you’ll be receiving spam. इस फार्म का दुरुपयोग के जो जरूरी आप स्पैम प्राप्त होगा इसका मतलब यह नहीं है एक बहुत ही सामान्य विधि है. If you’re server is getting a lot of bounced emails to its default email you may have someone abusing your site in this manner. यदि आप सर्वर रहे हैं की एक बहुत कुछ हो रहा है उसके डिफ़ॉल्ट ईमेल करने के लिए आप किसी को इस तरह से अपनी साइट अपमान किया है मई ईमेल bounced.

  1. <?php
  2. $source = $_SERVER [ ‘HTTP_HOST’ ] ;
  3. //or if you want to detect just the domain you can use a regular expression to filter it.
  4. $source = ereg_replace ( "^(www.)?([^.] ).[^.] $" , " \\ 2" , $_SERVER [ ‘HTTP_HOST’ ] ) ;
  5. if ( $source !== "robmalon.com" ) {
  6. echo "you are illegally accessing this script" ; इस echo "you are illegally accessing this script" ;
  7. } else {
  8. //typical form processes
  9. }
  10. //The referrer should also be from your own domain…Likewise, if there is no referral then the user obviously isnt using your form correctly (so we dont have to check for that).
  11. //Note: stristr() searches for the first occurrence of a string inside another string.
  12. if ( stristr ( getenv ( "HTTP_REFERER" ) , $source ) ) {
  13. //typical form processes
  14. } else {
  15. echo "you are illegally accessing this script" ; इस echo "you are illegally accessing this script" ;
  16. }
  17. ?>

Using Regular Expressions For Data Validation डेटा सत्यापन के लिए नियमित अभिव्यक्ति का उपयोग
I like to check data using preg_match (or any of the regular expression functions). मैं डेटा preg_match का उपयोग कर की जाँच करने के लिए तरह (या किसी भी नियमित अभिव्यक्ति कार्यों का). This method kills a lot of birds with one stone. इस पद्धति का एक पत्थर के साथ पक्षियों के एक बहुत मारता है. Why write separate functions to check if a string is empty, then another if it allows numbers, and another if it allows alpha characters, and another to specific field length, and another…you get the point. क्यों की जाँच करने के लिए अलग से काम करता है लिख अगर एक स्ट्रिंग खाली है, तो फिर एक और अगर यह, और संख्याओं की अनुमति देता है एक और अगर यह अल्फा वर्णों की अनुमति देता है, और एक अन्य विशिष्ट क्षेत्र लंबाई करने के लिए, और दूसरा ... क्या तुम इस बात मिलता है.

if (!preg_match(”/^[A-z0-9]{5,15}$/”, $name)) $error .= “<li class=\”errors\”>The Name field can only contain letters and numbers (no spaces) and can only be up to 15 characters long.</li>”; अगर (! preg_match ("/^[ A-z0-9] (5,15 }$/", $ नाम)) $ त्रुटि .= "<li class=\"errors\"> का नाम कोष्ठक केवल अक्षर शामिल कर सकते हैं और संख्या (कोई रिक्त स्थान) और कर सकते हैं केवल 15 वर्णों तक का ही होना चाहिए. </ ली> ";

In the preg_match I am checking that the name field only contains alphanumeric values (case insensitive) and needs to be at least 5 to 15 characters in length. मुझे लगता है कि इस नाम का क्षेत्र केवल (केस) असंवेदनशील अक्षरांकीय मूल्यों शामिल है और लंबाई में कम से कम 5 से 15 अक्षर किए जाने की आवश्यकता की जाँच कर रहा हूँ preg_match में. If you don’t meet that specification appropriate text is added to $error. यदि आपको लगता है कि विनिर्देशन उपयुक्त पाठ को पूरा नहीं करते $ करने के लिए त्रुटि जोड़ा है.

Using “[variable] [dot][equals] [text]” in this fashion allows me to keep an ongoing variable that I’m adding to. "[चर] का उपयोग [] डॉट [बराबर] [पाठ]" इस फैशन में मुझे कि मैं जोड़ने के लिए कर रहा हूँ एक चल रहे चर रखने के लिए अनुमति देता है. I can then check to see if $error contains any data before my script does any significant queries. मैं तो त्रुटि अगर $ देखने के लिए जाँच कर सकते हैं मेरी स्क्रिप्ट से पहले किसी भी डेटा शामिल है कोई महत्वपूर्ण प्रश्न करता है. If there are errors you can spit them out by echoing $error and ask the user to correct them. यदि आप त्रुटि $ दोहराने और उपयोगकर्ता पूछना उन correct करने से उन्हें बाहर थूक कर सकते हैं त्रुटियाँ हैं. I then use CSS to style my errors which you can see with class=\”errors\”. मैं तो सीएसएस करने के लिए शैली मेरी त्रुटियों को आप कक्षा के साथ = \ "त्रुटियाँ जो देख सकते हैं \" का प्रयोग करें.

Regular expressions defiantly have a learning curve on them but they are one of the best tools that can help simplify your life in a variety of situations. नियमित अभिव्यक्ति defiantly उन पर एक सीखने की अवस्था है लेकिन वे एक बेहतरीन औजार की है कि परिस्थितियों की एक किस्म में अपने जीवन को आसान बनाने में मदद कर सकते हैं. I’ll go into more detail about them down the road but for now you may want to buy a book or do some Googling. मैं और अधिक विस्तार में उनके बारे में सड़क पर नीचे जाऊँगा के लिए अब तुम एक पुस्तक खरीदने के लिए या कुछ Googling करना चाहते हो सकता है.

The Non-Technical Recap इस गैर तकनीकी पुनर्कथन
-Implement a CAPTCHA script. -एक कॅप्चा स्क्रिप्ट लागू.
-Escape slashes (and other bad characters). (और अन्य बुरा अक्षर) slashes भागने.
-Check to see if data is coming to your form using the correct method. यदि आपके डेटा बनाने के लिए सही पद्धति का उपयोग करके आ रहा है देखने के लिए जाँच करें.
-Check to see if the request is originating from your own server. -अगर इस अनुरोध को अपने खुद के सर्वर से प्रारंभिक है देखने के लिए जाँच करें.
-Check data using a regular expression. -डेटा एक नियमित अभिव्यक्ति का उपयोग करके देखें.

This is just the tip of the iceberg for what I can tell you about spam. यह मैं स्पैम के बारे में तुम क्या बता सकते हैं के लिए हिमशैल के सिर्फ टिप है. Thats why I’ve decided to make a mini series of it. Thats क्यों मैं इसका एक छोटा श्रृंखला बनाने का फैसला कर लिया है. Over the next couple weeks I will be bringing you more detailed ways I deal with spam. मैं स्पैम के साथ मैं सौदा अधिक विस्तृत तरीके तुम लाने होंगे अगले कुछ सप्ताहों में. Comment below or email me about your own spam preventative methods. टिप्पणी के नीचे या अपने खुद के स्पैम के बारे में मुझे ईमेल preventative तरीकों. If it is a new or unique technique I will post it in a future blog along with a link back to your blog. अगर यह मैं एक भविष्य के ब्लॉग में एक लिंक वापस अपने ब्लॉग के लिए के साथ यह पोस्ट करेंगे एक नई या अनोखी तकनीक है. Just write in the comments below and include your URL in the website field. बस नीचे दिए गए टिप्पणियों में लिखने और वेबसाइट के क्षेत्र में अपना यूआरएल शामिल हैं.


1 Comment(s) On 1 टिप्पणी (s) पर

"5 Ways To Catch And Prevent Website Form Spam - Part 1" "5 तरीके पकड़ने के लिए और रोकें वेबसाइट पर्चा स्पैम - भाग 1"
  1. MyAvatars 0.2 Rob - Mar 5, 2008 रोब - मार्च 5, 2008

    It just occured to me…setting up those if statements with a die() statement might be easier for a quick and dirty method. यह सिर्फ मेरे साथ हुआ ... उन लोगों की स्थापना अगर एक () बयान मरने के साथ बयान एक त्वरित और गंदा प्रक्रिया के लिए आसान हो सकता है. Which I’m sure most of you at least for now would want a quickfix to just toss in. Keep that in mind…Something like this: जो मुझे यकीन है कि तुम में से सबसे रहा हूँ कम से कम अभी के लिए बस टॉस करने के लिए एक quickfix चाहेगा अंदर यह है कि मन में ... कुछ तरह रखें:

    if ($_SERVER[‘REQUEST_METHOD’] !== ‘POST’) { die(”The form can not be used like that”); } ($ अगर _SERVER [ 'REQUEST_METHOD']! == 'पोस्ट') (( "के फार्म का इस तरह से" ") प्रयोग नहीं किया जा सकता मर;)

    You can put that anywhere at the beginning of a script for it to take effect without worrying about existing code too much. तुम रख सकते हैं कि एक स्क्रिप्ट की शुरुआत में कहीं भी के लिए यह मौजूदा कोड के बारे में बहुत ज्यादा चिंता के बिना प्रभाव लेने के लिए.



Leave A Comment: एक टिप्पणी को छोड़ दें:

Comments RSS Feed टिप्पणियाँ RSS फ़ीड

7 3 = 7 3 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. कस्टम थीम रोब Malon द्वारा | सामग्री व डिजाइन © 2008 - रोब Malon [डॉट] com. "));
"));