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? خاصة مع هذه الشبكة الجديدة 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 الهروب البيانات -- منع مزود الحقن
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 () -- الهروب الأحرف التالية : &،'،"،>،<... هذه هي الو ، اقتبس واحدة ، مزدوجة أقتبس ، أقل من ، وأكبر من الرموز.
  • strip_tags() - Strips out all HTML and PHP code from the given string. strip_tags () -- الأشرطة جميع هتمل وPHP رمز من سلسلة نظرا ل.
  • htmlentities() - Converts ALL characters to their HTML entities equivalent (this is a more catch all version of htmlspecialchars). htmlentities () -- تحويل جميع الحروف لهتمل الكيانات يعادل (هذا هو أكثر المصيد كل نسخة من htmlspecialchars).
  • urlencode() - Encodes the URL to pass strings on a GET method. urlencode () -- يشفر عنوان الموقع لتمرير قيود على الحصول على الطريقة. 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. تذكر ، مرة واحدة لكم تحويل مثل هذه البيانات باستخدام واحدة من المهام المذكورة أعلاه ، يمكنك التراجع عن ذلك لسهولة القراءة والانتاج بواسطة عكس وظيفة. urlencode () على سبيل المثال قد urldecode () إلى التراجع عن إجراءاتها حتى يمكنك أن تبدأ باستخدام سلسلة حسب قمتم قبل رموز.

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. وهو إلقاء بيان حول إذا القائمة الخاصة بك على شكل شيكات أن المعالج لمعرفة ما اذا كانت البيانات هي قادمة من غلوبالس بعد متغير. 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" ;
  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. إذا كنت الخادم هو الحصول على الكثير من رسائل البريد الإلكتروني للصعود إلى البريد الإلكتروني الافتراضي قد تكون لديكم شخص باساءة معاملة موقعك بهذه الطريقة.

  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" ;
  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" ;
  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 دولار}$/"، اسم)) خطأ دولار.= "<liclass=\"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. في preg_match أنا التحقق من أن اسم المجال فقط يحتوي على القيم الأبجدي (غير حساس لحالة الأحرف) ، ويحتاج إلى أن يكون على الأقل من 5 إلى 15 حرفا في الطول. 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. وإذا كانت هناك أخطاء يمكنك يبصقون عليهم بترديد دولار الخطأ ويطلب من المستخدم لتصحيحها. 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. العادية عبارات تحد لها على منحنى التعلم منها لكنها واحدة من أفضل الأدوات التي يمكن أن تساعد في تبسيط حياتك في مجموعة متنوعة من الحالات. 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). الهروب بين شرائح (وأخرى سيئة حرفا).
-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. ولهذا السبب أنا قررت تقديم مجموعة مصغرة من ذلك. 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. دون تعليق أو البريد الإلكتروني الخاصة بك لي عن البريد المزعج أساليب وقائية. 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 التعليق (ق) وفي

"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 التعليقات آر إس إس

7 Added To 3 = 7 ويضاف إلى 3 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. عرف الموضوع من جانب روب Malon | المحتوى و التصميم © 2008 -- روب Malon [نقطة] كوم. "));
"));