X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=4469fb25e0f9f2a27e22a4d5cf7d9f3d4fc96909;hb=8848f4a3fd7b32a1bbd9139766171701b94b2f42;hp=ffcff3c328e59b40ede7de82d11f03eed0672652;hpb=e9da1508b2a3ccbf63adc999981674740a47e074;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index ffcff3c328..4469fb25e0 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -434,7 +434,7 @@ function makeTime ($hours, $minutes, $seconds, $stamp) { } // Redirects to an URL and if neccessarry extends it with own base URL -function redirectToUrl ($url, $allowSpider = TRUE) { +function redirectToUrl ($url, $allowSpider = TRUE, $compileCode = TRUE) { // Is the output mode -2? if (isAjaxOutputMode()) { // This is always (!) an AJAX request and shall not be redirected @@ -446,8 +446,11 @@ function redirectToUrl ($url, $allowSpider = TRUE) { $url = substr($url, 6, -2); } // END - if - // Compile out codes - eval('$url = "' . compileRawCode(encodeUrl($url)) . '";'); + // Compile codes out? + if ($compileCode === TRUE) { + // Compile out codes + eval('$url = "' . compileRawCode(encodeUrl($url)) . '";'); + } // END - if // Default 'rel' value is external, nofollow is evil from Google and hurts the Internet $rel = ' rel="external"'; @@ -461,12 +464,18 @@ function redirectToUrl ($url, $allowSpider = TRUE) { // Three different ways to debug... //* DEBUG: */ reportBug(__FUNCTION__, __LINE__, 'URL=' . $url); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $url); - //* DEBUG: */ die($url); + //* DEBUG-DIE: */ die(__METHOD__ . ':url=' . $url . '
compileCode=' . intval($compileCode)); // We should not sent a redirect if headers are already sent if (!headers_sent()) { + // Compile again? + if ($compileCode === TRUE) { + // Do final compilation + $url = doFinalCompilation(str_replace('&', '&', $url), FALSE); + } // END - if + // Load URL when headers are not sent - sendRawRedirect(doFinalCompilation(str_replace('&', '&', $url), FALSE)); + sendRawRedirect($url); } else { // Output error message loadPageHeader(); @@ -536,7 +545,7 @@ function array_pk_sort (&$array, $a_sort, $primary_key = '0', $order = -1, $nums // function generateRandomCode ($length, $code, $userid, $extraData = '') { // Build server string - $server = $_SERVER['PHP_SELF'] . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . getenv('SERVER_SOFTWARE') . getEncryptSeparator() . detectRealIpAddress() . getEncryptSeparator() . detectRemoteAddr(); + $server = $_SERVER['REQUEST_URI'] . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . getenv('SERVER_SOFTWARE') . getEncryptSeparator() . detectRealIpAddress() . getEncryptSeparator() . detectRemoteAddr(); // Build key string $keys = getSiteKey() . getEncryptSeparator() . getDateKey(); @@ -772,7 +781,7 @@ function generateHash ($plainText, $salt = '', $hash = TRUE) { // When the salt is empty build a new one, else use the first x configured characters as the salt if (empty($salt)) { // Build server string for more entropy - $server = $_SERVER['PHP_SELF'] . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . getenv('SERVER_SOFTWARE') . getEncryptSeparator() . detectRealIpAddress() . getEncryptSeparator() . detectRemoteAddr(); + $server = $_SERVER['REQUEST_URI'] . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . getenv('SERVER_SOFTWARE') . getEncryptSeparator() . detectRealIpAddress() . getEncryptSeparator() . detectRemoteAddr(); // Build key string $keys = getSiteKey() . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . getFileHash() . getEncryptSeparator() . getMasterSalt(); @@ -2703,25 +2712,6 @@ function convertCharsetToUtf8 ($str, $charset) { return $str; } -// Hash string with SHA256 and encode it to hex -function hashSha256 ($str) { - /// Hash string - $hash = mhash(MHASH_SHA256, $str); - - // Encode it to hexadecimal - $hex = ''; - for ($i = 0; $i < strlen($hash); $i++) { - // Encode char to decimal, pad it with zero, add it - $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))), 2); - } // END - if - - // Make sure 'length modulo 2' = 0 - assert((strlen($hex) % 2) == 0); - - // Return it - return $hex; -} - // ---------------------------------------------------------------------------- // "Translatation" functions for points_data table // ---------------------------------------------------------------------------- @@ -2825,62 +2815,6 @@ if (!function_exists('html_entity_decode')) { } } // END - if -// "Calculates" password strength -function calculatePasswordStrength ($password, $configEntry = 'min_password_length') { - // Default score - $score = 1; - - if ((strlen($password) < 1) || (strlen($password) < getConfig($configEntry))) { - // Is to weak - return 0; - } // END - if - - // At least 8 chars long? - if (strlen($password) >= 8) { - // Add score - $score++; - } // END - if - - // At least 10 chars long? - if (strlen($password) >= 10) { - // Add score - $score++; - } // END - if - - // Lower and upper cases? - if ((preg_match('/[a-z]/', $password)) && (preg_match('/[A-Z]/', $password))) { - // Add score - $score++; - } // END - if - - // Also numbers? - if (preg_match('/[0-9]/', $password)) { - // Add score - $score++; - } // END - if - - // Special characters? - if (preg_match('/.[!,@,#,$,%,^,&,*,?,\/,_,~,+,-,(,)]/', $password)) { - // Add score - $score++; - } // END - if - - // Return password score - return $score; -} - -// "Translates" password strength/score -function translatePasswordStrength ($strength) { - // Return it translated - return '{--PASSWORD_SCORE_' . bigintval($strength) . '--}'; -} - -// Checks whether given password is strong enough -function isStrongPassword ($password) { - // Determine it - return (calculatePasswordStrength($password) >= getConfig('min_password_score')); -} - // "Getter" for base path from theme function getBasePathFromTheme ($theme) { return sprintf('%stheme/%s/css/', getPath(), $theme);