Fix redirect and flip boolean error

Stop redirecting to other pages using $_SERVER['HTTP_REFERER'] to go
back to page that attachment was trying to be downloaded from.
The if statement had it’s boolean wrong meaning if you were logged in
and not included in the selected user groups you would be allowed to;
fixed.