--- /dev/null
+<cfsetting enablecfoutputonly="true">\r
+<!---\r
+This code uses a CF User Defined Function and should work in CF version 5.0\r
+and up without alteration.\r
+\r
+Also if you are hosting your site at an ISP, you will have to check with them\r
+to see if the use of <CFEXECUTE> is allowed. In most cases ISP will not allow\r
+the use of that tag for security reasons. Clients would be able to access each\r
+others files in certain cases.\r
+--->\r
+\r
+<!--- The following variables values must reflect your installation. --->\r
+<cfset aspell_dir = "C:\Program Files\Aspell\bin">\r
+<cfset lang = "en_US">\r
+<cfset aspell_opts = "-a --lang=#lang# --encoding=utf-8 -H --rem-sgml-check=alt">\r
+<cfset tempfile_in = GetTempFile(GetTempDirectory(), "spell_")>\r
+<cfset tempfile_out = GetTempFile(GetTempDirectory(), "spell_")>\r
+<cfset spellercss = "../spellerStyle.css">\r
+<cfset word_win_src = "../wordWindow.js">\r
+\r
+<cfset form.checktext = form["textinputs[]"]>\r
+\r
+<!--- make no difference between URL and FORM scopes --->\r
+<cfparam name="url.checktext" default="">\r
+<cfparam name="form.checktext" default="#url.checktext#">\r
+\r
+<!--- Takes care of those pesky smart quotes from MS apps, replaces them with regular quotes --->\r
+<cfset submitted_text = ReplaceList(form.checktext,"%u201C,%u201D","%22,%22")>\r
+\r
+<!--- submitted_text now is ready for processing --->\r
+\r
+<!--- use carat on each line to escape possible aspell commands --->\r
+<cfset text = "">\r
+<cfset CRLF = Chr(13) & Chr(10)>\r
+\r
+<cfloop list="#submitted_text#" index="field" delimiters=",">\r
+ <cfset text = text & "%" & CRLF\r
+ & "^A" & CRLF\r
+ & "!" & CRLF>\r
+ <!--- Strip all tags for the text. (by FredCK - #339 / #681) --->\r
+ <cfset field = REReplace(URLDecode(field), "<[^>]+>", " ", "all")>\r
+ <cfloop list="#field#" index="line" delimiters="#CRLF#">\r
+ <cfset text = ListAppend(text, "^" & Trim(JSStringFormat(line)), CRLF)>\r
+ </cfloop>\r
+</cfloop>\r
+\r
+<!--- create temp file from the submitted text, this will be passed to aspell to be check for misspelled words --->\r
+<cffile action="write" file="#tempfile_in#" output="#text#" charset="utf-8">\r
+\r
+<!--- execute aspell in an UTF-8 console and redirect output to a file. UTF-8 encoding is lost if done differently --->\r
+<cfexecute name="cmd.exe" arguments='/c type "#tempfile_in#" | "#aspell_dir#\aspell.exe" #aspell_opts# > "#tempfile_out#"' timeout="100"/>\r
+\r
+<!--- read output file for further processing --->\r
+<cffile action="read" file="#tempfile_out#" variable="food" charset="utf-8">\r
+\r
+<!--- remove temp files --->\r
+<cffile action="delete" file="#tempfile_in#">\r
+<cffile action="delete" file="#tempfile_out#">\r
+\r
+<cfset texts = StructNew()>\r
+<cfset texts.textinputs = "">\r
+<cfset texts.words = "">\r
+<cfset texts.abort = "">\r
+\r
+<!--- Generate Text Inputs --->\r
+<cfset i = 0>\r
+<cfloop list="#submitted_text#" index="textinput">\r
+ <cfset texts.textinputs = ListAppend(texts.textinputs, 'textinputs[#i#] = decodeURIComponent("#textinput#");', CRLF)>\r
+ <cfset i = i + 1>\r
+</cfloop>\r
+\r
+<!--- Generate Words Lists --->\r
+<cfset word_cnt = 0>\r
+<cfset input_cnt = -1>\r
+<cfloop list="#food#" index="aspell_line" delimiters="#CRLF#">\r
+ <cfset leftChar = Left(aspell_line, 1)>\r
+ <cfif leftChar eq "*">\r
+ <cfset input_cnt = input_cnt + 1>\r
+ <cfset word_cnt = 0>\r
+ <cfset texts.words = ListAppend(texts.words, "words[#input_cnt#] = [];", CRLF)>\r
+ <cfset texts.words = ListAppend(texts.words, "suggs[#input_cnt#] = [];", CRLF)>\r
+ <cfelse>\r
+ <cfif leftChar eq "&" or leftChar eq "##">\r
+ <!--- word that misspelled --->\r
+ <cfset bad_word = Trim(ListGetAt(aspell_line, 2, " "))>\r
+ <cfset bad_word = Replace(bad_word, "'", "\'", "ALL")>\r
+ <!--- sugestions --->\r
+ <cfset sug_list = Trim(ListRest(aspell_line, ":"))>\r
+ <cfset sug_list = ListQualify(Replace(sug_list, "'", "\'", "ALL"), "'")>\r
+ <!--- javascript --->\r
+ <cfset texts.words = ListAppend(texts.words, "words[#input_cnt#][#word_cnt#] = '#bad_word#';", CRLF)>\r
+ <cfset texts.words = ListAppend(texts.words, "suggs[#input_cnt#][#word_cnt#] = [#sug_list#];", CRLF)>\r
+ <cfset word_cnt = word_cnt + 1>\r
+ </cfif>\r
+ </cfif>\r
+</cfloop>\r
+\r
+<cfif texts.words eq "">\r
+ <cfset texts.abort = "alert('Spell check complete.\n\nNo misspellings found.'); top.window.close();">\r
+</cfif>\r
+\r
+<cfcontent type="text/html; charset=utf-8">\r
+\r
+<cfoutput><html>\r
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r
+<link rel="stylesheet" type="text/css" href="#spellercss#" />\r
+<script language="javascript" src="#word_win_src#"></script>\r
+<script language="javascript">\r
+var suggs = new Array();\r
+var words = new Array();\r
+var textinputs = new Array();\r
+var error;\r
+\r
+#texts.textinputs##CRLF#\r
+#texts.words#\r
+#texts.abort#\r
+\r
+var wordWindowObj = new wordWindow();\r
+wordWindowObj.originalSpellings = words;\r
+wordWindowObj.suggestions = suggs;\r
+wordWindowObj.textInputs = textinputs;\r
+\r
+function init_spell() {\r
+ // check if any error occured during server-side processing\r
+ if( error ) {\r
+ alert( error );\r
+ } else {\r
+ // call the init_spell() function in the parent frameset\r
+ if (parent.frames.length) {\r
+ parent.init_spell( wordWindowObj );\r
+ } else {\r
+ alert('This page was loaded outside of a frameset. It might not display properly');\r
+ }\r
+ }\r
+}\r
+</script>\r
+\r
+</head>\r
+<body onLoad="init_spell();">\r
+\r
+<script type="text/javascript">\r
+wordWindowObj.writeBody();\r
+</script>\r
+\r
+</body>\r
+</html></cfoutput>\r
+<cfsetting enablecfoutputonly="false">\r