I do not believe your site was cracked because the folders/files permissions. A more logical cause is a bug in your php scripts that allow the attacker gain a shell with the same previlegies the php user has.
Anyway, change the owner of folders and files to the same php user. chmod -R nobody:nobody /path/to/your/rootdocumentfolder and chmod -R go-rwx /path/to/your/rootdocumentfolder.
good luck next time,