Caritatis

Just another WordPress.com weblog

Using an ajax-called cfc with Application.cfc April 15, 2011

Filed under: ColdFusion — caritatis @ 7:05 pm

If you want to use onRequest and you have cfc functions called by ajax (or other services), you’ll have a problem.  To get around this remove the onRequest function when you’re calling a cfc.  Do this in onRequestStart.

        <!— onRequest function breaks calls to cfc for json —>
  <cfif right(arguments.targetPage,4)  is “.cfc”>
            <cfset StructDelete(variables,”onRequest”)/>
            <cfset StructDelete( THIS, “OnRequest” ) />
  </cfif>

 

Getting rid of Word junk February 4, 2011

Filed under: ColdFusion,Drupal,FCK Editor — caritatis @ 9:01 pm

FROM:  http://tim.mackey.ie/CleanWordHTMLUsingRegularExpressions.aspx

Haven’t tried this, but looks good.

Wednesday, November 23, 2005 3:40:36 PM (GMT Standard Time, UTC+00:00) ( .Net General )

Introduction

I’ve spent a long time trying many different approaches at getting rid of MS Word HTML, when importing or pasting text into my content management system, with very mixed success.  Previous efforts involved using the MSHTML Element Dom but this was slow and difficult to implement.  i think i’ve finally found a satisfactory and fast solution using only regular expressions.  Please feel free to use it in your applications, and post any improvements you may find.

The Code

/// <summary>
/// Removes all FONT and SPAN tags, and all Class and Style attributes.
/// Designed to get rid of non-standard Microsoft Word HTML tags.
/// </summary>
private string CleanHtml(string html)
{
    // start by completely removing all unwanted tags
    html = Regex.Replace(html, @"<[/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^>]*?>", "", RegexOptions.IgnoreCase);
    // then run another pass over the html (twice), removing unwanted attributes
    html = Regex.Replace(html, @"<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>","<$1$2>", RegexOptions.IgnoreCase);
    html = Regex.Replace(html, @"<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>","<$1$2>", RegexOptions.IgnoreCase);
    return html;
}

Samples of non-standard Microsoft Word HTML

<SPAN lang=EN-IE style="mso-ansi-language: EN-IE">
<p>
<UL style="MARGIN-TOP: 0cm" type=circle>
<o:p>&nbsp;</o:p>
<li style='mso-list:l3 level1 lfo3;tab-stops:list 36.0pt'>

Explanation of Regular Expressions

I’ve spent a good deal of time examining the problematic tags that MS Word inserts in its HTML, some examples are shown above.  The above code is based on a few requirements for my CMS:

  • remove all FONT and SPAN tags, because all the content in my CMS is done through style-sheets.
  • remove all CLASS and STYLE tags because they mean nothing outside of the original word document
  • remove all namespace tags and attributes like <o:p> and < … v:shape … >

The first regular expression removes unwanted tags, and is broken down as follows:

<[/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^>]*?>
  • match an open tag character <
  • and optionally match a close tag sequence </  (because we also want to remove the closing tags)
  • match any of the list of unwanted tags: font,span,xml,del,ins
  • a pattern is given to match any of the namespace tags, anything beginning with o,v,w,x,p, followed by a : followed by another word
  • match any attributes as far as the closing tag character >
  • the replace string for this regex is “”, which will completely remove the instances of any matching tags.
  • note that we are not removing anything between the tags, just the tags themselves

The second regular expression removes unwanted attributes, and is broken down as follows:

<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>
  • match an open tag character <
  • capture any text before the unwanted attribute (This is $1 in the replace expression)
  • match (but don’t capture) any of the unwanted attributes: class, lang, style, size, face, o:p, v:shape etc.
  • there should always be an = character after the attribute name
  • match the value of the attribute by identifying the delimiters. these can be single quotes, or double quotes, or no quotes at all.
  • for single quotes, the pattern is: ‘ followed by anything but a ‘ followed by a ‘
  • similarly for double quotes.
  • for a non-delimited attribute value, i specify the pattern as anything except the closing tag character >
  • lastly, capture whatever comes after the unwanted attribute in ([^>]*)
  • the replacement string <$1$2> reconstructs the tag without the unwanted attribute found in the middle.
  • note: this only removes one occurence of an unwanted attribute, this is why i run the same regex twice.  For example, take the html fragment: <p style=”Margin-TOP:3em”>
    the regex will only remove one of these attributes.  Running the regex twice will remove the second one.  I can’t think of any reasonable cases where it would need to be run more than that.

Suggestions!

If you have any suggestions or improvments, please post them here as comments.
Thanks :)

Lots of great comments!  Here’s one in CF:

<cffunction name=”cleanUpWord” access=”public” output=”false” returntype=”string” returnformat=”JSON” hint=”I clean up MS Word code”>
<cfargument name=”inputString” type=”string” required=”yes”>

<cfset var local = StructNew()>

<!— The two regex expressions in this function were taken from http://tim.mackey.ie/CleanWordHTMLUsingRegularExpressions.aspx —>

<cfset local.cleanText = ReplaceNoCase(arguments.inputString,”<p “,”<p><p “,”all”)> <!— Keep our P tag when it has bullshit MS Word attributes —>
<cfset local.cleanText = ReReplaceNoCase(local.cleanText,”<[/]?(font|span|xml|del|ins|o|st1|[ovwxp]:\w+)[^>]*?>”,”",”all”)> <!— Borrowed Regex —>
<cfset local.cleanText = ReReplaceNoCase(local.cleanText,”<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:’[^']*’|”"[^""]*”"|[^\s>]+)([^>]*)>”,”",”all”)> <!— Borrowed Regex —>
<cfset local.cleanText = ReplaceNoCase(local.cleanText,”&ndash;”,”-”,”all”)> <!— Get rid of unnecessary escape sequences —>
<cfset local.cleanText = ReReplaceNoCase(local.cleanText,”&rsquo;|&lsquo;”,”‘”,”all”)> <!— Get rid of unnecessary escape sequences —>
<cfset local.cleanText = ReReplaceNoCase(local.cleanText,”&rdquo;|&ldquo;”,”"”",”all”)> <!— Get rid of unnecessary escape sequences —>

<cfset local.cleanText = ReReplaceNoCase(local.cleanText,”“|””,”&quot;”,”all”)> <!— Get rid of MS Word SmartQuotes —>

<cfreturn local.cleanText>
</cffunction>

 

Switching from Application.cfm to Application.cfc November 2, 2010

Filed under: ColdFusion — caritatis @ 3:38 pm

One thing that has given me pause in trying to switch from Application.cfm to .cfc before is that there’s a lot of legacy code that references the datasource through variables.dsn that’s set in Application.cfm.  I don’t want to change all the legacy code and I wasn’t sure how to pass anything in variables from the cfc.  I tried to do it through OnRequestStart and OnApplicationStart–but those just failed.  I also tried putting it outside of all the functions–that didn’t work either.  I finally found enough information in one of Ben Nadel’s post (http://www.bennadel.com/blog/726-ColdFusion-Application-cfc-Tutorial-And-Application-cfc-Reference.htm) to give me what I needed.

You can put variables in the OnRequest function and they will get passed to the pages.

    <cffunction name=”OnRequest” access=”public” returntype=”void” output=”true”
        hint=”Fires after pre page processing is complete.”>
     <cfargument name=”TargetPage” type=”string” required=”true”/>
        <cfset variables.dsn = “MyDSN”>
  <!— Include the requested page. —>
        <cfinclude template=”#ARGUMENTS.TargetPage#” />

    </cffunction>

For new sites I’m using Application.DSN in the OnApplicationStart so it’s only set one time, in one place.  But, for old stuff that’s working fine, I’m going to do the OnRequest.

 

Using CF cfc files in parallel folders November 2, 2010

Filed under: ColdFusion — caritatis @ 3:28 pm

I knew there had to be a way to do this and I finally found it on Ben Nadel’s blog (http://www.bennadel.com/blog/1608-ColdFusion-8-Application-Specific-Mappings-Work-With-The-CFComponent-Extends-Attribute.htm). 

I often put things in different folders based on what they do.  I also like to have all my cfc files in an includes folder, since that’s the de-facto standard at work.  However, I could never quite figure out how to reference a cfc in the includes from a folder that was parallel.

For example:

Application.cfc
\includes\…
\somestuff\…

How does something in “somestuff” reference “includes”?  It ends up you can add a mapping to includes in Application.cfc that will make all calls to includes go to the correct folder.  This prevents you from having more than one includes folder.  I tried this with an Application.cfm and it didn’t seem to work.  There may be a way, but I couldn’t figure it out and I didn’t want to spend any more time on it.  So, I switched to an Application.cfc and everything worked fine.  The only thing I had to do was verify the mapping.  It didn’t originally work as I expected because my application is buried a couple of layers deep in an html site.  I thought it would work from the application.cfc folder.  However, it actually mapped it one level higher.   But, once I checked the mapping (using cfdump with the This.Mappings), I could see it was just missing a folder name.  I added that and it worked.

 <!— Define application-specific mappings. This allows us to get to the includes folder from anywhere —>
<cfset THIS.Mappings[ "/includes" ] = (
  REReplace(
  GetDirectoryFromPath( GetCurrentTemplatePath() ),
  ”[^\\/]+[\\/]$”,
  ”",
  ”one”
  ) &
  ”includes/”
    ) />

 

An oldie but a goodie October 18, 2010

Filed under: ColdFusion — caritatis @ 7:29 pm

I always forget the 3 commands to keep the cache clear, since you write ‘em once and leave ‘em alone.  Here’s the coldfusion version:

<cfheader name="expires" value="-1">
<cfheader name="cache-control" value="no">
<cfheader name="pragma" value="no-cache">

The -1 in the expires saves you from problems when the clocks don’t match (different timezones, etc).  It seems silly to have to say the same thing 3 times, but this was what we found worked at my old job.  Hopefully this will be obsolete soon as people move to new browsers.

 

 

Random component argument issue October 14, 2010

Filed under: ColdFusion — caritatis @ 7:08 pm

Okay, I spent too long on this issue today and I don’t want to forget the answer.  It seems that when you have a CF component, you cannot have arguments named username or password.  They won’t get passed to the function.  You get an error that “the parameter to the function is required but was not passed in”.

 

Some good string manipulation to remember September 15, 2010

Filed under: ColdFusion — caritatis @ 12:19 pm

<cfcomponent>

<cffunction name=”tagStripper” access=”public” output=”no” returntype=”string”>
<cfargument name=”source” required=”YES” type=”string”>
<cfargument name=”action” required=”No” type=”string” default=”strip”>
<cfargument name=”tagList” required=”no” type=”string” default=”">

<!—
source = string variable
This is the string to be modified

action = “preserve” or “strip”
This function will either strip all tags except
those specified in the tagList argument, or it will
preserve all tags except those in the taglist argument.
The default action is “strip”

tagList = string variable
This argument contains a comma separated list of tags to be excluded from
the action.  If the action is “strip”, then these tags won’t be stripped.
If the action os “preserve”, then these tags won’t be preserved (ie, only
these tags will be stripped)

EXAMPLE

tagStripper(myString,”strip”,”b,i”)

This invocation will strip all html tags except for
<b></b> and <i></i>
—>
<cfscript>
var str = arguments.source;
var i = 1;
var tag = “”;

if (trim(lcase(action)) eq “preserve”)
{
// strip only the exclusions
for (i=1;i lte listlen(arguments.tagList); i = i + 1)
{
tag = listGetAt(tagList,i);
str = REReplaceNoCase(str,”</?#tag#.*?>”,”",”ALL”);
}
} else {
// if there are exclusions, mark them with NOSTRIP
if (tagList neq “”)
{
for (i=1;i lte listlen(tagList); i = i + 1)
{
tag = listGetAt(tagList,i);
str = REReplaceNoCase(str,”<(/?#tag#.*?)>”,”___TEMP___NOSTRIP___\1___TEMP___ENDNOSTRIP___”,”ALL”);
}
}
str = reReplaceNoCase(str,”</?[A-Z].*?>”,”",”ALL”);
// convert excluded tags back to normal
str = replace(str,”___TEMP___NOSTRIP___”,”<”,”ALL”);
str = replace(str,”___TEMP___ENDNOSTRIP___”,”>”,”ALL”);
}

return str;
</cfscript>
</cffunction>

<!— From Ben Nadel: http://www.bennadel.com/index.cfm?event=blog.viewcode&id=1155&index=1 —>
<cffunction
name=”CleanHighAscii”
access=”public”
returntype=”string”
output=”false”
hint=”Cleans extended ascii values to make the as web safe as possible.”>

<!— Define arguments. —>
<cfargument
name=”Text”
type=”string”
required=”true”
hint=”The string that we are going to be cleaning.”
/>

<!— Set up local scope. —>
<cfset var LOCAL = {} />

<!—
When cleaning the string, there are going to be ascii
values that we want to target, but there are also going
to be high ascii values that we don’t expect. Therefore,
we have to create a pattern that simply matches all non
low-ASCII characters. This will find all characters that
are NOT in the first 127 ascii values. To do this, we
are using the 2-digit hex encoding of values.
—>
<cfset LOCAL.Pattern = CreateObject(
“java”,
“java.util.regex.Pattern”
).Compile(
JavaCast( “string”, “[^\x00-\x7F]” )
)
/>

<!—
Create the pattern matcher for our target text. The
matcher will be able to loop through all the high
ascii values found in the target string.
—>
<cfset LOCAL.Matcher = LOCAL.Pattern.Matcher(
JavaCast( “string”, ARGUMENTS.Text )
) />

<!—
As we clean the string, we are going to need to build
a results string buffer into which the Matcher will
be able to store the clean values.
—>
<cfset LOCAL.Buffer = CreateObject(
“java”,
“java.lang.StringBuffer”
).Init() />

<!— Keep looping over high ascii values. —>
<cfloop condition=”LOCAL.Matcher.Find()”>

<!— Get the matched high ascii value. —>
<cfset LOCAL.Value = LOCAL.Matcher.Group() />

<!— Get the ascii value of our character. —>
<cfset LOCAL.AsciiValue = Asc( LOCAL.Value ) />

<!—
Now that we have the high ascii value, we need to
figure out what to do with it. There are explicit
tests we can perform for our replacements. However,
if we don’t have a match, we need a default
strategy and that will be to just store it as an
escaped value.
—>

<!— Check for Microsoft double smart quotes. —>
<cfif (
(LOCAL.AsciiValue EQ 8220) OR
(LOCAL.AsciiValue EQ 8221)
)>

<!— Use standard quote. —>
<cfset LOCAL.Value = “”"” />

<!— Check for Microsoft single smart quotes. —>
<cfelseif (
(LOCAL.AsciiValue EQ 8216) OR
(LOCAL.AsciiValue EQ 8217)
)>

<!— Use standard quote. —>
<cfset LOCAL.Value = “‘” />

<!— Check for Microsoft elipse. —>
<cfelseif (LOCAL.AsciiValue EQ 8230)>

<!— Use several periods. —>
<cfset LOCAL.Value = “…” />

<cfelse>

<!—
We didn’t get any explicit matches on our
character, so just store the escaped value.
—>
<cfset LOCAL.Value = “&###LOCAL.AsciiValue#;” />

</cfif>

<!—
Add the cleaned high ascii character into the
results buffer. Since we know we will only be
working with extended values, we know that we don’t
have to worry about escaping any special characters
in our target string.
—>
<cfset LOCAL.Matcher.AppendReplacement(
LOCAL.Buffer,
JavaCast( “string”, LOCAL.Value )
) />

</cfloop>

<!—
At this point there are no further high ascii values
in the string. Add the rest of the target text to the
results buffer.
—>
<cfset LOCAL.Matcher.AppendTail(
LOCAL.Buffer
) />

<!— Return the resultant string. —>
<cfreturn LOCAL.Buffer.ToString() />
</cffunction>

<!— From http://www.trunkful.com/index.cfm/2010/5/27/How-to-CFMAIL-Properly-and-Keep-the-SPAM-in-the-Can —>
<cffunction name=”textMessage” access=”public” returntype=”string” hint=”Converts an html email message into a nicely formatted with line breaks plain text message”>
<cfargument name=”string” required=”true” type=”string”>
<cfscript>
var pattern = “<br>”;
var CRLF = chr(13) & chr(10);
var message = ReplaceNoCase(arguments.string, pattern, CRLF , “ALL”);
pattern = “<[^>]*>”;
</cfscript>
<cfreturn REReplaceNoCase(message, pattern, “” , “ALL”)>
</cffunction>

<!— Removes all html entities (i.e. &nbsp; &Epsilon; ) from a string —>
<cffunction name=”cleanHTMLEntities” access=”public” returntype=”string” hint=”Removes all html entities from a string”>
<cfargument name=”input” required=”true” type=”string”>

<cfset output = REReplaceNoCase(input, “(&##\d{3};)|(&[a-zA-Z1-4]+;)|(&##x[A-F0-9]+;)”, “”, “all”)>

<cfreturn output>

</cffunction>

<cfscript>
/**
* Coverts special characters to character entities, making a string safe for display in HTML.
* Version 2 update by Eli Dickinson (eli.dickinson@gmail.com)
* Fixes issue of lists not being equal and adding bull
* v3, extra semicolons
*
*9/14/10 It was called HTMLSafe, but I needed to get the ASCII from the html entities
*  for the subject line of cf email since cf wasn’t converting the entities.  I also added a
*  bunch of upper & lower greek letters and removed some code
*  that dealt with different versions of cf since I only have the one and it’s a newer one.
*
* @param string      String to format. (Required)
* @return Returns a string.
* @author Gyrus (eli.dickinson@gmail.comgyrus@norlonto.net)
* @version 3, August 30, 2006
*/
function ReverseHTMLSafe(string) {
// Initialise
var goodChars = “&,”",#Chr(161)#,#Chr(162)#,#Chr(163)#,#Chr(164)#,#Chr(165)#,#Chr(166)#,#Chr(167)#,#Chr(168)#,#Chr(169)#,#Chr(170)#,#Chr(171)#,#Chr(172)#,#Chr(173)#,#Chr(174)#,#Chr(175)#,#Chr(176)#,#Chr(177)#,#Chr(178)#,#Chr(179)#,#Chr(180)#,#Chr(181)#,#Chr(182)#,#Chr(183)#,#Chr(184)#,#Chr(185)#,#Chr(186)#,#Chr(187)#,#Chr(188)#,#Chr(189)#,#Chr(190)#,#Chr(191)#,#Chr(215)#,#Chr(247)#,#Chr(192)#,#Chr(193)#,#Chr(194)#,#Chr(195)#,#Chr(196)#,#Chr(197)#,#Chr(198)#,#Chr(199)#,#Chr(200)#,#Chr(201)#,#Chr(202)#,#Chr(203)#,#Chr(204)#,#Chr(205)#,#Chr(206)#,#Chr(207)#,#Chr(208)#,#Chr(209)#,#Chr(210)#,#Chr(211)#,#Chr(212)#,#Chr(213)#,#Chr(214)#,#Chr(216)#,#Chr(217)#,#Chr(218)#,#Chr(219)#,#Chr(220)#,#Chr(221)#,#Chr(222)#,#Chr(223)#,#Chr(224)#,#Chr(225)#,#Chr(226)#,#Chr(227)#,#Chr(228)#,#Chr(229)#,#Chr(230)#,#Chr(231)#,#Chr(232)#,#Chr(233)#,#Chr(234)#,#Chr(235)#,#Chr(236)#,#Chr(237)#,#Chr(238)#,#Chr(239)#,#Chr(240)#,#Chr(241)#,#Chr(242)#,#Chr(243)#,#Chr(244)#,#Chr(245)#,#Chr(246)#,#Chr(248)#,#Chr(249)#,#Chr(250)#,#Chr(251)#,#Chr(252)#,#Chr(253)#,#Chr(254)#,#Chr(255)#”;
var badChars = “&amp;,&quot;,&iexcl;,&cent;,&pound;,&curren;,&yen;,&brvbar;,&sect;,&uml;,&copy;,&ordf;,&laquo;,&not;,&shy;,&reg;,&macr;,&deg;,&plusmn;,&sup2;,&sup3;,&acute;,&micro;,&para;,&middot;,&cedil;,&sup1;,&ordm;,&raquo;,&frac14;,&frac12;,&frac34;,&iquest;,&times;,&divide;,&Agrave;,&Aacute;,&Acirc;,&Atilde;,&Auml;,&Aring;,&AElig;,&Ccedil;,&Egrave;,&Eacute;,&Ecirc;,&Euml;,&Igrave;,&Iacute;,&Icirc;,&Iuml;,&ETH;,&Ntilde;,&Ograve;,&Oacute;,&Ocirc;,&Otilde;,&Ouml;,&Oslash;,&Ugrave;,&Uacute;,&Ucirc;,&Uuml;,&Yacute;,&THORN;,&szlig;,&agrave;,&aacute;,&acirc;,&atilde;,&auml;,&aring;,&aelig;,&ccedil;,&egrave;,&eacute;,&ecirc;,&euml;,&igrave;,&iacute;,&icirc;,&iuml;,&eth;,&ntilde;,&ograve;,&oacute;,&ocirc;,&otilde;,&ouml;,&oslash;,&ugrave;,&uacute;,&ucirc;,&uuml;,&yacute;,&thorn;,&yuml;,&##338;,&##339;,&##352;,&##353;,&##376;,&##710;,&##8211;,&##8212;,&##8216;,&##8217;,&##8218;,&##8220;,&##8221;,&##8222;,&##8224;,&##8225;,&##8240;,&##8249;,&##8250;,&##8364;,<sup><small>TM</small></sup>,&bull;,&nbsp;,&Alpha;,&alpha;,&Beta;,&beta;,&Gamma;,&gamma;,&Delta;,&delta;,&Epsilon;,&epsilon;,&Zeta;,&zeta;,&Eta;,&eta;,&Theta;,&theta;,&Iota;,&iota;,&Kappa;,&kappa;,&Lamda;,&lamda;,&Mu;,&mu;,&Nu;,&nu;,&Xi;,&xi;,&Omicron;,&omicron;,&Pi;,&pi;,&Rho;,&rho;,&Sigma;,&sigma;,&sigmaf;,&Tau;,&tau;,&Upsilon;,&upsilon;,&Phi;,&phi;,&Chi;,&chi;,&Psi;,&psi;,&Omega;,&omega;”;

// MX/Unicode matches
goodChars = “#goodChars#,#Chr(338)#,#Chr(339)#,#Chr(352)#,#Chr(353)#,#Chr(376)#,#Chr(710)#,#Chr(8211)#,#Chr(8212)#,#Chr(8216)#,#Chr(8217)#,#Chr(8218)#,#Chr(8220)#,#Chr(8221)#,#Chr(8222)#,#Chr(8224)#,#Chr(8225)#,#Chr(8240)#,#Chr(8249)#,#Chr(8250)#,#Chr(8364)#,#Chr(8482)#,#Chr(8226)#,#Chr(160)#,#Chr(913)#,#Chr(945)#,#Chr(914)#,#Chr(946)#,#Chr(915)#,#Chr(947)#,#Chr(916)#,#Chr(948)#,#Chr(917)#,#Chr(949)#,#Chr(918)#,#Chr(950)#,#Chr(919)#,#Chr(951)#,#Chr(920)#,#Chr(952)#,#Chr(921)#,#Chr(953)#,#Chr(922)#,#Chr(954)#,#Chr(923)#,#Chr(955)#,#Chr(924)#,#Chr(956)#,#Chr(925)#,#Chr(957)#,#Chr(926)#,#Chr(958)#,#Chr(927)#,#Chr(959)#,#Chr(928)#,#Chr(960)#,#Chr(929)#,#Chr(961)#,#Chr(931)#,#Chr(963)#,#Chr(962)#,#Chr(932)#,#Chr(964)#,#Chr(933)#,#Chr(965)#,#Chr(934)#,#Chr(966)#,#Chr(935)#,#Chr(967)#,#Chr(936)#,#Chr(968)#,#Chr(937)#,#Chr(969)#”;

// Return immediately if blank string
if (NOT Len(Trim(string))) return string;

// Do replacing
return ReplaceList(string, badChars, goodChars);

}
</cfscript>

</cfcomponent>

 

Edit ApplicationHost.config June 10, 2010

Filed under: ColdFusion,IIS — caritatis @ 12:55 am

From: http://technet.microsoft.com/en-us/library/cc735123(WS.10).aspx 

Edit application host history configuration

To change the application host history settings, edit the configHistory section in the ApplicationHost.config file.

To perform this procedure, you must have membership in Administrators, or you must have been delegated the appropriate authority.

To edit the configHistory section in the ApplicationHost.config file:

  1. Open an elevated Command Prompt window. Click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.
  2. Change to the directory %Windir%\system32\inetsrv.
  3. Type appcmd add backup backupName to back up the ApplicationHost.config file.A directory with the backup name that you specify will be created under the %Windir%\system32\inetsrv\backup directory. If you do not specify a name, appcmd will generate a directory name automatically using the current date and time.
  4. Change the directory to %Windir%\system32\inetsrv\config.
  5. Type notepad ApplicationHost.config.
  6. In notepad, search for the configHistory section under the system.applicationHost section.
  7. Use the article IIS 7.0: configHistory Element (IIS Settings Schema) as a reference to return the configHistory section settings to a well-known state.
  8. Save and close the ApplicationHost.config file.
 

Using a list in cfquery March 23, 2010

Filed under: ColdFusion,SQL — caritatis @ 8:22 pm

Very easy!  Awesome!

where  SomeID in (<cfqueryparam value=”#REQUEST.ATTRIBUTES.someIDList#” cfsqltype=”cf_sql_integer” list=”yes” />)

 

Get a list from a query March 23, 2010

Filed under: ColdFusion — caritatis @ 6:30 pm

From:  http://www.technicallychris.com/2006/07/27/little-known-functions-valuelist/

I saw a function today that I had actually never seen before, and it would have helped me save a few lines of code in many CF projects. The function is ValueList. ValueList takes a Query column as it’s first parameter, and a delimiter as an optional second parameter, and returns a list of the values from the query.

 An example:

 
<cfquery name="qryGetItems" datasource="#dsn#">
  select items.item_name
    from items
</cfquery>
<cfset all_items = ValueList(qryGetItems.item_name)>
 

You now have a comma delimited list of all items from your query.

 

 
Follow

Get every new post delivered to your Inbox.