Created
April 10, 2014 10:41
-
-
Save A35G/10366883 to your computer and use it in GitHub Desktop.
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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