BlogCFC on restricted shared hosting
A recent entry on Ray's forums questioned running BlogCFC on a hosting service that restricted access to createObject. I run this blog on GoDaddy and they basically let you use cfset and cfoutput, well maybe not that bad but you get the idea.
The createObject calls for the components need to be changed to cfinvoke like this:
becomes
<cfinvoke component="org.camden.blog.blog" method="init" returnvariable="application.blog">
<cfinvokeargument name="name" value="#blogname#">
</cfinvoke>
There are several of those changes needed in application.cfm, blog.cfc, and utils.cfc. The changes for application.cfm:
<cfinvoke component="org.camden.blog.blog" method="init" returnvariable="application.blog">
<cfinvokeargument name="name" value="#blogname#">
</cfinvoke>
<!--- Locale related --->
<cfinvoke component="org.hastings.locale.resourcebundle" method="init" returnvariable="application.resourceBundle"> </cfinvoke>
<cfinvoke component="org.hastings.locale.utils" method="init" returnvariable="application.localeutils"> </cfinvoke>
<!--- load slideshow --->
<cfinvoke component="org.camden.blog.slideshow" method="init" returnvariable="application.slideshow">
<cfinvokeargument name="dir" value="#slideshowdir#">
</cfinvoke>
<cfif application.usecaptcha>
<cfinvoke component="org.captcha.captchaService" method="init" returnvariable="application.captcha">
<cfinvokeargument name="configFile" value="#lylafile#">
</cfinvoke>
<cfset application.captcha.setup() />
</cfif>
<!--- Load the Utils CFC --->
<cfinvoke component="org.camden.blog.utils" method="init" returnvariable="application.utils"> </cfinvoke>
<!--- Load the Page CFC --->
<cfinvoke component="org.camden.blog.page" method="init" returnvariable="application.page">
<cfinvokeargument name="dsn" value="#application.blog.getProperty("dsn")#">
<cfinvokeargument name="username" value="#application.blog.getProperty("username")#">
<cfinvokeargument name="password" value="#application.blog.getProperty("password")#">
<cfinvokeargument name="blog" value="#blogname#">
</cfinvoke>
<!--- Load the TB CFC --->
<cfinvoke component="org.camden.blog.textblock" method="init" returnvariable="application.textblock">
<cfinvokeargument name="dsn" value="#application.blog.getProperty("dsn")#">
<cfinvokeargument name="username" value="#application.blog.getProperty("username")#">
<cfinvokeargument name="password" value="#application.blog.getProperty("password")#">
<cfinvokeargument name="blog" value="#blogname#">
</cfinvoke>
The uber blog.cfc file has a couple of createObjects listed in it for utils, ping, textblocks and render. I couldn't get the invokes for those to work right until I added an init function to each one of them. Anyone out there have a easier way to do this?
<cfreturn "blogCFC">
</cffunction>
hastings/locale
For the locale/utils.cfm, it does a lot of java calls for the localization code. At the risk of getting slaughtered, I didn't need that so I removed most of the java calls and hard-coded the formatting that I needed.Such as:
hint="Returns an array of locales.">
<cfreturn "US">
</cffunction>
Printing
Add fontembed="false" to line 22 of print.cfmFile uploading
To get around this error: access denied java.io.FilePermission, you need to turn off encoding for the form variables. I turned it off on all pages with form fields, you might want to just list the form fields you want to turn it off on.<cfset setEncoding("form","utf-8")>
<cfset setEncoding("url","utf-8")>
</cfif>
This covers the changes needed to get BlogCFC running on a restricted hosting server. If you have other experiences with changes need for certain hosting companies, add them to the comments or visit Ray's BlogCFC Forums to help give back to the growing CF open-source community. I have also heard that Ray has a wishlist....
