Rewrote some parts:
[mailer.git] / inc / libs / theme_functions.php
index 09dee2dd5df886db06016112589d0edebd708c44..74894b99564c3dabaf3dcb7dfa47b0220f913540 100644 (file)
@@ -77,13 +77,10 @@ ORDER BY
 
        // Load all themes
        while ($row = sqlFetchArray($result)) {
-               // Construct relative include file name
-               $inc = sprintf("theme/%s/theme.php", secureString($row['theme_path']));
-
                // Load it's theme.php file if found
-               if (isIncludeReadable($inc)) {
+               if (isThemeReadable($row['theme_path'])) {
                        // And save all data in array
-                       loadInclude($inc);
+                       loadInclude(sprintf('theme/%s/theme.php', secureString($row['theme_path'])));
                        array_push($themesArray['theme_unix'], $row['theme_path']);
                        array_push($themesArray['theme_name'], $row['theme_name']);
                } // END - if
@@ -154,7 +151,7 @@ function getThemeVersion ($name) {
 // Checks whether a theme is found in db
 function ifThemeExists ($name) {
        // Get theme and is it not nul?
-       return (((isExtensionActive('theme')) || (getModule() == 'admin')) && (getThemeId($name) > 0));
+       return (((isExtensionActive('theme')) || (getModule() == 'admin')) && (isValidId(getThemeId($name))));
 }
 
 // Checks if a theme is active
@@ -250,13 +247,13 @@ function getActualTheme () {
                } // END - if
        } elseif ((!isInstalled()) && ((isInstalling()) || (isHtmlOutputMode())) && ((isGetRequestElementSet('theme')) || (isPostRequestElementSet('theme')))) {
                // Prepare filename for checking
-               $themeFile = sprintf("theme/%s/theme.php", getRequestElement('theme'));
+               $themeFile = sprintf('theme/%s/theme.php', getRequestElement('theme'));
 
                // Installation mode active
-               if ((isGetRequestElementSet('theme')) && (isIncludeReadable($theme))) {
+               if ((isGetRequestElementSet('theme')) && (isThemeReadable(getRequestElement('theme')))) {
                        // Set cookie from URL data
                        setMailerTheme(getRequestElement('theme'));
-               } elseif (isIncludeReadable(sprintf("theme/%s/theme.php", postRequestElement('theme')))) {
+               } elseif ((isPostRequestElementSet('theme')) && (isThemeReadable(postRequestElement('theme')))) {
                        // Set cookie from posted data
                        setMailerTheme(postRequestElement('theme'));
                }