A function simple and quick for a dummy control on a text for the presence of any link. Useful for a first check on the body of an e-mail composed by a contact form
<?php | |
$dspam = array("a href", "href", "[url", "[link", "www", "http", "@", "[at]", "mailto"); | |
function checkExtLink($text, $dspam) { | |
$resp = 0; | |
if (is_array($dspam) && !empty($dspam)) { | |
foreach ($dspam as $key => $tofilter) { | |
$offset = $pos = 0; | |
while (is_integer($pos)) { | |
$pos = strpos($text, $tofilter, $offset); | |
if (is_integer($pos)) { | |
$arrPos[] = $pos; | |
$offset = ($pos + strlen($tofilter)); | |
} | |
} | |
if (isset($arrPos)) | |
$resp++; | |
} | |
} | |
return $resp; | |
} | |
$res_text = "Lorem ipsum dolor"; | |
$check_spam = checkExtLink($res_text, $dspam); | |
if (!empty($check_spam)) | |
echo "Possible spam into content of this e-mail"; | |
else | |
echo "Content of this e-mail is clean from spam"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment