}
/**
- * Aquires the IP address of this host by reading the /etc/hostname file and solving it
+ * Aquires the IP address of this host by reading the /etc/hostname file
+ * and solving it. It is now stored in configuration
*
- * @return $ip The resolved IP address
+ * @return void
*/
public static function acquireSelfIPAddress () {
// Local IP by default
));
}
- // Return the IP address
- return $ip;
+ // Set it in configuration
+ FrameworkConfiguration::getInstance()->setServerAddress($ip);
}
/**
} // END - if
// Is the first element "index.php" ?
- if ($args[0] == "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);
+ $argArray = explode('=', $arg);
// Is the second one set?
if (!isset($argArray[1])) {
// Add it likewise, but empty value
- $this->setRequestElement($argArray[0], "");
+ $this->setRequestElement($argArray[0], '');
} else {
// Set a name=value pair escaped and secured
$this->setRequestElement($argArray[0], escapeshellcmd($argArray[1]));
* @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 () {
- return "LOCAL";
+ return 'LOCAL';
}
/**
// Shall we encrypt the cookie?
if ($encrypted === true) {
+ // Unsupported at the moment
+ $this->partialStub('Encryption is unsupported at the moment.');
} // END - if
// For slow browsers set the cookie array element first
// Now construct the full header
$cookieString = $cookieName . '=' . $cookieValue . '; ';
- $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT";
+ $cookieString .= 'expires=' . date('D, d-F-Y H:i:s', $expires) . ' GMT';
// $cookieString .= "; path=".$path."; domain=".$domain;
// Set the cookie as a header
$this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance());
// Get the url from config
- $url = $this->getConfigInstance()->getConfigEntry($configEntry . "_url");
+ $url = $this->getConfigInstance()->getConfigEntry($configEntry . '_url');
// Compile the URL
$url = $this->getTemplateInstance()->compileRawCode($url);
// Shall we encrypt the cookie?
if ($encrypted === true) {
+ // Unsupported at the moment
+ $this->partialStub('Encryption is unsupported at the moment.');
} // END - if
// For slow browsers set the cookie array element first
mt_srand((double) sqrt(microtime() * 100000000 * $this->extraNumber));
// Set the server IP to cluster
- $serverIp = "cluster";
+ $serverIp = 'cluster';
// Do we have a single server?
if ($this->getConfigInstance()->getConfigEntry('is_single_server') == 'Y') {
// Then use that IP for extra security
- $serverIp = getenv('SERVER_ADDR');
+ $serverIp = $this->getConfigInstance()->getServerAddress();
} // END - if
// Yet-another fixed salt. This is not dependend on server software or date
$cfg->setConfigEntry('cookie_domain', $cfg->detectDomain()); // Is mostly the same...
// CFG: COOKIE-SSL
-$cfg->setConfigEntry('cookie_ssl', (isset($_SERVER['HTTPS'])));
+$cfg->setConfigEntry('cookie_ssl', $cfg->isHttpSecured());
// CFG: CRYPT-FIXED-SALT
$cfg->setConfigEntry('crypt_fixed_salt', 'N');
*/
public final function setDefaultTimezone ($zone) {
// At least 5.1.0 is required for this!
- if (version_compare(phpversion(), "5.1.0")) {
- @date_default_timezone_set($zone);
+ if (version_compare(phpversion(), '5.1.0')) {
+ date_default_timezone_set($zone);
} // END - if
}
$enableQuotes = (boolean) $enableQuotes;
// Set it
- @set_magic_quotes_runtime($enableQuotes);
+ set_magic_quotes_runtime($enableQuotes);
}
/**
*
* @param $arrayObject The array object with all include files
* @return void
+ * @deprecated
+ * @see ClassLoader
*/
private function loadIncludes (ArrayObject $arrayObject) {
// Load only if there are includes defined
return get_class($this);
}
+ /**
+ * Setter for SERVER_ADDR
+ *
+ * @param $serverAddress New SERVER_ADDR value to set
+ * @return void
+ */
+ public function setServerAddress ($serverAddress) {
+ $this->setConfigEntry('server_addr', (string) $serverAddress);
+ }
+
+ /**
+ * Getter for SERVER_ADDR
+ *
+ * @return $serverAddress New SERVER_ADDR value to set
+ */
+ public function getServerAddress () {
+ return $this->getConfigEntry('server_addr');
+ }
+
+ /**
+ * Detects the HTTPS flag
+ *
+ * @return $https The detected HTTPS flag or null if failed
+ */
+ public function detectHttpSecured () {
+ // Default is null
+ $https = null;
+
+ // Is HTTPS set?
+ if ($this->isHttpSecured()) {
+ // Then use it
+ $https = $_SERVER['HTTPS'];
+ } // END - if
+
+ // Return it
+ return $https;
+ }
+
+ /**
+ * Checks wether HTTPS is set in $_SERVER
+ *
+ * @return $isset Wether HTTPS is set
+ */
+ public function isHttpSecured () {
+ return (isset($_SERVER['HTTPS']));
+ }
+
/**
* Dectect and return the base URL for all URLs and forms
*
* @return $baseUrl Detected base URL
*/
- public function detectBaseUrl() {
+ public function detectBaseUrl () {
// Initialize the URL
$baseUrl = 'http';
// Do we have HTTPS?
- if (isset($_SERVER['HTTPS'])) {
+ if ($this->isHttpSecured()) {
// Add the >s< for HTTPS
$baseUrl .= 's';
} // END - if
require(FrameworkConfiguration::getInstance()->getConfigEntry('base_path') . 'inc/hooks.php');
// Does the user has an application specified?
+// @TODO Find a nicer OOP-ed way for this
if (!empty($_GET['app'])) {
// Set the application from string
$application = (string) $_GET['app'];