Cf.Objective()

BlogCFC on restricted shared hosting

Comments (19) || ColdFusion 3199 Views

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:

<cfset application.blog = createObject("component","org.camden.blog.blog").init(blogname)>

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:

<!--- load and init blog --->
   <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?

<cffunction name="init" access="public" returnType="any" output="false">
<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:

<cffunction name="getAvailableLocales" access="public" returnType="array" output="false"
            hint="Returns an array of locales.">

   <cfreturn "US">
</cffunction>

Printing

Add fontembed="false" to line 22 of print.cfm
<cfdocument format="pdf" fontembed="false">

File 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.

<cfif not structKeyExists(form,"fieldnames")>
   <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....


Related Blog Entries


Comments

  1. Yep that's pretty much how you do it, a good write up. I'm interested to hear how you manage/merge the ongoing updates to BlogCFC with the required GoDaddy modifications. Cheers.

  2. I made the changes here, but when I load up my site, I get an error from line 56 of blog.cfc saying "method configParam was not found". Do you have any idea what that's all about?

  3. yeah - check blog.cfc and make sure the createobjects are changed to cfinvokes.
    <!--- Load utils immidiately. --->
    <cfinvoke component="utils" method="init" returnvariable="variables.utils">   </cfinvoke>

  4. For anyone that is looking for GoDaddy answers, there's also a fairly massive thread running on Sean Corfield's blog: http://corfield.org/entry/GoDaddy_and_ColdFusion_M....

  5. Sorry the link had a typo, it's http://corfield.org/entry/GoDaddy_and_ColdFusion_M...

  6. Dang, really sorry for the Spam. Scott, feel free to cull my rambling.

  7. What do your init methods look like in the locale cfcs? I don't see any in my blogcfc disto.

  8. Nothing fancy

       <cffunction name="init" access="public" returnType="any" output="false">
          <cfargument name="dsn" type="string" required="false" default="e">
          <cfset variables.dsn = arguments.dsn>
          <cfreturn this>
       </cffunction>

  9. I hate to be a weenie. BUt could you post or email me the files that you have changed to get blogcfc working wihtout createobject?

    I'm a newbbie to using cfinvoke and I can't get the code working on the blog.cfc page.

    IF you could post the changes here like you did fo rthe application.cfm, for the other pages, that'd be great.

  10. Scott, Thanks for sharing your advice and solution to the GoDaddy <CF Create Headache> Tag...from what I have read on the web, they have definitely done a good job in frustrating CF developers.
    I too am trying to find a copy and paste method to hacking Ray Camdens BlogCFC, to work on GoDaddy, as norm requested. I do not quite have the CF skills to rewrite the code without training wheels....

  11. Edward, it's not worth it. It will drive you mad. I suggest an alternate host.

  12. I'm running into the same issue as tacShooter. I checked through blog.cfc and made sure I didn't have any references to createObject.

    If you have any other ideas, I'm all ears.

    Also, thanks for the great post.

  13. Has anybody been able to get this working on GoDaddy other than Scott?

  14. Yep, definitely.

  15. Well I switched to a host with much less restrictions for CF ... problem is now I can't seem to connect to an external DSN. From line two [2] in blog.ini.cfm ... I have my database setup on an external MSSQL 2005 DB server where my DSN is "Foo" How can I add a connection string to dsn="?" in order to connect?

  16. Could you please let me know which hosting provider have you shifted?

  17. Yeah Nicky - sorry for the lack of consideration &lt;?&gt; I am currently with HostMySite and I am happy to say that their customer service has been superb thus far. (Sorry for the plug Scott) They promptly helped me to configure the DSN after sending them a ticket ... My previous host, (take a guess) basically laughed when I asked them for assistance with well...anything. Goodbye Old Host.

  18. Thanks Edward for you reply.

    I am looking for a cheap CF Hosting company for my personal site. I Googled for that and came across http://www.hostingatoz.com . Does anybody has any exp. with them? The CF hosting prices are looking cool and too temptating but would love to hear if anybody having any exp. with them.

  19. I am looking for a cheap CF Hosting company for my personal site. I Googled for that and came across www.hostingatoz.com . Does anybody has any exp. with them? The CF hosting prices are looking cool and too temptating but would love to hear if anybody having any exp. with them.
    try this site http://healthguardian.org

© 2007 Scott Pinkston, LLC || Design by N.Design Studio || Powered by BlogCFC || Entries RSS || Login