From f5256455c137e978cb78b9489c3fb68d8735ab2a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 19 Dec 2006 03:17:59 +0000 Subject: [PATCH] - Added BSRouterController::_verifyPostRequest() - Added BSInput::getHttpMethod() --- Input.php | 16 ++++++++++++++++ RouterController.php | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Input.php b/Input.php index 759ce2a..32462f1 100644 --- a/Input.php +++ b/Input.php @@ -384,6 +384,22 @@ class BSInput return $array; } + // ################################################################### + /** + * Returns the lowercase version of the HTTP method (post or get) + * + * @return string HTTP method + */ + public function getHttpMethod() + { + $method = strtolower($_SERVER['REQUEST_METHOD']); + if (!in_array($method, array('get', 'post'))) + { + trigger_error('Invalid server request method: ' . $method); + } + return $method; + } + // ################################################################### /** * Checks to see if a POST refer is actually from us diff --git a/RouterController.php b/RouterController.php index 8c439a0..2a5ae80 100644 --- a/RouterController.php +++ b/RouterController.php @@ -53,6 +53,19 @@ abstract class BSRouterController $this->params = $params; } + // ################################################################### + /** + * Does nothing if the request was sent via POST, and triggers an + * error if it was not + */ + protected function _verifyPostRequest() + { + if ($this->params->getHttpMethod() != 'post') + { + trigger_error('Action is intended to be executed from a POST request'); + } + } + /** * The default action (index) */ -- 2.43.5