Replace URL for Cfchart in subdomain - coldfusion

I have a little problem with <cfchart> ...
<cfchart> is working fine with my live site.
But, not working with the subdomain.
As, it takes the url for <cfchart> as http://subdomain.mysite.com/CFIDE/GraphChart.cfm
instead of http://mysite.com/CFIDE/GraphChart.cfm
Here is the relevant code:
<cfchart format="flash" xaxistitle="Month" yaxistitle="Reviews" chartwidth="180" chartheight="150" show3d="yes">
<cfchartseries type="bar" colorlist="##778899,##778899,##778899,##778899">
<cfchartdata item="#DateFormat(LastMonthThree, 'mmm')#" value="0">
</cfchartseries>
</cfchart>

Thanks for everyone for responding me...
Anyway, i have solved the problem...
The problem was actually with cfchart-tag which takes map via the relative path to the CFIDE.
(/CFIDE/chartData.cfm)
So, when i was trying with subdomain.mysite.com, it does find the CFIDE.
(as it was tring to access **(subdomain.mysite.com/CFIDE/chartData.cfm)**...
But when i try to access CFIDE with mysite.com/CFIDE, it was working
(as it was added from the IIS-Server)
So, i just go to the IIS-Manager and add my CFIDE folder to subdomain.mysite.com
(subdomain.mysite.com/CFIDE)
And it worked...:)

Related

how can I use cfdirectory to make a list of documents downloadable using ColdFusion/Lucee?

In my Application.cfc, I setup a mapping
this.mappings["/downloads"]="J:\Downloads\documents";
In my template, I have
<cfdirectory action="list" directory="#expandpath("/downloads")#" filter="*.zip|*.docx" name="downloads" recurse="yes">
<!--- <cfdump var="#expandpath("/software")#"> --->
<cfdump var="#downloads#">
<ul>
<cfoutput query="#downloads#">
<li>#downloads.name#</li>
</cfoutput>
</ul>
I'm trying to make the documents downloadable but when the link is clicked, nothing is happening which makes me think my links are not correct however when I mouse over the link, I see the full path which is correct.
What am I missing to make the list of documents clickable?
Here is the URL displayed when mouseover the 3rd document for example.
Since the files are outside of your webroot you will need to have ColdFusion read the file and send it back to the browser.
You will need to create a page, like download.cfm, that can accept a URL parameter to know which file to access. Once you have selected the file you can use something like the following to stream the file.
<cfheader name="Content-disposition" value="attachment;filename=#datafile#">
<cfcontent file="#datafile#" type="application/pdf">
The above code was pulled from https://www.raymondcamden.com/2006/03/10/Ask-a-Jedi-Using-ColdFusion-to-serve-files
WARNING:
Reading URL parameters in this way and giving people access to the filesystem is extremely unsafe. Safer alternatives should be considered before moving something like this into a production environment.
All I needed to do for this exercise is to setup a mapping in my Application.cfc. As others have stated, there is zero security here but for the purpose of this exercise of understanding virtual directories (IIS) and aliases (CommandBox), this is sufficient.
this.mappings["/guides"]="J:\guides";
Then I can use cfdirectory to build my query object
<cfdirectory action="list" directory="j:\guides" recurse="false" name="nameofqry" type="file" sort="datelastmodified desc" filter="*.docx">
Next, perform a cfoutput using my alias as the a href link
<cfoutput query="nameofqry" maxrows="40">
<li>#nameofqry.name#</li>
</cfoutput>

<CFPDFForm> Populating PDFs from MySQL DB (Quit Working)

Without warning and with no code change on my end the hosting company applied Update 19 to ColdFusion 11. They claim it's unrelated yet no PDF document can be populated from the DB.
Here's the beginning of the code that worked perfect for years.
<cfpdfform source="#ExpandPath( 'FORMS/PDF_FORM_TEMPATE.pdf' )#" action="populate" destination="#expandPath('TEMP/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#" overwrite=true >
<cfpdfsubform name="i9Main">
<cfpdfformparam name="LAST_NAME" value="#hog_data.LAST_NAME#">
Then I end the code by writing it to the final destinations and output it to the screen for viewing.
<cfpdf action="write" destination="#expandPath('FINAL/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#" source="#expandPath('TEMP/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#" flatten="yes" overwrite="yes">
<cffile action="delete" file="#expandPath('TEMP/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#">
<cflocation url="final/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf">
This code has worked great until 6 Mar when the web hosting company applied ColdFusion Update 19. Has anyone has an issue with this or have suggestions?
First off, I want to thank all of you who provided suggestion. Turns out Adrian J. Moreno was correct. This issue was caused by an incompatible version of the Java Run Time Environment. Updating this fixed the issue and populating PDFs is now working again site-wide.

Adding page numbers to PDF with Lucee cfpdf

Everything I have found about CFPDF says that the way to add page numbers to a PDF is like this
<cfpdf action="addFooter" source="#finalFile#" name="mypdf"
text="Page _PAGENUMBER of _LASTPAGENUMBER" />
The problem is every reference I have found is for coldFusion 9 and before and I am wondering if maybe the Lucee guys didn't include this functionality because I get an error that says
Attribute text is not allowed for tag cfpdf
Is this a syntax issue or an oversight by Lucee/Railo not to put this in.
I am merging a group of PDFs using CFPDFs merge feature that this is working correctly but I now need to put page numbers on the PDF and that is were I am hitting a wall.
Here is the a more complete picture of what I am trying to do. The only part that isn't working is the addFooter line
<cfpdf action = "merge" destination="#finalFile#" overwrite="yes">
<cfloop array="#arrayOfPdfs#" index="k">
<cfpdfparam source="#k#">
</cfloop>
</cfpdf>
<cfpdf action="addFooter" source="#finalFile#" name="mypdf"
text="Page _PAGENUMBER of _LASTPAGENUMBER" />
<cfloop array="#arrayOfPdfs#" index="k">
<cffile action="delete" file="#k#">
</cfloop>
I did a little searching and here is what I found. Remember that Lucee was previously Railo. I found your exact issue reported as a bug in Railo back in August 2011 - cfpdf addfooter not supported It looks like that bug was never addressed.
The Lucee docs mention the ability to add a header/footer using cfpdf in the lead-in paragraph but not in the tags attributes - Lucee documentation for cfpdf
Create PDF portfolios - Add and remove header/footer from PDF documents - Optimize PDF documents
(my emphasis) But there is no mention of addheader or addfooter beyond that.
This just mirrors the original Railo documentation - Railo documentation for cfpdf
I am guessing that this bug was never resolved and now exists (still exists) in Lucee. I would create a new issue for the Lucee group to revisit this - https://luceeserver.atlassian.net/secure/Dashboard.jspa
It is interesting that it seems to accept the addfooter action just not the text attribute. That makes it seem like a bug.
UPDATE 11/18/2021
From Andy's comment below "It looks like a fix is coming from the PULL requests at github.com/lucee/extension-pdf/pulls specifically github.com/lucee/extension-pdf/pull/31" it appears that a fix may finally be coming for this issue. Thanks for the update Andy!

cfform cannot be initialized

I'm checking the tag cfform in coldfusion, the codes are very simple:
<cfform name="testFrm" format="Flash">
<cfinput type="text" name="abc" value ="">
</cfform>
But when running it says:
"NetworkError: 404 Not Found - .../1405338045.mxml.cfswf"
The form cannot be shown.
Anybody here got this error? Could you help me about this, I have no any clues on this?
Thanks.
I suspect you do not have a /CFIDE virtual directory mapping, which one needs if one is to use things like <cfform>.
Short of having that mapping, one can use <cfajaximport> to specify an alternative location for the resource files that <cfform> requires to work.
If you're using CF11, open the web.xml file in
{CF11}\cfusion\wwwroot\WEB-INF\web.xml and uncomment any configs that have to do with SWF or CFForm. Restart CF and try again.
Had a client with lots of legacy code that needed flash forms and this fixed the 404's for "mxml.cfswf" files for the client, so I figured I'd post here for the sake of anyone else searching on this topic.

Store and use ColdFusion templates outside of the web root

I have been tasked with researching the possibility of storing .cfm files outside of the web root as a further security measure. (I'm not talking about CFCs, but the files that will appear in the URL string.)
I figured that I could use the properties of OnRequest() in the Application.cfc to do this, but no luck.
I've tried this:
<cffunction name="OnRequest" access="public" returntype="void" output="true">
<cfargument name="TargetPage" type="string" required="true"/>
<cfinclude template="C:/test#arguments.TargetPage#"/>
<cfreturn/>
</cffunction>
I then put a test.cfm inside C:\test and attempted http://localhost/test.cfm. That gives me a "file not found" error.
So then I created a ColdFusion mapping to C:\test called "test" and changed my CFINCLUDE thusly:
<cfinclude template="/test#arguments.TargetPage#"/>
Unfortunately I got the same error.
So, is what I'm after even possible? (Windows Server 2008 and IIS in case it matters. ColdFusion 9.)
I know that I could put a CFINCLUDE in my index.cfm and pass around URLs like http://www.example.com/?file=test.cfm, but I'd prefer not to do that.
Well here's something: If I put an empty test.cfm in my web root then this works. Obviously I'd really rather not put empty stubs for every one of my files (which, for this project, will end up being in the hundreds).
Rather than spinning your wheels down this path, let me point you in a possible better direction which may solve the original issue, but from a more preferred/best practices standpoint:
ColdFusion Sourceless Deployment
Rather than trying to jimmy-rig the site to read files outside of root, you simply never put the source code out into the world.
I think you would have better luck using onMissingTemplate rather than onRequest. http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d2a.html