]> git.mxchange.org Git - mailer.git/blobdiff - inc/request-functions.php
Fixed handling of float values, ext-surfbar continued:
[mailer.git] / inc / request-functions.php
index c4afd304a919d52d64ef19dbbf0f4d8a7185ffe4..e3296109b45ebdc0bf09d700e9f7ccf9bc434968 100644 (file)
@@ -90,7 +90,7 @@ function getRequestArray () {
 // Counts entries in $_GET or returns false if not an array
 function countRequestGet () {
        // By default this is not an array
-       $count = false;
+       $count = FALSE;
 
        // Get the array
        $GET = getRequestArray();
@@ -155,10 +155,20 @@ function postRequestElement ($element, $subElement = NULL) {
 
 // Checks if an element in $_POST exists
 function isPostRequestElementSet ($element, $subElement = NULL) {
+       /*
+        * Always check that $element is a string and that $subElement is NULL or
+        * a string as numerical indexes are not wanted in POST data (in this
+        * project).
+        */
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element[]=' . gettype($element) . ',subElement[]=' . gettype($subElement));
+       assert(is_string($element) && ((is_null($subElement)) || (is_string($subElement)) || (is_int($subElement)) || (is_double($subElement))));
+
+       // Is a sub element set?
        if (is_null($subElement)) {
-               if (!is_string($element)) die(gettype($element));
+               // No, then only check $element
                return ((isset($GLOBALS['raw_request']['post'][$element])) && ((is_array($GLOBALS['raw_request']['post'][$element])) || (('' . $GLOBALS['raw_request']['post'][$element] . '') != '')));
        } else {
+               // Yes, then check both together
                return ((isset($GLOBALS['raw_request']['post'][$element][$subElement])) && (('' . $GLOBALS['raw_request']['post'][$element][$subElement] . '') != ''));
        }
 }
@@ -182,7 +192,7 @@ function setPostRequestArray ($postData) {
 // Counts entries in $_POST or returns false if not an array
 function countRequestPost () {
        // By default this is not an array
-       $count = false;
+       $count = FALSE;
 
        // Get the array
        $postData = postRequestArray();
@@ -219,16 +229,22 @@ function setPostRequestElement ($element, $value) {
                // Value is an array so set it directly
                $GLOBALS['raw_request']['post'][$element] = $value;
        } else {
+               // Debug message
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',value=' . $value . ' - BEFORE!');
+
                // Escape both
                $element = SQL_ESCAPE($element);
                $value   = SQL_ESCAPE($value);
 
+               // Debug message
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',value=' . $value . ' - AFTER!');
+
                // Set regular entry
                $GLOBALS['raw_request']['post'][$element] = $value;
        }
 
        // Update cache
-       $GLOBALS['cache_request']['post'][$element][null] = $value;
+       $GLOBALS['cache_request']['post'][$element][NULL] = $value;
 }
 
 // Checks whether a form was sent. If so, the $_POST['ok'] element must be set