Index: branches/main/admin/interface/version.php
===================================================================
--- branches/main/admin/interface/version.php	(revision 5)
+++ branches/main/admin/interface/version.php	(revision 6)
@@ -48,6 +48,6 @@
 
 // check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
 if(!defined('VERSION')) { define('VERSION', '2.10.1-dev'); }
-if(!defined('REVISION')) { define('REVISION', '5'); }
+if(!defined('REVISION')) { define('REVISION', '6'); }
 if(!defined('SP')) { define('SP', ''); }
 
Index: branches/main/framework/class.database.php
===================================================================
--- branches/main/framework/class.database.php	(revision 5)
+++ branches/main/framework/class.database.php	(revision 6)
@@ -36,8 +36,10 @@
 
     private $db_handle  = null; // readonly from outside
     private $db_name    = '';
+    private $sTablePrefix = '';
     private $connected  = false;
-    private $sCharset   = '';
+    private $sCharset   = 'utf8mb4';
+    private $sCollation = 'utf8mb4_unicode_ci';
     private $error      = '';
     private $error_no   = array();
     private $error_type = '';
@@ -46,29 +48,31 @@
 
 
     // Set DB_URL
-    function __construct($url = '') {
+    function __construct($url = '')
+    {
         // Connect to database
         if (!$this->connect()) {
             throw new DatabaseException($this->get_error());
         }
+        $this->sTablePrefix = TABLE_PREFIX;
     }
 
     // Connect to the database   DB_CHARSET
-    function connect() {
-
-        $this->sCharset = strtolower(preg_replace('/[^a-z0-9]/i', '', (defined('DB_CHARSET') ? DB_CHARSET : '')));
-
-        if (defined('DB_PORT')) {
-            $port = DB_PORT;
-        } else {
-            $port = ini_get('mysqli.default_port');
-        }
+    function connect()
+    {
+        $aTmp = preg_split(
+            '/[^a-z0-9]/i',
+            strtolower(preg_replace('/[^a-z0-9_]/i', '', (defined('DB_CHARSET') ? DB_CHARSET : 'utf8mb4_unicode_ci')))
+        );
+        $this->sCharset = $aTmp[0];
+        $this->sCollation = implode('_', $aTmp);
+        $port = defined('DB_PORT') ? DB_PORT : ini_get('mysqli.default_port');
         if (!($this->db_handle = mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, $port))) {
             $this->connected = false;
             $this->error = mysqli_connect_error();
         } else {
             if ($this->sCharset) {
-                @mysqli_query($this->db_handle, 'SET NAMES '.$this->sCharset);
+                mysqli_query($this->db_handle, 'SET NAMES '.$this->sCharset);
                 mysqli_set_charset($this->db_handle, $this->sCharset);
             }
             $this->db_name = DB_NAME;
@@ -78,7 +82,8 @@
     }
 
     // Disconnect from the database
-    function disconnect() {
+    function disconnect()
+    {
         if($this->connected==true) {
             mysqli_close();
             return true;
@@ -88,7 +93,8 @@
     }
 
     // Run a query
-    function query($statement) {
+    function query($statement)
+    {
         $mysql = new mysql($this->db_handle);
         $mysql->query($statement);
         $this->set_error($mysql->error());
@@ -114,7 +120,8 @@
     }
 
     // Set the DB error
-    function set_error($message = null) {
+    function set_error($message = null)
+    {
         $this->error = $message;
         $this->error_type = 'unknown';
         if ($message!=''){
@@ -122,16 +129,19 @@
     }
 
     // Return true if there was an error
-    function is_error() {
+    function is_error()
+    {
         return (!empty($this->error)) ? true : false;
     }
 
     // Return the error
-    function get_error() {
+    function get_error()
+    {
         return $this->error;
     }
     // Return the errno
-    function get_errno() {
+    function get_errno()
+    {
         return $this->is_error() ? mysqli_errno($this->db_handle) : 0;
     }
 /**
@@ -150,6 +160,10 @@
             case 'DbName':
                 $retval = $this->db_name;
                 break;
+            case 'sTablePrefix':
+            case 'TablePrefix':
+                $retval = $this->sTablePrefix;
+                break;
             default:
                 $retval = null;
                 break;
@@ -347,7 +361,7 @@
         $sTablePrefix  = '',
         $mAction       = true,
         $sTblEngine    = 'MyISAM',
-        $sTblCollation = 'utf8_unicode_ci'
+        $sTblCollation = 'utf8mb4_unicode_ci'
     ) {
         $iCount = 0;
         $sSqlBuffer  = '';
@@ -477,13 +491,14 @@
 define('MYSQLI_SEEK_FIRST', 0);
 define('MYSQLI_SEEK_LAST', -1);
 
-class mysql {
-
+class mysql
+{
     private $db_handle = null;
     private $result = null;
     private $error = '';
 
-    public function __construct($handle) {
+    public function __construct($handle)
+    {
         $this->db_handle = $handle;
     }
 /**
@@ -507,12 +522,14 @@
     }
 
     // Fetch num rows
-    public function numRows() {
+    public function numRows()
+    {
         return mysqli_num_rows($this->result);
     }
 
     // Fetch row  $typ = MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH
-    public function fetchRow($typ = MYSQLI_BOTH) {
+    public function fetchRow($typ = MYSQLI_BOTH)
+    {
         return mysqli_fetch_array($this->result, $typ);
     }
 /**
@@ -586,8 +603,9 @@
     }
 
     // Get error
-    public function error() {
-        if(isset($this->error)) {
+    public function error()
+    {
+        if (isset($this->error)) {
             return $this->error;
         } else {
             return null;
Index: branches/main/framework/initialize.php
===================================================================
--- branches/main/framework/initialize.php	(revision 5)
+++ branches/main/framework/initialize.php	(revision 6)
@@ -15,14 +15,13 @@
  * @lastmodified    $Date$
  *
  */
-error_reporting( -1 );
-$sStarttime = array_sum(explode(" ", microtime()));
-$aPhpFunctions = get_defined_functions();
+// $aPhpFunctions = get_defined_functions();
 /**
  * sanitize $_SERVER['HTTP_REFERER']
  * @param string $sWbUrl qualified startup URL of current application
  */
-function SanitizeHttpReferer($sWbUrl = WB_URL) {
+function SanitizeHttpReferer($sWbUrl = WB_URL)
+{
     $sTmpReferer = '';
     if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
         define('ORG_REFERER', ($_SERVER['HTTP_REFERER'] ?: ''));
@@ -60,43 +59,6 @@
     return preg_replace('/^(.*)$/', '[$1]', $aList);
 }
 
-/* ***************************************************************************************
- * Start initialization                                                                  *
- ****************************************************************************************/// aktivate exceptionhandler ---
-//    throw new Exception('PHP-'.PHP_VERSION.' found, but at last PHP-5.3.6 required !!');
-// Stop execution if PHP version is too old
-// PHP less then 5.6.0 is prohibited ---
-if (version_compare(PHP_VERSION, '5.6.0', '<')) {
-    $sMsg = '<p style="color: #ff0000;">WebsiteBaker is not able to run with PHP-Version less then 5.6.0!!<br />'
-          . 'Please change your PHP-Version to any kind from 5.6.0 and up!<br />'
-          . 'If you have problems to solve that, ask your hosting provider for it.<br  />'
-          . 'The very best solution is the use of PHP-7.0 and up</p>';
-    die($sMsg);
-}
-
-/* -------------------------------------------------------- */
-if ( !defined('WB_PATH')) { define('WB_PATH', dirname(__DIR__)); }
-// *** initialize Exception handling
-if(!function_exists('globalExceptionHandler')) {
-    include(__DIR__.'/globalExceptionHandler.php');
-}
-// *** initialize Error handling
-$sErrorLogFile = dirname(__DIR__).'/var/logs/php_error.log.php';
-$sErrorLogPath = dirname($sErrorLogFile);
-
-if (!file_exists($sErrorLogFile)) {
-    $sTmp = '<?php die(\'illegal file access\'); ?>'
-          . 'created: ['.date('c').']'.PHP_EOL;
-    if (false === file_put_contents($sErrorLogFile, $sTmp, FILE_APPEND)) {
-        throw new Exception('unable to create logfile \'/var/logs/php_error.log.php\'');
-    }
-}
-if (!is_writeable($sErrorLogFile)) {
-    throw new Exception('not writeable logfile \'/var/logs/php_error.log.php\'');
-}
-ini_set('log_errors', 1);
-ini_set ('error_log', $sErrorLogFile);
-
 /**
  * Read DB settings from configuration file
  * @return array
@@ -143,7 +105,8 @@
  * Set constants for system/install values
  * @throws RuntimeException
  */
-function initSetInstallWbConstants($aCfg) {
+function initSetInstallWbConstants($aCfg)
+{
     if (sizeof($aCfg)) {
         foreach($aCfg['Constants'] as $key=>$value) {
             switch($key):
@@ -265,39 +228,96 @@
     }
     $aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     $x = sizeof($aBt) -1;
-    $x = $x < 0 ? 0 : ($x <= 2 ? $x : 2);
+    $iSize = $x < 0 ? 0 : ($x <= 2 ? $x : 2);
     $sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
-            . ' from '.str_replace(dirname(__DIR__), '', $aBt[$x]['file']).':['.$aBt[$x]['line'].'] '
-            . (@$aBt[$x]['class'] ? $aBt[$x]['class'].$aBt[$x]['type'] : '').$aBt[$x]['function'].' '
+            . ' from '.str_replace(dirname(__DIR__), '', $aBt[$iSize]['file']).':['.$aBt[$iSize]['line'].'] '
+            . (isset($aBt[$iSize]['class']) ? $aBt[$iSize]['class'].$aBt[$iSize]['type'] : '').$aBt[$iSize]['function'].' '
             . '"'.$sErrorText.'"'.PHP_EOL;
     file_put_contents($sErrorLogFile, $sEntry, FILE_APPEND);
     return $bRetval;
 }
+/**
+ * create / recreate a admin object
+ * @param string $section_name (default: '##skip##')
+ * @param string $section_permission (default: 'start')
+ * @param bool $auto_header (default: true)
+ * @param bool $auto_auth (default: true)
+ * @return \admin
+ */
+function newAdmin($section_name= '##skip##', $section_permission = 'start', $auto_header = true, $auto_auth = true)
+{
+    if (isset($GLOBALS['admin']) && $GLOBALS['admin'] instanceof admin) {
+        unset($GLOBALS['admin']);
+        usleep(10000);
+    }
+    return new admin($section_name, $section_permission, $auto_header, $auto_auth);
+}
+
 /* ***************************************************************************************
  * Start initialization                                                                  *
  ****************************************************************************************/
-// activate errorhandler
+    // Stop execution if PHP version is too old
+    // PHP less then 5.6.0 is prohibited ---
+    if (version_compare(PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION, '5.6.0', '<')) {
+        $sMsg = '<p style="color: #ff0000;">WebsiteBaker is not able to run with PHP-Version less then 5.6.0!!<br />'
+              . 'Please change your PHP-Version to any kind from 5.6.0 and up!<br />'
+              . 'If you have problems to solve that, ask your hosting provider for it.<br  />'
+              . 'The very best solution is the use of PHP-7.0 and up</p>';
+        die($sMsg);
+    }
+    error_reporting(E_ALL);
+    $sStarttime = array_sum(explode(" ", microtime()));
+    /* -------------------------------------------------------- */
+    if ( !defined('WB_PATH')) { define('WB_PATH', dirname(__DIR__)); }
+    // *** initialize Exception handling
+    if(!function_exists('globalExceptionHandler')) {
+        include(__DIR__.'/globalExceptionHandler.php');
+    }
+    // *** initialize Error handling
+    $sErrorLogFile = dirname(__DIR__).'/var/logs/php_error.log.php';
+    $sErrorLogPath = dirname($sErrorLogFile);
+
+    if (!file_exists($sErrorLogFile)) {
+        $sTmp = '<?php die(\'illegal file access\'); ?>'
+              . 'created: ['.date('c').']'.PHP_EOL;
+        if (false === file_put_contents($sErrorLogFile, $sTmp, FILE_APPEND)) {
+            throw new Exception('unable to create logfile \'/var/logs/php_error.log.php\'');
+        }
+    }
+    if (!is_writeable($sErrorLogFile)) {
+        throw new Exception('not writeable logfile \'/var/logs/php_error.log.php\'');
+    }
+    ini_set('log_errors', 1);
+    ini_set ('error_log', $sErrorLogFile);
+
+// activate errorhandler *****************************************************************
     set_error_handler('WbErrorHandler', -1 );
-    if (! defined('SYSTEM_RUN')) { define('SYSTEM_RUN', true); }
+    defined('SYSTEM_RUN') ? '' : define('SYSTEM_RUN', true);
 // load configuration ---
     $aCfg = initReadSetupFile();
     initSetInstallWbConstants($aCfg);
 // ---------------------------
 // get Database connection data from configuration
-if (!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', 'admin'); }
-if (!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
-    throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
-}
-if ( !defined('ADMIN_URL')) { define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY); }
-if ( !defined('ADMIN_PATH')) { define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
-if ( !defined('WB_REL')){
-    $x1 = parse_url(WB_URL);
-    define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
-}
-if ( !defined('DOCUMENT_ROOT')) {
-    define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
-    $_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
-}
+    defined('ADMIN_DIRECTORY') ? '' : define('ADMIN_DIRECTORY', 'admin');
+    if (!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
+        throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
+    }
+    defined('ADMIN_URL') ? '' : define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY);
+    defined('ADMIN_PATH') ? '' : define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY);
+    if ( !defined('WB_REL')){
+        $x1 = parse_url(WB_URL);
+        define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
+    }
+    if ( !defined('DOCUMENT_ROOT')) {
+        define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
+        $_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
+    }
+// activate Autoloader
+    if (!class_exists('\bin\Autoloader')) {
+        include __DIR__.'/Autoloader.php';
+    }
+    \bin\Autoloader::doRegister();
+
 if (file_exists(WB_PATH.'/framework/class.database.php')) {
     // sanitize $_SERVER['HTTP_REFERER']
     SanitizeHttpReferer(WB_URL);
@@ -311,16 +331,15 @@
 // register PHPMailer autoloader ---
     $sTmp = dirname(dirname(__FILE__)).'/include/phpmailer/PHPMailerAutoload.php';
     if (!function_exists('PHPMailerAutoload') && is_readable($sTmp)) {
-        require($sTmp);
+        include $sTmp;
     }
 
-    if (!class_exists('database', false)){
-      // load database class
-      require(__DIR__.'/class.database.php');
+//    if (!class_exists('database', false)){
+//      // load database class
+//      require(__DIR__.'/class.database.php');
       // Create database class
       $database = new database();
-      $database->sTablePrefix = TABLE_PREFIX;
-    }
+//    }
 
     // activate frontend OutputFilterApi (initialize.php)
     if (is_readable(WB_PATH .'/modules/output_filter/OutputFilterApi.php')) {
@@ -330,19 +349,6 @@
     } else {
         throw new RuntimeException('missing mandatory global OutputFilterApi!');
     }
-    if (version_compare(PHP_VERSION, '5.4.0', '<')) {
-        @ini_set("magic_quotes_runtime", 0); // Disable magic_quotes_runtime
-        @ini_set("magic_quotes_gpc", 0); // Disable magic_quotes_gpc
-    }
-    if (get_magic_quotes_gpc()) {
-        $unescape = function(&$value, $key) {
-            $value = stripslashes($value);
-        };
-        array_walk_recursive($_POST, $unescape);
-        array_walk_recursive($_GET,  $unescape);
-        array_walk_recursive($_REQUEST, $unescape);
-        array_walk_recursive($_COOKIE, $unescape);
-    }
     // Get website settings (title, keywords, description, header, and footer)
     $sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
     if (($get_settings = $database->query($sql))) {
@@ -356,7 +362,7 @@
             if ($setting_value == 'true') {
                 $setting_value = true;
             }
-            @define($setting_name, $setting_value);
+            defined($setting_name) ? '' : define($setting_name, $setting_value);
             $x++;
         }
     } else {
@@ -365,29 +371,29 @@
     if (!$x) {
         throw new RuntimeException('no settings found');
     }
-    @define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
-    ini_set('display_errors', ((defined('DEBUG')&& (DEBUG==true)) ?'1':'0'));
+    defined('DO_NOT_TRACK') ? '' : define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
+    ini_set('display_errors', ((defined('DEBUG') && (DEBUG==true)) ?'1':'0'));
 
-    if (!defined('DEBUG')){ define('DEBUG', false); }
-    $string_file_mode = defined('STRING_FILE_MODE')?STRING_FILE_MODE:'0644';
-    @define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
-    $string_dir_mode = defined('STRING_DIR_MODE')?STRING_DIR_MODE:'0755';
-    @define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
+    defined('DEBUG') ? '' : define('DEBUG', false);
+    $string_file_mode = defined('STRING_FILE_MODE') ? STRING_FILE_MODE : '0644';
+    defined('OCTAL_FILE_MODE') ? '' : define('OCTAL_FILE_MODE', (int) octdec($string_file_mode));
+    $string_dir_mode = defined('STRING_DIR_MODE') ? STRING_DIR_MODE : '0755';
+    defined('OCTAL_DIR_MODE')  ? '' : define('OCTAL_DIR_MODE',  (int) octdec($string_dir_mode));
 //    $sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
 //    $sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
 //    require_once($sSecMod);
-    if (!defined("WB_INSTALL_PROCESS")) {
+    if (!defined('WB_INSTALL_PROCESS')) {
     // get CAPTCHA and ASP settings
         $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
         if (($get_settings = $database->query($sql)) &&
             ($setting = $get_settings->fetchRow(MYSQLI_ASSOC))
         ) {
-            @define('ENABLED_CAPTCHA', (($setting['enabled_captcha'] == '1') ? true : false));
-            @define('ENABLED_ASP', (($setting['enabled_asp'] == '1') ? true : false));
-            @define('CAPTCHA_TYPE', $setting['captcha_type']);
-            @define('ASP_SESSION_MIN_AGE', (int)$setting['asp_session_min_age']);
-            @define('ASP_VIEW_MIN_AGE', (int)$setting['asp_view_min_age']);
-            @define('ASP_INPUT_MIN_AGE', (int)$setting['asp_input_min_age']);
+            defined('ENABLED_CAPTCHA')     ? '' : define('ENABLED_CAPTCHA',     (bool) ($setting['enabled_captcha'] == '1'));
+            defined('ENABLED_ASP')         ? '' : define('ENABLED_ASP',         (bool) ($setting['enabled_asp'] == '1'));
+            defined('CAPTCHA_TYPE')        ? '' : define('CAPTCHA_TYPE',        $setting['captcha_type']);
+            defined('ASP_SESSION_MIN_AGE') ? '' : define('ASP_SESSION_MIN_AGE', (int) $setting['asp_session_min_age']);
+            defined('ASP_VIEW_MIN_AGE')    ? '' : define('ASP_VIEW_MIN_AGE',    (int) $setting['asp_view_min_age']);
+            defined('ASP_INPUT_MIN_AGE')   ? '' : define('ASP_INPUT_MIN_AGE',   (int) $setting['asp_input_min_age']);
         } else {
             throw new RuntimeException('CAPTCHA-Settings not found');
         }
@@ -442,9 +448,9 @@
             require $slangFile;
         }
     }
-    if (!class_exists('Translate', false)) {
-        include __DIR__.'/Translate.php';
-    }
+//    if (!class_exists('Translate', false)) {
+//        include __DIR__.'/Translate.php';
+//    }
     $oTrans = Translate::getInstance();
     $oTrans->initialize(array('EN', DEFAULT_LANGUAGE, LANGUAGE), $sCachePath); // 'none'
     // Get users timezone
@@ -472,12 +478,3 @@
     define('EDIT_ONE_SECTION', false);
     define('EDITOR_WIDTH', 0);
 }
-
-function newAdmin($section_name= '##skip##', $section_permission = 'start', $auto_header = true, $auto_auth = true)
-{
-    if (isset($GLOBALS['admin']) && $GLOBALS['admin'] instanceof admin) {
-        unset($GLOBALS['admin']);
-        usleep(10000);
-    }
-    return new admin($section_name, $section_permission, $auto_header, $auto_auth);
-}
