]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
A lot more wrapper functions added, templates renamed
[mailer.git] / inc / functions.php
index aeb0ac419f36d907c3eeaeaf1fb390ea38faa3b8..e07307acb584b51404c1ecd3a9d6b2de1ebd226f 100644 (file)
@@ -659,7 +659,7 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') {
        $server = $_SERVER['PHP_SELF'] . getEncryptSeperator() . detectUserAgent() . getEncryptSeperator() . getenv('SERVER_SOFTWARE') . getEncryptSeperator() . detectRealIpAddress() . getEncryptSeperator() . detectRemoteAddr();
 
        // Build key string
-       $keys = getConfig('SITE_KEY') . getEncryptSeperator() . getConfig('DATE_KEY');
+       $keys = getSiteKey() . getEncryptSeperator() . getDateKey();
        if (isConfigEntrySet('secret_key')) {
                $keys .= getEncryptSeperator().getSecretKey();
        } // END - if
@@ -690,22 +690,26 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') {
 
        if (isConfigEntrySet('master_salt')) {
                // Generate hash with master salt from modula of number with the prime number and other data
-               $saltedHash = generateHash(($a % getPrime()) . getEncryptSeperator() . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . $a, getMasterSalt());
+               $saltedHash = generateHash(($a % getPrime()) . getEncryptSeperator() . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getDateKey() . getEncryptSeperator() . $a, getMasterSalt());
 
                // Create number from hash
-               $rcode = hexdec(substr($saltedHash, strlen(getMasterSalt()), 9)) / abs(getConfig('rand_no') - $a + sqrt(getConfig('_ADD'))) / pi();
+               $rcode = hexdec(substr($saltedHash, strlen(getMasterSalt()), 9)) / abs(getRandNo() - $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 % getPrime()) . getEncryptSeperator() . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . $a, substr(sha1(getConfig('SITE_KEY')), 0, getSaltLength()));
+               $saltedHash = generateHash(($a % getPrime()) . getEncryptSeperator() . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getDateKey() . getEncryptSeperator() . $a, substr(sha1(getSiteKey()), 0, getSaltLength()));
 
                // Create number from hash
-               $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getConfig('rand_no') - $a + sqrt(getConfig('_ADD'))) / pi();
+               $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getRandNo() - $a + sqrt(getConfig('_ADD'))) / pi();
        }
 
        // At least 10 numbers shall be secure enought!
        $len = getCodeLength();
-       if ($len == '0') $len = $length;
-       if ($len == '0') $len = 10;
+       if ($len == '0') {
+               $len = $length;
+       } // END - if
+       if ($len == '0') {
+               $len = 10;
+       } // END - if
 
        // Cut off requested counts of number
        $return = substr(str_replace('.', '', $rcode), 0, $len);
@@ -947,10 +951,10 @@ function sendRawRequest ($host, $request) {
        //* DEBUG: */ die('SCRIPT=' . $script);
        if ($useProxy === true) {
                // Resolve hostname into IP address
-               $ip = $resolver->resolveHostname(compileRawCode(getConfig('proxy_host')));
+               $ip = $resolver->resolveHostname(compileRawCode(getProxyHost()));
 
                // Connect to host through proxy connection
-               $fp = fsockopen($ip, bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
+               $fp = fsockopen($ip, bigintval(getProxyPort()), $errno, $errdesc, 30);
        } else {
                // Resolve hostname into IP address
                $ip = $resolver->resolveHostname($host);
@@ -1079,9 +1083,9 @@ function setupProxyTunnel ($host, $resource) {
        $proxyTunnel .= 'Host: ' . $host . getConfig('HTTP_EOL');
 
        // Use login data to proxy? (username at least!)
-       if (getConfig('proxy_username') != '') {
+       if (getProxyUsername() != '') {
                // Add it as well
-               $encodedAuth = base64_encode(compileRawCode(getConfig('proxy_username')) . ':' . compileRawCode(getConfig('proxy_password')));
+               $encodedAuth = base64_encode(compileRawCode(getProxyUsername()) . ':' . compileRawCode(getProxyPassword()));
                $proxyTunnel .= 'Proxy-Authorization: Basic ' . $encodedAuth . getConfig('HTTP_EOL');
        } // END - if
 
@@ -1176,7 +1180,7 @@ function generateHash ($plainText, $salt = '', $hash = true) {
                $server = $_SERVER['PHP_SELF'] . getEncryptSeperator() . detectUserAgent() . getEncryptSeperator() . getenv('SERVER_SOFTWARE') . getEncryptSeperator() . detectRealIpAddress() . getEncryptSeperator() . detectRemoteAddr();
 
                // Build key string
-               $keys   = getConfig('SITE_KEY') . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . getSecretKey() . getEncryptSeperator() . getFileHash() . getEncryptSeperator() . getDateFromPatchTime() . getEncryptSeperator() . getMasterSalt();
+               $keys   = getSiteKey() . getEncryptSeperator() . getDateKey() . getEncryptSeperator() . getSecretKey() . getEncryptSeperator() . getFileHash() . getEncryptSeperator() . getDateFromPatchTime() . getEncryptSeperator() . getMasterSalt();
 
                // Additional data
                $data = $plainText . getEncryptSeperator() . uniqid(mt_rand(), true) . getEncryptSeperator() . time();
@@ -1185,7 +1189,7 @@ function generateHash ($plainText, $salt = '', $hash = true) {
                $a = time() + getConfig('_ADD') - 1;
 
                // Generate SHA1 sum from modula of number and the prime number
-               $sha1 = sha1(($a % getPrime()) . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . $a);
+               $sha1 = sha1(($a % getPrime()) . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getDateKey() . getEncryptSeperator() . $a);
                //* DEBUG: */ debugOutput('SHA1=' . $sha1.' ('.strlen($sha1).')<br />');
                $sha1 = scrambleString($sha1);
                //* DEBUG: */ debugOutput('Scrambled=' . $sha1.' ('.strlen($sha1).')<br />');