application/selector/.htaccess -text
application/selector/class_ApplicationHelper.php -text
application/selector/class_ApplicationSelector.php -text
+application/selector/config.php -text
application/selector/debug.php -text
application/selector/exceptions.php -text
application/selector/init.php -text
inc/classes/main/resolver/controller/web/.htaccess -text
inc/classes/main/resolver/controller/web/class_WebControllerResolver.php -text
inc/classes/main/response/.htaccess -text
-inc/classes/main/response/class_HttpResponse.php -text
-inc/classes/main/response/class_ImageResponse.php -text
+inc/classes/main/response/class_BaseResponse.php -text
+inc/classes/main/response/http/.htaccess -text
+inc/classes/main/response/http/class_HttpResponse.php -text
+inc/classes/main/response/image/.htaccess -text
+inc/classes/main/response/image/class_ImageResponse.php -text
inc/classes/main/result/.htaccess -text
inc/classes/main/result/class_DatabaseResult.php -text
inc/classes/main/rng/.htaccess -text
print("MSG:".$message."<br />\n");
} // END - if
}
+
+ /**
+ * Assigns application-depending data
+ *
+ * @param $templateInstance An instance of a template engine
+ * @return void
+ */
+ public function assignExtraTemplateData (CompileableTemplate $templateInstance) {
+ // Assign charset
+ $templateInstance->assignConfigVariable('header_charset');
+ }
}
// [EOF]
// Get a configuration instance for shorter lines
$cfg = FrameworkConfiguration::getInstance();
+// CFG: HEADER-CHARSET
+$cfg->setConfigEntry('header_charset', "utf-8");
+
// CFG: DEFAULT-WEB-COMMAND
$cfg->setConfigEntry('default_web_command', "home");
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
// Initialize output system
require($cfg->readConfig('base_path') . 'inc/output.php');
public function handleFatalMessages (array $messageList) {
die("<pre>".print_r($messageList, true)."</pre>");
}
+
+ /**
+ * Assigns application-depending data
+ *
+ * @param $templateInstance An instance of a template engine
+ * @return void
+ */
+ public function assignExtraTemplateData (CompileableTemplate $templateInstance) {
+ // Assign charset
+ $templateInstance->assignConfigVariable('header_charset');
+ }
}
// [EOF]
*/
public function readApplicationDirectory () {
// Generate the base path for all applications
- $appBasePath = sprintf("%s%s/",
- $this->getConfigInstance()->readConfig('base_path'),
- $this->getConfigInstance()->readConfig('application_path')
- );
+ $appBasePath = $this->getConfigInstance()->readConfig('application_path');
// Add the selector path to the ignore list
$this->addDirIgnoreList($this->getConfigInstance()->readConfig('selector_path'));
// Get a directory pointer for the application path
$dirInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($appBasePath);
- // Backup and remove the 'app' from global name space
+ // Backup and remove the 'app' from local name space
/*$appBackup = $app;
unset($app);*/
--- /dev/null
+<?php
+/**
+ * Additional/overwritten configuration parts
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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/>.
+ */
+
+// Get a configuration instance for shorter lines
+$cfg = FrameworkConfiguration::getInstance();
+
+// CFG: HEADER-CHARSET
+$cfg->setConfigEntry('header_charset', "utf-8");
+
+// CFG: DEFAULT-WEB-COMMAND
+$cfg->setConfigEntry('default_web_command', "home");
+
+// CFG: DEFAULT-IMAGE-COMMAND
+$cfg->setConfigEntry('default_image_command', "build");
+
+// CFG: PAGE-WITH-NEWS
+$cfg->setConfigEntry('page_with_news', "home");
+
+// CFG: FORM-ACTION
+$cfg->setConfigEntry('form_action', "index.php?app={?app_short_name?}&page=do_form");
+
+// CFG: FORM-METHOD
+$cfg->setConfigEntry('form_method', "post");
+
+// CFG: FORM-TARGET
+$cfg->setConfigEntry('form_target', "_self");
+
+// [EOF]
+?>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
// Initialize output system
require($cfg->readConfig('base_path') . 'inc/output.php');
print("MSG:".$message."<br />\n");
} // END - if
}
+
+ /**
+ * Assigns application-depending data
+ *
+ * @param $templateInstance An instance of a template engine
+ * @return void
+ */
+ public function assignExtraTemplateData (CompileableTemplate $templateInstance) {
+ // Assign charset
+ $templateInstance->assignConfigVariable('header_charset');
+ }
}
// [EOF]
// Get a configuration instance for shorter lines
$cfg = FrameworkConfiguration::getInstance();
+// CFG: HEADER-CHARSET
+$cfg->setConfigEntry('header_charset', "utf-8");
+
// CFG: DEFAULT-WEB-COMMAND
$cfg->setConfigEntry('default_web_command', "home");
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
// Initialize output system
require($cfg->readConfig('base_path') . 'inc/output.php');
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Make sure only allowed values are comming through
- foreach ($this->allowedData as $alias=>$element) {
+ foreach ($this->allowedData as $alias => $element) {
// Get data
$data = $requestInstance->getRequestElement($element);
} // END - if
// Add a lot elements to the dataset criteria
- foreach ($this->criteriaElements as $alias=>$element) {
+ foreach ($this->criteriaElements as $alias => $element) {
// Do we have an alias?
if (is_string($alias)) {
// Yes, so use it
} // END - foreach
// Mark the username as unique key
- $criteriaInstance->setUniqueKey('username');
+ $criteriaInstance->setUniqueKey(UserDatabaseWrapper::DB_COLUMN_USERNAME);
// Add account status as configured
$criteriaInstance->addConfiguredCriteria(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $configEntry);
print("MSG:".$message."<br />\n");
} // END - if
}
+
+ /**
+ * Assigns application-depending data
+ *
+ * @param $templateInstance An instance of a template engine
+ * @return void
+ */
+ public function assignExtraTemplateData (CompileableTemplate $templateInstance) {
+ // Assign charset
+ $templateInstance->assignConfigVariable('header_charset');
+ }
}
// [EOF]
// Get a configuration instance for shorter lines
$cfg = FrameworkConfiguration::getInstance();
+// CFG: HEADER-CHARSET
+$cfg->setConfigEntry('header_charset', "utf-8");
+
// CFG: DEFAULT-WEB-COMMAND
$cfg->setConfigEntry('default_web_command', "home");
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
+
// Initialize output system
require($cfg->readConfig('base_path') . 'inc/output.php');
} // END - if
// Generate FQFN for all application templates
- $fqfn = sprintf("%s%s/%s/%s",
- $this->getConfigInstance()->readConfig('base_path'),
+ $fqfn = sprintf("%s%s/%s",
$this->getConfigInstance()->readConfig('application_path'),
strtolower($appInstance->getAppShortName()),
$this->getConfigInstance()->readConfig('tpl_base_path')
} // END - if
// Add line number to the code
- foreach (explode("\n", $phpCode) as $lineNo=>$code) {
+ foreach (explode("\n", $phpCode) as $lineNo => $code) {
// Add line numbers
$markedCode .= sprintf("<span id=\"code_line\">%s</span>: %s\n",
($lineNo + 1),
// Prepare a template instance
$templateInstance = $this->prepareTemplateInstance($appInstance);
+ // Assign application data with template engine
+ $templateInstance->assignApplicationData($appInstance);
+
// Load the master template
$masterTemplate = $appInstance->getMasterTemplate();
// Prepare a template instance
$templateInstance = $this->prepareTemplateInstance($appInstance);
+ // Assign application data
+ $templateInstance->assignApplicationData($appInstance);
+
// Load the master template
$masterTemplate = $appInstance->getMasterTemplate();
$counted = 0;
// Walk through all entries
- foreach ($entryArray as $key=>$entry) {
+ foreach ($entryArray as $key => $entry) {
// Then walk through all search criteria
- foreach ($this->searchCriteria as $criteriaKey=>$criteriaValue) {
+ foreach ($this->searchCriteria as $criteriaKey => $criteriaValue) {
// Is the element found and does it match?
if (($key == $criteriaKey) && ($criteriaValue == $entry)) {
// Then count this one up
// Is this an array?
if (is_array($dataArray)) {
// Search in the criteria with FMFW (First Matches, First Wins)
- foreach ($dataArray as $key=>$value) {
+ foreach ($dataArray as $key => $value) {
// Get criteria element
$criteria = $criteriaInstance->getCriteriaElemnent($key);
// Is this an array?
if (is_array($dataArray)) {
// Search in the criteria with FMFW (First Matches, First Wins)
- foreach ($dataArray as $key=>$value) {
+ foreach ($dataArray as $key => $value) {
// Get criteria element
$criteria = $searchInstance->getCriteriaElemnent($key);
} // END - if
// Entry found, so update it
- foreach ($criteriaArray as $criteriaKey=>$criteriaValue) {
+ foreach ($criteriaArray as $criteriaKey => $criteriaValue) {
$dataArray[$criteriaKey] = $criteriaValue;
} // END - foreach
$this->setBlue($blue);
// Get a pointer for background color
- $backColor = imagecolorallocate($this->imageResource, $red, $green, $blue);
+ $backColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue);
// Fill the image
- imagefill($this->imageResource, 0, 0, $backColor);
+ imagefill($this->getImageResource(), 0, 0, $backColor);
// Compile foreground colors
$red = $templateInstance->compileRawCode($this->foregroundColor['red']);
$this->setBlue($blue);
// Get a pointer for foreground color
- $foreColor = imagecolorallocate($this->imageResource, $red, $green, $blue);
+ $foreColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue);
switch ($this->groupable) {
case "single": // Single image string
$size = $templateInstance->compileRawCode($this->getFontSize());
// Set the image string
- imagestring($this->imageResource, $size, $x, $y, $imageString, $foreColor);
+ imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor);
break;
case "groupable": // More than one string allowed
// Set the image string
//* DEBUG: */ echo __METHOD__.": size={$size}, x={$x}, y={$y}, string={$imageString}<br />\n";
- imagestring($this->imageResource, $size, $x, $y, $imageString, $foreColor);
+ imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor);
} // END - foreach
break;
}
// Get a file name for our image
$cacheFile = $this->getTemplateInstance()->getImageCacheFqfn();
+ // Does it exist?
+ if (file_exists($cacheFile)) {
+ // Remove it
+ @unlink($cacheFile);
+ } // END - if
+
// Finish the image and send it to a cache file
imagepng($this->getImageResource(), $cacheFile, 9, PNG_ALL_FILTERS);
}
$templateInstance->assignVariable('subject', $this->getSubjectLine());
// Walk through all variables, first config to assign them
- foreach ($recipientList['config_vars'] as $variable=>$dummy) {
+ foreach ($recipientList['config_vars'] as $variable => $dummy) {
// Load the config value and set it
$templateInstance->assignConfigVariable($variable);
} // END - if
// Now do the same with the values but ask the "value instance" instead!
- foreach ($recipientList['value_vars'] as $variable=>$dummy) {
+ foreach ($recipientList['value_vars'] as $variable => $dummy) {
// Is the value instance there?
if (!isset($recipientList['values'][$variable])) {
// Throw exception
public final function output ($outStream=false) {
if ($outStream === false) {
// Output something here...
- foreach ($this->vars as $var=>$value) {
+ foreach ($this->vars as $var => $value) {
$this->output("var=".$var.", value=".$value."");
}
} else {
* @return void
*/
public function prepareRequestData () {
- // Copy the $_REQUEST array
- $this->requestData = $_REQUEST;
+ // Copy GET then POST data
+ $this->requestData = array_merge($_GET, $_POST);
}
/**
* @return void
*/
public function setRequestElement ($element, $value) {
+ error_log(__METHOD__.":{$element}={$value}");
$this->requestData[$element] = $value;
}
--- /dev/null
+<?php
+/**
+ * A generic request class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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/>.
+ *
+ * The extended headers are taken from phpMyAdmin setup tool, written by
+ * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
+ */
+class BaseResponse extends BaseFrameworkSystem {
+ /**
+ * Response status
+ */
+ private $responseStatus = "200 OK";
+
+ /**
+ * Array with all headers
+ */
+ private $responseHeaders = array();
+
+ /**
+ * Cookies we shall sent out
+ */
+ private $cookies = array();
+
+ /**
+ * Body of the response
+ */
+ private $responseBody = "";
+
+ /**
+ * Instance of the template engine
+ */
+ private $templateInstance = null;
+
+ /**
+ * Fatal resolved messages from filters and so on
+ */
+ private $fatalMessages = array();
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the concrete response
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Setter for status
+ *
+ * @param $status New response status
+ * @return void
+ */
+ public final function setResponseStatus ($status) {
+ $this->responseStatus = (string) $status;
+ }
+
+ /**
+ * Add header element
+ *
+ * @param $name Name of header element
+ * @param $value Value of header element
+ * @return void
+ */
+ public final function addHeader ($name, $value) {
+ $this->responseHeaders[$name] = $value;
+ }
+
+ /**
+ * Reset the header array
+ *
+ * @return void
+ */
+ public final function resetResponseHeaders () {
+ $this->responseHeaders = array();
+ }
+
+ /**
+ * "Writes" data to the response body
+ *
+ * @param $output Output we shall sent in the HTTP response
+ * @return void
+ */
+ public final function writeToBody ($output) {
+ $this->responseBody .= $output;
+ }
+
+ /**
+ * Sets the response body to something new
+ *
+ * @param $output Output we shall sent in the HTTP response
+ * @return void
+ */
+ public final function setResponseBody ($output) {
+ $this->responseBody = $output;
+ }
+
+ /**
+ * Adds a fatal message id to the response. The added messages can then be
+ * processed and outputed to the world
+ *
+ * @param $messageId The message id we shall add
+ * @return void
+ */
+ public final function addFatalMessage ($messageId) {
+ // Adds the resolved message id to the fatal message list
+ $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId);
+ }
+
+ /**
+ * Flushs the cached HTTP response to the outer world
+ *
+ * @param $force Wether we shall force the output or abort if headers are
+ * already sent with an exception
+ * @return void
+ * @throws ResponseHeadersAlreadySentException Thrown if headers are
+ * already sent
+ */
+ public function flushBuffer ($force = false) {
+ if ((headers_sent()) && (!$force)) {
+ // Headers are already sent!
+ throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
+ } elseif (!headers_sent()) {
+ // Send headers out
+ header("HTTP/1.1 {$this->responseStatus}");
+
+ // Used later
+ $now = gmdate('D, d M Y H:i:s') . ' GMT';
+
+ // General header for no caching
+ $this->addHeader('Expired', $now); // RFC2616 - Section 14.21
+ $this->addHeader('Last-Modified', $now);
+ $this->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+ $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0
+
+ // Define the charset to be used
+ //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset')));
+
+ // Send all headers
+ foreach ($this->responseHeaders as $name => $value) {
+ header("{$name}: {$value}");
+ //* DEBUG: */ echo "{$name}: {$value}<br />\n";
+ } // END - foreach
+
+ // Send cookies out?
+ if (count($this->cookies) > 0) {
+ // Send all cookies
+ $cookieString = implode(" ", $this->cookies);
+ header("Set-Cookie: {$cookieString}");
+
+ // Remove them all
+ $this->cookies = array();
+ } // END - if
+ }
+
+ // Are there some error messages?
+ if (count($this->fatalMessages) == 0) {
+ // Flush the output to the world
+ $this->getWebOutputInstance()->output($this->responseBody);
+ } else {
+ // Display all error messages
+ $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages);
+
+ // Send the error messages out to the world
+ $this->getWebOutputInstance()->output($this->responseBody);
+ }
+
+ // Clear response header and body
+ $this->setResponseBody("");
+ $this->resetResponseHeaders();
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-<?php
-/**
- * A class for an HTTP response on an HTTP request
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * 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/>.
- *
- * The extended headers are taken from phpMyAdmin setup tool, written by
- * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
- */
-class HttpResponse extends BaseFrameworkSystem implements Responseable {
- /**
- * Response status
- */
- private $responseStatus = "200 OK";
-
- /**
- * Array with all headers
- */
- private $responseHeaders = array();
-
- /**
- * Cookies we shall sent out
- */
- private $cookies = array();
-
- /**
- * Body of the response
- */
- private $responseBody = "";
-
- /**
- * Instance of the template engine
- */
- private $templateInstance = null;
-
- /**
- * Fatal resolved messages from filters and so on
- */
- private $fatalMessages = array();
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
- }
-
- /**
- * Creates an object of this class
- *
- * @param $appInstance An instance of a manageable application
- * @return $responseInstance A prepared instance of this class
- */
- public final static function createHttpResponse (ManageableApplication $appInstance) {
- // Get a new instance
- $responseInstance = new HttpResponse();
-
- // Set the application instance
- $responseInstance->setApplicationInstance($appInstance);
-
- // Initialize the template engine here
- $responseInstance->initTemplateEngine($appInstance);
-
- // Return the prepared instance
- return $responseInstance;
- }
-
- /**
- * Setter for status
- *
- * @param $status New response status
- * @return void
- */
- public final function setResponseStatus ($status) {
- $this->responseStatus = (string) $status;
- }
-
- /**
- * Add header element
- *
- * @param $name Name of header element
- * @param $value Value of header element
- * @return void
- */
- public final function addHeader ($name, $value) {
- $this->responseHeaders[$name] = $value;
- }
-
- /**
- * Reset the header array
- *
- * @return void
- */
- public final function resetResponseHeaders () {
- $this->responseHeaders = array();
- }
-
- /**
- * "Writes" data to the response body
- *
- * @param $output Output we shall sent in the HTTP response
- * @return void
- */
- public function writeToBody ($output) {
- $this->responseBody .= $output;
- }
-
- /**
- * Sets the response body to something new
- *
- * @param $output Output we shall sent in the HTTP response
- * @return void
- */
- public function setResponseBody ($output) {
- $this->responseBody = $output;
- }
-
- /**
- * Flushs the cached HTTP response to the outer world
- *
- * @param $force Wether we shall force the output or abort if headers are
- * already sent with an exception
- * @return void
- * @throws ResponseHeadersAlreadySentException Thrown if headers are
- * already sent
- */
- public function flushBuffer ($force=false) {
- if ((headers_sent()) && (!$force)) {
- // Headers are already sent!
- throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
- } elseif (!headers_sent()) {
- // Send headers out
- header("HTTP/1.1 {$this->responseStatus}");
-
- // Used later
- $now = gmdate('D, d M Y H:i:s') . ' GMT';
-
- // General header for no caching
- $this->addHeader('Expired', $now); // rfc2616 - Section 14.21
- $this->addHeader('Last-Modified', $now);
- $this->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
- $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0
-
- // Define the charset to be used
- //$this->addHeader('Content-Type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset')));
-
- foreach ($this->responseHeaders as $name=>$value) {
- header("{$name}: {$value}");
- } // END - foreach
-
- // Send cookies out?
- if (count($this->cookies) > 0) {
- // Send all cookies
- $cookieString = implode(" ", $this->cookies);
- header("Set-Cookie: {$cookieString}");
-
- // Remove them all
- $this->cookies = array();
- } // END - if
- }
-
- // Are there some error messages?
- if (count($this->fatalMessages) == 0) {
- // Flush the output to the world
- $this->getWebOutputInstance()->output($this->responseBody);
- } else {
- // Display all error messages
- $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages);
-
- // Send the error messages out to the world
- $this->getWebOutputInstance()->output($this->responseBody);
- }
-
- // Clear response header and body
- $this->setResponseBody("");
- $this->resetResponseHeaders();
- }
-
- /**
- * Initializes the template engine instance
- *
- * @param $appInstance An instance of a manageable application
- * @return void
- */
- public final function initTemplateEngine (ManageableApplication $appInstance) {
- $this->setTemplateInstance($this->prepareTemplateInstance($appInstance));
- }
-
- /**
- * Adds a fatal message id to the response. The added messages can then be
- * processed and outputed to the world
- *
- * @param $messageId The message id we shall add
- * @return void
- */
- public final function addFatalMessage ($messageId) {
- // Adds the resolved message id to the fatal message list
- $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId);
- }
-
- /**
- * Adds a cookie to the response
- *
- * @param $cookieName Cookie's name
- * @param $cookieValue Value to store in the cookie
- * @param $encrypted Do some extra encryption on the value
- * @param $expires Timestamp of expiration (default: configured)
- * @return void
- * @throws ResponseHeadersAlreadySentException If headers are already sent
- * @todo Encryption of cookie data not yet supported.
- * @todo Why are these parameters conflicting?
- * @todo If the return statement is removed and setcookie() commented out,
- * @todo this will send only one cookie out, the first one.
- */
- public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) {
- //* DEBUG: */ echo $cookieName."=".$cookieValue."<br />\n";
- // Are headers already sent?
- if (headers_sent()) {
- // Throw an exception here
- //* DEBUG: */ return;
- throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
- } // END - if
-
- // Shall we encrypt the cookie?
- if ($encrypted === true) {
- } // END - if
-
- // For slow browsers set the cookie array element first
- $_COOKIE[$cookieName] = $cookieValue;
-
- // Get all config entries
- if (is_null($expires)) {
- $expires = (time() + $this->getConfigInstance()->readConfig('cookie_expire'));
- } // END - if
-
- $path = $this->getConfigInstance()->readConfig('cookie_path');
- $domain = $this->getConfigInstance()->readConfig('cookie_domain');
-
- setcookie($cookieName, $cookieValue, $expires);
- //, $path, $domain, (isset($_SERVER['HTTPS']))
- return;
-
- // Now construct the full header
- $cookieString = $cookieName . "=" . $cookieValue . "; ";
- $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT";
- // $cookieString .= "; path=".$path."; domain=".$domain;
-
- // Set the cookie as a header
- $this->cookies[$cookieName] = $cookieString;
- }
-
- /**
- * Redirect to a configured URL. The URL can be absolute or relative. In
- * case of relative URL it will be extended automatically.
- *
- * @param $configEntry The configuration entry which holds our URL
- * @return void
- * @throws ResponseHeadersAlreadySentException If headers are already sent
- */
- public function redirectToConfiguredUrl ($configEntry) {
- // Is the header not yet sent?
- if (headers_sent()) {
- // Throw an exception here
- throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
- } // END - if
-
- // Get the url from config
- $url = $this->getConfigInstance()->readConfig($configEntry);
-
- // Do we have a "http" in front of the URL?
- if (substr(strtolower($url), 0, 4) != "http") {
- // Is there a / in front of the relative URL?
- if (substr($url, 0, 1) == "/") $url = substr($url, 1);
-
- // No, then extend it with our base URL
- $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url;
- } // END - if
-
- // Add redirect header
- $this->addHeader("Location", $url);
-
- // Set correct response status
- $this->setResponseStatus("301 Moved Permanently");
-
- // Clear the body
- $this->setResponseBody("");
-
- // Flush the result
- $this->flushBuffer();
-
- // All done here...
- exit();
- }
-
- /**
- * Expires the given cookie if it is set
- *
- * @param $cookieName Cookie to expire
- * @return void
- */
- public function expireCookie ($cookieName) {
- // Is the cookie there?
- if (isset($_COOKIE[$cookieName])) {
- // Then expire it with 20 minutes past
- $this->addCookie($cookieName, "", false, (time() - 1200));
-
- // Remove it from array
- unset($_COOKIE[$cookieName]);
- } // END - if
- }
-
- /**
- * Refreshs a given cookie. This will make the cookie live longer
- *
- * @param $cookieName Cookie to refresh
- * @return void
- */
- public function refreshCookie ($cookieName) {
- // Only update existing cookies
- if (isset($_COOKIE[$cookieName])) {
- // Update the cookie
- $this->addCookie($cookieName, $_COOKIE[$cookieName], false);
- } // END - if
- }
-
- /**
- * Getter for default command
- *
- * @return $defaultCommand Default command for this response
- */
- public function getDefaultCommand () {
- $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command');
- return $defaultCommand;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A class for an image response on an HTTP request
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * 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/>.
- *
- * The extended headers are taken from phpMyAdmin setup tool, written by
- * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
- */
-class ImageResponse extends BaseFrameworkSystem implements Responseable {
- /**
- * Response status
- */
- private $responseStatus = "200 OK";
-
- /**
- * Array with all headers
- */
- private $responseHeaders = array();
-
- /**
- * Cookies we shall sent out
- */
- private $cookies = array();
-
- /**
- * Body of the response
- */
- private $responseBody = "";
-
- /**
- * Fatal resolved messages from filters and so on
- */
- private $fatalMessages = array();
-
- /**
- * Instance of the image
- */
- private $imageInstance = null;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
- }
-
- /**
- * Creates an object of this class
- *
- * @param $appInstance An instance of a manageable application
- * @return $responseInstance A prepared instance of this class
- */
- public final static function createImageResponse (ManageableApplication $appInstance) {
- // Get a new instance
- $responseInstance = new ImageResponse();
-
- // Set the application instance
- $responseInstance->setApplicationInstance($appInstance);
-
- // Initialize the template engine here
- $responseInstance->initTemplateEngine($appInstance);
-
- // Return the prepared instance
- return $responseInstance;
- }
-
- /**
- * Setter for status
- *
- * @param $status New response status
- * @return void
- */
- public final function setResponseStatus ($status) {
- $this->responseStatus = (string) $status;
- }
-
- /**
- * Add header element
- *
- * @param $name Name of header element
- * @param $value Value of header element
- * @return void
- */
- public final function addHeader ($name, $value) {
- $this->responseHeaders[$name] = $value;
- }
-
- /**
- * Reset the header array
- *
- * @return void
- */
- public final function resetResponseHeaders () {
- $this->responseHeaders = array();
- }
-
- /**
- * "Writes" data to the response body
- *
- * @param $output Output we shall sent in the HTTP response
- * @return void
- */
- public function writeToBody ($output) {
- $this->responseBody .= $output;
- }
-
- /**
- * Sets the response body to something new
- *
- * @param $output Output we shall sent in the HTTP response
- * @return void
- */
- public function setResponseBody ($output) {
- $this->responseBody = $output;
- }
-
- /**
- * Flushs the cached HTTP response to the outer world
- *
- * @param $force Wether we shall force the output or abort if headers are
- * already sent with an exception
- * @return void
- * @todo Add support for fatal messages in image response
- * @throws ResponseHeadersAlreadySentException Thrown if headers are
- * already sent
- */
- public function flushBuffer ($force=false) {
- if ((headers_sent()) && (!$force)) {
- // Headers are already sent!
- throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
- } elseif (!headers_sent()) {
- // Send headers out
- header("HTTP/1.1 {$this->responseStatus}");
-
- // Used later
- $now = gmdate('D, d M Y H:i:s') . ' GMT';
-
- // General header for no caching
- $this->addHeader('Expired', $now); // rfc2616 - Section 14.21
- $this->addHeader('Last-Modified', $now);
- $this->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
- $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0
- $this->addHeader('Content-type', 'image/'.$this->imageInstance->getImageType());
-
- // Define the charset to be used
- //$this->addHeader('Content-Type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->readConfig('header_charset')));
-
- foreach ($this->responseHeaders as $name=>$value) {
- header("{$name}: {$value}");
- } // END - foreach
-
- // Send cookies out?
- if (count($this->cookies) > 0) {
- // Send all cookies
- $cookieString = implode(" ", $this->cookies);
- header("Set-Cookie: {$cookieString}");
-
- // Remove them all
- $this->cookies = array();
- } // END - if
- }
-
- // Are there some error messages?
- if (count($this->fatalMessages) == 0) {
- // Get image content from cache
- $imageContent = $this->imageInstance->getContent();
- die($imageContent);
- } else {
- // Display all error messages
- $this->partialStub("Fatal messages are currently unsupported in image response.");
- }
-
- // Clear response header and body
- $this->setResponseBody("");
- $this->resetResponseHeaders();
- }
-
- /**
- * Initializes the template engine instance
- *
- * @param $appInstance An instance of a manageable application
- * @return void
- */
- public final function initTemplateEngine (ManageableApplication $appInstance) {
- // Get config instance
- $cfg = $this->getConfigInstance();
-
- // Set new template engine
- $cfg->setConfigEntry('template_class' , $cfg->readConfig('image_template_class'));
- $cfg->setConfigEntry('raw_template_extension' , ".img");
- $cfg->setConfigEntry('code_template_extension', ".itp");
- $cfg->setConfigEntry('tpl_base_path' , "templates/images/");
- $cfg->setConfigEntry('code_template_type' , "image");
-
- // Get a prepared instance
- $this->setTemplateInstance($this->prepareTemplateInstance($appInstance));
- }
-
- /**
- * Adds a fatal message id to the response. The added messages can then be
- * processed and outputed to the world
- *
- * @param $messageId The message id we shall add
- * @return void
- */
- public final function addFatalMessage ($messageId) {
- // Adds the resolved message id to the fatal message list
- $this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId);
- }
-
- /**
- * Adds a cookie to the response
- *
- * @param $cookieName Cookie's name
- * @param $cookieValue Value to store in the cookie
- * @param $encrypted Do some extra encryption on the value
- * @param $expires Timestamp of expiration (default: configured)
- * @return void
- * @throws ResponseHeadersAlreadySentException If headers are already sent
- * @todo Encryption of cookie data not yet supported.
- * @todo Why are these parameters conflicting?
- * @todo If the return statement is removed and setcookie() commented out,
- * @todo this will send only one cookie out, the first one.
- */
- public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) {
- // Are headers already sent?
- if (headers_sent()) {
- // Throw an exception here
- throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
- } // END - if
-
- // Shall we encrypt the cookie?
- if ($encrypted === true) {
- } // END - if
-
- // For slow browsers set the cookie array element first
- $_COOKIE[$cookieName] = $cookieValue;
-
- // Get all config entries
- if (is_null($expires)) {
- $expires = (time() + $this->getConfigInstance()->readConfig('cookie_expire'));
- } // END - if
-
- $path = $this->getConfigInstance()->readConfig('cookie_path');
- $domain = $this->getConfigInstance()->readConfig('cookie_domain');
-
- setcookie($cookieName, $cookieValue, $expires);
- //, $path, $domain, (isset($_SERVER['HTTPS']))
- return;
-
- // Now construct the full header
- $cookieString = $cookieName . "=" . $cookieValue . "; ";
- $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT";
- // $cookieString .= "; path=".$path."; domain=".$domain;
-
- // Set the cookie as a header
- $this->cookies[$cookieName] = $cookieString;
- }
-
- /**
- * Redirect to a configured URL. The URL can be absolute or relative. In
- * case of relative URL it will be extended automatically.
- *
- * @param $configEntry The configuration entry which holds our URL
- * @return void
- * @throws ResponseHeadersAlreadySentException If headers are already sent
- */
- public function redirectToConfiguredUrl ($configEntry) {
- // Is the header not yet sent?
- if (headers_sent()) {
- // Throw an exception here
- throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
- } // END - if
-
- // Get the url from config
- $url = $this->getConfigInstance()->readConfig($configEntry);
-
- // Do we have a "http" in front of the URL?
- if (substr(strtolower($url), 0, 4) != "http") {
- // Is there a / in front of the relative URL?
- if (substr($url, 0, 1) == "/") $url = substr($url, 1);
-
- // No, then extend it with our base URL
- $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url;
- } // END - if
-
- // Add redirect header
- $this->addHeader("Location", $url);
-
- // Set correct response status
- $this->setResponseStatus("301 Moved Permanently");
-
- // Clear the body
- $this->setResponseBody("");
-
- // Flush the result
- $this->flushBuffer();
-
- // All done here...
- exit();
- }
-
- /**
- * Expires the given cookie if it is set
- *
- * @param $cookieName Cookie to expire
- * @return void
- */
- public function expireCookie ($cookieName) {
- // Is the cookie there?
- if (isset($_COOKIE[$cookieName])) {
- // Then expire it with 20 minutes past
- $this->addCookie($cookieName, "", false, (time() - 1200));
-
- // Remove it from array
- unset($_COOKIE[$cookieName]);
- } // END - if
- }
-
- /**
- * Refreshs a given cookie. This will make the cookie live longer
- *
- * @param $cookieName Cookie to refresh
- * @return void
- */
- public function refreshCookie ($cookieName) {
- // Only update existing cookies
- if (isset($_COOKIE[$cookieName])) {
- // Update the cookie
- $this->addCookie($cookieName, $_COOKIE[$cookieName], false);
- } // END - if
- }
-
- /**
- * Setter for image instanxe
- *
- * @param $imageInstance An instance of an image
- * @return void
- */
- public final function setImageInstance (BaseImage $imageInstance) {
- $this->imageInstance = $imageInstance;
- }
-
- /**
- * Getter for default command
- *
- * @return $defaultCommand Default command for this response
- */
- public function getDefaultCommand () {
- $defaultCommand = $this->getConfigInstance()->readConfig('default_image_command');
- return $defaultCommand;
- }
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A class for an HTTP response on an HTTP request
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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/>.
+ *
+ * The extended headers are taken from phpMyAdmin setup tool, written by
+ * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
+ */
+class HttpResponse extends BaseResponse implements Responseable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an object of this class
+ *
+ * @param $appInstance An instance of a manageable application
+ * @return $responseInstance A prepared instance of this class
+ */
+ public final static function createHttpResponse (ManageableApplication $appInstance) {
+ // Get a new instance
+ $responseInstance = new HttpResponse();
+
+ // Set the application instance
+ $responseInstance->setApplicationInstance($appInstance);
+
+ // Initialize the template engine here
+ $responseInstance->initTemplateEngine($appInstance);
+
+ // Return the prepared instance
+ return $responseInstance;
+ }
+
+ /**
+ * Initializes the template engine instance
+ *
+ * @param $appInstance An instance of a manageable application
+ * @return void
+ */
+ public final function initTemplateEngine (ManageableApplication $appInstance) {
+ $this->setTemplateInstance($this->prepareTemplateInstance($appInstance));
+ }
+
+ /**
+ * Adds a cookie to the response
+ *
+ * @param $cookieName Cookie's name
+ * @param $cookieValue Value to store in the cookie
+ * @param $encrypted Do some extra encryption on the value
+ * @param $expires Timestamp of expiration (default: configured)
+ * @return void
+ * @throws ResponseHeadersAlreadySentException If headers are already sent
+ * @todo Encryption of cookie data not yet supported.
+ * @todo Why are these parameters conflicting?
+ * @todo If the return statement is removed and setcookie() commented out,
+ * @todo this will send only one cookie out, the first one.
+ */
+ public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) {
+ //* DEBUG: */ echo $cookieName."=".$cookieValue."<br />\n";
+ // Are headers already sent?
+ if (headers_sent()) {
+ // Throw an exception here
+ //* DEBUG: */ return;
+ throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
+ } // END - if
+
+ // Shall we encrypt the cookie?
+ if ($encrypted === true) {
+ } // END - if
+
+ // For slow browsers set the cookie array element first
+ $_COOKIE[$cookieName] = $cookieValue;
+
+ // Get all config entries
+ if (is_null($expires)) {
+ $expires = (time() + $this->getConfigInstance()->readConfig('cookie_expire'));
+ } // END - if
+
+ $path = $this->getConfigInstance()->readConfig('cookie_path');
+ $domain = $this->getConfigInstance()->readConfig('cookie_domain');
+
+ setcookie($cookieName, $cookieValue, $expires);
+ //, $path, $domain, (isset($_SERVER['HTTPS']))
+ return;
+
+ // Now construct the full header
+ $cookieString = $cookieName . "=" . $cookieValue . "; ";
+ $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT";
+ // $cookieString .= "; path=".$path."; domain=".$domain;
+
+ // Set the cookie as a header
+ $this->cookies[$cookieName] = $cookieString;
+ }
+
+ /**
+ * Redirect to a configured URL. The URL can be absolute or relative. In
+ * case of relative URL it will be extended automatically.
+ *
+ * @param $configEntry The configuration entry which holds our URL
+ * @return void
+ * @throws ResponseHeadersAlreadySentException If headers are already sent
+ */
+ public function redirectToConfiguredUrl ($configEntry) {
+ // Is the header not yet sent?
+ if (headers_sent()) {
+ // Throw an exception here
+ throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
+ } // END - if
+
+ // Assign application data
+ $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance());
+
+ // Get the url from config
+ $url = $this->getConfigInstance()->readConfig($configEntry);
+
+ // Compile the URL
+ $url = $this->getTemplateInstance()->compileRawCode($url);
+
+ // Do we have a "http" in front of the URL?
+ if (substr(strtolower($url), 0, 4) != "http") {
+ // Is there a / in front of the relative URL?
+ if (substr($url, 0, 1) == "/") $url = substr($url, 1);
+
+ // No, then extend it with our base URL
+ $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url;
+ } // END - if
+
+ // Add redirect header
+ $this->addHeader("Location", $url);
+
+ // Set correct response status
+ $this->setResponseStatus("301 Moved Permanently");
+
+ // Clear the body
+ $this->setResponseBody("");
+
+ // Flush the result
+ $this->flushBuffer();
+
+ // All done here...
+ exit();
+ }
+
+ /**
+ * Expires the given cookie if it is set
+ *
+ * @param $cookieName Cookie to expire
+ * @return void
+ */
+ public function expireCookie ($cookieName) {
+ // Is the cookie there?
+ if (isset($_COOKIE[$cookieName])) {
+ // Then expire it with 20 minutes past
+ $this->addCookie($cookieName, "", false, (time() - 1200));
+
+ // Remove it from array
+ unset($_COOKIE[$cookieName]);
+ } // END - if
+ }
+
+ /**
+ * Refreshs a given cookie. This will make the cookie live longer
+ *
+ * @param $cookieName Cookie to refresh
+ * @return void
+ */
+ public function refreshCookie ($cookieName) {
+ // Only update existing cookies
+ if (isset($_COOKIE[$cookieName])) {
+ // Update the cookie
+ $this->addCookie($cookieName, $_COOKIE[$cookieName], false);
+ } // END - if
+ }
+
+ /**
+ * Getter for default command
+ *
+ * @return $defaultCommand Default command for this response
+ */
+ public function getDefaultCommand () {
+ $defaultCommand = $this->getConfigInstance()->readConfig('default_web_command');
+ return $defaultCommand;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A class for an image response on an HTTP request
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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/>.
+ *
+ * The extended headers are taken from phpMyAdmin setup tool, written by
+ * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
+ */
+class ImageResponse extends BaseResponse implements Responseable {
+ /**
+ * Instance of the image
+ */
+ private $imageInstance = null;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an object of this class
+ *
+ * @param $appInstance An instance of a manageable application
+ * @return $responseInstance A prepared instance of this class
+ */
+ public final static function createImageResponse (ManageableApplication $appInstance) {
+ // Get a new instance
+ $responseInstance = new ImageResponse();
+
+ // Set the application instance
+ $responseInstance->setApplicationInstance($appInstance);
+
+ // Initialize the template engine here
+ $responseInstance->initTemplateEngine($appInstance);
+
+ // Return the prepared instance
+ return $responseInstance;
+ }
+
+ /**
+ * Initializes the template engine instance
+ *
+ * @param $appInstance An instance of a manageable application
+ * @return void
+ */
+ public final function initTemplateEngine (ManageableApplication $appInstance) {
+ // Get config instance
+ $cfg = $this->getConfigInstance();
+
+ // Set new template engine
+ $cfg->setConfigEntry('template_class' , $cfg->readConfig('image_template_class'));
+ $cfg->setConfigEntry('raw_template_extension' , ".img");
+ $cfg->setConfigEntry('code_template_extension', ".itp");
+ $cfg->setConfigEntry('tpl_base_path' , "templates/images/");
+ $cfg->setConfigEntry('code_template_type' , "image");
+
+ // Get a prepared instance
+ $this->setTemplateInstance($this->prepareTemplateInstance($appInstance));
+ }
+
+ /**
+ * Adds a cookie to the response
+ *
+ * @param $cookieName Cookie's name
+ * @param $cookieValue Value to store in the cookie
+ * @param $encrypted Do some extra encryption on the value
+ * @param $expires Timestamp of expiration (default: configured)
+ * @return void
+ * @throws ResponseHeadersAlreadySentException If headers are already sent
+ * @todo Encryption of cookie data not yet supported.
+ * @todo Why are these parameters conflicting?
+ * @todo If the return statement is removed and setcookie() commented out,
+ * @todo this will send only one cookie out, the first one.
+ */
+ public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) {
+ // Are headers already sent?
+ if (headers_sent()) {
+ // Throw an exception here
+ throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
+ } // END - if
+
+ // Shall we encrypt the cookie?
+ if ($encrypted === true) {
+ } // END - if
+
+ // For slow browsers set the cookie array element first
+ $_COOKIE[$cookieName] = $cookieValue;
+
+ // Get all config entries
+ if (is_null($expires)) {
+ $expires = (time() + $this->getConfigInstance()->readConfig('cookie_expire'));
+ } // END - if
+
+ $path = $this->getConfigInstance()->readConfig('cookie_path');
+ $domain = $this->getConfigInstance()->readConfig('cookie_domain');
+
+ setcookie($cookieName, $cookieValue, $expires);
+ //, $path, $domain, (isset($_SERVER['HTTPS']))
+ return;
+
+ // Now construct the full header
+ $cookieString = $cookieName . "=" . $cookieValue . "; ";
+ $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT";
+ // $cookieString .= "; path=".$path."; domain=".$domain;
+
+ // Set the cookie as a header
+ $this->cookies[$cookieName] = $cookieString;
+ }
+
+ /**
+ * Redirect to a configured URL. The URL can be absolute or relative. In
+ * case of relative URL it will be extended automatically.
+ *
+ * @param $configEntry The configuration entry which holds our URL
+ * @return void
+ * @throws ResponseHeadersAlreadySentException If headers are already sent
+ */
+ public function redirectToConfiguredUrl ($configEntry) {
+ // Is the header not yet sent?
+ if (headers_sent()) {
+ // Throw an exception here
+ throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
+ } // END - if
+
+ // Assign application data
+ $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance());
+
+ // Get the url from config
+ $url = $this->getConfigInstance()->readConfig($configEntry);
+
+ // Compile the URL
+ $url = $this->getTemplateInstance()->compileRawCode($url);
+
+ // Do we have a "http" in front of the URL?
+ if (substr(strtolower($url), 0, 4) != "http") {
+ // Is there a / in front of the relative URL?
+ if (substr($url, 0, 1) == "/") $url = substr($url, 1);
+
+ // No, then extend it with our base URL
+ $url = $this->getConfigInstance()->readConfig('base_url') . "/" . $url;
+ } // END - if
+
+ // Add redirect header
+ $this->addHeader("Location", $url);
+
+ // Set correct response status
+ $this->setResponseStatus("301 Moved Permanently");
+
+ // Clear the body
+ $this->setResponseBody("");
+
+ // Flush the result
+ $this->flushBuffer();
+
+ // All done here...
+ exit();
+ }
+
+ /**
+ * Flushs the cached HTTP response to the outer world
+ *
+ * @param $force Wether we shall force the output or abort if headers are
+ * already sent with an exception
+ * @return void
+ */
+ public function flushBuffer ($force = false) {
+ // Finish the image
+ $this->getImageInstance()->finishImage();
+
+ // Get image content
+ $content = $this->getImageInstance()->getContent();
+
+ // Set it as response body
+ $this->setResponseBody($content);
+
+ // Set content type
+ $this->addHeader('Content-type', "image/".$this->getImageInstance()->getImageType());
+
+ // Call parent method
+ parent::flushBuffer($force);
+ }
+
+ /**
+ * Expires the given cookie if it is set
+ *
+ * @param $cookieName Cookie to expire
+ * @return void
+ */
+ public function expireCookie ($cookieName) {
+ // Is the cookie there?
+ if (isset($_COOKIE[$cookieName])) {
+ // Then expire it with 20 minutes past
+ $this->addCookie($cookieName, "", false, (time() - 1200));
+
+ // Remove it from array
+ unset($_COOKIE[$cookieName]);
+ } // END - if
+ }
+
+ /**
+ * Refreshs a given cookie. This will make the cookie live longer
+ *
+ * @param $cookieName Cookie to refresh
+ * @return void
+ */
+ public function refreshCookie ($cookieName) {
+ // Only update existing cookies
+ if (isset($_COOKIE[$cookieName])) {
+ // Update the cookie
+ $this->addCookie($cookieName, $_COOKIE[$cookieName], false);
+ } // END - if
+ }
+
+ /**
+ * Setter for image instanxe
+ *
+ * @param $imageInstance An instance of an image
+ * @return void
+ */
+ public final function setImageInstance (BaseImage $imageInstance) {
+ $this->imageInstance = $imageInstance;
+ }
+
+ /**
+ * Getter for image instanxe
+ *
+ * @return $imageInstance An instance of an image
+ */
+ public final function getImageInstance () {
+ return $this->imageInstance;
+ }
+
+ /**
+ * Getter for default command
+ *
+ * @return $defaultCommand Default command for this response
+ */
+ public function getDefaultCommand () {
+ $defaultCommand = $this->getConfigInstance()->readConfig('default_image_command');
+ return $defaultCommand;
+ }
+}
+
+// [EOF]
+?>
$entryKey = $this->key();
// Now get the update criteria array and update all entries
- foreach ($updateInstance->getUpdateCriteria() as $criteriaKey=>$criteriaValue) {
+ foreach ($updateInstance->getUpdateCriteria() as $criteriaKey => $criteriaValue) {
// Update data
$this->resultArray['rows'][$entryKey][$criteriaKey] = $criteriaValue;
$currentEntry = $this->current();
// Walk only through out-dated columns
- foreach ($this->outDated as $key=>$dummy) {
+ foreach ($this->outDated as $key => $dummy) {
// Does this key exist?
//* DEBUG: */ echo "outDated: {$key}<br />\n";
if (isset($currentEntry[$key])) {
*/
private $varStack = array();
- /**
- * Configuration variables in a simple array
- */
- private $configVariables = array();
-
/**
* Loaded templates for recursive protection and detection
*/
// Is the group there?
if (isset($this->varStack[$this->currGroup])) {
// Now search for it
- foreach ($this->varStack[$this->currGroup] as $idx=>$currEntry) {
+ foreach ($this->varStack[$this->currGroup] as $idx => $currEntry) {
+ //* DEBUG: */ echo __METHOD__.":currGroup={$this->currGroup},idx={$idx},currEntry={$currEntry['name']},var={$var}<br />\n";
// Is the entry found?
if ($currEntry['name'] == $var) {
// Found!
+ //* DEBUG: */ echo __METHOD__.":FOUND!<br />\n";
$found = $idx;
break;
} // END - if
// Did we find some variables?
if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) {
// Initialize all missing variables
- foreach ($variableMatches[3] as $key=>$var) {
+ foreach ($variableMatches[3] as $key => $var) {
// Variable name
$varName = $variableMatches[1][$key];
if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
// Template not found, but maybe variable assigned?
+ //* DEBUG: */ echo __METHOD__.":template={$template}<br />\n";
if ($this->isVariableAlreadySet($template) !== false) {
// Use that content here
$this->loadedRawData[$template] = $this->readVariable($template);
+ // Recursive protection:
+ $this->loadedTemplates[] = $template;
+ } elseif (isset($this->varStack['config'][$template])) {
+ // Use that content here
+ $this->loadedRawData[$template] = $this->varStack['config'][$template];
+
// Recursive protection:
$this->loadedTemplates[] = $template;
} else {
if (in_array($template, $this->compiledTemplates)) {
// Abort here...
return;
- }
+ } // END - if
// Remember this template being compiled
$this->compiledTemplates[] = $template;
*/
private function insertAllTemplates (array $templateMatches) {
// Run through all loaded codes
- foreach ($this->loadedRawData as $template=>$code) {
+ foreach ($this->loadedRawData as $template => $code) {
// Search for the template
$foundIndex = array_search($template, $templateMatches[1]);
*/
private function assignAllVariables (array $varMatches) {
// Search for all variables
- foreach ($varMatches[1] as $key=>$var) {
+ foreach ($varMatches[1] as $key => $var) {
// Detect leading equals
if (substr($varMatches[2][$key], 0, 1) == "=") {
if (count($this->loadedRawData) > 0) {
// Then compile all!
- foreach ($this->loadedRawData as $template=>$code) {
+ foreach ($this->loadedRawData as $template => $code) {
// Is this template already compiled?
if (in_array($template, $this->compiledTemplates)) {
*/
private function insertRawTemplates () {
// Load all templates
- foreach ($this->rawTemplates as $template=>$content) {
+ foreach ($this->rawTemplates as $template => $content) {
// Set the template as a variable with the content
$this->assignVariable($template, $content);
}
*/
public function assignConfigVariable ($var) {
// Sweet and simple...
- $this->configVariables[$var] = $this->getConfigInstance()->readConfig($var);
+ //* DEBUG: */ echo __METHOD__.":var={$var}<br />\n";
+ $this->varStack['config'][$var] = $this->getConfigInstance()->readConfig($var);
}
/**
/**
* Load a specified code template into the engine
*
- * @param $template The code template we shall load which is
+ * @param $template The code template we shall load which is
* located in "code" by default
* @return void
*/
// Transfer it's name/value combination to the $content array
//* DEBUG: */ echo $currVariable['name']."=<pre>".htmlentities($currVariable['value'])."</pre>\n";
$dummy[$currVariable['name']] = $currVariable['value'];
-
}// END - if
- // Set the new variable (don't remove the second dollar !)
+ // Set the new variable (don't remove the second dollar!)
$$validVar = $dummy;
// Prepare all configuration variables
- $config = $this->configVariables;
+ $config = null;
+ if (isset($this->varStack['config'])) {
+ $config = $this->varStack['config'];
+ } // END - if
// Remove some variables
unset($idx);
// Get version number and assign it
$this->assignVariable('app_version' , $appInstance->getAppVersion());
+
+ // Assign extra application-depending data
+ $appInstance->assignExtraTemplateData($this);
}
/**
// Construct the request string
$requestString = $this->config['api_url'] . $scriptName."?api_id=".$this->config['wernis_api_id']."&api_key=".$this->config['wernis_api_key'];
- foreach ($requestData as $key=>$value) {
+ foreach ($requestData as $key => $value) {
$requestString .= "&".$key."=".$value;
}
$cfg->setConfigEntry('db_type', "local");
// CFG: LOCAL-DB-PATH
-$cfg->setConfigEntry('local_db_path', $cfg->readConfig('base_path', "db/"));
+$cfg->setConfigEntry('local_db_path', $cfg->readConfig('base_path') . "db/");
// CFG: TIME-ZONE
$cfg->setDefaultTimezone("Europe/Berlin");
$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
// CFG: APPLICATION-PATH
-$cfg->setConfigEntry('application_path', "application");
+$cfg->setConfigEntry('application_path', $cfg->readConfig('base_path') . "application/");
// CFG: COMPILE-OUTPUT-PATH
$cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
// CFG: WEB-CONTENT-TYPE
$cfg->setConfigEntry('web_content_type', "text/html");
-// CFG: HEADER-CHARSET
-$cfg->setConfigEntry('header_charset', "utf-8");
-
// CFG: VALID-TEMPLATE-VARIABLE
$cfg->setConfigEntry('tpl_valid_var', "content");
*/
// Initialize layer
-$layer = null;
+$layerInstance = null;
// Get config instance
$cfg = FrameworkConfiguration::getInstance();
// Prepare database instance
try {
- $db = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $layer);
+ $db = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $layerInstance);
} catch (NullPointerException $e) {
ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
$e->getMessage()
// Zum Testen speichern wir in lokale Dateien (LocalFileDatabase)
try {
- $layer = LocalFileDatabase::createLocalFileDatabase(FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance());
+ $layerInstance = LocalFileDatabase::createLocalFileDatabase(FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance());
} catch (SavePathIsEmptyException $e) {
ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong>",
$e->getMessage()
// Construct the FQFN for the cache
if (!defined('DEVELOPER')) {
- $this->listCacheFQFN = $this->cfgInstance->readConfig('base_path') . $this->cfgInstance->readConfig('local_db_path') . "list-" . $this->cfgInstance->readConfig('app_name') . ".cache";
- $this->classCacheFQFN = $this->cfgInstance->readConfig('base_path') . $this->cfgInstance->readConfig('local_db_path') . "class-" . $this->cfgInstance->readConfig('app_name') . ".cache";
+ $this->listCacheFQFN = $this->cfgInstance->readConfig('local_db_path') . "list-" . $this->cfgInstance->readConfig('app_name') . ".cache";
+ $this->classCacheFQFN = $this->cfgInstance->readConfig('local_db_path') . "class-" . $this->cfgInstance->readConfig('app_name') . ".cache";
} // END - if
// Set suffix and prefix from configuration
*/
private function includeExtraConfigs () {
// Run through all class names (should not be much)
- foreach ($this->classes as $fileName=>$fqfn) {
+ foreach ($this->classes as $fileName => $fqfn) {
// Is this a config?
if (substr($fileName, 0, $this->prefixLen) == $this->prefix) {
// Then include it
}
// Generate a FQFN for the helper class
- $fqfn = sprintf("%s%s/%s/%s%s",
- $cfg->readConfig('base_path'),
+ $fqfn = sprintf("%s%s/%s%s",
$cfg->readConfig('application_path'),
$cfg->readConfig('app_name'),
$inc,
// Get and prepare backtrace for output
$backtraceArray = debug_backtrace();
$backtrace = "";
- foreach ($backtraceArray as $key=>$trace) {
+ foreach ($backtraceArray as $key => $trace) {
if (!isset($trace['file'])) $trace['file'] = __FILE__;
if (!isset($trace['line'])) $trace['line'] = __LINE__;
if (!isset($trace['args'])) $trace['args'] = array();
$backtrace .= "<span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span><br />";
} // END - foreach
+ // Init application instance
+ $appInstance = null;
+
+ // Is the class there?
+ if (class_exists('ApplicationHelper')) {
+ // Get application instance
+ $appInstance = ApplicationHelper::getInstance();
+
+ // Assign application data
+ $templateInstance->assignApplicationData($appInstance);
+ } // END - if
+
// Assign variables
$templateInstance->assignVariable('message', $message);
$templateInstance->assignVariable('code', $code);
<meta name="keywords" content="$config[meta_keywords]" />
<meta name="robots" content="index,follow" />
<meta name="description" content="$config[meta_description]" />
- <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+ <meta http-equiv="content-type" content="text/html; charset={?header_charset?}" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="language" content="de" />