4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5 * Copyright (C) 2002-2012 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 // Remove $_COOKIE keys in $_REQUEST
15 // This is for maintaining the compatibility with PHP 4.0.6
16 // and also for avoiding bugs of plugins due to cookie keys
17 if (isset($_REQUEST) and isset($_COOKIE)) {
18 foreach($_COOKIE as $key=>$value) {
19 if (isset($_REQUEST[$key])) unset($_REQUEST[$key]);
23 function getVar($name) {
24 if (!isset($_GET[$name])) {
28 return undoMagic($_GET[$name]);
31 function postVar($name) {
32 if (!isset($_POST[$name])) {
36 return undoMagic($_POST[$name]);
39 function cookieVar($name) {
40 if (!isset($_COOKIE[$name])) {
44 return undoMagic($_COOKIE[$name]);
47 function requestVar($name) {
48 if(array_key_exists($name,$_REQUEST))
49 return undoMagic($_REQUEST[$name]);
50 elseif( array_key_exists($name,$_GET))
51 return undoMagic($_GET[$name]);
52 elseif( array_key_exists($name,$_POST))
53 return undoMagic($_POST[$name]);
58 function serverVar($name) {
59 if (!isset($_SERVER[$name])) {
63 return $_SERVER[$name];
66 // removes magic quotes if that option is enabled
67 function undoMagic($data) {
68 if (!get_magic_quotes_gpc())
70 if (ini_get('magic_quotes_sybase') != 1)
71 return stripslashes_array($data);
73 return undoSybaseQuotes_array($data);
76 function stripslashes_array($data) {
77 return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
80 function undoSybaseQuotes_array($data) {
81 return is_array($data) ? array_map('undoSybaseQuotes_array', $data) : str_replace("''", "'", $data);
84 function undoSybaseQuotes($data) {
85 return str_replace("''", "'", $data);
88 // integer array from request
89 function requestIntArray($name) {
90 if (!isset($_REQUEST[$name])) {
94 return $_REQUEST[$name];
97 // array from request. Be sure to call undoMagic on the strings inside
98 function requestArray($name) {
99 if (!isset($_REQUEST[$name])) {
103 return $_REQUEST[$name];
106 // add all the variables from the request as hidden input field
107 // @see globalfunctions.php#passVar
108 function passRequestVars() {
109 foreach ($_REQUEST as $key => $value) {
110 if (($key == 'action') && ($value != requestVar('nextaction')))
113 // a nextaction of 'showlogin' makes no sense
114 if (($key == 'nextaction') && ($value == 'showlogin'))
117 if (($key != 'login') && ($key != 'password'))
118 passVar($key, $value);
122 function postFileInfo($name) {
123 if (!isset($_FILES[$name])) {
127 return $_FILES[$name];
130 function setOldAction($value) {
131 $_POST['oldaction'] = $value;