Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, April 20, 2024
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  PHP Contact Script - How to stop spam?

phpMyEdit Installation     PHP Contact Script - How to stop spam?
Post new topic   Reply to topic    
 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2017-10-14 21:12
Back to top  Reply with quote     

Forms attract spam from every corner of the Earth but mostly from Russia. You can never defeat spam submitted via online forms unless the validation for user input is done extremely well, which takes a lot of work initially and long term tweaks as junk creeps through. I've built 200 websites in the past, everyone wanted a Contact form, everyone ended up with spam to some degree. To simplify ongoing maintenance, do your homework on the validation of user input. Consider posting to one website an array of spam phrases.

https://www.phpvs.com/spam.txt

Have your validation process call the spam.txt file, split the array, check each spam item against user input, etc.

Below is a partial code clip (example, not functioning code for you) of how I process the remote file.

if(file_exists($fn)){
$unixtime = fileatime($fn);
$diff = $_SERVER['REQUEST_TIME'] - $unixtime;
if($diff < $seconds_per_day){
$create_file = false;
}
}
if($create_file){
// attempt to read a file from a remote server
// Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/phpvs/public_html/bs/contact.php on line 440
// Warning: file_get_contents(https://www.phpvs.com/spam.txt): failed to open stream: no suitable wrapper could be found in /home/phpvs/public_html/bs/contact.php on line 440
// note the @ below
$anti_spam_string = @trim(file_get_contents($parent.$fn));
if($anti_spam_string === false){
// fail; use older local file if it exists
if(file_exists($fn)){
$anti_spam_string = trim(file_get_contents($fn));
}
}else{
// pass
if(function_exists('file_put_contents')){
file_put_contents($fn, $anti_spam_string);
}
}
}else{
// read from local file
if(file_exists($fn)){
$anti_spam_string = trim(file_get_contents($fn));
}
}
$pos = stripos($anti_spam_string, '|'); // ensure pipe deliminators exist
if($pos === false){
//false; some sort of error encountered; use the pattern from October 10, 2013
$cfg['pattern'] = "/\[link|\[php\]|\[url|5280techrecycling|831 beacon|abraham34|accelerateyourmarketing|acrotray|activemd|ads\-phbe|adwords|allergan\.com|Allmobileapps|art gallery|aubsc\.|aubscmagic|Augeo|author_name|b2bsalesgen|base64_decode|base64_encode|base64_url_decode|base64_url_encode|bearhatstudios|bestmailing|bigbuzzinc|bizymoms|black hat|business ranking|buzzcomb\.com|blogengine|candcinfotech|castlerockmediagroup|China|cialis|clearchannel\.com|ClicktoFax|cliftondesigns|collector\.org|commercialmortgagellc|content\-type|corporatedev|creativeeye|damailbox|directconnectcommunications|dulciesqs|dvt360|email marketing|epaymanagement|escapeshellarg\(|esupportstaff\.com|eval\(|everjade|evertexnextgen|eweb\-solution\.com|exec\(|fotolog\.com|fpmandassoc|#### you|fwpoc\.com|gcc\.cc|global connectivity|google ranking|griffonyc|group\-res\.com|grow your business|gzinflate|gzuncompress|healthhaven|hot women|hybridb|hyper do|icnsportsweb|icreon|impressionsofcolorado|increase traffic|india\s|integrasystems|internet marketing|intrepidlending|isuccessclub|itaamerica|itakethelead|izigg|jack wu|jahmobileapp|joinburney|jonfine|joseph2655|ksmediagroup|louboutin|lead generation|leadhustler|leadsquery|link building|link exchange|linkbuilding|linkedin\.com|linkhelpers|linkworth|localndex|localpositionsus|localvisible|m really like it|madwire media|marketing expert|mastergoogle|masterpiecebanner|mediafinders\.net|milldogrescue|mpbanner|multipart|myapptogo|netmediamarkets|newhostingdomain|newofferstore|nikhil|nisesite|nkaiye|nsearch|online leads|online presence|online visibility|olstore|onlinereputationmanagement|optimization|optimize your site|opxyiea|page rank|passthru\(|pay per click|physicianendorsed|pleasedontleave|postingonly|postingshowcase|postingtrader|postpositivereviews|powerpointseo|prodawez|provab|ranking|reachlocal|redwinelady|reputationdefense|ron2310|roofermarketing|rrls\.net|rsls\.net|sandeep|search |search engine|searchsight|send\-contactus|seo\-for\-traffic|seo|seobook|seonext|seoranking|sharkim|simpleglobalmethods|sinaiseo|SmartWaiver|social bookmarking|social cloud|Social Media|software development|spot\-1\.net|sql injection|superpages|system\(|targetedtrafficcrew|teennick|theoreminc|tom Eickbush|topseoranking|treatment of a brain tumor|trexco|trucks@yahoo\.com|usagy|valpak|viagra|viddler\.com|vigitize|vipmarketingusa|visibilitysource|vmags|web design|web site assessment|webhostgear|webmerchantshield|website analysis|webwisemedia|weeklyplus|white hat|white\-hat|wilksdenver|xrumer|zenmanproductions|zippyshare|zubredo|EyeMD/i";
}else{
//true;
$cfg['pattern'] = '/'.$anti_spam_string.'/i';
}

$print_r_text = preg_replace('/\n/s', "\r\n", print_r($_POST, true));
//if(preg_match($cfg['pattern'], $print_r_text)){
if(preg_match($cfg['pattern'], $comment)){
$errors['comment'] = 'Comment validation failed';
}

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy