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