X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Ffunctions.php;h=90f2b6d378b37e83312dd7bfb9c70e7e7a4fe79f;hb=fc9a6d12d5143014c74aa0e9ed0810b93f20b118;hp=1b6b5dc88c5487b808e723d6612bde81e66b9693;hpb=e3934352dffa6eb9da59a137ae1a9414e5b4d80b;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index 1b6b5dc88c..90f2b6d378 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -202,11 +202,11 @@ function sendRawEmail ($toEmail, $subject, $message, $headers) { $mail->Subject = $subject; if ((isExtensionActive('html_mail')) && (secureString($message) != $message)) { $mail->Body = $message; - $mail->AltBody = 'Your mail program required HTML support to read this mail!'; + $mail->AltBody = decodeEntities($message); $mail->WordWrap = 70; $mail->IsHTML(true); } else { - $mail->Body = decodeEntities($message); + $mail->Body = decodeEntities(strip_tags($message)); } $mail->AddAddress($toEmail, ''); @@ -534,6 +534,12 @@ function makeTime ($hours, $minutes, $seconds, $stamp) { // Redirects to an URL and if neccessarry extends it with own base URL function redirectToUrl ($url, $allowSpider = true) { + // Is the output mode -2? + if (getScriptOutputMode() == -2) { + // This is always (!) an AJAX request and shall not be redirected + return; + } // END - if + // Remove {%url= if (substr($url, 0, 6) == '{%url=') { $url = substr($url, 6, -2); @@ -558,12 +564,6 @@ function redirectToUrl ($url, $allowSpider = true) { // We should not sent a redirect if headers are already sent if (!headers_sent()) { - // Clear output buffer - clearOutputBuffer(); - - // Clear own output buffer - $GLOBALS['output'] = ''; - // Load URL when headers are not sent sendRawRedirect(doFinalCompilation(str_replace('&', '&', $url), false)); } else { @@ -767,7 +767,7 @@ function createFancyTime ($stamp) { foreach ($data as $k => $v) { if ($v > 0) { // Value is greater than 0 "eval" data to return string - $ret .= ', ' . $v . ' {--_' . strtoupper($k) . '--}'; + $ret .= ', ' . $v . ' {%pipe,translateTimeUnit=' . $k . '%}'; break; } // END - if } // END - foreach @@ -778,7 +778,7 @@ function createFancyTime ($stamp) { $ret = substr($ret, 2); } else { // Zero seconds - $ret = '0 {--_SECONDS--}'; + $ret = '0 {--TIME_UNIT_SECOND--}'; } // Return fancy time string @@ -801,7 +801,7 @@ function isEmailValid ($email) { } // Function taken from user comments on www.php.net / function isInStringIgnoreCase() -function isUrlValid ($url, $compile=true) { +function isUrlValid ($url, $compile = true) { // Trim URL a little $url = trim(urldecode($url)); //* DEBUG: */ debugOutput($url); @@ -1048,11 +1048,17 @@ function getCurrentTheme () { // The default theme is 'default'... ;-) $ret = 'default'; - // Do we have ext-theme installed and active? - if (isExtensionActive('theme')) { + // Do we have ext-theme installed and active or is 'theme' in URL or POST data? + if ((isPostRequestElementSet('theme')) && (isIncludeReadable(sprintf("theme/%s/theme.php", postRequestElement('theme'))))) { + // Use value from POST data + $ret = postRequestElement('theme'); + } elseif ((isGetRequestElementSet('theme')) && (isIncludeReadable(sprintf("theme/%s/theme.php", getRequestElement('theme'))))) { + // Use value from GET data + $ret = getRequestElement('theme'); + } elseif (isExtensionActive('theme')) { // Call inner method $ret = getActualTheme(); - } // END - if + } // Return theme value return $ret; @@ -1372,11 +1378,11 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0 function sendAdminNotification ($subject, $templateName, $content = array(), $userid = NULL) { if ((isExtensionInstalledAndNewer('admins', '0.4.1')) && (function_exists('sendAdminsEmails'))) { // Send new way - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=Y,subject=' . $subject . ',templateName=' . $templateName); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=Y,subject=' . $subject . ',templateName=' . $templateName . ' - OKAY!'); sendAdminsEmails($subject, $templateName, $content, $userid); } else { // Send out-dated way - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=N,subject=' . $subject . ',templateName=' . $templateName); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=N,subject=' . $subject . ',templateName=' . $templateName . ' - OUT-DATED!'); $message = loadEmailTemplate($templateName, $content, $userid); sendAdminEmails($subject, $message); } @@ -1440,7 +1446,7 @@ function convertSelectionsToEpocheTime (array &$postData, array &$content, &$id, if (in_array($test, array('_ye', '_mo', '_we', '_da', '_ho', '_mi', '_se'))) { // Found a multi-selection for timings? $test = substr($id, 0, -3); - if ((isset($postData[$test.'_ye'])) && (isset($postData[$test.'_mo'])) && (isset($postData[$test.'_we'])) && (isset($postData[$test.'_da'])) && (isset($postData[$test.'_ho'])) && (isset($postData[$test.'_mi'])) && (isset($postData[$test.'_se'])) && ($test != $test2)) { + if ((isset($postData[$test . '_ye'])) && (isset($postData[$test . '_mo'])) && (isset($postData[$test . '_we'])) && (isset($postData[$test . '_da'])) && (isset($postData[$test . '_ho'])) && (isset($postData[$test . '_mi'])) && (isset($postData[$test . '_se'])) && ($test != $test2)) { // Generate timestamp $postData[$test] = createEpocheTimeFromSelections($test, $postData); $content[] = sprintf("`%s`='%s'", $test, $postData[$test]); @@ -1572,8 +1578,8 @@ function determineRealRemoteAddress ($remoteAddr = false) { // This is a high-level function! function addNewBonusMail ($data, $mode = '', $output = true) { // Use mode from data if not set and availble ;-) - if ((empty($mode)) && (isset($data['mode']))) { - $mode = $data['mode']; + if ((empty($mode)) && (isset($data['mail_mode']))) { + $mode = $data['mail_mode']; } // END - if // Generate receiver list @@ -1793,19 +1799,32 @@ function isExtraTitleSet () { return ((isset($GLOBALS['extra_title'])) && (!empty($GLOBALS['extra_title']))); } -// Reads a directory recursively by default and searches for files not matching -// an exclusion pattern. You can now keep the exclusion pattern empty for reading -// a whole directory. +/** + * Reads a directory recursively by default and searches for files not matching + * an exclusion pattern. You can now keep the exclusion pattern empty for reading + * a whole directory. + * + * @param $baseDir Relative base directory to PATH to scan from + * @param $prefix Prefix for all positive matches (which files should be found) + * @param $fileIncludeDirs Wether to include directories in the final output array + * @param $addBaseDir Wether to add $baseDir to all array entries + * @param $excludeArray Excluded files and directories, these must be full files names, e.g. 'what-' will exclude all files named 'what-' but won't exclude 'what-foo.php' + * @param $extension File extension for all positive matches + * @param $excludePattern Regular expression to exclude more files (preg_match()) + * @param $recursive Wether to scan recursively + * @param $suffix Suffix for positive matches ($extension will be appended, too) + * @return $foundMatches All found positive matches for above criteria + */ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $addBaseDir = true, $excludeArray = array(), $extension = '.php', $excludePattern = '@(\.|\.\.)$@', $recursive = true, $suffix = '') { - // Add default entries we should exclude - $excludeArray[] = '.'; - $excludeArray[] = '..'; - $excludeArray[] = '.svn'; - $excludeArray[] = '.htaccess'; + // Add default entries we should always exclude + $excludeArray[] = '.'; // Current directory + $excludeArray[] = '..'; // Parent directory + $excludeArray[] = '.svn'; // Directories created by Subversion + $excludeArray[] = '.htaccess'; // Directory protection files (mostly) //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'baseDir=' . $baseDir . ',prefix=' . $prefix . ' - Entered!'); - // Init includes - $files = array(); + // Init found includes + $foundMatches = array(); // Open directory $dirPointer = opendir(getPath() . $baseDir) or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.'); @@ -1828,10 +1847,8 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Check if the base filenname matches an exclusion pattern and if the pattern is not empty if ((!empty($excludePattern)) && (preg_match($excludePattern, $baseFile, $match))) { - // These Lines are only for debugging!! - //* DEBUG: */ debugOutput('baseDir:' . $baseDir); - //* DEBUG: */ debugOutput('baseFile:' . $baseFile); - //* DEBUG: */ debugOutput('FQFN:' . $FQFN); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'baseDir=' . $baseDir . ',baseFile=' . $baseFile . ',FQFN=' . $FQFN); // Exclude this one continue; @@ -1840,7 +1857,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Skip also files with non-matching prefix genericly if (($recursive === true) && (isDirectory($FQFN))) { // Is a redirectory so read it as well - $files = merge_array($files, getArrayFromDirectory($baseDir . $baseFile . '/', $prefix, $fileIncludeDirs, $addBaseDir, $excludeArray, $extension, $excludePattern, $recursive)); + $foundMatches = merge_array($foundMatches, getArrayFromDirectory($baseDir . $baseFile . '/', $prefix, $fileIncludeDirs, $addBaseDir, $excludeArray, $extension, $excludePattern, $recursive)); // And skip further processing continue; @@ -1872,10 +1889,10 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Add file with or without base path if ($addBaseDir === true) { // With base path - $files[] = $fileName; + $foundMatches[] = $fileName; } else { // No base path - $files[] = $baseFile; + $foundMatches[] = $baseFile; } } else { // We found .php file but should not search for them, why? @@ -1883,7 +1900,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad } } elseif ($fileExtension == $extension) { // Other, generic file found - $files[] = $fileName; + $foundMatches[] = $fileName; } } // END - while @@ -1891,11 +1908,11 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad closedir($dirPointer); // Sort array - sort($files); + sort($foundMatches); // Return array with include files //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Left!'); - return $files; + return $foundMatches; } // Checks wether $prefix is found in $fileName @@ -2134,7 +2151,7 @@ function handleFieldWithBraces ($field) { } // Converts a zero or NULL to word 'NULL' -function makeZeroToNull ($number) { +function convertZeroToNull ($number) { // Is it a valid username? if ((!is_null($number)) && (!empty($number)) && ($number > 0)) { // Always secure it @@ -2149,7 +2166,7 @@ function makeZeroToNull ($number) { } // Converts a NULL to zero -function makeNullToZero ($number) { +function convertNullToZero ($number) { // Is it a valid username? if ((!is_null($number)) && (!empty($number)) && ($number > 0)) { // Always secure it