$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, '');
// 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);
// 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 {
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
$ret = substr($ret, 2);
} else {
// Zero seconds
- $ret = '0 {--_SECONDS--}';
+ $ret = '0 {--TIME_UNIT_SECOND--}';
}
// Return fancy time string
}
// 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);
// 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;
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);
}
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) . '.');
// 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;
// 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;
// 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?
}
} elseif ($fileExtension == $extension) {
// Other, generic file found
- $files[] = $fileName;
+ $foundMatches[] = $fileName;
}
} // END - while
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