Properly checking for the $_SERVER["HTTP_X_FORWARDED_PROTO"] instead of simply ignoring errors with an @
Cleaned up api.php and apistats.php, added proper typecasting to the XML (probably has no effect, but whatever) and made the JSON properly set JSON_NUMERIC_CHECK