2
Mactron,
Welcome to XOOPS!
If the mentioned folders are 777 and mainfile.php is 666, then the only thing left that would prevent you from writing to those files is ownership or extended attributes. The most likely of the 2 being ownership.
Make sure that the owner of the folders and files is the owner of the web root.
You can determine this by doing a ls -ald on your web root directory.
HTH.
James
Insanity can be defined as "doing the same thing over and over and expecting different results."
Stupidity is not a crime. Therefore, you are free to go.