X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=08fa13dc1783c29bcdaf8fe0502ea790e97c86d1;hp=333de57fec72d155269ce177afa46889ae7a78b7;hb=56931cd9321119dd37372bd16d6c552857e40066;hpb=0851db137e420b90617f47b77de2302e770f5f02 diff --git a/inc/functions.php b/inc/functions.php index 333de57fec..08fa13dc17 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -105,7 +105,7 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' // Is the webmaster! $toEmail = getWebmaster(); } - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "TO={$toEmail}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TO=' . $toEmail); // Check for PHPMailer or debug-mode if ((!checkPhpMailerUsage()) || (isDebugModeEnabled())) { @@ -640,14 +640,14 @@ function generateRandomCode ($length, $code, $userid, $extraData = '') { // Build key string $keys = getSiteKey() . getEncryptSeperator() . getDateKey(); if (isConfigEntrySet('secret_key')) { - $keys .= getEncryptSeperator().getSecretKey(); + $keys .= getEncryptSeperator() . getSecretKey(); } // END - if if (isConfigEntrySet('file_hash')) { - $keys .= getEncryptSeperator().getFileHash(); + $keys .= getEncryptSeperator() . getFileHash(); } // END - if $keys .= getEncryptSeperator() . getDateFromPatchTime(); if (isConfigEntrySet('master_salt')) { - $keys .= getEncryptSeperator().getMasterSalt(); + $keys .= getEncryptSeperator() . getMasterSalt(); } // END - if // Build string from misc data @@ -670,22 +670,21 @@ function generateRandomCode ($length, $code, $userid, $extraData = '') { 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() . getDateKey() . getEncryptSeperator() . $a, getMasterSalt()); - - // Create number from hash - $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() . getDateKey() . getEncryptSeperator() . $a, substr(sha1(getSiteKey()), 0, getSaltLength())); - - // Create number from hash - $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getRandNo() - $a + sqrt(getConfig('_ADD'))) / pi(); } + // Create number from hash + $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') { + if (isExtensionActive('other')) { + $len = getCodeLength(); + } else { $len = $length; } // END - if + if ($len == '0') { $len = 10; } // END - if @@ -1186,7 +1185,7 @@ function getMessageFromErrorCode ($code) { case getCode('COOKIES_DISABLED') : $message = '{--LOGIN_COOKIES_DISABLED--}'; break; case getCode('BEG_SAME_AS_OWN') : $message = '{--BEG_SAME_USERID_AS_OWN--}'; break; case getCode('LOGIN_FAILED') : $message = '{--GUEST_LOGIN_FAILED_GENERAL--}'; break; - case getCode('MODULE_MEMBER_ONLY') : $message = getMaskedMessage('MODULE_MEMBER_ONLY', getRequestParameter('mod')); break; + case getCode('MODULE_MEMBER_ONLY') : $message = '{%message,MODULE_MEMBER_ONLY=' . getRequestParameter('mod') . '%}'; break; case getCode('OVERLENGTH') : $message = '{--MEMBER_TEXT_OVERLENGTH--}'; break; case getCode('URL_FOUND') : $message = '{--MEMBER_TEXT_CONTAINS_URL--}'; break; case getCode('SUBJECT_URL') : $message = '{--MEMBER_SUBJECT_CONTAINS_URL--}'; break; @@ -1207,13 +1206,13 @@ function getMessageFromErrorCode ($code) { if (isExtensionActive('mailid', true)) { $message = '{--ERROR_CONFIRMING_MAIL--}'; } else { - $message = generateExtensionInactiveNotInstalledMessage('mailid'); + $message = '{%pipe,generateExtensionInactiveNotInstalledMessage=mailid%}'; } break; case getCode('EXTENSION_PROBLEM'): if (isGetRequestParameterSet('ext')) { - $message = generateExtensionInactiveNotInstalledMessage(getRequestParameter('ext')); + $message = '{%pipe,generateExtensionInactiveNotInstalledMessage=' . getRequestParameter('ext') . '%}'; } else { $message = '{--EXTENSION_PROBLEM_UNSET_EXT--}'; } @@ -1248,7 +1247,7 @@ function getMessageFromErrorCode ($code) { default: // Missing/invalid code - $message = getMaskedMessage('UNKNOWN_MAILID_CODE', $code); + $message = '{%message,UNKNOWN_MAILID_CODE=' . $code . '%}'; // Log it logDebugMessage(__FUNCTION__, __LINE__, $message); @@ -1570,7 +1569,7 @@ function rebuildCache ($cache, $inc = '', $force = false) { // Is the include there? if (isIncludeReadable($inc)) { // And rebuild it from scratch - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "inc={$inc} - LOADED!
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'inc=' . $inc . ' - LOADED!'); loadInclude($inc); } else { // Include not found @@ -1745,7 +1744,7 @@ function shutdown () { SQL_CLOSE(__FUNCTION__, __LINE__); } elseif (!isInstallationPhase()) { // No database link - addFatalMessage(__FUNCTION__, __LINE__, '{--NO_DB_LINK_SHUTDOWN--}'); + debug_report_bug(__FUNCTION__, __LINE__, 'Database link is already down, while shutdown is running.'); } // Stop executing here @@ -1989,7 +1988,7 @@ function initCacheInstance () { // Did it work? if ($GLOBALS['cache_instance']->getStatusCode() != 'done') { // Failed to initialize cache sustem - addFatalMessage(__FUNCTION__, __LINE__, '(' . __LINE__ . '): {--CACHE_CANNOT_INITIALIZE--}'); + debug_report_bug(__FUNCTION__, __LINE__, 'Cache system returned with unexpected error. getStatusCode()=' . $GLOBALS['cache_instance']->getStatusCode()); } // END - if } @@ -2221,13 +2220,26 @@ function generateAdminMailLinks ($mailType, $mailId) { if (!empty($table)) { // Query for the mail $result = SQL_QUERY_ESC("SELECT `id`, `%s` AS `mail_status` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `id`=%s LIMIT 1", - array($statusColumn, $table, bigintval($mailId)), __FILE__, __LINE__); + array( + $statusColumn, + $table, + bigintval($mailId) + ), __FILE__, __LINE__); // Do we have one entry there? if (SQL_NUMROWS($result) == 1) { // Load the entry $content = SQL_FETCHARRAY($result); - die('Unfinished area:
'.__FUNCTION__.':
content=
'.print_r($content, true).'
'); + + // Add output and type + $content['type'] = $mailType; + $content['__output'] = ''; + + // Filter all data + $content = runFilterChain('generate_admin_mail_links', $content); + + // Get output back + $OUT = $content['__output']; } // END - if // Free result @@ -2240,7 +2252,7 @@ function generateAdminMailLinks ($mailType, $mailId) { /** - * determine if a string can represent a number in hexadecimal + * Determine if a string can represent a number in hexadecimal * * @param $hex A string to check if it is hex-encoded * @return $foo True if the string is a hex, otherwise false @@ -2260,9 +2272,14 @@ function isHexadecimal ($hex) { return ($hex == dechex(hexdec($hex))); } -// Replace "\r" with "[r]" and "\n" with "[n]" and add a final new-line to make -// them visible to the developer. Use this function to debug e.g. buggy HTTP -// response handler functions. +/** + * Replace "\r" with "[r]" and "\n" with "[n]" and add a final new-line to make + * them visible to the developer. Use this function to debug e.g. buggy HTTP + * response handler functions. + * + * @param $str String to overwork + * @return $str Overworked string + */ function replaceReturnNewLine ($str) { return str_replace("\r", '[r]', str_replace("\n", '[n] ', $str)); @@ -2300,7 +2317,7 @@ function detectMultiBytePrefix ($str) { } // Searches the given array for a sub-string match and returns all found keys in an array -function getArrayKeysFromSubStrArray ($heystack, array $needles, $offset = 0) { +function getArrayKeysFromSubStrArray ($heystack, $needles, $offset = 0) { // Init array for all found keys $keys = array(); @@ -2320,6 +2337,7 @@ function getArrayKeysFromSubStrArray ($heystack, array $needles, $offset = 0) { // Determines database column name from given subject and locked function determinePointsColumnFromSubjectLocked ($subject, $locked) { + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ' - ENTERED!'); // Default is 'normal' points $pointsColumn = 'points'; @@ -2342,6 +2360,7 @@ function determinePointsColumnFromSubjectLocked ($subject, $locked) { $pointsColumn = $filterData['column']; // Return it + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ',pointsColumn=' . $pointsColumn . ' - EXIT!'); return $pointsColumn; } @@ -2391,6 +2410,39 @@ function translateTaskType ($taskType) { return $message; } +// Translates points subject to human-readable +function translatePointsSubject ($subject) { + // Construct message id + $messageId = 'POINTS_SUBJECT_' . strtoupper($subject) . ''; + + // Is the message id there? + if (isMessageIdValid($messageId)) { + // Then construct message + $message = '{--' . $messageId . '--}'; + } else { + // Else it is an unknown task type + $message = '{%message,POINTS_SUBJECT_UNKNOWN=' . $subject . '%}'; + } // END - if + + // Return message + return $message; +} + +// "Translates" 'true' to true and 'false' to false +function convertStringToBoolean ($str) { + // Trim it lower-case for validation + $str = trim(strtolower($str)); + + // Is it valid? + if (!in_array($str, array('true', 'false'))) { + // Not valid! + debug_report_bug(__FUNCTION__, __LINE__, 'str=' . $str . ' is not true/false'); + } // END - if + + // Return it + return (($str == 'true') ? true : false); +} + //----------------------------------------------------------------------------- // Automatically re-created functions, all taken from user comments on www.php.net //-----------------------------------------------------------------------------