Debug code commented out
[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 cached or there?
46         if (isset($GLOBALS['cache_array']['request_get'][$element])) {
47                 // Then use the cache
48                 $value = $GLOBALS['cache_array']['request_get'][$element];
49         } elseif (REQUEST_ISSET_GET($element)) {
50                 // Then get it directly
51                 $value = SQL_ESCAPE($_GET[$element]);
52
53                 // Store it in cache
54                 $GLOBALS['cache_array']['request_get'][$element] = $value;
55         } // END - if
56
57         // Return value
58         return $value;
59 }
60
61 // Checks if an element in $_GET exists
62 function REQUEST_ISSET_GET ($element) {
63         return (isset($_GET[$element]));
64 }
65
66 // Removes an element from $_GET
67 function REQUEST_UNSET_GET ($element) {
68         unset($_GET[$element]);
69 }
70
71 // Getter for whole $_GET array
72 function REQUEST_GET_ARRAY () {
73         return $_GET;
74 }
75
76 // Counts entries in $_GET or returns false if not an array
77 function REQUEST_GET_COUNT () {
78         // By default this is not an array
79         $count = false;
80
81         // Get the array
82         $GET = REQUEST_GET_ARRAY();
83
84         // Is it an array?
85         if (is_array($GET)) {
86                 // Then count it
87                 $count = count($GET);
88         } // END - if
89
90         // Return value
91 }
92
93 // Wrapper for elements in $_POST
94 function REQUEST_POST ($element) {
95         // By default no element is there
96         $value = null;
97
98         // Is the element there?
99         if (REQUEST_ISSET_POST($element)) {
100                 // Then use it
101                 $value = $_POST[$element];
102         } // END - if
103
104         // Return value
105         return $value;
106 }
107
108 // Checks if an element in $_POST exists
109 function REQUEST_ISSET_POST ($element) {
110         return (isset($_POST[$element]));
111 }
112
113 // Removes an element from $_POST
114 function REQUEST_UNSET_POST ($element) {
115         unset($_POST[$element]);
116 }
117
118 // Getter for whole $_POST array
119 function REQUEST_POST_ARRAY () {
120         return $_POST;
121 }
122
123 // Counts entries in $_POST or returns false if not an array
124 function REQUEST_POST_COUNT () {
125         // By default this is not an array
126         $count = false;
127
128         // Get the array
129         $POST = REQUEST_POST_ARRAY();
130
131         // Is it an array?
132         if (is_array($POST)) {
133                 // Then count it
134                 $count = count($POST);
135         } // END - if
136
137         // Return value
138 }
139
140 // Checks wether a form was sent. If so, the $_POST['ok'] element must be set
141 function IS_FORM_SENT () {
142         // Simply wrap it!
143         return REQUEST_ISSET_POST('ok');
144 }
145
146 //
147 ?>