Ray Yates
: mivascript at, pcinet d0t com
08/02/2011 22:52 p.m.
08/02/2011 22:52 p.m.
Searches for each word in [banned] a comma seperated list of words, in a text string. If any word is found it is returned. It uses the previously posted function ReplaceChars(). These two function form the basis for the spam filter used by the Annotation program on this site.
<MvFUNCTIONNAME="IsBanned"PARAMETERS="banned var, string var"STANDARDOUTPUTLEVEL=""><MvASSIGNNAME="l.words"VALUE="{ miva_array_deserialize(l.banned) }>"<MvASSIGNNAME="l.maxwords"VALUE="{ miva_array_max(l.words) }>"<MvASSIGNNAME="l.textstring"VALUE="{ ReplaceChars(l.string,'~`!@#$%^&*()_-+={}|[]:;<>?,./' $ asciichar(34) $ asciichar(39), ' ') }>"<MvASSIGNNAME="l.textstring"VALUE="{ glosub(glosub(glosub(l.textstring,' ',' '),' ',' '),' ',' ') }>"<MvASSIGNNAME="l.posn"VALUE="{ 1 }>"<MvWHILEEXPR="{ l.posn LE l.maxwords }>"<MvIFEXPR="{ l.words[l.posn] }>"<MvIFEXPR="{ l.words[l.posn] CIN l.textstring}>"<MvASSIGNNAME="l.found"VALUE="{ l.words[l.posn] }>"<MvWHILESTOP></MvIF></MvIF><MvASSIGNNAME="l.posn"VALUE="{ l.posn + 1 }>"</MvWHILE><MvFUNCRETURNVALUE="{ l.found }>"</MvFUNCTION>