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, information about the current directory for the typically relative ICONS_DIR, and changes the recommended chmod 777 by the less dangerous chmod +rw (which does not make every file executable).