]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
New wrapper functions introduced
[mailer.git] / inc / functions.php
index 5d929a993427cbf929300ff813c70a7dcf0ea7d9..f50a594a58a21f8feec74f756c87a495a5cdd49c 100644 (file)
@@ -104,7 +104,7 @@ function getTotalFatalErrors () {
 
 // Send mail out to an email address
 function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '') {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "TO={$toEmail},SUBJECT={$subject}<br />");
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'toEmail=' . $toEmail . ',subject=' . $subject . ',isHtml=' . $isHtml);
 
        // Compile subject line (for POINTS constant etc.)
        eval('$subject = decodeEntities("' . compileRawCode(escapeQuotes($subject)) . '");');
@@ -405,9 +405,9 @@ function translateGender ($gender) {
 
        // Male/female or company?
        switch ($gender) {
-               case 'M':
-               case 'M':
-               case 'C':
+               case 'M': // Male
+               case 'F': // Female
+               case 'C': // Company
                        $ret = sprintf("{--GENDER_%s--}", $gender);
                        break;
 
@@ -1198,7 +1198,7 @@ function generateHash ($plainText, $salt = '', $hash = true) {
 }
 
 // Scramble a string
-function scrambleString($str) {
+function scrambleString ($str) {
        // Init
        $scrambled = '';
 
@@ -1233,7 +1233,7 @@ function scrambleString($str) {
 }
 
 // De-scramble a string scrambled by scrambleString()
-function descrambleString($str) {
+function descrambleString ($str) {
        // Scramble only 40 chars long strings
        if (strlen($str) != 40) return $str;
 
@@ -1361,7 +1361,7 @@ function getCurrentTheme () {
 }
 
 // Generates an error code from given account status
-function generateErrorCodeFromUserStatus ($status='') {
+function generateErrorCodeFromUserStatus ($status = '') {
        // If no status is provided, use the default, cached
        if ((empty($status)) && (isMember())) {
                // Get user status
@@ -1507,9 +1507,9 @@ function getMessageFromErrorCode ($code) {
 
                        // Finally contruct the message
                        // @TODO Rewrite this old lost code to a template
-                       $message = "{--MEMBER_URL_TIME_LOCK--}<br />{--CONFIG_URL_TLOCK--} ".$STD."
-                       {--_HOURS--}, ".$MIN." {--_MINUTES--} {--_AND--} ".$SEC." {--_SECONDS--}<br />
-                       {--MEMBER_LAST_TLOCK--}: ".$timestamp;
+                       $message = '{--MEMBER_URL_TIME_LOCK--}<br />{--CONFIG_URL_TLOCK--} ' . $STD . '
+                       {--_HOURS--}, ' . $MIN . ' {--_MINUTES--} {--_AND--} ' . $SEC . ' {--_SECONDS--}<br />
+                       {--MEMBER_LAST_TLOCK--}: ' . $timestamp;
                        break;
 
                default:
@@ -1575,9 +1575,9 @@ function isUrlValidSimple ($url) {
                // Debug regex?
                if (isDebugRegularExpressionEnabled()) {
                        // @TODO Are these convertions still required?
-                       $pat = str_replace('.', "&#92;&#46;", $pat);
-                       $pat = str_replace('@', "&#92;&#64;", $pat);
-                       //* DEBUG: */ debugOutput($key."=&nbsp;" . $pat);
+                       $pat = str_replace('.', '&#92;&#46;', $pat);
+                       $pat = str_replace('@', '&#92;&#64;', $pat);
+                       //* DEBUG: */ debugOutput($key . '=&nbsp;' . $pat);
                } // END - if
 
                // Check if expression matches
@@ -1623,7 +1623,10 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
                                        // Read from source file
                                        $line = fgets ($fp, 1024);
 
-                                       if (strpos($line, $search) > -1) { $next = '0'; $found = true; }
+                                       if (strpos($line, $search) > -1) { 
+                                               $next = '0';
+                                               $found = true;
+                                       } // END - if
 
                                        if ($next > -1) {
                                                if ($next === $seek) {
@@ -1792,7 +1795,7 @@ function handleLoginFailures ($accessLevel) {
                // Ignore zero values
                if (getSession('mailer_' . $accessLevel . '_failures') > 0) {
                        // Non-guest has login failures found, get both data and prepare it for template
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "accessLevel={$accessLevel}<br />");
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'accessLevel=' . $accessLevel . '<br />');
                        $content = array(
                                'login_failures' => 'mailer_' . $accessLevel . '_failures',
                                'last_failure'   => generateDateTime(getSession('mailer_' . $accessLevel . '_last_failure'), 2)
@@ -1836,7 +1839,7 @@ function rebuildCache ($cache, $inc = '', $force = false) {
                                loadInclude($inc);
                        } else {
                                // Include not found!
-                               logDebugMessage(__FUNCTION__, __LINE__, "Include {$inc} not found. cache={$cache}");
+                               logDebugMessage(__FUNCTION__, __LINE__, 'Include ' . $inc . ' not found. cache=' . $cache);
                        }
                } // END - if
        } // END - if
@@ -1906,7 +1909,7 @@ function addNewBonusMail ($data, $mode = '', $output=true) {
 // Determines referal id and sets it
 function determineReferalId () {
        // Skip this in non-html-mode and outside ref.php
-       if ((getScriptOutputMode() != 0) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) return false;
+       if ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) return false;
 
        // Check if refid is set
        if ((isset($GLOBALS['refid'])) && ($GLOBALS['refid'] > 0)) {
@@ -2058,7 +2061,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
        $excludeArray[] = '.svn';
        $excludeArray[] = '.htaccess';
 
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix} - Entered!");
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'baseDir=' . $baseDir . ',prefix=' . $prefix . ' - Entered!');
        // Init includes
        $files = array();
 
@@ -2101,20 +2104,20 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
                        continue;
                } elseif (substr($baseFile, 0, strlen($prefix)) != $prefix) {
                        // Skip this file
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Invalid prefix in file " . $baseFile . ", prefix=" . $prefix);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Invalid prefix in file ' . $baseFile . ', prefix=' . $prefix);
                        continue;
                } elseif ((!empty($suffix)) && (substr($baseFile, -(strlen($suffix . $extension)), (strlen($suffix . $extension))) != $suffix . $extension)) {
                        // Skip wrong suffix as well
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Invalid suffix in file " . $baseFile . ", suffix=" . $suffix);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Invalid suffix in file ' . $baseFile . ', suffix=' . $suffix);
                        continue;
                } elseif (!isFileReadable($FQFN)) {
                        // Not readable so skip it
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "File " . $FQFN . " is not readable!");
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File ' . $FQFN . ' is not readable!');
                        continue;
                }
 
                // Is the file a PHP script or other?
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}");
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'baseDir=' . $baseDir . ',prefix=' . $prefix . ',baseFile=' . $baseFile);
                if ((substr($baseFile, -4, 4) == '.php') || (($fileIncludeDirs === true) && (isDirectory($FQFN)))) {
                        // Is this a valid include file?
                        if ($extension == '.php') {
@@ -2269,7 +2272,7 @@ function getModuleFromFileName ($file, $accessLevel) {
 // Encodes an URL for adding session id, etc.
 function encodeUrl ($url, $outputMode = '0') {
        // Do we have already have a PHPSESSID inside or view.php is called? Then abort here
-       if ((strpos($url, session_name()) !== false) || (getScriptOutputMode() == -3)) return $url;
+       if ((strpos($url, session_name()) !== false) || (isRawOutputMode())) return $url;
 
        // Do we have a valid session?
        if (((!isset($GLOBALS['valid_session'])) || ($GLOBALS['valid_session'] === false) || (!isset($_COOKIE[session_name()]))) && (isSpider() === false)) {
@@ -2279,7 +2282,7 @@ function encodeUrl ($url, $outputMode = '0') {
                if (strpos($url, '?') === false) {
                        // No question mark
                        $seperator = '?';
-               } elseif ((getScriptOutputMode() != '0') || ($outputMode != '0')) {
+               } elseif ((!isHtmlOutputMode()) || ($outputMode != '0')) {
                        // Non-HTML mode
                        $seperator = '&';
                }
@@ -2386,9 +2389,9 @@ function makeDatabaseUserId ($userid) {
        return $userid;
 }
 
-//////////////////////////////////////////////////
-// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
-//////////////////////////////////////////////////
+//-----------------------------------------------------------------------------
+// Automatically re-created functions, all taken from user comments on www.php.net
+//-----------------------------------------------------------------------------
 //
 if (!function_exists('html_entity_decode')) {
        // Taken from documentation on www.php.net