4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5 * Copyright (C) 2002-2009 The Nucleus Group
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * (see nucleus/documentation/index.html#license for more info)
14 * @license http://nucleuscms.org/license.txt GNU General Public License
15 * @copyright Copyright (C) 2002-2009 The Nucleus Group
16 * @version $Id: vars4.1.0.php 1544 2011-06-25 22:32:50Z kaigreve $
20 * Return the value of $_GET for the variable $name
22 * If the variable is set the function returns the value,
23 * if it is not set it returns null (which is equal to false).
25 * @param unknown_type $name
27 function getVar($name) {
28 if (!isset($_GET[$name])) {
32 return undoMagic($_GET[$name]);
36 * Return the value of $_POST for the variable $name
38 * If the variable is set the function returns the value,
39 * if it is not set it returns null (which is equal to false).
41 * @param unknown_type $name
43 function postVar($name) {
44 if (!isset($_POST[$name])) {
48 return undoMagic($_POST[$name]);
52 * Return the value of $_COOKIE for the variable $name
54 * If the variable is set the function returns the value,
55 * if it is not set it returns null (which is equal to false).
57 * @param unknown_type $name
59 function cookieVar($name) {
60 if (!isset($_COOKIE[$name])) {
64 return undoMagic($_COOKIE[$name]);
68 * Return the request var for the variable $name
70 * If the variable is set the function returns the value,
71 * if it is not set it returns null (which is equal to false).
72 * Trys to resolve also $_GET and $_POST
74 * @param unknown_type $name
76 function requestVar($name) {
77 if(array_key_exists($name,$_REQUEST))
78 return undoMagic($_REQUEST[$name]);
79 elseif( array_key_exists($name,$_GET))
80 return undoMagic($_GET[$name]);
81 elseif( array_key_exists($name,$_POST))
82 return undoMagic($_POST[$name]);
88 * Return the value of $_SERVER for the variable $name
90 * If the variable is set the function returns the value,
91 * if it is not set it returns null (which is equal to false)
93 * @param unknown_type $name
95 function serverVar($name) {
96 if (!isset($_SERVER[$name])) {
100 return $_SERVER[$name];
104 * Removes magic quotes if that option is enabled
108 function undoMagic($data) {
109 if (!get_magic_quotes_gpc())
111 if (ini_get('magic_quotes_sybase') != 1)
112 return stripslashes_array($data);
114 return undoSybaseQuotes_array($data);
118 * Strip slashes from a variable or an array
122 function stripslashes_array($data) {
123 return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
127 * Undo Sybase Quotes from an array
131 function undoSybaseQuotes_array($data) {
132 return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data);
136 * Undo Sybase Quotes from a variable
140 function undoSybaseQuotes($data) {
141 return str_replace("''", "'", $data);
145 * Integer array from request
147 * @param unknown_type $name
149 function requestIntArray($name) {
150 if (!isset($_REQUEST[$name])) {
154 return $_REQUEST[$name];
158 * Array from request. Be sure to call undoMagic on the strings inside.
162 function requestArray($name) {
163 if (!isset($_REQUEST[$name])) {
167 return $_REQUEST[$name];
171 * add all the variables from the request as hidden input field
172 * @see globalfunctions.php#passVar
175 function passRequestVars() {
176 foreach ($_REQUEST as $key => $value) {
177 if (($key == 'action') && ($value != requestVar('nextaction')))
180 // a nextaction of 'showlogin' makes no sense
181 if (($key == 'nextaction') && ($value == 'showlogin'))
184 if (($key != 'login') && ($key != 'password'))
185 passVar($key, $value);
190 * Return the value of $_FILES for the variable $name
192 * If the variable is set the function returns the value,
193 * if it is not set it returns null (which is equal to false)
197 function postFileInfo($name) {
198 if (!isset($_FILES[$name])) {
202 return $_FILES[$name];
206 * Sets the $_POST variable oldaction to the given value
210 function setOldAction($value) {
211 $_POST['oldaction'] = $value;