samman Posted November 16, 2006 Share Posted November 16, 2006 I am using ereg() to filter out spam from a form on our website. All has worked well, until recently. I have been successful with expressions such as, "^mail", "^test", "^user", ... "adshost.info$", "adshost.com$", "adshost.org$". Now I am needing to be able to find a single character (example: "m") at the beginning of an email address (example: "m@spam_mail.com"). It needs to only find one char, and if there are others (like "mary"), it needs to let it go. I have tried "^m", "^m$", "^.$" (and a few others), but none are working. Can someone lend me a hand?Thanks,Sam Link to comment https://forums.phpfreaks.com/topic/27477-finding-single-char-with-ereg/ Share on other sites More sharing options...
Orio Posted November 16, 2006 Share Posted November 16, 2006 You need an email validator with a certain letter in the begining?Try-eregi("^m[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email);Orio. Link to comment https://forums.phpfreaks.com/topic/27477-finding-single-char-with-ereg/#findComment-125665 Share on other sites More sharing options...
samman Posted November 16, 2006 Author Share Posted November 16, 2006 Actually, I was hoping to find something similar to what I'm using at present, and to check for [b]any one [/b] char before the @ symbol. I do check for valid emal on the form, but I am logging the spam attempts, so I am using a seperate script to look at the email after it is determined it is a valid format, and either accept or reject the submission and log it as 'FAIL' or 'SUCCESS'.Below is the code I am using for known spamers ($email is what the user enters in the form field)....$spam_check = array("pisem.net$", "pisem.com$", "pisem.org$","pisem.info$", "pisem.us$", "^mail", "^test", "^user", "^flower", "^usa", "^carlover", "qatalystusa.com$", "adshost.info$", "adshost.com$", "adshost.org$", "adshost.net$", "alexahost.info$", "bc15.info$", "b1ac.info$", "alfika.com$", "adshosting.info$", "adshosting.com$", "adshosting.org$", "adshosting.net$", "fchost.info$"); for($i=0; $i<count($spam_check); $i++) { if(ereg($spam_check[$i], $email)) { header("Location: error.html"); $day = date("g:i:sa l, F j, Y"); $fp = fopen("log.txt", "a+"); fwrite($fp, "FAIL: " . $day . " " .$ip_address . " " . $email . "\n"); fclose($fp); die; } else { continue; } } Link to comment https://forums.phpfreaks.com/topic/27477-finding-single-char-with-ereg/#findComment-125678 Share on other sites More sharing options...
samman Posted November 16, 2006 Author Share Posted November 16, 2006 Got it figured out..."^.@" checks for any one char before the @ symbol. I may have to modify it to a certain char (like the 'm' I have been getting), but for the mean time, it is working.Thanks. Link to comment https://forums.phpfreaks.com/topic/27477-finding-single-char-with-ereg/#findComment-125684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.