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). Kiedyś się tak dużo spamu w mojej skrzynce codziennego, że byłem wydatków więcej czasu, usuwając je potem byłem dodawania nowych treści, utrzymania witryny, lub rozpoczęcia nowych miejsc łączone (typowa historia prawej). 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. Niektóre witryny internetowej jest spam nie można zapobiec, lub jest zapobiec, ale na koszt użycia i / lub dobre informacje otrzymuję złowionych w "złe rzeczy" 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. Bez wątpienia, jeśli poważnie internetowych rozwoju masz zamiar zostać tworzenia i interakcji z formularzy w sposób regularny. Especially with this new web 2.0 attitude every has…gee wiz, what’s that? Specjalnie z tej nowej web 2.0 ma ... co postawę Gee czarodziej, co to jest?

CAPTCHA CAPTCHA
CAPTCHA is the number one method most people are using to prevent spam today. CAPTCHA jest numer jeden sposób większość ludzi jest używany w celu zapobieżenia spam dziś. What is it? Co to jest?

“A CAPTCHA is a challenge response test used on computers to check if the user is human. "A CAPTCHA jest wyzwaniem odpowiedzi na test używanych komputerów, aby sprawdzić, czy użytkownik jest człowiekiem. A common kind of CAPTCHA that is used on websites requires that the visitor type the letters and numbers of a distorted image. Wspólna rodzaj CAPTCHA, który jest używany na stronach internetowych wymaga, aby odwiedzający wpisz litery i cyfry na zniekształcony obraz. 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 Metoda ta opiera się na fakcie, że jest trudny dla komputerów, aby wyodrębnić tekst z obrazka, natomiast jest bardzo łatwe dla ludzi. "- Captchacreator.com

Here’sa few resources to scripts so you’ll be able to implement that functionality into your own forms: Oto kilka środków na skrypty dzięki czemu będziemy w stanie realizować funkcje, które na własne formy:

Escape Data - Prevent SQL Injections Escape danych - SQL injection zapobiec
Capcha is usless if you’re leaving your form unprotected from attack. Capcha jest usless jeśli pozostawiając formę niezabezpieczone przed atakiem. Remember to filter post strings with addslashes() or mysql_real_escape_string() . Pamiętaj, aby filtr po smyczki z addslashes () lub mysql_real_escape_string ().

Also take a look at these functions for other similar kind of checks that might be useful: Również przyjrzeć się tych funkcji na innych podobnego rodzaju kontroli, które mogą być przydatne:

  • htmlspecialchars() - Escapes the following characters: &,’,”,>,< ...that is the ampersand, single quote, double quote, less than, and greater than symbols. htmlspecialchars () - Escapes następujących znaków: &,',",>,< ... że jest ampersand, pojedynczy cudzysłów, podwójny cudzysłów, mniejsze i większe niż symbole.
  • strip_tags() - Strips out all HTML and PHP code from the given string. strip_tags () - Taśmy obecnie wszystkie kodu HTML i PHP z danego łańcucha.
  • htmlentities() - Converts ALL characters to their HTML entities equivalent (this is a more catch all version of htmlspecialchars). htmlentities () - Konwertuje wszystkie znaki na ich podmioty równoważne HTML (jest to bardziej połowu wszystkich wersji htmlspecialchars).
  • urlencode() - Encodes the URL to pass strings on a GET method. urlencode () - Koduje URL ciągi przejść na metodę GET. As I mentioned, don’t use GET with forms. Jak już wspomniałem, nie korzystają z form GET. This is useful when you’re passing user input variables for other reasons. Jest to przydatne, jeśli użytkownik przechodzi zmiennych wejściowych z innych powodów.

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. Należy pamiętać, że po tym jak konwertować dane za pomocą jednej z wyżej wymienionych funkcji, można ją cofnąć w celu zachowania czytelności i wyjściowych za pomocą jej funkcji odwrotnej. Urlencode () na przykład urldecode (), aby cofnąć jego działania, aby móc rozpocząć korzystanie jako ciąg to masz przed kodowania.

Check Request Method Sprawdź wniosek metody
Throw an if statement around your existing form processor that checks to see if data is coming from the globals post variable. Wyrzuci, jeżeli oświadczenie wokół istniejącej formie, że procesor sprawdza, czy dane pochodzące z GLOBALS po zmiennej. If not, then the user is not accessing your form the way you designed it to be used. Jeśli nie, to użytkownik nie ma dostępu do Twojego formularza sposób zaprojektowany, aby był używany.

  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. Zmień to GET, jeśli używasz, że zamiast. However, I would high recommend you never use that method as it is more insecure. Jednak, chciałbym polecić wysokiej nigdy nie używać tej metody, gdyż jest bardziej niepewna.

Check Request Source Sprawdź wniosek source
You should also check to see if the request is originating from your own server. Należy również sprawdzić, czy wniosek jest pochodząca z własnego serwera. This is a very common method of form abuse which doesn’t necessarily mean you’ll be receiving spam. Jest to metoda bardzo często formy nadużyć, które nie musi koniecznie oznaczać, będziesz otrzymywać 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. Jeśli serwer jest otrzymuję wiele e-maili do odbijania jej domyślny adres e-mail może być ktoś nadużywa swojej witryny w ten sposób.

  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 Korzystanie z wyrażeń regularnych do walidacji danych
I like to check data using preg_match (or any of the regular expression functions). Lubię sprawdzać dane przy użyciu preg_match (lub dowolnego wyrażenia regularnego funkcji). This method kills a lot of birds with one stone. Ta metoda zabija wiele ptaków z jednym kamieniu. 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. Dlaczego pisać oddzielne funkcje, aby sprawdzić, czy ciąg jest pusty, a potem innym, jeżeli pozwala numery, a inny, jeśli pozwala alfa znaków, a drugi do konkretnych długości pola, a innym ... Ci punktu.

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 }$/", $ nazwa)) $ error .= "<li class=\"errors\"> polu Nazwa może zawierać tylko litery i numery (bez spacji) i może być tylko do 15 znaków. </ 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. W preg_match Ja sprawdzanie, czy pole Nazwa zawiera tylko wartości alfanumerycznych (liter) i musi być co najmniej 5 do 15 znaków długości. If you don’t meet that specification appropriate text is added to $error. Jeśli nie spełniają odpowiednich specyfikacji, że tekst jest dodawany do $ błędu.

Using “[variable] [dot][equals] [text]” in this fashion allows me to keep an ongoing variable that I’m adding to. Korzystanie z "[zmienna] [dot] [równe] [tekst]" w ten sposób pozwala mi utrzymać stały zmienna, że mam do dodania. I can then check to see if $error contains any data before my script does any significant queries. I może następnie sprawdzić, czy zawiera błąd $ wszelkie dane, zanim script nie moje wszelkich istotnych zapytań. If there are errors you can spit them out by echoing $error and ask the user to correct them. Jeżeli występują błędy można napluć im przez odzwierciedlając $ błędu i poprosi użytkownika, aby je skorygować. I then use CSS to style my errors which you can see with class=\”errors\”. I wtedy użyć stylów CSS, aby moje błędy, które widać z class = \ "błędy \".

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. Wyrażeń regularnych defiantly mają krzywej uczenia się na nich, ale są one jednym z najlepszych narzędzi, które mogą pomóc uprościć swoje życie w różnych sytuacjach. 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. I'll przejść do bardziej szczegółowo o nich w dół drogi, ale na razie można kupić książkę lub zrobić kilka guglanie.

The Non-Technical Recap Nietechnicznego recap
-Implement a CAPTCHA script. -Wdrożenie CAPTCHA skryptu.
-Escape slashes (and other bad characters). -Escape ukośniki (i innych złych znaków).
-Check to see if data is coming to your form using the correct method. -Sprawdź, czy dane zbliża się do formy używając prawidłowe metody.
-Check to see if the request is originating from your own server. -Sprawdź, czy wniosek jest pochodząca z własnego serwera.
-Check data using a regular expression. -Sprawdzanie danych za pomocą wyrażeń regularnych.

This is just the tip of the iceberg for what I can tell you about spam. To tylko wierzchołek góry lodowej, za co mogę powiedzieć na temat spamu. Thats why I’ve decided to make a mini series of it. Thats why I już zdecydowała się mini serii go. Over the next couple weeks I will be bringing you more detailed ways I deal with spam. W ciągu następnych kilku tygodni będzie przyciągają bardziej szczegółowe metody postępowania ze spamem. Comment below or email me about your own spam preventative methods. Komentarz poniżej lub napisz do mnie na temat własnej spam metod zapobiegawczych. If it is a new or unique technique I will post it in a future blog along with a link back to your blog. Jeśli jest to nowy lub unikalną technikę Ja je opublikować w przyszłym blogu wraz z linkiem z powrotem do swojego bloga. Just write in the comments below and include your URL in the website field. Wystarczy napisać w komentarzach poniżej i zawierać adres URL w polu na stronie internetowej.


1 Comment(s) On 1 Komentarz (y) na

"5 Ways To Catch And Prevent Website Form Spam - Part 1" "5 Ways To Catch i zapobiegania Witryna Forma Spam - część 1"
  1. MyAvatars 0.2 Rob - Mar 5, 2008 Rob - 5 marca 2008

    It just occured to me…setting up those if statements with a die() statement might be easier for a quick and dirty method. To po prostu wystąpił do mnie ... jeśli powołanie tych oświadczeń o śmierć () oświadczenie może być łatwiejsze dla brudne i szybki sposób. 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: Która Mam na pewno większość z Was przynajmniej na razie będzie chcą quickfix tylko podrzucanie cala keep that in mind ... coś takiego:

    if ($_SERVER[‘REQUEST_METHOD’] !== ‘POST’) { die(”The form can not be used like that”); } if ($ _SERVER [ 'REQUEST_METHOD']! == 'POST') (die ( "Formularz nie może być używana tak");)

    You can put that anywhere at the beginning of a script for it to take effect without worrying about existing code too much. Możesz umieścić w dowolnym miejscu, że na początku skryptu, aby wejść w życie bez martwienia się o istniejący kod zbyt wiele.



Leave A Comment: Zostaw komentarz:

Comments RSS Feed Kanał RSS komentarzy

8 3 = 8 3 =

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