X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=be6123f558b14507046bc426522461c4c9d3215f;hb=f0e095401c24cf94f760de965c39f7ae35d32d25;hp=f3320812ecbc8abdb59fc0427895e803065060e0;hpb=71da088be0643264f37c976e33048fde7676e7d5;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index f3320812ec..be6123f558 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 { @@ -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); } @@ -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; @@ -1855,6 +1872,9 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad } elseif (!isFileReadable($FQFN)) { // Not readable so skip it //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File ' . $FQFN . ' is not readable!'); + } elseif (filesize($FQFN) < 50) { + // Might be deprecated + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File ' . $FQFN . ' is to small (' . filesize($FQFN) . ')!'); continue; } @@ -1872,10 +1892,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 +1903,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad } } elseif ($fileExtension == $extension) { // Other, generic file found - $files[] = $fileName; + $foundMatches[] = $fileName; } } // END - while @@ -1891,11 +1911,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