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). I tottuneet saamaan niin paljon roskapostia minun postilaatikkoon jokapäiväistä, että minulla oli menoja enemmän aikaa poistamalla se sitten olin lisäämällä uutta sisältöä, kunnossapito-sivustot, tai aloittaa uusia sivustoja yhdistetty (tyypillinen tarina oikealla). 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. Jotkin sivuston roskapostia ei ole ehkäistävissä, tai se ei ehkäistävissä, mutta hintana käytettävyyttä ja / tai hyvää tietoa juutu, että "huonoja juttuja" samoin.

No doubt, if you’re serious about web development you’re going to be creating and interacting with forms on a regular basis. Epäilemättä, jos olet tosissaan Web-kehitys olet tulee luoda ja vuorovaikutuksessa lomakkeet säännöllisesti. Especially with this new web 2.0 attitude every has…gee wiz, what’s that? Varsinkin tämän uuden web 2.0 asenne joka on ... jannu Wiz, mitä siitä?

CAPTCHA CAPTCHA
CAPTCHA is the number one method most people are using to prevent spam today. CAPTCHA on numero yksi menetelmä useimmat ihmiset käyttävät estää roskapostin tänään. What is it? Mikä se on?

“A CAPTCHA is a challenge response test used on computers to check if the user is human. "A CAPTCHA on haaste vastaus testi käyttää tietokoneita tarkistaa, jos käyttäjä on ihminen. A common kind of CAPTCHA that is used on websites requires that the visitor type the letters and numbers of a distorted image. Yhteinen eräänlainen CAPTCHA, jota käytetään Web-sivustoissa edellyttää, että kävijä kirjoittaa kirjaimet ja numerot vääristyneen kuvan. 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 Tämä menetelmä perustuu siihen, että on vaikea tietokoneet poimia tekstin kuvan, kun se on hyvin helppoa ihmisille. "- Captchacreator.com

Here’sa few resources to scripts so you’ll be able to implement that functionality into your own forms: Ohessa muutama resurssit käsikirjoituksiin, joten sinun on pystyttävä toteuttamaan toiminnot oman muodoissa:

Escape Data - Prevent SQL Injections Escape Data - estää SQL-injektioita
Capcha is usless if you’re leaving your form unprotected from attack. Capcha on usless jos olet joten muodossa suojaamaton hyökkäyksiltä. Remember to filter post strings with addslashes() or mysql_real_escape_string() . Muista suodatin post merkkijonon addslashes () tai mysql_real_escape_string ().

Also take a look at these functions for other similar kind of checks that might be useful: Myös katsoa näitä toimintoja muihin vastaaviin luontoissuoritukset tarkastuksia, jotka voivat olla hyödyllisiä:

  • htmlspecialchars() - Escapes the following characters: &,’,”,>,< ...that is the ampersand, single quote, double quote, less than, and greater than symbols. htmlspecialchars () - escape seuraavia merkkejä: &,',",>,< ... se on et-merkki, yksi tarjous, lainausmerkki, pienempi kuin ja suurempi kuin symboleja.
  • strip_tags() - Strips out all HTML and PHP code from the given string. strip_tags () - kaistaleet kaikki HTML-ja PHP-koodi on annettava merkkijono.
  • htmlentities() - Converts ALL characters to their HTML entities equivalent (this is a more catch all version of htmlspecialchars). htmlentities () - Muuntaa kaikki merkit niiden HTML-yksiköt vastaavat (tämä on enemmän kiinni kaikki versio htmlspecialchars).
  • urlencode() - Encodes the URL to pass strings on a GET method. urlencode () - Koodaa URL siirtää jouset on GET-menetelmällä. As I mentioned, don’t use GET with forms. Kuten mainitsin, ei saa käyttää GET-muotoon. This is useful when you’re passing user input variables for other reasons. Tämä on hyödyllinen silloin, kun olet ohimennen käyttäjä syöttää muuttujat muista syistä.

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. Muista, kun muuntaa tiedot tältä käyttäen jotakin edellä mainituista toiminnoista, voit perua sen luettavuutta ja ulostulon avulla sen kääntää toiminnon. Urlencode () esimerkiksi on urldecode () kumota sen toimia, jotta voit alkaa käyttää merkkijonon kuin teistä olisi ennen koodaa.

Check Request Method Tarkista pyynnöstä menetelmä
Throw an if statement around your existing form processor that checks to see if data is coming from the globals post variable. Heitä if julkilausuma noin olemassa olevan lomakkeen käsittelijä, joka tarkistaa, onko tiedot ovat lähtöisin globals post muuttuja. If not, then the user is not accessing your form the way you designed it to be used. Jos ei, niin käyttäjä ei käytäkään lomakkeen tapaan kuin on suunniteltu sitä voidaan käyttää.

  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. Muuta tämä GET jos käytät sitä. However, I would high recommend you never use that method as it is more insecure. Haluan kuitenkin korkea suositella sinulle koskaan käytä tätä menetelmää, koska se on epävarma.

Check Request Source Tarkista pyynnöstä lähde
You should also check to see if the request is originating from your own server. Sinun tulisi myös tarkistaa, onko pyyntö on peräisin oma palvelin. This is a very common method of form abuse which doesn’t necessarily mean you’ll be receiving spam. Tämä on hyvin yleinen menetelmä muodon väärinkäyttö, joka ei välttämättä tarkoita sitä, voit saada roskapostia. 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. Jos olet palvelimen on tulossa paljon palautuneet sähköpostiviestit sen oletus sähköposti sinulla voi olla joku väärin sivustosi tällä tavalla.

  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 Käytä säännöllisiä lausekkeita tietojen validointi
I like to check data using preg_match (or any of the regular expression functions). Haluan tarkistaa tietoja käyttävien preg_match (tai säännöllinen lauseke-toiminnot). This method kills a lot of birds with one stone. Tämä tapa tappaa paljon kärpästä yhdellä iskulla. 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. Miksi kirjoittaa erilliseen erikoistoimintojaan tarkistaa, onko merkkijono on tyhjä, sitten toinen, jos se mahdollistaa numeroita, ja toinen, jos se mahdollistaa alfa-merkkiä, ja toinen erityisiä pituus ja toinen ... saat kohta.

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 }$/", $ nimi)) $ virhe .= "<li class=\"errors\"> Nimi-kenttään voi sisältää vain kirjaimia ja-numerot (ei välilyöntejä) ja voin vain olla enintään 15 merkkiä pitkä. </ 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. Kun preg_match Olen tarkistaa, että nimi kenttä sisältää vain kirjaimia ja numeroita sekä arvot (isot) ja sen on oltava vähintään 5-15 merkkiä pitkä. If you don’t meet that specification appropriate text is added to $error. Jos et täytä tätä standardia sopiva teksti on lisätty $ virhe.

Using “[variable] [dot][equals] [text]” in this fashion allows me to keep an ongoing variable that I’m adding to. Käyttämällä "[muuttuja] [piste] [sama] [teksti]" tässä muoti sallii minun pitää jatkuvasti muuttuva, että olen lisäämällä. I can then check to see if $error contains any data before my script does any significant queries. Voin sitten tarkistaa, jos $ virhe sisältää kaikki tiedot, ennen kuin skripti ei mitään merkittävää kyselyitä. If there are errors you can spit them out by echoing $error and ask the user to correct them. Jos on virheitä, voit sylkeä ne yhtymällä $ virheen ja pyytää käyttäjää korjaamaan niitä. I then use CSS to style my errors which you can see with class=\”errors\”. En sitten käyttää CSS on tyyliä minun virheitä, jotka voit nähdä class = \ "virheet \".

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. Regular expressions defiantly on oppimiskäyrä on, mutta ne ovat yksi parhaita keinoja, joilla voidaan yksinkertaistaa henkesi useissa eri tilanteissa. 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 syventyä yksityiskohtaisesti niistä tiellä, mutta nyt voit halutessasi ostaa kirjan tai tehdä Google-hakuja.

The Non-Technical Recap Ei-teknisiä kertaus
-Implement a CAPTCHA script. -Pantava täytäntöön CAPTCHA script.
-Escape slashes (and other bad characters). -Escape vinoviivoilla (ja muiden huono merkkiä).
-Check to see if data is coming to your form using the correct method. -Tarkista, onko tietoja on tulossa lomakkeen avulla oikea menetelmä.
-Check to see if the request is originating from your own server. -Tarkista, onko pyyntö on peräisin oma palvelin.
-Check data using a regular expression. -Check-tietoja käyttämällä säännöllinen lauseke.

This is just the tip of the iceberg for what I can tell you about spam. Tämä on vain jäävuoren huippu siitä, mitä voin kertoa sinulle roskapostia. Thats why I’ve decided to make a mini series of it. Thats miksi olen päättänyt tehdä mini-sarjassa sitä. Over the next couple weeks I will be bringing you more detailed ways I deal with spam. Yli muutaman seuraavan viikon aikana aion saat yksityiskohtaisempia keinoja I käsitellä roskapostia. Comment below or email me about your own spam preventative methods. Kommentoi alle tai sähköpostitse minulle oman roskapostin ennalta ehkäiseviä menetelmiä. If it is a new or unique technique I will post it in a future blog along with a link back to your blog. Jos kyseessä on uusi tai ainutlaatuinen tekniikka aion postitse sen tulevan blogin pitkin, jossa on linkki takaisin blogiisi. Just write in the comments below and include your URL in the website field. Vain kirjoittaa kommentteja alla ja sisältää URL-sivustolla alalla.


1 Comment(s) On 1 Kommentti (t)

"5 Ways To Catch And Prevent Website Form Spam - Part 1" "5 tapoja Saalis ja estää Web-sivuston muoto Spam - Osa 1"
  1. MyAvatars 0,2 Rob - Mar 5, 2008 Rob - Mar 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. Se vain tapahtui minulle ... perustamalla niille, jos kannanotot, joiden die () voi olla helpompaa nopea ja likainen menetelmällä. 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: Mikä Olen varma, että useimmat teistä ainakin nyt halua quickfix vain nakata tuumaa Pidä mielessä ... Jotain tältä:

    if ($_SERVER[‘REQUEST_METHOD’] !== ‘POST’) { die(”The form can not be used like that”); } if ($ _SERVER [ 'REQUEST_METHOD']! == 'POST') (die ( "Lomake ei voida käyttää kuten että");)

    You can put that anywhere at the beginning of a script for it to take effect without worrying about existing code too much. Voit laittaa, että missä tahansa alussa käsikirjoituksen, jotta se tulee voimaan ilman huolta olemassa olevan koodin liikaa.



Leave A Comment: Jätä kommentti:

Comments RSS Feed Kommentit RSS-syöte

8 - 4 = 8 - 4 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. Custom Theme: Rob Malon | Sisältö & Design © 2008 - Rob Malon [piste] com. "));
"));