]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
Deprecated action=login (admin area) removed
[mailer.git] / inc / wrapper-functions.php
index 6803dfc37810eee46a9a9f38a5763230f3fb4365..7068fdc8bb5baee5a5d0b658101fd58d621ccfe5 100644 (file)
@@ -44,6 +44,12 @@ if (!defined('__SECURITY')) {
 
 // Read a given file
 function readFromFile ($FQFN, $sqlPrepare = false) {
+       // Sanity-check if file is there (should be there, but just to make it sure)
+       if (!isFileReadable($FQFN)) {
+               // This should not happen
+               debug_report_bug(__FUNCTION__.': File ' . basename($FQFN) . ' is not readable!');
+       } // END - if
+
        // Load the file
        if (function_exists('file_get_contents')) {
                // Use new function
@@ -125,11 +131,11 @@ function loadInclude ($INC) {
 function loadIncludeOnce ($INC) {
        // Is it not loaded?
        if (!isset($GLOBALS['load_once'][$INC])) {
+               // Mark it as loaded
+               $GLOBALS['load_once'][$INC] = "loaded";
+
                // Then try to load it
                loadInclude($INC);
-
-               // And mark it as loaded
-               $GLOBALS['load_once'][$INC] = "loaded";
        } // END - if
 }
 
@@ -278,7 +284,28 @@ function isInstalling () {
 
 // Check wether this script is installed
 function isInstalled () {
-       return (getConfig('MXCHANGE_INSTALLED') == 'Y');
+       return (
+       (
+               // New config file found and loaded
+               getConfig('MXCHANGE_INSTALLED') == 'Y'
+       ) || (
+               // Fall-back!
+               isIncludeReadable('inc/config.php')
+       ) || (
+               (
+                       // New config file found, but not yet read
+                       isIncludeReadable('inc/cache/config-local.php')
+               ) && (
+                       (
+                               // Only new config file is found
+                               !isIncludeReadable('inc/config.php')
+                       ) || (
+                               // Is installation mode
+                               isInstalling()
+                       )
+               )
+       )
+       );
 }
 
 // Check wether an admin is registered
@@ -298,6 +325,12 @@ function isDebugModeEnabled () {
        return (getConfig('DEBUG_MODE') == 'Y');
 }
 
+// Checks wether we shall debug regular expressions
+function isDebugRegExpressionEnabled () {
+       // Simply check it
+       return (getConfig('DEBUG_REGEX') == 'Y');
+}
+
 // Checks wether the cache instance is valid
 function isCacheInstanceValid () {
        return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance'])));
@@ -351,14 +384,14 @@ function sendHeader ($header) {
        } // END - if
 
        // Send the header
-       header($header);
+       header(trim($header));
 }
 
 // Wrapper function for chmod()
 // @TODO Do some more sanity check here
 function changeMode ($FQFN, $mode) {
        // Is the file/directory there?
-       if ((!isFile($FQFN)) && (!isDirectory($FQFN))) {
+       if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
                // Neither, so abort here
                debug_report_bug('Cannot chmod() on ' . basename($FQFN) . '.');
        } // END - if
@@ -367,10 +400,28 @@ function changeMode ($FQFN, $mode) {
        chmod($FQFN, $mode);
 }
 
+// Wrapper for unlink()
+function removeFile ($FQFN) {
+       // Is the file there?
+       if (isFileReadable($FQFN)) {
+               // Yes, so remove it
+               return unlink($FQFN);
+       } // END - if
+
+       // All fine if no file was removed. If we change this to 'false' or rewrite
+       // above if() block it would be to restrictive.
+       return true;
+}
+
 // Wrapper for $_POST['sel']
 function countPostSelection () {
        return countSelection(REQUEST_POST('sel'));
 }
 
+// Checks wether the config-local.php is loaded
+function isConfigLocalLoaded () {
+       return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
+}
+
 // [EOF]
 ?>