Don't silently ignore invalid URLs

Scenario: Providing an invalid url via $_GET (wrong/missing extension or file isn't an image (also happens on download errors))
Behavior before: Silently redirect to index
Behavior after: Display error message
Update extension.class.php

Fix my previous commit. Also put the results of the tests into variables so we don't need to check them again.
Merge pull request #365 from HungryFeline/patch-2

Don't silently ignore invalid URLs