Jump to content

Finding Single Char With ereg()


samman

Recommended Posts

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

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;
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.