Skip to content

Instantly share code, notes, and snippets.

View JamoCA's full-sized avatar

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / justNumericList.cfm
Last active December 20, 2015 18:49
ColdFusion 8+ UDF to filter a list so that just numeric entries are returned. Based on http://cflib.org/udf/justNumericList Additionally filtered by number type, min/max limits & max number of values to return. Added SQL-type number translation to javacast type. Add trim to values in case user accidentally pastes tab or space characters (ie, fro…
<cfscript>
/* Based on http://www.cflib.org/udf/justNumericList
Filters a list so that just numeric entries are returned.
Additionally filtered by number type, min/max limits & max number of values to return
Added SQL-type number translation to javacast type
Add trim to values in case user accidentally pastes tab or space characters (ie, from Excel)
*/
function justNumericList(nList) {
var intIndex = 0;
var aryN = arrayNew(1);
@JamoCA
JamoCA / getShippingURL.cfm
Created August 8, 2013 00:48
ColdFusion UDF to generate tracking URLs for major shipping companies: UPS, Fedex, U.S. Postal Service, OnTrac, DHL based on shipment tracking URLs at http://verysimple.com/2011/07/06/ups-tracking-url/ (NOTE: You can test this at CFLive.net)
<cfscript>
function getShippingURL(shipper, trackingNumber){
var shipURL = '';
var trackingURLS = StructNew();
trackingURLS['UPS'] = 'http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=';
trackingURLS['FedEx'] = 'http://www.fedex.com/Tracking?action=track&tracknumbers=';
trackingURLS['USPS'] = 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=';
trackingURLS['DHLUS'] = 'http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=';
trackingURLS['DHLGlobal'] = 'http://webtrack.dhlglobalmail.com/?mobile=&trackingnumber=';
trackingURLS['OnTrac'] = 'http://www.ontrac.com/trackingres.asp?tracking_number=';
@JamoCA
JamoCA / camelSpace.cfm
Last active December 20, 2015 21:29
camelSpace is a ColdFusion UDF to convert any ColdFusion (scoped or non-scoped) variable name to a title formatted string. (NOTE: You can test this at CFLive.net)
<p>NOTE: 2 other UDFs exist that have similar functionality.</p>
<p><b>varNameToText()</b> - Incorrectly adds spaces between all uppercase words like "ZIP". Doesn't remove scope.<br>
http://cflib.org/udf/varNameToText</p>
<p><b>camelToSpace()</b> - If first letter is upper, adds a space. Doesn't remove underscores.<br>
http://cflib.org/udf/camelToSpace</p>
<cfscript>
@JamoCA
JamoCA / makeHoneyPotLink.cfm
Last active December 20, 2015 23:28
ColdFusion UDF to generate randomized Honey Pot HTML Code. For use with ProjectHoneyPot.org. (NOTE: You can test this at CFLive.net)
@JamoCA
JamoCA / projecthoneypot_honeypot.cfm
Last active December 21, 2015 12:58
The Project Honey Pot script for ColdFusion was timing out + failing with a "Element EMAIL is undefined in RETURNVARS." error on line 239. (I added a 5 second timeout & 403 error if a "408 Request Timeout" is received.)
<!--- Line 129, change this --->
<cfhttp url="http://#REQUEST_HOST##REQUEST_SCRIPT#" method="POST" port="#REQUEST_PORT#">
<!--- to this (if it takes more than 5 seconds, we will abort) --->
<cfhttp url="http://#REQUEST_HOST##REQUEST_SCRIPT#" method="POST" port="#REQUEST_PORT#" timeout="5">
<!--- After CFHTTP call (around line 144), add this --->
<CFIF Findnocase("408", CFHTTP.StatusCode)>
<cfcontent type="text/html; charset=UTF-8">
<cfheader statuscode="403" statustext="Forbidden">
<CFOUTPUT><h1>Forbidden</h1></CFOUTPUT>
@JamoCA
JamoCA / CFDUMPLineLength.cfm
Last active December 21, 2015 22:59
Simple ColdFusion script to identify # of lines outputted when using CFDump.
<cfset CR = chr(10)>
<cfset simpleVar = "a">
<cfsavecontent variable="simpleResults"><cfdump var="#simpleVar#"></cfsavecontent>
<cfoutput><div>simpleResults = #ListLen(simpleResults, CR)#</div></cfoutput>
@JamoCA
JamoCA / CFParam_Test.cfm
Created September 9, 2013 18:09
This ColdFusion sample attempts to identify what happens if a space is added to the name parameter of the CFPARAM function. Try this code at CFLive.net. Railo provides consistent/expected output, but the Adobe ColdFusion results vary.
<cfparam name=" test " default="xyz">
<cfparam name="test " default="123">
<cfparam name="test" default="abc">
<cfparam name="test2" default="abc">
<cfparam name="test2 " default="123">
<cfparam name=" test2 " default="xyz">
<h2>test</h2>
@JamoCA
JamoCA / FormRepost.htm
Created September 11, 2013 16:53
This is an easy method to visually reconstruct a form post using copy-and-paste data. I use this script to repost ColdFusion CFDump data from a reported error. (This scripts requires jQuery & HandsOnTable.)
<!DOCTYPE>
<html>
<head>
<title>Form Re-Post</title>
<link rel="stylesheet" type="text/css" media="screen" href="http://handsontable.com/dist/jquery.handsontable.full.css">
<script src="http://handsontable.com/lib/jquery.min.js" type="text/javascript"></script>
<script src="http://handsontable.com/dist/jquery.handsontable.full.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var table_Data = $('#table_Data');
@JamoCA
JamoCA / GetNetVersions.cfm
Last active December 23, 2015 13:09
A simple ColdFusion script to identify which versions of .Net are installed on a Windows server. (Requires CFRegistry) ColdFusion is currently at version 10 and this information is still absent from the "System Information" page.
<cfset SupportedNet = structnew()>
<cfset bit32 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\">
<cfset bit64 = "HKLM\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\">
<cfset NetCheck = StructNew()>
<cfset NetCheck["4 Client"] = {branch="#bit32#v4\Client", keys={"Install"=1, "Version"="4.0.30319"}}>
<cfset NetCheck["4 Full"] = {branch="#bit32#v4\Full", keys={"Install"=1, "Version"="4.0.30319"}}>
<cfset NetCheck["3.5 Original Release"] = {branch="#bit32#v3.5", keys={"Install"=1, "SP"="0"}}>
<cfset NetCheck["3.5 Service Pack 1"] = {branch="#bit32#v3.5", keys={"Install"=1, "SP"="1"}}>
<cfset NetCheck["3.0 Original Release"] = {branch="#bit32#v3.0", keys={"Install"=1, "SP"="0"}}>
@JamoCA
JamoCA / Timer.cfm
Created September 20, 2013 18:09
This is a ColdFusion Custom Tag to replace the native CFTimer function. I can't seem to get CFTimer to work even though it's enabled in the ColdFusion Administrator, debugging is enabled and my IP is whitelisted. I also added the ability to display the time based on an IP address mask. (NOTE: I've added this functionality to a basic myTimer tag …
<cfsetting enableCFOutputOnly="Yes"><!---
Author: James Moberg
Date: 9/20/2013
Notes: Called like cftimer but without enabling debugging. (NOTE: "debug" mode not supported.)
Types: outline (default),
Added "AllowedIPs". Enter a list of IPs. Masks acceptable (127.0.0.1,192.168.*.*)
CREDITS: Initial "myTimer" CFTag by Chris Phillips ( http://www.cfchris.com/cfchris/index.cfm/2007/4/5/My-CFTIMER-Custom-Tag )
CFTIMER FUNCTION: https://learn.adobe.com/wiki/display/coldfusionen/cftimer
EXAMPLE USAGE