This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
function makeHoneyPotLink(HoneyPotPath){ | |
var a = RandRange(1, 9, 'SHA1PRNG'); | |
var str = ''; | |
var randomWords = "closed-vestpocket,digitate,microwave,integrate,ultra-round,semester,volume"; | |
var serverName = CGI.Server_Name; | |
if (arrayLen(arguments) gte 2 AND len(trim(arguments[2]))) serverName = trim(arguments[2]); //Pass server name (optional) | |
if (arrayLen(arguments) gte 3 AND len(trim(arguments[3]))) randomWords = trim(arguments[2]); // Pass random words (optional) | |
randomWords = trim(listGetAt(randomWords, RandRange(1, ListLen(randomWords), 'SHA1PRNG'))); | |
HoneyPotPath = trim(HoneyPotPath); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
Convert CSV file to a ColdFusion query object using opencsv. | |
Requirements: | |
- ColdFusion 8+ ( http://en.wikipedia.org/wiki/Adobe_ColdFusion ) | |
- opencsv - free parser library for Java ( http://opencsv.sourceforge.net/ ) | |
http://opencsv.sourceforge.net/ | |
opencsv supports all the basic csv-type things you're likely to want to do: | |
- Arbitrary numbers of values per line | |
- Ignoring commas in quoted elements | |
- Handling quoted entries with embedded carriage returns (ie entries that span multiple lines) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Sample ColdFusion 9+ script to prevent Fallback Scope Injection. URL & Form variables are universally accessible in the scope & used as fallback. | |
Based on insights provided by Peter Freitag's blog post http://www.petefreitag.com/item/834.cfm ---> | |
<cfscript> | |
Scopes = "arguments,local,thread,variables,cgi,cookie,client,request,application,session,server,caller,thistag,this"; | |
for (thisField in Form) { | |
if (ListLen(thisField,".") GT 1 AND ListFindNocase(Scopes, trim(ListFirst(ThisField,".")))){ | |
StructDelete(Form, thisField); | |
if (ListFindnocase(Form.Fieldnames, ThisField)){ | |
Form.Fieldnames = ListDeleteAt(Form.Fieldnames, ListFindnocase(Form.Fieldnames, ThisField)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="doZipSearch" access="public" returntype="query" > | |
<cfargument name="zip" /> | |
<cfargument name="radius" /> | |
<cfscript> | |
//var all the variables to make sure race conditions are prevented | |
var qzips = false; | |
var pQry = false; | |
var rQry = false; | |
var theList = ""; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/* 3/18/2015 sanitizeFileName() | |
Pass filename, list of options (optional), replacementCharacter (default="") */ | |
function sanitizeFileName(s){ | |
var e = trim(listLast(trim(s), ".")); | |
var rules = ""; | |
var replacementCharacter = ""; | |
if(ArrayLen(Arguments) GTE 2) { rules = Arguments[2];} | |
if(ArrayLen(Arguments) GTE 3 AND LEN(trim(Arguments[3]))) { replacementCharacter = Arguments[3];} | |
s = trim(s); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// Query to retrieve some data from the database | |
variables.myData = queryExecute( | |
sql = " | |
SELECT * | |
FROM myTable | |
LIMIT 10 | |
", | |
options = {datasource="#Application.myDSN#"} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// If you don't set this then the searchParams structure will be uppercased when converted to JSON and cause ElasticSearch to error. | |
processingdirective preserveCase="true"; | |
public struct function elasticSearchSearch( required string serverURL, | |
required struct searchParams, | |
required string index, | |
required string type) { | |
// Post the search parameters to the ElasticSearch index and type | |
http method="post" url="#arguments.serverURL#/#arguments.index#/#arguments.type#/_search" result="searchResponse" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
function convertSecondsToTimeString(seconds) { | |
local.hours = arguments.seconds \ 3600; | |
local.minutes = (arguments.seconds \ 60) mod 60; | |
local.seconds = (arguments.seconds) mod 60; | |
return numberformat(local.hours, "0") & ":" & numberformat(local.minutes, "00") & ":" & numberformat(local.seconds, "00"); | |
} | |
</cfscript> | |
<cfoutput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
public any function getWeekOfMonth(date d='#Now()#', numeric minDaysInFirstWeek=1) { | |
var cal = CreateObject('java', 'java.util.GregorianCalendar').init( | |
JavaCast('int', Year(arguments.d)) | |
, JavaCast('int', Month(arguments.d)-1) | |
, JavaCast('int', Day(arguments.d)) | |
, JavaCast('int', Hour(arguments.d)) | |
, JavaCast('int', Minute(arguments.d)) | |
, JavaCast('int', Second(arguments.d)) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
public any function isoDateTimeFormat(date timestamp='#Now()#') { | |
var dt = DateConvert('local2utc', arguments.timestamp); | |
return DateFormat(dt, 'yyyy-mm-dd') & 'T' & TimeFormat(dt, 'HH:mm:ss.000') & 'Z'; | |
} | |
</cfscript> |