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). Ja se koriste kako bi dobili toliko neželjene pošte u moj spremnik svakodnevnom da mi je više vremena provodite obriše onda sam dodao novog sadržaja, održavanje web lokacije, ili s početkom nove stranice kombinaciji (tipična priča desno). 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. Neki od neželjenih sadržaja Vaše web lokacije ne preventable, ili, što je preventable, ali po cijenu upotrebljivost i / ili dobre informacije dobivanje zatečen u "loše stvari" kao dobro.

No doubt, if you’re serious about web development you’re going to be creating and interacting with forms on a regular basis. Nema sumnje, ako ste ozbiljni o web razvoju idete na stvaranje i interakcije s obrascima na regularnoj osnovi. Especially with this new web 2.0 attitude every has…gee wiz, what’s that? Pogotovo sa ovim novim web 2.0 stav svaki ima ... điha talentovana osoba, što je to?

CAPTCHA CAPTCHA
CAPTCHA is the number one method most people are using to prevent spam today. CAPTCHA je broj jedan način većina ljudi koriste kako bi se spriječila neželjena pošta danas. What is it? Što je to?

“A CAPTCHA is a challenge response test used on computers to check if the user is human. "A CAPTCHA izazove je odgovor test se koristi na računalima kako biste provjerili je li korisnik ljudskih. A common kind of CAPTCHA that is used on websites requires that the visitor type the letters and numbers of a distorted image. Zajedničke vrste CAPTCHA koji se koristi na web stranice potrebno je da posjetitelj upišite slova i brojeve od iskrivljene slike. 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 Ova metoda se temelji na činjenici da je teško za računala na ekstrakt tekst iz slike, dok je vrlo lako za ljude. "- Captchacreator.com

Here’sa few resources to scripts so you’ll be able to implement that functionality into your own forms: Here'sa nekoliko resursa za skripte pa ćete moći provoditi funkcionalnost da se u vlastite obrasce:

Escape Data - Prevent SQL Injections Escape podataka - SQL spriječiti davanja injekcija
Capcha is usless if you’re leaving your form unprotected from attack. Capcha je usless ako si ti ostavljanja oblik nezaštićeni od napada. Remember to filter post strings with addslashes() or mysql_real_escape_string() . Ne zaboravite da filtra post žice sa addslashes () ili mysql_real_escape_string ().

Also take a look at these functions for other similar kind of checks that might be useful: Također pogledajte te funkcije i za druge slične vrste provjera koje bi mogle biti korisne:

  • htmlspecialchars() - Escapes the following characters: &,’,”,>,< ...that is the ampersand, single quote, double quote, less than, and greater than symbols. htmlspecialchars () - Escapes sljedeće znakove: &,',",>,< ... to je znak za struju, Quote jednokrevetna, dvokrevetna citat, manje od, i veći od simbola.
  • strip_tags() - Strips out all HTML and PHP code from the given string. strip_tags () - traka iz svih HTML i PHP koda s obzirom na niz.
  • htmlentities() - Converts ALL characters to their HTML entities equivalent (this is a more catch all version of htmlspecialchars). htmlentities () - pretvara sve znakove njihove HTML entiteta ekvivalent (ovo je više uhvatiti sve verziju htmlspecialchars).
  • urlencode() - Encodes the URL to pass strings on a GET method. urlencode () - kodira URL proći žice na GET metoda. As I mentioned, don’t use GET with forms. Kao što sam spomenuo, ne koriste DOBITI s oblicima. This is useful when you’re passing user input variables for other reasons. Ovo je korisno ako ste u prolazu korisnik varijable za unos drugih razloga.

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. Podsjećamo, nakon što pretvorite podataka kao što je ovaj jednom od navedenih funkcija, možete poništiti za čitljivost i izlaz pomoću obrnutog svojih funkcija. Urlencode () za primjer ima urldecode () kako bi poništili svoje akcije tako da možete početi koristiti kao niz ti bi prije šifrirati.

Check Request Method Provjerite zahtjev metoda
Throw an if statement around your existing form processor that checks to see if data is coming from the globals post variable. Baciti jedan ako izjavi oko Vaš postojeći oblik procesor koji provjerava da li se podaci dolaze iz globals post varijable. If not, then the user is not accessing your form the way you designed it to be used. Ako ne, onda korisnik nema pristupa Vašem obrascu na način na koji ste osmišljen je da se koristi.

  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. Promijenite to DOBITI ako se u tome što umjesto. However, I would high recommend you never use that method as it is more insecure. Međutim, ja bih visoko preporučiti vam da nikada ne koristiti metode kao što je više nepouzdan.

Check Request Source Provjerite zahtjev izvor
You should also check to see if the request is originating from your own server. Vi bi također trebali provjeriti da li je zahtjev iz vlastitog servera. This is a very common method of form abuse which doesn’t necessarily mean you’ll be receiving spam. To je vrlo uobičajena metoda oblik zlostavljanja koje ne znači da ćete biti primanja neželjenih poruka. 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. Ako poslužitelj postaje puno bounced e-poštu na svoje zadane e-pošte koju svibanj imati nekoga abusing vaših stranica na ovaj način.

  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 Korištenje Regularni izraz za provjeru ispravnosti podataka
I like to check data using preg_match (or any of the regular expression functions). Ja bih da provjerite podatke koristeći preg_match (ili bilo koju od regularnih izraza funkcija). This method kills a lot of birds with one stone. Ova metoda ubija velike ptice s jednim kamenom. 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. Zašto pisati odvojene funkcije za provjeru je li niz je prazna, a zatim još jedan ako to dopušta broj, a drugi ako ga omogućuje alfa znakova, a drugi na području određene dužine, a drugi ... ste dobili točki.

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>”; if (! preg_match ("/^[ A-z0-9] (5,15 }$/", $ ime)) $ pogreška .= "<li class=\"errors\"> U polje Ime može sadržavati samo slova i brojeva (bez razmaka) i mogu biti samo do 15 znakova. </ 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. U preg_match sam da provjere ime polje sadrži samo alfanumeričke vrijednosti (case insensitive) i mora biti najmanje 5 do 15 znakova. If you don’t meet that specification appropriate text is added to $error. Ako ne zadovoljava specifikaciju odgovarajući tekst koji se dodaje na $ pogreške.

Using “[variable] [dot][equals] [text]” in this fashion allows me to keep an ongoing variable that I’m adding to. Korištenje "[varijablu] [dot] [izjednačuje] [tekst]" u ovom moda dopušta meni da bi jedan aktivni varijable koje sam dodao da. I can then check to see if $error contains any data before my script does any significant queries. Ne mogu a zatim provjerite je li $ o pogrešci sadrži sve podatke prije nego što moje skripte ne bilo koji značajan upite. If there are errors you can spit them out by echoing $error and ask the user to correct them. Ako postoje greške možete ih pljuvati po PLIMNI $ pogrešku i zatražiti od korisnika da ispravite ih. I then use CSS to style my errors which you can see with class=\”errors\”. I onda koristiti CSS u stilu moje pogreške koje možete vidjeti sa klase = \ "greške \".

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. Redovita defiantly izrazi imaju krivulja učenja na njima, ali oni su jedan od najboljih alata koji mogu pomoći pojednostaviti svoj život u različitim situacijama. 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. Ja ću ići u više detalja o njima dolje na cesti, ali za sada vam svibanj želite kupiti knjigu ili napraviti nešto Googling.

The Non-Technical Recap Non-tehničke rekapitulacija
-Implement a CAPTCHA script. -Provodi CAPTCHA skripta.
-Escape slashes (and other bad characters). -Escape slashes (i drugim lošeg znakova).
-Check to see if data is coming to your form using the correct method. -Provjeriti da li se podaci koji dolaze na svoj oblik koristeći ispravan način.
-Check to see if the request is originating from your own server. -Provjeriti da li je zahtjev iz vlastitog servera.
-Check data using a regular expression. -Provjerite podatke pomoću regularnih izraza.

This is just the tip of the iceberg for what I can tell you about spam. Ovo je samo napojnica u santa leda za ono što ja mogu reći o neželjena pošta. Thats why I’ve decided to make a mini series of it. Thats zašto sam odlučio napraviti mini-serija od toga. Over the next couple weeks I will be bringing you more detailed ways I deal with spam. Tijekom narednih nekoliko tjedana bit ću vam donosi detaljnije načine sam se bave spam. Comment below or email me about your own spam preventative methods. Komentar ispod ili e-pošta mene o vlastitu neželjene pošte preventivnih metoda. If it is a new or unique technique I will post it in a future blog along with a link back to your blog. Ako je to novi ili jedinstveni tehnika ću ga objaviti u budućnost bloga, uz link nazad na svoj blog. Just write in the comments below and include your URL in the website field. Samo napiši u komentare ispod i uključite svoj URL u polje web stranice.


1 Comment(s) On 1 Komentar (a) Na

"5 Ways To Catch And Prevent Website Form Spam - Part 1" "5 NAČINI uhvatiti i spriječiti Web stranica Obrazac Spam - 1. dio"
  1. MyAvatars 0.2 Rob - Mar 5, 2008 Rob - 5. ožujka 2008

    It just occured to me…setting up those if statements with a die() statement might be easier for a quick and dirty method. Ona se dogodila upravo za mene ... ako postavljate one izvještaje s umrijeti () izjava može biti jednostavnije za brz i prljavi način. 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: Koji siguran sam da većina od vas barem za sada bi se žele quickfix samo bacanje rezervirati Imajte na umu da ... nešto poput ovoga:

    if ($_SERVER[‘REQUEST_METHOD’] !== ‘POST’) { die(”The form can not be used like that”); } if ($ _SERVER [ 'REQUEST_METHOD']! == 'POST') (umrijeti ( "U formu se ne mogu koristiti kao da je");)

    You can put that anywhere at the beginning of a script for it to take effect without worrying about existing code too much. Možete staviti da negdje na početku skriptu za nju stupiti na snagu bez brige o postojećim kôd previše.



Leave A Comment: Ostavi komentar:

Comments RSS Feed Komentari RSS Feed

8 Minus 1 = 8 Minus 1 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. Custom Theme by Rob Malon | Sadržaj & Design © 2008 - Rob Malon [dot] com. "));
"));