*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @return $httpInstance An instance of this class
*/
- public final static function createConsoleRequest () {
+ public static final function createConsoleRequest () {
// Create an instance
$httpInstance = new ConsoleRequest();
* @todo Needs to be implemented
*/
public function prepareRequestData () {
- $this->partialStub("Please implement this method.");
+ // Get the "request data" from the command-line argument list
+ $args = $_SERVER['argv'];
+
+ // Are there less than two parameters?
+ if ($_SERVER['argc'] < 2) {
+ // Skip this
+ return;
+ } // END - if
+
+ // Is the first element "index.php" ?
+ if ($args[0] == 'index.php') {
+ // Then remove it
+ array_shift($args);
+ } // END - if
+
+ // Try to determine next parameters
+ foreach ($args as $arg) {
+ // Seperate arguemnt name from value
+ $argArray = explode('=', $arg);
+
+ // Is the second one set?
+ if (!isset($argArray[1])) {
+ // Add it likewise, but empty value
+ $this->setRequestElement($argArray[0], '');
+ } else {
+ // Set a name=value pair escaped and secured
+ $this->setRequestElement($argArray[0], escapeshellcmd($argArray[1]));
+ }
+ } // END - foreach
}
/**
* @return $headerValue Value of the header or 'null' if not found
*/
public function getHeader ($headerName) {
- $this->partialStub("Please implement this method.");
+ $this->partialStub('Please implement this method.');
}
/**
* @return $requestMethod Used request method
*/
public final function getRequestMethod () {
- $this->partialStub("Please implement this method.");
- return $_SERVER['REQUEST_METHOD'];
+ return 'LOCAL';
}
/**
* @return $cookieValue Value of cookie or null if not found
*/
public final function readCookie ($cookieName) {
- $this->partialStub("Please implement this method.");
+ // @TODO There are no cookies on console
+ return null;
}
}