ColdFusion Language

10K

Solutions

3K

Contributors

ColdFusion is a server-side rapid application development platform originally created by Allaire and now sold by Adobe, implementing the dynamic general purpose CFML programming language. The term ColdFusion is sometimes colloquially used to refer to the CFML language (Cold Fusion Markup Language), but can also include discussions of the server software implementation. ColdFusion runs using a customised version of Apache Tomcat. Earlier versions are bundled with JRun.

Share tech news, updates, or what's on your mind.

Sign up to Post

I need to validate 2 form fields w/ similar criteria for each field but each needs to validate w/ an older set of criteria and a new one. Code below:

  <cfset errorMsg = ""> 
   	<cfif NOT refind("^[DdFfGgHhNnVv][A-Za-z0-9]{1,21}$", form.Contract_Number) AND NOT refind("^70[Zz]0[a-zA-Z0-9]{2}\d{2}[a-zA-Z][a-zA-Z0-9]{8}$", form.Contract_Number)>
	   <cfset errorMsg = "The Contract Number is required and can contain no more than 22 alphanumeric characters.,">
	</cfif>
	<cfset session.invoiceDataContr.errorString = errorMsg>

Open in new window


     <cfset errorMsg = "">     
   	<cfif NOT refind("^[Hh][Ss][Cc][Gg][A-Za-z0-9]{1,21}$|^$", form.Task_Order) AND NOT refind("^70[Zz]0[A-Za-z0-9]$", form.Task_Order)>
	   <cfset errorMsg = "The Delivery/Task Order Number must begin with HSCG with a maximum of 25 alphanumeric characters. Do not use hyphens or special characters. The
Delivery/Task Order Number can be found in block 4 of the SF-1449 form or in block 3 of the OF-347 form.,">
	</cfif>	
	<cfset session.invoiceDataContr.errorString = errorMsg>

Open in new window


Do I need 2 different cfset params? Not sure what's up. won't catch the second validation
0
Learn by Doing. Anytime. Anywhere.
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Hi, I have a dynamic CF page with  printout tables. Problem is with printing. Table printout can be split depending on the dynamic content. I need to force a new page for each table output. Is there a CF or html string I can use to force this break

many thanks
0
I have a very simple JSON feed and have been able to parse the feed using the below code. However, when the script gets to the "OFFERS" structure, it won't output the results cause it sees the brackets [ ] and is treating the data as a LIST of objects under OFFERS instead of objects like they would be under normal braces { }. I don't know how to get Coldfusion to properly give me the subitems of OFFERS.  You can easily see the feed using the link I provide also.

<cfoutput>
<cftry>
	<cfhttp url="https://rest.bandsintown.com/artists/spencerkane/events?app_id=day6mgmt&date=2017-08-19" result="httpResult" charset="utf-8" method="get"/>
 	<cfset BITdata = deserializeJSON(httpResult.filecontent)/>
	<cfloop array="#BITdata#" index="post">
		<cfif StructKeyExists(post, "datetime")>
			<cfset event_date = post.datetime>
		<cfelse>
			<cfset event_date = "">
		</cfif>
		<cfif StructKeyExists(post, "venue") and StructKeyExists(post.venue, "name")>
		    <cfset ev_title = post.venue.name>
		<cfelse>
            <cfset ev_title = "">
		</cfif>
		<cfif StructKeyExists(post, "venue") and StructKeyExists(post.venue, "city")>
			<cfset city = post.venue.city>
		<cfelse>
			<cfset city = "">
		</cfif>
		<cfif StructKeyExists(post, "venue") and StructKeyExists(post.venue, "region")>
			<cfset region = post.venue.region>
		<cfelse>
			<cfset region = "">
		</cfif>
		<cfif StructKeyExists(post, "offers[url]")>
		<cfset tickets = post.offers[url]>
			<cfelse>
		<cfset tickets = "">
		

Open in new window

0
Hi,

Am newbie to ColdFusion Please tell me code for login process am so confused for that can't get understand login process in my analysis.

Am tried below code,

My Form Code like,

  <!DOCTYPE html>
<html>
<head>
<title>Login</title>
Please Log In
</head>
<body>
    <cfform  name="LoginForm" action="" method="Post">
    <table>
    <tr>
    <td>Username:</td>
    <td><cfinput type="text" name="username" size="20" maxlength="30" required="yes" validate="maxlength,required" message="The Username must be between 1 and 30 characters."><br></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><cfinput type="password" name="password" required="yes" pattern="^[a-zA-Z0-9._]{8,16}$" maxlength="35" validate="required,regex" message="The Password must be between 8 and 16 characters."><br></td>
    </tr>
    </table>
    <br>
    <cfinput type="Submit" name="SubmitLoginForm" value="Submit">       
    </cfform>
      </body>
</html>

Am checking  username and password in below code,

<cfif isdefined("form.SubmitLoginForm")>
      <cfquery name="getpassword" datasource="testcf">
      select username, salt, password ,id from user where username = "#form.username#"
      </cfquery>      
      <cfif getpassword.RecordCount EQ 1>
      <cfset passwordHash = Hash(form.password & getpassword.salt, 'SHA-512') />
      <cfoutput>
      #getpassword.id#
      </cfoutput>
      <cfif getpassword.password EQ passwordHash>      
      
      <cfset session.allowin = "True">
      <cfset userid = '#getpassword.id#'/>
      <cfset…
0
Hello.

I would like to be able to browse C: \ wwwroot at http: // localhost: 8500 / test.
This is displayed as it is actually accessed.

” the page you are trying to access cannot be displayed.
please try again or notify the administrator ”

Using IIS, the physical path is set to C: \ wwwroot.
Check and set index.cfm in the default document

I'm using
windows server 2012 R2
IIS 8.5
ColdFusion 2016

I am a beginner. Please give me advice on which other setting to do.
0
<cfoutput>
<cftry>
	<cfhttp url="https://rest.bandsintown.com/artists/spencerkane/events?app_id=day6mgmt&start_date=2017-01-01" result="httpResult" charset="utf-8" method="get"/>
 	<cfset BITdata = deserializeJSON(httpResult.filecontent)/>
	<cfloop array="#BITdata#" index="post">
		<cfif StructKeyExists(post, "datetime")>
			<cfset event_date = post.datetime>
		<cfelse>
			<cfset event_date = "">
		</cfif>
		<cfif StructKeyExists(post, "venue.name")>
		    <cfset ev_title = post.venue.name>
		<cfelse>
            <cfset ev_title = "">
		</cfif>
		<cfif StructKeyExists(post, "venue.city")>
			<cfset city = post.venue.city>
		<cfelse>
			<cfset city = "">
		</cfif>
		<cfif StructKeyExists(post, "venue.region")>
			<cfset region = post.venue.region>
		<cfelse>
			<cfset region = "">
		</cfif>
		<cfif StructKeyExists(post, "offers.url")>
		<cfset tickets = post.offers.url>
			<cfelse>
		<cfset tickets = "">
			</cfif>

<!--- FEED OUTPUT --->        
<cfif not event_date is "">		
#event_date#<p>
#ev_title#<p>
#city#<p>
#region#<p>
#tickets#
<hr />
</cfif>		
	</cfloop>

	<cfcatch type="any">
		<p>
			<cfdump var="#cfcatch#" />
			#LSDateFormat(Now(), "dd-mm-yyyy")# #lsTimeFormat(Now(), "HH:mm")#<br />
			<a href="##">
				Oh, sorry... I can't connect to Bandsintown
			</a>
		</p>
	</cfcatch>

</cftry>
</cfoutput>

Open in new window


My output only gives me the datetime and none of the other structure data even though the raw feed in a browser window definitely shows there is more data to be displayed. I am using Adobe's output structure of data.struct1.substruct but it doesn't display anything.
0
Hello Experts,

I am working on a CF application and need a CF function equivalent to exit(); (PHP).

I am trying to addess this particular fix
Acunetix reference

This is what I am doing, but not sure if t works.  

<cfset GetPageContext().getCFOutput().clear()>
   <CFLOCATION URL="Login.cfm?Message=Logon ID must be 5 digits." ADDTOKEN="no">
	<CFABORT>

Open in new window


- Dan
0
I have courses for agents to study online.  I have a save and exit button when clicked will save their place and close the window.  However, if the student just clicks on the X on their browser and closes the window my system does not currently recognize that they are no longer active in the course.  We tried "onbeforeunload" but that gets triggered if the student is just going to the next page.  I only want to trigger it if they click to close the browser using the X.
0
I have a form that is completed online that now needs to be generated as a saved pdf file in a folder on the server. The name and location for the pdf would then be emailed to someone for them to retrieve for viewing. As an aside, would also need to know best way to have a signature placed into the pdf when created (I realize this is 2 questions in 1. 1st one more important for now)
0
I have a JSON feed which dumps a Facebook Page timeline feed. For some reason, Facebook allows a linked URL to be part of the actual message that is sent via JSON. So if I had a FB post that included a link to a Youtube video, it comes through the JSON feed like

'check out my cool new video http://www.youtube.com/myvideoid'

I'd prefer to strip out the url string from the JSON result and have it just give me

'check out my cool new video'

I know this has something to do with ReFindNoCase() or another similar thing, but I don't know how to write the code to strip it out and just leave me the message without the long url string.
0
Understanding Linux Permissions
Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Currently we are migrating from coldfusion 6 to coldfusion 2016.

<cfloop index="RSG004_i" from="1" to="#RSG004_dt.num#" step="1">

I want you to tell me how to deal with this error.
Thank you.
0
Hi,

Am using ColdFusion version 8,

Am export my Db recordset datas using,

<cfsavecontent variable="report">XXXXX</cfsavecontent>

<cffile action="write"  file = "#fullfile#" output="#report#" nameconflict="overwrite">

It's export fine,but I need to expand excel column width.Please Refer my attachment , I got my excel output like my attachment.file:///tmp/mozilla_geetha2/Employee_Report-3.xls
0
Hi, Here is the code i am trying to convert PHP code in ColdFusion code

Here is the code i have
public static function calculateSignature($consumerId, $privateKey, $requestUrl, $requestMethod, $timestamp=null)
    {
        if(is_null($timestamp) || !is_numeric($timestamp)){
            $timestamp = self::getMilliseconds();
        }
        /**
         * Append values into string for signing
         */
        $message = $consumerId."\n".$requestUrl."\n".strtoupper($requestMethod)."\n".$timestamp."\n";
        /**
         * Get RSA object for signing
         */
        $rsa = new RSA();
        $decodedPrivateKey = base64_decode($privateKey);
        $rsa->setPrivateKeyFormat(RSA::PRIVATE_FORMAT_PKCS8);
        $rsa->setPublicKeyFormat(RSA::PRIVATE_FORMAT_PKCS8);
        /**
         * Load private key
         */
        if($rsa->loadKey($decodedPrivateKey,RSA::PRIVATE_FORMAT_PKCS8)){
            /**
             * Make sure we use SHA256 for signing
             */
            $rsa->setHash('sha256');
            $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);
            $signed = $rsa->sign($message);
            /**
             * Return Base64 Encode generated signature
             */
            return base64_encode($signed);
        } else {
            throw new \Exception("Unable to load private key", 1446780146);
        }
    }

Open in new window


I have been able to get the milliseconds using the java code which is like below

<cfset jDate = createObject("java", "java.util.Date")>
<cfdump var="#jDate.getTime()#">

Open in new window



but other part of the php code i am unclear of what is happening
0
We are looking to upgrade our coldfusion server (v 6.1) running server (2003) to a new server (server 2012) and ColdFusion 2016.

Looking for a solution/upgrade path.. If I need to upgrade first to a lower version.

If its not semi simple then possibly moving to another dev language.

Thanks in advance!
0
After upgrading to Coldfusion 16 some of the functions with my grids do not work.

I use the below code to open records on double click in the grid, and to put a total count in the grid. Neither is working and when I visit the page the debugger says carGrid is undefined. Can anyone assist?

	<script>			
		function initMyGrid(){
			carGrid = ColdFusion.Grid.getGridObject('myGrid');
			carGrid.on('dblclick', openCarRecord);	
		}
	
		function openCarRecord(){
			var recID= ColdFusion.getElementValue('frmGrid','myGrid','#varIDNumber#');
			var url = '#recordPage#?myKEY='+recID;
			location.href = url;
		}
		
	    var gridRender = function(){
		carGrid = ColdFusion.Grid.getGridObject('myGrid');
	        carGrid.store.on('load', function( ds ) {
	        carGrid.setTitle('Total records: '+ carGrid.store.getTotalCount());
	        }); 
	    };   
	</script>

Open in new window

0
I have the code below trying to use cfif and cfelseif to validate on form field, which is for a contract number. I need to use one form field but validate w/ 3 different sets of criteria using 3 different sets of regex validations. Its currently not working and I'm sure the syntax I'm using is off. I'm new to CF much less using cfelseif but I believe I'm on the right track...can anyone provide some suggestions on how to rework this please?

thanks in advance...see code below:
<cftry>
  
   <cfif>
    <cfparam name="form.Contract_Number" pattern="^[DdFfGgHhNnVv][A-Za-z0-9]{1,21}$" type="regex" default="#form.Contract_Number#">
    <cfcatch>
		<cfset #session.invoiceDataContr.errorString# = #session.invoiceDataContr.errorString#&"The USCG Contract Number is required and can contain no more than 22 alphanumeric characters,">
    </cfcatch>
      
       <cfelseif>
       
       <cfparam name="form.Contract_Number_Z" pattern="^70Z0\d{4}[CDF]\d{8}$" type="regex" default="#form.Contract_Number_Z#">
       <cfcatch>
		<cfset #session.invoiceDataContr.errorString# = #session.invoiceDataContr.errorString#&"The TSA Contract Number is required and can contain no more than 22 alphanumeric characters,">
       </cfcatch>
        
         <cfelseif> 
                     
        <cfparam name="form.Contract_Number_T" pattern="^70T0\d{4}[CDF]\d{8}$" type="regex" default="#form.Contract_Number_T#">
        <cfcatch>
		<cfset #session.invoiceDataContr.errorString# = 

Open in new window

0
Good Afternoon, I would like to get some assistance with something I'm trying to do. I have a query that queries a table and gets various project information from that table, and it works fine. I have another table that has many comments about each project, so I have a one to many situation. My problem is that all UI want to retrieve from that second table is the last comment entered. I store the date of the last comment so I thought I would be able to do some sort of retrieval with a max date but not sure how to go about it. Ultimately I'm building a spreadsheet so the query is being built to populate the spreadsheet. Everything works fine till I had the 'proj_reason_closed' field. That the field that has many entries for each project.

SELECT DISTINCT proj_no,
spl,
capces_location,
capces_state,
capces_description,
maxdate,
proj_closed_reason,
ob_date_sort

FROM  (SELECT DISTINCT

       current_bulk_filter.proj_no,
       current_bulk_filter.capces_location,
       current_bulk_filter.capces_description,
       current_bulk_filter.capces_state,
       current_bulk_filter.spl,
       capces_support_data.ob_date_sort,
       spend_plan_history.proj_closed_reason,
       x2.maxdate

      FROM   mca.current_bulk_filter

left join mca.spend_plan_history
        ON ( current_bulk_filter.proj_no = spend_plan_history.proj_no and
             )

WHERE ......
0
is it possible to set up a regex to validate each position in a string of characters in a form field?

I have a requirement for a contract number field in a Cold Fusion form. Requirements are:

•      Positions 1-6 will be the  70Z0XX where XX is the contracting office code IE: 23.
•      Positions 7-8 will be the two digit Fiscal Year IE: 17.
•      Position 9 will be the one character instrument code IE: C, D, F.
•      Positions 10-17 will be agency assigned number.
•      New Example: 70Z02317D00000001

Is it possible to set up an expression at different points w/in the string of characters? I've never done that...only length requirements and forcing it to start w/ either a number or a letter. thanks for any help.
0
I want to keep cookies alive even after restarting Coldfusion on the server each morning.  Screen-Shot-2017-06-21-at-8.51.25-AM.pngI am attaching the settings from Coldfusion.

Thanks for your help
0
Get HTML5 Certified
LVL 9
Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

I have one form field with a Cold Fusion form that is requiring 2 different sets of criteria for validation....can this be done?

I have 2 sets of criteria for a contract number field w/in a CF form field. One is requiring the contract number to begin with a numeric character the other alphanumeric. I currently have the one set that needs to start w/ a letter but need to add the validation using a regex to the same form field to trigger the field to validate for the additional set of criteria that requires the new contract number configuration to begin with a number.

Current setup for the validation is:

			, Contract_Number: {
				required: true
			   ,pattern: /^[DdFfGgHhNnVv][A-Za-z0-9]{1,21}$/

Open in new window


Form field setup:

                        	<font face="Arial" size="2" color="#990000">
                            <label for="Contract_Number">Contract Number:&nbsp;</label>
							 <input type="text" name="Contract_Number" id="Contract_Number" minlength="8"  maxlength="22" tabindex="7" value="<cfif structkeyexists(session.invoiceDataContr, "PASS")><cfoutput>#session.invoiceDataContr.Contract_Number#</cfoutput><cfelse><cfoutput>#form.Contract_Number#</cfoutput></cfif>" required/>
                        	<font size="1" color="navy" title="No hyphens or special characters, OF-347 block 2, SF-26 block 2, SF-1442 block 4, SF-1449 block 2, SF-33 block 2">(help)</font></font>

Open in new window


Is there a way to use a hidden field maybe? I'm not sure its even possible to do. This will need to use jquery for client but also needs server side validation as well.

I'm thinking I can use as try catch and w/in that use a cfif/cfelse setup:


Open in new window

0
hi, i have the following json Code:

{"WhoisRecord": { "createdDate": "1997-09-15T00:00:00-0700", "updatedDate": "2015-06-12T10:38:52-0700", "expiresDate": "2020-09-13T21:00:00-0700", "registrant": { "name": "Dns Admin", "organization": "Google Inc.", "street1": "Please contact contact-admin@google.com, 1600 Amphitheatre Parkway", "city": "Mountain View", "state": "CA", "postalCode": "94043", "country": "UNITED STATES", "email": "dns-admin@google.com", "telephone": "16502530000", "fax": "16506188571", "rawText": "Registrant Name: Dns Admin\u000aRegistrant Organization: Google Inc.\u000aRegistrant Street: Please contact contact-admin@google.com, 1600 Amphitheatre Parkway\u000aRegistrant City: Mountain View\u000aRegistrant State/Province: CA\u000aRegistrant Postal Code: 94043\u000aRegistrant Country: US\u000aRegistrant Phone: +1.6502530000\u000aRegistrant Fax: +1.6506188571\u000aRegistrant Email: dns-admin@google.com" }, "administrativeContact": { "name": "DNS Admin", "organization": "Google Inc.", "street1": "1600 Amphitheatre Parkway", "city": "Mountain View", "state": "CA", "postalCode": "94043", "country": "UNITED STATES", "email": "dns-admin@google.com", "telephone": "16506234000", "fax": "16506188571", "rawText": "Admin Name: DNS Admin\u000aAdmin Organization: Google Inc.\u000aAdmin Street: 1600 Amphitheatre Parkway\u000aAdmin City: Mountain View\u000aAdmin State/Province: CA\u000aAdmin Postal Code: 94043\u000aAdmin Country: US\u000aAdmin Phone: 

Open in new window

0
Bootstrap validator trying to validate the form and submit to the database. The validation part works but it does not submit

the link is here https://jsfiddle.net/tsomik1/5cu96c6y/10/
0
I've been using  sys-con.com's code in my Application.cfc file to check for malicious input through FORM and URL variables, but I'm running into issues with hyphenated variable names (specifically Google's reCAPTCHA.) This is the code I use:

<cfloop collection="#form#" item="formelement">
    <cfif isSimpleValue(evaluate(formelement)) AND refindnocase(sqlregex, "#evaluate(formelement)#")>
        <cflocation url="messages.cfm?message=invalid">
        <cfset StructClear(form)>
	<cfabort>
    </cfif>
</cfloop>

Open in new window


And this is the error I'm receiving:

Variable G is undefined.

Which makes sense, because it's looking at g-recaptcha-response. What do I need to do to my code to allow it to accept hyphenated variable names?

Thanks!
0
I am trying to validate using remote options, but it is always validate as failed
<div class="row">
										<div class="col-sm-12 col-xs-12">
											<input type="text" name="userName" placeholder="Username" class="form-control input-lg" required="required" data-bv-remote="true"/>
										</div>
									</div>

Open in new window

 userName: {
                message: 'The username is not valid',
                validators: {
                    notEmpty: {
                        message: 'The username is required and can\'t be empty'
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: 'The username must be more than 6 and less than 30 characters long'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: 'The username can only consist of alphabetical, number, dot and underscore'
                    },

                    remote: {
	                    url: '/includes/website.cfc?method=checkusername',
	                    message: {
	                        en_US:  "This usenrame is already taken, please choose another one",
	                    },
	                    data: {
	                        type: 'userName'
	                    },
	                    type: 'POST',
	                    delay: 1000
	                }


                }
            },

Open in new window

<cffunction name="checkusername" output="true" returntype="any" access="remote" returnformat="JSON" >
          <cfargument name="username" required="true" type="string" />
          <!--- set the default value to false --->
          <cfset var emails = StructNew() />
          <cfset emails.valid = "false" />


          <!--- code to check email in system --->
          <cfquery name="findemail" datasource="#request.datasource#">
               select username
               from users
               where username = <cfqueryparam  value="#arguments.username#" cfsqltype="cf_sql_varchar" />
          </cfquery>
          <cfif findemail.RecordCount eq 0>
               <cfset emails.valid = "true" />
          </cfif>
          <cfoutput>#SerializeJSON(emails)#</cfoutput>
     </cffunction>

Open in new window

0
I am looking for a solution that uses CFSCRIPT to remove all text that is surrounded by '<style' and '/style>' including removing the style tags. Can someone show me how I can use something like ReReplaceNoCase to solve this.

For example: if I have text that looks like:

section a <style>here is style to remove</style>section b <style>more style to remove</style>section c

I need the function to return:
section a section b section c

Thank you.
0

ColdFusion Language

10K

Solutions

3K

Contributors

ColdFusion is a server-side rapid application development platform originally created by Allaire and now sold by Adobe, implementing the dynamic general purpose CFML programming language. The term ColdFusion is sometimes colloquially used to refer to the CFML language (Cold Fusion Markup Language), but can also include discussions of the server software implementation. ColdFusion runs using a customised version of Apache Tomcat. Earlier versions are bundled with JRun.