4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5 * Copyright (C) 2002-2011 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-2011 The Nucleus Group
17 * @version $NucleusJP: vars4.1.0.php,v 1.10.2.2 2007/10/30 19:01:33 kmorimatsu Exp $
21 // Remove $_COOKIE keys in $_REQUEST
22 // This is for maintaining the compatibility with PHP 4.0.6
23 // and also for avoiding bugs of plugins due to cookie keys
24 if (isset($_REQUEST) and isset($_COOKIE)) {
25 foreach($_COOKIE as $key=>$value) {
26 if (isset($_REQUEST[$key])) unset($_REQUEST[$key]);
30 function getVar($name) {
31 if (!isset($_GET[$name])) {
35 return undoMagic($_GET[$name]);
38 function postVar($name) {
39 if (!isset($_POST[$name])) {
43 return undoMagic($_POST[$name]);
46 function cookieVar($name) {
47 if (!isset($_COOKIE[$name])) {
51 return undoMagic($_COOKIE[$name]);
54 function requestVar($name) {
55 if(array_key_exists($name,$_REQUEST))
56 return undoMagic($_REQUEST[$name]);
57 elseif( array_key_exists($name,$_GET))
58 return undoMagic($_GET[$name]);
59 elseif( array_key_exists($name,$_POST))
60 return undoMagic($_POST[$name]);
65 function serverVar($name) {
66 if (!isset($_SERVER[$name])) {
70 return $_SERVER[$name];
73 // removes magic quotes if that option is enabled
74 function undoMagic($data) {
75 if (!get_magic_quotes_gpc())
77 if (ini_get('magic_quotes_sybase') != 1)
78 return stripslashes_array($data);
80 return undoSybaseQuotes_array($data);
83 function stripslashes_array($data) {
84 return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
87 function undoSybaseQuotes_array($data) {
88 return is_array($data) ? array_map('undoSybaseQuotes_array', $data) : str_replace("''", "'", $data);
91 function undoSybaseQuotes($data) {
92 return str_replace("''", "'", $data);
95 // integer array from request
96 function requestIntArray($name) {
97 if (!isset($_REQUEST[$name])) {
101 return $_REQUEST[$name];
104 // array from request. Be sure to call undoMagic on the strings inside
105 function requestArray($name) {
106 if (!isset($_REQUEST[$name])) {
110 return $_REQUEST[$name];
113 // add all the variables from the request as hidden input field
114 // @see globalfunctions.php#passVar
115 function passRequestVars() {
116 foreach ($_REQUEST as $key => $value) {
117 if (($key == 'action') && ($value != requestVar('nextaction')))
120 // a nextaction of 'showlogin' makes no sense
121 if (($key == 'nextaction') && ($value == 'showlogin'))
124 if (($key != 'login') && ($key != 'password'))
125 passVar($key, $value);
129 function postFileInfo($name) {
130 if (!isset($_FILES[$name])) {
134 return $_FILES[$name];
137 function setOldAction($value) {
138 $_POST['oldaction'] = $value;