]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Some fixes for surfbar extension (#123), double->single, misc cleanups/fixes
[mailer.git] / inc / functions.php
index d7a327592143bbfefa1a2c89601faf9ff7c9228d..71538ea79815e23daf5961754171266df50ce86d 100644 (file)
@@ -230,10 +230,10 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
        if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
 
        // @DEPRECATED Try to rewrite the if() condition
-       if ($template == "member_support_form") {
+       if ($template == 'member_support_form') {
                // Support request of a member
                $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-               array(getUserId()), __FUNCTION__, __LINE__);
+                       array(getUserId()), __FUNCTION__, __LINE__);
 
                // Is content an array?
                if (is_array($content)) {
@@ -265,27 +265,27 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
        $mode = '';
 
        // Check for admin/guest/member templates
-       if (strpos($template, "admin_") > -1) {
+       if (strpos($template, 'admin_') > -1) {
                // Admin template found
-               $mode = "admin/";
-       } elseif (strpos($template, "guest_") > -1) {
+               $mode = 'admin/';
+       } elseif (strpos($template, 'guest_') > -1) {
                // Guest template found
-               $mode = "guest/";
-       } elseif (strpos($template, "member_") > -1) {
+               $mode = 'guest/';
+       } elseif (strpos($template, 'member_') > -1) {
                // Member template found
-               $mode = "member/";
-       } elseif (strpos($template, "install_") > -1) {
+               $mode = 'member/';
+       } elseif (strpos($template, 'install_') > -1) {
                // Installation template found
-               $mode = "install/";
-       } elseif (strpos($template, "ext_") > -1) {
+               $mode = 'install/';
+       } elseif (strpos($template, 'ext_') > -1) {
                // Extension template found
-               $mode = "ext/";
-       } elseif (strpos($template, "la_") > -1) {
-               // "Logical-area" template found
-               $mode = "la/";
+               $mode = 'ext/';
+       } elseif (strpos($template, 'la_') > -1) {
+               // 'Logical-area' template found
+               $mode = 'la/';
        } else {
                // Test for extension
-               $test = substr($template, 0, strpos($template, "_"));
+               $test = substr($template, 0, strpos($template, '_'));
                if (EXT_IS_ACTIVE($test)) {
                        // Set extra path to extension's name
                        $mode = $test.'/';
@@ -295,15 +295,15 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
        ////////////////////////
        // Generate file name //
        ////////////////////////
-       $FQFN = $basePath.$mode.$template.".tpl";
+       $FQFN = $basePath . $mode . $template . '.tpl';
 
-       if ((!empty($GLOBALS['what'])) && ((strpos($template, "_header") > 0) || (strpos($template, "_footer") > 0)) && (($mode == "guest/") || ($mode == "member/") || ($mode == "admin/"))) {
+       if ((!empty($GLOBALS['what'])) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) {
                // Select what depended header/footer template file for admin/guest/member area
                $file2 = sprintf("%s%s%s_%s.tpl",
-               $basePath,
-               $mode,
-               $template,
-               SQL_ESCAPE($GLOBALS['what'])
+                       $basePath,
+                       $mode,
+                       $template,
+                       SQL_ESCAPE($GLOBALS['what'])
                );
 
                // Probe for it...
@@ -311,12 +311,12 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
 
                // Remove variable from memory
                unset($file2);
-       }
+       } // END - if
 
        // Does the special template exists?
        if (!isFileReadable($FQFN)) {
                // Reset to default template
-               $FQFN = $basePath.$template.".tpl";
+               $FQFN = $basePath . $template . '.tpl';
        } // END - if
 
        // Now does the final template exists?
@@ -339,7 +339,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
                }
 
                // Add surrounding HTML comments to help finding bugs faster
-               $ret = "<!-- Template ".$template." - Start -->\n".$ret."<!-- Template ".$template." - End -->\n";
+               $ret = "<!-- Template " . $template . " - Start -->\n" . $ret . "<!-- Template " . $template . " - End -->\n";
        } elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
                // Only admins shall see this warning or when installation mode is active
                $ret = "<br /><span class=\"guest_failed\">{--TEMPLATE_404--}</span><br />
@@ -368,12 +368,12 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
                }
        } elseif (isDebugModeEnabled()) {
                // Warning, empty output!
-               return "E:".$template."<br />\n";
+               return "E:" . $template."<br />\n";
        }
 }
 
 // Send mail out to an email address
-function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
+function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail},SUBJECT={$subject}<br />\n";
 
        // Compile subject line (for POINTS constant etc.)
@@ -403,7 +403,7 @@ function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
                        // Free result
                        SQL_FREERESULT($result_email);
                }
-       } elseif ("$toEmail" == '0') {
+       } elseif ($toEmail == '0') {
                // Is the webmaster!
                $toEmail = constant('WEBMASTER');
        }
@@ -414,18 +414,18 @@ function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
                // Not in PHPMailer-Mode
                if (empty($mailHeader)) {
                        // Load email header template
-                       $mailHeader = LOAD_EMAIL_TEMPLATE("header");
+                       $mailHeader = LOAD_EMAIL_TEMPLATE('header');
                } else {
                        // Append header
-                       $mailHeader .= LOAD_EMAIL_TEMPLATE("header");
+                       $mailHeader .= LOAD_EMAIL_TEMPLATE('header');
                }
        } elseif (isDebugModeEnabled()) {
                if (empty($mailHeader)) {
                        // Load email header template
-                       $mailHeader = LOAD_EMAIL_TEMPLATE("header");
+                       $mailHeader = LOAD_EMAIL_TEMPLATE('header');
                } else {
                        // Append header
-                       $mailHeader .= LOAD_EMAIL_TEMPLATE("header");
+                       $mailHeader .= LOAD_EMAIL_TEMPLATE('header');
                }
        }
 
@@ -441,11 +441,11 @@ function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
        if (empty($HTML)) $HTML = 'N';
        if (isDebugModeEnabled()) {
                // In debug mode we want to display the mail instead of sending it away so we can debug this part
-               print("<pre>
+               OUTPUT_HTML("<pre>
 ".htmlentities(trim($mailHeader))."
-To      : ".$toEmail."
-Subject : ".$subject."
-Message : ".$message."
+To      : " . $toEmail."
+Subject : " . $subject."
+Message : " . $message."
 </pre>\n");
        } elseif (($HTML == 'Y') && (EXT_IS_ACTIVE('html_mail'))) {
                // Send mail as HTML away
@@ -467,7 +467,7 @@ function checkPhpMailerUsage() {
 }
 
 // Send out a raw email with PHPMailer class or legacy mail() command
-function sendRawEmail ($toEmail, $subject, $msg, $from) {
+function sendRawEmail ($toEmail, $subject, $message, $from) {
        // Shall we use PHPMailer class or legacy mode?
        if (checkPhpMailerUsage()) {
                // Use PHPMailer class with SMTP enabled
@@ -491,13 +491,13 @@ function sendRawEmail ($toEmail, $subject, $msg, $from) {
                }
                $mail->FromName   = constant('MAIN_TITLE');
                $mail->Subject    = $subject;
-               if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($msg) != $msg)) {
-                       $mail->Body       = $msg;
+               if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($message) != $message)) {
+                       $mail->Body       = $message;
                        $mail->AltBody    = 'Your mail program required HTML support to read this mail!';
                        $mail->WordWrap   = 70;
                        $mail->IsHTML(true);
                } else {
-                       $mail->Body       = decodeEntities($msg);
+                       $mail->Body       = decodeEntities($message);
                }
                $mail->AddAddress($toEmail, '');
                $mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE'));
@@ -506,7 +506,7 @@ function sendRawEmail ($toEmail, $subject, $msg, $from) {
                $mail->Send();
        } else {
                // Use legacy mail() command
-               @mail($toEmail, $subject, decodeEntities($msg), $from);
+               mail($toEmail, $subject, decodeEntities($message), $from);
        }
 }
 
@@ -577,7 +577,7 @@ function generateDateTime ($time, $mode = '0') {
 // Translates Y/N to yes/no
 function translateYesNo ($yn) {
        // Default
-       $translated = "??? (".$yn.')';
+       $translated = "??? (" . $yn.')';
        switch ($yn) {
                case 'Y': $translated = getMessage('YES'); break;
                case 'N': $translated = getMessage('NO'); break;
@@ -815,29 +815,29 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
        // Check for admin/guest/member templates
        if (strpos($template, 'admin_') > -1) {
                // Admin template found
-               $FQFN = $basePath.'admin/'.$template.'.tpl';
+               $FQFN = $basePath.'admin/' . $template.'.tpl';
        } elseif (strpos($template, 'guest_') > -1) {
                // Guest template found
-               $FQFN = $basePath.'guest/'.$template.'.tpl';
+               $FQFN = $basePath.'guest/' . $template.'.tpl';
        } elseif (strpos($template, 'member_') > -1) {
                // Member template found
-               $FQFN = $basePath.'member/'.$template.'.tpl';
+               $FQFN = $basePath.'member/' . $template.'.tpl';
        } else {
                // Test for extension
                $test = substr($template, 0, strpos($template, '_'));
                if (EXT_IS_ACTIVE($test)) {
                        // Set extra path to extension's name
-                       $FQFN = $basePath.$test.'/'.$template.'.tpl';
+                       $FQFN = $basePath . $test.'/' . $template.'.tpl';
                } else {
                        // No special filename
-                       $FQFN = $basePath.$template.'.tpl';
+                       $FQFN = $basePath . $template.'.tpl';
                }
        }
 
        // Does the special template exists?
        if (!isFileReadable($FQFN)) {
                // Reset to default template
-               $FQFN = $basePath.$template.'.tpl';
+               $FQFN = $basePath . $template.'.tpl';
        } // END - if
 
        // Now does the final template exists?
@@ -852,7 +852,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
                eval($tmpl_file);
        } elseif (!empty($template)) {
                // Template file not found!
-               $newContent = "{--TEMPLATE_404--}: ".$template."<br />
+               $newContent = "{--TEMPLATE_404--}: " . $template."<br />
 {--TEMPLATE_CONTENT--}
 <pre>".print_r($content, true)."</pre>
 {--TEMPLATE_DATA--}
@@ -869,7 +869,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
        // Is there some content?
        if (empty($newContent)) {
                // Compiling failed
-               $newContent = "Compiler error for template {$template}!\nUncompiled content:\n".$tmpl_file;
+               $newContent = "Compiler error for template {$template}!\nUncompiled content:\n" . $tmpl_file;
                // Add last error if the required function exists
                if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx.";
        } // END - if
@@ -1027,17 +1027,17 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
                        if ($fuzzyFound) continue;
 
                        // Take all string elements
-                       if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) {
+                       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);
-                               $code = str_replace($match, "\".".$newMatch.".\"", $code);
-                               $matchesFound[$key."_".$matches[4][$key]] = 1;
+                               $newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match);
+                               $code = str_replace($match, "\"." . $newMatch.".\"", $code);
+                               $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";
-                               $code = str_replace($match, "\".".$match.".\"", $code);
+                               $code = str_replace($match, "\"." . $match.".\"", $code);
                                $matchesFound[$match] = 1;
                        }
                } // END - foreach
@@ -1104,30 +1104,30 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') {
 
        if ($type == 'yn') {
                // This is a yes/no selection only!
-               if ($id > 0) $prefix .= "[".$id."]";
-               $OUT .= "    <select name=\"".$prefix."\" class=\"register_select\" size=\"1\">\n";
+               if ($id > 0) $prefix .= "[" . $id."]";
+               $OUT .= "    <select name=\"" . $prefix."\" class=\"register_select\" size=\"1\">\n";
        } else {
                // Begin with regular selection box here
                if (!empty($prefix)) $prefix .= "_";
                $type2 = $type;
-               if ($id > 0) $type2 .= "[".$id."]";
-               $OUT .= "    <select name=\"".strtolower($prefix.$type2)."\" class=\"register_select\" size=\"1\">\n";
+               if ($id > 0) $type2 .= "[" . $id."]";
+               $OUT .= "    <select name=\"".strtolower($prefix . $type2)."\" class=\"register_select\" size=\"1\">\n";
        }
 
        switch ($type) {
                case "day": // Day
                        for ($idx = 1; $idx < 32; $idx++) {
-                               $OUT .= "<option value=\"".$idx."\"";
+                               $OUT .= "<option value=\"" . $idx."\"";
                                if ($default == $idx) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        } // END - for
                        break;
 
                case "month": // Month
                        foreach ($GLOBALS['month_descr'] as $month => $descr) {
-                               $OUT .= "<option value=\"".$month."\"";
+                               $OUT .= "<option value=\"" . $month."\"";
                                if ($default == $month) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$descr."</option>\n";
+                               $OUT .= ">" . $descr."</option>\n";
                        } // END - for
                        break;
 
@@ -1150,19 +1150,19 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') {
                        // Check if the default value is larger than minimum and bigger than actual year
                        if (($default > $minYear) && ($default >= $year)) {
                                for ($idx = $year; $idx < ($year + 11); $idx++) {
-                                       $OUT .= "<option value=\"".$idx."\"";
+                                       $OUT .= "<option value=\"" . $idx."\"";
                                        if ($default == $idx) $OUT .= ' selected="selected"';
-                                       $OUT .= ">".$idx."</option>\n";
+                                       $OUT .= ">" . $idx."</option>\n";
                                } // END - for
                        } elseif ($default == -1) {
                                // Current year minus 1
                                for ($idx = $startYear; $idx <= ($year + 1); $idx++)
                                {
-                                       $OUT .= "<option value=\"".$idx."\">".$idx."</option>\n";
+                                       $OUT .= "<option value=\"" . $idx."\">" . $idx."</option>\n";
                                }
                        } else {
                                // Get current year and subtract the configured minimum age
-                               $OUT .= "<option value=\"".($minYear - 1)."\">&lt;".$minYear."</option>\n";
+                               $OUT .= "<option value=\"".($minYear - 1)."\">&lt;" . $minYear."</option>\n";
                                // Calculate earliest year depending on extension version
                                if (GET_EXT_VERSION('other') >= '0.2.1') {
                                        // Use configured minimum age
@@ -1174,9 +1174,9 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') {
 
                                // Construct year selection list
                                for ($idx = $minYear; $idx <= $year; $idx++) {
-                                       $OUT .= "<option value=\"".$idx."\"";
+                                       $OUT .= "<option value=\"" . $idx."\"";
                                        if ($default == $idx) $OUT .= ' selected="selected"';
-                                       $OUT .= ">".$idx."</option>\n";
+                                       $OUT .= ">" . $idx."</option>\n";
                                } // END - for
                        }
                        break;
@@ -1184,19 +1184,19 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') {
                case "sec":
                case "min":
                        for ($idx = 0; $idx < 60; $idx+=5) {
-                               if (strlen($idx) == 1) $idx = '0'.$idx;
-                               $OUT .= "<option value=\"".$idx."\"";
+                               if (strlen($idx) == 1) $idx = '0' . $idx;
+                               $OUT .= "<option value=\"" . $idx."\"";
                                if ($default == $idx) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        } // END - for
                        break;
 
                case "hour":
                        for ($idx = 0; $idx < 24; $idx++) {
-                               if (strlen($idx) == 1) $idx = '0'.$idx;
-                               $OUT .= "<option value=\"".$idx."\"";
+                               if (strlen($idx) == 1) $idx = '0' . $idx;
+                               $OUT .= "<option value=\"" . $idx."\"";
                                if ($default == $idx) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        } // END - for
                        break;
 
@@ -1232,27 +1232,27 @@ function generateRandomCode ($length, $code, $uid, $DATA = '') {
        if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
 
        // Build string from misc data
-       $data   = $code.getConfig('ENCRYPT_SEPERATOR').$uid.getConfig('ENCRYPT_SEPERATOR').$DATA;
+       $data   = $code.getConfig('ENCRYPT_SEPERATOR') . $uid.getConfig('ENCRYPT_SEPERATOR') . $DATA;
 
        // Add more additional data
        if (isSessionVariableSet('u_hash'))         $data .= getConfig('ENCRYPT_SEPERATOR').getSession('u_hash');
        if (isUserIdSet())                          $data .= getConfig('ENCRYPT_SEPERATOR').getUserId();
        if (isSessionVariableSet('mxchange_theme')) $data .= getConfig('ENCRYPT_SEPERATOR').getSession('mxchange_theme');
        if (isSessionVariableSet('mx_lang'))        $data .= getConfig('ENCRYPT_SEPERATOR').getLanguage();
-       if (isset($GLOBALS['refid']))               $data .= getConfig('ENCRYPT_SEPERATOR').$GLOBALS['refid'];
+       if (isset($GLOBALS['refid']))               $data .= getConfig('ENCRYPT_SEPERATOR') . $GLOBALS['refid'];
 
        // Calculate number for generating the code
        $a = $code + getConfig('_ADD') - 1;
 
        if (isConfigEntrySet('master_hash')) {
                // Generate hash with master salt from modula of number with the prime number and other data
-               $saltedHash = generateHash(($a % 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'));
+               $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();
        } 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));
+               $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();
@@ -1280,7 +1280,7 @@ function bigintval ($num, $castValue = true) {
 
        // Has the whole value changed?
        // @TODO Remove this if() block if all is working fine
-       if ("".$ret."" != ''.$num."") {
+       if ("" . $ret."" != '' . $num."") {
                // Log the values
                debug_report_bug("{$ret}<>{$num}");
        } // END - if
@@ -1296,7 +1296,7 @@ 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
@@ -1343,7 +1343,7 @@ function GENERATE_IMAGE ($img_code, $headerSent=true) {
 function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) {
        // Calculate 2-seconds timestamp
        $stamp = round($timestamp);
-       //* DEBUG: */ print("*".$stamp.'/'.$timestamp."*<br />");
+       //* DEBUG: */ print("*" . $stamp.'/' . $timestamp."*<br />");
 
        // Do we have a leap year?
        $SWITCH = 0;
@@ -1398,7 +1398,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
                );
        } else {
                // Generate table
-               $OUT  = "<div align=\"".$align."\">\n";
+               $OUT  = "<div align=\"" . $align."\">\n";
                $OUT .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_table dashed\">\n";
                $OUT .= "<tr>\n";
 
@@ -1435,94 +1435,94 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
 
                if (ereg('Y', $display) || (empty($display))) {
                        // Generate year selection
-                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"".$prefix."_ye\" size=\"1\">\n";
+                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_ye\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 10; $idx++) {
-                               $OUT .= "    <option class=\"mini_select\" value=\"".$idx."\"";
+                               $OUT .= "    <option class=\"mini_select\" value=\"" . $idx."\"";
                                if ($idx == $Y) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        }
                        $OUT .= "  </select></td>\n";
                } else {
-                       $OUT .= "<INPUT type=\"hidden\" name=\"".$prefix."_ye\" value=\"0\" />\n";
+                       $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_ye\" value=\"0\" />\n";
                }
 
                if (ereg("M", $display) || (empty($display))) {
                        // Generate month selection
-                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"".$prefix."_mo\" size=\"1\">\n";
+                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_mo\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 11; $idx++)
                        {
-                               $OUT .= "  <option class=\"mini_select\" value=\"".$idx."\"";
+                               $OUT .= "  <option class=\"mini_select\" value=\"" . $idx."\"";
                                if ($idx == $M) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        }
                        $OUT .= "  </select></td>\n";
                } else {
-                       $OUT .= "<INPUT type=\"hidden\" name=\"".$prefix."_mo\" value=\"0\" />\n";
+                       $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_mo\" value=\"0\" />\n";
                }
 
                if (ereg("W", $display) || (empty($display))) {
                        // Generate week selection
-                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"".$prefix."_we\" size=\"1\">\n";
+                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_we\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 4; $idx++) {
-                               $OUT .= "  <option class=\"mini_select\" value=\"".$idx."\"";
+                               $OUT .= "  <option class=\"mini_select\" value=\"" . $idx."\"";
                                if ($idx == $W) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        }
                        $OUT .= "  </select></td>\n";
                } else {
-                       $OUT .= "<INPUT type=\"hidden\" name=\"".$prefix."_we\" value=\"0\" />\n";
+                       $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_we\" value=\"0\" />\n";
                }
 
                if (ereg("D", $display) || (empty($display))) {
                        // Generate day selection
-                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"".$prefix."_da\" size=\"1\">\n";
+                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_da\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 31; $idx++) {
-                               $OUT .= "  <option class=\"mini_select\" value=\"".$idx."\"";
+                               $OUT .= "  <option class=\"mini_select\" value=\"" . $idx."\"";
                                if ($idx == $D) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        }
                        $OUT .= "  </select></td>\n";
                } else {
-                       $OUT .= "<INPUT type=\"hidden\" name=\"".$prefix."_da\" value=\"0\">\n";
+                       $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_da\" value=\"0\">\n";
                }
 
                if (ereg("h", $display) || (empty($display))) {
                        // Generate hour selection
-                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"".$prefix."_ho\" size=\"1\">\n";
+                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_ho\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 23; $idx++)      {
-                               $OUT .= "  <option class=\"mini_select\" value=\"".$idx."\"";
+                               $OUT .= "  <option class=\"mini_select\" value=\"" . $idx."\"";
                                if ($idx == $h) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        }
                        $OUT .= "  </select></td>\n";
                } else {
-                       $OUT .= "<INPUT type=\"hidden\" name=\"".$prefix."_ho\" value=\"0\">\n";
+                       $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_ho\" value=\"0\">\n";
                }
 
                if (ereg('m', $display) || (empty($display))) {
                        // Generate minute selection
-                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"".$prefix."_mi\" size=\"1\">\n";
+                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_mi\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 59; $idx++) {
-                               $OUT .= "  <option class=\"mini_select\" value=\"".$idx."\"";
+                               $OUT .= "  <option class=\"mini_select\" value=\"" . $idx."\"";
                                if ($idx == $m) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        }
                        $OUT .= "  </select></td>\n";
                } else {
-                       $OUT .= "<INPUT type=\"hidden\" name=\"".$prefix."_mi\" value=\"0\">\n";
+                       $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_mi\" value=\"0\">\n";
                }
 
                if (ereg("s", $display) || (empty($display))) {
                        // Generate second selection
-                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"".$prefix."_se\" size=\"1\">\n";
+                       $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_se\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 59; $idx++) {
-                               $OUT .= "  <option class=\"mini_select\" value=\"".$idx."\"";
+                               $OUT .= "  <option class=\"mini_select\" value=\"" . $idx."\"";
                                if ($idx == $s) $OUT .= ' selected="selected"';
-                               $OUT .= ">".$idx."</option>\n";
+                               $OUT .= ">" . $idx."</option>\n";
                        }
                        $OUT .= "  </select></td>\n";
                } else {
-                       $OUT .= "<INPUT type=\"hidden\" name=\"".$prefix."_se\" value=\"0\">\n";
+                       $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_se\" value=\"0\">\n";
                }
                $OUT .= "</tr>\n";
                $OUT .= "</table>\n";
@@ -1568,7 +1568,7 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
        $template = trim($template);
 
        // Load email template
-       $msg = LOAD_EMAIL_TEMPLATE($template, $content, $UID);
+       $message = LOAD_EMAIL_TEMPLATE($template, $content, $UID);
 
        // Check which admin shall receive this mail
        $result = SQL_QUERY_ESC("SELECT DISTINCT admin_id FROM `{!_MYSQL_PREFIX!}_admins_mails` WHERE mail_template='%s' ORDER BY admin_id",
@@ -1596,7 +1596,7 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
                if ($aid == '-1') {
                        if (EXT_IS_ACTIVE('events')) {
                                // Add line to user events
-                               EVENTS_ADD_LINE($subj, $msg, $UID);
+                               EVENTS_ADD_LINE($subj, $message, $UID);
                        } else {
                                // Log error for debug
                                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Extension 'events' missing: tpl=%s,subj=%s,UID=%s",
@@ -1618,7 +1618,7 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
 
        // Load email addresses and send away
        while ($content = SQL_FETCHARRAY($result)) {
-               sendEmail($content['email'], $subj, $msg);
+               sendEmail($content['email'], $subj, $message);
        } // END - while
 
        // Free memory
@@ -1657,7 +1657,7 @@ function ADD_EMAIL_NAV ($PAGES, $offset, $show_form, $colspan, $return=false) {
        $SEP = ''; $TOP = '';
        if (!$show_form) {
                $TOP = " top2";
-               $SEP = "<tr><td colspan=\"".$colspan."\" class=\"seperator\">&nbsp;</td></tr>";
+               $SEP = "<tr><td colspan=\"" . $colspan."\" class=\"seperator\">&nbsp;</td></tr>";
        }
 
        $NAV = '';
@@ -1668,7 +1668,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=".$GLOBALS['what']."&amp;page=".$page."&amp;offset=".$offset;
+                       $NAV .= "<a href=\"{!URL!}/modules.php?module=admin&amp;what=" . $GLOBALS['what']."&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'));
@@ -1728,7 +1728,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 />\n");
        if (substr(strtolower($script), 0, 7) == 'http://') {
                // But only if http:// is in front!
                $script = substr($script, (strlen($url) + 7));
@@ -1737,7 +1737,7 @@ function extractHostnameFromUrl (&$script) {
                $script = substr($script, (strlen($url) + 8));
        }
 
-       //* DEBUG: */ print("SCRIPT=".$script."<br />\n");
+       //* DEBUG: */ print("SCRIPT=" . $script."<br />\n");
        if (substr($script, 0, 1) == '/') $script = substr($script, 1);
 
        // Return host name
@@ -1826,7 +1826,7 @@ function sendRawRequest ($host, $request) {
        } // END - if
 
        // Open connection
-       //* DEBUG: */ die("SCRIPT=".$script."<br />\n");
+       //* DEBUG: */ die("SCRIPT=" . $script."<br />\n");
        if ($useProxy === true) {
                // Connect to host through proxy connection
                $fp = @fsockopen(COMPILE_CODE(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
@@ -1856,7 +1856,7 @@ function sendRawRequest ($host, $request) {
 
                // Add last new-line
                $proxyTunnel .= getConfig('HTTP_EOL');
-               //* DEBUG: */ print("<strong>proxyTunnel=</strong><pre>".$proxyTunnel."</pre>");
+               //* DEBUG: */ print("<strong>proxyTunnel=</strong><pre>" . $proxyTunnel."</pre>");
 
                // Write request
                fputs($fp, $proxyTunnel);
@@ -1948,13 +1948,13 @@ function isUrlValid ($URL, $compile=true) {
        //* DEBUG: */ echo $URL."<br />";
 
        // Compile some chars out...
-       if ($compile) $URL = compileUriCode($URL, false, false, false);
+       if ($compile === true) $URL = compileUriCode($URL, false, false, false);
        //* DEBUG: */ echo $URL."<br />";
 
        // Check for the extension filter
        if (EXT_IS_ACTIVE('filter')) {
                // Use the extension's filter set
-               return FILTER_isUrlValid($URL, false);
+               return FILTER_VALIDATE_URL($URL, false);
        } // END - if
 
        // If not installed, perform a simple test. Just make it sure there is always a http:// or
@@ -1971,8 +1971,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: */ echo "*" . $tar.'/' . $status."*<br />\n";
                if (($tar == "lock_user") && ($status == 'LOCKED')) {
                        // Locked accounts shall be unlocked
                        $eval .= "UNLOCK_USER";
@@ -2052,12 +2052,12 @@ function generateHash ($plainText, $salt = '') {
                $a = time() + getConfig('_ADD') - 1;
 
                // 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 />";
+               $sha1 = sha1(($a % getConfig('_PRIME')) . $server.getConfig('ENCRYPT_SEPERATOR') . $keys.getConfig('ENCRYPT_SEPERATOR') . $data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR') . $a);
+               //* DEBUG: */ echo "SHA1=" . $sha1." (".strlen($sha1).")<br />";
                $sha1 = scrambleString($sha1);
-               //* DEBUG: */ echo "Scrambled=".$sha1." (".strlen($sha1).")<br />";
+               //* DEBUG: */ echo "Scrambled=" . $sha1." (".strlen($sha1).")<br />";
                //* DEBUG: */ $sha1b = descrambleString($sha1);
-               //* DEBUG: */ echo "Descrambled=".$sha1b." (".strlen($sha1b).")<br />";
+               //* DEBUG: */ echo "Descrambled=" . $sha1b." (".strlen($sha1b).")<br />";
 
                // Generate the password salt string
                $salt = substr($sha1, 0, getConfig('salt_length'));
@@ -2069,7 +2069,7 @@ function generateHash ($plainText, $salt = '') {
        }
 
        // Return hash
-       return $salt.sha1($salt.$plainText);
+       return $salt.sha1($salt . $plainText);
 }
 
 // Scramble a string
@@ -2090,7 +2090,7 @@ function scrambleString($str) {
        }
 
        // Scramble string here
-       //* DEBUG: */ echo "***Original=".$str."***<br />";
+       //* DEBUG: */ echo "***Original=" . $str."***<br />";
        for ($idx = 0; $idx < strlen($str); $idx++) {
                // Get char on scrambled position
                $char = substr($str, $scrambleNums[$idx], 1);
@@ -2100,7 +2100,7 @@ function scrambleString($str) {
        } // END - for
 
        // Return scrambled string
-       //* DEBUG: */ echo "***Scrambled=".$scrambled."***<br />";
+       //* DEBUG: */ echo "***Scrambled=" . $scrambled."***<br />";
        return $scrambled;
 }
 
@@ -2117,14 +2117,14 @@ function descrambleString($str) {
 
        // Begin descrambling
        $orig = str_repeat(" ", 40);
-       //* DEBUG: */ echo "+++Scrambled=".$str."+++<br />";
+       //* DEBUG: */ echo "+++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: */ echo "+++Original=" . $orig."+++<br />";
        return $orig;
 }
 
@@ -2171,20 +2171,20 @@ function generatePassString ($passHash) {
                                $mod = dechex(sqrt(($part2 - $part1) * getConfig('_PRIME') / pi()));
                        }
                        $mod = substr(round($mod), 0, 4);
-                       $mod = str_repeat('0', 4-strlen($mod)).$mod;
-                       //* DEBUG: */ echo "*".$start.'='.$mod."*<br />";
+                       $mod = str_repeat('0', 4-strlen($mod)) . $mod;
+                       //* DEBUG: */ echo "*" . $start.'=' . $mod."*<br />";
                        $start += 4;
                        $newHash .= $mod;
                } // END - for
 
-               //* DEBUG: */ print($passHash."<br />".$newHash." (".strlen($newHash).')');
+               //* DEBUG: */ print($passHash."<br />" . $newHash." (".strlen($newHash).')');
                $ret = generateHash($newHash, getConfig('master_salt'));
                //* DEBUG: */ print($ret."<br />\n");
        } else {
                // Hash it simple
-               //* DEBUG: */ echo "--".$passHash."--<br />\n";
+               //* DEBUG: */ echo "--" . $passHash."--<br />\n";
                $ret = md5($passHash);
-               //* DEBUG: */ echo "++".$ret."++<br />\n";
+               //* DEBUG: */ echo "++" . $ret."++<br />\n";
        }
 
        // Return result
@@ -2206,7 +2206,7 @@ function fixDeletedCookies ($cookies) {
 }
 
 // Output error messages in a fasioned way and die...
-function app_die ($F, $L, $msg) {
+function app_die ($F, $L, $message) {
        // Check if Script is already dieing and not let it kill itself another 1000 times
        if (!isset($GLOBALS['app_died'])) {
                // Make sure, that the script realy realy diese here and now
@@ -2216,16 +2216,16 @@ function app_die ($F, $L, $msg) {
                loadIncludeOnce('inc/header.php');
 
                // Prepare message for output
-               $msg = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $msg);
+               $message = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $message);
 
                // Load the message template
-               LOAD_TEMPLATE('admin_settings_saved', false, $msg);
+               LOAD_TEMPLATE('admin_settings_saved', false, $message);
 
                // Load footer
                loadIncludeOnce('inc/footer.php');
        } else {
                // Script tried to kill itself twice
-               debug_report_bug('Script wanted to kill itself more than once! Raw message=' . $msg . ', file/function=' . $F . ', line=' . $L);
+               debug_report_bug('Script wanted to kill itself more than once! Raw message=' . $message . ', file/function=' . $F . ', line=' . $L);
        }
 }
 
@@ -2267,14 +2267,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: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-CACHE!<br />\n";
                $res = ($GLOBALS['cache_array']['const'][$constName] === true);
        } else {
                // Check constant
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$constName."-RESOLVE!<br />\n";
+               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-RESOLVE!<br />\n";
                if (defined($constName)) {
                        // Found!
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$constName."-FOUND!<br />\n";
+                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): " . $constName."-FOUND!<br />\n";
                        $res = (constant($constName) === true);
                } // END - if
 
@@ -2405,7 +2405,7 @@ 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: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):dir=" . $dir."<br />\n";
        // 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|\.svn|debug\.log|\.cache|config\.php)$@';
@@ -2423,12 +2423,12 @@ function searchDirsRecursive ($dir, &$last_changed) {
                        // $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: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):DESCENT: " . $newDir."<br />\n";
                        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: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):File: " . $d." found. (".($last_changed['time'] - $time).")<br />\n";
                        if ($last_changed['time'] < $time) {
                                // This file is newer as the file before
                                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>) - NEWER!<br />\n";
@@ -2539,7 +2539,7 @@ function getArrayFromActualVersion () {
        // This foreach loops the $searchFor-Tags (array('Revision', 'Date', 'Tag', 'Author') --> could easaly extended in the future)
        foreach ($searchFor as $search) {
                // Searches for "$search-tag:VALUE$" or "$search-tag::VALUE$"(the stylish keywordversion ;-)) in the lates modified file
-               $res += preg_match('@\$'.$search.'(:|::) (.*) \$@U', $last_file, $t);
+               $res += preg_match('@\$' . $search.'(:|::) (.*) \$@U', $last_file, $t);
                // This trimms the search-result and puts it in the $akt_vers-return array
                if (isset($t[2])) $akt_vers[$search] = trim($t[2]);
        } // END - foreach
@@ -2590,7 +2590,7 @@ function debug_get_printable_backtrace () {
                if (!isset($trace['file'])) $trace['file'] = __FUNCTION__;
                if (!isset($trace['line'])) $trace['line'] = __LINE__;
                if (!isset($trace['args'])) $trace['args'] = array();
-               $backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function'].'('.count($trace['args']).")</span></li>\n";
+               $backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:" . $trace['line'].", <span class=\"backtrace_function\">" . $trace['function'].'('.count($trace['args']).")</span></li>\n";
        } // END - foreach
 
        // Close it
@@ -2618,7 +2618,7 @@ function debug_report_bug ($message = '') {
        // Add output
        $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you cannot attach files!):<pre>";
        $debug .= debug_get_printable_backtrace();
-       $debug .= "</pre>\nRequest-URI: ".$_SERVER['REQUEST_URI']."<br />\n";
+       $debug .= "</pre>\nRequest-URI: " . $_SERVER['REQUEST_URI']."<br />\n";
        $debug .= "Thank you for finding bugs.";
 
        // And abort here
@@ -2634,49 +2634,49 @@ function generateSeed () {
 
 // Converts a message code to a human-readable message
 function convertCodeToMessage ($code) {
-       $msg = '';
+       $message = '';
        switch ($code) {
-               case getCode('LOGOUT_DONE')      : $msg = getMessage('LOGOUT_DONE'); break;
-               case getCode('LOGOUT_FAILED')    : $msg = "<span class=\"guest_failed\">{--LOGOUT_FAILED--}</span>"; break;
-               case getCode('DATA_INVALID')     : $msg = getMessage('MAIL_DATA_INVALID'); break;
-               case getCode('POSSIBLE_INVALID') : $msg = getMessage('MAIL_POSSIBLE_INVALID'); break;
-               case getCode('ACCOUNT_LOCKED')   : $msg = getMessage('MEMBER_ACCOUNT_LOCKED_UNC'); break;
-               case getCode('USER_404')         : $msg = getMessage('USER_NOT_FOUND'); break;
-               case getCode('STATS_404')        : $msg = getMessage('MAIL_STATS_404'); break;
-               case getCode('ALREADY_CONFIRMED'): $msg = getMessage('MAIL_ALREADY_CONFIRMED'); break;
+               case getCode('LOGOUT_DONE')      : $message = getMessage('LOGOUT_DONE'); break;
+               case getCode('LOGOUT_FAILED')    : $message = "<span class=\"guest_failed\">{--LOGOUT_FAILED--}</span>"; break;
+               case getCode('DATA_INVALID')     : $message = getMessage('MAIL_DATA_INVALID'); break;
+               case getCode('POSSIBLE_INVALID') : $message = getMessage('MAIL_POSSIBLE_INVALID'); break;
+               case getCode('ACCOUNT_LOCKED')   : $message = getMessage('MEMBER_ACCOUNT_LOCKED_UNC'); break;
+               case getCode('USER_404')         : $message = getMessage('USER_NOT_FOUND'); break;
+               case getCode('STATS_404')        : $message = getMessage('MAIL_STATS_404'); break;
+               case getCode('ALREADY_CONFIRMED'): $message = getMessage('MAIL_ALREADY_CONFIRMED'); break;
 
                case getCode('ERROR_MAILID'):
                        if (EXT_IS_ACTIVE($ext, true)) {
-                               $msg = getMessage('ERROR_CONFIRMING_MAIL');
+                               $message = getMessage('ERROR_CONFIRMING_MAIL');
                        } else {
-                               $msg = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'mailid');
+                               $message = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'mailid');
                        }
                        break;
 
                case getCode('EXTENSION_PROBLEM'):
                        if (REQUEST_ISSET_GET('ext')) {
-                               $msg = generateExtensionInactiveNotInstalledMessage(REQUEST_GET('ext'));
+                               $message = generateExtensionInactiveNotInstalledMessage(REQUEST_GET('ext'));
                        } else {
-                               $msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT');
+                               $message = getMessage('EXTENSION_PROBLEM_UNSET_EXT');
                        }
                        break;
 
-               case getCode('COOKIES_DISABLED') : $msg = getMessage('LOGIN_NO_COOKIES'); break;
-               case getCode('BEG_SAME_AS_OWN')  : $msg = getMessage('BEG_SAME_UID_AS_OWN'); break;
-               case getCode('LOGIN_FAILED')     : $msg = getMessage('LOGIN_FAILED_GENERAL'); break;
-               case getCode('MODULE_MEM_ONLY')  : $msg = sprintf(getMessage('MODULE_MEM_ONLY'), REQUEST_GET('mod')); break;
+               case getCode('COOKIES_DISABLED') : $message = getMessage('LOGIN_NO_COOKIES'); break;
+               case getCode('BEG_SAME_AS_OWN')  : $message = getMessage('BEG_SAME_UID_AS_OWN'); break;
+               case getCode('LOGIN_FAILED')     : $message = getMessage('LOGIN_FAILED_GENERAL'); break;
+               case getCode('MODULE_MEM_ONLY')  : $message = sprintf(getMessage('MODULE_MEM_ONLY'), REQUEST_GET('mod')); break;
 
                default:
                        // Missing/invalid code
-                       $msg = sprintf(getMessage('UNKNOWN_MAILID_CODE'), $code);
+                       $message = sprintf(getMessage('UNKNOWN_MAILID_CODE'), $code);
 
                        // Log it
-                       DEBUG_LOG(__FUNCTION__, __LINE__, $msg);
+                       DEBUG_LOG(__FUNCTION__, __LINE__, $message);
                        break;
        } // END - switch
 
        // Return the message
-       return $msg;
+       return $message;
 }
 
 // Generate a "link" for the given admin id (aid)
@@ -2694,7 +2694,7 @@ function generateAdminLink ($aid) {
                        // Is the extension there?
                        if (EXT_IS_ACTIVE('admins')) {
                                // Admin found
-                               $admin = "<a href=\"".adminsCreateEmailLink(getAdminEmail($aid))."\">".$login."</a>";
+                               $admin = "<a href=\"".adminsCreateEmailLink(getAdminEmail($aid))."\">" . $login."</a>";
                        } else {
                                // Extension not found
                                $admin = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'admins');
@@ -2712,19 +2712,19 @@ function generateAdminLink ($aid) {
 // Compile characters which are allowed in URLs
 function compileUriCode ($code, $simple=true) {
        // Compile constants
-       if (!$simple) $code = str_replace("{--", '".', str_replace("--}", '."', $code));
+       if (!$simple) $code = str_replace('{--', '".', str_replace('--}', '."', $code));
 
        // Compile QUOT and other non-HTML codes
        $code = str_replace('{DOT}', '.',
-       str_replace('{SLASH}', '/',
-       str_replace('{QUOT}', "'",
-       str_replace('{DOLLAR}', '$',
-       str_replace('{OPEN_ANCHOR}', '(',
-       str_replace('{CLOSE_ANCHOR}', ')',
-       str_replace('{OPEN_SQR}', '[',
-       str_replace('{CLOSE_SQR}', ']',
-       str_replace('{PER}', '%',
-       $code
+               str_replace('{SLASH}', '/',
+               str_replace('{QUOT}', "'",
+               str_replace('{DOLLAR}', '$',
+               str_replace('{OPEN_ANCHOR}', '(',
+               str_replace('{CLOSE_ANCHOR}', ')',
+               str_replace('{OPEN_SQR}', '[',
+               str_replace('{CLOSE_SQR}', ']',
+               str_replace('{PER}', '%',
+               $code
        )))))))));
 
        // Return compiled code
@@ -2734,7 +2734,7 @@ function compileUriCode ($code, $simple=true) {
 // Function taken from user comments on www.php.net / function eregi()
 function isUrlValidSimple ($url) {
        // Prepare URL
-       $url = strip_tags(str_replace("\\", '', compileUriCode(urldecode($url))));
+       $url = strip_tags(str_replace("\\", '', COMPILE_CODE(urldecode($url))));
 
        // Allows http and https
        $http      = "(http|https)+(:\/\/)";
@@ -2751,44 +2751,42 @@ function isUrlValidSimple ($url) {
        // ... and the string after and including question character
        $getstring1 = "([\?/]([[:alnum:]][-\._%[:alnum:]]*(=)?([-\@\._:%[:alnum:]])+)(&([[:alnum:]]([-_%[:alnum:]])*(=)?([-\@\[\._:%[:alnum:]])+(\])*))*)?";
        // Pattern for URLs like http://url/dir/doc.html?var=value
-       $pattern['d1dpg1']  = $http.$domain1.$dir.$page.$getstring1;
-       $pattern['d2dpg1']  = $http.$domain2.$dir.$page.$getstring1;
-       $pattern['ipdpg1']  = $http.$ip.$dir.$page.$getstring1;
+       $pattern['d1dpg1']  = $http . $domain1 . $dir . $page . $getstring1;
+       $pattern['d2dpg1']  = $http . $domain2 . $dir . $page . $getstring1;
+       $pattern['ipdpg1']  = $http . $ip . $dir . $page . $getstring1;
        // Pattern for URLs like http://url/dir/?var=value
-       $pattern['d1dg1']  = $http.$domain1.$dir.'/'.$getstring1;
-       $pattern['d2dg1']  = $http.$domain2.$dir.'/'.$getstring1;
-       $pattern['ipdg1']  = $http.$ip.$dir.'/'.$getstring1;
+       $pattern['d1dg1']  = $http . $domain1 . $dir.'/' . $getstring1;
+       $pattern['d2dg1']  = $http . $domain2 . $dir.'/' . $getstring1;
+       $pattern['ipdg1']  = $http . $ip . $dir.'/' . $getstring1;
        // Pattern for URLs like http://url/dir/page.ext
-       $pattern['d1dp']  = $http.$domain1.$dir.$page;
-       $pattern['d1dp']  = $http.$domain2.$dir.$page;
-       $pattern['ipdp']  = $http.$ip.$dir.$page;
+       $pattern['d1dp']  = $http . $domain1 . $dir . $page;
+       $pattern['d1dp']  = $http . $domain2 . $dir . $page;
+       $pattern['ipdp']  = $http . $ip . $dir . $page;
        // Pattern for URLs like http://url/dir
-       $pattern['d1d']  = $http.$domain1.$dir;
-       $pattern['d2d']  = $http.$domain2.$dir;
-       $pattern['ipd']  = $http.$ip.$dir;
+       $pattern['d1d']  = $http . $domain1 . $dir;
+       $pattern['d2d']  = $http . $domain2 . $dir;
+       $pattern['ipd']  = $http . $ip . $dir;
        // Pattern for URLs like http://url/?var=value
-       $pattern['d1g1']  = $http.$domain1.'/'.$getstring1;
-       $pattern['d2g1']  = $http.$domain2.'/'.$getstring1;
-       $pattern['ipg1']  = $http.$ip.'/'.$getstring1;
+       $pattern['d1g1']  = $http . $domain1 . '/' . $getstring1;
+       $pattern['d2g1']  = $http . $domain2 . '/' . $getstring1;
+       $pattern['ipg1']  = $http . $ip . '/' . $getstring1;
        // Pattern for URLs like http://url?var=value
-       $pattern['d1g12']  = $http.$domain1.$getstring1;
-       $pattern['d2g12']  = $http.$domain2.$getstring1;
-       $pattern['ipg12']  = $http.$ip.$getstring1;
+       $pattern['d1g12']  = $http . $domain1 . $getstring1;
+       $pattern['d2g12']  = $http . $domain2 . $getstring1;
+       $pattern['ipg12']  = $http . $ip . $getstring1;
        // Test all patterns
        $reg = false;
-       foreach ($pattern as $key=>$pat) {
+       foreach ($pattern as $key => $pat) {
                // Debug regex?
-               if (defined('DEBUG_REGEX')) {
-                       $pat = str_replace("[:alnum:]", "0-9a-zA-Z", $pat);
-                       $pat = str_replace("[:alpha:]", "a-zA-Z", $pat);
-                       $pat = str_replace("[:digit:]", "0-9", $pat);
-                       $pat = str_replace('.', "\.", $pat);
-                       $pat = str_replace("@", "\@", $pat);
-                       echo $key."=&nbsp;".$pat."<br />";
-               }
+               if (isDebugRegExpressionEnabled()) {
+                       // @TODO Are these convertions still required?
+                       $pat = str_replace('.', "&#92;&#46;", $pat);
+                       $pat = str_replace('@', "&#92;&#64;", $pat);
+                       echo $key."=&nbsp;" . $pat . "<br />";
+               } // END - if
 
                // Check if expression matches
-               $reg = ($reg || preg_match(("^".$pat."^"), $url));
+               $reg = ($reg || preg_match(('^' . $pat.'^'), $url));
 
                // Does it match?
                if ($reg === true) break;
@@ -2876,8 +2874,8 @@ function sendAdminNotification ($subject, $templateName, $content=array(), $uid
                SEND_ADMIN_EMAILS_PRO($subject, $templateName, $content, $uid);
        } else {
                // Send out out-dated way
-               $msg = LOAD_EMAIL_TEMPLATE($templateName, $content, $uid);
-               SEND_ADMIN_EMAILS($subject, $msg);
+               $message = LOAD_EMAIL_TEMPLATE($templateName, $content, $uid);
+               SEND_ADMIN_EMAILS($subject, $message);
        }
 }
 
@@ -2890,7 +2888,7 @@ function DEBUG_LOG ($funcFile, $line, $message, $force=true) {
 
                // Log this message away
                $fp = fopen(constant('PATH')."inc/cache/debug.log", 'a') or app_die(__FUNCTION__, __LINE__, "Cannot write logfile debug.log!");
-               fwrite($fp, date("d.m.Y|H:i:s", time())."|".$GLOBALS['module']."|".basename($funcFile)."|".$line."|".strip_tags($message)."\n");
+               fwrite($fp, date("d.m.Y|H:i:s", time())."|" . $GLOBALS['module']."|".basename($funcFile)."|" . $line."|".strip_tags($message)."\n");
                fclose($fp);
        } // END - if
 }
@@ -2992,7 +2990,7 @@ function convertSelectionsToTimestamp (&$POST, &$DATA, &$id, &$skip) {
 
                        // Remove data from array
                        foreach (array('ye', 'mo', 'we', 'da', 'ho', 'mi', 'se') as $rem) {
-                               unset($POST[$test.'_'.$rem]);
+                               unset($POST[$test.'_' . $rem]);
                        } // END - foreach
 
                        // Skip adding
@@ -3036,14 +3034,14 @@ function HANDLE_LOGIN_FAILTURES ($accessLevel) {
        $OUT = '';
 
        // Is the session data set?
-       if ((isSessionVariableSet('mxchange_'.$accessLevel.'_failures')) && (isSessionVariableSet('mxchange_'.$accessLevel.'_last_fail'))) {
+       if ((isSessionVariableSet('mxchange_' . $accessLevel.'_failures')) && (isSessionVariableSet('mxchange_' . $accessLevel.'_last_fail'))) {
                // Ignore zero values
-               if (getSession('mxchange_'.$accessLevel.'_failures') > 0) {
+               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";
                        $content = array(
-                               'login_failures' => getSession('mxchange_'.$accessLevel.'_failures'),
-                               'last_failure'   => generateDateTime(getSession('mxchange_'.$accessLevel.'_last_fail'), '2')
+                               'login_failures' => getSession('mxchange_' . $accessLevel.'_failures'),
+                               'last_failure'   => generateDateTime(getSession('mxchange_' . $accessLevel.'_last_fail'), '2')
                        );
 
                        // Load template
@@ -3051,8 +3049,8 @@ function HANDLE_LOGIN_FAILTURES ($accessLevel) {
                } // END - if
 
                // Reset session data
-               setSession('mxchange_'.$accessLevel.'_failures', '');
-               setSession('mxchange_'.$accessLevel.'_last_fail', '');
+               setSession('mxchange_' . $accessLevel.'_failures', '');
+               setSession('mxchange_' . $accessLevel.'_last_fail', '');
        } // END - if
 
        // Return rendered content
@@ -3168,18 +3166,18 @@ function addNewBonusMail ($data, $mode = '', $output=true) {
 // Determines referal id and sets it
 function DETERMINE_REFID () {
        // Check if refid is set
-       if ((!empty($_GET['user'])) && (basename($_SERVER['PHP_SELF']) == "click.php")) {
+       if ((REQUEST_ISSET_GET('user')) && (basename($_SERVER['PHP_SELF']) == 'click.php')) {
                // The variable user comes from the click-counter script click.php and we only accept this here
-               $GLOBALS['refid'] = bigintval($_GET['user']);
-       } elseif (!empty($_POST['refid'])) {
+               $GLOBALS['refid'] = bigintval(REQUEST_GET('user'));
+       } elseif (REQUEST_ISSET_POST('refid')) {
                // Get referal id from variable refid (so I hope this makes my script more compatible to other scripts)
-               $GLOBALS['refid'] = SQL_ESCAPE(strip_tags($_POST['refid']));
-       } elseif (!empty($_GET['refid'])) {
+               $GLOBALS['refid'] = strip_tags(REQUEST_POST('refid'));
+       } elseif (REQUEST_ISSET_GET('refid')) {
                // Get referal id from variable refid (so I hope this makes my script more compatible to other scripts)
-               $GLOBALS['refid'] = SQL_ESCAPE(strip_tags($_GET['refid']));
-       } elseif (!empty($_GET['ref'])) {
+               $GLOBALS['refid'] = strip_tags(REQUEST_GET('refid'));
+       } elseif (REQUEST_ISSET_GET('ref')) {
                // Set refid=ref (the referal link uses such variable)
-               $GLOBALS['refid'] = SQL_ESCAPE(strip_tags($_GET['ref']));
+               $GLOBALS['refid'] = strip_tags(REQUEST_GET('ref'));
        } elseif ((isSessionVariableSet('refid')) && (getSession('refid') != 0)) {
                // Set session refid als global
                $GLOBALS['refid'] = bigintval(getSession('refid'));
@@ -3266,10 +3264,10 @@ function handleCodeMessage () {
                if (REQUEST_ISSET_GET('ext')) $ext = REQUEST_GET('ext');
 
                // Convert the 'msg' parameter from URL to a human-readable message
-               $msg = convertCodeToMessage(REQUEST_GET('msg'));
+               $message = convertCodeToMessage(REQUEST_GET('msg'));
 
                // Load message template
-               LOAD_TEMPLATE('message', false, $msg);
+               LOAD_TEMPLATE('message', false, $message);
        } // END - if
 }
 
@@ -3304,16 +3302,16 @@ function generateExtensionInactiveMessage ($ext_name) {
        } // END - if
 
        // Default message
-       $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), $ext_name);
+       $message = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), $ext_name);
 
        // Is an admin logged in?
        if (IS_ADMIN()) {
                // Then output admin message
-               $msg = sprintf(getMessage('ADMIN_EXTENSION_PROBLEM_EXT_INACTIVE'), $ext_name);
+               $message = sprintf(getMessage('ADMIN_EXTENSION_PROBLEM_EXT_INACTIVE'), $ext_name);
        } // END - if
 
        // Return prepared message
-       return $msg;
+       return $message;
 }
 
 // Generates a 'extension foo not installed' message
@@ -3325,16 +3323,16 @@ function generateExtensionNotInstalledMessage ($ext_name) {
        } // END - if
 
        // Default message
-       $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_NOT_INSTALLED'), $ext_name);
+       $message = sprintf(getMessage('EXTENSION_PROBLEM_EXT_NOT_INSTALLED'), $ext_name);
 
        // Is an admin logged in?
        if (IS_ADMIN()) {
                // Then output admin message
-               $msg = sprintf(getMessage('ADMIN_EXTENSION_PROBLEM_EXT_NOT_INSTALLED'), $ext_name);
+               $message = sprintf(getMessage('ADMIN_EXTENSION_PROBLEM_EXT_NOT_INSTALLED'), $ext_name);
        } // END - if
 
        // Return prepared message
-       return $msg;
+       return $message;
 }
 
 // Generates a message depending on if the extension is not installed or not