How do I use WordPress alongside CFWheels? - coldfusion

Anyone with a bit of experience with CFWheels will know how awesome it is, but also how fiddly it is with its placement in the web root / sub-folders etc.
I have a CFWheels website, that I would now like to place alongside a WordPress installation.
CFWheels placed in the web root (which is fine) and I would like WordPress to run in a sub-folder in that same web root named 'blog'. How can I do this without invoking CFWheels desire to find a controller or action called 'blog'?
I know that the 'miscellaneous' folder is a folder that I can place things that CFWheels will ignore, but putting the blog into this directory isn't really an option.
Any help or advice would be great.
EDIT: I just noticed that the miscellaneous folder has a blank Application.cfc file that stops CFWheels messing with it. I'm not around to test this right now, but will update later if it's possible to use this same technique on other folders I create. I may have answered my own question in record time.
Thanks,
Mikey.

Wordpress runs on PHP so CFWheels should never get involved in the process. If it does, simply change the DirectoryIndex (or IIS equivalent) to have index.php ahead of index.cfm for the Wordpress directory (or link to blog using full URL and not just the directory) and you should be fine.

Placing a blank Application.cfc file in the folder of choice, stops CFWheels getting involved with everything in it.

Related

Why is CreateObject with a dot-notation path to the component not working using CF Administrator Mappings that define the path to the CFC directory?

I am working on a web app already on the production server based on CF code that uses and depends on the CF Administrator Mappings to locate CFCs. I have a directory structure like this:
Webroot/
_TaskDir/
Application.cfm
myFile.cfm
CFC/
component1.cfc
...
app/
Application.cfm
index.cfm
...
My Mappings in CF Administrator has something like:
Logical Path: /myComponents
Directory Path: C:/Projects/Code/.../CFC/
Most of the app is under the app directory and uses calls to create objects all over the place like:
<cfset myCFCojb = CreateObject("component", "myComponents.component1").init()>
There are some scheduled task type scripts in another folder at the webroot (_TaskDir) that calls the CreateObject method in the same way as everywhere else, using the dot notation to specify the path to the components mapped directory. It supposedly has been working fine on production but for some unknown reason I am finding it doesn't work in this directory in my dev environment. The CreateObject works fine in the rest of my app, but when put into scripts in this folder it fails.
By fails, I mean i get a NullPointerException error. If I change the dot-notation path to a physical path (since both paths are within the webroot) such as CreateObject("component", "/CFC/component1").init() then it's fine. It's just the dot notation and mappings that seem to be ignored in just this directory.
Is this because this folder is outside the app directory which has the main Application.cfm and that _TaskDir has it's own Application.cfm? I would think the Mappings would work for either.
The first part of the stackTrace is:
java.lang.NullPointerException at
coldfusion.util.Utils.getDirectoryFromPath(Utils.java:350) at
coldfusion.runtime.TemplateProxyFactory.getTemplateFileHelper(TemplateProxyFactory.java:1638)
at
coldfusion.cfc.ComponentProxyFactory.getProxy(ComponentProxyFactory.java:51)
at coldfusion.runtime.CFPage.CreateObject(CFPage.java:6354) at
coldfusion.runtime.CFPage.CreateObject(CFPage.java:6373)...
I am using CF2016 in a Tomcat container.
I found the problem. Found out that the version of Tomcat (8.5.20) I am using as the container for my Apache server is now case sensitive. I ran 3 scripts from my _TaskDir directory specifying the URL with the wrong case (_Taskdir), first 2 ran fine. The 3rd was the one that was trying to run CreateObject using Administrator Mappings to find the CFC directory. The URL is apparently being used to comparie with the Mappings paths. With the wrong case being used in the URL is impacting the dot-notation path to the CFC directory. At least I know how to resolve this now.
If you can shed more light on how this case sensitive paths is impacting CF, I'd like to know more. If there is an article on this, please share.

Github Pages 404 for everything but index.html

I have a Github pages website for our team at http://olinaeromarketing.github.io/. I've tried opening index.html locally and it works perfectly in chrome on my pc. Everything loads perfect. However, when I push everything to Github and try to open it with http://olinaeromarketing.github.io/, everything except index.html gives a 404 error and can't load. I'm pretty stumped as to why this is happening. I also haven't been able to find anything on the web regarding this issue.
The repository is located at https://github.com/OlinAeroMarketing/OlinAeroMarketing.github.io. BTW, the website is currently a WIP and not yet finished.
By default, Jekyll is used to process GitHub Pages. Files/directories that begin with an underscore have special meaning for Jekyll and are, therefore, treated differently.
Since you don't seem to be using Jekyll, your simplest solution is to add a file named '.nojekyll' to the root path to disable Jekyll functionality.
Check out https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/ for more info.
Edit: Just to be clear, the offending directory is '_include'.

Media folder out of web server root hierarchy

I want to have an offline website (no intention to make it available outside the LAN), to handle several pictures in my user picture folder (and they have to stay where they are), but the thing is that I dont know if I can access them from WAMP, as it's outside the folder hierarchy.
Also thought about another solution that maybe exists some webserver for PHP, like what SQLite is for SQL, lightweight standalone program that doesn't need any installation, and that can be placed anywhere.
Thanks in advance,
any help would be very apreciated :)
There's a few ways to can go about this:
Use Mod_Rewrite to direct URLs from something like '/pictures' to the location of the pictures, see
http://httpd.apache.org/docs/2.4/rewrite/remapping.html
Change the document root of the apache server in httpd.conf to the location of the pictures (probably not what you want)
Add another virtual server to apache and set its document root to the location of the pictures
(again, probably not what you want but thought I'd suggest it)
Add a symbolic link, not quite sure how it would work (if at all) in Windows but again, something you can look at

coldfusion application.cfm and affected files

If I have a site where there is a protected back end and I'm looking to use an application.cfm file, how can I tell which pages use the application filesa and which ones do not.
index.cfm
update/application.cfm
update/loginexpired.cfm
update/login.cfm
update/somesecurepage.cfm
update/someothersecurepage.cfm
I want updates/login.cfm to create the session if the login is correct.
If the secure pages update/somesecurepage.cfm and update/someothersecurepage.cfm are accessed without correct login the application should forward to update/loginexpired.cfm but I don't want any of the other pages to use application.cfm.
Is this plausible or should I use cfinclude instead?
Always make sure you name your Application.cfm and Application.cfc files with a capital "A". This way if you move from Windows to a case sensitive file system, you wont have an issue where ColdFusion cannot find your Application.cfm/cfc files.
As far as your question goes, with your current structure, all files in the "update" folder will use the Application.cfm file. It will be executed before any other code in those files. If you only want certain pages to redirect to a loginexpired page, then I would typically create a subfolder, put an Application.cfm file in that folder that includes the Application.cfm file from the parent folder: <cfinclude template="../Application.cfm" />. Then in this file, you would add your security check. in the parent Application.cfm file you would include the <cfapplication /> tag. If you are using sessions, be sure to enable session management in your cfapplication tag. (<cfapplication name="myappname" sessionmanagement="true" />)
You really should have an Application.cfm or Applciation.cfc file in the root of your site. If you do not, the application will run without an application scope. ColdFusion has a kind of "unnamed" application where this would run without a defined application name. You will most likely encounter undesired effects. All CF apps should have a named application, using the cfapplication tag or a Application.cfc file with this.name set.
If you are writing this as a new application, I would suggest you use Application.cfc instead of Application.cfm. You will have access to the application, session and request life cycles (onApplicationStart/End, onSessionStart/End, onRequestStart/End) as well as the onError and onMissingTemplate event handlers giving your more control over the flow of your application.
When a .cfm page is loaded, it will first look for an Application.cfc (The modern, recommended Application object) in the same folder and run it. If that file is not present, it will look for an Application.cfm (the old way of instantiating an Application.)
If neither exists in that folder, it will look up the tree to the next folder and check there for Application.cfc, then Application.cfm, it will repeat this until it finds one or gets to the root of the server.
Therefore, ALL of the files you listed in your 'update' folder will automatically use the application.cfm. Only the index.cfm listed in the root will not. (because neither Application.cfc nor Application.cfm are located in that folder.)
So it would be best to use an Application.cfc in the root of your site for everyone, and then put the locked down pages in a subfolder with a more restrictive Application.cfc.
I hope that answers your question directly. Otherwise, I agree with what Sean stated.
More info about Application.cfc and Application.cfm is available on Adobe's Coldfusion site.
I suggest to you to make a different Appliction.cfm (pref Application.cfc) for the public area and secure area. Also define a differnt name for those Application.
Oops, spelling error
I suggest to you to make a different Appliction.cfm (pref Application.cfc) for the public area and secure area. Also define a different name for those Application.

Coldfusion Application.cfc & Application.cfm in the same folder

I am modifying an existing web application which has been coded in Coldfusion. In the existing code, a large portion of the folders contain an Application.cfm file which sets the Application variables
However, part of my modification to these apps requires me to use the Application.cfc rather then the existing .cfm file.
Is there any potiential problems of having both of these files in the same directory? Or will Coldfusion default to using one over the other (or will it run both?)
Thanks,
Steven
EDIT
Just to shine some more light onto this. I am integrating a new centralized login system, but a caveat of this is that it must have a fall back login (in case of downtimne for login system). That is why i dont want to blow out the old code
If there is an Application.cfc file ColdFusion will use that. If you have both, Application.cfm will be ignored.