Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion

ColdFusion: Article

Ask the Training Staff

Ask the Training Staff

September means summer is over and we all get back to work or back to school.

And for those of us who have been out of school for a very long time, I hope you always look for opportunities to learn something new. Send me your questions if you get stuck!

Q:I have a CF Scheduler question: How do I schedule the execution of a template to run at 6 a.m. on weekdays (Mon-Fri) only? I know how to schedule it at 6 a.m. every day, but I don't want it to run on Saturday or Sunday. Any suggestions?
A:
Unfortunately, there's no way to get the CF Scheduler to do this for you (at least none that I'm aware of). There is, however, an easy way to accomplish this. Schedule the template to run at 6 a.m. every day, which you already know how to do, but put a CFIF block in your template to test for the day of the week. If the current day is a Saturday or Sunday, don't execute the code. The template is still executed by the scheduler, but none of the code executes on those days. Here's the code you need to wrap around the existing code in your page:

<CFIF DayOfWeek(Now()) gt 1 AND DayOfWeek(Now()) lt 7>
...this will only run Mon-Fri!
</CFIF>

Q: I want to assign a user a password using a randomly generated string of letters and numbers without repeating any characters. How can I do this?
A:
Great question. The solution is in the following code. Let's assume that the password will be eight characters long using both letters and numbers. First, assign a variable that contains all the possible characters (I like to omit the letters "L" and "O" because they're often confused with the numbers 1 and 0). Next, initialize your password to null. Then loop from 1 to 8. For each iteration of the loop, pick a random number between 1 and the length of your character list. Select the character from the list based on the random number and append it to the password. Last, delete that character from the list so it won't get picked again.

<CFSET charList =
"a,b,c,d,e,f,g,h,i,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9">
<CFSET Password = "">
<CFLOOP FROM="1" TO="8" INDEX="i">
<CFSET RandNum = RandRange(1,ListLen(charList))>
<CFSET Password = Password & ListGetAt(charList,RandNum)>
<CFSET charList = ListDeleteAt(charList,RandNum)>
</CFLOOP>
<CFDUMP VAR="#Password#">

Q: We recently received an e-mail from one of our customers explaining that attaching the following code (mode= debug) to the URL of a ColdFusion file (for example, listings.cfm? mode=debug) will reveal most, if not all, of our network information (IP address, server information, OS information, etc). Obviously, this is a potential security threat and has shaken us. What can we do about it?
A:
It's funny (ironic) that when this was first introduced (in version 4, I think), it was actually billed as a "feature"! Appending "?mode=debug" to the URL does reveal the execution time of a page and all of the Form, URL, and CGI variables that were available to the page when it was processed. At times when debugging an application it's helpful to a developer to get this info on-the-fly by applying this URL string. But, as you mention, it can be very dangerous to your site if a good hacker gets this information! Fortunately, you can prevent this from happening by placing one line of code in your Application.cfm file:

<CFSETTING SHOWDEBUGOUTPUT="No">

With this tag in Application. cfm, nobody (including yourself) will be able to see any of this debug information. When developing an application, I leave this setting set to "Yes," but when I put the application into production, I set it to "No."

*  *  *

Please send your questions about ColdFusion (CFML, CF Server, or CF Studio) to [email protected]. Please visit our archive site at www.NetsiteDynamics.com/AskCFDJ.

More Stories By Bruce Van Horn

Bruce Van Horn is president of Netsite Dynamics, LLC, a certified ColdFusion developer/instructor, and a member of the CFDJ International Advisory Board.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
shane schmidt 09/08/02 07:35:00 PM EDT

As a very new-comer to coldfusion, I am perplexed with their variables. To build a user defined database query based upon variables passed, I have cut my code into 3 forms. I can pass form variables A to form B and form variables B to form C . However I cannot pass form variables A to C.

Can you assist ?

IoT & Smart Cities Stories
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...
Machine learning has taken residence at our cities' cores and now we can finally have "smart cities." Cities are a collection of buildings made to provide the structure and safety necessary for people to function, create and survive. Buildings are a pool of ever-changing performance data from large automated systems such as heating and cooling to the people that live and work within them. Through machine learning, buildings can optimize performance, reduce costs, and improve occupant comfort by ...
The explosion of new web/cloud/IoT-based applications and the data they generate are transforming our world right before our eyes. In this rush to adopt these new technologies, organizations are often ignoring fundamental questions concerning who owns the data and failing to ask for permission to conduct invasive surveillance of their customers. Organizations that are not transparent about how their systems gather data telemetry without offering shared data ownership risk product rejection, regu...
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.
Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As automation and artificial intelligence (AI) power solution development and delivery, many businesses need to build backend cloud capabilities. Well-poised organizations, marketing smart devices with AI and BlockChain capabilities prepare to refine compliance and regulatory capabilities in 2018. Volumes of health, financial, technical and privacy data, along with tightening compliance requirements by...
Predicting the future has never been more challenging - not because of the lack of data but because of the flood of ungoverned and risk laden information. Microsoft states that 2.5 exabytes of data are created every day. Expectations and reliance on data are being pushed to the limits, as demands around hybrid options continue to grow.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
As IoT continues to increase momentum, so does the associated risk. Secure Device Lifecycle Management (DLM) is ranked as one of the most important technology areas of IoT. Driving this trend is the realization that secure support for IoT devices provides companies the ability to deliver high-quality, reliable, secure offerings faster, create new revenue streams, and reduce support costs, all while building a competitive advantage in their markets. In this session, we will use customer use cases...