4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5 * Copyright (C) 2002-2007 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-2007 The Nucleus Group
16 * @version $Id: vars4.1.0.php,v 1.6 2007-03-22 09:23:58 kimitake Exp $
17 * @version $NucleusJP: vars4.1.0.php,v 1.10 2007/02/04 06:28:46 kimitake Exp $
20 function getVar($name) {
21 if (!isset($_GET[$name])) {
25 return undoMagic($_GET[$name]);
28 function postVar($name) {
29 if (!isset($_POST[$name])) {
33 return undoMagic($_POST[$name]);
36 function cookieVar($name) {
37 if (!isset($_COOKIE[$name])) {
41 return undoMagic($_COOKIE[$name]);
44 function requestVar($name) {
45 if(array_key_exists($name,$_REQUEST))
46 return undoMagic($_REQUEST[$name]);
47 elseif( array_key_exists($name,$_GET))
48 return undoMagic($_GET[$name]);
49 elseif( array_key_exists($name,$_POST))
50 return undoMagic($_POST[$name]);
55 function serverVar($name) {
56 if (!isset($_SERVER[$name])) {
60 return $_SERVER[$name];
63 // removes magic quotes if that option is enabled
64 function undoMagic($data) {
65 if (!get_magic_quotes_gpc())
67 if (ini_get('magic_quotes_sybase') != 1)
68 return stripslashes_array($data);
70 return undoSybaseQuotes_array($data);
73 function stripslashes_array($data) {
74 return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
77 function undoSybaseQuotes_array($data) {
78 return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data);
81 function undoSybaseQuotes($data) {
82 return str_replace("''", "'", $data);
85 // integer array from request
86 function requestIntArray($name) {
87 if (!isset($_REQUEST[$name])) {
91 return $_REQUEST[$name];
94 // array from request. Be sure to call undoMagic on the strings inside
95 function requestArray($name) {
96 if (!isset($_REQUEST[$name])) {
100 return $_REQUEST[$name];
103 // add all the variables from the request as hidden input field
104 // @see globalfunctions.php#passVar
105 function passRequestVars() {
106 foreach ($_REQUEST as $key => $value) {
107 if (($key == 'action') && ($value != requestVar('nextaction')))
110 // a nextaction of 'showlogin' makes no sense
111 if (($key == 'nextaction') && ($value == 'showlogin'))
114 if (($key != 'login') && ($key != 'password'))
115 passVar($key, $value);
119 function postFileInfo($name) {
120 if (!isset($_FILES[$name])) {
124 return $_FILES[$name];
127 function setOldAction($value) {
128 $_POST['oldaction'] = $value;