Those folders do not necessarily have to be 777 (in fact I'd recommend to never make them world writable); they only need to be readable/browsable/writable by the user running the PHP files and data
needs to be readble/browsabe by the user running the webserver.
On our servers the data
ist 755 and internal_data
is 700, the files are 644.
(I probably might add code to further lower down permissions on internal_data)