0066994f26757168c63a4fbe8aef21bde6e2f150
[mailer.git] / inc / request-functions.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 02/28/2009 *
4  * ===============                              Last change: 02/28/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : request-functions.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Special functions for request handling           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Spezialle Funktionen fuer die Anfragebehandlung  *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 } // END - if
39
40 // Wrapper for elements in $_GET
41 function REQUEST_GET ($element) {
42         // By default no element is there
43         $value = null;
44
45         // Is the element there?
46         if (REQUEST_ISSET_GET($element)) {
47                 // Then use it
48                 $value = $_GET[$element];
49         } // END - if
50
51         // Return value
52         return $value;
53 }
54
55 // Checks if an element in $_GET exists
56 function REQUEST_ISSET_GET ($element) {
57         return (isset($_GET['element']));
58 }
59
60 // Removes an element from $_GET
61 function REQUEST_UNSET_GET ($element) {
62         unset($_GET[$element]);
63 }
64
65 // Getter for whole $_GET array
66 function REQUEST_GET_ARRAY () {
67         return $_GET;
68 }
69
70 // Counts entries in $_GET or returns false if not an array
71 function REQUEST_GET_COUNT () {
72         // By default this is not an array
73         $count = false;
74
75         // Get the array
76         $GET = REQUEST_GET_ARRAY();
77
78         // Is it an array?
79         if (is_array($GET)) {
80                 // Then count it
81                 $count = count($GET);
82         } // END - if
83
84         // Return value
85 }
86
87 // Wrapper for elements in $_POST
88 function REQUEST_POST ($element) {
89         // By default no element is there
90         $value = null;
91
92         // Is the element there?
93         if (REQUEST_ISSET_POST($element)) {
94                 // Then use it
95                 $value = $_POST[$element];
96         } // END - if
97
98         // Return value
99         return $value;
100 }
101
102 // Checks if an element in $_POST exists
103 function REQUEST_ISSET_POST ($element) {
104         return (isset($_POST['element']));
105 }
106
107 // Removes an element from $_POST
108 function REQUEST_UNSET_POST ($element) {
109         unset($_POST[$element]);
110 }
111
112 // Getter for whole $_POST array
113 function REQUEST_POST_ARRAY () {
114         return $_POST;
115 }
116
117 // Counts entries in $_POST or returns false if not an array
118 function REQUEST_POST_COUNT () {
119         // By default this is not an array
120         $count = false;
121
122         // Get the array
123         $POST = REQUEST_POST_ARRAY();
124
125         // Is it an array?
126         if (is_array($POST)) {
127                 // Then count it
128                 $count = count($POST);
129         } // END - if
130
131         // Return value
132 }
133
134 // Checks wether a form was sent. If so, the $_POST['ok'] element must be set
135 function IS_FORM_SENT () {
136         // Simply wrap it!
137         return REQUEST_ISSET_POST('ok');
138 }
139
140 //
141 ?>