]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Several more constants rewritten to getConfig()
[mailer.git] / inc / functions.php
index 508112789ff98c0d85f315728fd3e445c60a5aea..34e1aa54fedfbc70905ed34f53126602dfc21d7b 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)) {
@@ -79,17 +83,17 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 
                        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,7 +125,7 @@ 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...
                        $newContent = '';
@@ -214,27 +218,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 +269,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 +342,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;
@@ -411,7 +418,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,7 +426,7 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
                }
        } elseif ($toEmail == '0') {
                // Is the webmaster!
-               $toEmail = constant('WEBMASTER');
+               $toEmail = getConfig('WEBMASTER');
        }
        //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />");
 
@@ -469,7 +476,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 +497,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 +506,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 +521,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 +717,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 +729,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 +748,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 +769,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 +781,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
@@ -827,7 +834,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 +925,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 +937,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 +1005,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
@@ -1014,8 +1021,22 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
        // But shall I keep simple quotes for later use?
        if ($simple) $code = str_replace("'", '{QUOT}', $code);
 
+       // 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 $match.'='.$matches[1][$key].' ('.$key.')<br />';
+                       $code = str_replace($match, getConfig($matches[1][$key]), $code);
+               } // END - foreach
+       } // END - if
+
        // 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)) {
@@ -1041,15 +1062,15 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
                        } // 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: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):key={$key},match={$match}<br />");
-                               $newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match);
+                               $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!
@@ -1234,12 +1255,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 +1283,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 +1330,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'))
@@ -1685,7 +1702,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 +1746,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://') {
@@ -1772,12 +1789,8 @@ 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');
-       } else {
-               $request .= "User-Agent: " . constant('TITLE') . "/?.?.?" . 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: text/plain" . getConfig('HTTP_EOL');
        $request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL');
        $request .= "Connection: Close" . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
@@ -1810,8 +1823,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');
@@ -1987,7 +2000,7 @@ 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_";
+               $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
@@ -2335,13 +2348,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')));
                }
@@ -2440,7 +2453,7 @@ function searchDirsRecursive ($dir, &$last_changed) {
        // 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: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />");
@@ -2509,7 +2522,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 +2667,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
@@ -2934,7 +2947,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
@@ -3423,7 +3436,7 @@ 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)) {
@@ -3436,7 +3449,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
 
                // Construct include filename and FQFN
                $fileName = $baseDir . '/' . $baseFile;
-               $FQFN = constant('PATH') . $fileName;
+               $FQFN = getConfig('PATH') . $fileName;
 
                // Remove double slashes
                $FQFN = str_replace('//', '/', $FQFN);