ColdFusion error after hosting transfer - windows

I recently moved a ColdFusion site from one domain to the other with no issue (practically) besides one which I am having some trouble figuring out. I am a LAMP developer / designer and CF is a bit foreign to me so pardon my ignorance.
The site is working properly except for the store component, I am getting the following error "The .cart.models.store name is not a valid component or interface name.Component and interface names cannot be empty and cannot start or end with a period.". The only piece of code that I have changed throughout this process has been the config.ini, I changed the vmap=SitenameDev to vmap= as the notes in this file recommneded to do if the directory housing the site was the webroot directory.
Any insight on this error or common issues when transferring will be greatly appreciated, as always.
JN

FYI, the config.ini is something specific to the app you're dealing not a ColdFusion convention of any sort. Most likely the "vmap" entry therein means "virtual mapping". Its value is probably being used to resolve a path to an object (i.e. [value of vmap] + ".cart.models.store". With it empty, you're getting an error because ColdFusion wants its paths to not start with a period, and is unable to resolve the location of the file its looking for to create an object.
So previously this path was "SitenameDev.cart.models.store". What you need to do is figure out what directory houses the "cart\models\store" hierarchy. Then in the ColdFusion administrator setup a mapping to its parent directory - that is an alias to a physical directory that ColdFusion recognizes. Then whatever alias you choose should be set as the "vmap" value in the config.ini file.

Related

classic asp create text file on webserver: error 800a0034 Bad_file_name_or_number

I have a classic asp page in VBS and I am trying to create a file on the web server with the following code.
Set fso = CreateObject("Scripting.FileSystemObject")
Set file1 = fso.CreateTextFile("\\localhost\inetpub\wwwroot\cs\batch\123456dirs.bat", true)
This returns the following error:
|666|800a0034|Bad_file_name_or_number
Line 666 is the CreateTextFile line.
According to the Microsoft docs, this means that I'm trying to create a file with an invalid filename. Then it explains the rules for filenames and mine appears to be perfectly valid.
Any suggestions or ideas on how I can further troubleshoot this?
first thing to check to make sure your users have access to the folder. Assuming you're not using windows authentication, make sure IUSR account has write access to the folder.
second, unless inetpub is set up as a share to folder, you're syntax won't work. if the root of your website is located in the CS folder, you can do something like:
Set file1 = fso.CreateTextFile(Server.MapPath( "/cs/batch/123456dirs.bat" ), true)
The createtextfile() function runs on the web server but in the context of the local server itself. Simply put, any path you give it must resolve as if you were logged on to a windows desktop on the server and tried to CD to that path.
The format \localhost... is a UNC path. See this question for a discussion about UNC paths and windows. Unless you know for sure that there is a UNC path mapped for \localhost then that is probably your issue. You may be making the assumption the \localhost will be a reasonable path to use, but as I said unless you know for sure it is available then this is an invalid choice.
Lastly, if you decide to set up a share for \localhost, you will be getting in to some interesting territory around the user context that the web server operates in. You see you will have to set up the share for the IIS user that is configured as the run-as identity for IIS, so you will need to know that and create the required config to give that user the share.
If it were me, I would switch to using a standard windows path, although even then you need to appreciate the run-as user context and security config, etc.

How to name api routing on a webhost sub folder

I have always thought the api controllers where not found by physical paths. The reason I ask is I have a website example.com I created a folder example.com/testing and uploaded my project to there. When I ran it I got errors saying that none of the apiControllers could be found. So I changed /api/apiCustomers to /testing/api/apiCustomers. It then worked, well not the actual posting of any new records. It did locate and retrieve all the records from the database though. But it doesn't seem like that is what I would actually need to do? I have a domain with WinHost and the default publish folder is example.com/myApp
AM I looking at this the wrong way?
To handle request where you do not know the root path, you can use (as in ASP.NET) the ~-character like this:
~/api/apiCustomers
~ will then be replaced by the root (i.e. /api/apiCustomers for prod and /testing/api/apiCustomers for your test environment)

With GroceryCrud, how can I put uploads above application root?

I'm using GroceryCRUD to act as a front end for a database containing news releases. Secretaries can go in and add/edit/delete news releases in the database easily now. Only qualified users are able to access the application root via an .htaccess password. The problem with this is that GroceryCRUD uploads assets such as photos are uploaded to the directory /www/approot/assets/uploads/ which is password protected since /approot/ is protected.
My ideal solution would be to set an upload directory outside of the application root which is where I'm running into trouble. By default this is how GroceryCRUD handles uploads:
$this->grocery_crud->set_field_upload('photo1','assets/uploads/');
I've tried changing it to something like this:
$this->grocery_crud->set_field_upload('photo1','/public/assets/uploads/');
I was hoping this / would make the path start from the document root instead of the application root, but it throws this error:
PHP Fatal error: Uncaught exception 'Exception' with message 'It
seems that the folder "/Users/myusername/www/approot//public/assets/uploads/"
for the field name "photo1" doesn't exists.
This seems to suggest that CI or GroceryCRUD just takes the second argument in set_upload field and just concatenates it onto the end of the site URL that is defined. Is there any way around this that doesn't involve creating a user login system?
Try using relative path.
$this->grocery_crud->set_field_upload('photo1','../assets/uploads/');
.. -> Go up one directory
I ended up implementing a login system outlined in this tutorial:
http://net.tutsplus.com/tutorials/php/easy-authentication-with-codeigniter/
It was quite simple to set up and suits my needs. I found ways to give access to the directory using httpd.conf directives but I feel like this was a more viable solution since I don't have direct access to server configuration files.
Maybe in the future GroceryCRUD will allow placement of uploads outside the application folder.

Coldfusion 10 AJAX replace content in cfdiv

I have an href that throws an error when trying to replace the contents of its parent cfdiv.
In the efforts to keep this short, the link looks something like this:
<cfdiv id="managerDiv">
<a href="javascript:ColdFusion.navigate('theURL?theVariables','managerDiv');" >add a new thing</a>
</cfdiv>
The error that I'm getting is a dialog box that indicates the following:
Error retrieving markup for element managerDiv : /manager/CFIDE/administrator/templates/errors.jsp [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
A few things to note:
On my Coldfusion 10 development environment, I have no problems. This error only occurs on my hosting server.
The directory structure of both my hosting and development environments is EXACTLY the same
I do NOT have a pointer or mapping to "errors.jsp" anywhere in my source code or Coldfusion settings.
manager is a sub-directory at the root level
"theURL" is any coldfusion file, I have tried with a simple blank.cfm file, and it still passes the same error
Thoughts
Obviously, it seems like Coldfusion is looking for a file that doesn't exist to replace the contents of the cfdiv. However, I really have no idea why it is looking for something other than the contents of "theURL", and why it is looking for it in the directory specified in the error (manager/CFIDE/...)
I did some more testing.
It appears that the coldfusion.navigate URL parameter does not like the relative path (again, it works fine on my dev environment, but not on production).
For example, this works:
<a href='javascript.Coldfusion.navigate('test.cfm');'>
but this does NOT:
<a href='javascript.Coldfusion.navigate('folder/test.cfm');'>
thoughts?
All:
It appears that I should have been more specific, as this is a very targeted answer.
The file that I was attempting to load was coming from a directory that I had named "manager". After some testing, it appears that the name "manager" is the issue. We renamed the directory, and the problem was solved.
In other words, here was my link (I omitted the names, because I thought them irrelevant initially, but here is the actual link):
<a href='javascript.Coldfusion.navigate('manager/test.cfm');'>
I was forwarded this page by the support team, which seems to reinforce this point:
http://www.giancarlogomez.com/2012/06/directory-of-manager-in-webroot-not.html
Bottom line, don't name a directory in your root folder "manager". Coldfusion/TomCat reserves that name (at least at the root level).
I'm not sure why they did this (given the occassional use of the word "Manager" as an admin role, and therefore, a common trend to have a directory for this role), but oh well :)

Launching a registered mime helper application

I used to be able to launch a locally installed helper application by registering a given mime-type in the Windows registry. This enabled me to allow users to be able to click once on a link to the current install of our internal browser application. This worked fine in Internet Explorer 5 (most of the time) and Firefox but now does not work in Internet Explorer 7.
The filename passed to my shell/open/command is not the full physical path to the downloaded install package. The path parameter I am handed by IE is
"C:\Document and Settings\chq-tomc\Local Settings\Temporary Internet Files\
EIPortal_DEV_2_0_5_4[1].expd"
This unfortunately does not resolve to the physical file when calling FileExists() or when attempting to create a TFileStream object.
The physical path is missing the Internet Explorer hidden caching sub-directory for Temporary Internet Files of "Content.IE5\ALBKHO3Q" whose absolute path would be expressed as
"C:\Document and Settings\chq-tomc\Local Settings\Temporary Internet Files\
Content.IE5\ALBKHO3Q\EIPortal_DEV_2_0_5_4[1].expd"
Yes, the sub-directories are randomly generated by IE and that should not be a concern so long as IE passes the full path to my helper application, which it unfortunately is not doing.
Installation of the mime helper application is not a concern. It is installed/updated by a global login script for all 10,000+ users worldwide. The mime helper is only invoked when the user clicks on an internal web page with a link to an installation of our Desktop browser application. That install is served back with a mime-type of "application/x-expeditors". The registration of the ".expd" / "application/x-expeditors" mime-type looks like this.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.expd]
#="ExpeditorsInstaller"
"Content Type"="application/x-expeditors"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller]
"EditFlags"=hex:00,00,01,00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller\shell\open]
#=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller\shell\open\command]
#="\"C:\\projects\\desktop2\\WebInstaller\\WebInstaller.exe\" \"%1\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type\application/x-expeditors]
"Extension"=".expd"
I had considered enumerating all of a user's IE cache entries but I would be concerned with how long it may take to examine them all or that I may end up finding an older cache entry before the current entry I am looking for. However, the bracketed filename suffix "[n]" may be the unique key.
I have tried wininet method GetUrlCacheEntryInfo but that requires the URL, not the virtual path handed over by IE.
My hope is that there is a Shell function that given a virtual path will hand back the physical path.
I believe the sub-directories created by IE are randomly generated, so you won't be able guarantee that it will be named the same every time, and the problem I see with the registry method is that it only works when the file is still in the cache...emptying the cache would purge the file requiring yet another installation.
Would it not be better to install this helper into application data?
I'm not sure about this but perhaps this may lead you in the right direction: try using URL cache functions from the wininet DLL: FindFirstUrlCacheEntry, FindNextUrlCacheEntry, FindCloseUrlCache for enumeration and when you locate an entry whose local file name matches the given path maybe you can use RetrieveUrlCacheEntryFile to retrieve the file.
I am using a similar system with the X-Appl browser to display WAML web applications and it works perfectly. Maybe you should have a look at how they managed to do it.
It looks like iexplore is passing the shell namespace "name" of the file rather than the filesystem name.
I dont think there is a documented way to be passed a shell item id on the command line - explorer does it to itself, but there are marshaling considerations as shell item ids are (pointers to) binary data structures that are only valid in a single process.
What I might try doing is:
1. Call SHGetDesktopFolder which will return the root IShellFolder object of the shell namespace.
2. Call the IShellFolder::ParseDisplayName to turn the name you are given back into a shell item id list.
3. Try the IShellFolder::GetDisplayNameOF with the SHGDN_FORPARSING flag - which, frankly, feels like w'eve just gone in a complete circle and are back where we started. Because I think its this API thats ultimately responsible for returning the "wrong" filesystem relative path.
Some follow-up to close out this question.
Turned out the real issue was how I was creating the file handle using TFileStream. I changed to open with fmOpenRead or fmShareDenyWrite which solved what turned out to be a file locking issue.
srcFile := TFileStream.Create(physicalFilename, fmOpenRead or fmShareDenyWrite);

Resources