‘coldfusion’ Archive

ColdFusion Leap Year Fun

9 March 2008 15:18

So just an update on this. I sent off some emails to folks at Adobe and have had acknowledgment but as yet no reply. I’ll you know if and when I get something back.

Filed: Technology // Tagged: , , // No Comments

Coldfusion possible Leap Year bug

28 February 2008 10:11

My colleague noticed that as of midnight GMT one of our applications at work broke. After some digging it looks like a CF leap year bug.

<cfset attributes.minage = 18>
<cfoutput>
#now()#<br />
#attributes.minage#<br />
#dateadd("yyyy", -(attributes.minage), now())#<br />
#datediff("yyyy", dateadd("yyyy", -(attributes.minage), now()), now())#<br />
#datediff("yyyy", dateadd("yyyy", -(attributes.minage), now()), DateAdd("d", 1, now()))#
</cfoutput>

The code was run on CF 7.0.1, 7.0.2 & 8.0.0 on Windows and Linux, all produce same results.

Not sure for definite it’s a bug, but, it’s always worked until today, in theory it might work again tomorrow as well. Last leap year of course was CF6 so may not have shown up.

Yay for dateDiff()… :|

Update

A more detailed example. It only effects the 28/2. Other dates fine suggesting more that it’s leap year related.

<cfoutput>
	<cfset variables.datea = createDate(2008,02,3)>
	<cfloop from="2008" to="1990" step="-1" index="variables.y">
		<cfset variables.dateb = createDate(variables.y,02,3)>
		<cfset variables.diff = datediff("yyyy", variables.datea, variables.dateb)>
		#variables.datea# - #variables.dateb# = #variables.diff#<br />
	</cfloop>
</cfoutput>

And it’s output….

{ts '2008-02-28 00:00:00'} - {ts '2008-02-28 00:00:00'} = 0
{ts '2008-02-28 00:00:00'} - {ts '2007-02-28 00:00:00'} = 0
{ts '2008-02-28 00:00:00'} - {ts '2006-02-28 00:00:00'} = -1
{ts '2008-02-28 00:00:00'} - {ts '2005-02-28 00:00:00'} = -2
{ts '2008-02-28 00:00:00'} - {ts '2004-02-28 00:00:00'} = -4
{ts '2008-02-28 00:00:00'} - {ts '2003-02-28 00:00:00'} = -4
{ts '2008-02-28 00:00:00'} - {ts '2002-02-28 00:00:00'} = -5
{ts '2008-02-28 00:00:00'} - {ts '2001-02-28 00:00:00'} = -6
{ts '2008-02-28 00:00:00'} - {ts '2000-02-28 00:00:00'} = -8
{ts '2008-02-28 00:00:00'} - {ts '1999-02-28 00:00:00'} = -8
{ts '2008-02-28 00:00:00'} - {ts '1998-02-28 00:00:00'} = -9
{ts '2008-02-28 00:00:00'} - {ts '1997-02-28 00:00:00'} = -10
{ts '2008-02-28 00:00:00'} - {ts '1996-02-28 00:00:00'} = -12
{ts '2008-02-28 00:00:00'} - {ts '1995-02-28 00:00:00'} = -12
{ts '2008-02-28 00:00:00'} - {ts '1994-02-28 00:00:00'} = -13
{ts '2008-02-28 00:00:00'} - {ts '1993-02-28 00:00:00'} = -14
{ts '2008-02-28 00:00:00'} - {ts '1992-02-28 00:00:00'} = -16
{ts '2008-02-28 00:00:00'} - {ts '1991-02-28 00:00:00'} = -16
{ts '2008-02-28 00:00:00'} - {ts '1990-02-28 00:00:00'} = -17

Filed: Technology // Tagged: , , // No Comments

Calling the Mailbuild API from CF

4 December 2007 15:42

Had to help with someone out today who was trying to call the Mailbuild API from ColdFusion. It’s a webservice and was proving a little annoying to get going, but after a bit of playing the final code looks like this.

<cfscript>
params = structNew();
params.ApiKey = '{yourkey}';
params.ListID = '{yourlistid}';
params.Email = 'name@domain.com';
params.Name = 'Name';
</cfscript>

<cfinvoke webservice="http://{company}.createsend.com/api/api.asmx?wsdl"
method="AddSubscriber"
parameters = "#params#">

This is adding a new subscriber to a given list. Hopefully this might help someone integrating with CF!

Filed: Technology // Tagged: , , // No Comments

ColdFusion 64bit and Leopard Beta

22 November 2007 9:10

Slow to the game on this but been busy working! If you want to get in on the 64bit / Leopard beta check out Kristen’s blog.

Filed: Technology // Tagged: , , , , // No Comments

Deploying CF7 on JRun with CF8 on Leopard, Single IP Error

10 November 2007 14:23

Having got ColdFusion 8 running in multi-server mode on Leopard I decided to try and deploy CF7 to it as well. Started out going well, following the same process I’ve always used. I created a new server, removed the default-ear, started the proxy service and stopped the web service then dropped in the cf7 ear file. Setup all the apache2 config and restarted that OK. For reference I’ve got a jrun.conf with the module in then a cf702.conf included by default with the jrun.conf in httpd.conf then a cf8.conf I include in vhosts as needed. The server started OK but when I tried browsing the cf7.local vhost I created I was shown the message:

500
java.lang.NullPointerException
at coldfusion.license.LicenseManager._isSingleIP(LicenseManager.java:171)
at coldfusion.license.LicenseManager.isSingleIP(LicenseManager.java:68)
at coldfusion.CfmServlet.getFilterChain(CfmServlet.java:66)
at coldfusion.CfmServlet.service(CfmServlet.java:103)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Interesting as it’s the same box, both configured on 127.0.0.1. A reload didn’t cure it, so off to google. I found a couple of posts relating to flash remoting. The first one was over on <a href=”http://www.talkingtree.com/blog/index.cfm/2004/9/15/flashgateway”>Steven Erat’s</a> blog from way back in 2004 related to something with flash remoting. I found a few other posts saying I’d need to remove the flash remoting ear file, which, I didn’t have showing in the JMC.

I decided to take a look in the JRun4 directory to see what flash related files there were:

macmini:JRun4 ianwinter$ find . -name "*flash*"
./docs/jmchelp/gs-flash-jrun.htm
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/CFIDE/administrator/images/flashmenu.swf
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfform/flash-unicode-table.xml
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashgateway.jar
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashremoting_update.jar
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfform/flash-unicode-table.xml
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/flashgateway.jar
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/preso/loadflash.js
./servers/samples/flashsamples-ear
./servers/samples/flashsamples-ear/ejbs/flashgateway
./servers/samples/SERVER-INF/classes/flashgateway

Some of these obviously can stay but as I don’t use flash remoting I decided to remove the flashgateway.jar and flashremoting-update.jar files. I backed up the servers directory as well first and have at this point stopped the servers.

macmini:JRun4 ianwinter$ sudo rm
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashgateway.jar
./servers/cf702/SERVER-INF/temp/cfusion.war-1439562941/WEB-INF/cfusion/lib/flashremoting_update.jar
./servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/flashgateway.jar

Restart all the JRun servers and browse back to cf7.local and voila it works. Bit of a faf and no good if you want flash remoting but it works. I don’t know if you remove just one of the flash remoting jar’s, like just from the cf7 server if it’d work, or, perhaps you can change mappings somewhere, solves my problem so I’m happy.

Filed: Technology // Tagged: , , , , // No Comments

Lingon for Leopard and starting JRun servers

10 November 2007 14:22

I still can’t get CF8 to start correctly on Leopard so having used Lingon previously on Tiger I downloaded the latest version from SourceForge. It’s been redesigned for Leopard as version 2.0.1 and looks really nice.

Configuration is easy, just add in a name, I choose com.adobe.jrunStartCfusion. In the “what” box just stick in “/Applications/JRun4/bin/jrun -start cfusion” and I only choose “Run it when it is loaded by the system (at startup or login)”. Once you’ve got that in hit save, reboot (I think logout would work but hey) and you’re done. Do a quick “ps -ef | grep cfusion” and you should see your CF process.

Filed: Technology // Tagged: , , , // No Comments

ColdFusion Leopard & 64 bit hints

8 November 2007 8:37

Looks like Adobe could be announcing support for ColdFusion on Leopard and 64bit (other than Solaris) soon (hopefully). [via forta.com]

Filed: Technology // Tagged: , , , , // No Comments

ColdFusion 8 on Leopard part 2

31 October 2007 23:13

So, just got ColdFusion 8 working on my Mac Mini running an upgraded version of Leopard (from Tiger). Below are the steps I took. As I said before it’s basically Geoff’s guide with a couple more reboots!

1. Install Apple XCode Tools from Leopard DVD<br>
2. Restart<br>
3. Install ColdFusion 8<br>

Multi-server, developer edition
ColdFusion 8 Document and Start ColdFusion on system init both checked
Installed to /Applications/JRun4
Web Servers
- Apache
- Configuration Directory: /etc/apache2
- Server Binary: /usr/sbin/httpd
- Server Control Script: /usr/sbin/apachectl
CFIDE installed to default documents folder which is /Library/Webserver/Documents

4. Complete wizard ignoring web server startup and connector failure messages
5. Restart
6. Compile the new connector

cd /Applications/JRun4/lib
unzip -d src wsconfig.jar
cd src/connectors/src
apxs -c -Wc,-arch -Wc,x86_64 -Wl,-arch -Wl,x86_64 -n jrun22 mod_jrun22.c jrun_maptable_impl.c jrun_property.c jrun_session.c platform.c jrun_mutex.c jrun_proxy.c jrun_utils.c
apxs -i -n jrun22 -S LIBEXECDIR=/Applications/JRun4/lib/src/connectors/src/ mod_jrun22.la
strip mod_jrun22.so

7. Check the connector with wsconfig

cd /Applications/JRun4/lib/
sudo java -jar wsconfig.jar

8. Delete the current connector and put your fresh shiny new one in

rm /Applications/JRun4/lib/wsconfig/1/mod_jrun22.so
cp /Applications/JRun4/lib/src/connectors/src/mod_jrun22.so /Application/JRun4/lib/wsconfig/1/mod_jrun22.so

9. Restart<br>
10. Start CF<br>

sudo /Applications/JRun4/bin/jrun -start cfusion

11. Kick apache

sudo apachectl restart

12. Browse to localhost/CFIDE/administrator/index.cfm (unless you’ve already added index.cfm as a default doc)<br>
13. Go to bed feeling happy.

Filed: Technology // Tagged: , , , // 1 Comment

ColdFusion 8 install on Leopard

31 October 2007 13:28

Having read many articles and endured much swearing this morning I finally got CF8 running with apache 2.2.6 on Leopard with my Macbook.

For information it’s a Intel Core 2 Macbook which had a completely clean, erase and install version of Leopard on.

I’ve writing a guide to the steps I took for reference but I was following this guide by Geoff Bowers (thanks!) and also reading comments on Mark Drew’s post. Going to try on my Mac Mini tonight which is an upgraded version of Leopard from Tiger.

Filed: Technology // Tagged: , , , // No Comments

Alternative to Captcha, Sort Of

11 October 2007 22:47

I’ve seen a lot of Captcha (Completely Automated Public Turing Test to Tell Computers and Humans Apart) graphics on sites now-a-days, some of which are quite hard to read.

One alternative, and don’t get me wrong it’s not better because it’s still text however it will make it a bit harder for bots to spam you, is to ask a question and have the user give the answer.

In this example I’ll ask the question:

<blockquote>What is two added with four? Please enter the answer as a number.</blockquote>

Below is a very basic ColdFusion page with that example.

<!--- store the numbers as words in a list, could also been and array --->
<cfset numberWords = "one,two,three,four,five,six,seven,eight,nine,ten">
<!--- get two numbers --->
<cfset n1 = randrange(1,10)>
<cfset n2 = randrange(1,10)>
<!--- calculate the total --->
<cfset nt = n1 + n2>
<!--- hash that value so it can't be seen in the source --->
<cfset nh = hash(nt)>
<cfoutput>
What is #listGetAt(numberWords,n1)# added to #listGetAt(numberWords,n2)#?
</cfoutput>
<form name="frm" method="post" action="captcha.cfm">
<!--- store the hash value in the form --->
<input type="hidden" name="hashvalue" value="<cfoutput>#nh#</cfoutput>">
<input type="text" name="answer">
<input type="submit">
</form>
<!--- hash the user's answer and compare to the passed hashed value --->
<cfif isDefined("form.answer")>
<cfif hash(form.answer) neq form.hashvalue>
<p>Nope</p>
<cfelse>
<p>Yay!</p>
</cfif>
</cfif>

Hopefully that might help someone!

Filed: Technology // Tagged: , , // No Comments

 
What's ianteresting?   •   Twitter   •   About   •   Contact
©2012 Ian Winter. All Rights Reserved.   •   Powered by WordPress   •   Hosted at Memset