define ENVIRONMENT constant, remove all other calls to defined()

Define ENVIRONMENT constant once in core/CodeIgniter.php if not defined in front controller (index.php); remove all other calls to defined(). And with this change, it is now possible to define ENVIRONMENT in config/constants.php, if preferred by the developer.