]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Fix for parser error
[mailer.git] / inc / functions.php
index 5acdb2688c6ffd4f175d0e48924813409cca7649..8d67bc491fbfa27d0820587296bf2ff977dcb7be 100644 (file)
@@ -347,8 +347,11 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
                        $ret = $tmpl_file;
                }
 
-               // Add surrounding HTML comments to help finding bugs faster
-               $ret = "<!-- Template " . $template . " - Start -->\n" . $ret . "<!-- Template " . $template . " - End -->\n";
+               // Normal HTML output?
+               if ($GLOBALS['output_mode'] == 0) {
+                       // Add surrounding HTML comments to help finding bugs faster
+                       $ret = "<!-- Template " . $template . " - Start -->\n" . $ret . "<!-- Template " . $template . " - End -->\n";
+               } // END - if
        } 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 />
@@ -390,14 +393,16 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
        eval($eval);
 
        // Set from header
-       if ((!eregi("@", $toEmail)) && ($toEmail > 0)) {
+       if ((!eregi('@', $toEmail)) && ($toEmail > 0)) {
                // Value detected, is the message extension installed?
-               if (EXT_IS_ACTIVE("msg")) {
+               // @TODO Extension 'msg' does not exist
+               if (EXT_IS_ACTIVE('msg')) {
                        ADD_MESSAGE_TO_BOX($toEmail, $subject, $message, $HTML);
                        return;
                } else {
                        // Load email address
-                       $result_email = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($toEmail)), __FUNCTION__, __LINE__);
+                       $result_email = SQL_QUERY_ESC("SELECT `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+                               array(bigintval($toEmail)), __FUNCTION__, __LINE__);
                        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result_email)."<br />\n";
 
                        // Does the user exist?
@@ -1240,7 +1245,7 @@ function generateRandomCode ($length, $code, $uid, $DATA = '') {
        $keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY');
        if (isConfigEntrySet('secret_key'))  $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key');
        if (isConfigEntrySet('file_hash'))   $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash');
-       $keys .= getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime')));
+       $keys .= getConfig('ENCRYPT_SEPERATOR') . date("d-m-Y (l-F-T)", getConfig('patch_ctime'));
        if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
 
        // Build string from misc data
@@ -1292,9 +1297,9 @@ 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}");
+               //debug_report_bug("{$ret}<>{$num}");
        } // END - if
 
        // Return result
@@ -1418,7 +1423,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
                        $OUT .= "  <td align=\"center\" class=\"admin_title bottom\"><div class=\"tiny\">{--_YEARS--}</strong></td>\n";
                }
 
-               if (ereg("M", $display) || (empty($display))) {
+               if (ereg('M', $display) || (empty($display))) {
                        $OUT .= "  <td align=\"center\" class=\"admin_title bottom\"><div class=\"tiny\">{--_MONTHS--}</strong></td>\n";
                }
 
@@ -1458,7 +1463,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
                        $OUT .= "<INPUT type=\"hidden\" name=\"" . $prefix."_ye\" value=\"0\" />\n";
                }
 
-               if (ereg("M", $display) || (empty($display))) {
+               if (ereg('M', $display) || (empty($display))) {
                        // Generate month selection
                        $OUT .= "  <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix."_mo\" size=\"1\">\n";
                        for ($idx = 0; $idx <= 11; $idx++)
@@ -2012,20 +2017,20 @@ function generateMemberAdminActionLinks ($uid, $status = '') {
 }
 
 // Generate an email link
-function generateMemberEmailLink ($email, $table = 'admins') {
+function generateEmailLink ($email, $table = 'admins') {
        // Default email link (INSECURE! Spammer can read this by harvester programs)
        $EMAIL = 'mailto:' . $email;
 
        // Check for several extensions
        if ((EXT_IS_ACTIVE('admins')) && ($table == 'admins')) {
                // Create email link for contacting admin in guest area
-               $EMAIL = adminsCreateEmailLink($email);
+               $EMAIL = generateAdminEmailLink($email);
        } elseif ((EXT_IS_ACTIVE('user')) && (GET_EXT_VERSION('user') >= '0.3.3') && ($table == 'user_data')) {
                // Create email link for contacting a member within admin area (or later in other areas, too?)
-               $EMAIL = USER_generateMemberEmailLink($email);
+               $EMAIL = generateEmailLink($email, 'user_data');
        } elseif ((EXT_IS_ACTIVE('sponsor')) && ($table == 'sponsor_data')) {
                // Create email link to contact sponsor within admin area (or like the link above?)
-               $EMAIL = SPONSOR_generateMemberEmailLink($email);
+               $EMAIL = generateEmailLink($email, 'sponsor_data');
        }
 
        // Shall I close the link when there is no admin?
@@ -2055,7 +2060,7 @@ function generateHash ($plainText, $salt = '') {
                $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr();
 
                // Build key string
-               $keys   = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key').getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash').getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime'))).getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
+               $keys   = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key').getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash').getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig('patch_ctime')).getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
 
                // Additional data
                $data = $plainText.getConfig('ENCRYPT_SEPERATOR').uniqid(mt_rand(), true).getConfig('ENCRYPT_SEPERATOR').time();
@@ -2482,9 +2487,12 @@ function getActualVersion ($type = 'Revision') {
                } // END - if
 
                // Is the cache file outdated/invalid?
-               if ($new === true){
+               if ($new === true) {
+                       // Reload the cache file
+                       $GLOBALS['cache_instance']->loadCacheFile('revision');
+
                        // Destroy cache file
-                       $GLOBALS['cache_instance']->destroyCacheFile();
+                       $GLOBALS['cache_instance']->destroyCacheFile(false, true);
 
                        // @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')?
                        unset($GLOBALS['cache_array']['revision']);
@@ -2728,7 +2736,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=\"".generateEmailLink(getAdminEmail($aid), 'admins')."\">" . $login."</a>";
                        } else {
                                // Extension not found
                                $admin = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'admins');
@@ -2744,7 +2752,7 @@ function generateAdminLink ($aid) {
 }
 
 // Compile characters which are allowed in URLs
-function compileUriCode ($code, $simple=true) {
+function compileUriCode ($code, $simple = true) {
        // Compile constants
        if (!$simple) $code = str_replace('{--', '".', str_replace('--}', '."', $code));
 
@@ -2845,12 +2853,12 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
                $tmp = $FQFN . '.tmp';
 
                // Open the source file
-               $fp = fopen($FQFN, 'r') or OUTPUT_HTML('<strong>READ:</strong> ' . $FQFN . "<br />\n");
+               $fp = fopen($FQFN, 'r') or OUTPUT_HTML('<strong>READ:</strong> ' . $FQFN . '<br />');
 
                // Is the resource valid?
                if (is_resource($fp)) {
                        // Open temporary file
-                       $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML('<strong>WRITE:</strong> ' . $tmp . "<br />\n");
+                       $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML('<strong>WRITE:</strong> ' . $tmp . '<br />');
 
                        // Is the resource again valid?
                        if (is_resource($fp_tmp)) {
@@ -2867,7 +2875,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
                                                } else {
                                                        $next++;
                                                }
-                                       }
+                                       } // END - if
 
                                        // Write to temp file
                                        fputs($fp_tmp, $line);
@@ -2920,9 +2928,9 @@ function DEBUG_LOG ($funcFile, $line, $message, $force=true) {
                // Remove CRLF
                $message = str_replace("\r", '', str_replace("\n", '', $message));
 
-               // 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())."|" . getModule()."|".basename($funcFile)."|" . $line."|".strip_tags($message)."\n");
+               // 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!');
+               fwrite($fp, date('d.m.Y|H:i:s', time()) . '|' . getModule() . '|' . basename($funcFile) . '|' . $line . '|' . strip_tags($message) . "\n");
                fclose($fp);
        } // END - if
 }
@@ -2932,7 +2940,7 @@ function runResetIncludes () {
        // Is the reset set or old sql_patches?
        if ((!isResetModeEnabled()) || (EXT_VERSION_IS_OLDER('sql_patches', '0.4.5'))) {
                // Then abort here
-               DEBUG_LOG(__FUNCTION__, __LINE__, "Cannot run reset! Please report this bug. Thanks");
+               DEBUG_LOG(__FUNCTION__, __LINE__, 'Cannot run reset! Please report this bug. Thanks');
        } // END - if
 
        // Get more daily reset scripts
@@ -3217,7 +3225,7 @@ function DETERMINE_REFID () {
                $GLOBALS['refid'] = bigintval(getSession('refid'));
        } elseif ((GET_EXT_VERSION('sql_patches') != '') && (getConfig('def_refid') > 0)) {
                // Set default refid as refid in URL
-               $GLOBALS['refid'] = getConfig(('def_refid'));
+               $GLOBALS['refid'] = getConfig('def_refid');
        } elseif ((GET_EXT_VERSION('user') >= '0.3.4') && (getConfig('select_user_zero_refid')) == 'Y') {
                // Select a random user which has confirmed enougth mails
                $GLOBALS['refid'] = determineRandomReferalId();