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). Am folosit pentru a obţine atât de mult spam în cutia mea poştală de zi cu zi pe care am mai mult timp de cheltuieli a fost de a şterge-o apoi am fost adăugarea de conţinut nou, menţinerea de site-uri, incepand de noi site-uri sau combinate (uzual poveste dreapta). 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. Unele din site-ul dvs. nu este spam prevenite, sau, este evitată, dar la costul de utilizare şi / sau obţinerea de informaţii bine prins în "lucruri rele", de asemenea.

No doubt, if you’re serious about web development you’re going to be creating and interacting with forms on a regular basis. Fără îndoială, dacă sunteţi serios despre dezvoltare web veţi fi crearea si interactiunea cu forme în mod regulat. Especially with this new web 2.0 attitude every has…gee wiz, what’s that? Mai ales cu acest nou web 2.0 atitudine are fiecare cal ... wiz, ce-i asta?

CAPTCHA CAPTCHA
CAPTCHA is the number one method most people are using to prevent spam today. CAPTCHA este numărul unu metodă de cele mai multe persoane sunt utilizaţi pentru a preveni spam de azi. What is it? Ce este?

“A CAPTCHA is a challenge response test used on computers to check if the user is human. "Un CAPTCHA este o provocare de răspuns de pe computerele de test utilizate pentru a verifica dacă utilizatorul este uman. A common kind of CAPTCHA that is used on websites requires that the visitor type the letters and numbers of a distorted image. Un fel de comune de CAPTCHA care este utilizat de pe site-uri de Web cere ca tipul de vizitator de litere şi numere dintr-o imagine distorsionată. 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 Această metodă se bazează pe faptul că este dificil pentru computere pentru a extrage textul din imagine în timp ce este foarte uşor pentru om. "- Captchacreator.com

Here’sa few resources to scripts so you’ll be able to implement that functionality into your own forms: Iata cateva resurse pentru a script-uri de aşa veţi putea să pună în aplicare ca funcţionalitate în propriile forme:

Escape Data - Prevent SQL Injections Evadare de date - SQL preveni preparate injectabile
Capcha is usless if you’re leaving your form unprotected from attack. Capcha este usless dacă sunteţi dvs. de a pleca de la forma neprotejat atac. Remember to filter post strings with addslashes() or mysql_real_escape_string() . Amintiţi-vă să filtru de post cu siruri de caractere addslashes () sau mysql_real_escape_string ().

Also take a look at these functions for other similar kind of checks that might be useful: De asemenea, să aruncaţi o privire la aceste funcţii similare pentru alte tipuri de controale care ar putea fi de folos:

  • htmlspecialchars() - Escapes the following characters: &,’,”,>,< ...that is the ampersand, single quote, double quote, less than, and greater than symbols. htmlspecialchars () - scapă următoarele caractere: &,',",>,< ... care este ampersand, singur citat, citat dublu, mai puţin de, şi mai mare de simboluri.
  • strip_tags() - Strips out all HTML and PHP code from the given string. strip_tags () - benzi toate cod HTML şi PHP de la şirul dat.
  • htmlentities() - Converts ALL characters to their HTML entities equivalent (this is a more catch all version of htmlspecialchars). htmlentities () - conversia tuturor caractere pentru a lor HTML entităţi echivalente (aceasta este o versiune mai prind toate de htmlspecialchars).
  • urlencode() - Encodes the URL to pass strings on a GET method. urlencode () - codifică URL-ul pentru a transmite siruri de caractere pe o metoda GET. As I mentioned, don’t use GET with forms. După cum am menţionat, nu folosesc GET cu forme. This is useful when you’re passing user input variables for other reasons. Acest lucru este util atunci când sunteţi utilizator care trece variabilele de intrare pentru alte motive.

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. Nu uitaţi, după ce vă place acest conversia de date, folosind una dintre funcţiile de mai sus, puteţi să anulaţi-o pentru lizibilitate şi de ieşire prin utilizarea funcţiei sale de revers. Urlencode () de exemplu a urldecode () pentru a anula acţiunile sale, astfel încât să puteţi începe folosind şirul de caractere ca ar trebui, înainte de a codifica.

Check Request Method Verificaţi Cerere de metoda
Throw an if statement around your existing form processor that checks to see if data is coming from the globals post variable. Arunca o declaraţie în jurul tău, dacă existente forma procesor că verificările de date, pentru a vedea dacă vine de la post globals variabilă. If not, then the user is not accessing your form the way you designed it to be used. Dacă nu, atunci utilizatorul nu vă accesează formularul de felul în care este proiectat pentru a fi utilizate.

  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. GET pentru a schimba acest lucru, dacă utilizaţi ca în loc. However, I would high recommend you never use that method as it is more insecure. Cu toate acestea, am ridicat-ar recomandăm să nu utilizaţi această metodă, deoarece este mai nesigure.

Check Request Source Verificaţi Cerere de sursă
You should also check to see if the request is originating from your own server. Ar trebui de asemenea să verificaţi, pentru a vedea dacă cererea este provenite de la propriul dvs. server. This is a very common method of form abuse which doesn’t necessarily mean you’ll be receiving spam. Aceasta este o metoda foarte comună formă de abuz, care nu înseamnă neapărat că veţi fi primirea de 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. Dacă server-se o multime de email-uri returnate său implicit de e-mail pentru a te putea avea cineva abuzând de pe site-ul dvs. în acest mod.

  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 Utilizarea expresiilor regulate pentru date de validare
I like to check data using preg_match (or any of the regular expression functions). Îmi place să verifice, folosind date preg_match (sau oricare din funcţiile de expresie regulată). This method kills a lot of birds with one stone. Această metodă ucide o mulţime de păsări cu unul de piatra. 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. De ce scrie funcţii separate pentru a verifica dacă un şir de caractere este gol, apoi un alt dacă se permite numere, şi dacă se permite un alt alfa de caractere, şi un alt domeniu specific pentru lungime, şi ... să-un alt punct.

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>”; dacă (! preg_match ("/^[ A-z0-9] (5,15 }$/", $ nume)) $ eroare .= "<li class=\"errors\"> Nume de domeniu poate conţine doar litere şi numere (fără spaţii) şi poate fi de până la 15 de caractere. </ li> ";

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. În preg_match Sunt de verificare de nume de domeniu care conţine numai valori alfanumerice (majuscule / litere mici) şi trebuie să fie de cel puţin 5 la 15 caractere lungime. If you don’t meet that specification appropriate text is added to $error. Dacă nu vă satisface specificaţia că este cazul de tip text se adaugă la $ eroare.

Using “[variable] [dot][equals] [text]” in this fashion allows me to keep an ongoing variable that I’m adding to. Utilizarea "[variabila] [punct] [egal] [text]", în acest mod de a-mi permite să o variabilă în curs de desfăşurare care sunt adăugaţi la. I can then check to see if $error contains any data before my script does any significant queries. Nu pot verifica apoi pentru a vedea dacă $ eroare conţine nici un fel de date înainte de script-ul nu-mi orice semnificative interogări. If there are errors you can spit them out by echoing $error and ask the user to correct them. Dacă există erori puteţi să le scuipa de $ sonor de eroare şi să solicite utilizatorului să le corectaţi. I then use CSS to style my errors which you can see with class=\”errors\”. Am folosi apoi pentru a CSS stilul meu de erori pe care le puteţi vedea cu clasa = \ "erori \".

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. Expresii regulate defiantly au o curbă de învăţare pe ele dar sunt unul dintre cele mai bune instrumente care pot ajuta procesul de viaţă într-o varietate de situaţii. 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. Voi merge în mai multe detalii despre ei pe drum, dar de acum poate doriţi să cumpere o carte sau faci unele Googling.

The Non-Technical Recap Non-tehnice de recapitulare
-Implement a CAPTCHA script. -Implementarea unui script de CAPTCHA.
-Escape slashes (and other bad characters). Escape-slashes (şi alte rele de caractere).
-Check to see if data is coming to your form using the correct method. -Verificaţi pentru a vedea dacă a datelor este de a veni la dvs., folosind formularul, metoda corect.
-Check to see if the request is originating from your own server. -Verificaţi pentru a vedea dacă cererea este provenite de la propriul dvs. server.
-Check data using a regular expression. Verificaţi-date printr-o expresie regulata.

This is just the tip of the iceberg for what I can tell you about spam. Acesta este doar vârful de iceberg pentru ceea ce pot să vă spun despre spam. Thats why I’ve decided to make a mini series of it. Asta am de ce aţi decis să faceţi o serie de mini-o. Over the next couple weeks I will be bringing you more detailed ways I deal with spam. In urmatoarele câteva săptămâni, mi se vor aduce mai multe modalităţi detaliate Eu face cu spam. Comment below or email me about your own spam preventative methods. Comentariul de mai jos sau e-mail-mi despre propriile metode preventive de spam. If it is a new or unique technique I will post it in a future blog along with a link back to your blog. Dacă este o nouă tehnică de unic sau voi post-l într-un viitor blog, împreună cu un link inapoi la blog-ul. Just write in the comments below and include your URL in the website field. Doar scrie în comentariile de mai jos şi include URL-ul dvs. în domeniul site-ul web.


1 Comment(s) On 1 comentariu (i) Pe

"5 Ways To Catch And Prevent Website Form Spam - Part 1" "5 moduri de a captura şi de a preveni spam Formular de Site Web - Partea 1"
  1. MyAvatars 0.2 Rob - Mar 5, 2008 Rob - Martie 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. A apărut doar la mine ... de înfiinţare, dacă aceste declaraţii cu o muri () declaraţie ar putea fi mai uşor pentru o metodă rapidă şi murdar. 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: Care sunt cele mai sigur de tine, cel puţin pentru acum ar fi nevoie de un quickfix doar pentru a se zvârcoli inch Păstraţi în minte că ... ceva de genul:

    if ($_SERVER[‘REQUEST_METHOD’] !== ‘POST’) { die(”The form can not be used like that”); } dacă ($ _SERVER [ 'REQUEST_METHOD']! == 'POST') (die ( "Formularul nu poate fi folosit ca asta");)

    You can put that anywhere at the beginning of a script for it to take effect without worrying about existing code too much. Puteţi pune oriunde că de la începutul unui script pentru a avea efect fără a avea grija de cod existent prea mult.



Leave A Comment: Lăsaţi un comentariu:

Comments RSS Feed Comentarii RSS Feed

7 - 2 = 7 - 2 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. Tema la comandă de către Rob Malon | Design & Content © 2008 - Rob Malon [punct] com. "));
"));