From 093cca175e42c0d0040821b4687ebd5823e95a5f Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 14 Feb 2017 23:42:06 -0500 Subject: Add function require_https() --- app/class/globals.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app') diff --git a/app/class/globals.php b/app/class/globals.php index c936488..8bfa029 100644 --- a/app/class/globals.php +++ b/app/class/globals.php @@ -53,4 +53,14 @@ function location(string $path) : void redirect(ar() . $path); } +/* + * Assert that the current connection to the server is over HTTPS. Redirect + * if not. + */ +function require_https() : void +{ + if (!isset($_SERVER['HTTPS'])) + redirect("https://" . $_SERVER['SERVER_NAME'] . ap()); +} + ?> -- cgit v1.2.3