]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Constants rewritten (internal TODO)
[mailer.git] / inc / functions.php
index db721a542e5b3e9aaa02ab60781e010421b0aeb1..361b71180b06a5c4ac1e1adf9bb2fa1fb5e276fd 100644 (file)
@@ -44,7 +44,11 @@ if (!defined('__SECURITY')) {
 // 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;
+       global $OUTPUT, $username;
+
+       // Prepare IP number and User Agent
+       $REMOTE_ADDR     = detectRemoteAddr();
+       $HTTP_USER_AGENT = detectUserAgent();
 
        // Do we have HTML-Code here?
        if (!empty($HTML)) {
@@ -58,7 +62,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
                                        outputRawCode($HTML);
 
                                        // That's why you don't need any \n at the end of your HTML code... :-)
-                                       if ($newLine) echo "\n";
+                                       if ($newLine) print("\n");
                                } else {
                                        // Render mode for old or lame servers...
                                        $OUTPUT .= $HTML;
@@ -74,22 +78,22 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 
                                // The same as above... ^
                                outputRawCode($HTML);
-                               if ($newLine) echo "\n";
+                               if ($newLine) print("\n");
                                break;
 
                        default:
                                // Huh, something goes wrong or maybe you have edited config.php ???
-                               app_die(__FUNCTION__, __LINE__, "<strong>{--FATAL_ERROR--}:</strong> {--LANG_NO_RENDER_DIRECT--}");
+                               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)) {
                // Headers already sent?
                if (headers_sent()) {
                        // Log this error
-                       DEBUG_LOG(__FUNCTION__, __LINE__, "Headers already sent! We need debug backtrace here.");
+                       DEBUG_LOG(__FUNCTION__, __LINE__, 'Headers already sent! We need debug backtrace here.');
 
                        // Trigger an user error
-                       debug_report_bug("Headers are already sent!");
+                       debug_report_bug('Headers are already sent!');
                } // END - if
 
                // Output cached HTML code
@@ -121,9 +125,10 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
                // Compile and run finished rendered HTML code
                while (strpos($OUTPUT, '{!') > 0) {
                        // Replace _MYSQL_PREFIX
-                       $OUTPUT = str_replace("{!_MYSQL_PREFIX!}", getConfig('_MYSQL_PREFIX'), $OUTPUT);
+                       $OUTPUT = str_replace('{!_MYSQL_PREFIX!}', getConfig('_MYSQL_PREFIX'), $OUTPUT);
 
                        // Prepare the content and eval() it...
+                       $content = array();
                        $newContent = '';
                        $eval = "\$newContent = \"".COMPILE_CODE(smartAddSlashes($OUTPUT))."\";";
                        eval($eval);
@@ -158,7 +163,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 // Output the raw HTML code
 function outputRawCode ($HTML) {
        // Output stripped HTML code to avoid broken JavaScript code, etc.
-       echo stripslashes(stripslashes($HTML));
+       print(stripslashes(stripslashes($HTML)));
 
        // Flush the output if only constant('_OB_CACHING') is not 'on'
        if (constant('_OB_CACHING') != 'on') {
@@ -214,27 +219,29 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
        // @TODO Remove this sanity-check if all is fine
        if (!is_bool($return)) debug_report_bug('return is not bool (' . gettype($return) . ')');
 
+       // Prepare IP number and User Agent
+       $REMOTE_ADDR     = detectRemoteAddr();
+       $HTTP_USER_AGENT = detectUserAgent();
+
        // Add more variables which you want to use in your template files
        global $DATA, $username;
 
-       // Get whole config array
-       $_CONFIG = getConfigArray();
-
        // Make all template names lowercase
        $template = strtolower($template);
 
        // Count the template load
        incrementConfigEntry('num_templates');
 
-       // Prepare IP number and User Agent
-       $REMOTE_ADDR     = detectRemoteAddr();
-       if (!defined('REMOTE_ADDR')) define('REMOTE_ADDR', $REMOTE_ADDR);
-       $HTTP_USER_AGENT = detectUserAgent();
-
        // Init some data
        $ret = '';
        if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
 
+       // Generate date/time string
+       $date_time = generateDateTime(time(), '1');
+
+       // Is content an array
+       if (is_array($content)) $content['date_time'] = $date_time;
+
        // @DEPRECATED Try to rewrite the if() condition
        if ($template == 'member_support_form') {
                // Support request of a member
@@ -263,11 +270,8 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
                SQL_FREERESULT($result);
        } // END - if
 
-       // Generate date/time string
-       $date_time = generateDateTime(time(), '1');
-
        // Base directory
-       $basePath = sprintf("%stemplates/%s/html/", constant('PATH'), getLanguage());
+       $basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage());
        $mode = '';
 
        // Check for admin/guest/member templates
@@ -339,9 +343,13 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
                // Do we have to compile the code?
                $ret = '';
                if ((strpos($tmpl_file, "\$") !== false) || (strpos($tmpl_file, '{--') !== false) || (strpos($tmpl_file, '--}') > 0)) {
-                       // Okay, compile it!
-                       $tmpl_file = "\$ret=\"".COMPILE_CODE(smartAddSlashes($tmpl_file))."\";";
-                       eval($tmpl_file);
+                       // Compile it
+                       $eval = "\$ret = \"".COMPILE_CODE(smartAddSlashes($tmpl_file))."\";";
+                       eval($eval);
+                       // NEW WAY: $ret = str_replace("\$content", "\$GLOBALS[compile][".$template."]", $tmpl_file);
+                       // NEW WAY: $ret = str_replace("\$DATA", "\$GLOBALS[data][".$template."]", $ret);
+                       // NEW WAY: $GLOBALS['compile'][$template] = $content;
+                       // NEW WAY: $GLOBALS['data'][$template] = $DATA;
                } else {
                        // Simply return loaded code
                        $ret = $tmpl_file;
@@ -386,7 +394,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
 
 // Send mail out to an email address
 function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail},SUBJECT={$subject}<br />\n";
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail},SUBJECT={$subject}<br />");
 
        // Compile subject line (for POINTS constant etc.)
        $eval = "\$subject = decodeEntities(\"".COMPILE_CODE(smartAddSlashes($subject))."\");";
@@ -403,7 +411,7 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
                        // Load email address
                        $result_email = SQL_QUERY_ESC("SELECT `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
                                array(bigintval($toEmail)), __FUNCTION__, __LINE__);
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result_email)."<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result_email)."<br />");
 
                        // Does the user exist?
                        if (SQL_NUMROWS($result_email)) {
@@ -411,7 +419,7 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
                                list($toEmail) = SQL_FETCHROW($result_email);
                        } else {
                                // Set webmaster
-                               $toEmail = constant('WEBMASTER');
+                               $toEmail = getConfig('WEBMASTER');
                        }
 
                        // Free result
@@ -419,9 +427,9 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
                }
        } elseif ($toEmail == '0') {
                // Is the webmaster!
-               $toEmail = constant('WEBMASTER');
+               $toEmail = getConfig('WEBMASTER');
        }
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />\n";
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />");
 
        // Check for PHPMailer or debug-mode
        if (!checkPhpMailerUsage()) {
@@ -469,7 +477,7 @@ Message : " . $message."
                sendRawEmail($toEmail, $subject, $message, $mailHeader);
        } elseif ($HTML == 'N') {
                // Problem found!
-               sendRawEmail(constant('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
+               sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
        }
 }
 
@@ -490,7 +498,7 @@ function sendRawEmail ($toEmail, $subject, $message, $from) {
 
                // get new instance
                $mail = new PHPMailer();
-               $mail->PluginDir  = sprintf("%sinc/phpmailer/", constant('PATH'));
+               $mail->PluginDir  = sprintf("%sinc/phpmailer/", getConfig('PATH'));
 
                $mail->IsSMTP();
                $mail->SMTPAuth   = true;
@@ -499,11 +507,11 @@ function sendRawEmail ($toEmail, $subject, $message, $from) {
                $mail->Username   = getConfig('SMTP_USER');
                $mail->Password   = getConfig('SMTP_PASSWORD');
                if (empty($from)) {
-                       $mail->From = constant('WEBMASTER');
+                       $mail->From = getConfig('WEBMASTER');
                } else {
                        $mail->From = $from;
                }
-               $mail->FromName   = constant('MAIN_TITLE');
+               $mail->FromName   = getConfig('MAIN_TITLE');
                $mail->Subject    = $subject;
                if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($message) != $message)) {
                        $mail->Body       = $message;
@@ -514,9 +522,9 @@ function sendRawEmail ($toEmail, $subject, $message, $from) {
                        $mail->Body       = decodeEntities($message);
                }
                $mail->AddAddress($toEmail, '');
-               $mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE'));
-               $mail->AddCustomHeader('Errors-To:' . constant('WEBMASTER'));
-               $mail->AddCustomHeader('X-Loop:' . constant('WEBMASTER'));
+               $mail->AddReplyTo(getConfig('WEBMASTER'), getConfig('MAIN_TITLE'));
+               $mail->AddCustomHeader('Errors-To:' . getConfig('WEBMASTER'));
+               $mail->AddCustomHeader('X-Loop:' . getConfig('WEBMASTER'));
                $mail->Send();
        } else {
                // Use legacy mail() command
@@ -710,7 +718,7 @@ function translateUserStatus ($status) {
 // Generates an URL for the dereferer
 function DEREFERER ($URL) {
        // Don't de-refer our own links!
-       if (substr($URL, 0, strlen(constant('URL'))) != constant('URL')) {
+       if (substr($URL, 0, strlen(getConfig('URL'))) != getConfig('URL')) {
                // De-refer this link
                $URL = 'modules.php?module=loader&amp;url=' . encodeString(compileUriCode($URL));
        } // END - if
@@ -722,7 +730,7 @@ function DEREFERER ($URL) {
 // Generates an URL for the frametester
 function FRAMETESTER ($URL) {
        // Prepare frametester URL
-       $frametesterUrl = sprintf("{!URL!}/modules.php?module=frametester&amp;url=%s",
+       $frametesterUrl = sprintf("{?URL?}/modules.php?module=frametester&amp;url=%s",
        encodeString(compileUriCode($URL))
        );
        return $frametesterUrl;
@@ -741,7 +749,7 @@ function countSelection ($array) {
 
 // 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 . '" />';
+       return '<IMG border="0" alt="Code" src="{?URL?}/mailid_top.php?uid=' . $uid . '&amp;' . $type . '=' . $DATA . '&amp;mode=img&amp;code=' . $code . '" />';
 }
 
 // Loads an email template and compiles it
@@ -762,7 +770,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
        $HTTP_USER_AGENT = detectUserAgent();
 
        // Default admin
-       $ADMIN = constant('MAIN_TITLE');
+       $ADMIN = getConfig('MAIN_TITLE');
 
        // Is the admin logged in?
        if (IS_ADMIN()) {
@@ -774,7 +782,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
        } // END - if
 
        // Neutral email address is default
-       $email = constant('WEBMASTER');
+       $email = getConfig('WEBMASTER');
 
        // Expiration in a nice output format
        // NOTE: Use $content[expiration] in your templates instead of $EXPIRATION
@@ -793,25 +801,25 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
        } // END - if
 
        // Load user's data
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):UID={$UID},template={$template},content[]=".gettype($content)."<br />\n";
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):UID={$UID},template={$template},content[]=".gettype($content)."<br />");
        if (($UID > 0) && (is_array($content))) {
                // If nickname extension is installed, fetch nickname as well
                if (EXT_IS_ACTIVE('nickname')) {
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />");
                        // Load nickname
                        $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email`, `nickname` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
                                array(bigintval($UID)), __FUNCTION__, __LINE__);
                } else {
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />");
                        /// Load normal data
                        $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
                                array(bigintval($UID)), __FUNCTION__, __LINE__);
                }
 
                // Fetch and merge data
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - PRE<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - PRE<br />");
                $content = merge_array($content, SQL_FETCHARRAY($result));
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - AFTER<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - AFTER<br />");
 
                // Free result
                SQL_FREERESULT($result);
@@ -827,7 +835,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
        $DATA['email'] = $email;
 
        // Base directory
-       $basePath = sprintf("%stemplates/%s/emails/", constant('PATH'), getLanguage());
+       $basePath = sprintf("%stemplates/%s/emails/", getConfig('PATH'), getLanguage());
 
        // Check for admin/guest/member templates
        if (strpos($template, 'admin_') > -1) {
@@ -918,7 +926,7 @@ function redirectToUrl ($URL) {
        // Check if http(s):// is there
        if ((substr($URL, 0, 7) != 'http://') && (substr($URL, 0, 8) != 'https://')) {
                // Make all URLs full-qualified
-               $URL = constant('URL') . '/' . $URL;
+               $URL = getConfig('URL') . '/' . $URL;
        } // END - if
 
        // Three different debug ways...
@@ -930,7 +938,7 @@ function redirectToUrl ($URL) {
        $rel = ' rel="external"';
 
        // Do we have internal or external URL?
-       if (substr($URL, 0, strlen(constant('URL'))) == constant('URL')) {
+       if (substr($URL, 0, strlen(getConfig('URL'))) == getConfig('URL')) {
                // Own (=internal) URL
                $rel = '';
        } // END - if
@@ -998,11 +1006,11 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
        if ($constants === true) {
                // BEFORE 0.2.1 : Language and data constants
                // WITH 0.2.1+  : Only language constants
-               $code = str_replace('{--','".', str_replace('--}','."', $code));
+               $code = str_replace('{--', "\".getMessage('", str_replace('--}', "').\"", $code));
 
                // BEFORE 0.2.1 : Not used
                // WITH 0.2.1+  : Data constants
-               $code = str_replace('{!','".', str_replace("!}", '."', $code));
+               $code = str_replace('{!', "\".constant('", str_replace("!}", "').\"", $code));
        } // END - if
 
        // Compile QUOT and other non-HTML codes
@@ -1015,7 +1023,7 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
        if ($simple) $code = str_replace("'", '{QUOT}', $code);
 
        // Find $content[bla][blub] entries
-       preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
+       preg_match_all('/\$(content|GLOBALS|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
 
        // Are some matches found?
        if ((count($matches) > 0) && (count($matches[0]) > 0)) {
@@ -1031,35 +1039,50 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
                                $test = substr($found, 0, strlen($match));
 
                                // Does this entry exist?
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):found={$found},match={$match},set={$set}<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):found={$found},match={$match},set={$set}<br />");
                                if ($test == $match) {
                                        // Match found!
-                                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):fuzzyFound!<br />\n";
+                                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):fuzzyFound!<br />");
                                        $fuzzyFound = true;
                                        break;
                                } // END - if
                        } // END - foreach
 
                        // Skip this entry?
-                       if ($fuzzyFound) continue;
+                       if ($fuzzyFound === true) continue;
 
                        // Take all string elements
                        if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_" . $matches[4][$key]]))) {
                                // Replace it in the code
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):key={$key},match={$match}<br />\n";
-                               $newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match);
+                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):key={$key},match={$match}<br />");
+                               $newMatch = str_replace('[', "['", str_replace(']', "']", $match));
                                $code = str_replace($match, "\"." . $newMatch.".\"", $code);
-                               $matchesFound[$key."_" . $matches[4][$key]] = 1;
+                               $matchesFound[$key . '_' . $matches[4][$key]] = 1;
                                $matchesFound[$match] = 1;
                        } elseif (!isset($matchesFound[$match])) {
                                // Not yet replaced!
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):match={$match}<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):match={$match}<br />");
                                $code = str_replace($match, "\"." . $match.".\"", $code);
                                $matchesFound[$match] = 1;
                        }
                } // END - foreach
        } // END - if
 
+       // Compile {?some_var?} to getConfig('some_var')
+       preg_match_all('/\{\?(([a-zA-Z0-9-_]+)*)\?\}/', $code, $matches);
+
+       // Some entries found?
+       if ((count($matches) > 0) && (count($matches[0]) > 0)) {
+               // Replace all matches
+               foreach ($matches[0] as $key => $match) {
+                       // Replace it
+                       //* DEBUG: */ if ($key == 0) { print '<pre>'; debug_print_backtrace(); print '</pre>'; }
+                       //* DEBUG: */ print htmlentities($match).'['.strlen($match).']='.$matches[1][$key].'='.getConfig($matches[1][$key]).' (key='.$key.',len='.strlen($code).')<br />';
+                       $code = str_replace($match, getConfig($matches[1][$key]), $code);
+                       //* DEBUG: */ if (($match == '{?URL?}') && (strlen($code) > 10000)) die('<pre>'.htmlentities($code).'</pre>');
+               } // END - foreach
+       } // END - if
+
        // Return compiled code
        return $code;
 }
@@ -1234,12 +1257,8 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') {
 // Optional   : $DATA
 //
 function generateRandomCode ($length, $code, $uid, $DATA = '') {
-       // Fix missing _MAX constant
-       // @TODO Rewrite this unnice code
-       if (!defined('_MAX')) define('_MAX', 15235);
-
        // Build server string
-       $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('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(getConfig('PATH').'inc/databases.php');
 
        // Build key string
        $keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY');
@@ -1266,13 +1285,13 @@ function generateRandomCode ($length, $code, $uid, $DATA = '') {
                $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(getConfig('_ADD'))) / pi();
+               $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(getConfig('_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 % 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(getConfig('_ADD'))) / pi();
+               $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getConfig('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
        }
 
        // At least 10 numbers shall be secure enought!
@@ -1313,11 +1332,11 @@ function GENERATE_IMAGE ($img_code, $headerSent=true) {
                return;
        } elseif (!$headerSent) {
                // Return in an HTML code code
-               return "<img src=\"{!URL!}/img.php?code=" . $img_code."\" alt=\"Image\" />\n";
+               return "<img src=\"{?URL?}/img.php?code=" . $img_code."\" alt=\"Image\" />\n";
        }
 
        // Load image
-       $img = sprintf("%s/theme/%s/images/code_bg.%s", constant('PATH'), getCurrentTheme(), getConfig('img_type'));
+       $img = sprintf("%s/theme/%s/images/code_bg.%s", getConfig('PATH'), getCurrentTheme(), getConfig('img_type'));
        if (isFileReadable($img)) {
                // Switch image type
                switch (getConfig('img_type'))
@@ -1373,25 +1392,25 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
 
        // First of all years...
        $Y = abs(floor($timestamp / (31536000 + $SWITCH)));
-       //* DEBUG: */ print("Y={$Y}<br />\n");
+       //* DEBUG: */ print("Y={$Y}<br />");
        // Next months...
        $M = abs(floor($timestamp / 2628000 - $Y * 12));
-       //* DEBUG: */ print("M={$M}<br />\n");
+       //* DEBUG: */ print("M={$M}<br />");
        // Next weeks
        $W = abs(floor($timestamp / 604800 - $Y * ((365 + $SWITCH / getConfig('one_day')) / 7) - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) / 7)));
-       //* DEBUG: */ print("W={$W}<br />\n");
+       //* DEBUG: */ print("W={$W}<br />");
        // Next days...
        $D = abs(floor($timestamp / 86400 - $Y * (365 + $SWITCH / getConfig('one_day')) - ($M / 12 * (365 + $SWITCH / getConfig('one_day'))) - $W * 7));
-       //* DEBUG: */ print("D={$D}<br />\n");
+       //* DEBUG: */ print("D={$D}<br />");
        // Next hours...
        $h = abs(floor($timestamp / 3600 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24) - $W * 7 * 24 - $D * 24));
-       //* DEBUG: */ print("h={$h}<br />\n");
+       //* DEBUG: */ print("h={$h}<br />");
        // Next minutes..
        $m = abs(floor($timestamp / 60 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 60 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 60) - $W * 7 * 24 * 60 - $D * 24 * 60 - $h * 60));
-       //* DEBUG: */ print("m={$m}<br />\n");
+       //* DEBUG: */ print("m={$m}<br />");
        // And at last seconds...
        $s = abs(floor($timestamp - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600) - $W * 7 * 24 * 3600 - $D * 24 * 3600 - $h * 3600 - $m * 60));
-       //* DEBUG: */ print("s={$s}<br />\n");
+       //* DEBUG: */ print("s={$s}<br />");
 
        // Is seconds zero and time is < 60 seconds?
        if (($s == 0) && ($timestamp < 60)) {
@@ -1685,7 +1704,7 @@ function ADD_EMAIL_NAV ($PAGES, $offset, $show_form, $colspan, $return=false) {
                        $NAV .= "<strong>-";
                } else {
                        // Open anchor tag and add base URL
-                       $NAV .= "<a href=\"{!URL!}/modules.php?module=admin&amp;what=" . getWhat()."&amp;page=" . $page."&amp;offset=" . $offset;
+                       $NAV .= "<a href=\"{?URL?}/modules.php?module=admin&amp;what=" . getWhat()."&amp;page=" . $page."&amp;offset=" . $offset;
 
                        // Add userid when we shall show all mails from a single member
                        if ((REQUEST_ISSET_GET('uid')) && (bigintval(REQUEST_GET('uid')) > 0)) $NAV .= "&amp;uid=".bigintval(REQUEST_GET('uid'));
@@ -1729,7 +1748,7 @@ function ADD_EMAIL_NAV ($PAGES, $offset, $show_form, $colspan, $return=false) {
 // Extract host from script name
 function extractHostnameFromUrl (&$script) {
        // Use default SERVER_URL by default... ;) So?
-       $url = constant('SERVER_URL');
+       $url = getConfig('SERVER_URL');
 
        // Is this URL valid?
        if (substr($script, 0, 7) == 'http://') {
@@ -1745,7 +1764,7 @@ function extractHostnameFromUrl (&$script) {
        if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/'));
 
        // Generate relative URL
-       //* DEBUG: */ print("SCRIPT=" . $script."<br />\n");
+       //* DEBUG: */ print("SCRIPT=" . $script."<br />");
        if (substr(strtolower($script), 0, 7) == 'http://') {
                // But only if http:// is in front!
                $script = substr($script, (strlen($url) + 7));
@@ -1754,7 +1773,7 @@ function extractHostnameFromUrl (&$script) {
                $script = substr($script, (strlen($url) + 8));
        }
 
-       //* DEBUG: */ print("SCRIPT=" . $script."<br />\n");
+       //* DEBUG: */ print("SCRIPT=" . $script."<br />");
        if (substr($script, 0, 1) == '/') $script = substr($script, 1);
 
        // Return host name
@@ -1772,11 +1791,11 @@ function sendGetRequest ($script) {
        // Generate GET request header
        $request  = "GET /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL');
        $request .= "Host: " . $host . getConfig('HTTP_EOL');
-       $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL');
-       if (defined('FULL_VERSION')) {
-               $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL');
+       $request .= "Referer: " . getConfig('URL') . "/admin.php" . getConfig('HTTP_EOL');
+       if (isConfigEntrySet('FULL_VERSION')) {
+               $request .= "User-Agent: " . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL');
        } else {
-               $request .= "User-Agent: " . constant('TITLE') . "/?.?.?" . getConfig('HTTP_EOL');
+               $request .= "User-Agent: " . getConfig('TITLE') . '/' . getConfig('VERSION') . getConfig('HTTP_EOL');
        }
        $request .= "Content-Type: text/plain" . getConfig('HTTP_EOL');
        $request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL');
@@ -1810,8 +1829,8 @@ function sendPostRequest ($script, $postData) {
        // Generate POST request header
        $request  = "POST /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL');
        $request .= "Host: " . $host . getConfig('HTTP_EOL');
-       $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL');
-       $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL');
+       $request .= "Referer: " . getConfig('URL') . "/admin.php" . getConfig('HTTP_EOL');
+       $request .= "User-Agent: " . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL');
        $request .= "Content-type: application/x-www-form-urlencoded" . getConfig('HTTP_EOL');
        $request .= "Content-length: " . strlen($data) . getConfig('HTTP_EOL');
        $request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL');
@@ -1843,7 +1862,7 @@ function sendRawRequest ($host, $request) {
        } // END - if
 
        // Open connection
-       //* DEBUG: */ die("SCRIPT=" . $script."<br />\n");
+       //* DEBUG: */ die("SCRIPT=" . $script."<br />");
        if ($useProxy === true) {
                // Connect to host through proxy connection
                $fp = @fsockopen(COMPILE_CODE(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
@@ -1961,11 +1980,11 @@ function isEmailValid ($email) {
 function isUrlValid ($URL, $compile=true) {
        // Trim URL a little
        $URL = trim(urldecode($URL));
-       //* DEBUG: */ echo $URL."<br />";
+       //* DEBUG: */ OUTPUT_HTML($URL."<br />");
 
        // Compile some chars out...
        if ($compile === true) $URL = compileUriCode($URL, false, false, false);
-       //* DEBUG: */ echo $URL."<br />";
+       //* DEBUG: */ OUTPUT_HTML($URL."<br />");
 
        // Check for the extension filter
        if (EXT_IS_ACTIVE('filter')) {
@@ -1987,8 +2006,8 @@ function generateMemberAdminActionLinks ($uid, $status = '') {
        $eval = "\$OUT = \"[&nbsp;";
 
        foreach ($TARGETS as $tar) {
-               $eval .= "<span class=\\\"admin_user_link\\\"><a href=\\\"{!URL!}/modules.php?module=admin&amp;what=" . $tar."&amp;uid=" . $uid."\\\" title=\\\"{--ADMIN_LINK_";
-               //* DEBUG: */ echo "*" . $tar.'/' . $status."*<br />\n";
+               $eval .= "<span class=\\\"admin_user_link\\\"><a href=\\\"{?URL?}/modules.php?module=admin&amp;what=" . $tar."&amp;uid=" . $uid."\\\" title=\\\"{--ADMIN_LINK_";
+               //* DEBUG: */ OUTPUT_HTML("*" . $tar.'/' . $status."*<br />");
                if (($tar == "lock_user") && ($status == 'LOCKED')) {
                        // Locked accounts shall be unlocked
                        $eval .= "UNLOCK_USER";
@@ -2069,19 +2088,19 @@ function generateHash ($plainText, $salt = '') {
 
                // Generate SHA1 sum from modula of number and the prime number
                $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 />";
+               //* DEBUG: */ OUTPUT_HTML("SHA1=" . $sha1." (".strlen($sha1).")<br />");
                $sha1 = scrambleString($sha1);
-               //* DEBUG: */ echo "Scrambled=" . $sha1." (".strlen($sha1).")<br />";
+               //* DEBUG: */ OUTPUT_HTML("Scrambled=" . $sha1." (".strlen($sha1).")<br />");
                //* DEBUG: */ $sha1b = descrambleString($sha1);
-               //* DEBUG: */ echo "Descrambled=" . $sha1b." (".strlen($sha1b).")<br />";
+               //* DEBUG: */ OUTPUT_HTML("Descrambled=" . $sha1b." (".strlen($sha1b).")<br />");
 
                // Generate the password salt string
                $salt = substr($sha1, 0, getConfig('salt_length'));
-               //* DEBUG: */ echo $salt." (".strlen($salt).")<br />";
+               //* DEBUG: */ OUTPUT_HTML($salt." (".strlen($salt).")<br />");
        } else {
                // Use given salt
                $salt = substr($salt, 0, getConfig('salt_length'));
-               //* DEBUG: */ echo "GIVEN={$salt}<br />\n";
+               //* DEBUG: */ OUTPUT_HTML("GIVEN={$salt}<br />");
        }
 
        // Return hash
@@ -2106,7 +2125,7 @@ function scrambleString($str) {
        }
 
        // Scramble string here
-       //* DEBUG: */ echo "***Original=" . $str."***<br />";
+       //* DEBUG: */ OUTPUT_HTML("***Original=" . $str."***<br />");
        for ($idx = 0; $idx < strlen($str); $idx++) {
                // Get char on scrambled position
                $char = substr($str, $scrambleNums[$idx], 1);
@@ -2116,7 +2135,7 @@ function scrambleString($str) {
        } // END - for
 
        // Return scrambled string
-       //* DEBUG: */ echo "***Scrambled=" . $scrambled."***<br />";
+       //* DEBUG: */ OUTPUT_HTML("***Scrambled=" . $scrambled."***<br />");
        return $scrambled;
 }
 
@@ -2132,15 +2151,15 @@ function descrambleString($str) {
        if (count($scrambleNums) != 40) return $str;
 
        // Begin descrambling
-       $orig = str_repeat(" ", 40);
-       //* DEBUG: */ echo "+++Scrambled=" . $str."+++<br />";
+       $orig = str_repeat(' ', 40);
+       //* DEBUG: */ OUTPUT_HTML("+++Scrambled=" . $str."+++<br />");
        for ($idx = 0; $idx < 40; $idx++) {
                $char = substr($str, $idx, 1);
                $orig = substr_replace($orig, $char, $scrambleNums[$idx], 1);
        } // END - for
 
        // Return scrambled string
-       //* DEBUG: */ echo "+++Original=" . $orig."+++<br />";
+       //* DEBUG: */ OUTPUT_HTML("+++Original=" . $orig."+++<br />");
        return $orig;
 }
 
@@ -2188,19 +2207,19 @@ function generatePassString ($passHash) {
                        }
                        $mod = substr(round($mod), 0, 4);
                        $mod = str_repeat('0', 4-strlen($mod)) . $mod;
-                       //* DEBUG: */ echo "*" . $start.'=' . $mod."*<br />";
+                       //* DEBUG: */ OUTPUT_HTML("*" . $start.'=' . $mod."*<br />");
                        $start += 4;
                        $newHash .= $mod;
                } // END - for
 
                //* DEBUG: */ print($passHash."<br />" . $newHash." (".strlen($newHash).')');
                $ret = generateHash($newHash, getConfig('master_salt'));
-               //* DEBUG: */ print($ret."<br />\n");
+               //* DEBUG: */ print($ret."<br />");
        } else {
                // Hash it simple
-               //* DEBUG: */ echo "--" . $passHash."--<br />\n";
+               //* DEBUG: */ OUTPUT_HTML("--" . $passHash."--<br />");
                $ret = md5($passHash);
-               //* DEBUG: */ echo "++" . $ret."++<br />\n";
+               //* DEBUG: */ OUTPUT_HTML("++" . $ret."++<br />");
        }
 
        // Return result
@@ -2286,14 +2305,14 @@ function isBooleanConstantAndTrue ($constName) { // : Boolean
        // In cache?
        if (isset($GLOBALS['cache_array']['const'][$constName])) {
                // Use cache
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-CACHE!<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-CACHE!<br />");
                $res = ($GLOBALS['cache_array']['const'][$constName] === true);
        } else {
                // Check constant
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-RESOLVE!<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-RESOLVE!<br />");
                if (defined($constName)) {
                        // Found!
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-FOUND!<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-FOUND!<br />");
                        $res = (constant($constName) === true);
                } // END - if
 
@@ -2335,13 +2354,13 @@ function getCurrentTheme() {
                } // END - if
        } elseif ((!isInstalled()) && ((isInstalling()) || (getOutputMode() == true)) && ((REQUEST_ISSET_GET('theme')) || (REQUEST_ISSET_POST('theme')))) {
                // Prepare FQFN for checking
-               $theme = sprintf("%stheme/%s/theme.php", constant('PATH'), REQUEST_GET('theme'));
+               $theme = sprintf("%stheme/%s/theme.php", getConfig('PATH'), REQUEST_GET('theme'));
 
                // Installation mode active
                if ((REQUEST_ISSET_GET('theme')) && (isFileReadable($theme))) {
                        // Set cookie from URL data
                        setSession('mxchange_theme', REQUEST_GET('theme'));
-               } elseif (isFileReadable(sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE(REQUEST_POST('theme'))))) {
+               } elseif (isFileReadable(sprintf("%stheme/%s/theme.php", getConfig('PATH'), SQL_ESCAPE(REQUEST_POST('theme'))))) {
                        // Set cookie from posted data
                        setSession('mxchange_theme', SQL_ESCAPE(REQUEST_POST('theme')));
                }
@@ -2430,33 +2449,33 @@ function generateErrorCodeFromUserStatus ($status) {
 // Function to search for the last modifified file
 function searchDirsRecursive ($dir, &$last_changed) {
        // Get dir as array
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):dir=" . $dir."<br />\n";
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):dir=" . $dir."<br />");
        // Does it match what we are looking for? (We skip a lot files already!)
        // RegexPattern to exclude  ., .., .revision,  .svn, debug.log or .cache in the filenames
        $excludePattern = '@(\.revision|debug\.log|\.cache|config\.php)$@';
        $ds = getArrayFromDirectory($dir, '', true, false, array(), '.php', $excludePattern);
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ds[]=".count($ds)."<br />\n";
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ds[]=".count($ds)."<br />");
 
        // Walk through all entries
        foreach ($ds as $d) {
                // Generate proper FQFN
-               $FQFN = str_replace('//', '/', constant('PATH') . $dir. '/'. $d);
+               $FQFN = str_replace('//', '/', getConfig('PATH') . $dir. '/'. $d);
 
                // Is it a file and readable?
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />");
                if (isDirectory($FQFN)) {
                        // $FQFN is a directory so also crawl into this directory
                        $newDir = $d;
                        if (!empty($dir)) $newDir = $dir . '/'. $d;
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):DESCENT: " . $newDir."<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):DESCENT: " . $newDir."<br />");
                        searchDirsRecursive($newDir, $last_changed);
                } elseif (isFileReadable($FQFN)) {
                        // $FQFN is a filename and no directory
                        $time = filemtime($FQFN);
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):File: " . $d." found. (".($last_changed['time'] - $time).")<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):File: " . $d." found. (".($last_changed['time'] - $time).")<br />");
                        if ($last_changed['time'] < $time) {
                                // This file is newer as the file before
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>) - NEWER!<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>) - NEWER!<br />");
                                $last_changed['path_name'] = $FQFN;
                                $last_changed['time'] = $time;
                        } // END - if
@@ -2509,7 +2528,7 @@ function getActualVersion ($type = 'Revision') {
                // Old Version without ext-cache active (deprecated ?)
 
                // FQFN of revision file
-               $FQFN = sprintf("%sinc/cache/.revision", constant('PATH'));
+               $FQFN = sprintf("%sinc/cache/.revision", getConfig('PATH'));
 
                // Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
                if ((REQUEST_ISSET_GET('check_revision_data')) && (REQUEST_GET('check_revision_data') == 'yes')) {
@@ -2654,7 +2673,7 @@ function debug_report_bug ($message = '') {
        if (!empty($message)) {
                // Use and log it
                $debug = sprintf("Note: %s<br />\n",
-               $message
+                       $message
                );
 
                // @TODO Add a little more infos here
@@ -2829,7 +2848,7 @@ function isUrlValidSimple ($url) {
                        // @TODO Are these convertions still required?
                        $pat = str_replace('.', "&#92;&#46;", $pat);
                        $pat = str_replace('@', "&#92;&#64;", $pat);
-                       echo $key."=&nbsp;" . $pat . "<br />";
+                       //* DEBUG: */ OUTPUT_HTML($key."=&nbsp;" . $pat . "<br />");
                } // END - if
 
                // Check if expression matches
@@ -2934,7 +2953,7 @@ function DEBUG_LOG ($funcFile, $line, $message, $force=true) {
                $message = str_replace("\r", '', str_replace("\n", '', $message));
 
                // Log this message away, we better don't call app_die() here to prevent an endless loop
-               $fp = fopen(constant('PATH') . 'inc/cache/debug.log', 'a') or die(__FUNCTION__.'['.__LINE__.']: Cannot write logfile debug.log!');
+               $fp = fopen(getConfig('PATH') . 'inc/cache/debug.log', 'a') or die(__FUNCTION__.'['.__LINE__.']: Cannot write logfile debug.log!');
                fwrite($fp, date('d.m.Y|H:i:s', time()) . '|' . getModule() . '|' . basename($funcFile) . '|' . $line . '|' . strip_tags($message) . "\n");
                fclose($fp);
        } // END - if
@@ -3085,7 +3104,7 @@ function HANDLE_LOGIN_FAILTURES ($accessLevel) {
                // Ignore zero values
                if (getSession('mxchange_' . $accessLevel.'_failures') > 0) {
                        // Non-guest has login failures found, get both data and prepare it for template
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):accessLevel={$accessLevel}<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):accessLevel={$accessLevel}<br />");
                        $content = array(
                                'login_failures' => getSession('mxchange_' . $accessLevel.'_failures'),
                                'last_failure'   => generateDateTime(getSession('mxchange_' . $accessLevel.'_last_fail'), '2')
@@ -3122,7 +3141,7 @@ function rebuildCacheFiles ($cache, $inc = '') {
                        // Is the include there?
                        if (isIncludeReadable($INC)) {
                                // And rebuild it from scratch
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): inc={$inc} - LOADED!<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): inc={$inc} - LOADED!<br />");
                                loadInclude($INC);
                        } else {
                                // Include not found!
@@ -3423,20 +3442,20 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
        $files = array();
 
        // Open directory
-       $dirPointer = opendir(constant('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.');
+       $dirPointer = opendir(getConfig('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.');
 
        // Read all entries
        while ($baseFile = readdir($dirPointer)) {
                // Exclude '.', '..' and entries in $excludeArray automatically
                if (in_array($baseFile, $excludeArray, true))  {
                        // Exclude them
-                       //* DEBUG: */ print 'excluded=' . $baseFile . "<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML('excluded=' . $baseFile . "<br />");
                        continue;
                } // END - if
 
                // Construct include filename and FQFN
                $fileName = $baseDir . '/' . $baseFile;
-               $FQFN = constant('PATH') . $fileName;
+               $FQFN = getConfig('PATH') . $fileName;
 
                // Remove double slashes
                $FQFN = str_replace('//', '/', $FQFN);
@@ -3444,9 +3463,9 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
                // Check if the base filename matches an exclusion pattern and if the pattern is not empty
                if ((!empty($excludePattern)) && (preg_match($excludePattern, $baseFile, $match))) {
                        // These Lines are only for debugging!!
-                       //* DEBUG: */ print 'baseDir:' . $baseDir . "<br />\n";
-                       //* DEBUG: */ print 'baseFile:' . $baseFile . "<br />\n";
-                       //* DEBUG: */ print 'FQFN:' . $FQFN . "<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML('baseDir:' . $baseDir . "<br />");
+                       //* DEBUG: */ OUTPUT_HTML('baseFile:' . $baseFile . "<br />");
+                       //* DEBUG: */ OUTPUT_HTML('FQFN:' . $FQFN . "<br />");
 
                        // Exclude this one
                        continue;