FIX Prevent DOS by checking for env and admin on ?flush=1 (#1692) in 2.4

Ensure that flush=1 only causes an actual flush if one of the following is true

- You are in dev mode
- You are logged in as an admin
- An error occurred while attempted to start up the page

Fixes #1692. This is the version for 2.4. The version for 3.0 is at #2243