<?php
/************************************************************************
- * MXChange v0.2.1 Start: 02/28/2009 *
- * =============== Last change: 02/28/2009 *
+ * Mailer v0.2.1-FINAL Start: 02/28/2009 *
+ * =================== Last change: 02/28/2009 *
* *
* -------------------------------------------------------------------- *
* File : request-functions.php *
* $Date:: $ *
* $Tag:: 0.2.1-FINAL $ *
* $Author:: $ *
- * Needs to be in all Files and every File needs "svn propset *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * For more information visit: http://www.mxchange.org *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
// Initialize the request elements
function initRequest () {
- $GLOBALS['raw_request']['get'] = $_GET;
- $GLOBALS['raw_request']['post'] = $_POST;
+ $GLOBALS['raw_request']['get'] = (array) $_GET;
+ $GLOBALS['raw_request']['post'] = (array) $_POST;
}
// Wrapper for elements in $_GET
function getRequestElement ($element) {
// By default no element is there
- $value = null;
+ $value = NULL;
// Is the element cached or there?
- if (isset($GLOBALS['cache_request']['request_get'][$element])) {
+ if (isset($GLOBALS['cache_request']['get'][$element])) {
// Then use the cache
- $value = $GLOBALS['cache_request']['request_get'][$element];
+ $value = $GLOBALS['cache_request']['get'][$element];
} elseif (isGetRequestElementSet($element)) {
// Then get it directly
$value = SQL_ESCAPE($GLOBALS['raw_request']['get'][$element]);
// Store it in cache
- $GLOBALS['cache_request']['request_get'][$element] = $value;
+ $GLOBALS['cache_request']['get'][$element] = $value;
} // END - if
// Return value
// Checks if an element in $_GET exists
function isGetRequestElementSet ($element, $subElement = '') {
if (empty($subElement)) {
- return ((isset($GLOBALS['raw_request']['get'][$element])) && (!empty($GLOBALS['raw_request']['get'][$element])));
+ return ((isset($GLOBALS['raw_request']['get'][$element])) && ('' . ($GLOBALS['raw_request']['get'][$element] . '') != ''));
} else {
- return ((isset($GLOBALS['raw_request']['get'][$element][$subElement])) && (!empty($GLOBALS['raw_request']['get'][$element][$subElement])));
+ return ((isset($GLOBALS['raw_request']['get'][$element][$subElement])) && ('' . ($GLOBALS['raw_request']['get'][$element][$subElement] . '') != ''));
}
}
}
// Setter for element in $_GET
-function setRequestGetElement ($element, $value) {
+function setGetRequestElement ($element, $value) {
// Escape both
$element = SQL_ESCAPE($element);
$value = SQL_ESCAPE($value);
$GLOBALS['raw_request']['get'][$element] = $value;
// Update cache
- $GLOBALS['cache_request']['request_get'][$element][null] = $value;
+ $GLOBALS['cache_request']['get'][$element] = $value;
}
// Wrapper for elements in $_POST
-function postRequestElement ($element, $subElement=null) {
+function postRequestElement ($element, $subElement = NULL) {
// By default no element is there
- $value = null;
+ $value = NULL;
// Is the element in cache?
- if (isset($GLOBALS['cache_request']['request_post'][$element][$subElement])) {
+ if (isset($GLOBALS['cache_request']['post'][$element][$subElement])) {
// Then use it
- $value = $GLOBALS['cache_request']['request_post'][$element][$subElement];
+ $value = $GLOBALS['cache_request']['post'][$element][$subElement];
+ //* DEBUG: */ print $element.'/'.$subElement.'='.$value.'<br />';
} elseif (isPostRequestElementSet($element)) {
// Then use it
$value = $GLOBALS['raw_request']['post'][$element];
if ((!is_null($subElement)) && (isPostRequestElementSet($element, $subElement))) {
// Then use this
$value = SQL_ESCAPE($value[$subElement]);
+ //* DEBUG: */ print 'sub!<br />';
} elseif (!is_array($value)) {
// Escape it here
$value = SQL_ESCAPE($value);
+ //* DEBUG: */ print 'no-array!<br />';
}
// Set it in cache
- $GLOBALS['cache_request']['request_post'][$element][$subElement] = $value;
+ //* DEBUG: */ print $element.'/'.$subElement.'='.$value.'<br />';
+ //* DEBUG: */ print('<pre>'.print_r($_POST,true).'</pre>');
+ $GLOBALS['cache_request']['post'][$element][$subElement] = $value;
} // END - if
// Return value
}
// Checks if an element in $_POST exists
-function isPostRequestElementSet ($element, $subElement=null) {
+function isPostRequestElementSet ($element, $subElement = NULL) {
if (is_null($subElement)) {
- return ((isset($GLOBALS['raw_request']['post'][$element])) && (!empty($GLOBALS['raw_request']['post'][$element])));
+ return ((isset($GLOBALS['raw_request']['post'][$element])) && (('' . $GLOBALS['raw_request']['post'][$element] . '') != ''));
} else {
- return ((isset($GLOBALS['raw_request']['post'][$element][$subElement])) && (!empty($GLOBALS['raw_request']['post'][$element][$subElement])));
+ return ((isset($GLOBALS['raw_request']['post'][$element][$subElement])) && (('' . $GLOBALS['raw_request']['post'][$element][$subElement] . '') != ''));
}
}
}
// Setter for whole $_POST array
-function setPostRequestArray (array $postData) {
+function setPostRequestArray ($postData) {
$GLOBALS['raw_request']['post'] = $postData;
}
} // END - if
// Return value
+ return $count;
}
// Setter for element in $_POST
-function setRequestPostElement ($element, $value) {
+function setPostRequestElement ($element, $value) {
// Is $element or $value an array?
if (is_array($element)) {
// Set array
}
// Update cache
- $GLOBALS['cache_request']['request_post'][$element][null] = $value;
+ $GLOBALS['cache_request']['post'][$element][null] = $value;
}
// Checks wether a form was sent. If so, the $_POST['ok'] element must be set
-function isFormSent () {
+function isFormSent ($requestParameter = 'ok') {
// Simply wrap it!
- return isPostRequestElementSet('ok');
+ return isPostRequestElementSet($requestParameter);
+}
+
+// Checks if 'content_type' is set
+function isContentTypeSet () {
+ return isset($GLOBALS['content_type']);
}
// Setter for content type
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]
?>