From 0d53041fc67e13fc53cca0c993ec1a7a31a5a16e Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 15 Jan 2017 05:57:19 -0500 Subject: Reorganize examples/ directory --- examples/class/controller.class.php | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 examples/class/controller.class.php (limited to 'examples/class/controller.class.php') diff --git a/examples/class/controller.class.php b/examples/class/controller.class.php new file mode 100644 index 0000000..0ab1a69 --- /dev/null +++ b/examples/class/controller.class.php @@ -0,0 +1,66 @@ +redirectTo("https://" . $_SERVER['SERVER_NAME'] . $this->ap()); + } + + /* + * Security check + * Assert that the current connection to this server is NOT secure. Redirects if not. + */ + function sec_forbid_https() + { + if (isset($_SERVER['HTTPS'])) + $this->redirectTo("http://" . $_SERVER['SERVER_NAME'] . $this->ap()); + } + + /* + * Security check + * Assert that the client's IP address does not change during its session. If a change is detected, logout. + */ + function sec_verify_ip() + { + $addr = $_SERVER['REMOTE_ADDR']; + + if ($this->getCurrentUser() && $addr != $this->getOriginIP()) + { + $this->setCurrentUser(); + $this->redirectTo($this->ar() . "/"); + } + } +} + +?> -- cgit v1.2.3