]> git.mxchange.org Git - mailer.git/blobdiff - inc/request-functions.php
New method generateExtensionInactiveMessage() introduced
[mailer.git] / inc / request-functions.php
index b110317396d89a7f79617ae8a9edb9b4fc2acf6e..b720ffc2d37589018fe592ee9eece8671f555f10 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Spezialle Funktionen fuer die Anfragebehandlung  *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $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 - 2008 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
@@ -33,7 +38,7 @@
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
        require($INC);
 } // END - if
 
@@ -59,11 +64,11 @@ function REQUEST_GET ($element) {
 }
 
 // Checks if an element in $_GET exists
-function REQUEST_ISSET_GET ($element, $extra="") {
-       if (empty($extra)) {
-               return (isset($_GET[$element]));
+function REQUEST_ISSET_GET ($element, $subElement = '') {
+       if (empty($subElement)) {
+               return ((isset($_GET[$element])) && (!empty($_GET[$element])));
        } else {
-               return (isset($_GET[$element][$extra]));
+               return ((isset($_GET[$element][$subElement])) && (!empty($_GET[$element][$subElement])));
        }
 }
 
@@ -94,8 +99,13 @@ function REQUEST_GET_COUNT () {
        // Return value
 }
 
+// Setter for element in $_GET
+function REQUEST_SET_GET ($element, $value) {
+       $_GET[SQL_ESCAPE($element)] = SQL_ESCAPE($value);
+}
+
 // Wrapper for elements in $_POST
-function REQUEST_POST ($element) {
+function REQUEST_POST ($element, $subElement=null) {
        // By default no element is there
        $value = null;
 
@@ -103,6 +113,12 @@ function REQUEST_POST ($element) {
        if (REQUEST_ISSET_POST($element)) {
                // Then use it
                $value = $_POST[$element];
+
+               // Is $subElement set?
+               if ((!is_null($subElement)) && (REQUEST_ISSET_POST($element, $subElement))) {
+                       // Then use this
+                       $value = $value[$subElement];
+               } // END - if
        } // END - if
 
        // Return value
@@ -110,11 +126,11 @@ 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 REQUEST_ISSET_POST ($element, $subElement=null) {
+       if (is_null($subElement)) {
+               return ((isset($_POST[$element])) && (!empty($_POST[$element])));
        } else {
-               return (isset($_POST[$element][$extra]));
+               return ((isset($_POST[$element][$subElement])) && (!empty($_POST[$element][$subElement])));
        }
 }
 
@@ -145,8 +161,31 @@ function REQUEST_POST_COUNT () {
        // Return value
 }
 
+// Setter for element in $_POST
+function REQUEST_SET_POST ($element, $value) {
+       if (is_array($element)) {
+               // Set array
+               $eval = "\$_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)) {
+               // Value is an array so set it directly
+               $_POST[SQL_ESCAPE($element)] = $value;
+       } else {
+               // Set regular entry
+               $_POST[SQL_ESCAPE($element)] = SQL_ESCAPE($value);
+       }
+}
+
 // Checks wether a form was sent. If so, the $_POST['ok'] element must be set
-function IS_FORM_SENT () {
+function isFormSent () {
        // Simply wrap it!
        return REQUEST_ISSET_POST('ok');
 }