Wednesday, January 30, 2008

Warning: I am able to write to the configuration file: Windows, Helm, Zen Cart/OS Commerce, and File Properties

Ok, so I am not too proud to admit that I am moving from a linux box to a Windows environment for many of my projects. Suffice it to say that it was not originally my idea and it ends up being a complex situation of cost and performance. In my defense, the windows hosting that I am using has newer versions of php and mysql and is a clustered, load balanced system as opposed to the single linux box. I was kicked off the linux box for having too many domains and taking up too much processing power, but that is another post I will make later.

In any case, I was porting over my Zen Cart installations to the windows environment. And everything went fairly smooth until I ran into the
"Warning: I am able to write to the configuration file:"

As I did research, i found this was supposed to be an easy fix of setting the file permissions to 644 or 444. Well low and behold, this was actually not that easy in my situation: I tried to set these permissions through dreamweaver, filezilla ftp, and then even through the IE Ftp interface... and still no luck. I went in through helm and tried to use the file manager, but it does not allow for setting file permissions.

I ended up putting in a ticket to my hosting company to see if they can help. Apparently all you need to do is look at the file from the OS, right click on it and then set to read only- and voila you should be fine. Well, I realized I did not want to have to rely on my hosting company for changes to these files every single time I want to update or change configuration (which would not be often, but I have a few other installations of zen cart I wanted to do on this server).

As I was waiting for response, I came up with the idea to try to set the file permissions through php or asp. I set out on a quest and found some code which I altered ever so slightly to get to work on my system... Here it is. Just make a setfilepermissions.asp page on your server. This page will just do one thing and this is to set the filepermissions to readonly. You will have to alter the code to make it dynamic or set the file back from read-only.

If you do add or change it, please post it here. Thanks!


......................................


response.write "i am in here"


Dim strSaveFilename
'As String

Dim scrFSO
'As Object 'Scripting.FileSystemObject
Dim scrFile
'As Object 'Scripting.File

'i used absolute path which worked for me
strSaveFilename = "c:\domains\your domain here\wwwroot\includes\configure.php"


' Set up Scripting variables
Set scrFSO = CreateObject("Scripting.FileSystemObject")
Set scrFile = scrFSO.GetFile(strSaveFilename)

' Set file to be read-only
scrFile.Attributes = 1 'ReadOnly

' De-reference variables
Set scrFSO = Nothing
Set scrFile = Nothing

response.write "
done setting permissions!"

Labels: , , , , , , , , , , ,