+++ /dev/null
-<?php
-// Own namespace
-namespace CoreFramework\Request;
-
-// Import framework stuff
-use CoreFramework\Request\Requestable;
-
-/**
- * A concrete and secured HTML request class to make HTML requests more abstract
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- * @todo Move out the cookie part to a seperate class, e.g. Cookie
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class HtmlRequest extends BaseRequest implements Requestable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class and prepares it a little
- *
- * @return $requestInstance An instance of this class
- */
- public static final function createHtmlRequest () {
- // Create an instance
- $requestInstance = new HtmlRequest();
-
- // Prepare the HTML request data for usage
- $requestInstance->prepareRequestData();
-
- // Return the prepared instance
- return $requestInstance;
- }
-
- /**
- * Checks if the request method is GET.
- *
- * @return $isGet Whether the request method is GET
- */
- public function isGetRequestMethod () {
- // Check it
- return ($this->getRequestMethod() == 'GET');
- }
-
- /**
- * Checks if the request method is HEAD.
- *
- * @return $isHead Whether the request method is HEAD
- */
- public function isHeadRequestMethod () {
- // Check it
- return ($this->getRequestMethod() == 'HEAD');
- }
-
- /**
- * Checks if the request method is POST.
- *
- * @return $isPost Whether the request method is POST
- */
- public function isPostRequestMethod () {
- // Check it
- return ($this->getRequestMethod() == 'POST');
- }
-
- /**
- * Prepares the HTML request data for usage by currently copying
- * $_REQUEST into a private attribute. Later on we can add more
- * things for initialization here.
- *
- * @return void
- */
- public function prepareRequestData () {
- // Copy GET then POST data
- $this->setRequestData(array_merge($_GET, $_POST));
- }
-
- /**
- * Getter for a header element or 'null' if header was not found
- *
- * @param $headerName Name of the header
- * @return $headerValue Value of the header or 'null' if not found
- */
- public function getHeaderElement ($headerName) {
- // Default return value on error
- $headerValue = NULL;
-
- // Construct the name
- $name = 'HTTP_' . strtoupper(self::convertDashesToUnderscores($headerName));
-
- // Does this header exist?
- if (isset($_SERVER[$name])) {
- $headerValue = $_SERVER[$name];
- } // END - if
-
- // Return the value
- return $headerValue;
- }
-
- /**
- * Getter for request method. This getter might be useful for security filters
- *
- * @return $requestMethod Used request method
- */
- public final function getRequestMethod () {
- return $_SERVER['REQUEST_METHOD'];
- }
-
- /**
- * Reads a cookie and returns it's value or null if not found
- *
- * @param $cookieName Name of cookie we shall read
- * @return $cookieValue Value of cookie or null if not found
- */
- public final function readCookie ($cookieName) {
- // Default is no cookie with that name found
- $cookieValue = NULL;
-
- // Is the cookie set?
- if (isset($_COOKIE[$cookieName])) {
- // Then get it
- $cookieValue = $_COOKIE[$cookieName];
- } // END - if
-
- // Return the value
- return $cookieValue;
- }
-
-}