X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Frequest-functions.php;h=d7817ba0c921108d059409c33ac75941c3a28cd2;hb=647822147615bad8572ad4282c9c3958fe983f5c;hp=b110317396d89a7f79617ae8a9edb9b4fc2acf6e;hpb=f74581eca45c393033acfd9d7798b958031bc625;p=mailer.git diff --git a/inc/request-functions.php b/inc/request-functions.php index b110317396..d7817ba0c9 100644 --- a/inc/request-functions.php +++ b/inc/request-functions.php @@ -1,7 +1,7 @@ '; + } elseif (isPostRequestElementSet($element)) { + // Then use it + $value = $GLOBALS['raw_request']['post'][$element]; + + // Is $subElement set? + if ((!is_null($subElement)) && (isPostRequestElementSet($element, $subElement))) { + // Then use this + $value = SQL_ESCAPE($value[$subElement]); + //* DEBUG: */ print 'sub!
'; + } elseif (!is_array($value)) { + // Escape it here + $value = SQL_ESCAPE($value); + //* DEBUG: */ print 'no-array!
'; + } + + // Set it in cache + //* DEBUG: */ print $element.'/'.$subElement.'='.$value.'
'; + //* DEBUG: */ print('
'.print_r($_POST,true).'
'); + $GLOBALS['cache_request']['post'][$element][$subElement] = $value; } // END - if // Return value @@ -110,46 +152,123 @@ function REQUEST_POST ($element) { } // Checks if an element in $_POST exists -function REQUEST_ISSET_POST ($element, $extra="") { - if (empty($extra)) { - return (isset($_POST[$element])); +function isPostRequestElementSet ($element, $subElement = NULL) { + if (is_null($subElement)) { + return ((isset($GLOBALS['raw_request']['post'][$element])) && (('' . $GLOBALS['raw_request']['post'][$element] . '') != '')); } else { - return (isset($_POST[$element][$extra])); + return ((isset($GLOBALS['raw_request']['post'][$element][$subElement])) && (('' . $GLOBALS['raw_request']['post'][$element][$subElement] . '') != '')); } } // Removes an element from $_POST -function REQUEST_UNSET_POST ($element) { - unset($_POST[$element]); +function unsetPostRequestElement ($element) { + unset($GLOBALS['raw_request']['post'][$element]); } // Getter for whole $_POST array -function REQUEST_POST_ARRAY () { - return $_POST; +function postRequestArray () { + return $GLOBALS['raw_request']['post']; +} + +// Setter for whole $_POST array +function setPostRequestArray ($postData) { + $GLOBALS['raw_request']['post'] = $postData; } // Counts entries in $_POST or returns false if not an array -function REQUEST_POST_COUNT () { +function countRequestPost () { // By default this is not an array $count = false; // Get the array - $POST = REQUEST_POST_ARRAY(); + $postData = postRequestArray(); // Is it an array? - if (is_array($POST)) { + if (is_array($postData)) { // Then count it - $count = count($POST); + $count = count($postData); } // END - if // Return value } +// Setter for element in $_POST +function setPostRequestElement ($element, $value) { + // Is $element or $value an array? + if (is_array($element)) { + // Set array + $eval = "\$GLOBALS['raw_request']['post']['"; + + // Add all entries + $eval .= implode("']['", $element); + + // Finish eval() command + $eval .= sprintf("'] = \"%s\";", SQL_ESCAPE($value)); + + // And run it + eval($eval); + } elseif (is_array($value)) { + // Escape element + $element = SQL_ESCAPE($element); + + // Value is an array so set it directly + $GLOBALS['raw_request']['post'][$element] = $value; + } else { + // Escape both + $element = SQL_ESCAPE($element); + $value = SQL_ESCAPE($value); + + // Set regular entry + $GLOBALS['raw_request']['post'][$element] = $value; + } + + // Update cache + $GLOBALS['cache_request']['post'][$element][null] = $value; +} + // Checks wether a form was sent. If so, the $_POST['ok'] element must be set -function IS_FORM_SENT () { +function isFormSent ($requestParameter = 'ok') { // Simply wrap it! - return REQUEST_ISSET_POST('ok'); + return isPostRequestElementSet($requestParameter); +} + +// Checks if 'content_type' is set +function isContentTypeSet () { + return isset($GLOBALS['content_type']); +} + +// Setter for content type +function setContentType ($contentType) { + $GLOBALS['content_type'] = (string) $contentType; +} + +// Getter for content type +function getContentType () { + return $GLOBALS['content_type']; +} + +// Getter for request URI +function getRequestUri () { + return $_SERVER['REQUEST_URI']; +} + +// Add all GET parameters to a string (without leading sign) +function addAllGetRequestParameters () { + // Init variable + $return = ''; + + // Now add all parameters + foreach (getRequestArray() as $key => $value) { + // Add it secured + $return .= SQL_ESCAPE($key) . '=' . SQL_ESCAPE($value) . '&'; + } // END - foreach + + // Remove trailing & + $return = substr($return, 0, -5); + + // Return it + return $return; } -// +// [EOF] ?>