Correct the php opening tag
Prevent "undefined index 'HTTPS'" Notice

In servers where notice error_level is enabled, php prints this notice
which mixed in to url.
Don't add 'index.php' to url, REQUEST_URI has it

See http://php.net/manual/en/reserved.variables.server.php
Add forgotten $ sign

Php was defaulting httpcodeOK to 'httpcodeOK' which always evaluates to
true (which is incorrect)
Fix undefined index and constant problems