Update sanity_check.php

Centralise error messages for the lack of write access in a new function error_message_not_writable(), with additional tests for PHP open_basedir, provides information about PHP username, and changes the recommended chmod 777 by the less dangerous chmod +rw (which does not make every file executable).