From 81bfbcd72e424060ea1223b49ad92fcfa150f361 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Mon, 6 Apr 2009 19:34:33 +0000
Subject: [PATCH] config.php partly solved, see #117

---
 .gitattributes                                |   6 +
 .gitignore                                    |   1 +
 admin.php                                     |   2 +-
 agb.php                                       |   2 +-
 beg.php                                       |  43 +-
 birthday_confirm.php                          |  27 +-
 click.php                                     |   2 +-
 confirm.php                                   |   2 +-
 css.php                                       |  10 +-
 debug.php                                     |   2 +-
 doubler.php                                   |   4 +-
 img.php                                       |   6 +-
 inc/config-functions.php                      |  50 +-
 inc/config-global.php                         |  81 +++
 inc/config-local.php.dist                     | 128 +++++
 inc/config.php                                | 172 +-----
 inc/databases.php                             |  14 +-
 inc/db/lib-mysql3.php                         |  47 +-
 inc/db/lib.php                                |  10 +-
 inc/doubler_send.php                          |   2 +-
 inc/extensions.php                            |   2 +-
 inc/extensions/ext-lead.php                   |  92 +++
 inc/extensions/ext-newsletter.php             |   4 +-
 inc/filters.php                               |   2 +-
 inc/footer.php                                |   8 +-
 inc/functions.php                             | 523 +++++-------------
 inc/header.php                                |  29 +-
 inc/inc-functions.php                         |   4 +-
 inc/install-inc.php                           | 134 +++--
 inc/language.php                              |  17 +-
 inc/language/bonus_de.php                     |   2 -
 inc/language/de.php                           |  10 +-
 inc/language/en.php                           |   6 +-
 inc/language/install_de.php                   |   3 +-
 inc/libs/admins_functions.php                 |   8 +-
 inc/libs/bonus_functions.php                  |  21 +-
 inc/libs/cache_functions.php                  |   4 +-
 inc/libs/doubler_functions.php                |   4 +-
 inc/libs/holiday_functions.php                |   4 +-
 inc/libs/html_mail_functions.php              |   6 +-
 inc/libs/rallye_functions.php                 |  26 +-
 inc/libs/register_functions.php               |   4 +-
 inc/libs/security_functions.php               |  14 +-
 inc/libs/sponsor_functions.php                |   2 +-
 inc/libs/surfbar_functions.php                |  28 +-
 inc/libs/user_functions.php                   |   6 +-
 inc/load_config.php                           |  66 +++
 inc/modules/admin.php                         |   4 +-
 inc/modules/admin/admin-inc.php               |  14 +-
 inc/modules/admin/overview-inc.php            |   4 +-
 inc/modules/admin/what-admin_add.php          |  17 +-
 inc/modules/admin/what-admins_edit.php        |   4 +-
 inc/modules/admin/what-admins_mails.php       |   2 +-
 inc/modules/admin/what-config_admin.php       |   4 +-
 inc/modules/admin/what-config_admins.php      |   4 +-
 inc/modules/admin/what-config_autopurge.php   |   4 +-
 inc/modules/admin/what-config_beg.php         | 119 ++--
 inc/modules/admin/what-config_birthday.php    |  20 +-
 inc/modules/admin/what-config_bonus.php       |  48 +-
 inc/modules/admin/what-config_cache.php       |  36 +-
 inc/modules/admin/what-config_doubler.php     |  31 +-
 inc/modules/admin/what-config_extensions.php  |   4 +-
 inc/modules/admin/what-config_holiday.php     |   6 +-
 inc/modules/admin/what-config_mediadata.php   |   2 +-
 inc/modules/admin/what-config_order.php       |  16 +-
 inc/modules/admin/what-config_other.php       |  46 +-
 inc/modules/admin/what-config_points.php      |   8 +-
 .../admin/what-config_rallye_prices.php       |   4 +-
 inc/modules/admin/what-config_refback.php     |   4 +-
 inc/modules/admin/what-config_removeip.php    |  32 +-
 inc/modules/admin/what-config_rewrite.php     |   4 +-
 inc/modules/admin/what-config_surfbar.php     |  24 +-
 inc/modules/admin/what-config_wernis.php      |   8 +-
 inc/modules/admin/what-del_holiday.php        |   4 +-
 inc/modules/admin/what-del_transfer.php       |   2 +-
 inc/modules/admin/what-email_archiv.php       |   6 +-
 inc/modules/admin/what-email_details.php      |   6 +-
 inc/modules/admin/what-extensions.php         |   2 +-
 inc/modules/admin/what-guest_add.php          |  17 +-
 inc/modules/admin/what-list_autopurge.php     |   6 +-
 inc/modules/admin/what-list_beg.php           |   4 +-
 inc/modules/admin/what-list_bonus.php         |  20 +-
 inc/modules/admin/what-list_holiday.php       |   6 +-
 inc/modules/admin/what-list_notifications.php |   4 +-
 inc/modules/admin/what-list_payouts.php       |   2 +-
 inc/modules/admin/what-list_primera.php       |   2 +-
 inc/modules/admin/what-list_rallyes.php       |   6 +-
 inc/modules/admin/what-list_refs.php          |   4 +-
 inc/modules/admin/what-list_sponsor.php       |  10 +-
 inc/modules/admin/what-list_task.php          |   2 +-
 inc/modules/admin/what-list_transfer.php      |   2 +-
 inc/modules/admin/what-list_unconfirmed.php   |   6 +-
 inc/modules/admin/what-list_user.php          |  12 +-
 inc/modules/admin/what-list_wernis.php        |   2 +-
 inc/modules/admin/what-logs.php               |  20 +-
 inc/modules/admin/what-mem_add.php            |   2 +-
 inc/modules/admin/what-refbanner.php          |   2 +-
 inc/modules/admin/what-send_newsletter.php    |   2 +-
 inc/modules/admin/what-surfbar_stats.php      |   2 +-
 inc/modules/admin/what-theme_check.php        |   2 +-
 inc/modules/admin/what-unlock_emails.php      |   2 +-
 inc/modules/admin/what-unlock_sponsor.php     |   4 +-
 inc/modules/admin/what-updates.php            |   2 +-
 inc/modules/admin/what-usage.php              |   4 +-
 inc/modules/guest/what-confirm.php            |   4 +-
 inc/modules/guest/what-login.php              |   2 +-
 inc/modules/guest/what-rallyes.php            |   4 +-
 inc/modules/guest/what-register.php           |   6 +-
 inc/modules/guest/what-stats.php              |   8 +-
 inc/modules/guest/what-top10.php              |   6 +-
 inc/modules/guest/what-wernis_portal.php      |   2 +-
 inc/modules/login.php                         |   2 +-
 inc/modules/member/what-beg2.php              |   2 +-
 inc/modules/member/what-bonus.php             |   2 +-
 inc/modules/member/what-categories.php        |   6 +-
 inc/modules/member/what-holiday.php           |   4 +-
 inc/modules/member/what-html_mail.php         |   4 +-
 inc/modules/member/what-newsletter.php        |   2 +-
 inc/modules/member/what-order.php             |   2 +-
 inc/modules/member/what-payout.php            |   2 +-
 inc/modules/member/what-primera.php           |   2 +-
 inc/modules/member/what-rallyes.php           |   4 +-
 inc/modules/member/what-stats.php             |   6 +-
 inc/modules/member/what-support.php           |   2 +-
 inc/modules/member/what-surfbar_list.php      |   4 +-
 inc/modules/member/what-transfer.php          |  10 +-
 inc/modules/member/what-wernis.php            |   2 +-
 inc/modules/sponsor/settings.php              |   4 +-
 inc/mysql-connect.php                         |  39 +-
 inc/mysql-manager.php                         |  33 +-
 inc/pool/pool-user.php                        |   6 +-
 inc/reset/reset_holiday.php                   |   6 +-
 inc/session.php                               |  11 -
 inc/stats_bonus.php                           |   2 +-
 inc/stylesheet.php                            |  16 +-
 inc/wrapper-functions.php                     | 376 +++++++++++++
 index.php                                     |   6 +-
 install.php                                   |   2 +-
 js.php                                        |  11 +-
 lead-confirm.php                              |   2 +-
 login.php                                     |   2 +-
 mailid.php                                    |  15 +-
 mailid_top.php                                |   4 +-
 modules.php                                   |   4 +-
 ref.php                                       |   2 +-
 show_bonus.php                                |  31 +-
 sponsor_confirm.php                           |   2 +-
 sponsor_ref.php                               |   2 +-
 surfbar.php                                   |   4 +-
 templates/de/html/admin/admin_config_beg.tpl  | 118 ++--
 .../de/html/admin/admin_config_birthday.tpl   |  37 +-
 .../de/html/admin/admin_config_bonus.tpl      |   2 +-
 templates/de/html/beg/beg_link.tpl            |   3 +-
 .../de/html/birthday/birthday_confirm.tpl     |  12 +-
 templates/de/html/birthday/birthday_msg.tpl   |   6 +-
 templates/de/html/copyright.tpl               |   7 +-
 templates/de/html/ext/ext_lead.tpl            |  21 +
 templates/de/html/guest/guest_beg.tpl         |   3 +-
 templates/de/html/index.tpl                   |   4 +-
 templates/de/html/member/member_beg.tpl       |   3 +-
 templates/de/html/show_bonus.tpl              |  29 +-
 templates/de/html/show_bonus_msg.tpl          |  10 +-
 view.php                                      |   4 +-
 163 files changed, 1770 insertions(+), 1433 deletions(-)
 create mode 100644 inc/config-global.php
 create mode 100644 inc/config-local.php.dist
 create mode 100644 inc/extensions/ext-lead.php
 create mode 100644 inc/load_config.php
 create mode 100644 inc/wrapper-functions.php
 create mode 100644 templates/de/html/ext/ext_lead.tpl

diff --git a/.gitattributes b/.gitattributes
index f9c448fe18..d789c7dec6 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -92,6 +92,8 @@ inc/autopurge/purge-unconfirmed.php -text
 inc/cache/.htaccess -text
 inc/check-reset.php -text
 inc/config-functions.php -text
+inc/config-global.php -text
+inc/config-local.php.dist -text
 inc/config.php -text
 inc/databases.php -text
 inc/db/.htaccess -text
@@ -125,6 +127,7 @@ inc/extensions/ext-events.php -text
 inc/extensions/ext-holiday.php -text
 inc/extensions/ext-html_mail.php -text
 inc/extensions/ext-iso3166.php -text
+inc/extensions/ext-lead.php -text
 inc/extensions/ext-logs.php -text
 inc/extensions/ext-mailid.php -text
 inc/extensions/ext-maintenance.php -text
@@ -261,6 +264,7 @@ inc/libs/user_functions.php -text
 inc/libs/wernis_functions.php -text
 inc/libs/yoomedia_functions.php -text
 inc/load_cache.php -text
+inc/load_config.php -text
 inc/load_extensions.php -text
 inc/loader/.htaccess -text
 inc/loader/load_cache-admin.php -text
@@ -627,6 +631,7 @@ inc/stylesheet.php -text
 inc/weekly/.htaccess -text
 inc/weekly/weekly_ -text
 inc/weekly/weekly_surfbar.php -text
+inc/wrapper-functions.php -text
 /index.php -text
 /install.php -text
 install/menu-de.sql -text
@@ -1241,6 +1246,7 @@ templates/de/html/ext/ext_doubler.tpl -text
 templates/de/html/ext/ext_events.tpl -text
 templates/de/html/ext/ext_holiday.tpl -text
 templates/de/html/ext/ext_html_mail.tpl -text
+templates/de/html/ext/ext_lead.tpl -text
 templates/de/html/ext/ext_logs.tpl -text
 templates/de/html/ext/ext_mailid.tpl -text
 templates/de/html/ext/ext_maintenance.tpl -text
diff --git a/.gitignore b/.gitignore
index e14734f1e0..9df491e110 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ inc/.secret/dummy.php
 inc/cache/*.cache
 inc/cache/*.log
 inc/cache/.revision
+inc/cache/config-local.php
diff --git a/admin.php b/admin.php
index 9ae71294ab..c6a9bf529e 100644
--- a/admin.php
+++ b/admin.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'admin';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if (isInstalled()) {
diff --git a/agb.php b/agb.php
index 652ad4b257..065941cc7f 100644
--- a/agb.php
+++ b/agb.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'agb';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if (isInstalled()) {
diff --git a/beg.php b/beg.php
index 6d4e6c5cc6..669afcf88e 100644
--- a/beg.php
+++ b/beg.php
@@ -51,7 +51,7 @@ $GLOBALS['output_mode'] = -1;
 $msg = null;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the 'beg' extension active?
 REDIRCT_ON_UNINSTALLED_EXTENSION('beg');
@@ -69,7 +69,7 @@ if (isInstalled()) {
 		$pay = false;
 
 		// Validate if it is not a number
-		if ("".(REQUEST_GET('uid') + 0)."" !== "".REQUEST_GET('uid')."") {
+		if (''.(REQUEST_GET('uid') + 0).'' !== ''.REQUEST_GET('uid').'') {
 			if (EXT_IS_ACTIVE('nickname')) {
 				// Maybe we have found a nickname?
 				$result = SQL_QUERY_ESC("SELECT userid, beg_clicks, ref_payout, status, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1",
@@ -86,7 +86,7 @@ if (isInstalled()) {
 		}
 
 		// Check if locked in so don't pay points
-		$status = "failed";
+		$status = 'failed';
 
 		// Check if account was found
 		if (SQL_NUMROWS($result) == 1) {
@@ -106,7 +106,7 @@ if (isInstalled()) {
 				// Set nickname / userid for the template(s
 				define('__BEG_UID'   , REQUEST_GET('uid'));
 				define('__BEG_CLICKS', ($clicks + 1));
-				define('__BEG_BANNER', LOAD_TEMPLATE("beg_banner", true));
+				define('__BEG_BANNER', LOAD_TEMPLATE('beg_banner', true));
 				define('__BEG_POINTS', translateComma($points));
 			} else {
 				// Other status
@@ -128,7 +128,7 @@ if (isInstalled()) {
 				array($uid, detectRemoteAddr(), session_id()), __FILE__, __LINE__);
 
 			// Entry not found, points set and not logged in?
-			if (((SQL_NUMROWS($result) == 0) || (IS_ADMIN())) && ($points > 0) && (!IS_MEMBER()) && (getConfig('beg_pay_mode') == "NONE")) {
+			if (((SQL_NUMROWS($result) == 0) || (IS_ADMIN())) && ($points > 0) && (!IS_MEMBER()) && (getConfig('beg_pay_mode') == 'NONE')) {
 
 				// Admin is testing?
 				if (!IS_ADMIN()) {
@@ -139,10 +139,7 @@ if (isInstalled()) {
 						array($uid, detectRemoteAddr(), session_id()), __FILE__, __LINE__);
 
 					// Was is successfull?
-					if (SQL_AFFECTEDROWS() == 1) {
-						// Okay!
-						$pay = true;
-					} // END - if
+					$pay (SQL_AFFECTEDROWS() == 1);
 				} else {
 					// Is admin!
 					$pay = true;
@@ -153,19 +150,19 @@ if (isInstalled()) {
 					// Add points to user or begging rallye account
 					if (BEG_ADD_POINTS($uid, $points)) {
 						// Set 'done' message
-						define('__BEG_MSG', LOAD_TEMPLATE("beg_done", true));
+						$content['msg'] = LOAD_TEMPLATE('beg_done', true));
 					} else {
 						// Error!
-						define('__BEG_MSG', LOAD_TEMPLATE("beg_failed", true));
+						$content['msg'] = LOAD_TEMPLATE('beg_failed', true));
 					}
 				} else {
 					// Error!
-					define('__BEG_MSG', LOAD_TEMPLATE("beg_failed", true));
+					$content['msg'] = LOAD_TEMPLATE('beg_failed', true));
 				}
 			} elseif (IS_MEMBER()) {
 				// Logged in user found!
-				define('__BEG_MSG', LOAD_TEMPLATE("beg_login", true));
-			} elseif (getConfig('beg_pay_mode') != "NONE") { // Other pay-mode active!
+				$content['msg'] = LOAD_TEMPLATE('beg_login', true));
+			} elseif (getConfig('beg_pay_mode') != 'NONE') { // Other pay-mode active!
 				// Prepare content for template
 				$content = array(
 					'clicks' => constant('__BEG_CLICKS'),
@@ -174,11 +171,11 @@ if (isInstalled()) {
 				);
 
 				// Load message template depending on pay-mode
-				define('__BEG_MSG', LOAD_TEMPLATE("beg_pay_mode_".strtolower(getConfig('beg_pay_mode')), true, $content));
+				$content['msg'] = LOAD_TEMPLATE('beg_pay_mode_'.strtolower(getConfig('beg_pay_mode')), true, $content));
 				$pay = true;
 			} else {
 				// Clicked received while reload lock is active
-				define('__BEG_MSG', LOAD_TEMPLATE("beg_failed", true));
+				$content['msg'] = LOAD_TEMPLATE('beg_failed', true));
 			}
 
 			// Free memory
@@ -188,28 +185,28 @@ if (isInstalled()) {
 			loadIncludeOnce('inc/header.php');
 
 			// Load final template
-			LOAD_TEMPLATE("beg_link");
+			LOAD_TEMPLATE('beg_link', false, $content);
 
 			// Tracker code enabled? (We don't track users here!
-			if ((getConfig('beg_pay_mode') != "NONE") && ($pay)) {
+			if ((getConfig('beg_pay_mode') != 'NONE') && ($pay === true)) {
 				// Prepare content for template
 				// @TODO Opps, what is missing here???
 				$content = array(
 				);
 
 				// Include config-depending template
-				LOAD_TEMPLATE("beg_pay_code_".strtolower(getConfig('beg_pay_mode')), false, $content);
-			} elseif ((!$pay) && (!defined('__BEG_MSG'))) {
+				LOAD_TEMPLATE('beg_pay_code_'.strtolower(getConfig('beg_pay_mode')), false, $content);
+			} elseif ((!$pay) && (!isset($content['msg']))) {
 				// Cannot pay! :-(
-				define('__BEG_MSG', LOAD_TEMPLATE("beg_failed", true));
+				$content['msg'] = LOAD_TEMPLATE('beg_failed', true));
 			}
 
 			// Include footer
 			loadIncludeOnce('inc/footer.php');
-		} elseif (($status != 'CONFIRMED') && ($status != "failed")) {
+		} elseif (($status != 'CONFIRMED') && ($status != 'failed')) {
 			// Maybe locked/unconfirmed account?
 			$msg = generateErrorCodeFromUserStatus($status);
-		} elseif (($uid == '0') || ($status == "failed")) {
+		} elseif (($uid == '0') || ($status == 'failed')) {
 			// Inalid or locked account, so let's find out
 			$result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1",
 				array(REQUEST_GET('uid')), __FILE__, __LINE__);
diff --git a/birthday_confirm.php b/birthday_confirm.php
index 829dc6965a..24c46fcc56 100644
--- a/birthday_confirm.php
+++ b/birthday_confirm.php
@@ -48,10 +48,10 @@ $GLOBALS['module'] = 'birthday_confirm';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the 'birthday' extension active?
-REDIRECT_ON_UNINSTALLED_EXTENSION('birthday');
+redirectOnUninstalledExtension('birthday');
 
 // Is the script installed?
 if (isInstalled()) {
@@ -70,6 +70,9 @@ WHERE b.userid=%s AND b.chk_value='%s' LIMIT 1",
  array($uid, $chk), __FILE__, __LINE__);
 	//* DEBUG: */ echo "uid=".$uid.",chk=".$chk." (".strlen($chk).'/'.strlen(REQUEST_GET('check')).'/'.SQL_NUMROWS($result).")<br />\n";
 
+	// Prepare content
+	$content = array();
+
 	// Is an entry there?
 	if (SQL_NUMROWS($result) == 1) {
 		// Ok, congratulation again! Here's your gift from us...
@@ -95,21 +98,19 @@ WHERE b.userid=%s AND b.chk_value='%s' LIMIT 1",
 			SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_birthday` WHERE userid=%s AND chk_value='%s' LIMIT 1",
 				array($uid, $chk), __FILE__, __LINE__);
 
-			// Transfer data to constants for the template
-			define('__GENDER', translateGender($data['gender']));
-			define('__SNAME' , $data['surname']);
-			define('__FNAME' , $data['family']);
-			define('__GIFT'  , translateComma($data['points']));
+			// "Translate" some data
+			$data['gender'] = translateGender($data['gender']);
+			$data['points'] = translateComma($data['points']);
 
 			// Load message from template
-			define('__MSG', LOAD_TEMPLATE('birthday_msg', true));
+			$content['msg'] = LOAD_TEMPLATE('birthday_msg', true, $data);
 		} else {
 			// Unconfirmed / locked accounts cannot get points
-			define('__MSG', sprintf(getMessage('BIRTHDAY_CANNOT_STATUS'), translateUserStatus($data['status'])));
+			$content['msg'] = sprintf(getMessage('BIRTHDAY_CANNOT_STATUS'), translateUserStatus($data['status']));
 		}
 	} else {
 		// Cannot load data!
-		define('__MSG', getMessage('BIRTHDAY_CANNOT_LOAD_DATA'));
+		$content['msg'] = getMessage('BIRTHDAY_CANNOT_LOAD_DATA');
 	}
 
 	// Free memory
@@ -122,13 +123,13 @@ WHERE b.userid=%s AND b.chk_value='%s' LIMIT 1",
 	loadInclude('inc/header.php');
 
 	// Load birthday header template (for your banners, e.g.?)
-	define('__BIRTHDAY_HEADER', LOAD_TEMPLATE('birthday_header', true));
+	$content['header'] =  LOAD_TEMPLATE('birthday_header', true);
 
 	// Load birthday footer template (for your banners, e.g.?)
-	define('__BIRTHDAY_FOOTER', LOAD_TEMPLATE('birthday_footer', true));
+	$content['footer'] =  LOAD_TEMPLATE('birthday_footer', true);
 
 	// Load final template and output it
-	LOAD_TEMPLATE('birthday_confirm');
+	LOAD_TEMPLATE('birthday_confirm', false, $content);
 
 	// Include footer
 	loadInclude('inc/footer.php');
diff --git a/click.php b/click.php
index 48ddf484d8..cf6f3e529f 100644
--- a/click.php
+++ b/click.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'click';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 if (((REQUEST_ISSET_GET(('user'))) || (REQUEST_ISSET_GET(('reseller')))) && (REQUEST_ISSET_GET(('banner')))) {
 	// Update clicks counter...
diff --git a/confirm.php b/confirm.php
index 1a540ccabc..96f7578208 100644
--- a/confirm.php
+++ b/confirm.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'confirm';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if ((isInstalled()) && (isAdminRegistered())) {
diff --git a/css.php b/css.php
index 5206767093..714848650a 100644
--- a/css.php
+++ b/css.php
@@ -40,7 +40,7 @@
 require('inc/libs/security_functions.php');
 
 // Footer is disabled in CSS mode
-$GLOBALS['footer_sent'] = "-1";
+$GLOBALS['footer_sent'] = '-1';
 
 // Init variables
 $GLOBALS['what'] = '';
@@ -50,11 +50,11 @@ $GLOBALS['action'] = '';
 $GLOBALS['output_mode'] = '1';
 $GLOBALS['module'] = 'css';
 
-// Set header
-header('Content-type: text/css');
-
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
+
+// Set header
+sendHeader('Content-type: text/css');
 
 // Load header
 loadInclude('inc/header.php');
diff --git a/debug.php b/debug.php
index c7cf9e9023..aa7c764e1f 100644
--- a/debug.php
+++ b/debug.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'debug';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Redirect only to registration page when this script is installed
 if ((isInstalled()) && (getTotalFatalErrors() == 0)) {
diff --git a/doubler.php b/doubler.php
index 908cc0264d..9a63547831 100644
--- a/doubler.php
+++ b/doubler.php
@@ -50,10 +50,10 @@ $GLOBALS['refid'] = 0;
 $GLOBALS['output_mode'] = 0;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the 'doubler' extension active?
-REDIRECT_ON_UNINSTALLED_EXTENSION('doubler');
+redirectOnUninstalledExtension('doubler');
 
 // Is the script installed?
 if (isInstalled()) {
diff --git a/img.php b/img.php
index 2f39fa0e37..f1099706ea 100644
--- a/img.php
+++ b/img.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'img';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Script installed?
 if (isInstalled()) {
@@ -59,10 +59,10 @@ if (isInstalled()) {
 	if (REQUEST_ISSET_GET(('code'))) {
 		// Generate image
 		GENERATE_IMAGE(bigintval(REQUEST_GET('code')));
-	} elseif (REQUEST_ISSET_GET(('tag'))) {
+	} elseif (REQUEST_ISSET_GET('tag')) {
 		// Tag set so create the IFN (Include-FileName)
 		$INC = sprintf("inc/img/tag-%s.php",
-			REQUEST_GET(('tag'))
+			REQUEST_GET('tag')
 		);
 
 		// Include is readable?
diff --git a/inc/config-functions.php b/inc/config-functions.php
index 186ede8339..506db1b908 100644
--- a/inc/config-functions.php
+++ b/inc/config-functions.php
@@ -49,16 +49,16 @@ function mergeConfig ($newConfig) {
 }
 
 // Getter for $_CONFIG entries
-function getConfig ($entry) {
+function getConfig ($configEntry) {
 	global $_CONFIG;
 
 	// Default value
 	$value = null;
 
 	// Is the entry there?
-	if (isConfigEntrySet($entry)) {
+	if (isConfigEntrySet($configEntry)) {
 		// Then use it
-		$value = $_CONFIG[$entry];
+		$value = $_CONFIG[$configEntry];
 	} // END - if
 
 	// Return it
@@ -66,20 +66,26 @@ function getConfig ($entry) {
 }
 
 // Setter for $_CONFIG entries
-function setConfigEntry ($entry, $value) {
+function setConfigEntry ($configEntry, $value) {
 	global $_CONFIG;
 
 	// Secure the entry name
-	$entry = SQL_ESCAPE($entry);
+	if (function_exists('SQL_ESCAPE')) {
+		// Use our secure function
+		$configEntry = SQL_ESCAPE($configEntry);
+	} else {
+		// Use maybe insecure function
+		$configEntry = smartAddSlashes($configEntry);
+	}
 
 	// And set it
-	$_CONFIG[$entry] = $value;
+	$_CONFIG[$configEntry] = $value;
 }
 
 // Checks wether the given config entry is set
-function isConfigEntrySet ($entry) {
+function isConfigEntrySet ($configEntry) {
 	global $_CONFIG;
-	return (isset($_CONFIG[$entry]));
+	return (isset($_CONFIG[$configEntry]));
 }
 
 // Increment or init with given value or 1 as default the given config entry
@@ -105,6 +111,7 @@ function isConfigLoaded () {
 // Init the config array
 function initConfig () {
 	global $_CONFIG;
+	debug_report_bug('Reached!');
 
 	// Set a minimum dummy configuration
 	$_CONFIG = array(
@@ -116,19 +123,17 @@ function initConfig () {
 
 // Load configuration and return it as an arry
 function loadConfiguration ($no = '0') {
-	global $_CONFIG;
-
 	// Check for cache extension, cache-array and if the requested configuration is in cache
-	if ((is_array($GLOBALS['cache_array'])) && (isset($GLOBALS['cache_array']['config'][$no])) && (is_array($GLOBALS['cache_array']['config'][$no]))) {
+	if ((isset($GLOBALS['cache_array'])) && (is_array($GLOBALS['cache_array'])) && (isset($GLOBALS['cache_array']['config'][$no])) && (is_array($GLOBALS['cache_array']['config'][$no]))) {
 		// Load config from cache
 		//* DEBUG: */ echo gettype($GLOBALS['cache_array']['config'][$no])."<br />\n";
 		foreach ($GLOBALS['cache_array']['config'][$no] as $key => $value) {
-			$_CONFIG[$key] = $value;
+			setConfigEntry($key, $value);
 		} // END - foreach
 
 		// Count cache hits if exists
-		if ((isset($_CONFIG['cache_hits'])) && (EXT_IS_ACTIVE('cache'))) {
-			$_CONFIG['cache_hits']++;
+		if ((isConfigEntrySet('cache_hits')) && (EXT_IS_ACTIVE('cache'))) {
+			incrementConfigEntry('cache_hits');
 		} // END - if
 	} elseif ((!EXT_IS_ACTIVE('cache')) || (!isset($GLOBALS['cache_array']['config'][$no]))) {
 		// Load config from DB
@@ -138,14 +143,14 @@ function loadConfiguration ($no = '0') {
 		// Is the config there?
 		if (SQL_NUMROWS($result_config) == 1) {
 			// Get config from database
-			$_CONFIG = SQL_FETCHARRAY($result_config);
+			mergeConfig(SQL_FETCHARRAY($result_config));
 		} // END - if
 
 		// Free result
 		SQL_FREERESULT($result_config);
 
 		// Remember this config in the array
-		$GLOBALS['cache_array']['config'][$no] = $_CONFIG;
+		$GLOBALS['cache_array']['config'][$no] = getConfigArray();
 	}
 }
 
@@ -153,8 +158,17 @@ function loadConfiguration ($no = '0') {
 function getConfigArray () {
 	global $_CONFIG;
 
-	// Return it
-	return $_CONFIG;
+	// Default is null
+	$return = null;
+
+	// Is the config set?
+	if (isConfigLoaded()) {
+		// Then use it
+		$return = $_CONFIG;
+	} // END - if
+
+	// Return result
+	return $return;
 }
 
 // [EOF]
diff --git a/inc/config-global.php b/inc/config-global.php
new file mode 100644
index 0000000000..de3c4ac3c3
--- /dev/null
+++ b/inc/config-global.php
@@ -0,0 +1,81 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 04/03/2009 *
+ * ===============                              Last change: 04/03/2009 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : config-global.php                                *
+ * -------------------------------------------------------------------- *
+ * Short description : Global configuration                             *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Globale Konfiguration                            *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.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 2 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, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
+	require($INC);
+} // END - if
+
+/************************************************************************
+ *      PLEASE DO NOT EDIT THE COMMENTS! install.php NEEDS THEM!        *
+ ************************************************************************/
+
+if (function_exists('date_default_timezone_set')) {
+	// CFG: TIME-ZONE
+	@date_default_timezone_set('Europe/Berlin');
+} // END - if
+
+// CFG: ERROR_REPORTING
+@error_reporting(0);
+
+// CFG: REGISTER-GLOBALS
+@import_request_variables('');
+
+// These constants should be rewritten
+define('VERSION', 'v0.2.1');
+define('AUTHOR' , 'Roland H&auml;der');
+define('TITLE', 'MXChange - Mail Exchange');
+define('COPY', 'Copyright &copy; 2003 - 2008, by Roland H&auml;der');
+
+// Auto-detection... (patched by "Stelzi" aka. profi-concept, thanks again!)
+$URL = 'http://' . getenv('SERVER_NAME') . str_replace("\\", '/', dirname($_SERVER['PHP_SELF']));
+while (substr($URL, -1, 1) == '/') { $URL = substr($URL, 0, -1); }
+$PATH = str_replace("\\", '/', substr(dirname(__FILE__), 0, -3));
+
+// CFG: SERVER-PATH
+define('PATH', $PATH);
+
+// CFG: HOST-URL (without trailing '/' !)
+define('URL', $URL);
+
+// Connect to the MySQL database...
+require(constant('PATH') . 'inc/mysql-connect.php');
+
+//
+?>
diff --git a/inc/config-local.php.dist b/inc/config-local.php.dist
new file mode 100644
index 0000000000..08e6779d5f
--- /dev/null
+++ b/inc/config-local.php.dist
@@ -0,0 +1,128 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 04/03/2009 *
+ * ===============                              Last change: 04/03/2009 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : config-local.php                                 *
+ * -------------------------------------------------------------------- *
+ * Short description : Local configuration                              *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Lokale Konfiguration                             *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.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 2 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, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
+	require($INC);
+} // END - if
+
+/************************************************************************
+ *      PLEASE DO NOT EDIT THE COMMENTS! install.php NEEDS THEM!        *
+ ************************************************************************/
+
+// CFG: SITE-KEY
+setConfigEntry('SITE_KEY', "");
+
+// CFG: DATE-KEY
+setConfigEntry('DATE_KEY', date("d-m-Y (l-F-T)", time()));
+
+// CFG: DEFAULT-LANGUAGE
+setConfigEntry('DEFAULT_LANG', "de");
+
+// CFG: NULLPASS-WARNING
+setConfigEntry('WARN_NO_PASS', "Y");
+
+// CFG: WRITE-FOOTER
+setConfigEntry('WRITE_FOOTER', "Y");
+
+// CFG: OUTPUT-MODE
+setConfigEntry('OUTPUT_MODE', "render");
+
+// CFG: INSTALLED
+setConfigEntry('MXCHANGE_INSTALLED', "N");
+
+// CFG: ADMIN-SETUP
+setConfigEntry('ADMIN_REGISTERED', "N");
+
+// CFG: MYSQL-PREIFX
+setConfigEntry('_MYSQL_PREFIX', "mxchange");
+
+// CFG: TABLE-TYPE
+setConfigEntry('_TABLE_TYPE', "MyISAM");
+
+// CFG: DATABASE-TYPE
+setConfigEntry('_DB_TYPE', "mysql3");
+
+// CFG: DEBUG-MODE (if enabled all mails will be *displayed* and *not* send!)
+setConfigEntry('DEBUG_MODE', "Y");
+
+// CFG: BACKLINK (Enable backlink to mxchange.org in footer? rel=external is set!)
+setConfigEntry('ENABLE_BACKLINK', 'Y');
+
+// CFG: DEBUG-RESET (comment in to test daily reset, comment out to not test)
+//setConfigEntry('DEBUG_RESET', "Y");
+
+// CFG: DEBUG-MONTHLY (comment in to test monthly reset, comment out to not test)
+//setConfigEntry('DEBUG_MONTHLY', "Y");
+
+// CFG: DEBUG-WEEKLY (comment in to test weekly reset, comment out to not test)
+//setConfigEntry('DEBUG_WEEKLY', "Y");
+
+// Your MySQL data (we don't like M$ SQL ;-) )
+$GLOBALS['mysql'] = array(
+	// CFG: MYSQL-HOST
+	'host'     => "localhost",
+	// CFG: MYSQL-DBASE
+	'dbase'    => "db",
+	// CFG: MYSQL-LOGIN
+	'login'    => "user",
+	// CFG: MYSQL-PASSWORD
+	'password' => "pass",
+);
+
+// SMTP-Subsystem (keep all empty to use legacy mail() command!)
+// CFG: SMTP-HOSTNAME
+setConfigEntry('SMTP_HOSTNAME', "");
+// CFG: SMTP-USER
+setConfigEntry('SMTP_USER'    , "");
+// CFG: SMTP-PASSWORD
+setConfigEntry('SMTP_PASSWORD', "");
+
+// @TODO Rewrite the following three constants, somehow...
+// CFG: MAIN-TITLE
+define('MAIN_TITLE', "Your mail-exchanger title");
+
+// CFG: SLOGAN
+define('SLOGAN', "Your cool slogan here");
+
+// CFG: WEBMASTER
+define('WEBMASTER', "you@some-hoster.tld.invalid");
+
+//
+?>
diff --git a/inc/config.php b/inc/config.php
index dfc866fb73..f551ef47b7 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -1,173 +1,3 @@
 <?php
-/************************************************************************
- * MXChange v0.2.1                                    Start: 08/25/2003 *
- * ===============                              Last change: 04/16/2004 *
- *                                                                      *
- * -------------------------------------------------------------------- *
- * File              : config.php                                       *
- * -------------------------------------------------------------------- *
- * Short description : Your configuration data (MySQL)                  *
- * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Ihre Konfigurationsdaten (MySQL)                 *
- * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.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 2 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, write to the Free Software          *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
- * MA  02110-1301  USA                                                  *
- ************************************************************************/
-
-// Some security stuff...
-if (!defined('__SECURITY'))
-{
-	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
-	require($INC);
-}
-
-/************************************************************************
- *      PLEASE DO NOT EDIT THE COMMENTS! install.php NEEDS THEM!        *
- ************************************************************************/
-
-if (function_exists('date_default_timezone_set')) {
-	// CFG: TIME-ZONE
-	@date_default_timezone_set("Europe/Berlin");
-}
-
-// Most of these constants are old and deprecated. We don't use them either.
-// You can still feel free to use them in your templates / scripts if you like :-)
-define('VERSION', "v0.2.1");
-define('AUTHOR' , "Roland H&auml;der");
-define('TITLE', "MXChange - Mail Exchange");
-define('COPY', "Copyright &copy; 2003 - 2008, by Roland H&auml;der");
-
-// CFG: ERROR_REPORTING
-@error_reporting(0);
-
-// CFG: REGISTER-GLOBALS
-@import_request_variables('');
-
-// CFG: SITE-KEY
-define('SITE_KEY', "gg42ny8-4yng23498-mf423igum-mtu248utn42-mf4839gun43");
-
-// CFG: DATE-KEY
-define('DATE_KEY', date("d-m-Y (l-F-T)", time()));
-
-// CFG: DEFAULT-LANGUAGE
-define('DEFAULT_LANG', "de");
-
-// CFG: NULLPASS-WARNING
-define('warn_no_pass', true);
-
-// CFG: WRITE-FOOTER
-define('WRITE_FOOTER', true);
-
-// CFG: OUTPUT-MODE
-define('OUTPUT_MODE', "render");
-
-// CFG: MAIN_TITLE
-define('MAIN_TITLE', "Your mail-exchanger title");
-
-// CFG: SLOGAN
-define('SLOGAN', "Your cool slogan here");
-
-// Auto-detection... (patched by "Stelzi" aka. profi-concept, thanks again!)
-$URL = "http://".getenv('SERVER_NAME') . str_replace("\\", '/', dirname($_SERVER['PHP_SELF']));
-while (substr($URL, -1, 1) == '/') { $URL = substr($URL, 0, -1); }
-$PATH = str_replace("\\", '/', substr(dirname(__FILE__), 0, -3));
-
-// CFG: HOST-URL (without trailing '/' !)
-define('URL', $URL);
-
-// CFG: SERVER-PATH
-define('PATH', $PATH);
-
-// CFG: WEBMASTER
-define('WEBMASTER', "you@some-hoster.tld.invalid");
-
-// CFG: INSTALLED
-define('mxchange_installed', false);
-
-// CFG: ADMIN-SETUP
-define('admin_registered', false);
-
-// CFG: FRAMESET
-define('frameset_active', false);
-
-// CFG: DEBUG-MODE (if enabled all mails will be *displayed* and *not* send!)
-define('DEBUG_MODE', false);
-
-// CFG: DEBUG-MAIL (turn this on if you need to debug mails, only affects if DEBUG_MODE is true)
-//define('DEBUG_MAIL', true);
-
-// CFG: DEBUG-RESET (comment in to test daily reset, comment out to not test)
-//define('DEBUG_RESET', true);
-
-// CFG: DEBUG-MONTHLY (comment in to test monthly reset, comment out to not test)
-//define('DEBUG_MONTHLY', true);
-
-// CFG: DEBUG-WEEKLY (comment in to test weekly reset, comment out to not test)
-//define('DEBUG_WEEKLY', true);
-
-// Your MySQL data (we don't like M$ SQL ;-) )
-$MySQL = array(
-	// CFG: MYSQL-HOST
-	'host'     => "localhost",
-	// CFG: MYSQL-DBASE
-	'dbase'    => "db",
-	// CFG: MYSQL-LOGIN
-	'login'    => "user",
-	// CFG: MYSQL-PASSWORD
-	'password' => "pass",
-);
-
-// CFG: MYSQL-PREIFX
-define('_MYSQL_PREFIX', "mxchange");
-
-// CFG: TABLE-TYPE
-define('_TABLE_TYPE', "MyISAM");
-
-// CFG: DATABASE-TYPE
-define('_DB_TYPE', "mysql3");
-
-// Lead-Code data
-define('LEAD_CODE_ENABLED', true);
-define('LEAD_EXPIRY_TIME' , (30*24*60*60)); // == 30 days
-
-// SMTP-Subsystem (keep all empty to use legacy mail() command!)
-// CFG: SMTP-HOSTNAME
-define('SMTP_HOSTNAME', "");
-// CFG: SMTP-USER
-define('SMTP_USER'    , "");
-// CFG: SMTP-PASSWORD
-define('SMTP_PASSWORD', "");
-
-// SSL cookies? (enable only if you have SSL, URLs will begin with https://)
-define('SSL_COOKIES', false);
-
-// CFG: BACKLINK (Enable backlink to mxchange.org in footer? rel=external is set!)
-define('ENABLE_BACKLINK', true);
-
-// Connect to the MySQL database...
-require(constant('PATH')."inc/mysql-connect.php");
-
-//
+// @DEPRECATED
 ?>
diff --git a/inc/databases.php b/inc/databases.php
index f06b34c034..d8ebad0b6f 100644
--- a/inc/databases.php
+++ b/inc/databases.php
@@ -95,26 +95,26 @@ setConfigEntry('one_day', (60*60*24));
 
 //
 // Timestamp for yesterday, today ... all at 00:00 am
-define('START_YDAY', makeTime(0, 0, 0, time() - getConfig('one_day')));
-define('START_TDAY', makeTime(0, 0, 0, time()));
+setConfigEntry('START_YDAY', makeTime(0, 0, 0, time() - getConfig('one_day')));
+setConfigEntry('START_TDAY', makeTime(0, 0, 0, time()));
 
 // Take a prime number which is long (if you know a longer one please try it out!)
-define('_PRIME', 591623);
+setConfigEntry('_PRIME', 591623);
 
 // Calculate "entropy" with the prime number (for code generation)
-define('_ADD', (constant('_PRIME') * constant('_PRIME') / (pi() * getConfig('code_length') + 1)));
+setConfigEntry('_ADD', (getConfig('_PRIME') * getConfig('_PRIME') / (pi() * getConfig('code_length') + 1)));
 
 // Random number for e.g. the "cache-buster" used in OpenX script
 define('CACHE_BUSTER', mt_rand(1000000, 9999999));
 
 // CFG: DEBUG-SQL (if enabled and DEBUG_MODE is enabled all SQL queries will be logged to debug.log)
-define('DEBUG_SQL', false);
+setConfigEntry('DEBUG_SQL', 'N');
 
 // CFG: ENCRYPT-SEPERATOR
-define('ENCRYPT_SEPERATOR', ':');
+setConfigEntry('ENCRYPT_SEPERATOR', ':');
 
 // Extra title is empty by default
-$EXTRA_TITLE = '';
+setExtraTitle('');
 
 //
 ?>
diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php
index b0de8af3fc..823e5d02f9 100644
--- a/inc/db/lib-mysql3.php
+++ b/inc/db/lib-mysql3.php
@@ -51,10 +51,10 @@ function SQL_QUERY ($sql_string, $F, $L) {
 	$sql_string = str_replace("\t", " ", str_replace("\n", " ", str_replace("\r", " ", $sql_string)));
 
 	// Replace {!_MYSQL_PREFIX!} with constant, closes #84. Thanks to profi-concept
-	$sql_string = str_replace("{!_MYSQL_PREFIX!}", constant('_MYSQL_PREFIX'), $sql_string);
+	$sql_string = str_replace("{!_MYSQL_PREFIX!}", getConfig('_MYSQL_PREFIX'), $sql_string);
 
 	// Replace {!_TABLE_TYPE!} with constant
-	$sql_string = str_replace("{!_TABLE_TYPE!}", constant('_TABLE_TYPE'), $sql_string);
+	$sql_string = str_replace("{!_TABLE_TYPE!}", getConfig('_TABLE_TYPE'), $sql_string);
 
 	// Starting time
 	$querytimeBefore = array_sum(explode(' ', microtime()));
@@ -80,11 +80,11 @@ Query string:<br />
 
 	// Debug output
 	//* DEBUG: */ print "Query=<pre>".$sql_string."</pre>, affected=<strong>".SQL_AFFECTEDROWS()."</strong>, numrows=<strong>".SQL_NUMROWS($result)."</strong><br />\n";
-	if (($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1") && (isDebugModeEnabled()) && (isBooleanConstantAndTrue('DEBUG_SQL'))) {
+	if (($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1') && (isDebugModeEnabled()) && (getConfig('DEBUG_SQL') == 'Y')) {
 		//
 		// Debugging stuff...
 		//
-		$fp = fopen(constant('PATH')."inc/cache/mysql.log", 'a') or app_die(__FILE__, __LINE__, "Cannot write mysql.log!");
+		$fp = fopen(constant('PATH') . 'inc/cache/mysql.log', 'a') or app_die(__FILE__, __LINE__, "Cannot write mysql.log!");
 		if (!isset($GLOBALS['sql_first_entry'])) {
 			// Write first entry
 			fwrite($fp, "Module=".$GLOBALS['module']."\n");
@@ -274,7 +274,7 @@ function SQL_QUERY_ESC ($qstring, $data, $F, $L, $run=true, $strip=true, $secure
 	// Debugging
 	//
 	//* DEBUG: */ $fp = fopen(constant('PATH')."inc/cache/escape_debug.log", 'a') or app_die(__FILE__, __LINE__, "Cannot write debug.log!");
-	//* DEBUG: */ fwrite($fp, $F."(".$L."): ".str_replace("\r", '', str_replace("\n", " ", $eval))."\n");
+	//* DEBUG: */ fwrite($fp, $F.'('.$L."): ".str_replace("\r", '', str_replace("\n", " ", $eval))."\n");
 	//* DEBUG: */ fclose($fp);
 
 	// Run the code
@@ -351,47 +351,54 @@ function SQL_ALTER_TABLE ($sql, $F, $L) {
 	$result = false;
 
 	// Determine index/fulltext/unique word
-	//         12    3             3         2    2    3                3         2    2    3              3         21
-	$noIndex = ((ereg("INDEX", $sql) == false) && (ereg("FULLTEXT", $sql) == false) && (ereg("UNIQUE", $sql) == false));
+	$noIndex = (
+		(
+			strpos($sql, 'INDEX') === false
+		) && (
+			strpos($sql, 'FULLTEXT') === false
+		) && (
+			strpos($sql, 'UNIQUE') === false
+		)
+	);
 
 	// Extract table name
 	$tableArray = explode(" ", $sql);
-	$tableName = str_replace("`", '', $tableArray[2]);
+	$tableName = str_replace('`', '', $tableArray[2]);
 
 	// Shall we add/drop?
-	if (((ereg("ADD", $sql)) || (ereg("DROP", $sql))) && ($noIndex)) {
+	if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false)) && ($noIndex === true)) {
 		// And column name as well
-		$columnName = str_replace("`", '', $tableArray[4]);
+		$columnName = str_replace('`', '', $tableArray[4]);
 
 		// Get column information
 		$result = SQL_QUERY_ESC("SHOW COLUMNS FROM %s LIKE '%s'",
 			array($tableName, $columnName), __FILE__, __LINE__);
 
 		// Do we have no entry on ADD or an entry on DROP?
-		// 123           4       4     3    3    4           432    23           4       4     3    3    4            4321
-		if (((SQL_NUMROWS($result) == 0) && (ereg("ADD", $sql))) || ((SQL_NUMROWS($result) == 1) && (ereg("DROP", $sql)))) {
+		// 123           4       4     3    3      4           4          32    23           4       4     3    3      4            4          321
+		if (((SQL_NUMROWS($result) == 0) && (strpos($sql, 'ADD') !== false)) || ((SQL_NUMROWS($result) == 1) && (strpos($sql, 'DROP') !== false))) {
 			// Do the query
 			//* DEBUG: */ print __LINE__.':'.$sql."<br />\n";
 			$result = SQL_QUERY($sql, $F, $L, false);
 		} // END - if
-	} elseif ((constant('_TABLE_TYPE') == "InnoDB") && (ereg("FULLTEXT", $sql))) {
+	} elseif ((getConfig('_TABLE_TYPE') == 'InnoDB') && (strpos($sql, 'FULLTEXT') !== false)) {
 		// Skip this query silently
 		//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,file=%s,line=%s", $sql, $F, $L));
 	} elseif (!$noIndex) {
 		// And column name as well
-		$columnName = str_replace("`", '', $tableArray[4]);
+		$columnName = str_replace('`', '', $tableArray[4]);
 
 		// Is this "UNIQUE" or so? FULLTEXT has been handled the elseif() block above
-		if (in_array(strtoupper($columnName), array("INDEX", "UNIQUE", "KEY", "FULLTEXT"))) {
+		if (in_array(strtoupper($columnName), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) {
 			// Init loop
-			$begin = 1; $columnName = ",";
-			while (strpos($columnName, ",") !== false) {
+			$begin = 1; $columnName = ',';
+			while (strpos($columnName, ',') !== false) {
 				// Use last
-				$columnName = str_replace("`", '', $tableArray[count($tableArray) - $begin]);
+				$columnName = str_replace('`', '', $tableArray[count($tableArray) - $begin]);
 				//* DEBUG: */ print __LINE__.':'.$columnName."----------------".$begin."<br />\n";
 
 				// Remove brackes
-				$columnName = str_replace("(", '', str_replace(")", '', $columnName));
+				$columnName = str_replace('(', '', str_replace(')', '', $columnName));
 				//* DEBUG: */ print __LINE__.':'.$columnName."----------------".$begin."<br />\n";
 
 				// Continue
@@ -400,7 +407,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L) {
 		} // END - if
 
 		// Show indexes
-		$result = SQL_QUERY_ESC("SHOW INDEX FROM %s",
+		$result = SQL_QUERY_ESC("SHOW INDEX FROM `%s`",
 			array($tableName), __FILE__, __LINE__);
 
 		// Walk through all
diff --git a/inc/db/lib.php b/inc/db/lib.php
index 72a1f6a525..217d7681b0 100644
--- a/inc/db/lib.php
+++ b/inc/db/lib.php
@@ -40,20 +40,20 @@
 if (!defined('__SECURITY')) {
 	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
 	require($INC);
-}
+} // END - if
 
-// Select MySQL 3 as default database type
-if (!defined('_DB_TYPE')) define('_DB_TYPE', "mysql3");
+// Is it not set?
+if (!isConfigEntrySet('_DB_TYPE')) setConfigEntry('_DB_TYPE', 'mysql3');
 
 // Create include file name
-$INC = sprintf("inc/db/lib-%s.php", constant('_DB_TYPE'));
+$INC = sprintf("inc/db/lib-%s.php", getConfig('_DB_TYPE'));
 
 if (isIncludeReadable($INC)) {
 	// Include abstraction layer
 	loadIncludeOnce($INC);
 } else {
 	// Bye, bye...
-	die("Cannot load database abstraction layer ".constant('_DB_TYPE')." -&gt; R.I.P.");
+	die('Cannot load database abstraction layer <u>' . getConfig('_DB_TYPE') . '</u> -&gt; R.I.P.');
 }
 
 //
diff --git a/inc/doubler_send.php b/inc/doubler_send.php
index 9388fc6b82..6017dfb65e 100644
--- a/inc/doubler_send.php
+++ b/inc/doubler_send.php
@@ -148,7 +148,7 @@ if (((SQL_NUMROWS($result_total) > 0) && (getConfig('doubler_sent_all') == 'Y'))
 				// Doubled points
 				'points' => translateComma($content['points']),
 				// Timemark
-				'when'   => generateDateTime($content['timemark'], "2"),
+				'when'   => generateDateTime($content['timemark'], '2'),
 				// IP number when the member submitted the doubling form
 				'ip'     => $content['remote_ip'],
 			);
diff --git a/inc/extensions.php b/inc/extensions.php
index d6c49ad67c..58f22fd028 100644
--- a/inc/extensions.php
+++ b/inc/extensions.php
@@ -1237,7 +1237,7 @@ function EXT_GET_REMOVAL_LIST () {
 }
 
 // Redirects if the provided extension is not installed
-function REDIRECT_ON_UNINSTALLED_EXTENSION ($ext_name) {
+function redirectOnUninstalledExtension ($ext_name) {
 	// So is the extension there?
 	if (!EXT_IS_ACTIVE($ext_name)) {
 		// Redirect to index
diff --git a/inc/extensions/ext-lead.php b/inc/extensions/ext-lead.php
new file mode 100644
index 0000000000..1e8d7ea6a5
--- /dev/null
+++ b/inc/extensions/ext-lead.php
@@ -0,0 +1,92 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 09/25/2004 *
+ * ================                             Last change: 09/25/2004 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : ext-                                             *
+ * -------------------------------------------------------------------- *
+ * Short description :                                                  *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  :                                                  *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.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 2 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, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
+	require($INC);
+}
+
+// Version number
+EXT_SET_VERSION('0.0');
+
+// Version history array (add more with , '0.1.0' and so on)
+EXT_SET_VER_HISTORY(array('0.0'));
+
+switch ($EXT_LOAD_MODE)
+{
+case 'register': // Do stuff when installation is running (modules.php?module=admin&action=login is called)
+	// SQL commands to run
+	break;
+
+case 'remove': // Do stuff when removing extension
+	// SQL commands to run
+	break;
+
+case 'activate': // Do stuff when admin activates this extension
+	// SQL commands to run
+	break;
+
+case 'deactivate': // Do stuff when admin deactivates this extension
+	// SQL commands to run
+	break;
+
+case 'update': // Update an extension
+	switch ($EXT_VER)
+	{
+	case '0.0.1': // SQL queries for v0.0.1
+		ADD_EXT_SQL("");
+
+		// Update notes (these will be set as task text!)
+		EXT_SET_UPDATE_NOTES("");
+		break;
+	}
+	break;
+
+case 'modify': // When the extension got modified
+	break;
+
+case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
+	break;
+
+default: // Do stuff when extension is loaded
+	break;
+}
+
+//
+?>
diff --git a/inc/extensions/ext-newsletter.php b/inc/extensions/ext-newsletter.php
index 2baf2f7745..83f9bdd779 100644
--- a/inc/extensions/ext-newsletter.php
+++ b/inc/extensions/ext-newsletter.php
@@ -158,10 +158,10 @@ default: // Do stuff when extension is loaded
 	// Don't use these chars in links... ;-)
 	//
 	$GLOBALS['url_ends'] = array(
-		" ",
+		' ',
 		"\n",
 		"\r",
-		")",
+		')',
 	);
 
 	// Valid email chars (without @, or do you want to have another @ inside your email addy?)
diff --git a/inc/filters.php b/inc/filters.php
index 74cda8e85b..098a2157f9 100644
--- a/inc/filters.php
+++ b/inc/filters.php
@@ -521,7 +521,7 @@ function FILTER_CHECK_ADMIN_ACL () {
 // Filter for initializing randomizer
 function FILTER_INIT_RANDOMIZER () {
 	// Simply init the randomizer with seed and _ADD value
-	mt_srand(generateSeed() + constant('_ADD'));
+	mt_srand(generateSeed() + getConfig('_ADD'));
 }
 
 // Filter for removing updates
diff --git a/inc/footer.php b/inc/footer.php
index 556022f0bf..d822c4eb7f 100644
--- a/inc/footer.php
+++ b/inc/footer.php
@@ -45,7 +45,7 @@ if (!defined('__SECURITY')) {
 
 // Footer disabled or already sent?
 // 1234      5                       54    45                              5    5                              543    3                              321
-if ((((!isset($GLOBALS['footer_sent'])) || (($GLOBALS['footer_sent'] != "1") && ($GLOBALS['footer_sent'] != "2"))) && ($GLOBALS['output_mode'] != "1"))) {
+if ((((!isset($GLOBALS['footer_sent'])) || (($GLOBALS['footer_sent'] != '1') && ($GLOBALS['footer_sent'] != '2'))) && ($GLOBALS['output_mode'] != '1'))) {
 	// Output the generated HTML code or do nothing in direct-mode
 	if (getTotalFatalErrors() > 0) {
 		// Output fatal error messages
@@ -53,9 +53,9 @@ if ((((!isset($GLOBALS['footer_sent'])) || (($GLOBALS['footer_sent'] != "1") &&
 	} // END - if
 
 	// Shall we display the copyright notice?
-	if ((!REQUEST_ISSET_GET(('frame'))) && (basename($_SERVER['PHP_SELF']) != "mailid_top.php") && (isBooleanConstantAndTrue('WRITE_FOOTER')) && ($GLOBALS['header_sent'] == "2")) {
+	if ((!REQUEST_ISSET_GET(('frame'))) && (basename($_SERVER['PHP_SELF']) != "mailid_top.php") && (getConfig('WRITE_FOOTER') == 'Y') && ($GLOBALS['header_sent'] == '2')) {
 		// Backlink enabled?
-		if (isBooleanConstantAndTrue('ENABLE_BACKLINK')) {
+		if ((getConfig('ENABLE_BACKLINK') == 'Y') || (isInstalling())) {
 			// Copyright with backlink, thanks! :-)
 			LOAD_TEMPLATE("copyright_backlink");
 		} else {
@@ -65,7 +65,7 @@ if ((((!isset($GLOBALS['footer_sent'])) || (($GLOBALS['footer_sent'] != "1") &&
 	} // END - if
 
 	// Shall we display the parsing time and number of queries?
-	if ((GET_EXT_VERSION('sql_patches') >= '0.4.1') && (getConfig('show_timings') == 'Y') && (!REQUEST_ISSET_GET(('frame'))) && ($GLOBALS['header_sent'] == "2")) {
+	if ((GET_EXT_VERSION('sql_patches') >= '0.4.1') && (getConfig('show_timings') == 'Y') && (!REQUEST_ISSET_GET(('frame'))) && ($GLOBALS['header_sent'] == '2')) {
 		// Then display it here
 		displayParsingTime();
 	} // END - if
diff --git a/inc/functions.php b/inc/functions.php
index dc5fe39367..7262baf0b7 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -41,7 +41,7 @@ if (!defined('__SECURITY')) {
 	require($INC);
 }
 
-// Output HTML code directly or "render" it. You addionally switch the new-line character off
+// Output HTML code directly or 'render' it. You addionally switch the new-line character off
 function OUTPUT_HTML ($HTML, $newLine = true) {
 	// Some global variables
 	global $OUTPUT;
@@ -49,11 +49,11 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 	// Do we have HTML-Code here?
 	if (!empty($HTML)) {
 		// Yes, so we handle it as you have configured
-		switch (constant('OUTPUT_MODE'))
+		switch (getConfig('OUTPUT_MODE'))
 		{
-		case "render":
+		case 'render':
 			// That's why you don't need any \n at the end of your HTML code... :-)
-			if (constant('_OB_CACHING') == "on") {
+			if (constant('_OB_CACHING') == 'on') {
 				// Output into PHP's internal buffer
 				outputRawCode($HTML);
 
@@ -70,7 +70,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 
 		case 'direct':
 			// If we are switching from render to direct output rendered code
-			if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != "on")) { outputRawCode($OUTPUT); $OUTPUT = ''; }
+			if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; }
 
 			// The same as above... ^
 			outputRawCode($HTML);
@@ -79,11 +79,11 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 
 		default:
 			// Huh, something goes wrong or maybe you have edited config.php ???
-			DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", constant('OUTPUT_MODE')));
+			DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", getConfig('OUTPUT_MODE')));
 			app_die(__FUNCTION__, __LINE__, "<strong>{--FATAL_ERROR--}:</strong> {--LANG_NO_RENDER_DIRECT--}");
 			break;
 		}
-	} elseif ((constant('_OB_CACHING') == "on") && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
+	} elseif ((constant('_OB_CACHING') == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
 		// Headers already sent?
 		if (headers_sent()) {
 			// Log this error
@@ -102,20 +102,20 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 		} // END - if
 
 		// Send HTTP header
-		header("HTTP/1.1 200");
+		sendHeader('HTTP/1.1 200');
 
 		// Used later
 		$now = gmdate('D, d M Y H:i:s') . ' GMT';
 
 		// General headers for no caching
-		header("Expired: " . $now); // RFC2616 - Section 14.21
-		header("Last-Modified: " . $now);
-		header("Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0"); // HTTP/1.1
-		header("Pragma: no-cache"); // HTTP/1.0
-		header("Connection: Close");
+		sendHeader('Expired: ' . $now); // RFC2616 - Section 14.21
+		sendHeader('Last-Modified: ' . $now);
+		sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+		sendHeader('Pragma: no-cache'); // HTTP/1.0
+		sendHeader('Connection: Close');
 
 		// Extension 'rewrite' installed?
-		if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) {
+		if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
 			$OUTPUT = rewriteLinksInCode($OUTPUT);
 		} // END - if
 
@@ -136,9 +136,9 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 
 		// Output code here, DO NOT REMOVE! ;-)
 		outputRawCode($OUTPUT);
-	} elseif ((constant('OUTPUT_MODE') == "render") && (!empty($OUTPUT))) {
+	} elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($OUTPUT))) {
 		// Rewrite links when rewrite extension is active
-		if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) {
+		if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
 			$OUTPUT = rewriteLinksInCode($OUTPUT);
 		} // END - if
 
@@ -158,8 +158,8 @@ function outputRawCode ($HTML) {
 	// Output stripped HTML code to avoid broken JavaScript code, etc.
 	echo stripslashes(stripslashes($HTML));
 
-	// Flush the output if only constant('_OB_CACHING') is not "on"
-	if (constant('_OB_CACHING') != "on") {
+	// Flush the output if only constant('_OB_CACHING') is not 'on'
+	if (constant('_OB_CACHING') != 'on') {
 		// Flush it
 		flush();
 	} // END - if
@@ -259,7 +259,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
 	} // END - if
 
 	// Generate date/time string
-	$date_time = generateDateTime(time(), "1");
+	$date_time = generateDateTime(time(), '1');
 
 	// Base directory
 	$basePath = sprintf("%stemplates/%s/html/", constant('PATH'), getLanguage());
@@ -343,12 +343,12 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
 		$ret = "<!-- Template ".$template." - Start -->\n".$ret."<!-- Template ".$template." - End -->\n";
 	} elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
 		// Only admins shall see this warning or when installation mode is active
-		$ret = "<br /><span class=\"guest_failed\">".TEMPLATE_404."</span><br />
+		$ret = "<br /><span class=\"guest_failed\">{--TEMPLATE_404--}</span><br />
 (".basename($FQFN).")<br />
 <br />
-".TEMPLATE_CONTENT."
+{--TEMPLATE_CONTENT--}
 <pre>".print_r($content, true)."</pre>
-".TEMPLATE_DATA."
+{--TEMPLATE_DATA--}
 <pre>".print_r($DATA, true)."</pre>
 <br /><br />";
 	}
@@ -411,7 +411,7 @@ function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
 	//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />\n";
 
 	// Check for PHPMailer or debug-mode
-	if (!CHECK_PHPMAILER_USAGE()) {
+	if (!checkPhpMailerUsage()) {
 		// Not in PHPMailer-Mode
 		if (empty($mailHeader)) {
 			// Load email header template
@@ -450,32 +450,30 @@ Message : ".$message."
 </pre>\n");
 	} elseif (($HTML == 'Y') && (EXT_IS_ACTIVE('html_mail'))) {
 		// Send mail as HTML away
-		SEND_HTML_EMAIL($toEmail, $subject, $message, $mailHeader);
+		sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
 	} elseif (!empty($toEmail)) {
 		// Send Mail away
-		SEND_RAW_EMAIL($toEmail, $subject, $message, $mailHeader);
+		sendRawEmail($toEmail, $subject, $message, $mailHeader);
 	} elseif ($HTML == 'N') {
 		// Problem found!
-		SEND_RAW_EMAIL(constant('WEBMASTER'), "[PROBLEM:]".$subject, $message, $mailHeader);
+		sendRawEmail(constant('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
 	}
 }
 
 // Check if legacy or PHPMailer command
 // @TODO Rewrite this to an extension 'smtp'
 // @private
-function CHECK_PHPMAILER_USAGE() {
-	return ((defined('SMTP_HOSTNAME')) && (defined('SMTP_USER')) && (defined('SMTP_PASSWORD')) && (constant('SMTP_HOSTNAME') != '') && (constant('SMTP_USER') != ''));
+function checkPhpMailerUsage() {
+	return ((getConfig('SMTP_HOSTNAME') != '') && (getConfig('SMTP_USER') != ''));
 }
 
-/*
- * Send out a raw email with PHPMailer class or legacy mail() command
- */
-function SEND_RAW_EMAIL ($toEmail, $subject, $msg, $from) {
+// Send out a raw email with PHPMailer class or legacy mail() command
+function sendRawEmail ($toEmail, $subject, $msg, $from) {
 	// Shall we use PHPMailer class or legacy mode?
-	if (CHECK_PHPMAILER_USAGE()) {
+	if (checkPhpMailerUsage()) {
 		// Use PHPMailer class with SMTP enabled
-		loadIncludeOnce("inc/phpmailer/class.phpmailer.php");
-		loadIncludeOnce("inc/phpmailer/class.smtp.php");
+		loadIncludeOnce('inc/phpmailer/class.phpmailer.php');
+		loadIncludeOnce('inc/phpmailer/class.smtp.php');
 
 		// get new instance
 		$mail = new PHPMailer();
@@ -483,10 +481,10 @@ function SEND_RAW_EMAIL ($toEmail, $subject, $msg, $from) {
 
 		$mail->IsSMTP();
 		$mail->SMTPAuth   = true;
-		$mail->Host       = constant('SMTP_HOSTNAME');
+		$mail->Host       = getConfig('SMTP_HOSTNAME');
 		$mail->Port       = 25;
-		$mail->Username   = constant('SMTP_USER');
-		$mail->Password   = constant('SMTP_PASSWORD');
+		$mail->Username   = getConfig('SMTP_USER');
+		$mail->Password   = getConfig('SMTP_PASSWORD');
 		if (empty($from)) {
 			$mail->From = constant('WEBMASTER');
 		} else {
@@ -496,7 +494,7 @@ function SEND_RAW_EMAIL ($toEmail, $subject, $msg, $from) {
 		$mail->Subject    = $subject;
 		if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($msg) != $msg)) {
 			$mail->Body       = $msg;
-			$mail->AltBody    = "Your mail program required HTML support to read this mail!";
+			$mail->AltBody    = 'Your mail program required HTML support to read this mail!';
 			$mail->WordWrap   = 70;
 			$mail->IsHTML(true);
 		} else {
@@ -504,8 +502,8 @@ function SEND_RAW_EMAIL ($toEmail, $subject, $msg, $from) {
 		}
 		$mail->AddAddress($toEmail, '');
 		$mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE'));
-		$mail->AddCustomHeader("Errors-To:".constant('WEBMASTER'));
-		$mail->AddCustomHeader("X-Loop:".constant('WEBMASTER'));
+		$mail->AddCustomHeader('Errors-To:' . constant('WEBMASTER'));
+		$mail->AddCustomHeader('X-Loop:' . constant('WEBMASTER'));
 		$mail->Send();
 	} else {
 		// Use legacy mail() command
@@ -580,7 +578,7 @@ function generateDateTime ($time, $mode = '0') {
 // Translates Y/N to yes/no
 function translateYesNo ($yn) {
 	// Default
-	$translated = "??? (".$yn.")";
+	$translated = "??? (".$yn.')';
 	switch ($yn) {
 		case 'Y': $translated = getMessage('YES'); break;
 		case 'N': $translated = getMessage('NO'); break;
@@ -728,11 +726,6 @@ function countSelection ($array) {
 	return $ret;
 }
 
-// Wrapper for $_POST['sel']
-function countPostSelection () {
-	return countSelection(REQUEST_POST('sel'));
-}
-
 // Generate XHTML code for the CAPTCHA
 function generateCaptchaCode ($code, $type, $DATA, $uid) {
 	return '<IMG border="0" alt="Code" src="{!URL!}/mailid_top.php?uid=' . $uid . '&amp;' . $type . '=' . $DATA . '&amp;mode=img&amp;code=' . $code . '" />';
@@ -741,13 +734,13 @@ function generateCaptchaCode ($code, $type, $DATA, $uid) {
 // "Getter" for language
 function getLanguage () {
 	// Set default return value to default language from config
-	$ret = constant('DEFAULT_LANG');
+	$ret = getConfig('DEFAULT_LANG');
 
 	// Init variable
 	$lang = '';
 
 	// Is the variable set
-	if (REQUEST_ISSET_GET(('mx_lang'))) {
+	if (REQUEST_ISSET_GET('mx_lang')) {
 		// Accept only first 2 chars
 		$lang = substr(REQUEST_GET('mx_lang'), 0, 2);
 	} elseif (isset($GLOBALS['cache_array']['language'])) {
@@ -755,16 +748,16 @@ function getLanguage () {
 		$ret = $GLOBALS['cache_array']['language'];
 	} elseif (!empty($lang)) {
 		// Check if main language file does exist
-		if (isFileReadable(constant('PATH').'inc/language/'.$lang.'.php')) {
+		if (isFileReadable(constant('PATH') . 'inc/language/'.$lang.'.php')) {
 			// Okay found, so let's update cookies
 			setLanguage($lang);
-		}
-	} elseif (!isSessionVariableSet('mx_lang')) {
+		} // END - if
+	} elseif (isSessionVariableSet('mx_lang')) {
 		// Return stored value from cookie
 		$ret = getSession('mx_lang');
 
 		// Fixes a warning before the session has the mx_lang constant
-		if (empty($ret)) $ret = constant('DEFAULT_LANG');
+		if (empty($ret)) $ret = getConfig('DEFAULT_LANG');
 	}
 
 	// Cache entry
@@ -935,7 +928,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
 	return COMPILE_CODE($newContent);
 }
 
-// Generates a timestamp (wrapper for mktime())
+// Generates a timestamp (some wrapper for mktime())
 function makeTime ($H, $M, $S, $stamp) {
 	// Extract day, month and year from given timestamp
 	$day   = date('d', $stamp);
@@ -947,7 +940,7 @@ function makeTime ($H, $M, $S, $stamp) {
 }
 
 // Redirects to an URL and if neccessarry extends it with own base URL
-function redirectToUrl ($URL, $addUrlData=true) {
+function redirectToUrl ($URL) {
 	// Compile out URI codes
 	$URL = compileUriCode($URL);
 
@@ -958,7 +951,7 @@ function redirectToUrl ($URL, $addUrlData=true) {
 	} // END - if
 
 	// Three different debug ways...
-	//* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+	/* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
 	//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
 	//* DEBUG: */ die($URL);
 
@@ -979,9 +972,6 @@ function redirectToUrl ($URL, $addUrlData=true) {
 		clearOutputBuffer();
 	} // END - if
 
-	// Add some data to URL if cookies are not accepted
-	if ((!isBooleanConstantAndTrue('__COOKIES')) && ($addUrlData === true)) $URL = addUrlData($URL);
-
 	// Secure the URL against bad things such als HTML insertions and so on...
 	$URL = htmlentities(strip_tags($URL), ENT_QUOTES);
 
@@ -992,7 +982,7 @@ function redirectToUrl ($URL, $addUrlData=true) {
 	} elseif (!headers_sent()) {
 		// Load URL when headers are not sent
 		//* DEBUG: */ debug_report_bug("URL={$URL}");
-		header ('Location: '.str_replace('&amp;', '&', $URL));
+		sendHeader('Location: '.str_replace('&amp;', '&', $URL));
 	} else {
 		// Output error message
 		loadInclude('inc/header.php');
@@ -1005,7 +995,7 @@ function redirectToUrl ($URL, $addUrlData=true) {
 }
 
 // Wrapper for redirectToUrl but URL comes from a configuration entry
-function LOAD_CONFIGURED_URL ($configEntry) {
+function redirectToConfiguredUrl ($configEntry) {
 	// Get the URL
 	$URL = getConfig($configEntry);
 
@@ -1278,40 +1268,40 @@ function generateRandomCodde ($length, $code, $uid, $DATA = '') {
 	if (!defined('_MAX')) define('_MAX', 15235);
 
 	// Build server string
-	$server = $_SERVER['PHP_SELF'].constant('ENCRYPT_SEPERATOR').detectUserAgent().constant('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').constant('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(constant('PATH')."inc/databases.php");
+	$server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(constant('PATH').'inc/databases.php');
 
 	// Build key string
-	$keys = constant('SITE_KEY').constant('ENCRYPT_SEPERATOR').constant('DATE_KEY');
-	if (isConfigEntrySet('secret_key'))  $keys .= constant('ENCRYPT_SEPERATOR').getConfig('secret_key');
-	if (isConfigEntrySet('file_hash'))   $keys .= constant('ENCRYPT_SEPERATOR').getConfig('file_hash');
-	$keys .= constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime')));
-	if (isConfigEntrySet('master_salt')) $keys .= constant('ENCRYPT_SEPERATOR').getConfig('master_salt');
+	$keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY');
+	if (isConfigEntrySet('secret_key'))  $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key');
+	if (isConfigEntrySet('file_hash'))   $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash');
+	$keys .= getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime')));
+	if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
 
 	// Build string from misc data
-	$data   = $code.constant('ENCRYPT_SEPERATOR').$uid.constant('ENCRYPT_SEPERATOR').$DATA;
+	$data   = $code.getConfig('ENCRYPT_SEPERATOR').$uid.getConfig('ENCRYPT_SEPERATOR').$DATA;
 
 	// Add more additional data
-	if (isSessionVariableSet('u_hash'))         $data .= constant('ENCRYPT_SEPERATOR').getSession('u_hash');
-	if (isUserIdSet())                          $data .= constant('ENCRYPT_SEPERATOR').getUserId();
-	if (isSessionVariableSet('mxchange_theme')) $data .= constant('ENCRYPT_SEPERATOR').getSession('mxchange_theme');
-	if (isSessionVariableSet('mx_lang'))        $data .= constant('ENCRYPT_SEPERATOR').getLanguage();
-	if (isset($GLOBALS['refid']))               $data .= constant('ENCRYPT_SEPERATOR').$GLOBALS['refid'];
+	if (isSessionVariableSet('u_hash'))         $data .= getConfig('ENCRYPT_SEPERATOR').getSession('u_hash');
+	if (isUserIdSet())                          $data .= getConfig('ENCRYPT_SEPERATOR').getUserId();
+	if (isSessionVariableSet('mxchange_theme')) $data .= getConfig('ENCRYPT_SEPERATOR').getSession('mxchange_theme');
+	if (isSessionVariableSet('mx_lang'))        $data .= getConfig('ENCRYPT_SEPERATOR').getLanguage();
+	if (isset($GLOBALS['refid']))               $data .= getConfig('ENCRYPT_SEPERATOR').$GLOBALS['refid'];
 
 	// Calculate number for generating the code
-	$a = $code + constant('_ADD') - 1;
+	$a = $code + getConfig('_ADD') - 1;
 
 	if (isConfigEntrySet('master_hash')) {
 		// Generate hash with master salt from modula of number with the prime number and other data
-		$saltedHash = generateHash(($a % constant('_PRIME')).constant('ENCRYPT_SEPERATOR').$server.constant('ENCRYPT_SEPERATOR').$keys.constant('ENCRYPT_SEPERATOR').$data.constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", time()).constant('ENCRYPT_SEPERATOR').$a, getConfig('master_salt'));
+		$saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR').$server.getConfig('ENCRYPT_SEPERATOR').$keys.getConfig('ENCRYPT_SEPERATOR').$data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').$a, getConfig('master_salt'));
 
 		// Create number from hash
-		$rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(constant('_MAX') - $a + sqrt(constant('_ADD'))) / pi();
+		$rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
 	} else {
 		// Generate hash with "hash of site key" from modula of number with the prime number and other data
-		$saltedHash = generateHash(($a % constant('_PRIME')).constant('ENCRYPT_SEPERATOR').$server.constant('ENCRYPT_SEPERATOR').$keys.constant('ENCRYPT_SEPERATOR').$data.constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", time()).constant('ENCRYPT_SEPERATOR').$a, substr(sha1(constant('SITE_KEY')), 0, 8));
+		$saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR').$server.getConfig('ENCRYPT_SEPERATOR').$keys.getConfig('ENCRYPT_SEPERATOR').$data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').$a, substr(sha1(getConfig('SITE_KEY')), 0, 8));
 
 		// Create number from hash
-		$rcode = hexdec(substr($saltedHash, 8, 9)) / abs(constant('_MAX') - $a + sqrt(constant('_ADD'))) / pi();
+		$rcode = hexdec(substr($saltedHash, 8, 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
 	}
 
 	// At least 10 numbers shall be secure enought!
@@ -1361,12 +1351,12 @@ function GENERATE_IMAGE ($img_code, $headerSent=true) {
 		// Switch image type
 		switch (getConfig('img_type'))
 		{
-		case "jpg":
+		case 'jpg':
 			// Okay, load image and hide all errors
 			$image = @imagecreatefromjpeg($img);
 			break;
 
-		case "png":
+		case 'png':
 			// Okay, load image and hide all errors
 			$image = @imagecreatefrompng($img);
 			break;
@@ -1384,19 +1374,19 @@ function GENERATE_IMAGE ($img_code, $headerSent=true) {
 	imagestring($image, 5, 14, 2, $img_code, $text_color);
 
 	// Return to browser
-	header ("Content-Type: image/".getConfig('img_type'));
+	sendHeader('Content-Type: image/' . getConfig('img_type'));
 
 	// Output image with matching image factory
 	switch (getConfig('img_type')) {
-		case "jpg": imagejpeg($image); break;
-		case "png": imagepng($image);  break;
+		case 'jpg': imagejpeg($image); break;
+		case 'png': imagepng($image);  break;
 	}
 
 	// Remove image from memory
 	imagedestroy($image);
 }
 // Create selection box or array of splitted timestamp
-function createTimeSelections ($timestamp, $prefix = '', $display = '', $align="center", $return_array=false) {
+function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) {
 	// Calculate 2-seconds timestamp
 	$stamp = round($timestamp);
 	//* DEBUG: */ print("*".$stamp.'/'.$timestamp."*<br />");
@@ -1648,8 +1638,8 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
 		$result = false;
 
 		// "implode" IDs and query string
-		$aid = implode(",", $adminIds);
-		if ($aid == "-1") {
+		$aid = implode(',', $adminIds);
+		if ($aid == '-1') {
 			if (EXT_IS_ACTIVE('events')) {
 				// Add line to user events
 				EVENTS_ADD_LINE($subj, $msg, $UID);
@@ -1719,7 +1709,7 @@ function ADD_EMAIL_NAV ($PAGES, $offset, $show_form, $colspan, $return=false) {
 	$NAV = '';
 	for ($page = 1; $page <= $PAGES; $page++) {
 		// Is the page currently selected or shall we generate a link to it?
-		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == "1"))) {
+		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == '1'))) {
 			// Is currently selected, so only highlight it
 			$NAV .= "<strong>-";
 		} else {
@@ -1733,7 +1723,7 @@ function ADD_EMAIL_NAV ($PAGES, $offset, $show_form, $colspan, $return=false) {
 			$NAV .= "\">";
 		}
 		$NAV .= $page;
-		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == "1"))) {
+		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == '1'))) {
 			// Is currently selected, so only highlight it
 			$NAV .= "-</strong>";
 		} else {
@@ -1901,7 +1891,7 @@ function sendRawRequest ($host, $request) {
 		// Use login data to proxy? (username at least!)
 		if (getConfig('proxy_username') != '') {
 			// Add it as well
-			$encodedAuth = base64_encode(COMPILE_CODE(getConfig('proxy_username')).constant('ENCRYPT_SEPERATOR').COMPILE_CODE(getConfig('proxy_password')));
+			$encodedAuth = base64_encode(COMPILE_CODE(getConfig('proxy_username')).getConfig('ENCRYPT_SEPERATOR').COMPILE_CODE(getConfig('proxy_password')));
 			$proxyTunnel .= "Proxy-Authorization: Basic ".$encodedAuth."\r\n";
 		} // END - if
 
@@ -2091,19 +2081,19 @@ function generateHash ($plainText, $salt = '') {
 	// When the salt is empty build a new one, else use the first x configured characters as the salt
 	if (empty($salt)) {
 		// Build server string (inc/databases.php is no longer updated with every commit)
-		$server = $_SERVER['PHP_SELF'].constant('ENCRYPT_SEPERATOR').detectUserAgent().constant('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').constant('ENCRYPT_SEPERATOR').detectRemoteAddr();
+		$server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr();
 
 		// Build key string
-		$keys   = constant('SITE_KEY').constant('ENCRYPT_SEPERATOR').constant('DATE_KEY').constant('ENCRYPT_SEPERATOR').getConfig('secret_key').constant('ENCRYPT_SEPERATOR').getConfig('file_hash').constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime'))).constant('ENCRYPT_SEPERATOR').getConfig('master_salt');
+		$keys   = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key').getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash').getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime'))).getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
 
 		// Additional data
-		$data = $plainText.constant('ENCRYPT_SEPERATOR').uniqid(mt_rand(), true).constant('ENCRYPT_SEPERATOR').time();
+		$data = $plainText.getConfig('ENCRYPT_SEPERATOR').uniqid(mt_rand(), true).getConfig('ENCRYPT_SEPERATOR').time();
 
 		// Calculate number for generating the code
-		$a = time() + constant('_ADD') - 1;
+		$a = time() + getConfig('_ADD') - 1;
 
 		// Generate SHA1 sum from modula of number and the prime number
-		$sha1 = sha1(($a % constant('_PRIME')).$server.constant('ENCRYPT_SEPERATOR').$keys.constant('ENCRYPT_SEPERATOR').$data.constant('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", time()).constant('ENCRYPT_SEPERATOR').$a);
+		$sha1 = sha1(($a % getConfig('_PRIME')).$server.getConfig('ENCRYPT_SEPERATOR').$keys.getConfig('ENCRYPT_SEPERATOR').$data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').$a);
 		//* DEBUG: */ echo "SHA1=".$sha1." (".strlen($sha1).")<br />";
 		$sha1 = scrambleString($sha1);
 		//* DEBUG: */ echo "Scrambled=".$sha1." (".strlen($sha1).")<br />";
@@ -2203,31 +2193,6 @@ function genScrambleString ($len) {
 	return $scrambleString;
 }
 
-// Append data like session ID or referal ID to the given URL which would
-// normally be stored in cookies
-function addUrlData ($URL) {
-	// Init add
-	$add = '';
-
-	// Determine URL binder
-	$BIND = '?';
-	if (strpos($URL, '?') !== false) $BIND = '&amp;';
-
-	if ((!defined('__COOKIES')) || ((!constant('__COOKIES')))) {
-		// Cookies are not accepted
-		if ((REQUEST_ISSET_GET(('refid'))) && (strpos($URL, "refid=") == 0)) {
-			// Cookie found in URL
-			$add .= $BIND."refid=".bigintval(REQUEST_GET('refid'));
-		} elseif ((GET_EXT_VERSION('sql_patches') != '') && (getConfig('def_refid') > 0)) {
-			// Not found! So let's set default here
-			$add .= $BIND."refid=".getConfig('def_refid');
-		}
-	} // END - if
-
-	// Add all together and return it
-	return $URL . $add;
-}
-
 // Generate an PGP-like encrypted hash of given hash for e.g. cookies
 function generatePassString ($passHash) {
 	// Return vanilla password hash
@@ -2242,9 +2207,9 @@ function generatePassString ($passHash) {
 			$part2 = hexdec(substr(getConfig('secret_key'), $start, 4));
 			$mod = dechex($idx);
 			if ($part1 > $part2) {
-				$mod = dechex(sqrt(($part1 - $part2) * constant('_PRIME') / pi()));
+				$mod = dechex(sqrt(($part1 - $part2) * getConfig('_PRIME') / pi()));
 			} elseif ($part2 > $part1) {
-				$mod = dechex(sqrt(($part2 - $part1) * constant('_PRIME') / pi()));
+				$mod = dechex(sqrt(($part2 - $part1) * getConfig('_PRIME') / pi()));
 			}
 			$mod = substr(round($mod), 0, 4);
 			$mod = str_repeat('0', 4-strlen($mod)).$mod;
@@ -2253,7 +2218,7 @@ function generatePassString ($passHash) {
 			$newHash .= $mod;
 		} // END - for
 
-		//* DEBUG: */ print($passHash."<br />".$newHash." (".strlen($newHash).")");
+		//* DEBUG: */ print($passHash."<br />".$newHash." (".strlen($newHash).')');
 		$ret = generateHash($newHash, getConfig('master_salt'));
 		//* DEBUG: */ print($ret."<br />\n");
 	} else {
@@ -2476,60 +2441,6 @@ function getThemeId ($name) {
 	return $id;
 }
 
-// Read a given file
-function readFromFile ($FQFN, $sqlPrepare = false) {
-	// Load the file
-	if (function_exists('file_get_contents')) {
-		// Use new function
-		$content = file_get_contents($FQFN);
-	} else {
-		// Fall-back to implode-file chain
-		$content = implode('', file($FQFN));
-	}
-
-	// Prepare SQL queries?
-	if ($sqlPrepare === true) {
-		// Remove some unwanted chars
-		$content = str_replace("\r", '', $content);
-		$content = str_replace("\n\n", "\n", $content);
-	} // END - if
-
-	// Return the content
-	return $content;
-}
-
-// Writes content to a file
-function writeToFile ($FQFN, $content) {
-	// Is the file writeable?
-	if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!chmod($FQFN, 0644))) {
-		// Not writeable!
-		DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
-
-		// Failed! :(
-		return false;
-	} // END - if
-
-	// By default all is failed...
-	$return = false;
-
-	// Is the function there?
-	if (function_exists('file_put_contents')) {
-		// Write it directly
-		$return = file_put_contents($FQFN, $content);
-	} else {
-		// Write it with fopen
-		$fp = fopen($FQFN, 'w') or app_die(__FUNCTION__, __LINE__, "Cannot write file ".basename($FQFN).'!');
-		fwrite($fp, $content);
-		fclose($fp);
-
-		// Set CHMOD rights
-		$return = chmod($FQFN, 0644);
-	}
-
-	// Return status
-	return $return;
-}
-
 // Generates an error code from given account status
 function generateErrorCodeFromUserStatus ($status) {
 	// Default error code if unknown account status
@@ -2551,15 +2462,6 @@ function generateErrorCodeFromUserStatus ($status) {
 	return $errorCode;
 }
 
-// Clears the output buffer. This function does *NOT* backup sent content.
-function clearOutputBuffer () {
-	// Trigger an error on failure
-	if (!ob_end_clean()) {
-		// Failed!
-		debug_report_bug(__FUNCTION__.': Failed to clean output buffer.');
-	} // END - if
-}
-
 // Function to search for the last modifified file
 function searchDirsRecursive ($dir, &$last_changed) {
 	// Get dir as array
@@ -2737,35 +2639,6 @@ function getArrayFromActualVersion () {
 	return $akt_vers;
 }
 
-
-// Loads an include file and logs any missing files for debug purposes
-function loadInclude ($INC) {
-	// Add the path. This is why we need a trailing slash in config.php
-	$FQFN = constant('PATH') . $INC;
-
-	// Is the include file there?
-	if (!isIncludeReadable($INC)) {
-		// Not there so log it
-		debug_report_bug(sprintf("Include file %s not found.", $INC));
-		return false;
-	} // END - if
-
-	// Try to load it
-	require($FQFN);
-}
-
-// Loads an include file once
-function loadIncludeOnce ($INC) {
-	// Is it not loaded?
-	if (!isset($GLOBALS['load_once'][$INC])) {
-		// Then try to load it
-		loadInclude($INC);
-
-		// And mark it as loaded
-		$GLOBALS['load_once'][$INC] = "loaded";
-	} // END - if
-}
-
 // Back-ported from the new ship-simu engine. :-)
 function debug_get_printable_backtrace () {
 	// Init variable
@@ -2777,7 +2650,7 @@ function debug_get_printable_backtrace () {
 		if (!isset($trace['file'])) $trace['file'] = __FUNCTION__;
 		if (!isset($trace['line'])) $trace['line'] = __LINE__;
 		if (!isset($trace['args'])) $trace['args'] = array();
-		$backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span></li>\n";
+		$backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function'].'('.count($trace['args']).")</span></li>\n";
 	} // END - foreach
 
 	// Close it
@@ -2805,7 +2678,7 @@ function debug_report_bug ($message = '') {
 	// Add output
 	$debug .= "Please report this bug at <a href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a>:<pre>";
 	$debug .= debug_get_printable_backtrace();
-	$debug .= "</pre>Request-URI: ".$_SERVER['REQUEST_URI']."<br />\n";
+	$debug .= "</pre>\nRequest-URI: ".$_SERVER['REQUEST_URI']."<br />\n";
 	$debug .= "Thank you for finding bugs.";
 
 	// And abort here
@@ -2841,8 +2714,8 @@ function convertCodeToMessage ($code) {
 			break;
 
 		case getCode('EXTENSION_PROBLEM'):
-			if (REQUEST_ISSET_GET(('ext'))) {
-				$msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), REQUEST_GET(('ext')));
+			if (REQUEST_ISSET_GET('ext')) {
+				$msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), REQUEST_GET('ext'));
 			} else {
 				$msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT');
 			}
@@ -2896,29 +2769,6 @@ function generateAdminLink ($aid) {
 	return $admin;
 }
 
-// Checks wether an include file (non-FQFN better) is readable
-function isIncludeReadable ($INC) {
-	// Construct FQFN
-	$FQFN = constant('PATH') . $INC;
-
-	// Is it readable?
-	return isFileReadable($FQFN);
-}
-
-// Encode strings
-// @TODO Implement $compress
-function encodeString ($str, $compress=true) {
-	$str = urlencode(base64_encode(compileUriCode($str)));
-	return $str;
-}
-
-// Decode strings encoded with encodeString()
-// @TODO Implement $decompress
-function decodeString ($str, $decompress=true) {
-	$str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
-	return $str;
-}
-
 // Compile characters which are allowed in URLs
 function compileUriCode ($code, $simple=true) {
 	// Compile constants
@@ -3008,21 +2858,6 @@ function isUrlValidSimple ($url) {
 	return $reg;
 }
 
-// Smartly adds slashes
-function smartAddSlashes ($unquoted) {
-	$unquoted = str_replace("\\", '', $unquoted);
-	return addslashes($unquoted);
-}
-
-// Decode entities in a nicer way
-function decodeEntities ($str) {
-	// Decode the entities to UTF-8 now
-	$decodedString = html_entity_decode($str, ENT_NOQUOTES, "UTF-8");
-
-	// Return decoded string
-	return $decodedString;
-}
-
 // Wtites data to a config.php-style file
 // @TODO Rewrite this function to use readFromFile() and writeToFile()
 function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
@@ -3106,26 +2941,6 @@ function sendAdminNotification ($subject, $templateName, $content=array(), $uid
 	}
 }
 
-// Merges an array together but only if both are arrays
-function merge_array ($array1, $array2) {
-	// Are both an array?
-	if ((is_array($array1)) && (is_array($array2))) {
-		// Merge all together
-		return array_merge($array1, $array2);
-	} elseif (is_array($array1)) {
-		// Return left array
-		DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
-		return $array1;
-	} elseif (is_array($array2)) {
-		// Return right array
-		DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
-		return $array2;
-	}
-
-	// Both are not arrays
-	debug_report_bug(__FUNCTION__.": No arrays provided!");
-}
-
 // Debug message logger
 function DEBUG_LOG ($funcFile, $line, $message, $force=true) {
 	// Is debug mode enabled?
@@ -3152,7 +2967,7 @@ function runResetIncludes () {
 	SET_INC_POOL(getArrayFromDirectory('inc/reset/', 'reset_'));
 
 	// Update database
-	if (!defined('DEBUG_RESET')) updateConfiguration('last_update', time());
+	if (getConfig('DEBUG_RESET') != 'Y') updateConfiguration('last_update', time());
 
 	// Is the config entry set?
 	if (GET_EXT_VERSION('sql_patches') >= '0.4.2') {
@@ -3165,7 +2980,7 @@ function runResetIncludes () {
 			MERGE_INC_POOL(getArrayFromDirectory('inc/weekly/', 'weekly_'));
 
 			// Update config
-			if (!defined('DEBUG_WEEKLY')) updateConfiguration('last_week', $currWeek);
+			if (getConfig('DEBUG_WEEKLY') != 'Y') updateConfiguration('last_week', $currWeek);
 		} // END - if
 
 		// Create current month mark
@@ -3177,7 +2992,7 @@ function runResetIncludes () {
 			MERGE_INC_POOL(getArrayFromDirectory('inc/monthly/', 'monthly_'));
 
 			// Update config
-			if (!defined('DEBUG_MONTHLY')) updateConfiguration('last_month', $currMonth);
+			if (getConfig('DEBUG_MONTHLY') != 'Y') updateConfiguration('last_month', $currMonth);
 		} // END - if
 	} // END - if
 
@@ -3218,12 +3033,6 @@ function handleExtraValues ($filterFunction, $value, $extraValue) {
 	return $ret;
 }
 
-// Check if given FQFN is a readable file
-function isFileReadable ($FQFN) {
-	// Check all...
-	return ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
-}
-
 // Converts timestamp selections into a timestamp
 function convertSelectionsToTimestamp (&$POST, &$DATA, &$id, &$skip) {
 	// Init test variable
@@ -3294,7 +3103,7 @@ function HANDLE_LOGIN_FAILTURES ($accessLevel) {
 			//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):accessLevel={$accessLevel}<br />\n";
 			$content = array(
 				'login_failures' => getSession('mxchange_'.$accessLevel.'_failures'),
-				'last_failure'   => generateDateTime(getSession('mxchange_'.$accessLevel.'_last_fail'), "2")
+				'last_failure'   => generateDateTime(getSession('mxchange_'.$accessLevel.'_last_fail'), '2')
 			);
 
 			// Load template
@@ -3372,8 +3181,8 @@ function determineRealRemoteAddress () {
 	}
 
 	// This strips out the real address from proxy output
-	if (strstr($address, ",")){
-		$addressArray = explode(",", $address);
+	if (strstr($address, ',')){
+		$addressArray = explode(',', $address);
 		$address = $addressArray[0];
 	} // END - if
 
@@ -3381,66 +3190,6 @@ function determineRealRemoteAddress () {
 	return $address;
 }
 
-// "Getter" for remote IP number
-function detectRemoteAddr () {
-	// Get remote ip from environment
-	$remoteAddr = determineRealRemoteAddress();
-
-	// Is removeip installed?
-	if (EXT_IS_ACTIVE('removeip')) {
-		// Then anonymize it
-		$remoteAddr = GET_ANONYMOUS_REMOTE_ADDR($remoteAddr);
-	} // END - if
-
-	// Return it
-	return $remoteAddr;
-}
-
-// "Getter" for remote hostname
-function detectRemoteHostname () {
-	// Get remote ip from environment
-	$remoteHost = getenv('REMOTE_HOST');
-
-	// Is removeip installed?
-	if (EXT_IS_ACTIVE('removeip')) {
-		// Then anonymize it
-		$remoteHost = GET_ANONYMOUS_REMOTE_HOST($remoteHost);
-	} // END - if
-
-	// Return it
-	return $remoteHost;
-}
-
-// "Getter" for user agent
-function detectUserAgent () {
-	// Get remote ip from environment
-	$userAgent = getenv('HTTP_USER_AGENT');
-
-	// Is removeip installed?
-	if (EXT_IS_ACTIVE('removeip')) {
-		// Then anonymize it
-		$userAgent = GET_ANONYMOUS_USER_AGENT($userAgent);
-	} // END - if
-
-	// Return it
-	return $userAgent;
-}
-
-// "Getter" for referer
-function detectReferer () {
-	// Get remote ip from environment
-	$referer = getenv('HTTP_REFERER');
-
-	// Is removeip installed?
-	if (EXT_IS_ACTIVE('removeip')) {
-		// Then anonymize it
-		$referer = GET_ANONYMOUS_REFERER($referer);
-	} // END - if
-
-	// Return it
-	return $referer;
-}
-
 // Adds a bonus mail to the queue
 // This is a high-level function!
 function addNewBonusMail ($data, $mode = '', $output=true) {
@@ -3499,7 +3248,7 @@ function DETERMINE_REFID () {
 		$GLOBALS['refid'] = getConfig(('def_refid'));
 	} elseif ((GET_EXT_VERSION('user') >= '0.3.4') && (getConfig('select_user_zero_refid')) == 'Y') {
 		// Select a random user which has confirmed enougth mails
-		$GLOBALS['refid'] = SELECT_RANDOM_REFID();
+		$GLOBALS['refid'] = determineRandomReferalId();
 	} else {
 		// No default ID when sql_patches is not installed or none set
 		$GLOBALS['refid'] = 0;
@@ -3515,23 +3264,6 @@ function DETERMINE_REFID () {
 	return $GLOBALS['refid'];
 }
 
-// Check wether we are installing
-function isInstalling () {
-	$installing = ((isset($GLOBALS['mxchange_installing'])) || (REQUEST_ISSET_GET('installing')));
-	//* DEBUG: */ var_dump($installing);
-	return $installing;
-}
-
-// Check wether this script is installed
-function isInstalled () {
-	return isBooleanConstantAndTrue('mxchange_installed');
-}
-
-// Check wether an admin is registered
-function isAdminRegistered () {
-	return isBooleanConstantAndTrue('admin_registered');
-}
-
 // Enables the reset mode. Only call this function if you really want the
 // reset to be run!
 function enableResetMode () {
@@ -3542,23 +3274,6 @@ function enableResetMode () {
 	runFilterChain('reset_enabled');
 }
 
-// Checks wether the reset mode is active
-function isResetModeEnabled () {
-	// Now simply check it
-	return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
-}
-
-// Checks wether the debug mode is enabled
-function isDebugModeEnabled () {
-	// Simply check it
-	return isBooleanConstantAndTrue('DEBUG_MODE');
-}
-
-// Checks wether the cache instance is valid
-function isCacheInstanceValid () {
-	return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
-}
-
 // Our shutdown-function
 function shutdown () {
 	// Call the filter chain 'shutdown'
@@ -3601,33 +3316,43 @@ function isUserIdSet () {
 	return (isset($GLOBALS['userid']));
 }
 
-// Checks wether the given FQFN is a directory and not .,.. or .svn
-function isDirectory ($FQFN) {
-	// Generate baseName
-	$baseName = basename($FQFN);
-
-	// Check it
-	$isDirectory = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != ".svn"));
-
-	// Return the result
-	return $isDirectory;
-}
-
 // Handle message codes from URL
 function handleCodeMessage () {
-	if (REQUEST_ISSET_GET(('msg'))) {
+	if (REQUEST_ISSET_GET('msg')) {
 		// Default extension is "unknown"
-		$ext = "unknown";
+		$ext = 'unknown';
 
 		// Is extension given?
-		if (REQUEST_ISSET_GET(('ext'))) $ext = REQUEST_GET(('ext'));
+		if (REQUEST_ISSET_GET('ext')) $ext = REQUEST_GET('ext');
 
 		// Convert the 'msg' parameter from URL to a human-readable message
 		$msg = convertCodeToMessage(REQUEST_GET('msg'));
 
 		// Load message template
-		LOAD_TEMPLATE("message", false, $msg);
+		LOAD_TEMPLATE('message', false, $msg);
+	} // END - if
+}
+
+// Setter for extra title
+function setExtraTitle ($extraTitle) {
+	$GLOBALS['extra_title'] = $extraTitle;
+}
+
+// Getter for extra title
+function getExtraTitle () {
+	// Is the extra title set?
+	if (!isExtraTitleSet()) {
+		// No, then abort here
+		debug_report_bug('extra_title is not set!');
 	} // END - if
+
+	// Return it
+	return $GLOBALS['extra_title'];
+}
+
+// Checks if the extra title is set
+function isExtraTitleSet () {
+	return ((isset($GLOBALS['extra_title'])) && (!empty($GLOBALS['extra_title'])));
 }
 
 //////////////////////////////////////////////////
diff --git a/inc/header.php b/inc/header.php
index 5c904093df..9afbe993d2 100644
--- a/inc/header.php
+++ b/inc/header.php
@@ -45,9 +45,9 @@ if (!defined('__SECURITY')) {
 }
 
 // Is the header already sent?
-if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) {
+if (($GLOBALS['header_sent'] != '1') && ($GLOBALS['header_sent'] != '2')) {
 	// If not in CSS mode generate the header
-	if (($GLOBALS['output_mode'] != "1")) {
+	if (($GLOBALS['output_mode'] != '1')) {
 		// Generate header
 		$TITLE = '';
 
@@ -59,9 +59,9 @@ if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) {
 				if ((getConfig('enable_title_deco') == 'Y') && (getConfig('title_left') != '')) $TITLE .= trim(getConfig('title_left'))." ";
 
 				// Do we have some extra title?
-				if (!empty($EXTRA_TITLE)) {
+				if (isExtraTitleSet()) {
 					// Then prepent it
-					$TITLE .= $EXTRA_TITLE." by ";
+					$TITLE .= getExtraTitle() . ' by ';
 				} // END - if
 
 				// Add main title
@@ -81,9 +81,12 @@ if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) {
 
 				// Remember title in constant for the template
 				define('__PAGE_TITLE', $TITLE);
+			} elseif ((isInstalled()) && (!isAdminRegistered())) {
+				// Installed but no admin registered
+				define('__PAGE_TITLE', sprintf(getMessage('SETUP_OF_MXCHANGE'), constant('MAIN_TITLE')));
 			} elseif ((!isInstalled()) || (!isAdminRegistered())) {
 				// Installation mode
-				define('__PAGE_TITLE', sprintf(getMessage('INSTALLATION_OF_MXCHANGE'), constant('MAIN_TITLE')));
+				define('__PAGE_TITLE', getMessage('INSTALLATION_OF_MXCHANGE'));
 			} else {
 				// Configuration not found!
 				define('__PAGE_TITLE', getMessage('NO_CONFIG_FOUND_TITLE'));
@@ -97,12 +100,12 @@ if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) {
 		unset($TITLE);
 
 		// Output page header code
-		LOAD_TEMPLATE("page_header");
+		LOAD_TEMPLATE('page_header');
 
 		// Include meta data in 'guest' module
 		if ($GLOBALS['module'] == 'index') {
 			// Load meta data template
-			LOAD_TEMPLATE("metadata");
+			LOAD_TEMPLATE('metadata');
 
 			// Add meta description to header
 			if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
@@ -112,23 +115,23 @@ if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) {
 		} // END - if
 
 		// Include more header data here
-		LOAD_TEMPLATE("header");
+		LOAD_TEMPLATE('header');
 
 		// Include stylesheet
-		loadIncludeOnce("inc/stylesheet.php");
+		loadIncludeOnce('inc/stylesheet.php');
 	} // END - if
 
 	// Closing HEAD tag
-	if ($GLOBALS['output_mode'] != "1") OUTPUT_HTML("</head>");
+	if ($GLOBALS['output_mode'] != '1') OUTPUT_HTML('</head>');
 	$GLOBALS['header_sent'] = 1;
 } // END - if
 
 // Load body or not
-if (($GLOBALS['module'] != "frametester") || (($GLOBALS['module'] == "frametester") && (REQUEST_ISSET_GET(('frame')))) || (($GLOBALS['header_sent'] == "1") && (REQUEST_ISSET_GET(('frame')))) && ($GLOBALS['output_mode'] != "1")) {
+if (($GLOBALS['module'] != 'frametester') || (($GLOBALS['module'] == 'frametester') && (REQUEST_ISSET_GET(('frame')))) || (($GLOBALS['header_sent'] == '1') && (REQUEST_ISSET_GET(('frame')))) && ($GLOBALS['output_mode'] != '1')) {
 	// Is the header sent and the script is not the mail confirmation script and not a CSS?
-	if (($GLOBALS['header_sent'] == "1") && (basename($_SERVER['PHP_SELF']) != "mailid.php") && ($GLOBALS['output_mode'] != "1")) {
+	if (($GLOBALS['header_sent'] == '1') && (basename($_SERVER['PHP_SELF']) != 'mailid.php') && ($GLOBALS['output_mode'] != '1')) {
 		// Add BODY tag
-		LOAD_TEMPLATE("page_body");
+		LOAD_TEMPLATE('page_body');
 		$GLOBALS['header_sent'] = 2;
 	} // END - if
 } // END - if
diff --git a/inc/inc-functions.php b/inc/inc-functions.php
index 7dc1946e0c..a2a63b5929 100644
--- a/inc/inc-functions.php
+++ b/inc/inc-functions.php
@@ -63,7 +63,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $includeDirs = false, $addBas
 	$INCs = array();
 
 	// Open directory
-	$dirPointer = opendir(constant('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, "Cannot read ".basename($baseDir)." path!");
+	$dirPointer = opendir(constant('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read '.basename($baseDir).' path!');
 
 	// Read all entries
 	while ($baseFile = readdir($dirPointer)) {
@@ -88,7 +88,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $includeDirs = false, $addBas
 
 		// Is this a valid reset file?
 		//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}");
-		if (((isFileReadable($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) || (($includeDirs) && (isDirectory($FQFN)))) {
+		if (((isFileReadable($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == '.php')) || (($includeDirs) && (isDirectory($FQFN)))) {
 			// Remove both for extension name
 			$extName = substr($baseFile, strlen($prefix), -4);
 
diff --git a/inc/install-inc.php b/inc/install-inc.php
index 6073f4e66d..3b93829627 100644
--- a/inc/install-inc.php
+++ b/inc/install-inc.php
@@ -44,7 +44,7 @@
 if (!defined('__SECURITY')) {
 	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
 	require($INC);
-}
+} // END - if
 
 // Init variables
 $mysql = array();
@@ -79,30 +79,29 @@ if ((REQUEST_ISSET_GET('page') && (REQUEST_GET('page') == 5))) {
 } // END - if
 
 // Is MXChange installed or no admin registered so far?
-if ((!isInstalled()) || (!isAdminRegistered()))
-{
+if ((!isInstalled()) || (!isAdminRegistered())) {
 	// Set URL for FORM actions
 	define('__BURL_ACTION', constant('URL'));
 
 	// Output page for entered value
 	switch (REQUEST_GET('page'))
 	{
-	case "welcome": // Welcome to the installation!
-		LOAD_TEMPLATE("install_welcome");
+	case 'welcome': // Welcome to the installation!
+		LOAD_TEMPLATE('install_welcome');
 		break;
 
-	case "1": // Server path, base URL
+	case '1': // Server path, base URL
 		// @Profi-Concept: Hab meine Meinung doch geaendert! :-)
 		// Load template
-		LOAD_TEMPLATE("install_page1");
+		LOAD_TEMPLATE('install_page1');
 		break;
 
-	case "2": // MySQL data (alone!)
-		if (empty($mysql['dbase']))  $mysql['dbase']  = "your_database";
-		if (empty($mysql['login']))  $mysql['login']  = "your_login";
-		if (empty($mysql['host']))   $mysql['host']   = "localhost";
-		if (empty($mysql['prefix'])) $mysql['prefix'] = "mxchange";
-		if (empty($mysql['type']))   $mysql['type']   = "MyISAM";
+	case '2': // MySQL data (alone!)
+		if (empty($mysql['dbase']))  $mysql['dbase']  = 'your_database';
+		if (empty($mysql['login']))  $mysql['login']  = 'your_login';
+		if (empty($mysql['host']))   $mysql['host']   = 'localhost';
+		if (empty($mysql['prefix'])) $mysql['prefix'] = 'mxchange';
+		if (empty($mysql['type']))   $mysql['type']   = 'MyISAM';
 		if (getTotalFatalErrors() > 0) {
 			OUTPUT_HTML("<span class=\"install_fatal\">");
 			foreach (getFatalArray() as $key => $err) {
@@ -122,10 +121,10 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 		define('__EMAIL_VALUE' , REQUEST_POST('email'));
 
 		// Load template
-		LOAD_TEMPLATE("install_page2");
+		LOAD_TEMPLATE('install_page2');
 		break;
 
-	case "3":
+	case '3':
 		// Set more values
 		define('__SPATH_VALUE' , REQUEST_POST('spath'));
 		define('__BURL_VALUE'  , REQUEST_POST('burl'));
@@ -134,14 +133,18 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 		define('__EMAIL_VALUE' , REQUEST_POST('email'));
 
 		// Use default SMTP data
-		$smtpHost  = constant('SMTP_HOSTNAME');
-		$smtpUser  = constant('SMTP_USER');
-		$smtpPass1 = constant('SMTP_PASSWORD');
-		$smtpPass2 = constant('SMTP_PASSWORD');
+		$smtpHost  = getConfig('SMTP_HOSTNAME');
+		$smtpUser  = getConfig('SMTP_USER');
+		$smtpPass1 = getConfig('SMTP_PASSWORD');
+		$smtpPass2 = getConfig('SMTP_PASSWORD');
 
 		// Overwrite it with the data from sent (failed) form
 		if (REQUEST_ISSET_POST(('smtp_host'))) $smtpHost = REQUEST_POST('smtp_host');
 		if (REQUEST_ISSET_POST(('smtp_user'))) $smtpUser = REQUEST_POST('smtp_user');
+		if (REQUEST_ISSET_POST(('smtp_pass'))) {
+			$smtpPass1 = REQUEST_POST('smtp_pass');
+			$smtpPass2 = REQUEST_POST('smtp_pass');
+		} // END - if
 
 		// MySQL settings
 		define('__MYSQL_HOST'  , $mysql['host']);
@@ -159,10 +162,10 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 		define('__SMTP_PASS2', $smtpPass2);
 
 		// Load template
-		LOAD_TEMPLATE("install_page3");
+		LOAD_TEMPLATE('install_page3');
 		break;
 
-	case "5": // Misc settings
+	case '5': // Misc settings
 		// General settings
 		define('__SPATH_VALUE' , REQUEST_POST('spath'));
 		define('__BURL_VALUE'  , REQUEST_POST('burl'));
@@ -199,12 +202,8 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td class=\"install\" align=\"right\">{--LANG_OUTPUT_MODE--}:&nbsp;&nbsp;</td>
   <td>
     <select name=\"omode\" size=\"1\" class=\"install_select\">
-      <option value=\"render\"");
-		if (constant('OUTPUT_MODE') == 'render') OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--MODE_RENDER--}</option>
-      <option value=\"direct\"");
-		if (constant('OUTPUT_MODE') == 'direct') OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--MODE_DIRECT--}</option>
+      <option value=\"render\">{--MODE_RENDER--}</option>
+      <option value=\"direct\">{--MODE_DIRECT--}</option>
     </select>
   </td>
 </tr>
@@ -213,12 +212,8 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td class=\"install\" align=\"right\">{--WARN_NO_PASSWORD--}:&nbsp;&nbsp;</td>
   <td>
     <select name=\"warn_no_pass\" size=\"1\" class=\"install_select\">
-      <option value=\"true\"");
-		if (isBooleanConstantAndTrue('warn_no_pass')) OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--YES--}</option>
-      <option value=\"false\"");
-		if (!isBooleanConstantAndTrue('warn_no_pass')) OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--NO--}</option>
+      <option value=\"Y\">{--YES--}</option>
+      <option value=\"N\">{--NO--}</option>
     </select>
   </td>
 </tr>
@@ -227,12 +222,8 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td class=\"install\" align=\"right\">{--LANG_WRITE_FOOTER--}:&nbsp;&nbsp;</td>
   <td>
     <select name=\"wfooter\" size=\"1\" class=\"install_select\">
-      <option value=\"true\"");
-		if (isBooleanConstantAndTrue('WRITE_FOOTER')) OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--YES--}</option>
-      <option value=\"false\"");
-		if (!isBooleanConstantAndTrue('WRITE_FOOTER')) OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--NO--}</option>
+      <option value=\"Y\">{--YES--}</option>
+      <option value=\"N\">{--NO--}</option>
     </select>
   </td>
 </tr>
@@ -241,12 +232,8 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td class=\"install\" align=\"right\">{--INSTALL_ENABLE_BACKLINK--}:&nbsp;&nbsp;</td>
   <td>
     <select name=\"blink\" size=\"1\" class=\"install_select\">
-      <option value=\"true\"");
-		if (isBooleanConstantAndTrue('ENABLE_BACKLINK')) OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--YES--}</option>
-      <option value=\"false\"");
-		if (!isBooleanConstantAndTrue('ENABLE_BACKLINK')) OUTPUT_HTML(' selected="selected"');
-		OUTPUT_HTML(">{--NO--}</option>
+      <option value=\"Y\">{--YES--}</option>
+      <option value=\"N\">{--NO--}</option>
     </select>
   </td>
 </tr>
@@ -272,7 +259,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 </form>");
 		break;
 
-	case "finalize": // Write captured data to files
+	case 'finalize': // Write captured data to files
 		if ((REQUEST_ISSET_POST(('finalize'))) && (!isInstalled())) {
 			// You have submitted data then we have to reset the SQLs
 			INIT_SQLS();
@@ -283,7 +270,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 				// Seems to work, also right database?
 				if (SQL_SELECT_DB($mysql['dbase'], __FILE__, __LINE__) === true) {
 					// Automatically run install.sql
-					if ((isFileReadable(REQUEST_POST('spath').'install/tables.sql')) && (isFileReadable(REQUEST_POST('spath').'install/menu-'.getLanguage().'.sql'))) {
+					if ((isFileReadable(REQUEST_POST('spath') . 'install/tables.sql')) && (isFileReadable(REQUEST_POST('spath') . 'install/menu-'.getLanguage().'.sql'))) {
 						// Both exists so import them
 						foreach (array('tables', 'menu-'.getLanguage()) as $dump) {
 							// Should be save here because file_exists() is there but we check it again. :)
@@ -301,8 +288,8 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 									} // END - while
 								} // END - foreach
 
-								// And split it up against ;\n ...
-								SET_SQLS(merge_array(GET_SQLS(), explode(";\n", $fileContent)));
+								// Split it up against ";\n" and merge it into existing SQLs
+								MERGE_SQLS(explode(";\n", $fileContent));
 							} else {
 								// Not readable!
 								debug_report_bug(sprintf("SQL dump %s is not readable!", $dump));
@@ -319,26 +306,37 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 						// Now run all queries through and try to keep out empty or comment queries
 						runFilterChain('run_sqls');
 
+						// Copy the config template and verify it
+						copyFileVerified(REQUEST_POST('spath') . 'inc/config-local.php.dist', REQUEST_POST('spath') . 'inc/cache/config-local.php', 0644);
+
 						// Ok, all done. So we can write the config data to the php files
-						if (REQUEST_POST('spath') != constant('PATH')) changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SERVER-PATH", "define('PATH', \"", "\");", REQUEST_POST('spath'), 0);
-						if (REQUEST_POST('burl')  != constant('URL'))  changeDataInFile(REQUEST_POST('spath')."inc/config.php", "HOST-URL", "define('URL', \"", "\");", REQUEST_POST('burl'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MAIN_TITLE", "define('MAIN_TITLE', \"", "\");", REQUEST_POST('title'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SLOGAN", "define('SLOGAN', \"", "\");", REQUEST_POST('slogan'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "WEBMASTER", "define('WEBMASTER', \"", "\");", REQUEST_POST('email'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "NULLPASS-WARNING", "define('warn_no_pass', ", ");", REQUEST_POST('warn_no_pass'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "WRITE-FOOTER", "define('WRITE_FOOTER', ", ");", REQUEST_POST('wfooter'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "BACKLINK", "define('ENABLE_BACKLINK', ", ");", REQUEST_POST('blink'), 0);
-						// DEACTIVATED: changeDataInFile(REQUEST_POST('spath')."inc/config.php", "OUTPUT-MODE", "define('OUTPUT_MODE', \"", "\");", REQUEST_POST('omode'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-HOST", "	'host'     => \"", "\",", $mysql['host'], 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-DBASE", "	'dbase'    => \"", "\",", $mysql['dbase'], 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-LOGIN", "	'login'    => \"", "\",", $mysql['login'], 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PASSWORD", "	'password' => \"", "\",", $mysql['pass1'], 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PREFIX", "define('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "TABLE-TYPE", "define('_TABLE_TYPE', \"", "\");", $mysql['type'], 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-HOSTNAME", "define('SMTP_HOSTNAME', \"", "\");", REQUEST_POST('smtp_host'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-USER", "define('SMTP_USER', \"", "\");", REQUEST_POST('smtp_user'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-PASSWORD", "define('SMTP_PASSWORD', \"", "\");", REQUEST_POST('smtp_pass1'), 0);
-						changeDataInFile(REQUEST_POST('spath')."inc/config.php", "INSTALLED", "define('mxchange_installed', ", ");", "true", 0);
+						if (REQUEST_POST('spath') != constant('PATH')) changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "SERVER-PATH", "define('PATH', \"", "\");", REQUEST_POST('spath'), 0);
+						if (REQUEST_POST('burl')  != constant('URL'))  changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "HOST-URL", "define('URL', \"", "\");", REQUEST_POST('burl'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "MAIN-TITLE", "define('MAIN_TITLE', \"", "\");", REQUEST_POST('title'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "SLOGAN", "define('SLOGAN', \"", "\");", REQUEST_POST('slogan'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "WEBMASTER", "define('WEBMASTER', \"", "\");", REQUEST_POST('email'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "NULLPASS-WARNING", "setConfigEntry('WARN_NO_PASS', \"", "\");", REQUEST_POST('warn_no_pass'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "WRITE-FOOTER", "setConfigEntry('WRITE_FOOTER', \"", "\");", REQUEST_POST('wfooter'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "BACKLINK", "setConfigEntry('ENABLE_BACKLINK', \"", "\");", REQUEST_POST('blink'), 0);
+						// DEACTIVATED: changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "OUTPUT-MODE", "define('OUTPUT_MODE', \"", "\");", REQUEST_POST('omode'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "MYSQL-HOST", "	'host'     => \"", "\",", $mysql['host'], 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "MYSQL-DBASE", "	'dbase'    => \"", "\",", $mysql['dbase'], 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "MYSQL-LOGIN", "	'login'    => \"", "\",", $mysql['login'], 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "MYSQL-PASSWORD", "	'password' => \"", "\",", $mysql['pass1'], 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "MYSQL-PREFIX", "setConfigEntry('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "TABLE-TYPE", "setConfigEntry('_TABLE_TYPE', \"", "\");", $mysql['type'], 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "SMTP-HOSTNAME", "setConfigEntry('SMTP_HOSTNAME', \"", "\");", REQUEST_POST('smtp_host'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "SMTP-USER", "setConfigEntry('SMTP_USER', \"", "\");", REQUEST_POST('smtp_user'), 0);
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "SMTP-PASSWORD", "setConfigEntry('SMTP_PASSWORD', \"", "\");", REQUEST_POST('smtp_pass1'), 0);
+
+						// Generate a long site key
+						$siteKey = generatePassword(50);
+
+						// And write it
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "SITE-KEY", "setConfigEntry('SITE_KEY', \"", "\");", $siteKey, 0);
+
+						// Script is now installed
+						changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "INSTALLED", "setConfigEntry('MXCHANGE_INSTALLED', \"", "\");", 'Y', 0);
 					} else {
 						// Installation area not found!
 						addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_MISSING_DUMPS'));
diff --git a/inc/language.php b/inc/language.php
index 60ca78fb9c..9b2b5a6caa 100644
--- a/inc/language.php
+++ b/inc/language.php
@@ -46,20 +46,19 @@ if (!defined('__SECURITY')) {
 $mx_lang = getSession('mx_lang');
 
 // Set default language if it is not (yet) set
-if (is_null($mx_lang)) $mx_lang = constant('DEFAULT_LANG');
+if (is_null($mx_lang)) $mx_lang = getConfig('DEFAULT_LANG');
 
 // Generate filename
 $INC = sprintf("inc/language/%s.php", SQL_ESCAPE($mx_lang));
 
-// Generate FQFN
-$FQFN = constant('PATH') . $INC;
-
 // Look for file
-if (!isFileReadable($FQFN)) {
+if (!isIncludeReadable($INC)) {
 	// Switch to default (DO NOT CHANGE!!!)
-	$mx_lang = constant('DEFAULT_LANG');
-	setSession('mx_lang', $mx_lang);
-	$INC = sprintf("inc/language/%s.php", $mx_lang);
+	setSession('mx_lang', 'de');
+	$INC = 'inc/language/de.php';
+
+	// And set it temporarily
+	setConfigEntry('DEFAULT_LANG', 'de');
 } // END - if
 
 // Load language file
@@ -68,7 +67,7 @@ loadIncludeOnce($INC);
 // Check for installation mode
 if ((isInstalling()) || (!isInstalled()) || (!isAdminRegistered())) {
 	// Load matching language file
-	loadInclude('inc/language/install_' . $mx_lang . '.php');
+	loadInclude('inc/language/install_' . getSession('mx_lang') . '.php');
 }
 
 // Remove no more needed variables
diff --git a/inc/language/bonus_de.php b/inc/language/bonus_de.php
index 5cbb93947c..5da63d96f0 100644
--- a/inc/language/bonus_de.php
+++ b/inc/language/bonus_de.php
@@ -65,8 +65,6 @@ define('BONUS_LOGIN_TURBO_NOTE', "Der Login-, Referal-, Klickrate-, Mailbuchungs
 define('BONUS_POINTS_TITLE', "Sonderbonus-{!POINTS!}");
 define('BONUS_RANK_YOU_ARE_NOT_FOUND', "Sie haben bis jetzt noch keine Aktiv-Verg&uuml;tung erhalten!");
 define('BONUS_RANK', "Platz");
-define('BONUS_SHOW_FOOTER_NOTE_1', "Wir w&uuml;nschen allen Gewinnern viel Gl&uuml;ck bei der monatlichen Aktiv-Rallye!");
-define('BONUS_SHOW_FOOTER_NOTE_2', "Es k&ouml;nnen nur die ersten {!__BONUS_TOTAL_RANKS!} die Aktiv-Rallye gewinnen. Der Rechtsweg ist ausgeschlossen.");
 define('BONUS_SHOW_HEADER_LINE_1', "Hier sehen Sie eine &Uuml;bersicht, wer alles");
 define('BONUS_SHOW_HEADER_LINE_2', "f&uuml;r die Mail");
 define('BONUS_SHOW_HEADER_LINE_3', "erhalten hat");
diff --git a/inc/language/de.php b/inc/language/de.php
index ea12b6d019..886903ebac 100644
--- a/inc/language/de.php
+++ b/inc/language/de.php
@@ -43,7 +43,7 @@ if (!defined('__SECURITY')) {
 }
 
 // Installation/setup
-define('CONFIG_IS_WRITE_PROTECTED', "Die Konfigurationsdatei <strong>inc/config.php</strong> ist schreibgesch&uuml;tzt. Bitte setzen Sie CHMOD 666 auf die Datei!");
+define('CONFIG_IS_WRITE_PROTECTED', "Die Konfigurationsdatei <strong>inc/cache/config-local.php</strong> ist schreibgesch&uuml;tzt. Bitte setzen Sie CHMOD 666 auf die Datei!");
 define('DUMMY_IS_WRITE_PROTECTED', "In dem Verzeichnis <strong>inc/</strong> kann keine Datei erzeugt werden. Bitte setzen Sie CHMOD 777 auf das Verzeichnis!");
 define('SECRET_IS_WRITE_PROTECTED', "In dem Verzeichnis <strong>inc/.secret/</strong> kann keine Datei erzeugt werden. Bitte setzen Sie CHMOD 777 auf das Verzeichnis oder probieren Sie auch 770 aus!");
 
@@ -69,9 +69,9 @@ define('META_KEYWORDS', "mailtausch, mailversand, kostenlos, kostenloser, mailex
 define('LANG_WARNING', "Warnung");
 define('DIE_CONFIG_CHANGED_YOU', "Sie haben Ihre Config-Datei editiert! Auf Wiedersehen...");
 define('DIE_RUN_INSTALL_MYSQL', "Bitte rufen Sie http://your-domain.com/install.php auf, um Ihre MySQL-Daten einzurichten!");
-define('WARN_NULL_PASSWORD', "Sie haben kein Passwort eingegeben! Bitte lesen Sie in der <strong>inc/config.php</strong> nach, wie Sie diese Warnung abschalten k&ouml;nnen.");
-define('FATAL_CONFIG_WRITABLE', "Ihre Datei inc/config.php ist beschreibbar! Dies ist ein m&ouml;gliches Sicherheitsrisiko!");
-define('FATAL_CANNOT_WRITE_CONFIG', "Kann Konfigurationsdaten nicht speichern, da ich keinen Schreibzugriff auf inc/config.php habe!");
+define('WARN_NULL_PASSWORD', "Sie haben kein Passwort eingegeben! Bitte lesen Sie in der <strong>inc/cache/config-local.php</strong> nach, wie Sie diese Warnung abschalten k&ouml;nnen.");
+define('FATAL_CONFIG_WRITABLE', "Ihre Datei inc/cache/config-local.php ist beschreibbar! Dies ist ein m&ouml;gliches Sicherheitsrisiko!");
+define('FATAL_CANNOT_WRITE_CONFIG', "Kann Konfigurationsdaten nicht speichern, da ich keinen Schreibzugriff auf inc/cache/config-local.php habe!");
 define('FATAL_CANNOT_CREATE_TMP', "Kann eine tempor&auml;re Datei nicht erzeugen! Bitte setzen Sie CHMOD 777 auf Verzeichnis inc!");
 define('FATAL_ERROR', "Fataler Fehler");
 define('LANG_NO_RENDER_DIRECT', "Sie haben weder 'render' noch 'direct' als Ausgabe-Modus eingestellt!");
@@ -168,7 +168,7 @@ define('CREATE_ACTION_FIRST', "Bitte erstellen Sie zuerst die action-xxxxx.php D
 define('IS_FIRST_MENU', "Ist das erste Hauptmen&uuml;");
 define('NO_DB_LINK', "Keine Verbindung zur Datenbank.");
 define('NO_DB_LINK_SHUTDOWN', "Keine Verbindung zur Datenbank beim Schliessen der Verbindung.");
-define('MYSQL_DATA_MISSING', "Die Konfiguration Ihrer Datenbankverbindung ist unnvollst&auml;ndig. Bitte in inc/config.php mindestens den Hostnamen, Datenbanknamen und Login zur Datenbank eingeben.");
+define('MYSQL_DATA_MISSING', "Die Konfiguration Ihrer Datenbankverbindung ist unnvollst&auml;ndig. Bitte in <strong>inc/cache/config-local.php</strong> mindestens den Hostnamen, Datenbanknamen und Login zur Datenbank eingeben.");
 define('REGISTER_PERSONAL_DATA', "Pers&ouml;nliche Daten");
 define('REGISTER_CATEGORIES', "Interessengebiete");
 define('REGISTER_MISC', "Passwort, maximale Mails pro Tag etc.");
diff --git a/inc/language/en.php b/inc/language/en.php
index 978e0c5653..d0d476cc9f 100644
--- a/inc/language/en.php
+++ b/inc/language/en.php
@@ -53,9 +53,9 @@ define('META_KEYWORDS', "Enter at least (1) 20 search keywords seperated by comm
 define('LANG_WARNING', "Warning");
 define('DIE_CONFIG_CHANGED_YOU', "You have edited your config.php file! I'm out here...");
 define('DIE_RUN_INSTALL_MYSQL', "Please run http://your-domain.com/install.php to setup your MySQL data.");
-define('WARN_NULL_PASSWORD', "You have a null-password! If you want to switch off this warning please have a look in <strong>inc/config.php</strong>.");
-define('FATAL_CONFIG_WRITABLE', "Your file inc/config.php is writeable! This is a possible security risk.");
-define('FATAL_CANNOT_WRITE_CONFIG', "Cannot write config data because I have no write permissions to inc/config.php.");
+define('WARN_NULL_PASSWORD', "You have a null-password! If you want to switch off this warning please have a look in <strong>inc/cache/config-local.php</strong>.");
+define('FATAL_CONFIG_WRITABLE', "Your file inc/cache/config-local.php is writeable! This is a possible security risk.");
+define('FATAL_CANNOT_WRITE_CONFIG', "Cannot write config data because I have no write permissions to inc/cache/config-local.php.");
 define('FATAL_ERROR', "Fatal error");
 define('LANG_NO_RENDER_DIRECT', "You did not setup the output mode weather to 'render' nor to 'direct'.");
 define('INSTALLATION', "Script installation");
diff --git a/inc/language/install_de.php b/inc/language/install_de.php
index c3b6b5057b..9b222bb158 100644
--- a/inc/language/install_de.php
+++ b/inc/language/install_de.php
@@ -43,7 +43,8 @@ if (!defined('__SECURITY')) {
 }
 
 // Language definitions
-define('INSTALLATION_OF_MXCHANGE', "Installation von MXChange-{!MT_WORD!}-Script - %s");
+define('INSTALLATION_OF_MXCHANGE', "Installation von MXChange-{!MT_WORD!}-Script");
+define('SETUP_OF_MXCHANGE', "Installation von MXChange-{!MT_WORD!}-Script - %s");
 define('INSTALL_MISSING_DUMPS', "Die SQL-Dumps wurden nicht gefunden! Diese sollten auch mit hochgeladen werden und lesbar sein (CHMOD 644).");
 define('INSTALL_ENABLE_BACKLINK', "Backlink (=R&uuml;ckverlinkung zu mxchange.org setzen?) <em>rel=&quot;external&quot;</em> ist gesetzt. Bitte nicht den Backlink einbauen, und <strong>nofollow</strong> verwenden! Das schadet allen.");
 define('WRONG_PAGE', "Sie oder dieses Script haben eine falsche Seite ausgew&auml;hlt!");
diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php
index 86f375c200..1279145d40 100644
--- a/inc/libs/admins_functions.php
+++ b/inc/libs/admins_functions.php
@@ -160,7 +160,7 @@ function adminsChangeAdminAccount ($POST) {
 		// When both passwords match update admin account
 		if ($POST['pass1'][$id] == $POST['pass2'][$id]) {
 			// Save only when both passwords are the same (also when they are empty)
-			$add = ''; $cache_update = "1";
+			$add = ''; $cache_update = '1';
 
 			// Generate hash
 			$hash = generateHash($POST['pass1'][$id]);
@@ -269,12 +269,12 @@ function adminsEditAdminAccount ($POST) {
 			// Shall we allow changing default ACL?
 			if ($currMode == "allow") {
 				// Allow chaning it
-				$content['mode']    = generateOptionList("/ARRAY/", array("allow", "deny"), array(constant('ADMINS_ALLOW_MODE'), constant('ADMINS_DENY_MODE')), $content['mode']);
+				$content['mode']    = generateOptionList('/ARRAY/', array("allow", "deny"), array(constant('ADMINS_ALLOW_MODE'), constant('ADMINS_DENY_MODE')), $content['mode']);
 			} else {
 				// Don't allow it
 				$content['mode'] = "&nbsp;";
 			}
-			$content['la_mode'] = generateOptionList("/ARRAY/", array("global", "OLD", "NEW"), array(ADMINS_GLOBAL_LA_SETTING, ADMINS_OLD_LA_SETTING, ADMINS_NEW_LA_SETTING), $content['la_mode']);
+			$content['la_mode'] = generateOptionList('/ARRAY/', array("global", "OLD", "NEW"), array(ADMINS_GLOBAL_LA_SETTING, ADMINS_OLD_LA_SETTING, ADMINS_NEW_LA_SETTING), $content['la_mode']);
 
 			// Load row template and switch color
 			$OUT .= LOAD_TEMPLATE("admin_edit_admins_row", true, $content);
@@ -349,7 +349,7 @@ function adminsRemoveAdminAccount ($POST) {
 
 			// Purge cache
 			cachePurgeAdminMenu($id);
-			$cache_update = "1";
+			$cache_update = '1';
 		}
 	}
 
diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php
index 109e740f1d..d5a360e57c 100644
--- a/inc/libs/bonus_functions.php
+++ b/inc/libs/bonus_functions.php
@@ -133,7 +133,7 @@ function BONUS_MAKE_RANK_ROWS ($data, $type, $uid) {
 		// Transfer data to template
 		define('__YR_LEVEL' , $rank);
 		define('__YR_POINTS', $points);
-		define('__YR_TMARK' , generateDateTime($mark, "1"));
+		define('__YR_TMARK' , generateDateTime($mark, '1'));
 
 		// Load template
 		define('__YOUR_RANKING_LINE', LOAD_TEMPLATE("show_bonus_yr", true));
@@ -194,12 +194,12 @@ function BONUS_POINTS_HANDLER ($mode) {
 	if (getConfig('bonus_active') != 'Y') return;
 
 	// Switch to jackpot-mode when no UID is supplied but userid-mode is selected
-	if ((getConfig('bonus_mode') == "UID") && (getConfig('bonus_uid') == '0')) {
+	if ((getConfig('bonus_mode') == 'UID') && (getConfig('bonus_uid') == '0')) {
 		// Update database & config
 		updateConfiguration('bonus_mode', 'JACKPOT');
 	} // END - if
 
-	if ($mode == "login_bonus") {
+	if ($mode == 'login_bonus') {
 		// Login bonus detected
 		$points = getConfig('login_bonus');
 	} else {
@@ -213,20 +213,20 @@ function BONUS_POINTS_HANDLER ($mode) {
 	case 'JACKPOT': // ... jackpot
 		if ((SUB_JACKPOT($points) == -1) && (getConfig('bonus_uid') > 0)) {
 			// Check points amount first...
-			$total = GET_TOTAL_DATA(getConfig('bonus_uid'), "user_points", "points") - GET_TOTAL_DATA(getConfig('bonus_uid'), "user_data", "used_points");
+			$total = GET_TOTAL_DATA(getConfig('bonus_uid'), 'user_points', 'points') - GET_TOTAL_DATA(getConfig('bonus_uid'), 'user_data', 'used_points');
 			if ($total >= $points) {
 				// Subtract points from userid's account
-				SUB_POINTS("bonus_payout_jackpot", getConfig('bonus_uid'), $points);
+				SUB_POINTS('bonus_payout_jackpot', getConfig('bonus_uid'), $points);
 			} // END - if
 		} // END - if
 		break;
 
-	case "UID": // ... userid's account
+	case 'UID': // ... userid's account
 		// Check his amount first
-		$total = GET_TOTAL_DATA(getConfig('bonus_uid'), "user_points", "points") - GET_TOTAL_DATA(getConfig('bonus_uid'), "user_data", "used_points");
+		$total = GET_TOTAL_DATA(getConfig('bonus_uid'), 'user_points', 'points') - GET_TOTAL_DATA(getConfig('bonus_uid'), 'user_data', 'used_points');
 		if ($total >= $points) {
 			// Subtract points from userid's account
-			SUB_POINTS("bonus_payout_uid", getConfig('bonus_uid'), $points);
+			SUB_POINTS('bonus_payout_uid', getConfig('bonus_uid'), $points);
 		} else {
 			// Try to subtract from jackpot
 			$dummy = SUB_JACKPOT($points);
@@ -241,8 +241,9 @@ function BONUS_PURGE_EXPIRED_TURBO_BONUS() {
 	$result = SQL_QUERY("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_bonus_turbo` WHERE timemark < (UNIX_TIMESTAMP() - ".getConfig('bonus_timeout').")", __FUNCTION__, __LINE__);
 	if (SQL_AFFECTEDROWS() > 0) {
 		// Send out email to admin
-		sendAdminNotification(AUTOPURGE_ADMIN_TURBO_SUBJECT, "admin_autopurge_turbo", SQL_AFFECTEDROWS(), '');
-	}
+		sendAdminNotification(AUTOPURGE_ADMIN_TURBO_SUBJECT, 'admin_autopurge_turbo', SQL_AFFECTEDROWS(), '');
+	} // END - if
 }
+
 //
 ?>
diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php
index b5804821a5..1e38e1faf6 100644
--- a/inc/libs/cache_functions.php
+++ b/inc/libs/cache_functions.php
@@ -119,7 +119,7 @@ class CacheSystem {
 		// This will destory an existing cache file!
 		if ($this->ret == $this->statusDone) {
 			// Create file
-			if ($this->isCacheReadable()) chmod($this->fqfn, 0666);
+			if ($this->isCacheReadable()) changeMode($this->fqfn, 0666);
 			$this->pointer = fopen($this->fqfn, 'w') or app_die(__METHOD__, __LINE__, "Cannot write to cache ".$this->fqfn." !");
 
 			// Add open PHP tag
@@ -172,7 +172,7 @@ class CacheSystem {
 			fclose($this->pointer);
 
 			// Set rights
-			if ($this->isCacheReadable()) chmod($this->fqfn, 0666);
+			if ($this->isCacheReadable()) changeMode($this->fqfn, 0666);
 
 			// Remove pointer
 			$this->pointer = false;
diff --git a/inc/libs/doubler_functions.php b/inc/libs/doubler_functions.php
index 16179e2569..e7b890c039 100644
--- a/inc/libs/doubler_functions.php
+++ b/inc/libs/doubler_functions.php
@@ -50,11 +50,11 @@ function DOUBLER_GENERATE_TABLE ($uid = '0', $done='N', $ref='N', $sort="ASC") {
 	if ($uid > 0) {
 		// Load entries only from a single user
 		$add = " AND `userid`='".bigintval($uid)."'";
-		$mode = 'member'; $COLS = "4"; $DT_MODE = "2";
+		$mode = 'member'; $COLS = "4"; $DT_MODE = '2';
 		$NOT_FOUND = getMessage('DOUBLER_MEMBER_NO_ENTRIES_FOUND');
 	} else {
 		// Guest mode!
-		$mode = 'guest'; $COLS = "3"; $DT_MODE = "3";
+		$mode = 'guest'; $COLS = '3'; $DT_MODE = '3';
 		$NOT_FOUND = getMessage('DOUBLER_GUEST_NO_ENTRIES_FOUND');
 	}
 
diff --git a/inc/libs/holiday_functions.php b/inc/libs/holiday_functions.php
index 58dba68cb6..885c6551a7 100644
--- a/inc/libs/holiday_functions.php
+++ b/inc/libs/holiday_functions.php
@@ -69,8 +69,8 @@ LIMIT 1", array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
 
 			// Prepare array
 			$content = array(
-				'holiday_end'      => generateDateTime($content['holiday_end']  , "3"),
-				'holiday_start'    => generateDateTime($content['holiday_start'], "3"),
+				'holiday_end'      => generateDateTime($content['holiday_end']  , '3'),
+				'holiday_start'    => generateDateTime($content['holiday_start'], '3'),
 				'holiday_comments' => $content['comments']
 			);
 
diff --git a/inc/libs/html_mail_functions.php b/inc/libs/html_mail_functions.php
index e2bcafab29..491afda732 100644
--- a/inc/libs/html_mail_functions.php
+++ b/inc/libs/html_mail_functions.php
@@ -151,11 +151,11 @@ function HTML_INSERT_URLS ($text) {
 	return COMPILE_CODE(str_replace("\n", "<br />\n", $text));
 }
 
-//
-function SEND_HTML_EMAIL($to, $subject, $message, $FROM) {
+// Sends a HTML mail to the user
+function sendHtmlEmail($to, $subject, $message, $FROM) {
 	if (EXT_IS_ACTIVE('html_mail')) {
 		// Send mail away as HTML
-		$FROM = "Content-Type: text/html\n".$FROM;
+		$FROM = "Content-Type: text/html\n" . $FROM;
 		sendEmail($to, $subject, $message, 'N', $FROM);
 	}
 }
diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php
index 9183a06d0d..46e8c45847 100644
--- a/inc/libs/rallye_functions.php
+++ b/inc/libs/rallye_functions.php
@@ -61,9 +61,9 @@ function RALLYE_AUTOSTART_RALLYES ($result) {
 
 	// Transfer all neccessary data to the global $DATA array
 	$DATA['uid_cnt']    = SQL_NUMROWS($result_user);
-	$DATA['start']      = generateDateTime($start, "2");
-	$DATA['end']        = generateDateTime($end  , "2");
-	$DATA['now_t']      = generateDateTime(time(), "2");
+	$DATA['start']      = generateDateTime($start, '2');
+	$DATA['end']        = generateDateTime($end  , '2');
+	$DATA['now_t']      = generateDateTime(time(), '2');
 	$DATA['title']      = $title;
 	$DATA['id']         = $id;  // ID for the rallye details link
 
@@ -293,9 +293,9 @@ VALUES ('%s','%s','0')",
 
 		if ($notify == 'Y') {
 			// Transfer all neccessary data to the global $DATA array
-			$DATA['start'] = generateDateTime($start, "2");
-			$DATA['end']   = generateDateTime($end  , "2");
-			$DATA['now_t'] = generateDateTime(time(), "2");
+			$DATA['start'] = generateDateTime($start, '2');
+			$DATA['end']   = generateDateTime($end  , '2');
+			$DATA['now_t'] = generateDateTime(time(), '2');
 			$DATA['title'] = $title;
 			$DATA['id']    = $id;  // ID for the rallye details link
 			$DATA['ref']   = 0;
@@ -330,9 +330,9 @@ function RALLYE_EXPIRE_RALLYES ($result) {
 	$DATA = array(); $cnt = 0;
 	$users = array();
 	$DATA['title']  = $title;
-	$DATA['start']  = generateDateTime($start, "1");
-	$DATA['end']    = generateDateTime($end  , "1");
-	$DATA['now_t']  = generateDateTime(time(), "1");
+	$DATA['start']  = generateDateTime($start, '1');
+	$DATA['end']    = generateDateTime($end  , '1');
+	$DATA['now_t']  = generateDateTime(time(), '1');
 
 	// Just count...
 	$total = 0;
@@ -442,7 +442,7 @@ VALUES ('NEW','RALLYE_EXPIRED','{--RALLYE_ADMIN_EXPIRED--}: %s','{--RALLYE_ADMIN
 //
 function RALLYE_LOAD_USER_DATA ($uids_array) {
 	// Implode user ids
-	$uid_string = implode(",", $uids_array['uid']);
+	$uid_string = implode(',', $uids_array['uid']);
 
 	// Init result string
 	$ret = '';
@@ -642,9 +642,9 @@ WHERE end_time <= (UNIX_TIMESTAMP() - %s) AND expired='Y'",
 		while ($content = SQL_FETCHARRAY($result_rallye)) {
 			// Prepare data for mail template
 			$DATA['title']  = $content['title'];
-			$DATA['start']  = generateDateTime($content['start_time'], "1");
-			$DATA['end']    = generateDateTime($content['end_time']  , "1");
-			$DATA['now_t']  = generateDateTime(time(), "1");
+			$DATA['start']  = generateDateTime($content['start_time'], '1');
+			$DATA['end']    = generateDateTime($content['end_time']  , '1');
+			$DATA['now_t']  = generateDateTime(time(), '1');
 
 			// Send mail to admin
 			sendAdminNotification(sprintf(getMessage('RALLYE_ADMIN_PURGED_SUBJ'), $content['title']), "admin_rallye_purged", '', 0);
diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php
index 8ed526a227..ceab0b90fe 100644
--- a/inc/libs/register_functions.php
+++ b/inc/libs/register_functions.php
@@ -146,9 +146,9 @@ function registerGenerateCategoryTable ($mode, $return=false) {
 			);
 
 			if ((REQUEST_POST('cat', $content['id']) == 'Y') || ((getConfig('register_default') == 'Y') && (!REQUEST_ISSET_POST('cat', $content['id'])))) {
-				$content['def_y'] = ' chkecked="checked"';
+				$content['def_y'] = ' checked="checked"';
 			} else {
-				$content['def_n'] = ' chkecked="checked"';
+				$content['def_n'] = ' checked="checked"';
 			}
 
 			// Load template and switch color
diff --git a/inc/libs/security_functions.php b/inc/libs/security_functions.php
index 9d1cf45625..6e1084ce94 100644
--- a/inc/libs/security_functions.php
+++ b/inc/libs/security_functions.php
@@ -90,7 +90,7 @@ if (!isset($_POST)) {
 // Generate arrays which holds the relevante chars to replace
 $GLOBALS['security_chars'] = array(
 	// The chars we are looking for...
-	'from' => array("{", "}", '/', '.', "'", "$", "(", ")", '{--', '--}', "%", ';', "[", "]", ':', "--"),
+	'from' => array("{", "}", '/', '.', "'", "$", '(', ')', '{--', '--}', "%", ';', "[", "]", ':', "--"),
 	// ... and we will replace to.
 	'to'   => array(
 		"{OPEN_ANCHOR2}",
@@ -163,15 +163,15 @@ if (!defined('_OB_CACHING')) {
 	if (phpversion() >= '4.0.4pl1' && (strstr(getenv('HTTP_USER_AGENT'),'compatible') || (strstr(getenv('HTTP_USER_AGENT'), "Mozilla")))) {
 		if ((extension_loaded('zlib')) && (function_exists('ob_start'))) {
 			// Start caching
-			define('_OB_CACHING', "on");
+			define('_OB_CACHING', 'on');
 			ob_start();
 		} else {
 			// Extension not loaded or required function is missing
-			define('_OB_CACHING', "404");
+			define('_OB_CACHING', '404');
 		}
 	} else {
 		// Old PHP version
-		define('_OB_CACHING', "old");
+		define('_OB_CACHING', 'old');
 	}
 }
 
@@ -183,9 +183,9 @@ $SELF_DIR  = dirname($_SERVER['PHP_SELF']);
 $SELF_FILE = basename($_SERVER['PHP_SELF']);
 
 // Check for a .php inside the $SELF_DIR...
-while (ereg(".php", $SELF_DIR)) {
+while (ereg('.php', $SELF_DIR)) {
 	// Correct the dirname
-	$SELF_DIR = substr($SELF_DIR, 0, (strpos($SELF_DIR, ".php") + 4));
+	$SELF_DIR = substr($SELF_DIR, 0, (strpos($SELF_DIR, '.php') + 4));
 	// Rewrite filename...
 	$SELF_FILE = basename($SELF_DIR);
 	// ... and dirname
@@ -200,7 +200,7 @@ unset($SELF_DIR);
 unset($SELF_FILE);
 
 // Security system loaded...
-define('__SECURITY', "1");
+define('__SECURITY', '1');
 
 //
 ?>
diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php
index 1d19320d93..3db8ad7841 100644
--- a/inc/libs/sponsor_functions.php
+++ b/inc/libs/sponsor_functions.php
@@ -142,7 +142,7 @@ function SPONSOR_HANDLE_SPONSOR (&$POST, $NO_UPDATE=false, $messageArray=array()
 			// Generate message
 			$message = SPONSOR_GET_MESSAGE(ADMIN_SPONSOR_UPDATED, "updated", $messageArray);
 			$ret = "updated";
-		} elseif ((!$ALREADY) || (($POST['force'] == "1") && (IS_ADMIN()))) {
+		} elseif ((!$ALREADY) || (($POST['force'] == '1') && (IS_ADMIN()))) {
 			// Add new sponsor, first add more data
 			$DATA['keys'][] = "sponsor_created"; $DATA['values'][] = time();
 			$DATA['keys'][] = 'status';
diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php
index 7c9f58af84..82ae305ab1 100644
--- a/inc/libs/surfbar_functions.php
+++ b/inc/libs/surfbar_functions.php
@@ -374,13 +374,13 @@ function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
 	if ($action == 'edit') {
 		// Default is not limited
 		$urlData['limited_yes'] = '';
-		$urlData['limited_no']  = ' chkecked="checked"';
+		$urlData['limited_no']  = ' checked="checked"';
 		$urlData['limited']     = 'false';
 
 		// Is this URL limited?
 		if ($urlData['views_max'] > 0) {
 			// Then rewrite form data
-			$urlData['limited_yes'] = ' chkecked="checked"';
+			$urlData['limited_yes'] = ' checked="checked"';
 			$urlData['limited_no']  = '';
 			$urlData['limited']     = 'true';
 		} // END - if
@@ -664,8 +664,8 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
 
 	// Translate some data if present
 	if (isset($content['status']))        $content['status']        = surfbarTranslateUserStatus($content['status']);
-	if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], "2");
-	if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], "2");
+	if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], '2');
+	if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], '2');
 	if (isset($content['views_total']))   $content['views_total']   = translateComma($content['views_total']);
 	if (isset($content['views_allowed'])) $content['views_allowed'] = translateComma($content['views_allowed']);
 	if (isset($content['views_max']))     $content['views_max']     = translateComma($content['views_max']);
@@ -697,8 +697,8 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
 
 	// Translate some data if present
 	if (isset($content['status']))        $content['status']        = surfbarTranslateUserStatus($content['status']);
-	if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], "2");
-	if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], "2");
+	if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], '2');
+	if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], '2');
 	if (isset($content['views_total']))   $content['views_total']   = translateComma($content['views_total']);
 	if (isset($content['views_allowed'])) $content['views_allowed'] = translateComma($content['views_allowed']);
 	if (isset($content['views_max']))     $content['views_max']     = translateComma($content['views_max']);
@@ -870,7 +870,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = 0) {
 	// Get amount from database
 	$result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
 FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
-WHERE userid NOT IN (".implode(",", $UIDs['uid']).") AND `status`='%s'",
+WHERE userid NOT IN (".implode(',', $UIDs['uid']).") AND `status`='%s'",
 		array($status), __FUNCTION__, __LINE__
 	);
 
@@ -1162,7 +1162,7 @@ ORDER BY u.userid ASC", __FUNCTION__, __LINE__);
 	SQL_FREERESULT($result);
 
 	// Debug message
-	//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getUserId().")", false);
+	//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getUserId().')', false);
 
 	// Return result
 	return $UIDs;
@@ -1410,7 +1410,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_salts` AS sbs
 ON sbu.id=sbs.url_id
 LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
 ON sbu.id=l.url_id
-WHERE sbu.userid NOT IN (".implode(",", $UIDs).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.`status`='ACTIVE'".$add."
+WHERE sbu.userid NOT IN (".implode(',', $UIDs).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.`status`='ACTIVE'".$add."
 GROUP BY sbu.id", __FUNCTION__, __LINE__);
 
 	// Log last query
@@ -1484,10 +1484,10 @@ function SURFBAR_RELOAD_TO_STOP_PAGE ($page="stop") {
 	// Internal or external?
 	if ((getConfig('surfbar_pause_mode') == 'INTERNAL') || (getConfig('surfbar_pause_url') == '')) {
 		// Reload to internal page
-		redirectToUrl("surfbar.php?frame=".$page);
+		redirectToUrl('surfbar.php?frame=' . $page);
 	} else {
 		// Reload to external page
-		LOAD_CONFIGURED_URL('surfbar_pause_url');
+		redirectToConfiguredUrl('surfbar_pause_url');
 	}
 }
 
@@ -1510,11 +1510,11 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) {
 			$add = " AND sbu.id NOT IN (";
 			foreach ($USE as $url_id => $lid) {
 				// Add URL id
-				$add .= $url_id.",";
+				$add .= $url_id.',';
 			} // END - foreach
 
 			// Add closing bracket
-			$add = substr($add, 0, -1) . ")";
+			$add = substr($add, 0, -1) . ')';
 		} // END - if
 
 		// Determine depleted user account
@@ -1537,7 +1537,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_salts` AS sbs
 ON sbu.id=sbs.url_id
 LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
 ON sbu.id=l.url_id
-WHERE sbu.userid NOT IN (".implode(",", $UIDs['uid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
+WHERE sbu.userid NOT IN (".implode(',', $UIDs['uid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
 GROUP BY sbu.id
 ORDER BY l.last_surfed ASC, sbu.id ASC
 LIMIT %s,1",
diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php
index 1b72e2065e..8ef78b4c6f 100644
--- a/inc/libs/user_functions.php
+++ b/inc/libs/user_functions.php
@@ -153,7 +153,7 @@ function ADD_PAGENAV ($PAGES, $offset, $show_form, $colspan,$return=false) {
 
 	$OUT = '';
 	for ($page = 1; $page <= $PAGES; $page++) {
-		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == "1"))) {
+		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == '1'))) {
 			$OUT .= "<strong>-";
 		} else {
 			if (!REQUEST_ISSET_GET(('letter'))) REQUEST_SET_GET('letter', getMessage('_ALL2'));
@@ -172,7 +172,7 @@ function ADD_PAGENAV ($PAGES, $offset, $show_form, $colspan,$return=false) {
 
 		$OUT .= $page;
 
-		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == "1"))) {
+		if (($page == REQUEST_GET('page')) || ((!REQUEST_ISSET_GET('page')) && ($page == '1'))) {
 			$OUT .= "-</strong>";
 		} else 	{
 			$OUT .= "</a>";
@@ -222,7 +222,7 @@ WHERE `email`='%s'".$locked." LIMIT 1",
 }
 
 // Selects a random user id as the new referal id if they have at least X confirmed mails in this run
-function SELECT_RANDOM_REFID () {
+function determineRandomReferalId () {
 	// Default is zero refid
 	$refid = 0;
 
diff --git a/inc/load_config.php b/inc/load_config.php
new file mode 100644
index 0000000000..26d35e68c8
--- /dev/null
+++ b/inc/load_config.php
@@ -0,0 +1,66 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 04/04/2009 *
+ * ===============                              Last change: 04/04/2009 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : load_config.php                                  *
+ * -------------------------------------------------------------------- *
+ * Short description : Loader for configuration                         *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Lader fuer Konfiguration                         *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.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 2 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, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
+	require($INC);
+} // END - if
+
+// Set some config entries which is required for installation phase
+setConfigEntry('OUTPUT_MODE' , 'render');
+setConfigEntry('WRITE_FOOTER', 'Y');
+setConfigEntry('_DB_TYPE'    , 'mysql3');
+
+// Is the local configuration there?
+if (isIncludeReadable('inc/cache/config-local.php')) {
+	// Then load it
+	loadIncludeOnce('inc/cache/config-local.php');
+} elseif (isInstalling()) {
+	// Set some essential constants
+	// @TODO Rewrite them to avoid this else block
+	define('MAIN_TITLE', 'Your mail-exchanger title');
+	define('SLOGAN'    , 'Your cool slogan here');
+	define('WEBMASTER' , 'you@some-hoster.tld.invalid');
+} else {
+	// Problem in application detected
+	debug_report_bug('Wether we are not installing nor config-local.php is created!');
+}
+
+//
+?>
diff --git a/inc/modules/admin.php b/inc/modules/admin.php
index 3a3472bcc1..a7c5c9146c 100644
--- a/inc/modules/admin.php
+++ b/inc/modules/admin.php
@@ -70,7 +70,7 @@ if (!isAdminRegistered()) {
 		switch ($ret)
 		{
 		case 'done':
-			$done = changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
+			$done = changeDataInFile(constant('PATH') . 'inc/cache/config-local.php', "ADMIN-SETUP", "setConfigEntry('ADMIN_REGISTERED', \"", "\");", 'Y', 0);
 			if ($done === true) {
 				// Registering is done
 				redirectToUrl('modules.php?module=admin&amp;register=done');
@@ -98,7 +98,7 @@ if (!isAdminRegistered()) {
 			// Admin still not registered?
 			if (!isAdminRegistered()) {
 				// Write to config that registration is done
-				changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
+				changeDataInFile(constant('PATH') . 'inc/cache/config-local.php', "ADMIN-SETUP", "setConfigEntry('ADMIN_REGISTERED', \"", "\");", 'Y', 0);
 
 				// Load URL for login
 				redirectToUrl('modules.php?module=admin');
diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php
index 889820cea9..af3e0ab424 100644
--- a/inc/modules/admin/admin-inc.php
+++ b/inc/modules/admin/admin-inc.php
@@ -69,7 +69,7 @@ function REGISTER_ADMIN ($user, $md5, $email) {
 // Only be executed on login procedure!
 function CHECK_ADMIN_LOGIN ($admin_login, $password) {
 	// By default no admin is found
-	$ret = "404";
+	$ret = '404';
 
 	// Get admin id
 	$aid = GET_ADMIN_ID($admin_login);
@@ -131,7 +131,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password) {
 	$salt = __SALT;
 
 	// Check if password is same
-	//* DEBUG: */ echo "*".$ret.",".$data['password'].",".$password.",".$salt."*<br >\n";
+	//* DEBUG: */ echo "*".$ret.','.$data['password'].','.$password.','.$salt."*<br >\n";
 	if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == $password)) {
 		// Re-hash the plain passord with new random salt
 		$data['password'] = generateHash($password);
@@ -218,13 +218,13 @@ function LOGIN_ADMIN ($adminLogin, $passHash) {
 // Only be executed on cookie checking
 function CHECK_ADMIN_COOKIES ($admin_login, $password) {
 	// By default no admin cookies are found
-	$ret = "404"; $pass = '';
+	$ret = '404'; $pass = '';
 
 	// Get hash
 	$pass = GET_ADMIN_HASH(GET_ADMIN_ID($admin_login));
-	if ($pass != "-1") $ret = 'pass';
+	if ($pass != '-1') $ret = 'pass';
 
-	//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):".generatePassString($pass)."(".strlen($pass).")/".$password."(".strlen($password).")<br />\n";
+	//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):".generatePassString($pass).'('.strlen($pass).")/".$password.'('.strlen($password).")<br />\n";
 
 	// Check if password matches
 	if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
@@ -661,7 +661,7 @@ function ADMIN_MAKE_MENU_SELECTION ($menu, $type, $name, $default = '') {
 	// Walk through all files
 	foreach ($menuArray as $file) {
 		// Is this a PHP script?
-		if ((!isDirectory($file)) && (strpos($file, "".$type.'-') > -1) && (strpos($file, ".php") > 0)) {
+		if ((!isDirectory($file)) && (strpos($file, "".$type.'-') > -1) && (strpos($file, '.php') > 0)) {
 			// Then test if the file is readable
 			$test = sprintf("%sinc/modules/%s/%s", constant('PATH'), $menu, $file);
 
@@ -993,7 +993,7 @@ function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $columns=array(), $filterFu
 				} // END - if
 
 				// Add id number
-				$idList .= $id.",";
+				$idList .= $id . ',';
 			} // END - foreach
 
 			// Run the query
diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php
index 504e740523..14944df068 100644
--- a/inc/modules/admin/overview-inc.php
+++ b/inc/modules/admin/overview-inc.php
@@ -55,7 +55,7 @@ function OUTPUT_STANDARD_OVERVIEW(&$result_tasks) {
 	$extensionList = getArrayFromDirectory("inc/extensions/", "ext-", false, false);
 	foreach ($extensionList as $file) {
 		// Is this file an extension?
-		if ((substr($file, 0, 4) == "ext-") && (substr($file, -4) == ".php")) {
+		if ((substr($file, 0, 4) == "ext-") && (substr($file, -4) == '.php')) {
 			//* DEBUG: */ echo $file."<br />\n";
 			// Possible newly installed extension found so we extract extension's name
 			$ext_name = strtolower(substr($file, 4, -4)); // Keep always extension names on lower case!!!
@@ -421,7 +421,7 @@ LIMIT 1",
 				'admin'   => $content['assigned_admin'],
 				'uid'     => $content['userid'],
 				'type'    => $content['task_type_msg'],
-				'created' => generateDateTime($content['task_created'], "2")
+				'created' => generateDateTime($content['task_created'], '2')
 			));
 
 			// Do we have extension task?
diff --git a/inc/modules/admin/what-admin_add.php b/inc/modules/admin/what-admin_add.php
index bc85b8a791..7c14e58139 100644
--- a/inc/modules/admin/what-admin_add.php
+++ b/inc/modules/admin/what-admin_add.php
@@ -136,18 +136,13 @@ if (!IS_FORM_SENT())
 	}
 	$OUT = "    <select class=\"admin_select\" name=\"sort\" size=\"1\">
       <option value=\"0\">".IS_FIRST_MENU."</option>\n";
-  	foreach ($below as $key => $m)
-	{
-		if (is_array($m))
-		{
-			foreach ($m as $key2 => $m2)
-			{
+	foreach ($below as $key => $m) {
+		if (is_array($m)) {
+			foreach ($m as $key2 => $m2) {
 				$OUT .= "      <option value=\"".$m2."\">".$titles[$key][$key2];
-				foreach ($menus as $k => $v)
-				{
-					if (($v == $key) && (!is_array($v)))
-					{
-						$OUT .= " (".$titles[$k].")";
+				foreach ($menus as $k => $v) {
+					if (($v == $key) && (!is_array($v))) {
+						$OUT .= " (" . $titles[$k] . ')';
 					}
 				}
 				$OUT .= "</option>\n";
diff --git a/inc/modules/admin/what-admins_edit.php b/inc/modules/admin/what-admins_edit.php
index f57381ce44..e0528331ae 100644
--- a/inc/modules/admin/what-admins_edit.php
+++ b/inc/modules/admin/what-admins_edit.php
@@ -54,8 +54,8 @@ if (REQUEST_ISSET_GET('admin')) {
 	$aid = bigintval(REQUEST_GET('admin'));
 
 	// Set required fields
-	REQUEST_SET_POST('edit', "1");
-	REQUEST_SET_POST(array('sel', $aid), "1");
+	REQUEST_SET_POST('edit', '1');
+	REQUEST_SET_POST(array('sel', $aid), '1');
 } // END - if
 
 if ((REQUEST_ISSET_POST('edit')) && (countPostSelection() > 0)) {
diff --git a/inc/modules/admin/what-admins_mails.php b/inc/modules/admin/what-admins_mails.php
index 7d9bbc2c92..6029cfd708 100644
--- a/inc/modules/admin/what-admins_mails.php
+++ b/inc/modules/admin/what-admins_mails.php
@@ -65,7 +65,7 @@ if (REQUEST_ISSET_POST('edit')) {
 				$OUT .=">{--ADMINS_ALL_ADMINS--}</option>\n";
 				if (EXT_IS_ACTIVE('events')) {
 					$OUT .= "<option value=\"-1\"";
-					if ($content['admin_id'] == "-1") $OUT .= ' selected="selected"';
+					if ($content['admin_id'] == '-1') $OUT .= ' selected="selected"';
 					$OUT .= ">{--ADMINS_TO_USER_EVENTS--}</option>\n";
 				}
 				$OUT .= generateOptionList('admins', "id", "login", $content['admin_id'], 'email');
diff --git a/inc/modules/admin/what-config_admin.php b/inc/modules/admin/what-config_admin.php
index 47bd9301b0..ab6c8b395a 100644
--- a/inc/modules/admin/what-config_admin.php
+++ b/inc/modules/admin/what-config_admin.php
@@ -52,13 +52,13 @@ if (IS_FORM_SENT()) {
 	switch (getConfig('admin_menu'))
 	{
 	case "NEW":
-		define('__ADMIN_MENU_NEW', ' chkecked="checked"');
+		define('__ADMIN_MENU_NEW', ' checked="checked"');
 		define('__ADMIN_MENU_OLD'   , '');
 		break;
 
 	case "OLD":
 		define('__ADMIN_MENU_NEW', '');
-		define('__ADMIN_MENU_OLD'   , ' chkecked="checked"');
+		define('__ADMIN_MENU_OLD'   , ' checked="checked"');
 		break;
 	}
 
diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php
index 24b9126b76..481435be66 100644
--- a/inc/modules/admin/what-config_admins.php
+++ b/inc/modules/admin/what-config_admins.php
@@ -66,7 +66,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($SEL > 0)) {
 			'action_selection' => ADMIN_MENU_SELECTION("action", $act, $id),
 			'what_selection'   => ADMIN_MENU_SELECTION("what", $wht, $id),
 			'mode_options'     => generateOptionList(
-				"/ARRAY/",
+				'/ARRAY/',
 				array("allow", "deny"),
 				array(constant('ADMINS_ALLOW_MODE'), constant('ADMINS_DENY_MODE')),
 				$mode
@@ -261,7 +261,7 @@ VALUES ('%s','%s','%s','%s')",
 	define('_WHAT_SELECTION'  , ADMIN_MENU_SELECTION("what"));
 	define('_MODE_OPTIONS'    ,
 		generateOptionList(
-			"/ARRAY/",
+			'/ARRAY/',
 			array("allow", "deny"),
 			array(
 				getMessage('ADMINS_ALLOW_MODE'),
diff --git a/inc/modules/admin/what-config_autopurge.php b/inc/modules/admin/what-config_autopurge.php
index e980c5747f..77ae1fa39e 100644
--- a/inc/modules/admin/what-config_autopurge.php
+++ b/inc/modules/admin/what-config_autopurge.php
@@ -71,11 +71,11 @@ if (IS_FORM_SENT()) {
 	// Mail confirmation links
 	define('_CFG_AUTO_PURGE', createTimeSelections(getConfig('auto_purge'), "auto_purge", "MWD"));
 	if (getConfig('auto_purge_active') != 'Y') {
-		define('_CFG_AP_ACTIVE_N', ' chkecked="checked"');
+		define('_CFG_AP_ACTIVE_N', ' checked="checked"');
 		define('_CFG_AP_ACTIVE_Y', '');
 	} else {
 		define('_CFG_AP_ACTIVE_N', '');
-		define('_CFG_AP_ACTIVE_Y', ' chkecked="checked"');
+		define('_CFG_AP_ACTIVE_Y', ' checked="checked"');
 	}
 
 	// Output template
diff --git a/inc/modules/admin/what-config_beg.php b/inc/modules/admin/what-config_beg.php
index 7200379faf..babddaa4a8 100644
--- a/inc/modules/admin/what-config_beg.php
+++ b/inc/modules/admin/what-config_beg.php
@@ -60,142 +60,121 @@ if (IS_FORM_SENT()) {
 	setConfigEntry('beg_ral_di_notify', REQUEST_POST('beg_ral_di_notify'));
 } else {
 	// Prepare constants for the template
-	define('__BEG_POINTS'           , translateComma(getConfig('beg_points')      , false));
-	define('__BEG_POINTS_MAX'       , translateComma(getConfig('beg_points_max')  , false));
-	define('__BEG_NOTIFY_BONUS'     , translateComma(getConfig('beg_notify_bonus'), false));
-	define('__BEG_TIMEOUT'          , createTimeSelections(getConfig('beg_timeout')    , "beg_timeout"    , "Dhm"));
-	define('__BEG_UID_TIMEOUT'      , createTimeSelections(getConfig('beg_uid_timeout'), "beg_uid_timeout", "Dhm"));
-	define('__BEG_REMOTE_IP_TIMEOUT', createTimeSelections(getConfig('beg_ip_timeout') , "beg_ip_timeout" , "Dhm"));
-	define('__WAIT_SELECTION'       , createTimeSelections(getConfig('beg_notify_wait'), "beg_notify_wait", "ms" ));
-	define('__BEG_RANKS'            , getConfig('beg_ranks'));
+	$content['points']           = translateComma(getConfig('beg_points')      , false);
+	$content['points_max']       = translateComma(getConfig('beg_points_max')  , false);
+	$content['notify_bonus']     = translateComma(getConfig('beg_notify_bonus'), false);
+	$content['timeout']          = createTimeSelections(getConfig('beg_timeout')    , 'beg_timeout'    , 'Dhm');
+	$content['uid_timeout']      = createTimeSelections(getConfig('beg_uid_timeout'), 'beg_uid_timeout', 'Dhm');
+	$content['ip_timeout']       = createTimeSelections(getConfig('beg_ip_timeout') , 'beg_ip_timeout' , 'Dhm');
+	$content['wait_selection']   = createTimeSelections(getConfig('beg_notify_wait'), 'beg_notify_wait', 'ms' );
+	$content['ranks']            = getConfig('beg_ranks');
 
 	// Activate / Deactivate beg rallye (Y/N)
 	switch (getConfig('beg_rallye'))
 	{
 	case 'Y':
-		define('__BEG_RALLYE_Y', ' chkecked="checked"');
-		define('__BEG_RALLYE_N', '');
+		$content['rallye_yes'] = ' checked="checked"';
+		$content['rallye_no']  = '';
 		break;
 
 	case 'N':
-		define('__BEG_RALLYE_Y', '');
-		define('__BEG_RALLYE_N', ' chkecked="checked"');
+		$content['rallye_yes'] = '';
+		$content['rallye_no']  = ' checked="checked"';
 		break;
 	}
 
 	switch (getConfig('beg_active'))
 	{
 	case 'Y':
-		define('__BEG_ACTIVE_Y', ' chkecked="checked"');
-		define('__BEG_ACTIVE_N', '');
+		$content['active_yes'] = ' checked="checked"';
+		$content['active_no']  = '';
 		break;
 
 	case 'N':
-		define('__BEG_ACTIVE_Y', '');
-		define('__BEG_ACTIVE_N', ' chkecked="checked"');
+		$content['active_yes'] = '';
+		$content['active_no']  = ' checked="checked"';
 		break;
 	}
 
 	switch (getConfig('beg_mode'))
 	{
-	case "DIRECT":
-		define('__BEG_MODE_DIRECT', ' chkecked="checked"');
-		define('__BEG_MODE_REF'   , '');
+	case 'DIRECT':
+		$content['mode_direct'] = ' checked="checked"';
+		$content['mode_ref']    = '';
 		break;
 
-	case "REF":
-		define('__BEG_MODE_DIRECT', '');
-		define('__BEG_MODE_REF'   , ' chkecked="checked"');
+	case 'REF':
+		$content['mode_direct'] = '';
+		$content['mode_ref']    = ' checked="checked"';
 		break;
 	}
 
 	switch (getConfig('beg_ral_en_notify'))
 	{
 	case 'Y':
-		define('__BEG_RAL_EN_NOTIFY_Y', ' chkecked="checked"');
-		define('__BEG_RAL_EN_NOTIFY_N', '');
+		$content['ral_enable_notify_yes'] = ' checked="checked"';
+		$content['ral_enable_notify_no']  = '';
 		break;
 
 	case 'N':
-		define('__BEG_RAL_EN_NOTIFY_Y', '');
-		define('__BEG_RAL_EN_NOTIFY_N', ' chkecked="checked"');
+		$content['ral_enable_notify_yes'] = '';
+		$content['ral_enable_notify_no']  = ' checked="checked"';
 		break;
 	}
 
 	switch (getConfig('beg_ral_di_notify'))
 	{
 	case 'Y':
-		define('__BEG_RAL_DI_NOTIFY_Y', ' chkecked="checked"');
-		define('__BEG_RAL_DI_NOTIFY_N', '');
+		$content['ral_disable_notify_yes'] = ' checked="checked"';
+		$content['ral_disable_notify_no']  = '';
 		break;
 
 	case 'N':
-		define('__BEG_RAL_DI_NOTIFY_Y', '');
-		define('__BEG_RAL_DI_NOTIFY_N', ' chkecked="checked"');
+		$content['ral_disable_notify_yes'] = '';
+		$content['ral_disable_notify_no']  = ' checked="checked"';
 		break;
 	}
 
 	switch (getConfig('beg_new_mem_notify'))
 	{
 	case 'Y':
-		define('__BEG_NEW_MEMBER_NOTIFY_Y', ' chkecked="checked"');
-		define('__BEG_NEW_MEMBER_NOTIFY_N', '');
+		$content['new_member_notify_yes'] = ' checked="checked"';
+		$content['new_member_notify_no']  = '';
 		break;
 
 	case 'N':
-		define('__BEG_NEW_MEMBER_NOTIFY_Y', '');
-		define('__BEG_NEW_MEMBER_NOTIFY_N', ' chkecked="checked"');
+		$content['new_member_notify_yes'] = '';
+		$content['new_member_notify_no']  = ' checked="checked"';
 		break;
 	}
 
 	switch (getConfig('beg_include_own'))
 	{
 	case 'Y':
-		define('__BEG_INCLUDE_OWN_Y', ' chkecked="checked"');
-		define('__BEG_INCLUDE_OWN_N', '');
+		$content['include_own_yes'] = ' checked="checked"';
+		$content['include_own_no']  = '';
 		break;
 
 	case 'N':
-		define('__BEG_INCLUDE_OWN_Y', '');
-		define('__BEG_INCLUDE_OWN_N', ' chkecked="checked"');
+		$content['include_own_yes'] = '';
+		$content['include_own_no']  = ' checked="checked"';
 		break;
 	}
 
-	switch (getConfig('beg_pay_mode')) {
-		case "IMG":
-			define('__BEG_PAY_MODE_IMG' , ' selected="selected"');
-			define('__BEG_PAY_MODE_JS'  , '');
-			define('__BEG_PAY_MODE_BOTH', '');
-			define('__BEG_PAY_MODE_NONE', '');
-			break;
-
-		case "JS":
-			define('__BEG_PAY_MODE_IMG' , '');
-			define('__BEG_PAY_MODE_JS'  , ' selected="selected"');
-			define('__BEG_PAY_MODE_BOTH', '');
-			define('__BEG_PAY_MODE_NONE', '');
-			break;
-
-		case "BOTH":
-			define('__BEG_PAY_MODE_IMG' , '');
-			define('__BEG_PAY_MODE_JS'  , '');
-			define('__BEG_PAY_MODE_BOTH', ' selected="selected"');
-			define('__BEG_PAY_MODE_NONE', '');
-			break;
-
-		case "NONE":
-			define('__BEG_PAY_MODE_IMG' , '');
-			define('__BEG_PAY_MODE_JS'  , '');
-			define('__BEG_PAY_MODE_BOTH', '');
-			define('__BEG_PAY_MODE_NONE', ' selected="selected"');
-			break;
-	}
+	// Init elements
+	$content['pay_mode_img']  = '';
+	$content['pay_mode_js']   = '';
+	$content['pay_mode_both'] = '';
+	$content['pay_mode_none'] = '';
+
+	// Set pay mode
+	$content['pay_mode_'.strtolower(getConfig('beg_pay_mode'))] = ' selected="selected"';
 
-	// Add data to constant __MEMBER_SELECTION
-	define('__MEMBER_SELECTION', ADD_MEMBER_SELECTION_BOX(getConfig('beg_uid'), false, true, true, "beg_uid"));
+	// Member selection box
+	$content['member_selection'] = ADD_MEMBER_SELECTION_BOX(getConfig('beg_uid'), false, true, true, 'beg_uid');
 
 	// Load form template
-	LOAD_TEMPLATE("admin_config_beg");
+	LOAD_TEMPLATE('admin_config_beg', false, $content);
 }
 
 //
diff --git a/inc/modules/admin/what-config_birthday.php b/inc/modules/admin/what-config_birthday.php
index f93e242854..6261ae22d2 100644
--- a/inc/modules/admin/what-config_birthday.php
+++ b/inc/modules/admin/what-config_birthday.php
@@ -54,25 +54,25 @@ if (IS_FORM_SENT()) {
 	switch (getConfig('birthday_active'))
 	{
 	case 'Y':
-		define('__BIRTHDAY_ACTIVE_Y', ' chkecked="checked"');
-		define('__BIRTHDAY_ACTIVE_N', '');
+		$content['active_yes'] = ' checked="checked"';
+		$content['active_no']  = '';
 		break;
 
 	case 'N':
-		define('__BIRTHDAY_ACTIVE_Y', '');
-		define('__BIRTHDAY_ACTIVE_N', ' chkecked="checked"');
+		$content['active_yes'] = '';
+		$content['active_no']  = ' checked="checked"';
 		break;
 	}
 	switch (getConfig('birthday_mode'))
 	{
-	case "DIRECT":
-		define('__BIRTHDAY_MODE_DIRECT', ' chkecked="checked"');
-		define('__BIRTHDAY_MODE_REF'   , '');
+	case 'DIRECT':
+		$content['mode_direct'] = ' checked="checked"';
+		$content['mode_ref']    = '';
 		break;
 
-	case "REF":
-		define('__BIRTHDAY_MODE_DIRECT', '');
-		define('__BIRTHDAY_MODE_REF'   , ' chkecked="checked"');
+	case 'REF':
+		$content['mode_direct'] = '';
+		$content['mode_ref']    = ' checked="checked"';
 		break;
 	}
 
diff --git a/inc/modules/admin/what-config_bonus.php b/inc/modules/admin/what-config_bonus.php
index 1f2ff3bac7..8d65db67a6 100644
--- a/inc/modules/admin/what-config_bonus.php
+++ b/inc/modules/admin/what-config_bonus.php
@@ -115,135 +115,135 @@ if (IS_FORM_SENT()) {
 	$OUT .= "</ol>\n";
 	define('__TRATES_LIST', $OUT);
 
-	define('__LOGIN_TIMEOUT_SELECTION', createTimeSelections(getConfig('login_timeout')    , "login_timeout"    , "WDh"));
-	define('__BONUS_TIMEOUT_SELECTION', createTimeSelections(getConfig('bonus_timeout')    , "bonus_timeout"    , "WDh"));
-	define('__WAIT_SELECTION'         , createTimeSelections(getConfig('bonus_notify_wait'), "bonus_notify_wait", "ms" ));
+	define('__LOGIN_TIMEOUT_SELECTION', createTimeSelections(getConfig('login_timeout')    , 'login_timeout'    , 'WDh'));
+	define('__BONUS_TIMEOUT_SELECTION', createTimeSelections(getConfig('bonus_timeout')    , 'bonus_timeout'    , 'WDh'));
+	$content['wait_selection']        = createTimeSelections(getConfig('bonus_notify_wait'), 'bonus_notify_wait', 'ms' );
 
 	// Activate / Deactivate bonus active rallye (Y/N)
 	switch (getConfig('bonus_active'))
 	{
 	case 'Y':
-		define('__BONUS_ACTIVE_Y', ' chkecked="checked"');
+		define('__BONUS_ACTIVE_Y', ' checked="checked"');
 		define('__BONUS_ACTIVE_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_ACTIVE_Y', '');
-		define('__BONUS_ACTIVE_N', ' chkecked="checked"');
+		define('__BONUS_ACTIVE_N', ' checked="checked"');
 		break;
 	}
 	// Other bonus to de-/activate
 	switch (getConfig('bonus_login_yn'))
 	{
 	case 'Y':
-		define('__BONUS_LOGIN_Y', ' chkecked="checked"');
+		define('__BONUS_LOGIN_Y', ' checked="checked"');
 		define('__BONUS_LOGIN_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_LOGIN_Y', '');
-		define('__BONUS_LOGIN_N', ' chkecked="checked"');
+		define('__BONUS_LOGIN_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_stats_yn'))
 	{
 	case 'Y':
-		define('__BONUS_STATS_Y', ' chkecked="checked"');
+		define('__BONUS_STATS_Y', ' checked="checked"');
 		define('__BONUS_STATS_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_STATS_Y', '');
-		define('__BONUS_STATS_N', ' chkecked="checked"');
+		define('__BONUS_STATS_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_order_yn'))
 	{
 	case 'Y':
-		define('__BONUS_ORDER_Y', ' chkecked="checked"');
+		define('__BONUS_ORDER_Y', ' checked="checked"');
 		define('__BONUS_ORDER_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_ORDER_Y', '');
-		define('__BONUS_ORDER_N', ' chkecked="checked"');
+		define('__BONUS_ORDER_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_ref_yn'))
 	{
 	case 'Y':
-		define('__BONUS_REF_Y', ' chkecked="checked"');
+		define('__BONUS_REF_Y', ' checked="checked"');
 		define('__BONUS_REF_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_REF_Y', '');
-		define('__BONUS_REF_N', ' chkecked="checked"');
+		define('__BONUS_REF_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_click_yn'))
 	{
 	case 'Y':
-		define('__BONUS_CLICK_Y', ' chkecked="checked"');
+		define('__BONUS_CLICK_Y', ' checked="checked"');
 		define('__BONUS_CLICK_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_CLICK_Y', '');
-		define('__BONUS_CLICK_N', ' chkecked="checked"');
+		define('__BONUS_CLICK_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_en_notify'))
 	{
 	case 'Y':
-		define('__BONUS_EN_NOTIFY_Y', ' chkecked="checked"');
+		define('__BONUS_EN_NOTIFY_Y', ' checked="checked"');
 		define('__BONUS_EN_NOTIFY_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_EN_NOTIFY_Y', '');
-		define('__BONUS_EN_NOTIFY_N', ' chkecked="checked"');
+		define('__BONUS_EN_NOTIFY_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_di_notify'))
 	{
 	case 'Y':
-		define('__BONUS_DI_NOTIFY_Y', ' chkecked="checked"');
+		define('__BONUS_DI_NOTIFY_Y', ' checked="checked"');
 		define('__BONUS_DI_NOTIFY_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_DI_NOTIFY_Y', '');
-		define('__BONUS_DI_NOTIFY_N', ' chkecked="checked"');
+		define('__BONUS_DI_NOTIFY_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_new_mem_notify'))
 	{
 	case 'Y':
-		define('__BONUS_NEW_MEMBER_NOTIFY_Y', ' chkecked="checked"');
+		define('__BONUS_NEW_MEMBER_NOTIFY_Y', ' checked="checked"');
 		define('__BONUS_NEW_MEMBER_NOTIFY_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_NEW_MEMBER_NOTIFY_Y', '');
-		define('__BONUS_NEW_MEMBER_NOTIFY_N', ' chkecked="checked"');
+		define('__BONUS_NEW_MEMBER_NOTIFY_N', ' checked="checked"');
 		break;
 	}
 	switch (getConfig('bonus_include_own'))
 	{
 	case 'Y':
-		define('__BONUS_INCLUDE_OWN_Y', ' chkecked="checked"');
+		define('__BONUS_INCLUDE_OWN_Y', ' checked="checked"');
 		define('__BONUS_INCLUDE_OWN_N', '');
 		break;
 
 	case 'N':
 		define('__BONUS_INCLUDE_OWN_Y', '');
-		define('__BONUS_INCLUDE_OWN_N', ' chkecked="checked"');
+		define('__BONUS_INCLUDE_OWN_N', ' checked="checked"');
 		break;
 	}
 
 	// Load final template
-	LOAD_TEMPLATE("admin_config_bonus", false);
+	LOAD_TEMPLATE('admin_config_bonus', false, $content);
 }
 //
 ?>
diff --git a/inc/modules/admin/what-config_cache.php b/inc/modules/admin/what-config_cache.php
index d271c05deb..86d588a7d4 100644
--- a/inc/modules/admin/what-config_cache.php
+++ b/inc/modules/admin/what-config_cache.php
@@ -89,109 +89,109 @@ if (IS_FORM_SENT()) {
 	// Prepare data
 	switch (getConfig('cache_admins')) {
 		case 'Y':
-			define('__ADMINS_Y', ' chkecked="checked"');
+			define('__ADMINS_Y', ' checked="checked"');
 			define('__ADMINS_N', '');
 			break;
 
 		case 'N':
 			define('__ADMINS_Y', '');
-			define('__ADMINS_N', ' chkecked="checked"');
+			define('__ADMINS_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_acls')) {
 		case 'Y':
-			define('__ACLS_Y', ' chkecked="checked"');
+			define('__ACLS_Y', ' checked="checked"');
 			define('__ACLS_N', '');
 			break;
 
 		case 'N':
 			define('__ACLS_Y', '');
-			define('__ACLS_N', ' chkecked="checked"');
+			define('__ACLS_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_exts')) {
 		case 'Y':
-			define('__EXTS_Y', ' chkecked="checked"');
+			define('__EXTS_Y', ' checked="checked"');
 			define('__EXTS_N', '');
 			break;
 
 		case 'N':
 			define('__EXTS_Y', '');
-			define('__EXTS_N', ' chkecked="checked"');
+			define('__EXTS_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_config')) {
 		case 'Y':
-			define('__CONFIG_Y', ' chkecked="checked"');
+			define('__CONFIG_Y', ' checked="checked"');
 			define('__CONFIG_N', '');
 			break;
 
 		case 'N':
 			define('__CONFIG_Y', '');
-			define('__CONFIG_N', ' chkecked="checked"');
+			define('__CONFIG_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_modreg')) {
 		case 'Y':
-			define('__MODREG_Y', ' chkecked="checked"');
+			define('__MODREG_Y', ' checked="checked"');
 			define('__MODREG_N', '');
 			break;
 
 		case 'N':
 			define('__MODREG_Y', '');
-			define('__MODREG_N', ' chkecked="checked"');
+			define('__MODREG_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_refdepth')) {
 		case 'Y':
-			define('__REFDEPTH_Y', ' chkecked="checked"');
+			define('__REFDEPTH_Y', ' checked="checked"');
 			define('__REFDEPTH_N', '');
 			break;
 
 		case 'N':
 			define('__REFDEPTH_Y', '');
-			define('__REFDEPTH_N', ' chkecked="checked"');
+			define('__REFDEPTH_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_refsys')) {
 		case 'Y':
-			define('__REFSYS_Y', ' chkecked="checked"');
+			define('__REFSYS_Y', ' checked="checked"');
 			define('__REFSYS_N', '');
 			break;
 
 		case 'N':
 			define('__REFSYS_Y', '');
-			define('__REFSYS_N', ' chkecked="checked"');
+			define('__REFSYS_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_themes')) {
 		case 'Y':
-			define('__THEMES_Y', ' chkecked="checked"');
+			define('__THEMES_Y', ' checked="checked"');
 			define('__THEMES_N', '');
 			break;
 
 		case 'N':
 			define('__THEMES_Y', '');
-			define('__THEMES_N', ' chkecked="checked"');
+			define('__THEMES_N', ' checked="checked"');
 			break;
 	}
 
 	switch (getConfig('cache_admin_menu')) {
 		case 'Y':
-			define('__ADMIN_MENU_Y', ' chkecked="checked"');
+			define('__ADMIN_MENU_Y', ' checked="checked"');
 			define('__ADMIN_MENU_N', '');
 			break;
 
 		case 'N':
 			define('__ADMIN_MENU_Y', '');
-			define('__ADMIN_MENU_N', ' chkecked="checked"');
+			define('__ADMIN_MENU_N', ' checked="checked"');
 			break;
 	}
 
diff --git a/inc/modules/admin/what-config_doubler.php b/inc/modules/admin/what-config_doubler.php
index 303d52a515..a4370e8659 100644
--- a/inc/modules/admin/what-config_doubler.php
+++ b/inc/modules/admin/what-config_doubler.php
@@ -76,13 +76,13 @@ if (IS_FORM_SENT()) {
 	switch (getConfig('doubler_jackpot'))
 	{
 	case 'Y':
-		define('__DOUBLER_JACKPOT_Y', ' chkecked="checked"');
+		define('__DOUBLER_JACKPOT_Y', ' checked="checked"');
 		define('__DOUBLER_JACKPOT_N', '');
 		break;
 
 	case 'N':
 		define('__DOUBLER_JACKPOT_Y', '');
-		define('__DOUBLER_JACKPOT_N', ' chkecked="checked"');
+		define('__DOUBLER_JACKPOT_N', ' checked="checked"');
 		break;
 	}
 
@@ -90,27 +90,27 @@ if (IS_FORM_SENT()) {
 	switch (getConfig('doubler_own'))
 	{
 	case 'Y':
-		define('__DOUBLER_OWN_Y', ' chkecked="checked"');
+		define('__DOUBLER_OWN_Y', ' checked="checked"');
 		define('__DOUBLER_OWN_N', '');
 		break;
 
 	case 'N':
 		define('__DOUBLER_OWN_Y', '');
-		define('__DOUBLER_OWN_N', ' chkecked="checked"');
+		define('__DOUBLER_OWN_N', ' checked="checked"');
 		break;
 	}
 
 	// Mail send mode
 	switch (getConfig('doubler_send_mode'))
 	{
-	case "DIRECT":
-		define('__DOUBLER_SEND_DIRECT', ' chkecked="checked"');
+	case 'DIRECT':
+		define('__DOUBLER_SEND_DIRECT', ' checked="checked"');
 		define('__DOUBLER_SEND_RESET' , '');
 		break;
 
 	case "RESET":
 		define('__DOUBLER_SEND_DIRECT', '');
-		define('__DOUBLER_SEND_RESET' , ' chkecked="checked"');
+		define('__DOUBLER_SEND_RESET' , ' checked="checked"');
 		break;
 	}
 
@@ -118,29 +118,30 @@ if (IS_FORM_SENT()) {
 	switch (getConfig('doubler_sent_all'))
 	{
 	case 'Y':
-		define('__DOUBLER_SENT_ALL_Y', ' chkecked="checked"');
+		define('__DOUBLER_SENT_ALL_Y', ' checked="checked"');
 		define('__DOUBLER_SENT_ALL_N', '');
 		break;
 
 	case 'N':
 		define('__DOUBLER_SENT_ALL_Y', '');
-		define('__DOUBLER_SENT_ALL_N', ' chkecked="checked"');
+		define('__DOUBLER_SENT_ALL_N', ' checked="checked"');
 		break;
 	}
 
 	// Transfer options (!!!) to __MEMBER_SELECTION
-	define('__MEMBER_SELECTION', ADD_MEMBER_SELECTION_BOX(getConfig('doubler_uid'), false, true, true, "doubler_uid"));
+	define('__MEMBER_SELECTION', ADD_MEMBER_SELECTION_BOX(getConfig('doubler_uid'), false, true, true, 'doubler_uid'));
 
 	// Number of rows to display (option lines!!!)
-	define('__DOUBLER_DISPLAY_NEW', generateOptionList("/ARRAY/", array(5,10,20,30,40,50,100), array(5,10,20,30,40,50,100), getConfig('doubler_display_new')));
-	define('__DOUBLER_DISPLAY_PAY', generateOptionList("/ARRAY/", array(5,10,20,30,40,50,100), array(5,10,20,30,40,50,100), getConfig('doubler_display_pay')));
-	define('__DOUBLER_DISPLAY_OLD', generateOptionList("/ARRAY/", array(5,10,20,30,40,50,100), array(5,10,20,30,40,50,100), getConfig('doubler_display_old')));
+	define('__DOUBLER_DISPLAY_NEW', generateOptionList('/ARRAY/', array(5,10,20,30,40,50,100), array(5,10,20,30,40,50,100), getConfig('doubler_display_new')));
+	define('__DOUBLER_DISPLAY_PAY', generateOptionList('/ARRAY/', array(5,10,20,30,40,50,100), array(5,10,20,30,40,50,100), getConfig('doubler_display_pay')));
+	define('__DOUBLER_DISPLAY_OLD', generateOptionList('/ARRAY/', array(5,10,20,30,40,50,100), array(5,10,20,30,40,50,100), getConfig('doubler_display_old')));
 
 	// Timeout selection box or input box?
-	define('__DOUBLER_TIMEOUT', createTimeSelections(getConfig('doubler_timeout')  , "doubler_timeout"  , "WDh"));
+	define('__DOUBLER_TIMEOUT', createTimeSelections(getConfig('doubler_timeout')  , 'doubler_timeout'  , 'WDh'));
 
 	// Load template
-	LOAD_TEMPLATE("admin_config_doubler");
+	LOAD_TEMPLATE('admin_config_doubler');
 }
+
 //
 ?>
diff --git a/inc/modules/admin/what-config_extensions.php b/inc/modules/admin/what-config_extensions.php
index 2863d40771..bd1d4e2605 100644
--- a/inc/modules/admin/what-config_extensions.php
+++ b/inc/modules/admin/what-config_extensions.php
@@ -52,13 +52,13 @@ if (IS_FORM_SENT()) {
 	// Prepare data
 	switch (getConfig('verbose_sql')) {
 		case 'Y':
-			define('__VERBOSE_Y', ' chkecked="checked"');
+			define('__VERBOSE_Y', ' checked="checked"');
 			define('__VERBOSE_N', '');
 			break;
 
 		case 'N':
 			define('__VERBOSE_Y', '');
-			define('__VERBOSE_N', ' chkecked="checked"');
+			define('__VERBOSE_N', ' checked="checked"');
 			break;
 	}
 
diff --git a/inc/modules/admin/what-config_holiday.php b/inc/modules/admin/what-config_holiday.php
index cde0b8234a..ac6f9091e4 100644
--- a/inc/modules/admin/what-config_holiday.php
+++ b/inc/modules/admin/what-config_holiday.php
@@ -58,13 +58,13 @@ if (IS_FORM_SENT())
 
 	switch (getConfig('holiday_mode')) {
 	case "RESET":
-		define('__RESET_DEFAULT' , ' chkecked="checked"');
+		define('__RESET_DEFAULT' , ' checked="checked"');
 		define('__DIRECT_DEFAULT', '');
 		break;
 
-	case "DIRECT":
+	case 'DIRECT':
 		define('__RESET_DEFAULT' , '');
-		define('__DIRECT_DEFAULT', ' chkecked="checked"');
+		define('__DIRECT_DEFAULT', ' checked="checked"');
 		break;
 	}
 
diff --git a/inc/modules/admin/what-config_mediadata.php b/inc/modules/admin/what-config_mediadata.php
index 7d7a403aaa..c719cc1729 100644
--- a/inc/modules/admin/what-config_mediadata.php
+++ b/inc/modules/admin/what-config_mediadata.php
@@ -76,7 +76,7 @@ if (IS_FORM_SENT()) {
 	// Start of this exchange
 	if (getConfig('mt_start') > 0) {
 		// Only show start
-		define('__MT_START', "<strong>".generateDateTime(getConfig('mt_start'), "3")."</strong>");
+		define('__MT_START', "<strong>".generateDateTime(getConfig('mt_start'), '3')."</strong>");
 	} else {
 		// Make start editable
 		define('__MT_START',
diff --git a/inc/modules/admin/what-config_order.php b/inc/modules/admin/what-config_order.php
index 584f71f521..665e149a17 100644
--- a/inc/modules/admin/what-config_order.php
+++ b/inc/modules/admin/what-config_order.php
@@ -53,13 +53,13 @@ if (IS_FORM_SENT()) {
 	switch (getConfig('order_max_full'))
 	{
 	case 'ORDER':
-		define('__ORDER_DEFAULT', ' chkecked="checked"');
+		define('__ORDER_DEFAULT', ' checked="checked"');
 		define('__MAX_DEFAULT'  , '');
 		break;
 
 	case 'MAX':
 		define('__ORDER_DEFAULT', '');
-		define('__MAX_DEFAULT'  , ' chkecked="checked"');
+		define('__MAX_DEFAULT'  , ' checked="checked"');
 		break;
 	}
 
@@ -85,11 +85,11 @@ if (IS_FORM_SENT()) {
 	define('_CFG_MAX_TLENGTH'   , getConfig('max_tlength'));
 
 	if (getConfig('test_text') != 'Y') {
-		define('_CFG_TEST_TEXT_N', ' chkecked="checked"');
+		define('_CFG_TEST_TEXT_N', ' checked="checked"');
 		define('_CFG_TEST_TEXT_Y', '');
 	} else {
 		define('_CFG_TEST_TEXT_N', '');
-		define('_CFG_TEST_TEXT_Y', ' chkecked="checked"');
+		define('_CFG_TEST_TEXT_Y', ' checked="checked"');
 	}
 
 	switch (getConfig('repay_deleted_mails')) {
@@ -113,19 +113,19 @@ if (IS_FORM_SENT()) {
 	}
 
 	if (getConfig('test_subj') != 'Y') {
-		define('_CFG_TEST_SUBJ_N', ' chkecked="checked"');
+		define('_CFG_TEST_SUBJ_N', ' checked="checked"');
 		define('_CFG_TEST_SUBJ_Y', '');
 	} else {
 		define('_CFG_TEST_SUBJ_N', '');
-		define('_CFG_TEST_SUBJ_Y', ' chkecked="checked"');
+		define('_CFG_TEST_SUBJ_Y', ' checked="checked"');
 	}
 
 	if (getConfig('url_blacklist') != 'Y') {
-		define('_CFG_URL_BLIST_N', ' chkecked="checked"');
+		define('_CFG_URL_BLIST_N', ' checked="checked"');
 		define('_CFG_URL_BLIST_Y', '');
 	} else {
 		define('_CFG_URL_BLIST_N', '');
-		define('_CFG_URL_BLIST_Y', ' chkecked="checked"');
+		define('_CFG_URL_BLIST_Y', ' checked="checked"');
 	}
 
 	// Selection list
diff --git a/inc/modules/admin/what-config_other.php b/inc/modules/admin/what-config_other.php
index 71971c0521..b333ac5b51 100644
--- a/inc/modules/admin/what-config_other.php
+++ b/inc/modules/admin/what-config_other.php
@@ -92,91 +92,91 @@ if (IS_FORM_SENT()) {
 	define('_CFG_PROF_REUPDATE' , createTimeSelections(getConfig('resend_profile_update') , 'resend_profile_update', 'MWD'));
 
 	if (getConfig('order_multi_page') != 'Y') {
-		define('_CFG_ORDER_MULTI_N', ' chkecked="checked"');
+		define('_CFG_ORDER_MULTI_N', ' checked="checked"');
 		define('_CFG_ORDER_MULTI_Y', '');
 	} else {
 		define('_CFG_ORDER_MULTI_N', '');
-		define('_CFG_ORDER_MULTI_Y', ' chkecked="checked"');
+		define('_CFG_ORDER_MULTI_Y', ' checked="checked"');
 	}
 
 	if (getConfig('autosend_active') != 'Y') {
-		define('_CFG_AUTOSEND_ACTIVE_N', ' chkecked="checked"');
+		define('_CFG_AUTOSEND_ACTIVE_N', ' checked="checked"');
 		define('_CFG_AUTOSEND_ACTIVE_Y', '');
 	} else {
 		define('_CFG_AUTOSEND_ACTIVE_N', '');
-		define('_CFG_AUTOSEND_ACTIVE_Y', ' chkecked="checked"');
+		define('_CFG_AUTOSEND_ACTIVE_Y', ' checked="checked"');
 	}
 
 	if (getConfig('send_prof_update') != 'Y') {
-		define('_CFG_SEND_UPDATE_N', ' chkecked="checked"');
+		define('_CFG_SEND_UPDATE_N', ' checked="checked"');
 		define('_CFG_SEND_UPDATE_Y', '');
 	} else {
 		define('_CFG_SEND_UPDATE_N', '');
-		define('_CFG_SEND_UPDATE_Y', ' chkecked="checked"');
+		define('_CFG_SEND_UPDATE_Y', ' checked="checked"');
 	}
 
 	if (getConfig('admin_notify') != 'Y') {
-		define('_CFG_ADMIN_NOTIFY_N', ' chkecked="checked"');
+		define('_CFG_ADMIN_NOTIFY_N', ' checked="checked"');
 		define('_CFG_ADMIN_NOTIFY_Y', '');
 	} else {
 		define('_CFG_ADMIN_NOTIFY_N', '');
-		define('_CFG_ADMIN_NOTIFY_Y', ' chkecked="checked"');
+		define('_CFG_ADMIN_NOTIFY_Y', ' checked="checked"');
 	}
 
-	if (getConfig('css_php') == "DIRECT") {
-		define('_CFG_CSS_PHP_DIRECT', ' chkecked="checked"');
+	if (getConfig('css_php') == 'DIRECT') {
+		define('_CFG_CSS_PHP_DIRECT', ' checked="checked"');
 		define('_CFG_CSS_PHP_FILE', '');
 	} else {
 		define('_CFG_CSS_PHP_DIRECT', '');
-		define('_CFG_CSS_PHP_FILE', ' chkecked="checked"');
+		define('_CFG_CSS_PHP_FILE', ' checked="checked"');
 	}
 
 	if (getConfig('guest_menu') == 'Y') {
-		define('_CFG_GUEST_MENU_ACTIVE', ' chkecked="checked"');
+		define('_CFG_GUEST_MENU_ACTIVE', ' checked="checked"');
 		define('_CFG_GUEST_MENU_INACTIVE', '');
 	} else {
 		define('_CFG_GUEST_MENU_ACTIVE', '');
-		define('_CFG_GUEST_MENU_INACTIVE', ' chkecked="checked"');
+		define('_CFG_GUEST_MENU_INACTIVE', ' checked="checked"');
 	}
 
 	if (getConfig('member_menu') == 'Y') {
-		define('_CFG_MEMBER_MENU_ACTIVE', ' chkecked="checked"');
+		define('_CFG_MEMBER_MENU_ACTIVE', ' checked="checked"');
 		define('_CFG_MEMBER_MENU_INACTIVE', '');
 	} else {
 		define('_CFG_MEMBER_MENU_ACTIVE', '');
-		define('_CFG_MEMBER_MENU_INACTIVE', ' chkecked="checked"');
+		define('_CFG_MEMBER_MENU_INACTIVE', ' checked="checked"');
 	}
 
 	if (getConfig('youre_here') == 'Y') {
-		define('_CFG_YOURE_HERE_ACTIVE', ' chkecked="checked"');
+		define('_CFG_YOURE_HERE_ACTIVE', ' checked="checked"');
 		define('_CFG_YOURE_HERE_INACTIVE', '');
 	} else {
 		define('_CFG_YOURE_HERE_ACTIVE', '');
-		define('_CFG_YOURE_HERE_INACTIVE', ' chkecked="checked"');
+		define('_CFG_YOURE_HERE_INACTIVE', ' checked="checked"');
 	}
 
 	if (getConfig('show_timings') == 'Y') {
-		define('_CFG_SHOW_TIMINGS_Y', ' chkecked="checked"');
+		define('_CFG_SHOW_TIMINGS_Y', ' checked="checked"');
 		define('_CFG_SHOW_TIMINGS_N', '');
 	} else {
 		define('_CFG_SHOW_TIMINGS_Y', '');
-		define('_CFG_SHOW_TIMINGS_N', ' chkecked="checked"');
+		define('_CFG_SHOW_TIMINGS_N', ' checked="checked"');
 	}
 
 	if (getConfig('show_points_unconfirmed') == 'Y') {
-		define('_CFG_SHOW_POINTS_UNCONFIRMED_Y', ' chkecked="checked"');
+		define('_CFG_SHOW_POINTS_UNCONFIRMED_Y', ' checked="checked"');
 		define('_CFG_SHOW_POINTS_UNCONFIRMED_N', '');
 	} else {
 		define('_CFG_SHOW_POINTS_UNCONFIRMED_Y', '');
-		define('_CFG_SHOW_POINTS_UNCONFIRMED_N', ' chkecked="checked"');
+		define('_CFG_SHOW_POINTS_UNCONFIRMED_N', ' checked="checked"');
 	}
 
 	if (getConfig('mailid_error_redirect') == 'INDEX') {
-		define('_CFG_MAILID_REDIRECT_INDEX', ' chkecked="checked"');
+		define('_CFG_MAILID_REDIRECT_INDEX', ' checked="checked"');
 		define('_CFG_MAILID_REDIRECT_REJECT', '');
 	} else {
 		define('_CFG_MAILID_REDIRECT_INDEX', '');
-		define('_CFG_MAILID_REDIRECT_REJECT', ' chkecked="checked"');
+		define('_CFG_MAILID_REDIRECT_REJECT', ' checked="checked"');
 	}
 
 	for ($i = 0; $i <= 5; $i++) {
diff --git a/inc/modules/admin/what-config_points.php b/inc/modules/admin/what-config_points.php
index 874f8c79b9..df3046a985 100644
--- a/inc/modules/admin/what-config_points.php
+++ b/inc/modules/admin/what-config_points.php
@@ -176,26 +176,26 @@ WHERE mails_confirmed < %s", $REF, $REF));
 	// Including new add-mode for one-time referal bonus
 	switch (getConfig('allow_direct_pay')) {
 	case 'Y':
-		define('__DIRECT_Y', ' chkecked="checked"');
+		define('__DIRECT_Y', ' checked="checked"');
 		define('__DIRECT_N', '');
 		break;
 
 	case 'N':
 		define('__DIRECT_Y', '');
-		define('__DIRECT_N', ' chkecked="checked"');
+		define('__DIRECT_N', ' checked="checked"');
 		break;
 	}
 
 	// One-time referal bonus add-mode
 	switch (getConfig('reg_points_mode')) {
 		case 'ref'   :
-			define('__MODE_REF', ' chkecked="checked"');
+			define('__MODE_REF', ' checked="checked"');
 			define('__MODE_DIRECT', '');
 			break;
 
 		case 'direct':
 			define('__MODE_REF', '');
-			define('__MODE_DIRECT', ' chkecked="checked"');
+			define('__MODE_DIRECT', ' checked="checked"');
 			break;
 	}
 
diff --git a/inc/modules/admin/what-config_rallye_prices.php b/inc/modules/admin/what-config_rallye_prices.php
index 09915021bd..05af9628f2 100644
--- a/inc/modules/admin/what-config_rallye_prices.php
+++ b/inc/modules/admin/what-config_rallye_prices.php
@@ -254,8 +254,8 @@ WHERE d.admin_id=a.id ORDER BY start_time DESC", __FILE__, __LINE__);
 				'aid'        => $content['admin_id'],
 				'email_link' => generateMemberEmailLink($content['admin_id']),
 				'alogin'     => $content['login'],
-				'start'      => generateDateTime($content['start_time'], "3"),
-				'end'        => generateDateTime($content['end_time'], "3"),
+				'start'      => generateDateTime($content['start_time'], '3'),
+				'end'        => generateDateTime($content['end_time'], '3'),
 			);
 
 			// Load row template and switch color
diff --git a/inc/modules/admin/what-config_refback.php b/inc/modules/admin/what-config_refback.php
index 7cb2758586..9432f69482 100644
--- a/inc/modules/admin/what-config_refback.php
+++ b/inc/modules/admin/what-config_refback.php
@@ -58,13 +58,13 @@ if (IS_FORM_SENT()) {
 	// Add more content
 	switch (getConfig('refback_enabled')) {
 		case 'Y': // Refback enabled
-			$content['refback_enabled_y'] = ' chkecked="checked"';
+			$content['refback_enabled_y'] = ' checked="checked"';
 			$content['refback_enabled_n'] = '';
 			break;
 
 		case 'N': // Refback disabled
 			$content['refback_enabled_y'] = '';
-			$content['refback_enabled_n'] = ' chkecked="checked"';
+			$content['refback_enabled_n'] = ' checked="checked"';
 			break;
 	}
 
diff --git a/inc/modules/admin/what-config_removeip.php b/inc/modules/admin/what-config_removeip.php
index 626e23176e..8967f1ef59 100644
--- a/inc/modules/admin/what-config_removeip.php
+++ b/inc/modules/admin/what-config_removeip.php
@@ -52,97 +52,97 @@ if (IS_FORM_SENT()) {
 	// Prepare data
 	switch (getConfig('removeip_anon_ip')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_ANON_IP_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_IP_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_ANON_IP_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_ANON_IP_Y', '');
-			define('__CFG_REMOVEIP_ANON_IP_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_IP_N', ' checked="checked"');
 			break;
 	} // END - switch
 
 	switch (getConfig('removeip_anon_host')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_ANON_HOST_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_HOST_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_ANON_HOST_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_ANON_HOST_Y', '');
-			define('__CFG_REMOVEIP_ANON_HOST_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_HOST_N', ' checked="checked"');
 			break;
 	} // END - switch
 
 	switch (getConfig('removeip_anon_ua')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_ANON_UA_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_UA_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_ANON_UA_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_ANON_UA_Y', '');
-			define('__CFG_REMOVEIP_ANON_UA_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_UA_N', ' checked="checked"');
 			break;
 	} // END - switch
 
 	switch (getConfig('removeip_anon_ref')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_ANON_REF_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_REF_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_ANON_REF_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_ANON_REF_Y', '');
-			define('__CFG_REMOVEIP_ANON_REF_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ANON_REF_N', ' checked="checked"');
 			break;
 	} // END - switch
 
 	switch (getConfig('removeip_admin_show')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_ADMIN_SHOW_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ADMIN_SHOW_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_ADMIN_SHOW_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_ADMIN_SHOW_Y', '');
-			define('__CFG_REMOVEIP_ADMIN_SHOW_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_ADMIN_SHOW_N', ' checked="checked"');
 			break;
 	} // END - switch
 
 	switch (getConfig('removeip_guest_show')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_GUEST_SHOW_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_GUEST_SHOW_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_GUEST_SHOW_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_GUEST_SHOW_Y', '');
-			define('__CFG_REMOVEIP_GUEST_SHOW_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_GUEST_SHOW_N', ' checked="checked"');
 			break;
 	} // END - switch
 
 	switch (getConfig('removeip_member_show')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_MEMBER_SHOW_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_MEMBER_SHOW_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_MEMBER_SHOW_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_MEMBER_SHOW_Y', '');
-			define('__CFG_REMOVEIP_MEMBER_SHOW_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_MEMBER_SHOW_N', ' checked="checked"');
 			break;
 	} // END - switch
 
 	switch (getConfig('removeip_sponsor_show')) {
 		case 'Y':
-			define('__CFG_REMOVEIP_SPONSOR_SHOW_Y', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_SPONSOR_SHOW_Y', ' checked="checked"');
 			define('__CFG_REMOVEIP_SPONSOR_SHOW_N', '');
 			break;
 
 		case 'N':
 			define('__CFG_REMOVEIP_SPONSOR_SHOW_Y', '');
-			define('__CFG_REMOVEIP_SPONSOR_SHOW_N', ' chkecked="checked"');
+			define('__CFG_REMOVEIP_SPONSOR_SHOW_N', ' checked="checked"');
 			break;
 	} // END - switch
 
diff --git a/inc/modules/admin/what-config_rewrite.php b/inc/modules/admin/what-config_rewrite.php
index 111e06c2ee..8c36ce73ff 100644
--- a/inc/modules/admin/what-config_rewrite.php
+++ b/inc/modules/admin/what-config_rewrite.php
@@ -73,12 +73,12 @@ if (IS_FORM_SENT()) {
 		// Already registered module?
 		if (ereg($content['module'], getConfig('rewrite_skip'))) {
 			// Found
-			$y = ' chkecked="checked"';
+			$y = ' checked="checked"';
 			$n = '';
 		} else {
 			// Not found
 			$y = '';
-			$n = ' chkecked="checked"';
+			$n = ' checked="checked"';
 		}
 
 		// Remember data in array for the dynamic row template
diff --git a/inc/modules/admin/what-config_surfbar.php b/inc/modules/admin/what-config_surfbar.php
index ee4f738d1d..f1b04536c2 100644
--- a/inc/modules/admin/what-config_surfbar.php
+++ b/inc/modules/admin/what-config_surfbar.php
@@ -75,67 +75,67 @@ if (IS_FORM_SENT()) {
 	// Prepare payment model for template
 	if (getConfig('surfbar_pay_model') == 'STATIC') {
 		// Static model
-		define('__CONFIG_SURFBAR_PAY_MODEL_STATIC' , ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_PAY_MODEL_STATIC' , ' checked="checked"');
 		define('__CONFIG_SURFBAR_PAY_MODEL_DYNAMIC', '');
 	} else {
 		// Dynamic model
 		define('__CONFIG_SURFBAR_PAY_MODEL_STATIC' , '');
-		define('__CONFIG_SURFBAR_PAY_MODEL_DYNAMIC', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_PAY_MODEL_DYNAMIC', ' checked="checked"');
 	}
 
 	// Prepare auto-sart
 	if (getConfig('surfbar_autostart') == 'Y') {
 		// Yes selected
-		define('__CONFIG_SURFBAR_AUTOSTART_Y', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_AUTOSTART_Y', ' checked="checked"');
 		define('__CONFIG_SURFBAR_AUTOSTART_N', '');
 	} else {
 		// No selected
 		define('__CONFIG_SURFBAR_AUTOSTART_Y', '');
-		define('__CONFIG_SURFBAR_AUTOSTART_N', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_AUTOSTART_N', ' checked="checked"');
 	}
 
 	// Prepare notify limits
 	if (getConfig('surfbar_notify_limits') == 'Y') {
 		// Yes selected
-		define('__CONFIG_SURFBAR_NOTIFY_LIMITS_Y', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_NOTIFY_LIMITS_Y', ' checked="checked"');
 		define('__CONFIG_SURFBAR_NOTIFY_LIMITS_N', '');
 	} else {
 		// No selected
 		define('__CONFIG_SURFBAR_NOTIFY_LIMITS_Y', '');
-		define('__CONFIG_SURFBAR_NOTIFY_LIMITS_N', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_NOTIFY_LIMITS_N', ' checked="checked"');
 	}
 
 	// Prepare notify admin about unlocked emails
 	if (getConfig('surfbar_notify_admin_unlock') == 'Y') {
 		// Yes selected
-		define('__CONFIG_SURFBAR_NOTIFY_ADMIN_UNLOCK_Y', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_NOTIFY_ADMIN_UNLOCK_Y', ' checked="checked"');
 		define('__CONFIG_SURFBAR_NOTIFY_ADMIN_UNLOCK_N', '');
 	} else {
 		// No selected
 		define('__CONFIG_SURFBAR_NOTIFY_ADMIN_UNLOCK_Y', '');
-		define('__CONFIG_SURFBAR_NOTIFY_ADMIN_UNLOCK_N', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_NOTIFY_ADMIN_UNLOCK_N', ' checked="checked"');
 	}
 
 	// Prepare order migration
 	if (getConfig('surfbar_migrate_order') == 'Y') {
 		// Yes selected
-		define('__CONFIG_SURFBAR_MIGRATE_ORDER_Y', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_MIGRATE_ORDER_Y', ' checked="checked"');
 		define('__CONFIG_SURFBAR_MIGRATE_ORDER_N', '');
 	} else {
 		// No selected
 		define('__CONFIG_SURFBAR_MIGRATE_ORDER_Y', '');
-		define('__CONFIG_SURFBAR_MIGRATE_ORDER_N', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_MIGRATE_ORDER_N', ' checked="checked"');
 	}
 
 	// Pause URL mode
 	if (getConfig('surfbar_pause_mode') == 'INTERNAL') {
 		// Internal pause page
-		define('__CONFIG_SURFBAR_PAUSE_MODE_INTERNAL', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_PAUSE_MODE_INTERNAL', ' checked="checked"');
 		define('__CONFIG_SURFBAR_PAUSE_MODE_EXTERNAL', '');
 	} else {
 		// External pause page (if not empty)
 		define('__CONFIG_SURFBAR_PAUSE_MODE_INTERNAL', '');
-		define('__CONFIG_SURFBAR_PAUSE_MODE_EXTERNAL', ' chkecked="checked"');
+		define('__CONFIG_SURFBAR_PAUSE_MODE_EXTERNAL', ' checked="checked"');
 	}
 
 	// Notification mode
diff --git a/inc/modules/admin/what-config_wernis.php b/inc/modules/admin/what-config_wernis.php
index ccd6fbfbc5..51016bf817 100644
--- a/inc/modules/admin/what-config_wernis.php
+++ b/inc/modules/admin/what-config_wernis.php
@@ -86,23 +86,23 @@ if (IS_FORM_SENT()) {
 	// Prepare payout Y/N selection
 	if (getConfig('wernis_payout_active') == 'Y') {
 		// Payout allowed
-		define('__CFG_WERNIS_PAYOUT_ACTIVE_Y', ' chkecked="checked"');
+		define('__CFG_WERNIS_PAYOUT_ACTIVE_Y', ' checked="checked"');
 		define('__CFG_WERNIS_PAYOUT_ACTIVE_N', '');
 	} else {
 		// Payout disabled
 		define('__CFG_WERNIS_PAYOUT_ACTIVE_Y', '');
-		define('__CFG_WERNIS_PAYOUT_ACTIVE_N', ' chkecked="checked"');
+		define('__CFG_WERNIS_PAYOUT_ACTIVE_N', ' checked="checked"');
 	}
 
 	// Prepare withdraw Y/N selection
 	if (getConfig('wernis_withdraw_active') == 'Y') {
 		// Payout allowed
-		define('__CFG_WERNIS_WITHDRAW_ACTIVE_Y', ' chkecked="checked"');
+		define('__CFG_WERNIS_WITHDRAW_ACTIVE_Y', ' checked="checked"');
 		define('__CFG_WERNIS_WITHDRAW_ACTIVE_N', '');
 	} else {
 		// Payout disabled
 		define('__CFG_WERNIS_WITHDRAW_ACTIVE_Y', '');
-		define('__CFG_WERNIS_WITHDRAW_ACTIVE_N', ' chkecked="checked"');
+		define('__CFG_WERNIS_WITHDRAW_ACTIVE_N', ' checked="checked"');
 	}
 
 	// Load template
diff --git a/inc/modules/admin/what-del_holiday.php b/inc/modules/admin/what-del_holiday.php
index c1f8af8e76..74cfcf0506 100644
--- a/inc/modules/admin/what-del_holiday.php
+++ b/inc/modules/admin/what-del_holiday.php
@@ -77,8 +77,8 @@ WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
 
 			// Prepare loaded data for the
 			$content = array(
-				'start' => generateDateTime($start, "3"),
-				'end'   => generateDateTime($end  , "3")
+				'start' => generateDateTime($start, '3'),
+				'end'   => generateDateTime($end  , '3')
 			);
 
 			// Send email to user
diff --git a/inc/modules/admin/what-del_transfer.php b/inc/modules/admin/what-del_transfer.php
index 9cc0a1b92c..04f171e199 100644
--- a/inc/modules/admin/what-del_transfer.php
+++ b/inc/modules/admin/what-del_transfer.php
@@ -77,7 +77,7 @@ if (SQL_NUMROWS($result) > 0) {
 		$content = array(
 			'sw'       => $SW,
 			'idx'      => $content['trans_id'],
-			'stamp'    => generateDateTime($content['time_trans'], "3"),
+			'stamp'    => generateDateTime($content['time_trans'], '3'),
 			'uid_from' => generateUserProfileLink($content['userid']),
 			'uid_to'   => generateUserProfileLink($content['to_uid']),
 			'reason'   => $content['reason'],
diff --git a/inc/modules/admin/what-email_archiv.php b/inc/modules/admin/what-email_archiv.php
index 961edaec7e..f86d378d2e 100644
--- a/inc/modules/admin/what-email_archiv.php
+++ b/inc/modules/admin/what-email_archiv.php
@@ -58,7 +58,7 @@ $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, time
 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
 
 // Set offset an current page to default values
-if (!REQUEST_ISSET_GET('page'))   REQUEST_SET_GET('page'  , "1");
+if (!REQUEST_ISSET_GET('page'))   REQUEST_SET_GET('page'  , '1');
 if (!REQUEST_ISSET_GET('offset')) REQUEST_SET_GET('offset', getConfig('mails_page'));
 
 // Add limitation to SQL string
@@ -76,8 +76,8 @@ if (SQL_NUMROWS($result) > 0) {
 
 	// Add navigation table rows
 	if ($PAGES > 1) {
-		define('__TOP_EMAIL_NAV'   , ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), true , "3", true));
-		define('__BOTTOM_EMAIL_NAV', ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, "3", true));
+		define('__TOP_EMAIL_NAV'   , ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), true , '3', true));
+		define('__BOTTOM_EMAIL_NAV', ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, '3', true));
 	} else {
 		define('__TOP_EMAIL_NAV'   , '');
 		define('__BOTTOM_EMAIL_NAV', '');
diff --git a/inc/modules/admin/what-email_details.php b/inc/modules/admin/what-email_details.php
index 8b1a87da3a..8fc1566d93 100644
--- a/inc/modules/admin/what-email_details.php
+++ b/inc/modules/admin/what-email_details.php
@@ -99,7 +99,7 @@ ORDER BY timestamp DESC";
 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
 
 // Set offset an current page to default values
-if (!REQUEST_ISSET_GET('page')) REQUEST_SET_GET('page', "1");
+if (!REQUEST_ISSET_GET('page')) REQUEST_SET_GET('page', '1');
 
 if (!REQUEST_ISSET_GET('offset')) {
 	if (isConfigEntrySet('mails_page')) {
@@ -181,7 +181,7 @@ if (SQL_NUMROWS($result_list) > 0) {
 
 	// Add navigation (with change box and colspan=3)
 	$content['nav'] = '';
-	if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, "3", true);
+	if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, '3', true);
 
 	// Prepare content
 	$content['rows'] = $OUT;
@@ -230,7 +230,7 @@ if ((EXT_IS_ACTIVE('bonus')) && ($WHO == _ALL)) {
 
 		// Add navigation (without change box but with colspan=3)
 		$content['nav'] = '';
-		if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, "3", true);
+		if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, '3', true);
 
 		// Prepare content
 		$content['rows'] = $OUT;
diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php
index f72bc83dcb..53abc64888 100644
--- a/inc/modules/admin/what-extensions.php
+++ b/inc/modules/admin/what-extensions.php
@@ -114,7 +114,7 @@ if (REQUEST_ISSET_GET(('reg_ext'))) {
 		LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_EXT_CHANGED'));
 	} else {
 		// Edit selected entries
-		$SW = "2"; $OUT = '';
+		$SW = 2; $OUT = '';
 		foreach (REQUEST_POST('sel') as $ext_id => $sel) {
 			// Edit this extension?
 			if (($sel == 'Y') || ($sel == 'N')) {
diff --git a/inc/modules/admin/what-guest_add.php b/inc/modules/admin/what-guest_add.php
index 7b9475afb5..f75c256fb5 100644
--- a/inc/modules/admin/what-guest_add.php
+++ b/inc/modules/admin/what-guest_add.php
@@ -141,18 +141,13 @@ WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort`",
 
 	$OUT = "    <select class=\"admin_select\" name=\"sort\" size=\"1\">
       <option value=\"0\">".IS_FIRST_MENU."</option>";
-  	foreach ($below as $key => $m)
-	{
-		if (is_array($m))
-		{
-			foreach ($m as $key2 => $m2)
-			{
+	foreach ($below as $key => $m) {
+		if (is_array($m)) {
+			foreach ($m as $key2 => $m2) {
 				$OUT .= "      <option value=\"".$m2."\">".$titles[$key][$key2];
-				foreach ($menus as $k => $v)
-				{
-					if (($v == $key) && (!is_array($v)))
-					{
-						$OUT .= " (".$titles[$k].")";
+				foreach ($menus as $k => $v) {
+					if (($v == $key) && (!is_array($v))) {
+						$OUT .= " (" . $titles[$k] . ')';
 					}
 				}
 				$OUT .= "</option>\n";
diff --git a/inc/modules/admin/what-list_autopurge.php b/inc/modules/admin/what-list_autopurge.php
index dd93f3ba03..be29dfad9f 100644
--- a/inc/modules/admin/what-list_autopurge.php
+++ b/inc/modules/admin/what-list_autopurge.php
@@ -83,9 +83,9 @@ if (SQL_NUMROWS($result) > 0) {
 			'sname'    => $content['surname'],
 			'fname'    => $content['family'],
 			'email'    => "<a href=\"".generateMemberEmailLink($content['email'], "user_data")."\">".$content['email']."</a>",
-			'joined'   => generateDateTime($content['joined'], "2"),
-			'last'     => generateDateTime($content['last_online'], "2"),
-			'notified' => generateDateTime($content['ap_notified'], "2"),
+			'joined'   => generateDateTime($content['joined'], '2'),
+			'last'     => generateDateTime($content['last_online'], '2'),
+			'notified' => generateDateTime($content['ap_notified'], '2'),
 		);
 
 		// Load row template
diff --git a/inc/modules/admin/what-list_beg.php b/inc/modules/admin/what-list_beg.php
index 3bb5aba71f..ed8b864cd4 100644
--- a/inc/modules/admin/what-list_beg.php
+++ b/inc/modules/admin/what-list_beg.php
@@ -91,7 +91,7 @@ ORDER BY beg_points DESC, last_online DESC, userid",
 				'sname'  => $content['surname'],
 				'fname'  => $content['family'],
 				'turbo'  => translateComma($content['beg_points']),
-				'last'   => generateDateTime($content['last_online'], "2"),
+				'last'   => generateDateTime($content['last_online'], '2'),
 				'sw'     => $SW,
 				'win1'   => $WIN1,
 				'win2'   => $WIN2,
@@ -116,7 +116,7 @@ ORDER BY beg_points DESC, last_online DESC, userid",
 
 		// Prepare constant for timemark
 		if (EXT_IS_ACTIVE('autopurge')) {
-			define('__AUTOPURGE_TIMEOUT', generateDateTime(time() - getConfig('ap_inactive_since'), "2"));
+			define('__AUTOPURGE_TIMEOUT', generateDateTime(time() - getConfig('ap_inactive_since'), '2'));
 		} else {
 			define('__AUTOPURGE_TIMEOUT', sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'autopurge'));
 		}
diff --git a/inc/modules/admin/what-list_bonus.php b/inc/modules/admin/what-list_bonus.php
index 1a225c96f3..ef776061a6 100644
--- a/inc/modules/admin/what-list_bonus.php
+++ b/inc/modules/admin/what-list_bonus.php
@@ -57,16 +57,16 @@ if (getConfig('bonus_active') == 'Y') {
 
 	if (GET_EXT_VERSION('bonus') >= '0.6.9') {
 		// Add more bonus points here
-		$USE = "(0";
-		if (getConfig('bonus_click_yn') == 'Y') $USE .= " + turbo_bonus";
-		if (getConfig('bonus_login_yn') == 'Y') $USE .= " + login_bonus";
-		if (getConfig('bonus_order_yn') == 'Y') $USE .= " + bonus_order";
-		if (getConfig('bonus_stats_yn') == 'Y') $USE .= " + bonus_stats";
-		if (getConfig('bonus_ref_yn')   == 'Y') $USE .= " + bonus_ref";
-		$USE .= ")";
+		$USE = '(0';
+		if (getConfig('bonus_click_yn') == 'Y') $USE .= " + `turbo_bonus`";
+		if (getConfig('bonus_login_yn') == 'Y') $USE .= " + `login_bonus`";
+		if (getConfig('bonus_order_yn') == 'Y') $USE .= " + `bonus_order`";
+		if (getConfig('bonus_stats_yn') == 'Y') $USE .= " + `bonus_stats`";
+		if (getConfig('bonus_ref_yn')   == 'Y') $USE .= " + `bonus_ref`";
+		$USE .= ')';
 	} else {
 		// Old version ???
-		$USE = "turbo_bonus";
+		$USE = 'turbo_bonus';
 	}
 
 	// Autopurge installed?
@@ -104,7 +104,7 @@ ORDER BY points DESC, last_online DESC, userid",
 			$content['email']  = generateMemberEmailLink($content['email'], "user_data");
 			$content['gender'] = translateGender($content['gender']);
 			$content['points'] = translateComma($content['points']);
-			$content['last']   = generateDateTime($content['last'], "2");
+			$content['last']   = generateDateTime($content['last'], '2');
 			$content['sw']     = $SW;
 			$content['win1']   = $WIN1;
 			$content['win2']   = $WIN2;
@@ -128,7 +128,7 @@ ORDER BY points DESC, last_online DESC, userid",
 
 		// Prepare constant for timemark
 		if (EXT_IS_ACTIVE('autopurge')) {
-			define('__AUTOPURGE_TIMEOUT', generateDateTime(time() - getConfig('ap_inactive_since'), "2"));
+			define('__AUTOPURGE_TIMEOUT', generateDateTime(time() - getConfig('ap_inactive_since'), '2'));
 		} else {
 			define('__AUTOPURGE_TIMEOUT', sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'autopurge'));
 		}
diff --git a/inc/modules/admin/what-list_holiday.php b/inc/modules/admin/what-list_holiday.php
index 9a0a4a1f09..0dc684b149 100644
--- a/inc/modules/admin/what-list_holiday.php
+++ b/inc/modules/admin/what-list_holiday.php
@@ -64,11 +64,11 @@ if (SQL_NUMROWS($result) > 0) {
 			'sw'       => $SW,
 			'id'       => $content['id'],
 			'uid'      => generateUserProfileLink($content['userid']),
-			'start'    => generateDateTime($content['holiday_start'], "3"),
-			'end'      => generateDateTime($content['holiday_end'], "3"),
+			'start'    => generateDateTime($content['holiday_start'], '3'),
+			'end'      => generateDateTime($content['holiday_end'], '3'),
 			'comments' => wordwrap($content['comments'], 15),
 			'status'   => translateUserStatus($content['status']),
-			'last'     => generateDateTime($content['last_online'], "3"),
+			'last'     => generateDateTime($content['last_online'], '3'),
 		);
 
 		// Load row template and switch color
diff --git a/inc/modules/admin/what-list_notifications.php b/inc/modules/admin/what-list_notifications.php
index bc34e3156c..ee0ec97d5e 100644
--- a/inc/modules/admin/what-list_notifications.php
+++ b/inc/modules/admin/what-list_notifications.php
@@ -50,7 +50,7 @@ $WHO = _ALL;
 $SQL2 = '';
 
 // Set offset an current page to default values
-if (!REQUEST_ISSET_GET('page'))   REQUEST_SET_GET('page'  , "1");
+if (!REQUEST_ISSET_GET('page'))   REQUEST_SET_GET('page'  , '1');
 if (!REQUEST_ISSET_GET('offset')) REQUEST_SET_GET('offset', getConfig('mails_page'));
 
 if ((EXT_IS_ACTIVE('bonus')) && ($WHO == getMessage('_ALL'))) {
@@ -109,7 +109,7 @@ if ((EXT_IS_ACTIVE('bonus')) && (SQL_NUMROWS($result_max) > 0) && (!empty($SQL2)
 
 		// Add navigation (without change box but with colspan=3)
 		$content['nav'] = '';
-		if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, "3", true);
+		if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, '3', true);
 
 		// Prepare content
 		$content['rows'] = $OUT;
diff --git a/inc/modules/admin/what-list_payouts.php b/inc/modules/admin/what-list_payouts.php
index 1215c5fa6d..5a63f110c4 100644
--- a/inc/modules/admin/what-list_payouts.php
+++ b/inc/modules/admin/what-list_payouts.php
@@ -258,7 +258,7 @@ ORDER BY p.payout_timestamp DESC", __FILE__, __LINE__);
 				'ptype'   => translateComma($content['payout_total'])." ".COMPILE_CODE($content['type']),
 				'account' => $content['target_account'],
 				'bank'    => $content['target_bank'],
-				'tstamp'  => generateDateTime($content['payout_timestamp'], "2"),
+				'tstamp'  => generateDateTime($content['payout_timestamp'], '2'),
 				'status'  => $content['status'],
 			);
 
diff --git a/inc/modules/admin/what-list_primera.php b/inc/modules/admin/what-list_primera.php
index cbb86b063c..f2bddbfa2f 100644
--- a/inc/modules/admin/what-list_primera.php
+++ b/inc/modules/admin/what-list_primera.php
@@ -58,7 +58,7 @@ if (SQL_NUMROWS($result) > 0) {
 		$content['sw']					= $SW;
 		$content['link']				= generateUserProfileLink($content['userid']);
 		$content['primera_amount']		= translateComma($content['primera_amount']);
-		$content['primera_timestamp']	= generateDateTime($content['primera_timestamp'], "2");
+		$content['primera_timestamp']	= generateDateTime($content['primera_timestamp'], '2');
 		$content['raw_type']			= strtolower($content['primera_type']);
 		$content['primera_type']		= PRIMERA_TRANSFER_STATUS($content['primera_type']);
 
diff --git a/inc/modules/admin/what-list_rallyes.php b/inc/modules/admin/what-list_rallyes.php
index 8f9e81d5fd..5d8c97163f 100644
--- a/inc/modules/admin/what-list_rallyes.php
+++ b/inc/modules/admin/what-list_rallyes.php
@@ -57,7 +57,7 @@ if (REQUEST_ISSET_GET(('rallye'))) {
 		// Activate / deactivate
 		switch (REQUEST_GET('activate'))
 		{
-		case "1": // Activate
+		case '1': // Activate
 			ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_rallye_data` SET is_active='Y' WHERE `id`=%s AND is_active='N' LIMIT 1");
 			break;
 
@@ -69,7 +69,7 @@ if (REQUEST_ISSET_GET(('rallye'))) {
 		// Automatic notification
 		switch (REQUEST_GET('notify'))
 		{
-		case "1": // Activate
+		case '1': // Activate
 			ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_rallye_data` SET send_notify='Y' WHERE `id`=%s AND send_notify='N' LIMIT 1");
 			break;
 
@@ -81,7 +81,7 @@ if (REQUEST_ISSET_GET(('rallye'))) {
 		// Automatic adding of new members
 		switch (REQUEST_GET('auto'))
 		{
-		case "1": // Activate
+		case '1': // Activate
 			ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_rallye_data` SET auto_add_new_user='Y' WHERE `id`=%s AND auto_add_new_user='N' LIMIT 1");
 			break;
 
diff --git a/inc/modules/admin/what-list_refs.php b/inc/modules/admin/what-list_refs.php
index 77912df496..4bfaa48adc 100644
--- a/inc/modules/admin/what-list_refs.php
+++ b/inc/modules/admin/what-list_refs.php
@@ -150,7 +150,7 @@ ORDER BY level ASC", __FILE__, __LINE__);
 									'family'     => $data['family'],
 									'email'      => "[<a href=\"".generateMemberEmailLink($data['email'], "user_data")."\">".$data['email']."</a>]",
 									'status'     => translateUserStatus($data['status']),
-									'registered' => generateDateTime($data['joined'], "3"),
+									'registered' => generateDateTime($data['joined'], '3'),
 								);
 
 								// Check if referal count is larger 0 and update link
@@ -202,7 +202,7 @@ ORDER BY level ASC", __FILE__, __LINE__);
 						'family'     => $levels['family'],
 						'email'      => "[<a href=\"".generateMemberEmailLink($levels['email'], "user_data")."\">".$levels['email']."</a>]",
 						'status'     => translateUserStatus($levels['status']),
-						'registered' => generateDateTime($levels['joined'], "3"),
+						'registered' => generateDateTime($levels['joined'], '3'),
 					);
 
 					// Check if referal count is larger 0 and update link
diff --git a/inc/modules/admin/what-list_sponsor.php b/inc/modules/admin/what-list_sponsor.php
index af15d3b2db..efb727b5e6 100644
--- a/inc/modules/admin/what-list_sponsor.php
+++ b/inc/modules/admin/what-list_sponsor.php
@@ -94,9 +94,9 @@ WHERE `id`='%s' LIMIT 1",
 		define('__SPONSOR_EMAIL_VALUE', $DATA['email']);
 		define('__SPONSOR_URL'        , DEREFERER($DATA['url']));
 		//  Timestamps
-		define('__SPONSOR_CREATED'    , generateDateTime($DATA['sponsor_created'], "2"));
-		define('__SPONSOR_LAST_ONLINE', generateDateTime($DATA['last_online'], "2"));
-		define('__SPONSOR_LAST_CHANGE', generateDateTime($DATA['last_change'], "2"));
+		define('__SPONSOR_CREATED'    , generateDateTime($DATA['sponsor_created'], '2'));
+		define('__SPONSOR_LAST_ONLINE', generateDateTime($DATA['last_online'], '2'));
+		define('__SPONSOR_LAST_CHANGE', generateDateTime($DATA['last_change'], '2'));
 		//  Sponsor points
 		define('__SPONSOR_AMOUNT'     , translateComma($DATA['points_amount']));
 		define('__SPONSOR_USED'       , translateComma($DATA['points_used']));
@@ -161,8 +161,8 @@ FROM `{!_MYSQL_PREFIX!}_sponsor_data` ORDER BY `id`", __FILE__, __LINE__);
 				'fname'   => $content['family'],
 				'email'   => "mailto:".$content['email'],
 				'status'  => sponsorTranslateUserStatus($content['status']),
-				'created' => generateDateTime($content['sponsor_created'], "2"),
-				'last'    => generateDateTime($content['last_online'], "2"),
+				'created' => generateDateTime($content['sponsor_created'], '2'),
+				'last'    => generateDateTime($content['last_online'], '2'),
 				'points'  => translateComma($content['points_amount'] - $content['points_used']),
 				'ip'      => $content['remote_addr'],
 			);
diff --git a/inc/modules/admin/what-list_task.php b/inc/modules/admin/what-list_task.php
index 3808ecf675..c4a7f8d217 100644
--- a/inc/modules/admin/what-list_task.php
+++ b/inc/modules/admin/what-list_task.php
@@ -167,7 +167,7 @@ ORDER BY userid DESC, task_type DESC, subject, task_created DESC", __FILE__, __L
 				'admin'   => $content['assigned_admin'],
 				'uid'     => $content['userid'],
 				'type'    => $content['task_type_msg'],
-				'created' => generateDateTime($content['task_created'], "2")
+				'created' => generateDateTime($content['task_created'], '2')
 			));
 
 			// Do we have an extension task?
diff --git a/inc/modules/admin/what-list_transfer.php b/inc/modules/admin/what-list_transfer.php
index 24cff28bed..17d79344fa 100644
--- a/inc/modules/admin/what-list_transfer.php
+++ b/inc/modules/admin/what-list_transfer.php
@@ -57,7 +57,7 @@ if (SQL_NUMROWS($result) > 0)
 		$content = array(
 			'sw'        => $SW,
 			'idx'       => $content['trans_id'],
-			'stamp'     => generateDateTime($content['time_trans'], "3"),
+			'stamp'     => generateDateTime($content['time_trans'], '3'),
 			'from_link' => generateUserProfileLink($content['userid']),
 			'to_link'   => generateUserProfileLink($content['to_uid']),
 			'reason'    => wordwrap($content['reason'], 15),
diff --git a/inc/modules/admin/what-list_unconfirmed.php b/inc/modules/admin/what-list_unconfirmed.php
index da4767d126..2d9cb3b763 100644
--- a/inc/modules/admin/what-list_unconfirmed.php
+++ b/inc/modules/admin/what-list_unconfirmed.php
@@ -60,7 +60,7 @@ ON p.id=s.pool_id
 WHERE p.id='".REQUEST_GET('mid')."' LIMIT 1";
 
 	// Column, type and ID for member's mail
-	$col = "stats_id"; $type = "NORMAL"; $ID = "-1";
+	$col = "stats_id"; $type = "NORMAL"; $ID = '-1';
 
 	// Load admin_list_unconfirmed template
 	$listed = true; $DATA = REQUEST_GET('mid'); $LINK = 'mailid';
@@ -92,7 +92,7 @@ if ($listed === true) {
 		SQL_FREERESULT($result);
 
 		// Transfer data to constants for the template
-		if (($stats_id > 0) && ($ID == "-1")) $ID = $stats_id;
+		if (($stats_id > 0) && ($ID == '-1')) $ID = $stats_id;
 		if ($col == 'bonus_id') $sender = 0;
 
 		// Load unconfirmed mail links. Hmmm, this select query is pretty cool
@@ -147,7 +147,7 @@ WHERE l.%s='%s' ORDER BY l.userid LIMIT %s",
 			'text'          => COMPILE_CODE($text),
 			'url'           => FRAMETESTER($url),
 			'unconfirmed'   => $unconfirmed,
-			'stamp'         => generateDateTime($stamp, "2"),
+			'stamp'         => generateDateTime($stamp, '2'),
 			'rows'          => $OUT
 		);
 
diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php
index a13bbaf732..c21ac0a8fc 100644
--- a/inc/modules/admin/what-list_user.php
+++ b/inc/modules/admin/what-list_user.php
@@ -92,7 +92,7 @@ if (EXT_IS_ACTIVE('country')) {
 // Init unset data (bad that we change $_GET here!)
 if (!REQUEST_ISSET_GET(('letter'))) { REQUEST_SET_GET('letter', getMessage('_ALL2')); }
 if (!REQUEST_ISSET_GET(('sortby'))) { REQUEST_SET_GET('sortby', 'userid');            }
-if (!REQUEST_ISSET_GET('page'))   { REQUEST_SET_GET('page'  , "1");                 }
+if (!REQUEST_ISSET_GET('page'))   { REQUEST_SET_GET('page'  , '1');                 }
 
 // Set base URL
 $base = "[<a href=\"{!URL!}/modules.php?module=admin";
@@ -129,10 +129,10 @@ LIMIT 1",
 		// Is this above zero?
 		if ($stamp > 0) {
 			// Then use it
-			define('_BIRTHDAY', generateDateTime($stamp, "3"));
+			define('_BIRTHDAY', generateDateTime($stamp, '3'));
 		} else {
 			// Zero or below so set zero!
-			define('_BIRTHDAY', generateDateTime(0, "3"));
+			define('_BIRTHDAY', generateDateTime(0, '3'));
 		}
 
 		// Prepare data for template
@@ -151,7 +151,7 @@ LIMIT 1",
 		$DATA['last_profile_sent'] = generateDateTime($DATA['last_profile_sent'], '0');
 		$DATA['total']             = translateComma(GET_TOTAL_DATA($uid, "user_points", "points"));
 		$DATA['locked']            = translateComma(GET_TOTAL_DATA($uid, "user_points", "locked_points"));
-		$DATA['lock_timestamp']    = generateDateTime($DATA['lock_timestamp'], "2");
+		$DATA['lock_timestamp']    = generateDateTime($DATA['lock_timestamp'], '2');
 
 		// Is the lock reason not set?
 		if (!isset($DATA['lock_reason'])) $DATA['lock_reason'] = '---';
@@ -250,7 +250,7 @@ LIMIT 1",
 	// Activate the extension please!
 	$PAGES = round(SQL_NUMROWS($result_master) / getConfig('user_limit') + 0.5);
 
-	if (!REQUEST_ISSET_GET('page'))   REQUEST_SET_GET('page'  , "1");
+	if (!REQUEST_ISSET_GET('page'))   REQUEST_SET_GET('page'  , '1');
 	if (!REQUEST_ISSET_GET('offset')) REQUEST_SET_GET('offset', getConfig('user_limit'));
 
 	// Add limitation to SQL string and run him again
@@ -327,7 +327,7 @@ LIMIT 1",
 			$content['points'] = translateComma($pointsTotal);
 			$content['rate']   = translateComma($clickRate);
 			$content['locked'] = translateComma(GET_TOTAL_DATA($content['userid'], "user_points", "locked_points"));
-			$content['lock_timestamp'] = generateDateTime($content['lock_timestamp'], "2");
+			$content['lock_timestamp'] = generateDateTime($content['lock_timestamp'], '2');
 			$content['status'] = translateUserStatus($content['status']);
 
 			// Is the lock reason not set?
diff --git a/inc/modules/admin/what-list_wernis.php b/inc/modules/admin/what-list_wernis.php
index 24501b427b..cce8fb1049 100644
--- a/inc/modules/admin/what-list_wernis.php
+++ b/inc/modules/admin/what-list_wernis.php
@@ -58,7 +58,7 @@ if (SQL_NUMROWS($result) > 0) {
 		$content['sw']					= $SW;
 		$content['link']				= generateUserProfileLink($content['userid']);
 		$content['wernis_amount']		= translateComma($content['wernis_amount']);
-		$content['wernis_timestamp']	= generateDateTime($content['wernis_timestamp'], "2");
+		$content['wernis_timestamp']	= generateDateTime($content['wernis_timestamp'], '2');
 		$content['raw_type']			= strtolower($content['wernis_type']);
 		$content['wernis_type']			= WERNIS_TRANSFER_STATUS($content['wernis_type']);
 
diff --git a/inc/modules/admin/what-logs.php b/inc/modules/admin/what-logs.php
index 8d1c582348..df3a5872f0 100644
--- a/inc/modules/admin/what-logs.php
+++ b/inc/modules/admin/what-logs.php
@@ -45,7 +45,7 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
 // Add description as navigation point
 ADD_DESCR('admin', __FILE__);
 
-if (REQUEST_ISSET_GET(('access'))) {
+if (REQUEST_ISSET_GET('access')) {
 	// Secure input and construct FQFN
 	$access = SQL_ESCAPE(strip_tags(REQUEST_GET('access')));
 	$target = sprintf("%slogs/%s", constant('PATH'), $access);
@@ -62,15 +62,15 @@ if (REQUEST_ISSET_GET(('access'))) {
 		clearOutputBuffer();
 
 		// Set header
-		if (substr($access, -3, 3) == "log") {
+		if (substr($access, -3, 3) == 'log') {
 			// Output header
-			header("Content-Type: text/plain");
-		} elseif (substr($access, -3, 3) == ".gz") {
+			sendHeader('Content-Type: text/plain');
+		} elseif (substr($access, -3, 3) == '.gz') {
 			// @TODO Fix content-type here
-			header("Content-Type: text/plain");
-		} elseif (substr($access, -3, 3) == ".bz2") {
+			sendHeader('Content-Type: text/plain');
+		} elseif (substr($access, -3, 3) == '.bz2') {
 			// @TODO Fix content-type here
-			header("Content-Type: text/plain");
+			sendHeader('Content-Type: text/plain');
 		} else {
 			// Restore old content
 			OUTPUT_HTML($OUTPUT);
@@ -90,13 +90,15 @@ if (REQUEST_ISSET_GET(('access'))) {
 } else {
 	// List access logfiles
 	$dir = constant('PATH') . getConfig('logs_base') . '/';
+
+	// Is the directory there?
 	if (isDirectory($dir)) {
 		// logs directory does exist
 		OUTPUT_HTML("<ol>");
-		$handle = opendir($dir) or app_die(__FILE__, __LINE__, "Cannot open directory ".getConfig('logs_base').'!');
+		$handle = opendir($dir) or app_die(__FILE__, __LINE__, 'Cannot open directory '.getConfig('logs_base') . '!');
 		while ($file = readdir($handle)) {
 			// We currenly only like files with "access" as prefix, should be more flexible!
-			if (substr($file, 0, 6) == "access") {
+			if (substr($file, 0, 6) == 'access') {
 				// Okay, let us print it out
 				OUTPUT_HTML("<li><a href=\"{!URL!}/modules.php?module=admin&amp;what=".$GLOBALS['what']."&amp;access=".urlencode($file)."\">".$file."</a></li>");
 			}
diff --git a/inc/modules/admin/what-mem_add.php b/inc/modules/admin/what-mem_add.php
index 9a8f9cfee0..d96a8491d9 100644
--- a/inc/modules/admin/what-mem_add.php
+++ b/inc/modules/admin/what-mem_add.php
@@ -145,7 +145,7 @@ if (!IS_FORM_SENT()) {
 				$OUT .= "      <option value=\"".$m2."\">".$titles[$key][$key2];
 				foreach ($menus as $k => $v) {
 					if (($v == $key) && (!is_array($v))) {
-						$OUT .= " (".$titles[$k].")";
+						$OUT .= " (" . $titles[$k] . ')';
 					}
 				}
 				$OUT .= "</option>\n";
diff --git a/inc/modules/admin/what-refbanner.php b/inc/modules/admin/what-refbanner.php
index bab476d6c1..857b516d6e 100644
--- a/inc/modules/admin/what-refbanner.php
+++ b/inc/modules/admin/what-refbanner.php
@@ -102,7 +102,7 @@ VALUES ('%s','%s','%s')",
 	LOAD_TEMPLATE('admin_settings_saved', false, $content);
 } elseif (($SEL > 0) && (REQUEST_ISSET_POST('edit'))) {
 	// Edit banner
-	$SW = ''; $OUT = '';
+	$SW = 2; $OUT = '';
 	foreach (REQUEST_POST('sel') as $id => $sel) {
 		// Load data
 		$result = SQL_QUERY_ESC("SELECT url, alternate, visible FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `id`=%s LIMIT 1",
diff --git a/inc/modules/admin/what-send_newsletter.php b/inc/modules/admin/what-send_newsletter.php
index c93be07865..c96e883df0 100644
--- a/inc/modules/admin/what-send_newsletter.php
+++ b/inc/modules/admin/what-send_newsletter.php
@@ -84,7 +84,7 @@ ORDER BY userid ASC", __FILE__, __LINE__);
 } else {
 	// Copy data into constants for the template and load it
 	// @TODO Rewrite this constant
-	define('_DATESTAMP', generateDateTime(time(), "3"));
+	define('_DATESTAMP', generateDateTime(time(), '3'));
 	if (EXT_IS_ACTIVE('html_mail')) {
 		// Load template with HTML mode
 		LOAD_TEMPLATE("admin_newsletter");
diff --git a/inc/modules/admin/what-surfbar_stats.php b/inc/modules/admin/what-surfbar_stats.php
index 6637b61c9b..05416d05f5 100644
--- a/inc/modules/admin/what-surfbar_stats.php
+++ b/inc/modules/admin/what-surfbar_stats.php
@@ -65,7 +65,7 @@ ORDER BY `userid` ASC",
 			// "Translate" some data
 			$content['userid']       = generateUserProfileLink($content['userid']);
 			$content['total_visits'] = translateComma($content['total_visits']);
-			$content['last_online']  = generateDateTime($content['last_online'], "2");
+			$content['last_online']  = generateDateTime($content['last_online'], '2');
 			$content['sw']           = $SW;
 
 			// Load row template
diff --git a/inc/modules/admin/what-theme_check.php b/inc/modules/admin/what-theme_check.php
index 7706757737..993ecc443b 100644
--- a/inc/modules/admin/what-theme_check.php
+++ b/inc/modules/admin/what-theme_check.php
@@ -127,7 +127,7 @@ if (($response[count($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) {
 			$OUT .= "<tr>
   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".($idx + 1).".</td>
   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\"><a href=\"".$LINK."\">".$name."</a></td>
-  <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".generateDateTime($THEMES['fctime'][$idx], "2")."</td>
+  <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".generateDateTime($THEMES['fctime'][$idx], '2')."</td>
   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".translateComma(round($THEMES['fsize'][$idx] / 1.024) / 1000)." ".KBYTES."</td>
   <td align=\"center\" class=\"switch_sw".$SW." bottom2\">".$THEMES['ver'][$idx]." (".$THEMES['cver'][$idx].")</td>
 </tr>
diff --git a/inc/modules/admin/what-unlock_emails.php b/inc/modules/admin/what-unlock_emails.php
index 20687f46a6..7411003f73 100644
--- a/inc/modules/admin/what-unlock_emails.php
+++ b/inc/modules/admin/what-unlock_emails.php
@@ -212,7 +212,7 @@ LIMIT 1",
 				'cat_link'  => $content['category'],
 				'pay_title' => str_replace("\"", "&quot;", getPaymentTitlePrice($content['payment'], true)),
 				'pay_link'  => $content['payment'],
-				'ordered'   => generateDateTime($content['timestamp'], "2"),
+				'ordered'   => generateDateTime($content['timestamp'], '2'),
 				'tsend'     => $content['target_send'],
 			);
 
diff --git a/inc/modules/admin/what-unlock_sponsor.php b/inc/modules/admin/what-unlock_sponsor.php
index e6e6866993..65418b104b 100644
--- a/inc/modules/admin/what-unlock_sponsor.php
+++ b/inc/modules/admin/what-unlock_sponsor.php
@@ -93,7 +93,7 @@ ORDER BY sp.pay_name",
 						$data = array(
 							'aid'   => $content['email'],
 							'order' => ($content['pay_count'] * $content['pay_rate'])." ".$content['pay_currency'],
-							'stamp' => generateDateTime($content['pay_ordered'], "2"),
+							'stamp' => generateDateTime($content['pay_ordered'], '2'),
 							'pname' => $content['pay_name'],
 						);
 	
@@ -194,7 +194,7 @@ if (SQL_NUMROWS($result) > 0) {
 			'family'  => $content['family'],
 			'email'   => "mailto:".$content['email'],
 			'remote'  => $content['remote_addr'],
-			'created' => generateDateTime($content['sponsor_created'], "2"),
+			'created' => generateDateTime($content['sponsor_created'], '2'),
 		);
 
 		// Load row template and switch colors
diff --git a/inc/modules/admin/what-updates.php b/inc/modules/admin/what-updates.php
index 411634ab67..de2c0a2dcd 100644
--- a/inc/modules/admin/what-updates.php
+++ b/inc/modules/admin/what-updates.php
@@ -132,7 +132,7 @@ if (empty($ONLINE['version'])) {
 } elseif (($ONLINE['version'] != constant('FULL_VERSION')) || ($ONLINE['revision'] != constant('CURR_SVN_REVISION'))) {
 	// New full-version available (all previous released patches are included in this version!)
 	define('__ONLINE_VERSION', $ONLINE['version']);
-	define('__ONLINE_CHANGE' , generateDateTime($ONLINE['changed'], "2"));
+	define('__ONLINE_CHANGE' , generateDateTime($ONLINE['changed'], '2'));
 	define('__ONLINE_REVISION', $ONLINE['revision']);
 
 	// Load template
diff --git a/inc/modules/admin/what-usage.php b/inc/modules/admin/what-usage.php
index 7041ee31bf..bd1a7e0378 100644
--- a/inc/modules/admin/what-usage.php
+++ b/inc/modules/admin/what-usage.php
@@ -46,7 +46,7 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
 ADD_DESCR('admin', __FILE__);
 
 // Base directory (should be moved to database)
-$usage = getConfig('usage_base').'/';
+$usage = getConfig('usage_base') . '/';
 
 if (REQUEST_ISSET_GET(('image'))) {
 	if (REQUEST_GET('type') == 'usage') {
@@ -66,7 +66,7 @@ if (REQUEST_ISSET_GET(('image'))) {
 
 	if (isFileReadable($FQFN)) {
 		$image = imagecreatefrompng($FQFN);
-		header("Content-type: image/png");
+		sendHeader("Content-type: image/png");
 		imagepng($image);
 		imagedestroy($image);
 	}
diff --git a/inc/modules/guest/what-confirm.php b/inc/modules/guest/what-confirm.php
index aa8d40d7d7..91595cf84a 100644
--- a/inc/modules/guest/what-confirm.php
+++ b/inc/modules/guest/what-confirm.php
@@ -108,7 +108,7 @@ if (REQUEST_ISSET_GET(('hash'))) {
 			} // END - if
 
 			// Account confirmed!
-			if (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
+			if (EXT_IS_ACTIVE('lead')) {
 				// Set special lead cookie
 				setSession('lead_uid', bigintval($uid));
 
@@ -119,7 +119,7 @@ if (REQUEST_ISSET_GET(('hash'))) {
 				define('__UID', bigintval($uid));
 				LOAD_TEMPLATE("guest_confirm_table");
 			}
-		} elseif (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
+		} elseif (EXT_IS_ACTIVE('lead')) {
 			// Set special lead cookie
 			setSession('lead_uid', bigintval($uid));
 
diff --git a/inc/modules/guest/what-login.php b/inc/modules/guest/what-login.php
index 61303934d4..c0f493ff82 100644
--- a/inc/modules/guest/what-login.php
+++ b/inc/modules/guest/what-login.php
@@ -88,7 +88,7 @@ if (!REQUEST_ISSET_GET(('login')))     REQUEST_SET_GET('login'    , '');
 if (IS_MEMBER()) {
 	// Login immidiately...
 	$URL = 'modules.php?module=login';
-} elseif ((IS_FORM_SENT()) && (''.$uid.'' != ''.REQUEST_POST('id').'')) {
+} elseif ((IS_FORM_SENT()) && (''.$uid.'' != ''.REQUEST_POST('id') . '')) {
 	// Invalid input (no nickname extension installed but nickname entered)
 	$errorCode = getCode('EXTENSION_PROBLEM');
 } elseif (IS_FORM_SENT()) {
diff --git a/inc/modules/guest/what-rallyes.php b/inc/modules/guest/what-rallyes.php
index be0254f732..dd494cf90f 100644
--- a/inc/modules/guest/what-rallyes.php
+++ b/inc/modules/guest/what-rallyes.php
@@ -91,8 +91,8 @@ if (SQL_NUMROWS($result) == 1) {
 	}
 
 	// Set start and end time
-	define('__RALLYE_START', generateDateTime($start, "1"));
-	define('__RALLYE_END'  , generateDateTime($end  , "1"));
+	define('__RALLYE_START', generateDateTime($start, '1'));
+	define('__RALLYE_END'  , generateDateTime($end  , '1'));
 
 	// Determine min_users
 	define('__RALLYE_MAX_USERS', RALLYE_DETERMINE_MIN_USERS($min_users));
diff --git a/inc/modules/guest/what-register.php b/inc/modules/guest/what-register.php
index 2c4368b4a9..ea30251620 100644
--- a/inc/modules/guest/what-register.php
+++ b/inc/modules/guest/what-register.php
@@ -69,7 +69,7 @@ if (!REQUEST_ISSET_POST(('street_nr')))    REQUEST_SET_POST('street_nr'   , '');
 if (!REQUEST_ISSET_POST('zip'))          REQUEST_SET_POST('zip'         , '');
 if (!REQUEST_ISSET_POST(('city')))         REQUEST_SET_POST('city'        , '');
 if (!REQUEST_ISSET_POST(('cntry')))        REQUEST_SET_POST('cntry'       , '');
-if (!REQUEST_ISSET_POST(('country_code'))) REQUEST_SET_POST('country_code', "1");
+if (!REQUEST_ISSET_POST(('country_code'))) REQUEST_SET_POST('country_code', '1');
 
 // Default refid is zero
 REQUEST_SET_POST('refid', 0);
@@ -190,7 +190,7 @@ if ((IS_FORM_SENT()) && ((!$FAILED) || (IS_ADMIN()))) {
 	$lockedUsers      = GET_TOTAL_DATA('LOCKED', 'user_data', 'userid', 'status', true);
 
 	// Generate hash which will be inserted into confirmation mail
-	$hash = generateHash(sha1($confirmedUsers.constant('ENCRYPT_SEPERATOR').$unconfirmedUsers.constant('ENCRYPT_SEPERATOR').$lockedUsers.constant('ENCRYPT_SEPERATOR').REQUEST_POST('month').'-'.REQUEST_POST('day').'-'.REQUEST_POST('year').constant('ENCRYPT_SEPERATOR').getenv('SERVER_NAME').constant('ENCRYPT_SEPERATOR').detectRemoteAddr().constant('ENCRYPT_SEPERATOR').detectUserAgent().'/'.constant('SITE_KEY').'/'.constant('DATE_KEY').'/'.constant('RAND_NUMBER')));
+	$hash = generateHash(sha1($confirmedUsers.getConfig('ENCRYPT_SEPERATOR').$unconfirmedUsers.getConfig('ENCRYPT_SEPERATOR').$lockedUsers.getConfig('ENCRYPT_SEPERATOR').REQUEST_POST('month') . '-'.REQUEST_POST('day') . '-'.REQUEST_POST('year').getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_NAME').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().getConfig('ENCRYPT_SEPERATOR').detectUserAgent().'/'.getConfig('SITE_KEY') . '/'.getConfig('DATE_KEY') . '/'.constant('RAND_NUMBER')));
 
 	// Add design when extension sql_patches is v0.2.7 or greater
 	// @TODO Rewrite these all to a single filter
@@ -198,7 +198,7 @@ if ((IS_FORM_SENT()) && ((!$FAILED) || (IS_ADMIN()))) {
 	if (GET_EXT_VERSION('sql_patches') >= '0.2.7') {
 		// Okay, add design here
 		$ADD1 = ", `curr_theme`";
-		$ADD2 = ", '".getCurrentTheme()."'";
+		$ADD2 = ', ''.getCurrentTheme().''';
 	} // END - if
 
 	// Check if I shall disable sending mail to newly registered members out about active/begging rallye
diff --git a/inc/modules/guest/what-stats.php b/inc/modules/guest/what-stats.php
index 2f4212d110..2c217a3916 100644
--- a/inc/modules/guest/what-stats.php
+++ b/inc/modules/guest/what-stats.php
@@ -72,12 +72,12 @@ switch (getConfig('guest_stats'))
 {
 case 'MEMBERS': // Statistics about your members
 	// Members yesterday / today online
-	$ymem = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE last_online >= ".constant('START_YDAY')." AND `last_online` < ".constant('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
-	$tmem = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE last_online >= ".constant('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
+	$ymem = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE last_online >= ".getConfig('START_YDAY')." AND `last_online` < ".getConfig('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
+	$tmem = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE last_online >= ".getConfig('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
 
 	// Yesterday / today registered
-	$yreg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE joined >= ".constant('START_YDAY')." AND joined < ".constant('START_TDAY'), __FILE__, __LINE__));
-	$treg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE joined >= ".constant('START_TDAY'), __FILE__, __LINE__));
+	$yreg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE joined >= ".getConfig('START_YDAY')." AND joined < ".getConfig('START_TDAY'), __FILE__, __LINE__));
+	$treg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE joined >= ".getConfig('START_TDAY'), __FILE__, __LINE__));
 
 	// Only males / females
 	$male   = GET_TOTAL_DATA('M', 'user_data', 'userid', 'gender', true, " AND `status`='CONFIRMED'");
diff --git a/inc/modules/guest/what-top10.php b/inc/modules/guest/what-top10.php
index 60a4bd24d0..3acd968059 100644
--- a/inc/modules/guest/what-top10.php
+++ b/inc/modules/guest/what-top10.php
@@ -79,7 +79,7 @@ while ($content = SQL_FETCHARRAY($result)) {
 		'nick'   => $content['nickname'],
 		'logins' => $content['total_logins'],
 		'points' => translateComma(GET_TOTAL_DATA($content['userid'], "user_points", "points")),
-		'last'   => generateDateTime($content['last_online'], "3"),
+		'last'   => generateDateTime($content['last_online'], '3'),
 	);
 
 	// Load row template
@@ -149,7 +149,7 @@ while ($content = SQL_FETCHARRAY($result)) {
 		'uid'    => $content['userid'],
 		'nick'   => $content['nickname'],
 		'points' => translateComma($content['points']),
-		'last'   => generateDateTime($content['last_online'], "3")
+		'last'   => generateDateTime($content['last_online'], '3')
 	);
 
 	// Load row template
@@ -220,7 +220,7 @@ while ($content = SQL_FETCHARRAY($result)) {
 		'refs'   => $content['refs'],
 		'nick'   => $content['nickname'],
 		'points' => translateComma(GET_TOTAL_DATA($content['userid'], "user_points", "points")),
-		'last'   => generateDateTime($content['last_online'], "3")
+		'last'   => generateDateTime($content['last_online'], '3')
 	);
 
 	// Load row template
diff --git a/inc/modules/guest/what-wernis_portal.php b/inc/modules/guest/what-wernis_portal.php
index bf3491770c..96444b1780 100644
--- a/inc/modules/guest/what-wernis_portal.php
+++ b/inc/modules/guest/what-wernis_portal.php
@@ -55,7 +55,7 @@ OUTPUT_HTML("<div style=\"padding-left: 10px; padding-right: 10px\">");
 $rdf = new fase4_rdf();
 $rdf->use_dynamic_display(false);
 $rdf->set_CacheDir(constant('PATH')."inc/cache/");
-$rdf->set_salt(md5(constant('SITE_KEY')));
+$rdf->set_salt(md5(getConfig('SITE_KEY')));
 $rdf->set_max_item(10);
 $rdf->set_Options(
 	array(
diff --git a/inc/modules/login.php b/inc/modules/login.php
index eb333e70ce..1c796983da 100644
--- a/inc/modules/login.php
+++ b/inc/modules/login.php
@@ -42,7 +42,7 @@ if (!defined('__SECURITY')) {
 	require($INC);
 } elseif (!IS_MEMBER()) {
 	$URL = 'modules.php?module=index';
-	if ($check == 'mem_only') $URL .= '&amp;msg='.getCode('MODULE_MEM_ONLY').'&amp;mod='.$GLOBALS['module'];
+	if ($check == 'mem_only') $URL .= '&amp;msg='.getCode('MODULE_MEM_ONLY') . '&amp;mod='.$GLOBALS['module'];
 	redirectToUrl($URL);
 }
 
diff --git a/inc/modules/member/what-beg2.php b/inc/modules/member/what-beg2.php
index cee62bc19a..217b63ed43 100644
--- a/inc/modules/member/what-beg2.php
+++ b/inc/modules/member/what-beg2.php
@@ -76,7 +76,7 @@ if (SQL_NUMROWS($result) > 0) {
 			'cnt'    => $cnt,
 			'uid'    => bigintval($content['userid']),
 			'points' => translateComma($content['beg']),
-			'last'   => generateDateTime($content['last_online'], "2"),
+			'last'   => generateDateTime($content['last_online'], '2'),
 		);
 
 		// Load row template
diff --git a/inc/modules/member/what-bonus.php b/inc/modules/member/what-bonus.php
index d44f961776..059b028234 100644
--- a/inc/modules/member/what-bonus.php
+++ b/inc/modules/member/what-bonus.php
@@ -92,7 +92,7 @@ if (SQL_NUMROWS($result) > 0) {
 		$content['cnt']    = $cnt;
 		$content['uid']    = bigintval($content['uid']);
 		$content['points'] = translateComma($content['points']);
-		$content['last']   = generateDateTime($content['last'], "2");
+		$content['last']   = generateDateTime($content['last'], '2');
 
 		// Load row template
 		$OUT .= LOAD_TEMPLATE("member_bonus_row", true, $content);
diff --git a/inc/modules/member/what-categories.php b/inc/modules/member/what-categories.php
index 93da79f9ab..9f2f814446 100644
--- a/inc/modules/member/what-categories.php
+++ b/inc/modules/member/what-categories.php
@@ -113,21 +113,21 @@ if ($cats > 0) {
 		$OUT = ''; $SW = 2;
 		while ($content = SQL_FETCHARRAY($result)) {
 			// Default he has not joined
-			$content['jn'] = ' chkecked="checked"';
+			$content['jn'] = ' checked="checked"';
 			$content['jy'] = '';
 
 			// When we found an entry don't read it, just change the jx elements
 			if (REQUEST_ISSET_POST(('cat'))) {
 				// Form sent?
 				if (REQUEST_POST('cat', $content['id']) =='Y') {
-					$content['jy'] = ' chkecked="checked"';
+					$content['jy'] = ' checked="checked"';
 					$content['jn'] = '';
 				}
 			} else {
 				// Check if he has an entry
 				if (GET_TOTAL_DATA($UID, "user_cats", "id", 'userid', true, sprintf(" AND cat_id=%s", bigintval($content['id']))) == 1) {
 					$content['jn'] = '';
-					$content['jy'] = ' chkecked="checked"';
+					$content['jy'] = ' checked="checked"';
 				}
 			}
 
diff --git a/inc/modules/member/what-holiday.php b/inc/modules/member/what-holiday.php
index 7a1fa8642a..30863ddd6e 100644
--- a/inc/modules/member/what-holiday.php
+++ b/inc/modules/member/what-holiday.php
@@ -151,8 +151,8 @@ WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
 			SQL_FREERESULT($result);
 
 			// Prepare it for the template
-			define('__HOLIDAY_START', generateDateTime($start, "3"));
-			define('__HOLIDAY_END'  , generateDateTime($end  , "3"));
+			define('__HOLIDAY_START', generateDateTime($start, '3'));
+			define('__HOLIDAY_END'  , generateDateTime($end  , '3'));
 
 			// Deactivate it now
 			SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
diff --git a/inc/modules/member/what-html_mail.php b/inc/modules/member/what-html_mail.php
index 90a6f7aadd..7baa959b92 100644
--- a/inc/modules/member/what-html_mail.php
+++ b/inc/modules/member/what-html_mail.php
@@ -64,10 +64,10 @@ if (IS_FORM_SENT()) {
 	SQL_FREERESULT($result);
 
 	if ($mode == 'Y') {
-		define('HTML_Y', ' chkecked="checked"');
+		define('HTML_Y', ' checked="checked"');
 		define('HTML_N', '');
 	} else {
-		define('HTML_N', ' chkecked="checked"');
+		define('HTML_N', ' checked="checked"');
 		define('HTML_Y', '');
 	}
 	LOAD_TEMPLATE("member_html_mail_settings");
diff --git a/inc/modules/member/what-newsletter.php b/inc/modules/member/what-newsletter.php
index 5cac3962b5..3294b49517 100644
--- a/inc/modules/member/what-newsletter.php
+++ b/inc/modules/member/what-newsletter.php
@@ -98,7 +98,7 @@ VALUES ('0','NEW','NL_UNSUBSCRIBE','{--ADMIN_NL_SUBJECT--}','".$admin_msg."', UN
 
 	case 'N': // Does not receive the newsletter
 		define('__STATUS_VALUE', getMessage('NL_MEMBER_OFF'));
-		define('__UNTIL_VALUE' , generateDateTime($until, "2"));
+		define('__UNTIL_VALUE' , generateDateTime($until, '2'));
 		define('NL_SUBMIT'     , getMessage('NL_MEMBER_SUBMIT_ON'));
 		break;
 	}
diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php
index 0f1f3f6169..78916d846e 100644
--- a/inc/modules/member/what-order.php
+++ b/inc/modules/member/what-order.php
@@ -488,7 +488,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
 
 					// Load timestamp from last order
 					list($LORDER) = SQL_FETCHROW($result);
-					$LORDER = generateDateTime($LORDER, "1");
+					$LORDER = generateDateTime($LORDER, '1');
 
 					// Free memory
 					SQL_FREERESULT($result);
diff --git a/inc/modules/member/what-payout.php b/inc/modules/member/what-payout.php
index 4eb6016eda..3717af5a04 100644
--- a/inc/modules/member/what-payout.php
+++ b/inc/modules/member/what-payout.php
@@ -135,7 +135,7 @@ ORDER BY p.payout_timestamp DESC",
 					'acc'    => $content['target_account'],
 					'points' => translateComma($content['payout_total'])." ".COMPILE_CODE($content['type']),
 					'bank'   => $content['target_bank'],
-					'stamp'  => generateDateTime($content['payout_timestamp'], "2"),
+					'stamp'  => generateDateTime($content['payout_timestamp'], '2'),
 					'status' => $content['status']
 				);
 
diff --git a/inc/modules/member/what-primera.php b/inc/modules/member/what-primera.php
index eb8b813615..078af8325e 100644
--- a/inc/modules/member/what-primera.php
+++ b/inc/modules/member/what-primera.php
@@ -94,7 +94,7 @@ if (!REQUEST_ISSET_GET(('mode'))) {
 		while ($data = SQL_FETCHARRAY($result)) {
 			// Prepare data for output
 			$rowContent = array(
-				'stamp'		=> generateDateTime($data['primera_timestamp'], "2"),
+				'stamp'		=> generateDateTime($data['primera_timestamp'], '2'),
 				'points'		=> translateComma($data['primera_amount']),
 				'acc'		=> SQL_ESCAPE($data['primera_account']),
 				'status'		=> PRIMERA_TRANSFER_STATUS($data['primera_type']),
diff --git a/inc/modules/member/what-rallyes.php b/inc/modules/member/what-rallyes.php
index dbc3bce2b4..39f7f0ea03 100644
--- a/inc/modules/member/what-rallyes.php
+++ b/inc/modules/member/what-rallyes.php
@@ -97,8 +97,8 @@ if (SQL_NUMROWS($result) == 1) {
 	define('__RALLYE_MAX_PRICES',  RALLYE_DETERMINE_MIN_PRICES($min_prices));
 
 	// Set start and end time
-	define('__RALLYE_START', generateDateTime($start, "1"));
-	define('__RALLYE_END'  , generateDateTime($end  , "1"));
+	define('__RALLYE_START', generateDateTime($start, '1'));
+	define('__RALLYE_END'  , generateDateTime($end  , '1'));
 
 	if ($expired === true) {
 		define('__RALLYE_PRICES', RALLYE_LIST_WINNERS($id));
diff --git a/inc/modules/member/what-stats.php b/inc/modules/member/what-stats.php
index 38d199573b..c8ff9de929 100644
--- a/inc/modules/member/what-stats.php
+++ b/inc/modules/member/what-stats.php
@@ -73,7 +73,7 @@ if (SQL_NUMROWS($result) > 0) {
 			'pay'   => getPaymentTitlePrice($data['payment_id']),
 			'subj'  => COMPILE_CODE($data['subject']),
 			'url'   => DEREFERER($data['url']),
-			'stamp' => generateDateTime($data['timestamp'], "2"),
+			'stamp' => generateDateTime($data['timestamp'], '2'),
 			'recs'  => $data['target_send'],
 			'type'  => translatePoolType($data['data_type']),
 			'zip'   => $data['zip']
@@ -115,9 +115,9 @@ if (SQL_NUMROWS($result) > 0) {
 			'pay'   => getPaymentTitlePrice($data[2]),
 			'subj'  => COMPILE_CODE($data[3]),
 			'url'   => DEREFERER($data[4]),
-			'stamp' => generateDateTime($data[5], "2"),
+			'stamp' => generateDateTime($data[5], '2'),
 			'recs'  => $data[6],
-			'sent'  => generateDateTime($data[7], "2"),
+			'sent'  => generateDateTime($data[7], '2'),
 			'clix'  => $data[8],
 			'perc'  => COMPILE_CODE($data[8] / $data[6] * 100)."%",
 		);
diff --git a/inc/modules/member/what-support.php b/inc/modules/member/what-support.php
index 747ea4078d..ab4a5b950f 100644
--- a/inc/modules/member/what-support.php
+++ b/inc/modules/member/what-support.php
@@ -88,7 +88,7 @@ if ((!IS_FORM_SENT()) || (!REQUEST_ISSET_POST(('qsummary')))) {
 
 	// Drop a message in the admin's area
 	SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (userid, assigned_admin, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','SUPPORT_MEMBER','%s','%s', UNIX_TIMESTAMP())",
-		array(getUserId(), $subj_a, REQUEST_POST('qsummary').':'.array('text' => REQUEST_POST('qdetails'))), __FILE__, __LINE__);
+		array(getUserId(), $subj_a, REQUEST_POST('qsummary') . ':'.array('text' => REQUEST_POST('qdetails'))), __FILE__, __LINE__);
 
 	// Form sent
 	LOAD_TEMPLATE("member_support_contcted");
diff --git a/inc/modules/member/what-surfbar_list.php b/inc/modules/member/what-surfbar_list.php
index b2494b9b00..6de11b2e39 100644
--- a/inc/modules/member/what-surfbar_list.php
+++ b/inc/modules/member/what-surfbar_list.php
@@ -77,8 +77,8 @@ if ((IS_FORM_SENT()) && (REQUEST_ISSET_POST(('action'))) && (REQUEST_ISSET_POST(
 			// Include link to stats
 			$content['views_total'] = "[<a href=\"{!URL!}/modules.php?module=login&amp;what=surfbar_list\">".translateComma($content['views_total'])."</a>]";
 		} // END - if
-		$content['registered']  = generateDateTime($content['registered'], "2");
-		$content['last_locked'] = generateDateTime($content['last_locked'], "2");
+		$content['registered']  = generateDateTime($content['registered'], '2');
+		$content['last_locked'] = generateDateTime($content['last_locked'], '2');
 		$content['actions']     = SURFBAR_MEMBER_ACTIONS($content['id'], $content['status']);
 		$content['status']      = surfbarTranslateUserStatus($content['status']);
 		if (empty($content['lock_reason'])) {
diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php
index 923ef52a4e..aa017d8a3a 100644
--- a/inc/modules/member/what-transfer.php
+++ b/inc/modules/member/what-transfer.php
@@ -335,7 +335,7 @@ case "list_out": // List only outgoing transactions
 			$content = array(
 				'sw'     => $SW,
 				'tid'    => $id,
-				'stamp'  => generateDateTime($stamp, "3"),
+				'stamp'  => generateDateTime($stamp, '3'),
 				'uid'    => $uid,
 				'reason' => $reason,
 				'points' => translateComma($points)
@@ -425,7 +425,7 @@ array(getUserId(), getConfig('transfer_max')), __FILE__, __LINE__);
 
 			// Prepare content for template
 			$content['sw']     = $SW;
-			$content['time']   = generateDateTime($content['time_trans'], "3");
+			$content['time']   = generateDateTime($content['time_trans'], '3');
 			$content['points'] = translateComma($content['points']);
 
 			// Load row template
@@ -517,14 +517,14 @@ case "": // Overview page
 	switch ($opt_in)
 	{
 	case 'Y':
-		define('__TRANSFER_ALLOW_Y', ' chkecked="checked"');
+		define('__TRANSFER_ALLOW_Y', ' checked="checked"');
 		define('__TRANSFER_ALLOW_N', '');
 		define('__TRANSFER_NEW_LINK', "<a href=\"{!URL!}/modules.php?module=login&amp;what=transfer&amp;mode=new\">{--TRANSFER_NOW_LINK--}</a>");
 		break;
 
 	case 'N':
 		define('__TRANSFER_ALLOW_Y', '');
-		define('__TRANSFER_ALLOW_N', ' chkecked="checked"');
+		define('__TRANSFER_ALLOW_N', ' checked="checked"');
 		define('__TRANSFER_NEW_LINK', getMessage('TRANSFER_PLEASE_ALLOW_OPT_IN'));
 		break;
 	}
@@ -542,7 +542,7 @@ LIMIT 1", array(getConfig('transfer_timeout'), getUserId()), __FILE__, __LINE__)
 		// Load newest transaction
 		list($newest) = SQL_FETCHROW($result);
 		SQL_FREERESULT($result);
-		define('__TRANSFER_SETTINGS_CONTENT', sprintf(getMessage('TRANSFER_LATEST_IS'), generateDateTime($newest, "3")));
+		define('__TRANSFER_SETTINGS_CONTENT', sprintf(getMessage('TRANSFER_LATEST_IS'), generateDateTime($newest, '3')));
 	}
 
 	// Load template
diff --git a/inc/modules/member/what-wernis.php b/inc/modules/member/what-wernis.php
index c7fa6d1532..9e5768ee17 100644
--- a/inc/modules/member/what-wernis.php
+++ b/inc/modules/member/what-wernis.php
@@ -94,7 +94,7 @@ if ((!REQUEST_ISSET_GET(('mode'))) || (REQUEST_GET('mode') == "choose")) {
 		while ($data = SQL_FETCHARRAY($result)) {
 			// Prepare data for output
 			$rowContent = array(
-				'stamp'    => generateDateTime($data['wernis_timestamp'], "2"),
+				'stamp'    => generateDateTime($data['wernis_timestamp'], '2'),
 				'points'   => translateComma($data['wernis_amount']),
 				'acc'      => bigintval($data['wernis_account']),
 				'status'   => WERNIS_TRANSFER_STATUS($data['wernis_type']),
diff --git a/inc/modules/sponsor/settings.php b/inc/modules/sponsor/settings.php
index bf986e0d7b..96ce1e5b2e 100644
--- a/inc/modules/sponsor/settings.php
+++ b/inc/modules/sponsor/settings.php
@@ -95,13 +95,13 @@ if (SQL_NUMROWS($result) == 1) {
 			// Make yes/no selection
 			switch ($content['receive_warnings']) {
 				case 'Y':
-					define('__YES', ' chkecked="checked"');
+					define('__YES', ' checked="checked"');
 					define('__NO', '');
 					break;
 
 				case 'N':
 					define('__YES', '');
-					define('__NO', ' chkecked="checked"');
+					define('__NO', ' checked="checked"');
 					break;
 			}
 
diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php
index 6e257ae804..8693a51c6b 100644
--- a/inc/mysql-connect.php
+++ b/inc/mysql-connect.php
@@ -45,6 +45,9 @@ if (!defined('__SECURITY')) {
 // Non-database functions
 require('inc/functions.php');
 
+// Wrapper functions
+require('inc/wrapper-functions.php');
+
 // Load more function libraries or includes
 foreach (array('request-functions', 'session-functions', 'config-functions', 'code-functions', 'inc-functions', 'filters', 'mysql-manager', 'extensions', 'db/lib', 'handler', 'hooks') as $lib) {
 	// Load special functions
@@ -54,28 +57,28 @@ foreach (array('request-functions', 'session-functions', 'config-functions', 'co
 // Set error handler
 set_error_handler('__errorHandler');
 
+// Load configuration file(s) here
+loadIncludeOnce('inc/load_config.php');
+
+// Set important header_sent
+$GLOBALS['header_sent'] = 0;
+
 // Check if the user setups his MySQL stuff...
-if ((empty($MySQL['login'])) && (!isInstalling()) && (!REQUEST_ISSET_GET('installing')) && (isInstalled())) {
+if ((empty($GLOBALS['mysql']['login'])) && (!isInstalling()) && (!REQUEST_ISSET_GET('installing')) && (isInstalled())) {
 	// No login entered and outside installation mode
-	OUTPUT_HTML("<strong>{--LANG_WARNING--}:</strong> ");
+	OUTPUT_HTML('<strong>{--LANG_WARNING--}:</strong> ');
 	if (isInstalled()) {
 		// You have changed my configuration file!
-		app_die(__FILE__, __LINE__, "{--DIE_CONFIG_CHANGED_YOU--}");
+		app_die(__FILE__, __LINE__, '{--DIE_CONFIG_CHANGED_YOU--}');
 	} else {
 		// Please run the installation script (maybe again)
-		app_die(__FILE__, __LINE__, "{--DIE_RUN_INSTALL_MYSQL--}");
+		app_die(__FILE__, __LINE__, '{--DIE_RUN_INSTALL_MYSQL--}');
 	}
-} elseif ((!isInstalling()) && (empty($MySQL['password'])) && (isBooleanConstantAndTrue('warn_no_pass'))) {
+} elseif ((!isInstalling()) && (empty($GLOBALS['mysql']['password'])) && (getConfig('WARN_NO_PASS') == 'Y')) {
 	// No database password entered!!!
-	OUTPUT_HTML("<div>{--LANG_WARNING--}:</div> {--WARN_NULL_PASSWORD--}");
+	OUTPUT_HTML('<div>{--LANG_WARNING--}:</div> {--WARN_NULL_PASSWORD--}');
 }
 
-// Set dummy config array
-initConfig();
-
-// Set important header_sent
-$GLOBALS['header_sent'] = 0;
-
 // Init fatal messages
 initFatalMessages();
 
@@ -88,19 +91,19 @@ if ((!isInstalling()) && (isInstalled())) {
 	// CSS array
 	EXT_INIT_CSS_FILES();
 
-	if ((!empty($MySQL['host'])) && (!empty($MySQL['login'])) && (!empty($MySQL['password'])) && (!empty($MySQL['dbase']))) {
+	if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['password'])) && (!empty($GLOBALS['mysql']['dbase']))) {
 		// Connect to DB
-		SQL_CONNECT($MySQL['host'], $MySQL['login'], $MySQL['password'], __FILE__, __LINE__);
+		SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__);
 
 		// Is the link valid?
 		if (SQL_IS_LINK_UP()) {
 			// Is it a valid resource?
-			if (SQL_SELECT_DB($MySQL['dbase'], __FILE__, __LINE__) === true) {
+			if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === true) {
 				// This is required for extension 'optimize' to work
-				define('__DB_NAME', $MySQL['dbase']);
+				define('__DB_NAME', $GLOBALS['mysql']['dbase']);
 
 				// Remove MySQL array from namespace
-				unset($MySQL);
+				unset($GLOBALS['mysql']);
 
 				// Load configuration stuff
 				loadConfiguration();
@@ -115,7 +118,7 @@ if ((!isInstalling()) && (isInstalled())) {
 				loadIncludeOnce('inc/versions.php');
 
 				// Loading patching system is required here...
-				loadIncludeOnce('inc/patch-system.php'); // Initialize patch system
+				loadIncludeOnce('inc/patch-system.php');
 
 				// Run daily reset
 				loadIncludeOnce('inc/check-reset.php');
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index be375eea69..a8532d6997 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -92,7 +92,7 @@ function getModuleDescription ($mode, $wht, $column = 'what') {
 	} // END - if
 
 	// Default is not found
-	$ret = "??? (".$wht.")";
+	$ret = "??? (".$wht.')';
 
 	// Look for title
 	$result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE %s='%s' LIMIT 1",
@@ -237,7 +237,7 @@ function checkModulePermissions ($mod) {
 			$ret = checkModulePermissions($mod_chk);
 		} else {
 			// Module not found we don't add it to the database
-			$ret = "404";
+			$ret = '404';
 		}
 	} elseif (!$found) {
 		// Problem with module detected
@@ -328,7 +328,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
 	$prefix .= "&nbsp;-&gt;&nbsp;";
 
 	// We need to remove .php and the end
-	if (substr($search, -4, 4) == ".php") {
+	if (substr($search, -4, 4) == '.php') {
 		// Remove the .php
 		$search = substr($search, 0, -4);
 	} // END - i
@@ -441,7 +441,7 @@ function ADD_MENU ($mode, $act, $wht) {
 						}
 
 						// Navigation link
-						$OUT .= "<a name=\"menu\" class=\"menu_blur\" href=\"{!URL!}/modules.php?module=".$GLOBALS['module']."&amp;what=".$content['sub_what'].addUrlData("")."\" target=\"_self\">";
+						$OUT .= "<a name=\"menu\" class=\"menu_blur\" href=\"{!URL!}/modules.php?module=".$GLOBALS['module']."&amp;what=".$content['sub_what']."\" target=\"_self\">";
 					} else {
 						$OUT .= "<em>";
 					}
@@ -664,7 +664,7 @@ function addMaxReceiveList ($mode, $default = '', $return = false) {
 			$OUT .= "      <option value=\"".$content['value']."\"";
 			if (REQUEST_POST('max_mails') == $content['value']) $OUT .= ' selected="selected"';
 			$OUT .= ">".$content['value']." {--PER_DAY--}";
-			if (!empty($content['comment'])) $OUT .= " (".$content['comment'].")";
+			if (!empty($content['comment'])) $OUT .= " (".$content['comment'].')';
 			$OUT .= "</option>\n";
 		}
 		define('__MAX_RECEIVE_OPTIONS', $OUT);
@@ -1606,7 +1606,6 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
 	if (SQL_NUMROWS($result) == 1) {
 		// Save his points to add them to the jackpot
 		list($points) = SQL_FETCHROW($result);
-		SQL_FREERESULT($result);
 
 		// Delete points entries as well
 		SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
@@ -1619,7 +1618,10 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
 
 		// Now, when we have all his points adds them do the jackpot!
 		ADD_JACKPOT($points);
-	}
+	} // END - if
+
+	// Free the result
+	SQL_FREERESULT($result);
 
 	// Delete category selections as well...
 	SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE userid=%s",
@@ -1629,10 +1631,10 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
 	if (EXT_IS_ACTIVE('rallye')) {
 		SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_users` WHERE userid=%s",
 			array(bigintval($uid)), __FUNCTION__, __LINE__);
-	}
+	} // END - if
 
 	// Now a mail to the user and that's all...
-	$msg = LOAD_EMAIL_TEMPLATE("del-user", array('text' => $reason), $uid);
+	$msg = LOAD_EMAIL_TEMPLATE('del-user', array('text' => $reason), $uid);
 	sendEmail($uid, getMessage('ADMIN_DEL_ACCOUNT'), $msg);
 
 	// Ok, delete the account!
@@ -1644,7 +1646,7 @@ function generateMetaDescriptionCode ($mod, $wht) {
 	// Exclude admin and member's area
 	if (($mod != 'admin') && ($mod != 'login')) {
 		// Construct dynamic description
-		$DESCR = '{!MAIN_TITLE!} '.trim(getConfig('title_middle')).' '.ADD_DESCR('guest', 'what-'.$wht, true);
+		$DESCR = '{!MAIN_TITLE!} '.trim(getConfig('title_middle')) . ' ' . ADD_DESCR('guest', 'what-'.$wht, true);
 
 		// Output it directly
 		OUTPUT_HTML('<meta name="description" content="' . $DESCR . '" />');
@@ -1655,7 +1657,7 @@ function generateMetaDescriptionCode ($mod, $wht) {
 }
 
 // Adds points to the jackpot
-function ADD_JACKPOT($points) {
+function ADD_JACKPOT ($points) {
 	$result = SQL_QUERY("SELECT points FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE ok='ok' LIMIT 1", __FUNCTION__, __LINE__);
 	if (SQL_NUMROWS($result) == 0) {
 		// Create line
@@ -1671,7 +1673,7 @@ function ADD_JACKPOT($points) {
 }
 
 // Subtracts points from the jackpot
-function SUB_JACKPOT($points) {
+function SUB_JACKPOT ($points) {
 	// First failed
 	$ret = '-1';
 
@@ -2176,7 +2178,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) {
 
 		// Now update all user accounts
 		SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s",
-			array(implode(",", $UIDs), count($UIDs)), __FUNCTION__, __LINE__);
+			array(implode(',', $UIDs), count($UIDs)), __FUNCTION__, __LINE__);
 	} // END - if
 
 	// Free result
@@ -2219,6 +2221,11 @@ function SET_SQL_KEY ($key, $value) {
 	$GLOBALS['sqls'][$key] = (string) $value;
 }
 
+// Merge SQLs together
+function MERGE_SQLS ($SQLs) {
+	SET_SQLS(merge_array(GET_SQLS(), $SQLs));
+}
+
 // Counter for SQLs array
 function COUNT_SQLS () {
 	// Default is false
diff --git a/inc/pool/pool-user.php b/inc/pool/pool-user.php
index 1be90b21c5..3613f38d1f 100644
--- a/inc/pool/pool-user.php
+++ b/inc/pool/pool-user.php
@@ -129,7 +129,7 @@ if (SQL_NUMROWS($result_main) > 0) {
 						list($stats_id) = SQL_FETCHROW($result_stats);
 
 						// Mark this user as "spammed" ;-) And place a line for him...
-						//* DEBUG: */ echo "?L:".__LINE__.'/'.$dummy.'/'.$key.'/'.$uid."(".$DATA[1].")/".$DATA[0].'/'.$stats_id."?<br />";
+						//* DEBUG: */ echo "?L:".__LINE__.'/'.$dummy.'/'.$key.'/'.$uid.'('.$DATA[1].")/".$DATA[0].'/'.$stats_id."?<br />";
 						switch (removeReceiver($dummy, $key, bigintval($uid), bigintval($DATA[0]), bigintval($stats_id)))
 						{
 						case 'done':
@@ -317,13 +317,13 @@ if (SQL_NUMROWS($result_main) > 0) {
 					$mailText = LOAD_EMAIL_TEMPLATE("back-member", $content, bigintval($uid));
 
 					// Send mail out to member
-					sendEmail($email, getMessage('MEMBER_BACK_JACKPOT')." (".$uid.")", $mailText);
+					sendEmail($email, getMessage('MEMBER_BACK_JACKPOT')." (".$uid.')', $mailText);
 				} else {
 					// Add to jackpot
 					ADD_JACKPOT($PB);
 
 					// Send mail out to admin
-					sendAdminNotification(getMessage('ADMIN_BACK_JACKPOT')." (".$uid.")", "back-admin", $content, 'admin');
+					sendAdminNotification(getMessage('ADMIN_BACK_JACKPOT')." (".$uid.')', "back-admin", $content, 'admin');
 				}
 			} // END - if
 		} // END - foreach
diff --git a/inc/reset/reset_holiday.php b/inc/reset/reset_holiday.php
index a98000981b..d8e3660b10 100644
--- a/inc/reset/reset_holiday.php
+++ b/inc/reset/reset_holiday.php
@@ -74,9 +74,9 @@ LIMIT 1",
 
 			// Prepare all data for the template
 			$content = array(
-				'activated' => generateDateTime($content['holiday_activated'], "1"),
-				'start'     => generateDateTime($content['holiday_start']    , "1"),
-				'end'       => generateDateTime($content['holiday_end']      , "1")
+				'activated' => generateDateTime($content['holiday_activated'], '1'),
+				'start'     => generateDateTime($content['holiday_start']    , '1'),
+				'end'       => generateDateTime($content['holiday_end']      , '1')
 			);
 
 			// Send email to user
diff --git a/inc/session.php b/inc/session.php
index d48a534419..3944e24ebb 100644
--- a/inc/session.php
+++ b/inc/session.php
@@ -75,17 +75,6 @@ if (isSessionVariableSet('userid')) {
 	} // END - if
 } // END - if
 
-// Test session if index.php or modules.php is loaded
-if ((basename($_SERVER['PHP_SELF']) == 'index.php') || (basename($_SERVER['PHP_SELF']) == 'modules.php') || (isInstalling())) {
-	if (count($_SESSION) > 0) {
-		// Session variables accepted!
-		define('__COOKIES', true);
-	} else {
-		// Cookies rejected!
-		define('__COOKIES', false);
-	}
-} // END - if
-
 //* DEBUG: */ print('<pre>'.print_r($_SESSION, true).'</pre>');
 
 //
diff --git a/inc/stats_bonus.php b/inc/stats_bonus.php
index 1f67d01d93..b13a2ff7bd 100644
--- a/inc/stats_bonus.php
+++ b/inc/stats_bonus.php
@@ -59,7 +59,7 @@ if (SQL_NUMROWS($result_bonus) > 0) {
 			array(getConfig('bonus_stats'), bigintval($content['userid'])), __FILE__, __LINE__);
 
 		// Translate some data
-		$content['timestamp'] generateDateTime($content['timestamp_ordered'], "2");
+		$content['timestamp'] generateDateTime($content['timestamp_ordered'], '2');
 
 		// Load email template and send email
 		$msg = LOAD_EMAIL_TEMPLATE("member_stats_bonus", $content, bigintval($content['userid']));
diff --git a/inc/stylesheet.php b/inc/stylesheet.php
index a7312b5589..3748c130d1 100644
--- a/inc/stylesheet.php
+++ b/inc/stylesheet.php
@@ -44,17 +44,17 @@ if (!defined('__SECURITY')) {
 
 // Default styles
 $STYLES = array(
-		"general.css",
+		'general.css',
 );
 
 // Add stylesheet for installation
-if ((isInstalling()) || (!isInstalled())) $STYLES[] = "install.css";
+if ((isInstalling()) || (!isInstalled())) $STYLES[] = 'install.css';
 
 // When no CSS output-mode is set, set it to file-output
-if (!isConfigEntrySet('css_php')) setConfigEntry('css_php', "FILE");
+if (!isConfigEntrySet('css_php')) setConfigEntry('css_php', 'FILE');
 
 // Output CSS files or content or link to css.php ?
-if (($GLOBALS['output_mode'] == "1") || (getConfig('css_php') == "DIRECT")) {
+if (($GLOBALS['output_mode'] == '1') || (getConfig('css_php') == 'DIRECT')) {
 	// Load CSS files
 	$STYLES = merge_array($STYLES, EXT_GET_CSS_FILES());
 
@@ -67,13 +67,17 @@ if (($GLOBALS['output_mode'] == "1") || (getConfig('css_php') == "DIRECT")) {
 		// Do include only existing files and whose are not empty
 		if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) {
 			switch (getConfig('css_php')) {
-				case 'DIRECT':
+				case 'DIRECT': // Just link them (unsupported)
 					OUTPUT_HTML('<link rel="stylesheet" type="text/css" href="{!URL!}/theme/' . getCurrentTheme() . '/' . $value . '" />');
 					break;
 
-				case 'FILE':
+				case 'FILE': // Output contents
 					OUTPUT_HTML(readFromFile($FQFN));
 					break;
+
+				default: // Invalid mode!
+					debug_report_bug(sprintf("Invalid css_php value %s detected.", getConfig('css_php')));
+					break;
 			} // END - switch
 		} // END - if
 	} // END - foreach
diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php
new file mode 100644
index 0000000000..6803dfc378
--- /dev/null
+++ b/inc/wrapper-functions.php
@@ -0,0 +1,376 @@
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 04/04/2009 *
+ * ===============                              Last change: 04/04/2009 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : wrapper-functions.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : Wrapper functions                                *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Wrapper-Funktionen                               *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.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 2 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, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+	$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
+	require($INC);
+} // END - if
+
+// Read a given file
+function readFromFile ($FQFN, $sqlPrepare = false) {
+	// Load the file
+	if (function_exists('file_get_contents')) {
+		// Use new function
+		$content = file_get_contents($FQFN);
+	} else {
+		// Fall-back to implode-file chain
+		$content = implode('', file($FQFN));
+	}
+
+	// Prepare SQL queries?
+	if ($sqlPrepare === true) {
+		// Remove some unwanted chars
+		$content = str_replace("\r", '', $content);
+		$content = str_replace("\n\n", "\n", $content);
+	} // END - if
+
+	// Return the content
+	return $content;
+}
+
+// Writes content to a file
+function writeToFile ($FQFN, $content) {
+	// Is the file writeable?
+	if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
+		// Not writeable!
+		DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
+
+		// Failed! :(
+		return false;
+	} // END - if
+
+	// By default all is failed...
+	$return = false;
+
+	// Is the function there?
+	if (function_exists('file_put_contents')) {
+		// Write it directly
+		$return = file_put_contents($FQFN, $content);
+	} else {
+		// Write it with fopen
+		$fp = fopen($FQFN, 'w') or app_die(__FUNCTION__, __LINE__, "Cannot write file ".basename($FQFN).'!');
+		fwrite($fp, $content);
+		fclose($fp);
+
+		// Set CHMOD rights
+		$return = changeMode($FQFN, 0644);
+	}
+
+	// Return status
+	return $return;
+}
+
+// Clears the output buffer. This function does *NOT* backup sent content.
+function clearOutputBuffer () {
+	// Trigger an error on failure
+	if (!ob_end_clean()) {
+		// Failed!
+		debug_report_bug(__FUNCTION__.': Failed to clean output buffer.');
+	} // END - if
+}
+
+// Loads an include file and logs any missing files for debug purposes
+function loadInclude ($INC) {
+	// Add the path. This is why we need a trailing slash in config.php
+	$FQFN = constant('PATH') . $INC;
+
+	// Is the include file there?
+	if (!isIncludeReadable($INC)) {
+		// Not there so log it
+		debug_report_bug(sprintf("Include file %s not found.", $INC));
+		return false;
+	} // END - if
+
+	// Try to load it
+	require($FQFN);
+}
+
+// Loads an include file once
+function loadIncludeOnce ($INC) {
+	// Is it not loaded?
+	if (!isset($GLOBALS['load_once'][$INC])) {
+		// Then try to load it
+		loadInclude($INC);
+
+		// And mark it as loaded
+		$GLOBALS['load_once'][$INC] = "loaded";
+	} // END - if
+}
+
+// Checks wether an include file (non-FQFN better) is readable
+function isIncludeReadable ($INC) {
+	// Construct FQFN
+	$FQFN = constant('PATH') . $INC;
+
+	// Is it readable?
+	return isFileReadable($FQFN);
+}
+
+// Encode strings
+// @TODO Implement $compress
+function encodeString ($str, $compress = true) {
+	$str = urlencode(base64_encode(compileUriCode($str)));
+	return $str;
+}
+
+// Decode strings encoded with encodeString()
+// @TODO Implement $decompress
+function decodeString ($str, $decompress = true) {
+	$str = compileUriCode(base64_decode(urldecode(compileUriCode($str))));
+	return $str;
+}
+
+// Smartly adds slashes
+function smartAddSlashes ($unquoted) {
+	$unquoted = str_replace("\\", '', $unquoted);
+	return addslashes($unquoted);
+}
+
+// Decode entities in a nicer way
+function decodeEntities ($str) {
+	// Decode the entities to UTF-8 now
+	$decodedString = html_entity_decode($str, ENT_NOQUOTES, 'UTF-8');
+
+	// Return decoded string
+	return $decodedString;
+}
+
+// Merges an array together but only if both are arrays
+function merge_array ($array1, $array2) {
+	// Are both an array?
+	if ((is_array($array1)) && (is_array($array2))) {
+		// Merge all together
+		return array_merge($array1, $array2);
+	} elseif (is_array($array1)) {
+		// Return left array
+		DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
+		return $array1;
+	} elseif (is_array($array2)) {
+		// Return right array
+		DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
+		return $array2;
+	}
+
+	// Both are not arrays
+	debug_report_bug(__FUNCTION__.": No arrays provided!");
+}
+
+// Check if given FQFN is a readable file
+function isFileReadable ($FQFN) {
+	// Check all...
+	return ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN)));
+}
+
+// Checks wether the given FQFN is a directory and not .,.. or .svn
+function isDirectory ($FQFN) {
+	// Generate baseName
+	$baseName = basename($FQFN);
+
+	// Check it
+	$isDirectory = ((is_dir($FQFN)) && ($baseName != '.') && ($baseName != '..') && ($baseName != '.svn'));
+
+	// Return the result
+	return $isDirectory;
+}
+
+// "Getter" for remote IP number
+function detectRemoteAddr () {
+	// Get remote ip from environment
+	$remoteAddr = determineRealRemoteAddress();
+
+	// Is removeip installed?
+	if (EXT_IS_ACTIVE('removeip')) {
+		// Then anonymize it
+		$remoteAddr = GET_ANONYMOUS_REMOTE_ADDR($remoteAddr);
+	} // END - if
+
+	// Return it
+	return $remoteAddr;
+}
+
+// "Getter" for remote hostname
+function detectRemoteHostname () {
+	// Get remote ip from environment
+	$remoteHost = getenv('REMOTE_HOST');
+
+	// Is removeip installed?
+	if (EXT_IS_ACTIVE('removeip')) {
+		// Then anonymize it
+		$remoteHost = GET_ANONYMOUS_REMOTE_HOST($remoteHost);
+	} // END - if
+
+	// Return it
+	return $remoteHost;
+}
+
+// "Getter" for user agent
+function detectUserAgent () {
+	// Get remote ip from environment
+	$userAgent = getenv('HTTP_USER_AGENT');
+
+	// Is removeip installed?
+	if (EXT_IS_ACTIVE('removeip')) {
+		// Then anonymize it
+		$userAgent = GET_ANONYMOUS_USER_AGENT($userAgent);
+	} // END - if
+
+	// Return it
+	return $userAgent;
+}
+
+// "Getter" for referer
+function detectReferer () {
+	// Get remote ip from environment
+	$referer = getenv('HTTP_REFERER');
+
+	// Is removeip installed?
+	if (EXT_IS_ACTIVE('removeip')) {
+		// Then anonymize it
+		$referer = GET_ANONYMOUS_REFERER($referer);
+	} // END - if
+
+	// Return it
+	return $referer;
+}
+
+// Check wether we are installing
+function isInstalling () {
+	$installing = ((isset($GLOBALS['mxchange_installing'])) || (REQUEST_ISSET_GET('installing')));
+	//* DEBUG: */ var_dump($installing);
+	return $installing;
+}
+
+// Check wether this script is installed
+function isInstalled () {
+	return (getConfig('MXCHANGE_INSTALLED') == 'Y');
+}
+
+// Check wether an admin is registered
+function isAdminRegistered () {
+	return (getConfig('ADMIN_REGISTERED') == 'Y');
+}
+
+// Checks wether the reset mode is active
+function isResetModeEnabled () {
+	// Now simply check it
+	return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
+}
+
+// Checks wether the debug mode is enabled
+function isDebugModeEnabled () {
+	// Simply check it
+	return (getConfig('DEBUG_MODE') == 'Y');
+}
+
+// Checks wether the cache instance is valid
+function isCacheInstanceValid () {
+	return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
+}
+
+// Copies a file from source to destination and verifies if that goes fine.
+// This function should wrap the copy() command and make a nicer debug backtrace
+// even if there is no xdebug extension installed.
+function copyFileVerified ($source, $dest, $chmod = '') {
+	// Failed is the default
+	$status = false;
+
+	// Is the source file there?
+	if (!isFileReadable($source)) {
+		// Then abort here
+		debug_report_bug('Cannot read from source file ' . basename($source) . '.');
+	} // END - if
+
+	// Is the target directory there?
+	if (!isDirectory(dirname($dest))) {
+		// Then abort here
+		debug_report_bug('Cannot find directory ' . str_replace(constant('PATH'), '', dirname($dest)) . '.');
+	} // END - if
+
+	// Now try to copy it
+	if (!copy($source, $dest)) {
+		// Something went wrong
+		debug_report_bug('copy() has failed to copy the file.');
+	} // END - if
+
+	// If there are chmod rights set, apply them
+	if (!empty($chmod)) {
+		// Try to apply them
+		$status = changeMode($dest, $chmod);
+	} else {
+		// All fine
+		$status = true;
+	}
+
+	// All fine
+	return $status;
+}
+
+// Wrapper function for header()
+// Send a header but checks before if we can do so
+function sendHeader ($header) {
+	// Is the header already sent?
+	if (headers_sent()) {
+		// Then abort here
+		debug_report_bug('Headers already sent!');
+	} // END - if
+
+	// Send the header
+	header($header);
+}
+
+// Wrapper function for chmod()
+// @TODO Do some more sanity check here
+function changeMode ($FQFN, $mode) {
+	// Is the file/directory there?
+	if ((!isFile($FQFN)) && (!isDirectory($FQFN))) {
+		// Neither, so abort here
+		debug_report_bug('Cannot chmod() on ' . basename($FQFN) . '.');
+	} // END - if
+
+	// Try to set them
+	chmod($FQFN, $mode);
+}
+
+// Wrapper for $_POST['sel']
+function countPostSelection () {
+	return countSelection(REQUEST_POST('sel'));
+}
+
+// [EOF]
+?>
diff --git a/index.php b/index.php
index 16cf25a432..04c3926242 100644
--- a/index.php
+++ b/index.php
@@ -51,7 +51,7 @@ $GLOBALS['module'] = 'index';
 $GLOBALS['output_mode'] = '0';
 
 // Load config.php
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if (isInstalled()) {
@@ -74,13 +74,13 @@ if (isInstalled()) {
 		}
 
 		// Template laden
-		LOAD_TEMPLATE('index', false, addUrlData(''));
+		LOAD_TEMPLATE('index');
 
 		// Shall I insert an automated forward?
 		if (getConfig('index_delay') > 0) {
 			// This will be a JavaScript-redirect!
 			define('__DELAY_VALUE', (getConfig('index_delay') * 1000 + 500));
-			define('__MOD_VALUE'  , addUrlData('index'));
+			define('__MOD_VALUE'  , 'index');
 			LOAD_TEMPLATE('index_forward');
 		} // END - if
 	} else {
diff --git a/install.php b/install.php
index 788f7bfa02..d632be4e43 100644
--- a/install.php
+++ b/install.php
@@ -63,7 +63,7 @@ $GLOBALS['output_mode'] = 0;
 $GLOBALS['module'] = 'install';
 
 // Load config file
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Header
 loadInclude('inc/header.php');
diff --git a/js.php b/js.php
index 830bec24ea..6ec94157d8 100644
--- a/js.php
+++ b/js.php
@@ -36,9 +36,6 @@
  * MA  02110-1301  USA                                                  *
  ************************************************************************/
 
-// Deactivate caching system in fake-CSS mode
-define('_OB_CACHING', "old");
-
 // Load security stuff here
 require('inc/libs/security_functions.php');
 
@@ -57,19 +54,19 @@ $GLOBALS['output_mode'] = '1';
 $GLOBALS['module'] = 'js';
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is this script installed and a JavaScript tag is provied?
-if ((isInstalled()) && (REQUEST_ISSET_GET(('tag')))) {
+if ((isInstalled()) && (REQUEST_ISSET_GET('tag'))) {
 	// Set header
-	header('Content-type: text/javascript');
+	sendHeader('Content-type: text/javascript');
 
 	// Load header
 	loadIncludeOnce('inc/header.php');
 
 	// Prepare include file for looking
 	$INC = sprintf("inc/js/tag-%s.php",
-		REQUEST_GET(('tag'))
+		REQUEST_GET('tag')
 	);
 
 	// Is that file readable?
diff --git a/lead-confirm.php b/lead-confirm.php
index 24c3e4d2b7..3078aa5b47 100644
--- a/lead-confirm.php
+++ b/lead-confirm.php
@@ -51,7 +51,7 @@ $GLOBALS['module'] = 'lead-confirm';
 $GLOBALS['output_mode'] = '0';
 
 // Load config.php
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if (isInstalled()) {
diff --git a/login.php b/login.php
index 218b3c4414..9a0c074af2 100644
--- a/login.php
+++ b/login.php
@@ -50,7 +50,7 @@ $GLOBALS['module'] = 'login';
 $GLOBALS['output_mode'] = '0';
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if (isInstalled()) {
diff --git a/mailid.php b/mailid.php
index de8018f6bc..b08e29be38 100644
--- a/mailid.php
+++ b/mailid.php
@@ -48,11 +48,11 @@ $GLOBALS['module'] = 'mailid';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 if (isInstalled()) {
 	// Is the extension active?
-	REDIRECT_ON_UNINSTALLED_EXTENSION('mailid');
+	redirectOnUninstalledExtension('mailid');
 
 	// Init
 	$url_uid = 0; $url_bid = 0; $url_mid = 0;
@@ -97,7 +97,7 @@ if (isInstalled()) {
 
 			case 'BONUS':
 				// Is the bonus extension active?
-				REDIRECT_ON_UNINSTALLED_EXTENSION('bonus');
+				redirectOnUninstalledExtension('bonus');
 
 				// Bonus-Mails
 				$result = SQL_QUERY_ESC("SELECT id, url, subject FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1",
@@ -107,13 +107,16 @@ if (isInstalled()) {
 
 			if (SQL_NUMROWS($result) == 1) {
 				// Load data
-				list($pool, $URL, $EXTRA_TITLE) = SQL_FETCHROW($result);
+				list($pool, $URL, $title) = SQL_FETCHROW($result);
 
 				// Free result
 				SQL_FREERESULT($result);
 
 				// Compile extra title
-				$EXTRA_TITLE = COMPILE_CODE($EXTRA_TITLE);
+				$title = COMPILE_CODE($title);
+
+				// Set it
+				setExtraTitle($title);
 
 				// Is the user's ID unlocked?
 				$result = SQL_QUERY_ESC("SELECT status, gender, surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
@@ -204,7 +207,7 @@ if (isInstalled()) {
 				break;
 
 			case 'REJECT': // Redirect to rejection page
-				LOAD_CONFIGURED_URL('reject_url');
+				redirectToConfiguredUrl('reject_url');
 				break;
 
 			default:
diff --git a/mailid_top.php b/mailid_top.php
index 0a16e40af6..c292aaf2dd 100644
--- a/mailid_top.php
+++ b/mailid_top.php
@@ -48,11 +48,11 @@ $GLOBALS['module'] = 'mailid';
 $GLOBALS['output_mode'] = 0;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 if (isInstalled()) {
 	// Is the extension active
-	REDIRECT_ON_UNINSTALLED_EXTENSION('mailid');
+	redirectOnUninstalledExtension('mailid');
 
 	// Secure all data
 	$url_uid = 0; $url_bid = 0; $url_mid = 0; $code = 0; $mode = '';
diff --git a/modules.php b/modules.php
index 85703b5e05..8b2c771373 100644
--- a/modules.php
+++ b/modules.php
@@ -50,7 +50,7 @@ $GLOBALS['action'] = '';
 $GLOBALS['module'] = '';
 
 // Needed include files
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Fix missing module to 'index'
 if (!REQUEST_ISSET_GET('module')) REQUEST_SET_GET('module', 'index');
@@ -63,7 +63,7 @@ if (IS_MEMBER()) {
 	if (SQL_NUMROWS($result) == 1) {
 		// Load surname and family's name and build the username
 		list($s, $f) = SQL_FETCHROW($result);
-		$username = $s.' '.$f;
+		$username = $s . ' ' . $f;
 
 		// Additionally admin?
 		if (IS_ADMIN()) {
diff --git a/ref.php b/ref.php
index b331326ec4..55e8ef3585 100644
--- a/ref.php
+++ b/ref.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'ref';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Redirect only to registration page when this script is installed
 if (isInstalled()) {
diff --git a/show_bonus.php b/show_bonus.php
index 99d7cc4310..d8dc4bf7d0 100644
--- a/show_bonus.php
+++ b/show_bonus.php
@@ -49,10 +49,10 @@ $GLOBALS['module'] = 'show_bonus';
 $GLOBALS['output_mode'] = 0;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the 'bonus' extension active?
-REDIRECT_ON_UNINSTALLED_EXTENSION('bonus');
+redirectOnUninstalledExtension('bonus');
 
 // List only rankings when script is installed
 if (isInstalled()) {
@@ -93,46 +93,43 @@ LIMIT 1",
 				$content = SQL_FETCHARRAY($result);
 
 				// Prepare constants for the pre-template
-				define('__GENDER'   , translateGender($content['gender']));
-				define('__SNAME'    , $content['surname']);
-				define('__FNAME'    , $content['family']);
-				define('__RANK'     , BIGINTVAL($content['level']));
-				define('__POINTS'   , translateComma($content['points']));
-				define('__MAILID'   , bigintval(REQUEST_GET('d')));
-				define('__RANK_ROWS', BONUS_MAKE_RANK_ROWS(bigintval(REQUEST_GET('d')), $t, bigintval(REQUEST_GET('uid'))));
+				$content['gender'] = translateGender($content['gender']);
+				$content['points'] = translateComma($content['points']);
+				$content['mailid'] = bigintval(REQUEST_GET('d'));
+				$content['rows']   = BONUS_MAKE_RANK_ROWS(bigintval(REQUEST_GET('d')), $t, bigintval(REQUEST_GET('uid')));
 
 				// Constant created within previous function which contains informations for current user's ranking position:
 				//   __YOUR_RANKING_LINE
 
 				// Load pre-template
-				define('__BONUS_MSG', LOAD_TEMPLATE('show_bonus_msg', true));
+				$content['msg'] = LOAD_TEMPLATE('show_bonus_msg', true, $content);
 			} else {
 				// No data found
-				define('__BONUS_MSG', "<span class=\"guest_failed\">{--BONUS_SHOW_NO_DATA--}</span>");
+				$content['msg'] = "<span class=\"guest_failed\">{--BONUS_SHOW_NO_DATA--}</span>";
 			}
 
 			// Free memory
 			SQL_FREERESULT($result);
 		} else {
 			// Wrong type entered
-			define('__BONUS_MSG', "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_TYPE--}</span>");
+			$content['msg'] = "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_TYPE--}</span>";
 		}
 	} else {
 		// Wrong call!
-		define('__BONUS_MSG', "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_CALL--}</span>");
+		$content['msg'] = "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_CALL--}</span>";
 	}
 
 	// Load send_bonus header template (for your banners, e.g.?)
-	define('__BONUS_HEADER', LOAD_TEMPLATE('show_bonus_header', true));
+	$content['header'] = LOAD_TEMPLATE('show_bonus_header', true);
 
 	// Load show_bonus footer template (for your banners, e.g.?)
-	define('__BONUS_FOOTER', LOAD_TEMPLATE('show_bonus_footer', true));
+	$content['footer'] = LOAD_TEMPLATE('show_bonus_footer', true);
 
 	// Total ranks who can win
-	define('__BONUS_TOTAL_RANKS', getConfig('bonus_ranks'));
+	$content['total_ranks'] = getConfig('bonus_ranks');
 
 	// Load final template
-	LOAD_TEMPLATE('show_bonus');
+	LOAD_TEMPLATE('show_bonus', false, $content);
 
 	// Include footer
 	loadInclude('inc/footer.php');
diff --git a/sponsor_confirm.php b/sponsor_confirm.php
index b630cb1daf..59f734fcfe 100644
--- a/sponsor_confirm.php
+++ b/sponsor_confirm.php
@@ -49,7 +49,7 @@ $GLOBALS['module'] = 'sponsor_confirm';
 $GLOBALS['output_mode'] = '0';
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if (isInstalled()) {
diff --git a/sponsor_ref.php b/sponsor_ref.php
index 762e38bf3e..b1cdd9b479 100644
--- a/sponsor_ref.php
+++ b/sponsor_ref.php
@@ -49,7 +49,7 @@ $GLOBALS['module'] = 'sponsor_ref';
 $GLOBALS['output_mode'] = '0';
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Redirect only to registration page when this script is installed
 if (isInstalled()) {
diff --git a/surfbar.php b/surfbar.php
index ae518872b5..f6f0ca1d4b 100644
--- a/surfbar.php
+++ b/surfbar.php
@@ -52,12 +52,12 @@ $GLOBALS['output_mode'] = 0;
 $msg = null;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 // Is the script installed?
 if (isInstalled()) {
 	// Only logged in users may use this surfbar!
-	REDIRECT_ON_UNINSTALLED_EXTENSION('surfbar');
+	redirectOnUninstalledExtension('surfbar');
 
 	// No member?
 	if (!IS_MEMBER()) {
diff --git a/templates/de/html/admin/admin_config_beg.tpl b/templates/de/html/admin/admin_config_beg.tpl
index 91fcada2b0..eba5dae727 100644
--- a/templates/de/html/admin/admin_config_beg.tpl
+++ b/templates/de/html/admin/admin_config_beg.tpl
@@ -2,29 +2,32 @@
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed" width="500">
 	<tr>
 		<td colspan="3" align="center" class="admin_title bottom2" height="30">
-		<strong>{--ADMIN_EDIT_BEG_SETTINGS--}</strong></td>
+			<strong>{--ADMIN_EDIT_BEG_SETTINGS--}</strong>
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
 		<td align="right" width="200" height="20">
-		{--ADMIN_BEG_POINTS--}:</td>
+			{--ADMIN_BEG_POINTS--}:
+		</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td width="295" align="center"><input type="text"
-			name="beg_points" class="admin_normal" size="7" maxlength="10"
-			value="{!__BEG_POINTS!}"></td>
+		<td width="295" align="center">
+			<input type="text" name="beg_points" class="admin_normal" size="7" maxlength="10" value="$content[points]" />
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
 		<td align="right" width="300" height="20">
-		{--ADMIN_BEG_POINTS_MAX--}:</td>
+			{--ADMIN_BEG_POINTS_MAX--}:
+		</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td width="195" align="center"><input type="text"
-			name="beg_points_max" class="admin_normal" size="7" maxlength="10"
-			value="{!__BEG_POINTS_MAX!}"></td>
+		<td width="195" align="center">
+			<input type="text" name="beg_points_max" class="admin_normal" size="7" maxlength="10" value="$content[points_max]" />
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -32,7 +35,7 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_CONFIG_BEG_TIMEOUT--}:</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center">{!__BEG_TIMEOUT!}</td>
+		<td align="center">$content[timeout]</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -41,16 +44,17 @@
 		<td align="right" height="20">
 		{--ADMIN_CONFIG_BEG_UID_TIMEOUT--}:</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center">{!__BEG_UID_TIMEOUT!}</td>
+		<td align="center">$content[uid_timeout]</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
 		<td align="right" height="20">
-		{--ADMIN_CONFIG_BEG_REMOTE_IP_TIMEOUT--}:</td>
+			{--ADMIN_CONFIG_BEG_REMOTE_IP_TIMEOUT--}:
+		</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center">{!__BEG_REMOTE_IP_TIMEOUT!}</td>
+		<td align="center">$content[ip_timeout]</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -59,7 +63,7 @@
 		<td align="right" height="20">{--ADMIN_BEG_USERID--}:</td>
 		<td class="seperator" width="5">&nbsp;</td>
 		<td align="center">
-			{!__MEMBER_SELECTION!}
+			$content[member_selection]
 		</td>
 	</tr>
 	<tr>
@@ -67,18 +71,19 @@
 	</tr>
 	<tr>
 		<td colspan="3" align="center" class="admin_title bottom2" height="30">
-		<strong>{--ADMIN_SELECT_BEG_MODE--}:</strong></td>
+			<strong>{--ADMIN_SELECT_BEG_MODE--}:</strong>
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
-		<td align="right" height="20"><input type="radio" name="beg_mode"
-			class="admin_normal" value="DIRECT"{!__BEG_MODE_DIRECT!}>&nbsp;{--BEG_MODE_DIRECT--}<br />
+		<td align="right" height="20">
+			<input type="radio" name="beg_mode" class="admin_normal" value="DIRECT"$content[mode_direct] />&nbsp;{--BEG_MODE_DIRECT--}
 		</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="beg_mode"
-			class="admin_normal" value="REF"{!__BEG_MODE_REF!}>&nbsp;{--BEG_MODE_REF--}
+		<td align="center">
+			<input type="radio" name="beg_mode" class="admin_normal" value="REF"$content[mode_ref] />&nbsp;{--BEG_MODE_REF--}
 		</td>
 	</tr>
 	<tr>
@@ -86,7 +91,8 @@
 	</tr>
 	<tr>
 		<td colspan="3" align="center" class="admin_title bottom2" height="30">
-		<strong>{--ADMIN_EDIT_BEG_RALLYE_SETTINGS--}</strong></td>
+			<strong>{--ADMIN_EDIT_BEG_RALLYE_SETTINGS--}</strong>
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -94,9 +100,9 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_RALLYE_ACTIVE--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="beg_rallye"
-			class="admin_normal" value="Y"{!__BEG_RALLYE_Y!} />&nbsp;{--YES--}<br />
-		<input type="radio" name="beg_rallye" class="admin_normal" value="N"{!__BEG_RALLYE_N!} />&nbsp;{--NO--}
+		<td align="center">
+			<input type="radio" name="beg_rallye" class="admin_normal" value="Y"$content[rallye_yes] />&nbsp;{--YES--}<br />
+			<input type="radio" name="beg_rallye" class="admin_normal" value="N"$content[rallye_no] />&nbsp;{--NO--}
 		</td>
 	</tr>
 	<tr>
@@ -105,10 +111,10 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_INCLUDE_OWN--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="beg_include_own"
-			class="admin_normal" value="Y"{!__BEG_INCLUDE_OWN_Y!} />&nbsp;{--YES--}<br />
-		<input type="radio" name="beg_include_own" class="admin_normal"
-			value="N"{!__BEG_INCLUDE_OWN_N!} />&nbsp;{--NO--}</td>
+		<td align="center">
+			<input type="radio" name="beg_include_own" class="admin_normal" value="Y"$content[include_own_yes] />&nbsp;{--YES--}<br />
+			<input type="radio" name="beg_include_own" class="admin_normal" value="N"$content[include_own_no] />&nbsp;{--NO--}
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -116,8 +122,8 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_RANKS--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="text" name="beg_ranks"
-			class="admin_normal" size="3" maxlength="7" value="{!__BEG_RANKS!}" />
+		<td align="center">
+			<input type="text" name="beg_ranks" class="admin_normal" size="3" maxlength="7" value="$content[ranks]" />
 		</td>
 	</tr>
 	<tr>
@@ -128,9 +134,9 @@
 			{--ADMIN_BEG_RALLYE_ONLY_ACTIVE--}
 		</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="beg_active"
-			class="admin_normal" value="Y"{!__BEG_ACTIVE_Y!} />&nbsp;{--YES--}<br />
-		<input type="radio" name="beg_active" class="admin_normal" value="N"{!__BEG_ACTIVE_N!} />&nbsp;{--NO--}
+		<td align="center">
+			<input type="radio" name="beg_active" class="admin_normal" value="Y"$content[active_yes] />&nbsp;{--YES--}<br />
+			<input type="radio" name="beg_active" class="admin_normal" value="N"$content[active_no] />&nbsp;{--NO--}
 		</td>
 	</tr>
 	<tr>
@@ -143,10 +149,10 @@
 		<td class="seperator" width="5">&nbsp;</td>
 		<td align="center">
 			<select name="beg_pay_mode" size="1">
-				<option value="IMG"{!__BEG_PAY_MODE_IMG!}>{--ADMIN_BEG_PAY_MODE_IMG--}</option>
-				<option value="JS"{!__BEG_PAY_MODE_JS!}>{--ADMIN_BEG_PAY_MODE_JS--}</option>
-				<option value="BOTH"{!__BEG_PAY_MODE_BOTH!}>{--ADMIN_BEG_PAY_MODE_BOTH--}</option>
-				<option value="NONE"{!__BEG_PAY_MODE_NONE!}>{--ADMIN_BEG_PAY_MODE_NONE--}</option>
+				<option value="IMG"$content[pay_mode_img]>{--ADMIN_BEG_PAY_MODE_IMG--}</option>
+				<option value="JS"$content[pay_mode_js]>{--ADMIN_BEG_PAY_MODE_JS--}</option>
+				<option value="BOTH"$content[pay_mode_both]>{--ADMIN_BEG_PAY_MODE_BOTH--}</option>
+				<option value="NONE"$content[pay_mode_none]>{--ADMIN_BEG_PAY_MODE_NONE--}</option>
 			</select>
 		</td>
 	</tr>
@@ -164,10 +170,10 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_RAL_EN_NOTIFY--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="beg_ral_en_notify"
-			class="admin_normal" value="Y"{!__BEG_RAL_EN_NOTIFY_Y!} />&nbsp;{--YES--}<br />
-		<input type="radio" name="beg_ral_en_notify" class="admin_normal"
-			value="N"{!__BEG_RAL_EN_NOTIFY_N!} />&nbsp;{--NO--}</td>
+		<td align="center">
+			<input type="radio" name="beg_ral_en_notify" class="admin_normal" value="Y"$content[ral_enable_notify_yes] />&nbsp;{--YES--}<br />
+			<input type="radio" name="beg_ral_en_notify" class="admin_normal" value="N"$content[ral_enable_notify_no] />&nbsp;{--NO--}
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -175,10 +181,10 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_RAL_DI_NOTIFY--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="beg_ral_di_notify"
-			class="admin_normal" value="Y"{!__BEG_RAL_DI_NOTIFY_Y!} />&nbsp;{--YES--}<br />
-		<input type="radio" name="beg_ral_di_notify" class="admin_normal"
-			value="N"{!__BEG_RAL_DI_NOTIFY_N!} />&nbsp;{--NO--}</td>
+		<td align="center">
+			<input type="radio" name="beg_ral_di_notify" class="admin_normal" value="Y"$content[ral_disable_notify_yes] />&nbsp;{--YES--}<br />
+			<input type="radio" name="beg_ral_di_notify" class="admin_normal" value="N"$content[ral_disable_notify_no] />&nbsp;{--NO--}
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -186,10 +192,10 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_NEW_MEMBER_NOTIFY--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="beg_new_mem_notify"
-			class="admin_normal" value="Y"{!__BEG_NEW_MEMBER_NOTIFY_Y!} />&nbsp;{--YES--}<br />
-		<input type="radio" name="beg_new_mem_notify" class="admin_normal"
-			value="N"{!__BEG_NEW_MEMBER_NOTIFY_N!} />&nbsp;{--NO--}</td>
+		<td align="center">
+			<input type="radio" name="beg_new_mem_notify" class="admin_normal" value="Y"$content[new_member_notify_yes] />&nbsp;{--YES--}<br />
+			<input type="radio" name="beg_new_mem_notify" class="admin_normal" value="N"$content[new_member_notify_no] />&nbsp;{--NO--}
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -197,9 +203,9 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_NOTIFY_BONUS--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="text" name="beg_notify_bonus"
-			class="admin_normal" size="3" maxlength="7"
-			value="{!__BEG_NOTIFY_BONUS!}"></td>
+		<td align="center">
+			<input type="text" name="beg_notify_bonus" class="admin_normal" size="3" maxlength="7" value="$content[notify_bonus]" />
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -207,16 +213,16 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BEG_NOTIFY_WAIT--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center">{!__WAIT_SELECTION!}</td>
+		<td align="center">$content[wait_selection]</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="bottom2 seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
-		<td colspan="3" class="admin_footer"><input
-			type="reset" class="admin_reset" value="{--CLEAR_FORM--}" />
-		<input type="submit" name="ok" class="admin_submit"
-			value="{--SAVE_SETTINGS--}" /></td>
+		<td colspan="3" class="admin_footer">
+			<input type="reset" class="admin_reset" value="{--CLEAR_FORM--}" />
+			<input type="submit" name="ok" class="admin_submit" value="{--SAVE_SETTINGS--}" />
+		</td>
 	</tr>
 </table>
 </form>
diff --git a/templates/de/html/admin/admin_config_birthday.tpl b/templates/de/html/admin/admin_config_birthday.tpl
index a0d4f433f9..f7586e4ca2 100644
--- a/templates/de/html/admin/admin_config_birthday.tpl
+++ b/templates/de/html/admin/admin_config_birthday.tpl
@@ -3,7 +3,8 @@
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
 	<tr>
 		<td colspan="3" align="center" class="admin_title bottom2" height="30">
-		<strong>{--ADMIN_CONFIG_BIRTHDAY_HEADER--}</strong></td>
+			<strong>{--ADMIN_CONFIG_BIRTHDAY_HEADER--}</strong>
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
@@ -12,9 +13,10 @@
 		<td width="400" align="right">{--ADMIN_BIRTHDAY_POINTS--}:
 		<span class="admin_note">({--ADMIN_BIRTHDAY_POINTS_NOTE--})</span></td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td width="170"><input type="text" name="birthday_points"
-			class="admin_normal" value="{!__POINTS_VALUE!}" size="4"
-			maxlength="6">&nbsp;<div class="tiny">({!POINTS!})</div></td>
+		<td width="170">
+			<input type="text" name="birthday_points" class="admin_normal" value="{!__POINTS_VALUE!}" size="4" maxlength="6" />
+			<div class="tiny">({!POINTS!})</div>
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator bottom2" height="5">&nbsp;</td>
@@ -25,38 +27,39 @@
 	<tr>
 		<td align="right" height="20">{--ADMIN_BIRTHDAY_ONLY_ACTIVE--}</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="birthday_active"
-			class="admin_normal" value="Y"{!__BIRTHDAY_ACTIVE_Y!} />&nbsp;{--YES--}<br />
-		<input type="radio" name="birthday_active" class="admin_normal"
-			value="N"{!__BIRTHDAY_ACTIVE_N!} />&nbsp;{--NO--}</td>
+		<td align="center">
+			<input type="radio" name="birthday_active" class="admin_normal" value="Y"$content[active_yes] />&nbsp;{--YES--}<br />
+			<input type="radio" name="birthday_active" class="admin_normal" value="N"$content[active_no] />&nbsp;{--NO--}
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="bottom2 seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
 		<td colspan="3" align="center" class="admin_title bottom2" height="30">
-		<strong>{--ADMIN_SELECT_BIRTHDAY_MODE--}:</strong></td>
+			<strong>{--ADMIN_SELECT_BIRTHDAY_MODE--}:</strong>
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
-		<td align="right" height="20"><input type="radio"
-			name="birthday_mode" class="admin_normal" value="DIRECT"{!__BIRTHDAY_MODE_DIRECT!}>&nbsp;{--BIRTHDAY_MODE_DIRECT--}<br />
+		<td align="right" height="20">
+			<input type="radio" name="birthday_mode" class="admin_normal" value="DIRECT"$content[mode_direct] />&nbsp;{--BIRTHDAY_MODE_DIRECT--}
 		</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td align="center"><input type="radio" name="birthday_mode"
-			class="admin_normal" value="REF"{!__BIRTHDAY_MODE_REF!}>&nbsp;{--BIRTHDAY_MODE_REF--}
+		<td align="center">
+			<input type="radio" name="birthday_mode" class="admin_normal" value="REF"$content[mode_ref] />&nbsp;{--BIRTHDAY_MODE_REF--}
 		</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="bottom2 seperator" height="5">&nbsp;</td>
 	</tr>
 	<tr>
-		<td colspan="3" class="admin_footer"><input
-			type="reset" class="admin_reset" value="{--CLEAR_FORM--}" />&nbsp;<input
-			type="submit" name="ok" class="admin_submit"
-			value="{--SAVE_SETTINGS--}" /></td>
+		<td colspan="3" class="admin_footer">
+			<input type="reset" class="admin_reset" value="{--CLEAR_FORM--}" />
+			<input type="submit" name="ok" class="admin_submit" value="{--SAVE_SETTINGS--}" />
+		</td>
 	</tr>
 </table>
 </form>
diff --git a/templates/de/html/admin/admin_config_bonus.tpl b/templates/de/html/admin/admin_config_bonus.tpl
index ad3853a5f5..f9971b5303 100644
--- a/templates/de/html/admin/admin_config_bonus.tpl
+++ b/templates/de/html/admin/admin_config_bonus.tpl
@@ -318,7 +318,7 @@
 		<td align="right" width="300" height="20">
 		{--ADMIN_BONUS_RALLYE_NOTIFY_WAIT--}:</td>
 		<td class="seperator" width="5">&nbsp;</td>
-		<td width="195" align="center">{!__WAIT_SELECTION!}</td>
+		<td width="195" align="center">$content[wait_selection]</td>
 	</tr>
 	<tr>
 		<td colspan="3" class="bottom2 seperator" height="5">&nbsp;</td>
diff --git a/templates/de/html/beg/beg_link.tpl b/templates/de/html/beg/beg_link.tpl
index c2536b18a3..e33128224f 100644
--- a/templates/de/html/beg/beg_link.tpl
+++ b/templates/de/html/beg/beg_link.tpl
@@ -13,7 +13,8 @@
 			</tr>
 			<tr>
 				<td align="center" height="120" class="beg_msg bottom2">
-				{!__BEG_MSG!}</td>
+				$content[msg]
+				</td>
 			</tr>
 			<tr>
 				<td align="center" height="30"><a
diff --git a/templates/de/html/birthday/birthday_confirm.tpl b/templates/de/html/birthday/birthday_confirm.tpl
index 5d23308db7..5cc32235d5 100644
--- a/templates/de/html/birthday/birthday_confirm.tpl
+++ b/templates/de/html/birthday/birthday_confirm.tpl
@@ -1,11 +1,17 @@
 <table border="0" cellspacing="0" cellpadding="0" width="100%" style="height: 100%">
 <tr>
-	<td height="10%" align="center">{!__BIRTHDAY_HEADER!}</td>
+	<td height="10%" align="center">
+		$content[header]
+	</td>
 </tr>
 <tr>
-	<td height="80%" align="center">{!__MSG!}</td>
+	<td height="80%" align="center">
+		$content[msg]
+	</td>
 </tr>
 <tr>
-	<td height="10%" align="center">{!__BIRTHDAY_FOOTER!}</td>
+	<td height="10%" align="center">
+		$content[footer]
+	</td>
 </tr>
 </table>
diff --git a/templates/de/html/birthday/birthday_msg.tpl b/templates/de/html/birthday/birthday_msg.tpl
index d06a4ae596..17a05701cc 100644
--- a/templates/de/html/birthday/birthday_msg.tpl
+++ b/templates/de/html/birthday/birthday_msg.tpl
@@ -1,8 +1,8 @@
-<div class="big">Herzlichen Gl&uuml;ckwunsch zum Geburtstag!</div> <br />
+<div class="big">Herzlichen Gl&uuml;ckwunsch zum Geburtstag!</div><br />
 <br />
-Hallo {!__GENDER!} {!__SNAME!} {!__FNAME!}!<br />
+Hallo $content[gender] $content[surname] $content[family]!<br />
 <br />
 Wir das Team von <span class="nobr">{!MAIN_TITLE!}</span> w&uuml;schen Ihnen
 alles Gute und Gesundheit zum Geburtstag. Als kleines Geschenk von uns haben wir
-Ihnen soeben <span class="nobr">{!__GIFT!} {!POINTS!}</span> Ihrem Account
+Ihnen soeben <span class="nobr">$content[points] {!POINTS!}</span> Ihrem Account
 gutgeschrieben!
diff --git a/templates/de/html/copyright.tpl b/templates/de/html/copyright.tpl
index d1a91d7c0f..eb0cef1c5d 100644
--- a/templates/de/html/copyright.tpl
+++ b/templates/de/html/copyright.tpl
@@ -1,11 +1,12 @@
 <div align="center">
 <div class="footer_box">
-<div class="footer_lines">
-	{!TITLE!} v{!FULL_VERSION!} R{!CURR_SVN_REVISION!}<br />
+<div class="footer_lines" style="float:left">
+	{!TITLE!}
+	v{!FULL_VERSION!} R{!CURR_SVN_REVISION!}<br />
 	{!COPY!}
 </div>
 
-<div class="footer_lines">
+<div class="footer_lines" style="float:right">
 	This website&#39;s engine is free software which is released under the GNU
 	GPL either version 2 of the License.
 </div>
diff --git a/templates/de/html/ext/ext_lead.tpl b/templates/de/html/ext/ext_lead.tpl
new file mode 100644
index 0000000000..01265f5949
--- /dev/null
+++ b/templates/de/html/ext/ext_lead.tpl
@@ -0,0 +1,21 @@
+Diese Erweiterung bietet Ihnen die M&ouml;glichkeit an, Lead-Code von
+Sponsornetzwerken in die Mitgliederanmeldung einzubinden. Dazu m&uuml;ssen
+Sie derzeit den Lead-Code in das Template <u>lead_code.tpl</u> einbinden
+(mehrere Lead-Codes sind auch m&ouml;glich!).<br />
+<br />
+Meistens m&uuml;ssen Sie irgentwelche eindeutigen Daten an den Lead-Code
+&uuml;bergeben. Dies k&ouml;nnen z.B. doe User-Id und/oder die Email-Adresse
+sein. Beides wird von diesem Script derzeit auch unterst&uuml;tzt.<br />
+<br />
+Wenn Sie die User-Id &uuml;bertragen m&ouml;chten, so verwenden Sie die
+Template-Variable <u>lead_uid</u>, m&ouml;chten Sie die Email-Adresse von der
+Anmeldung &uuml;bertragen, verwenden Sie <u>lead_email</u>. Dazu ein
+Beispielcode:<br />
+<br />
+&lt;img border=&quot;0&quot; alt=&quot;Lead&quot; width=&quot;1&quot; height=&quot;1&quot;
+ src=&quot;http://some-sponsor-network/lead-image.php?campaign=xxx&amp;user_data=&#36;content[lead_uid]_$content[lead_email]&quot; /&gt;
+<br />
+Sollten Sie dazu noch Fragen haben, so kommen Sie doch einfach <a target="_blank"
+ href="http://forum.mxchange.org" title="Direkt-Link zum Support-Forum">in das
+Forum</a>. Mein Support-Team und ich beantworten Ihnen gerne Ihre Fragen dazu
+und helfen Ihnen bei Schwierigkeiten weiter.
diff --git a/templates/de/html/guest/guest_beg.tpl b/templates/de/html/guest/guest_beg.tpl
index 8f335100bf..a71da4d443 100644
--- a/templates/de/html/guest/guest_beg.tpl
+++ b/templates/de/html/guest/guest_beg.tpl
@@ -1,6 +1,5 @@
 <div align="center">
-<table border="0" cellspacing="0" cellpadding="0"
-	class="beg_table dashed" width="500">
+<table border="0" cellspacing="0" cellpadding="0" class="beg_table dashed" width="500">
 	<tr>
 		<td width="10" rowspan="10" class="seperator">&nbsp;</td>
 		<td height="5" class="seperator">&nbsp;</td>
diff --git a/templates/de/html/index.tpl b/templates/de/html/index.tpl
index 9788973104..e596704e9f 100644
--- a/templates/de/html/index.tpl
+++ b/templates/de/html/index.tpl
@@ -6,7 +6,7 @@
 		<table border="0" cellspacing="0" cellpadding="0" width="100%">
 			<tr>
 				<td align="center"><a target="_parent"
-					href="{!URL!}/modules.php?module=index&amp;what=welcome$content">
+					href="{!URL!}/modules.php?module=index&amp;what=welcome">
 				<!-- <img src="{!THEME_URL!}/images/index_logo.jpg" alt="{!MAIN_TITLE!}" title="{!MAIN_TITLE!}" border="0"> //-->
 				<div class="big">{!MAIN_TITLE!}</div> </a></td>
 			</tr>
@@ -22,7 +22,7 @@
 	<tr>
 		<td align="center" height="26%"><div class="big">[&nbsp;<a
 			target="_parent"
-			href="{!URL!}/modules.php?module=index&amp;what=welcome$content">Weiter...</a>&nbsp;]</div>
+			href="{!URL!}/modules.php?module=index&amp;what=welcome">Weiter...</a>&nbsp;]</div>
 		</td>
 	</tr>
 	<tr>
diff --git a/templates/de/html/member/member_beg.tpl b/templates/de/html/member/member_beg.tpl
index c38ae9392d..ae712fe076 100644
--- a/templates/de/html/member/member_beg.tpl
+++ b/templates/de/html/member/member_beg.tpl
@@ -1,5 +1,4 @@
-<table border="0" cellspacing="0" cellpadding="0"
-	class="beg_table dashed" width="500">
+<table border="0" cellspacing="0" cellpadding="0" class="beg_table dashed" width="500">
 	<tr>
 		<td width="10" rowspan="9" class="seperator">&nbsp;</td>
 		<td height="5" class="seperator">&nbsp;</td>
diff --git a/templates/de/html/show_bonus.tpl b/templates/de/html/show_bonus.tpl
index 90174b1321..5cc32235d5 100644
--- a/templates/de/html/show_bonus.tpl
+++ b/templates/de/html/show_bonus.tpl
@@ -1,12 +1,17 @@
-<table border="0" cellspacing="0" cellpadding="0" width="100%"
-	style="height: 100%">
-	<tr>
-		<td height="10%" align="center">{!__BONUS_HEADER!}</td>
-	</tr>
-	<tr>
-		<td height="80%" align="center">{!__BONUS_MSG!}</td>
-	</tr>
-	<tr>
-		<td height="10%" align="center">{!__BONUS_FOOTER!}</td>
-	</tr>
-</table>
\ No newline at end of file
+<table border="0" cellspacing="0" cellpadding="0" width="100%" style="height: 100%">
+<tr>
+	<td height="10%" align="center">
+		$content[header]
+	</td>
+</tr>
+<tr>
+	<td height="80%" align="center">
+		$content[msg]
+	</td>
+</tr>
+<tr>
+	<td height="10%" align="center">
+		$content[footer]
+	</td>
+</tr>
+</table>
diff --git a/templates/de/html/show_bonus_msg.tpl b/templates/de/html/show_bonus_msg.tpl
index 4fffd92e26..b0d869c904 100644
--- a/templates/de/html/show_bonus_msg.tpl
+++ b/templates/de/html/show_bonus_msg.tpl
@@ -1,10 +1,10 @@
-{--HELLO--} {!__GENDER!} {!__SNAME!} {!__FNAME!}!
+{--HELLO--} $content[gender] $content[surname] $content[family]!
 <br />
 <br />
 {--BONUS_SHOW_HEADER_LINE_1--}
 <strong>{!POINTS!}</strong>
 {--BONUS_SHOW_HEADER_LINE_2--}
-<strong>{!__MAILID!}</strong>
+<strong>$content[mailid]</strong>
 {--BONUS_SHOW_HEADER_LINE_3--}:
 <br />
 <br />
@@ -14,7 +14,7 @@
 		<td width="120" align="center" class="member_header bottom2"><strong>{!_UID!}:</strong></td>
 		<td width="100" align="center" class="member_header bottom2"><strong>{!POINTS!}:</strong></td>
 	</tr>
-	{!__RANK_ROWS!}
+	$content[rows]
 	<tr>
 		<td colspan="3" class="member_footer" align="center"><div class="tiny member_note">&nbsp;</div></td>
 	</tr>
@@ -23,6 +23,6 @@
 <div>{!__YOUR_RANKING_LINE!}</div>
 
 <div class="member_note">
-	{--BONUS_SHOW_FOOTER_NOTE_1--}<br />
-	{--BONUS_SHOW_FOOTER_NOTE_2--}
+	Wir w&uuml;nschen allen Gewinnern viel Gl&uuml;ck bei der monatlichen Aktiv-Rallye!<br />
+	Es k&ouml;nnen nur die ersten <u>$content[total_ranks]</u> die Aktiv-Rallye gewinnen. Der Rechtsweg ist ausgeschlossen.
 </div>
diff --git a/view.php b/view.php
index f933089bbb..0834ed3adc 100644
--- a/view.php
+++ b/view.php
@@ -48,7 +48,7 @@ $GLOBALS['module'] = 'view';
 $GLOBALS['output_mode'] = -1;
 
 // Load the required file(s)
-require('inc/config.php');
+require('inc/config-global.php');
 
 if (((REQUEST_ISSET_GET(('user'))) || (REQUEST_ISSET_GET(('reseller')))) && (REQUEST_ISSET_GET(('banner')))) {
 	// for later things... ;-)
@@ -61,7 +61,7 @@ if (((REQUEST_ISSET_GET(('user'))) || (REQUEST_ISSET_GET(('reseller')))) && (REQ
 			array(bigintval(REQUEST_GET('banner'))), __FILE__, __LINE__);
 
 		$type = substr($url, -3);
-		header ('Content-Type: image/' . $type);
+		sendHeader('Content-Type: image/' . $type);
 		redirectToUrl($url, false);
 	} else {
 		// Free memory
-- 
2.39.5