| 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <!--- |
|---|
| 3 | Name : udf.cfm |
|---|
| 4 | Author : Raymond Camden |
|---|
| 5 | Created : June 01, 2004 |
|---|
| 6 | Last Updated : August 22, 2007 |
|---|
| 7 | History : |
|---|
| 8 | Purpose : |
|---|
| 9 | ---> |
|---|
| 10 | |
|---|
| 11 | <cfscript> |
|---|
| 12 | function isLoggedOn() { |
|---|
| 13 | return getAuthUser() neq ""; |
|---|
| 14 | } |
|---|
| 15 | request.udf.isLoggedOn = isLoggedOn; |
|---|
| 16 | |
|---|
| 17 | /** |
|---|
| 18 | * Tests passed value to see if it is a valid e-mail address (supports subdomain nesting and new top-level domains). |
|---|
| 19 | * Update by David Kearns to support ' |
|---|
| 20 | * SBrown@xacting.com pointing out regex still wasn't accepting ' correctly. |
|---|
| 21 | * |
|---|
| 22 | * @param str The string to check. (Required) |
|---|
| 23 | * @return Returns a boolean. |
|---|
| 24 | * @author Jeff Guillaume (jeff@kazoomis.com) |
|---|
| 25 | * @version 2, August 15, 2002 |
|---|
| 26 | */ |
|---|
| 27 | function IsEmail(str) { |
|---|
| 28 | //supports new top level tlds |
|---|
| 29 | if (REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$",str)) return TRUE; |
|---|
| 30 | else return FALSE; |
|---|
| 31 | } |
|---|
| 32 | request.udf.isEmail = isEmail; |
|---|
| 33 | |
|---|
| 34 | function isValidUsername(str) { |
|---|
| 35 | if(reFindNoCase("[^a-z0-9]",str)) return false; |
|---|
| 36 | return true; |
|---|
| 37 | } |
|---|
| 38 | request.udf.isValidUsername = isValidUsername; |
|---|
| 39 | |
|---|
| 40 | function cleanStruct(s) { |
|---|
| 41 | var key = ""; |
|---|
| 42 | for(key in s) { |
|---|
| 43 | s[key] = trim(htmlEditFormat(s[key])); |
|---|
| 44 | } |
|---|
| 45 | return s; |
|---|
| 46 | } |
|---|
| 47 | request.udf.cleanStruct = cleanStruct; |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * Returns a XHTML compliant string wrapped with properly formatted paragraph tags. |
|---|
| 51 | * |
|---|
| 52 | * @param string String you want XHTML formatted. |
|---|
| 53 | * @param attributeString Optional attributes to assign to all opening paragraph tags (i.e. style=""font-family: tahoma""). |
|---|
| 54 | * @return Returns a string. |
|---|
| 55 | * @author Jeff Howden (jeff@members.evolt.org) |
|---|
| 56 | * @version 1.1, January 10, 2002 |
|---|
| 57 | */ |
|---|
| 58 | function XHTMLParagraphFormat(string) { |
|---|
| 59 | var attributeString = ''; |
|---|
| 60 | var returnValue = ''; |
|---|
| 61 | |
|---|
| 62 | //added by me to support different line breaks |
|---|
| 63 | string = replace(string, chr(10) & chr(10), chr(13) & chr(10), "all"); |
|---|
| 64 | |
|---|
| 65 | if(ArrayLen(arguments) GTE 2) attributeString = ' ' & arguments[2]; |
|---|
| 66 | if(Len(Trim(string))) |
|---|
| 67 | returnValue = '<p' & attributeString & '>' & Replace(string, Chr(13) & Chr(10), '</p>' & Chr(13) & Chr(10) & '<p' & attributeString & '>', 'ALL') & '</p>'; |
|---|
| 68 | return returnValue; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | request.udf.XHTMLParagraphFormat = XHTMLParagraphFormat; |
|---|
| 72 | |
|---|
| 73 | function arrayDefinedAt(arr,pos) { |
|---|
| 74 | var temp = ""; |
|---|
| 75 | try { |
|---|
| 76 | temp = arr[pos]; |
|---|
| 77 | return true; |
|---|
| 78 | } |
|---|
| 79 | catch(coldfusion.runtime.UndefinedElementException ex) { |
|---|
| 80 | return false; |
|---|
| 81 | } |
|---|
| 82 | catch(coldfusion.runtime.CfJspPage$ArrayBoundException ex) { |
|---|
| 83 | return false; |
|---|
| 84 | } |
|---|
| 85 | } |
|---|
| 86 | request.udf.arrayDefinedAt = arrayDefinedAt; |
|---|
| 87 | </cfscript> |
|---|
| 88 | |
|---|
| 89 | <cfsetting enablecfoutputonly=false> |
|---|