]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
More usage of isValidUserId()
[mailer.git] / inc / wrapper-functions.php
index 894c2f4d4e19bc8c26bb1b0053cabdcf762a37b1..8a85b56b5ec6d5684b26b33075e3da23b9a7e052 100644 (file)
@@ -559,7 +559,7 @@ function getAction ($strict = true) {
        $action = null;
 
        // Is the value set?
-       if (isActionSet(($strict) && (getScriptOutputMode() == 0))) {
+       if (isActionSet(($strict) && (isHtmlOutputMode()))) {
                // Then use it
                $action = $GLOBALS['action'];
        } // END - if
@@ -804,7 +804,10 @@ function setAdminHash ($adminId, $hash) {
 // Init user data array
 function initUserData () {
        // User id should not be zero
-       if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+       if (!isValidUserId(getCurrentUserId())) {
+               // Should be always valid
+               debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+       } // END - if
 
        // Init the user
        $GLOBALS['user_data'][getCurrentUserId()] = array();
@@ -813,7 +816,10 @@ function initUserData () {
 // Getter for user data
 function getUserData ($column) {
        // User id should not be zero
-       if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+       if (!isValidUserId(getCurrentUserId())) {
+               // Should be always valid
+               debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+       } // END - if
 
        // Return the value
        return $GLOBALS['user_data'][getCurrentUserId()][$column];
@@ -822,15 +828,18 @@ function getUserData ($column) {
 // Geter for whole user data array
 function getUserDataArray () {
        // Get user id
-       $uid = getCurrentUserId();
+       $userid = getCurrentUserId();
 
-       // User id should not be zero
-       if ($uid < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+       // Is the current userid valid?
+       if (!isValidUserId($userid)) {
+               // Should be always valid
+               debug_report_bug(__FUNCTION__, __LINE__, 'User id is invalid.');
+       } // END - if
 
        // Get the whole array if found
-       if (isset($GLOBALS['user_data'][$uid])) {
+       if (isset($GLOBALS['user_data'][$userid])) {
                // Found, so return it
-               return $GLOBALS['user_data'][$uid];
+               return $GLOBALS['user_data'][$userid];
        } else {
                // Return empty array
                return array();
@@ -963,7 +972,7 @@ function sendRawRedirect ($url) {
 
        // check if running on IIS < 6 with CGI-PHP
        if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
-               (strpos($_SERVER['GATEWAY_INTERFACE'],'CGI') !== false) &&
+               (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) &&
                (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
                ($matches[1] < 6)) {
                // Send the IIS header
@@ -1049,7 +1058,7 @@ function isValidUserId ($userid) {
 // Encodes entities
 function encodeEntities ($str) {
        // Secure it first
-       $str = secureString($str);
+       $str = secureString($str, true, true);
 
        // Encode dollar sign as well
        $str = str_replace('$', '&#36;', $str);
@@ -1814,6 +1823,18 @@ function getIndexHome () {
        return $GLOBALS['index_home'];
 }
 
+// "Getter" for one_day
+function getOneDay () {
+       // Do we have cache?
+       if (!isset($GLOBALS['one_day'])) {
+               // Determine it
+               $GLOBALS['one_day'] = getConfig('ONE_DAY');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['one_day'];
+}
+
 // Checks wether proxy configuration is used
 function isProxyUsed () {
        // Do we have cache?
@@ -1831,7 +1852,7 @@ function ifPostContainsSelections ($element = 'sel') {
        // Do we have cache?
        if (!isset($GLOBALS['post_contains_selections'][$element])) {
                // Determine it
-               $GLOBALS['post_contains_selections'][$element] = (countPostSelection($element) > 0);
+               $GLOBALS['post_contains_selections'][$element] = ((isPostRequestParameterSet($element)) && (countPostSelection($element) > 0));
        } // END - if
 
        // Return cache
@@ -1886,5 +1907,35 @@ function isDirectPaymentAllowed () {
        return $GLOBALS['is_direct_payment_allowed'];
 }
 
+// Wrapper to check if current task is for extension (not update)
+function isExtensionTask ($content) {
+       // Do we have cache?
+       if (!isset($GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']])) {
+               // Determine it
+               $GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['is_extension_task'][$content['task_type'] . '_' . $content['infos']];
+}
+
+// Wrapper to check if output mode is CSS
+function isCssOutputMode () {
+       // Determine it
+       return (getScriptOutputMode() == 1);
+}
+
+// Wrapper to check if output mode is HTML
+function isHtmlOutputMode () {
+       // Determine it
+       return (getScriptOutputMode() == 0);
+}
+
+// Wrapper to check if output mode is RAW
+function isRawOutputMode () {
+       // Determine it
+       return (getScriptOutputMode() == -1);
+}
+
 // [EOF]
 ?>