Several rewrites/renames, fixes for installation. Resolves #104
[mailer.git] / inc / functions.php
index 8dac96a08f566065a7c96504feaf8ef1ce0fc360..e9196a01fd848bc86b79f00f939c16e5353f617c 100644 (file)
@@ -476,9 +476,10 @@ Message : ".$MSG."
 }
 
 // Check if legacy or PHPMailer command
+// @TODO Rewrite this to an extension 'smtp'
 // @private
 function CHECK_PHPMAILER_USAGE() {
-       return ((defined('SMTP_HOSTNAME')) && (defined('SMTP_USER')) && (defined('SMTP_PASSWORD')) && (SMTP_HOSTNAME != "") && (SMTP_USER != ""));
+       return ((defined('SMTP_HOSTNAME')) && (defined('SMTP_USER')) && (defined('SMTP_PASSWORD')) && (constant('SMTP_HOSTNAME') != "") && (constant('SMTP_USER') != ""));
 }
 
 /*
@@ -675,8 +676,8 @@ function FRAMETESTER ($URL) {
 function SELECTION_COUNT ($array) {
        $ret = 0;
        if (is_array($array)) {
-               foreach ($array as $key => $sel) {
-                       if (!empty($sel)) $ret++;
+               foreach ($array as $key => $selected) {
+                       if (!empty($selected)) $ret++;
                }
        }
        return $ret;
@@ -1241,8 +1242,9 @@ function TRANSLATE_YESNO ($yn) {
 // Deprecated : $length
 // Optional   : $DATA
 //
-function GEN_RANDOM_CODE ($length, $code, $uid, $DATA="") {
+function generateRandomCodde ($length, $code, $uid, $DATA="") {
        // Fix missing _MAX constant
+       // @TODO Rewrite this unnice code
        if (!defined('_MAX')) define('_MAX', 15235);
 
        // Build server string
@@ -1261,9 +1263,9 @@ function GEN_RANDOM_CODE ($length, $code, $uid, $DATA="") {
        // Add more additional data
        if (isSessionVariableSet('u_hash'))                     $data .= ":".get_session('u_hash');
        if (isset($GLOBALS['userid']))                          $data .= ":".$GLOBALS['userid'];
-       if (isSessionVariableSet('mxchange_theme'))     $data .= ":".get_session('mxchange_theme');
-       if (isSessionVariableSet('mx_lang'))            $data .= ":".GET_LANGUAGE();
-       if (isset($GLOBALS['refid']))                           $data .= ":".$GLOBALS['refid'];
+       if (isSessionVariableSet('mxchange_theme'))             $data .= ":".get_session('mxchange_theme');
+       if (isSessionVariableSet('mx_lang'))                    $data .= ":".GET_LANGUAGE();
+       if (isset($GLOBALS['refid']))                                   $data .= ":".$GLOBALS['refid'];
 
        // Calculate number for generating the code
        $a = $code + constant('_ADD') - 1;
@@ -1276,7 +1278,7 @@ function GEN_RANDOM_CODE ($length, $code, $uid, $DATA="") {
                $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(constant('_MAX') - $a + sqrt(constant('_ADD'))) / pi();
        } else {
                // Generate hash with "hash of site key" from modula of number with the prime number and other data
-               $saltedHash = generateHash(($a % constant('_PRIME')).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, substr(sha1(SITE_KEY), 0, 8));
+               $saltedHash = generateHash(($a % constant('_PRIME')).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, substr(sha1(constant('SITE_KEY')), 0, 8));
 
                // Create number from hash
                $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(constant('_MAX') - $a + sqrt(constant('_ADD'))) / pi();
@@ -3177,7 +3179,7 @@ function HANDLE_LOGIN_FAILTURES ($accessLevel) {
 }
 
 // Rebuild cache
-function REBUILD_CACHE ($cache, $inc="") {
+function rebuildCacheFiles ($cache, $inc="") {
        // Shall I remove the cache file?
        if ((EXT_IS_ACTIVE("cache")) && (is_object($GLOBALS['cache_instance']))) {
                // Rebuild cache