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

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 3.0 (and 3.1 though there'll be a couple of merge errors there). Version for 2.4 is at #2246