{"id":754,"date":"2006-06-18T03:34:35","date_gmt":"2006-06-18T01:34:35","guid":{"rendered":"https:\/\/www.dreamsworld.it\/emanuele\/2006-06-18\/wordpress-contactform-con-trencaspammers\/"},"modified":"2016-05-01T16:38:25","modified_gmt":"2016-05-01T14:38:25","slug":"wordpress-contactform-con-trencaspammers","status":"publish","type":"post","link":"https:\/\/www.dreamsworld.it\/emanuele\/2006-06-18\/wordpress-contactform-con-trencaspammers\/","title":{"rendered":"WordPress ContactForm con Trencaspammers"},"content":{"rendered":"<p>Questa volta si \u00e8 trattato di un&#8230; detto &#8211; fatto. Ne avevo parlato giusto <a target=\"_blank\" title=\"Adattare trencaspammers\" href=\"\/\/www.dreamsworld.it\/emanuele\/2006-06-17\/quanto-dura-una-casella-e-mail-senza-spam\/#comment-526\">alcune ore fa<\/a> ed ecco pronta la soluzione&#8230; il <a target=\"_blank\" title=\"Contattami\" href=\"\/\/www.dreamsworld.it\/emanuele\/contattami\/\">modulo contatti<\/a> con <a target=\"_blank\" title=\"Pi\u00f9 captcha per tutti\" href=\"\/\/www.dreamsworld.it\/emanuele\/2006-06-16\/piu-captcha-per-tutti\/\">captcha<\/a> di sicurezza.<\/p>\n<p>Il plugin che utilizzo nella pagina dei contatti \u00e8 <a target=\"_blank\" title=\"Wordpress ContactForm\" href=\"http:\/\/www.ryanduff.net\/projects\/wp-contactform\/\">Wp ContactForm<\/a> che, nella sua semplicit\u00e0, non prevedeva alcuna funzione anti-spam. Per questo, modificando qualche riga di codice, ho inserito <a target=\"_blank\" title=\"Trencaspammers\" href=\"https:\/\/plugins.trac.wordpress.org\/wiki\/Trencaspammers\">Trencaspammers<\/a>, un ottimo plugin per WordPress messo in funzione un paio di giorni fa.<\/p>\n<p>Le modifiche da apportare al codice sono semplicissime.<\/p>\n<p>Aprite wp-contactform.php ed intorno alla riga 78, dopo:<\/p>\n<pre><code>global $wpcf_strings;\r\n$ok = true;<\/code><\/pre>\n<p>Inserite:<\/p>\n<pre><code>$ts_code=trim($_POST['ts_code']);\r\n$ts_random=$_POST['ts_random'];\r\nif ( !ts_is_human($ts_random, $ts_code))\r\ndie( __('Errore: per favore inserisci il codice di sicurezza correttamente.'));<\/code><\/pre>\n<p>Alla riga 159, subito dopo l&#8217;apertura della parentesi graffa dell&#8217;else, inserite:<\/p>\n<p><code>$ts_random=rand();<\/code><\/p>\n<p>Ed alla riga 166, subito dopo la riga che inizia per:<\/p>\n<p><code><\/p>\n<div class=\"contactleft\"><label for=\"wpcf_website\">...<\/label><\/div>\n<p><\/code><\/p>\n<p>andate a capo ed inserite (sostituendo il giusto percorso verso trencaspammers.php):<\/p>\n<pre><code>&lt;div class=&quot;contactleft&quot;&gt;&lt;label for=&quot;ts_code&quot;&gt;<br \/>&lt;input type=&quot;hidden&quot; name=&quot;ts_random&quot; value=&quot;' . $ts_random . '&quot;\/&gt;<br \/>&lt;img src=&quot;http:\/\/PERCORSO\/trencaspammers.php?ts_random=' . $ts_random .'&quot; alt=&quot;spam&quot; \/&gt;<br \/>&lt;\/label&gt;&lt;\/div&gt;<br \/>&lt;div class=&quot;contactright&quot;&gt;<br \/>&lt;input type=&quot;text&quot; name=&quot;ts_code&quot; id=&quot;ts_code&quot; size=&quot;30&quot; \/&gt; (obbligatorio)&lt;\/div&gt;<\/code><\/pre>\n<p>A questo punto salvate il file e&#8230; dovrebbe funzionare tutto. \ud83d\ude09<\/p>\n<p>Buon hack e&#8230; fanc*lo agli spammers! \ud83d\ude42<\/p>\n<p><strong>P|xeL<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Questa volta si \u00e8 trattato di un&#8230; detto &#8211; fatto. Ne avevo parlato giusto alcune ore fa ed ecco pronta la soluzione&#8230; il modulo contatti con captcha di sicurezza. Il plugin che utilizzo nella pagina dei contatti \u00e8 Wp ContactForm &hellip; <a href=\"https:\/\/www.dreamsworld.it\/emanuele\/2006-06-18\/wordpress-contactform-con-trencaspammers\/\">Leggi ancora &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[4],"tags":[],"class_list":["post-754","post","type-post","status-publish","format-standard","hentry","category-internet"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/posts\/754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/comments?post=754"}],"version-history":[{"count":0,"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/posts\/754\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/media?parent=754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/categories?post=754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dreamsworld.it\/emanuele\/wp-json\/wp\/v2\/tags?post=754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}