my first instinct was to use 'sudo' or 'su' when using the shell_exec() function. But I know that 'sudo' prompts for a password so that you can get super user access.
I was searching the 'sudo' command and hoping there is an option to give the password so you don't get that prompt, but i didn't find any 🙁
this is what i thought it might look like:
shell_exec("sudo -p password; vim /etc/dir/file");
at least something like that.... dunno.
I don't have much experience using the cmd(), exec(), shell_exec() commands, but i thought i'd share what i had in mind. It might give you an idea at least.
ohh... i just thought about this. you can upload (ftp) the file; move it to its desired destination and override the original file and then give it the correct permissions.
ex:
cmd("sudo -p password; mv /home/user/upload/hosts /etc/hosts; chmod 222 /etc/hosts; chown root:root /etc/hosts")
or ahhhh i will stop 🙂