-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSpamFilter.cfc
647 lines (545 loc) · 21.8 KB
/
SpamFilter.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
<!--- 1.2 (Build 17) --->
<!--- Last Updated: 2015-09-03 --->
<!--- Created by Steve Bryant 2007-08-15 --->
<!--- Information: sebtools.com --->
<cfcomponent displayname="Spam Filter" output="false">
<cfset cr = "
">
<cfset variables.ignoreKeysDefaults = ["grecaptcharesponse", "g-recaptcha-response", "h-captcha-response", "email"]>
<cfset variables.ignoreKeys = variables.ignoreKeysDefaults>
<cffunction name="init" access="public" returntype="any" output="no" hint="I instantiate and return this component.">
<cfargument name="DataMgr" type="any" required="yes">
<cfargument name="getNewDefs" type="boolean" default="0">
<cfargument name="Scheduler" type="any" required="false">
<cfscript>
var qWords = 0;
variables.DataMgr = arguments.DataMgr;
variables.getNewDefs = arguments.getNewDefs;
variables.datasource = variables.DataMgr.getDatasource();
variables.DataMgr.loadXML(getDbXml(),true,true);
if ( StructKeyExists(arguments,"Scheduler") ) {
variables.Scheduler = arguments.Scheduler;
loadScheduledTask();
}
</cfscript>
<cfif variables.getNewDefs AND NOT StructKeyExists(arguments,"Scheduler")>
<cfset loadUniversalData()>
</cfif>
<!--- Add Default Words --->
<cfif variables.DataMgr.hasRecords("spamWords")>
<cfset loadWords(getDefaultSpamWords())>
</cfif>
<cfreturn this>
</cffunction>
<cffunction name="loadScheduledTask" access="public" returntype="void" output="no">
<cfif StructKeyExists(variables,"Scheduler")>
<cfinvoke component="#variables.Scheduler#" method="setTask">
<cfinvokeargument name="Name" value="SpamFilter">
<cfinvokeargument name="ComponentPath" value="com.sebtools.SpamFilter">
<cfinvokeargument name="Component" value="#This#">
<cfinvokeargument name="MethodName" value="loadUniversalData">
<cfinvokeargument name="interval" value="weekly">
<cfinvokeargument name="weekdays" value="Monday">
<cfinvokeargument name="Hours" value="1,2,3">
</cfinvoke>
</cfif>
</cffunction>
<cffunction name="filter" access="public" returntype="struct" output="no" hint="I run the filter on the given structure and return it.">
<cfargument name="data" type="struct" required="yes">
<cfargument name="maxpoints" type="numeric" default="0">
<cfif isSpam(argumentCollection=arguments)>
<cfthrow message="This message appears to be spam." detail="If you feel that you have gotten this message in error, pleas change your entry and try again." type="SpamFilter" errorcode="Spam">
</cfif>
<cfreturn arguments.data>
</cffunction>
<cffunction name="isSpam" access="public" returntype="boolean" output="no" hint="I indicate whether the given structure is spam.">
<cfargument name="data" type="struct" required="yes">
<cfargument name="maxpoints" type="numeric" default="0">
<cfset var pointlimit = arguments.maxpoints>
<cfset var pointval = 0>
<cfset var result = false>
<!--- If we don't have a point limit, set it to the number of fields --->
<cfif NOT pointlimit>
<cfset pointlimit = getPointLimit(arguments.data,maxpoints)>
</cfif>
<!--- Run that filter! --->
<cfset pointval = getPoints(arguments.data,maxpoints)>
<cfif pointval GT pointlimit>
<cfset result = true>
</cfif>
<cfreturn result>
</cffunction>
<cffunction name="getPoints" access="public" returntype="numeric" output="no"hint="I return the number of points in the given structure.">
<cfargument name="data" type="struct" required="yes">
<cfargument name="maxpoints" type="numeric" default="0">
<cfset var langPoints = 0>
<cfset var pointval = 0>
<cfset var qWords = variables.DataMgr.getRecords("spamWords", {orderBy="points DESC"})>
<cfset var qRegExs = variables.DataMgr.getRecords("spamRegExs")>
<cfset var field = "">
<cfset var finds = 0>
<cfset var field2 = "">
<cfset var duplist = "">
<cfloop collection="#arguments.data#" item="field">
<cfif ArrayFindNoCase(variables.ignoreKeys, field) or ListFindNoCase("validate,finger", listFirst(field,"_"))>
<!--- Ignore --->
<cfelseif isSimpleValue(arguments.data[field]) AND Len(field) and Len(arguments.data[field]) and field NEQ "Email">
<cfloop query="qWords">
<!--- Get the number of times the word appears --->
<cfset finds = numWordMatches(arguments.data[field],trim(Word),Arguments.maxpoints)>
<cfset pointval = pointval + (finds * Val(points))>
<cfif maxpoints GT 0 AND pointval GT maxpoints>
<cfreturn pointval>
</cfif>
</cfloop>
<cfloop query="qRegExs">
<!--- Get the number of times the expression is matched --->
<cfset finds = numRegExMatches(arguments.data[field],trim(RegEx),Val(checkcase),Arguments.maxpoints)>
<cfset pointval = pointval + (finds * Val(points))>
<cfif maxpoints GT 0 AND pointval GT maxpoints>
<cfreturn pointval>
</cfif>
</cfloop>
<!--- Points for duplicate field values --->
<cfset duplist = ListAppend(duplist,field)>
<cfloop collection="#arguments.data#" item="field2">
<cfif
(field2 NEQ field)
AND isSimpleValue(arguments.data[field])
AND isSimpleValue(arguments.data[field2])
AND (arguments.data[field2] EQ arguments.data[field])
AND NOT ListFindNoCase(duplist,field2)
>
<cfset pointval = pointval + 1>
<cfset duplist = ListAppend(duplist,field2)>
<cfif maxpoints GT 0 AND pointval GT maxpoints>
<cfreturn pointval>
</cfif>
</cfif>
</cfloop>
<!--- get points for banned foreign languages --->
<cfset langPoints = getForeignLanguagePoints(arguments.data[field]) />
<cfset pointval = pointval + langPoints />
</cfif>
</cfloop>
<cfreturn pointval>
</cffunction>
<cffunction name="getPointsArray" access="public" returntype="array" output="no"hint="I return an array of details about the points in the given structure.">
<cfargument name="data" type="struct" required="yes">
<cfset var pointval = 0>
<cfset var qWords = variables.DataMgr.getRecords("spamWords", {orderBy="points DESC"})>
<cfset var qRegExs = variables.DataMgr.getRecords("spamRegExs")>
<cfset var field = "">
<cfset var finds = 0>
<cfset var aPoints = ArrayNew(1)>
<cfset var field2 = "">
<cfset var duplist = "">
<cfloop collection="#arguments.data#" item="field">
<cfif isSimpleValue(arguments.data[field]) AND Len(field) AND Len(arguments.data[field]) AND field NEQ "Email">
<cfloop query="qWords">
<!--- Get the number of times the word appears --->
<cfset finds = numWordMatches(arguments.data[field],trim(Word))>
<cfif finds>
<cfset pointval = pointval + (finds * points)>
<cfset ArrayAppend(aPoints,"#(finds * points)#:#trim(Word)#")>
</cfif>
</cfloop>
<cfloop query="qRegExs">
<!--- Get the number of times the expression is matched --->
<cfset finds = numRegExMatches(arguments.data[field],trim(RegEx),Val(checkcase))>
<cfif finds>
<cfset pointval = pointval + (finds * points)>
<cfset ArrayAppend(aPoints,"#(finds * points)#:(#Label#):#trim(Regex)#")>
</cfif>
</cfloop>
<!--- Points for duplicate field values --->
<cfset duplist = ListAppend(duplist,field)>
<cfloop collection="#arguments.data#" item="field2">
<cfif
(field2 neq field)
AND isSimpleValue(arguments.data[field])
AND isSimpleValue(arguments.data[field2])
AND (arguments.data[field2] eq arguments.data[field])
AND NOT ListFindNoCase(duplist,field2)
>
<cfset pointval = pointval + 1>
<cfset duplist = ListAppend(duplist,field2)>
<cfset ArrayAppend(aPoints,"#(1)#:(duplicate):#field2#:#arguments.data[field2]#")>
</cfif>
</cfloop>
</cfif>
</cfloop>
<cfreturn aPoints>
</cffunction>
<cffunction name="getRegEx" access="public" returntype="query" output="no" hint="I return the requested regex.">
<cfargument name="RegExID" type="string" required="yes">
<cfreturn variables.DataMgr.getRecord("spamRegExs",arguments)>
</cffunction>
<cffunction name="getRegExs" access="public" returntype="query" output="no" hint="I return all of the regexs.">
<cfreturn variables.DataMgr.getRecords("spamRegExs",arguments)>
</cffunction>
<cffunction name="getWord" access="public" returntype="query" output="no" hint="I return the requested word.">
<cfargument name="WordID" type="string" required="yes">
<cfreturn variables.DataMgr.getRecord("spamWords",arguments)>
</cffunction>
<cffunction name="getWords" access="public" returntype="query" output="no" hint="I return all of the words.">
<cfreturn variables.DataMgr.getRecords("spamWords",arguments)>
</cffunction>
<cffunction name="loadUniversalData" access="public" returntype="void" output="no" hint="I get external spam definitions.">
<cftry>
<!--- Do an HTTP call to get a text file with spam words --->
<cfhttp url="http://www.bryantwebconsulting.com/spamdefs.txt" method="GET" resolveurl="false"></cfhttp>
<!--- Parse the XML file and load new spam words --->
<cfset loadWords(CFHTTP.FileContent)>
<cfcatch>
</cfcatch>
</cftry>
<cftry>
<!--- Do an HTTP call to get an XML file with spam expressions --->
<cfhttp url="http://www.bryantwebconsulting.com/spamdefs.xml" method="GET" resolveurl="false"></cfhttp>
<!--- Parse the XML file and load new spam expressions --->
<cfset variables.DataMgr.loadXML(CFHTTP.FileContent,true,true)>
<cfcatch>
</cfcatch>
</cftry>
</cffunction>
<cffunction name="loadWords" access="public" returntype="void" output="no"hint="I load the given list of (carriage-return delimited) words to the spam words definitions.">
<cfargument name="wordlist" type="string" required="yes">
<cfset var word = "">
<cfset var data = StructNew()>
<cfloop list="#arguments.wordlist#" index="word" delimiters="#cr#">
<cfset data["Word"] = trim(word)>
<cfset variables.DataMgr.insertRecord("spamWords",data,"skip")>
</cfloop>
</cffunction>
<cffunction name="removeRegEx" access="public" returntype="void" output="no" hint="I delete the given RegEx.">
<cfargument name="RegExID" type="string" required="yes">
<cfset variables.DataMgr.deleteRecord("spamRegExs",arguments)>
</cffunction>
<cffunction name="removeWord" access="public" returntype="void" output="no" hint="I delete the given Word.">
<cfargument name="WordID" type="string" required="yes">
<cfset variables.DataMgr.deleteRecord("spamWords",arguments)>
</cffunction>
<cffunction name="saveRegEx" access="public" returntype="string" output="no" hint="I save a RegEx.">
<cfargument name="RegExID" type="string" required="no">
<cfargument name="RegEx" type="string" required="no">
<cfargument name="Label" type="string" required="no">
<cfargument name="points" type="string" required="no">
<cfreturn variables.DataMgr.saveRecord("spamRegExs",arguments)>
</cffunction>
<cffunction name="saveWord" access="public" returntype="string" output="no" hint="I save a Word.">
<cfargument name="WordID" type="string" required="no">
<cfargument name="Word" type="string" required="no">
<cfargument name="points" type="string" required="no">
<cfreturn variables.DataMgr.saveRecord("spamWords",arguments)>
</cffunction>
<cffunction name="numRegExMatches" access="public" returntype="numeric" output="no" hint="I return the number of times the given regular expression is matched in the given string.">
<cfargument name="string" type="string" require="true">
<cfargument name="regex" type="string" require="true">
<cfargument name="checkcase" type="boolean" default="false">
<cfset var result = 0>
<cfset var sFind = 0>
<cfif arguments.checkcase>
<cfreturn numRegExCaseMatches(arguments.string,arguments.regex)>
</cfif>
<cfscript>
sFind = REFindNoCase(arguments.regex, arguments.string, 1, true);
while ( sFind.pos[1] GT 0 ) {
result = result + 1;
sFind = REFindNoCase(arguments.regex, arguments.string, sFind.pos[1]+sFind.len[1], true );
}
</cfscript>
<cfreturn result>
</cffunction>
<cffunction name="getRegExCaseMatches" access="public" returntype="array" output="no" hint="I return an array of the given regular expression is matches in the given string.">
<cfargument name="string" type="string" require="true">
<cfargument name="regex" type="string" require="true">
<cfset var aResults = ArrayNew(1)>
<cfset var sFind = REFind(arguments.regex, arguments.string,1,true)>
<cfscript>
while ( sFind.pos[1] GT 0 ) {
ArrayAppend(aResults, Mid(Arguments.string,sFind.pos[1],sFind.len[1]));
sFind = REFind(arguments.regex, arguments.string, sFind.pos[1]+1,true);
}
</cfscript>
<cfreturn aResults>
</cffunction>
<cffunction name="numRegExCaseMatches" access="public" returntype="numeric" output="no" hint="I return the number of times the given regular expression is matched in the given string.">
<cfargument name="string" type="string" require="true">
<cfargument name="regex" type="string" require="true">
<cfargument name="maxpoints" type="numeric" default="0">
<cfset var result = 0>
<cfset var findat = REFind(arguments.regex, arguments.string)>
<cfscript>
while ( findat GT 0 ) {
result = result + 1;
if ( arguments.maxpoints GT 0 AND result GT arguments.maxpoints ) {
return result;
}
findat = REFind(arguments.regex, arguments.string, findat+1);
}
</cfscript>
<cfreturn result>
</cffunction>
<cffunction name="numWordMatches" access="public" returntype="numeric" output="no" hint="I return the number of times the given word is found in the given string.">
<cfargument name="string" type="string" require="true">
<cfargument name="word" type="string" require="true">
<cfargument name="maxpoints" type="numeric" default="0">
<cfreturn numRegExMatches(arguments.string,"\b#arguments.word#\b",arguments.maxpoints)>
</cffunction>
<cffunction name="getPointLimit" access="public" returntype="numeric" output="no">
<cfargument name="struct" type="struct" required="yes">
<cfset var key = "">
<cfset var result = 0>
<cfloop collection="#arguments.struct#" item="key">
<cfif StructKeyExists(arguments.struct,key) AND isSimpleValue(arguments.struct[key]) AND Len(Trim(arguments.struct[key])) AND key NEQ "Email">
<cfset result = result + 1>
</cfif>
</cfloop>
<cfreturn result>
</cffunction>
<cffunction name="getForeignLanguagePoints" access="public" returntype="numeric" output="no">
<cfargument name="string" type="string" require="true">
<cfset var pointval = 1>
<cfset var result = 0>
<!--- Test for Cyrilic --->
<cfif arguments.string.matches("(.*)[\u0400-\u04FF](.*)")>
<cfset result = result + pointval>
</cfif>
<!--- Test for Kanji --->
<cfif arguments.string.matches("(.*)[\u4E00-\u9FFF](.*)")>
<cfset result = result + pointval>
</cfif>
<cfreturn result>
</cffunction>
<cffunction name="getDbXml" access="public" returntype="string" output="no" hint="I return the XML for the tables needed for SpamFilter.cfc to work.">
<cfset var tableXML = "">
<cfsavecontent variable="tableXML"><cfoutput>
<tables>
<table name="spamWords">
<field ColumnName="WordID" CF_DataType="CF_SQL_INTEGER" PrimaryKey="true" Increment="true" />
<field ColumnName="Word" CF_DataType="CF_SQL_VARCHAR" Length="150" />
<field ColumnName="points" CF_DataType="CF_SQL_INTEGER" Default="1" />
</table>
<table name="spamRegExs">
<field ColumnName="RegExID" CF_DataType="CF_SQL_INTEGER" PrimaryKey="true" Increment="true" />
<field ColumnName="RegEx" CF_DataType="CF_SQL_VARCHAR" Length="250" />
<field ColumnName="Label" CF_DataType="CF_SQL_VARCHAR" Length="60" />
<field ColumnName="points" CF_DataType="CF_SQL_INTEGER" Default="1" />
<field ColumnName="checkcase" CF_DataType="CF_SQL_BIT" Default="0" />
</table>
<data table="spamRegExs" permanentRows="true" checkFields="Label" onexists="update">
<row Label="Email" points="2" RegEx="^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name|jobs|travel))$" />
<row Label="URL" points="2" RegEx="https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?" />
<row Label="URL2" points="2" RegEx="URL=[\w-]+\.+[\w-]{3,}\b" />
<row Label="Million Dollars" points="3" Regex="\$.*,\d{3},\d{3}(\.d{2})?" />
<row Label="IP Address" points="3" Regex="\b(((\d{1,2})|(1\d{2})|(2[0-4])|(25[0-5]))\.){3}((\d{1,2})|(1\d{2})|(2[0-4])|(25[0-5]))\b" />
<row Label="GobbledyGook" points="0" Regex="\b[^\s]*?[bcdfghjklmnpqrstvxwz]{5,}[^\s]*?\b" />
<row Label="Junk" points="3" Regex="[^a-z\d_\-\.@##\s:;/\+]{5,}" />
<row Label="Case Changes" points="2" Regex="\b([a-z][A-Z][^ \n\b]*){3,}\b" checkcase="true" />
<row Label="Words with numbers" points="2" Regex="\b[a-z]+\d+\w+\b" />
</data>
</tables>
</cfoutput></cfsavecontent>
<cfreturn tableXML>
</cffunction>
<cffunction name="setIgnoreKeys" access="public" returntype="void" output="no" hint="I set struct keys to ignore">
<cfargument name="keys" type="any" required="yes">
<cfset var k = duplicate(arguments.keys)>
<cfset var thisKey = "">
<cfif isSimpleValue(k)>
<cfset k = listtoarray(k)>
</cfif>
<cfset variables.ignoreKeys = k>
<cfloop array="#variables.ignoreKeysDefault#" index="thisKey">
<cfset arrayAppend(variables.ignoreKeys, thisKey)>
</cfloop>
</cffunction>
<cffunction name="identifySpam" access="public" returntype="struct" output="no" hint="I return spam points score and rules that were triggered.">
<cfargument name="data" type="struct" required="yes">
<cfargument name="maxpoints" type="numeric" default="0">
<cfset var pointlimit = arguments.maxpoints>
<cfset var result = structNew()>
<cfset var thisKey = "">
<!--- If we don't have a point limit, set it to the number of fields --->
<cfif NOT pointlimit>
<cfset pointlimit = getPointLimit(arguments.data,maxpoints)>
</cfif>
<!--- Run that filter! --->
<cfset result = getPointsStruct(arguments.data,maxpoints)>
<!--- Identify ignored fields --->
<cfset result.ignored = StructNew()>
<cfloop array="#variables.ignoreKeys#" index="thisKey">
<cfif StructKeyExists(data, thisKey)>
<cfset result.ignored[thisKey] = data[thisKey]>
</cfif>
</cfloop>
<cfset result.isSpam = false>
<cfif result.score GT pointlimit>
<cfset result.isSpam = true>
</cfif>
<cfreturn result>
</cffunction>
<cffunction name="getPointsStruct" access="public" returntype="struct" output="no" hint="I return the number of points in the given structure.">
<cfargument name="data" type="struct" required="yes">
<cfargument name="maxpoints" type="numeric" default="0">
<cfset var result = {score = 0, rules = ArrayNew(1)}>
<cfset var qWords = variables.DataMgr.getRecords("spamWords", {orderBy="points DESC"})>
<cfset var qRegExs = variables.DataMgr.getRecords("spamRegExs")>
<cfset var field = "">
<cfset var finds = 0>
<cfset var field2 = "">
<cfset var duplist = "">
<cfloop collection="#arguments.data#" item="field">
<cfif ArrayFindNoCase(variables.ignoreKeys, field) or ListFindNoCase("validate,finger", listFirst(Field,"_"))>
<!--- Ignore --->
<cfelseif isSimpleValue(arguments.data[field]) and Len(field) and Len(arguments.data[field]) and field neq "Email">
<cfloop query="qWords">
<!--- Get the number of times the word appears --->
<cfset finds = numWordMatches(arguments.data[field],trim(Word),Arguments.maxpoints)>
<cfif finds gt 0>
<cfset result.score = result.score + (finds * Val(points))>
<cfset ArrayAppend(result.rules, {points=(finds * points), type="word", rule=trim(Word)})>
<cfif maxpoints GT 0 and result.score gt maxpoints>
<cfreturn result>
</cfif>
</cfif>
</cfloop>
<cfloop query="qRegExs">
<!--- Get the number of times the expression is matched --->
<cfset finds = numRegExMatches(arguments.data[field],trim(RegEx),Val(checkcase),Arguments.maxpoints)>
<cfif finds GT 0>
<cfset result.score = result.score + (finds * Val(points))>
<cfset ArrayAppend(result.rules, {points=(finds * points), type=Label, rule=trim(Regex)})>
<cfif maxpoints gt 0 and result.score gt maxpoints>
<cfreturn result>
</cfif>
</cfif>
</cfloop>
<!--- Points for duplicate field values --->
<cfset duplist = ListAppend(duplist,field)>
<cfloop collection="#arguments.data#" item="field2">
<cfif
(field2 neq field)
and isSimpleValue(arguments.data[field])
and isSimpleValue(arguments.data[field2])
and (arguments.data[field2] EQ arguments.data[field])
and not ListFindNoCase(duplist,field2)
>
<cfset result.score = result.score + 1>
<cfset ArrayAppend(result.rules, {points=1, type="duplicate", rule="#field2#=#arguments.data[field2]#"})>
<cfset duplist = ListAppend(duplist,field2)>
<cfif maxpoints GT 0 and result.score gt maxpoints>
<cfreturn result>
</cfif>
</cfif>
</cfloop>
<!--- get points for banned foreign languages --->
<cfset langPoints = getForeignLanguagePoints(arguments.data[field]) />
<cfif val(langPoints) gt 1>
<cfset result.score = result.score + langPoints />
<cfset ArrayAppend(result.rules, {points=langPoints, type="foreign", rule="Cyrilic/Kanji"})>
</cfif>
</cfif>
</cfloop>
<cfreturn result>
</cffunction>
<cffunction name="getDefaultSpamWords" access="private" returntype="string" output="no">
<cfset var result = "">
<cfsavecontent variable="result"><cfoutput>-online
4u
adipex
adult book
adult comic
advicer
baccarrat
blackjack
bllogspot
bondage
booker
byob
car-rental-e-site
car-rentals-e-site
carisoprodol
casino
casinos
chatroom
cialis
coolcoolhu
coolhu
credit-card-debt
credit-report-4u
cwas
cyclen
cyclobenzaprine
dating-e-site
day-trading
debt-consolidation
debt-consolidation-consultant
discreetordering
duty-free
dutyfree
equityloans
fioricet
flowers-leading-site
freenet-shopping
freenet
free-site-host.com
gambling-
hair-loss
health-insurancedeals-4u
homeequityloans
homefinance
holdem
holdempoker
holdemsoftware
holdemtexasturbowilson
hotel-dealse-site
hotele-site
hotelse-site
incest
insurance-quotesdeals-4u
insurancedeals-4u
jrcreations
levitra
macinstruct
MILLION UNITED STATES DOLLARS
mortgage-4-u
mortgagequotes
online-gambling
onlinegambling-4u
ottawavalleyag
ownsthis
palm-texas-holdem-game
paxil
penis
pharmacy
phentermine
poker-chip
porn
porno
poze
propecia
pussy
rental-car-e-site
ringtones
roulette
sex
shemale
shoes
slot-machine
texas-holdem
thorcarlson
top-site
top-e-site
tramadol
trim-spa
ultram
valeofglamorganconservatives
viagra
vioxx
xanax
zolus</cfoutput></cfsavecontent>
<cfreturn result>
</cffunction>
</cfcomponent>