4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
5 * Copyright (C) 2002-2004 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
13 * $Id: vars4.0.6.php,v 1.2 2005-03-08 09:32:13 kimitake Exp $
\r
17 * The purpose of the functions below is to avoid declaring HTTP_ vars to be global
\r
18 * everywhere, plus to offer support for php versions before 4.1.0, that do not
\r
19 * have the _GET etc vars
\r
21 function getVar($name) {
\r
22 global $HTTP_GET_VARS;
\r
23 return undoMagic($HTTP_GET_VARS[$name]);
\r
26 function postVar($name) {
\r
27 global $HTTP_POST_VARS;
\r
28 return undoMagic($HTTP_POST_VARS[$name]);
\r
31 function cookieVar($name) {
\r
32 global $HTTP_COOKIE_VARS;
\r
33 return undoMagic($HTTP_COOKIE_VARS[$name]);
\r
36 // request: either POST or GET
\r
37 function requestVar($name) {
\r
38 return (postVar($name)) ? postVar($name) : getVar($name);
\r
41 function serverVar($name) {
\r
42 global $HTTP_SERVER_VARS;
\r
43 return $HTTP_SERVER_VARS[$name];
\r
46 // removes magic quotes if that option is enabled
\r
47 function undoMagic($data) {
\r
48 return get_magic_quotes_gpc() ? stripslashes_array($data) : $data;
\r
51 function stripslashes_array($data) {
\r
52 return is_array($data) ? array_map('stripslashes', $data) : stripslashes($data);
\r
55 // integer array from request
\r
56 function requestIntArray($name) {
\r
57 global $HTTP_POST_VARS;
\r
58 return $HTTP_POST_VARS[$name];
\r
61 // array from request. Be sure to call undoMagic on the strings inside
\r
62 function requestArray($name) {
\r
63 global $HTTP_POST_VARS;
\r
64 return $HTTP_POST_VARS[$name];
\r
68 // add all the variables from the request as hidden input field
\r
69 // @see globalfunctions.php#passVar
\r
70 function passRequestVars() {
\r
71 global $HTTP_POST_VARS, $HTTP_GET_VARS;
\r
72 foreach ($HTTP_POST_VARS as $key => $value) {
\r
73 if (($key == 'action') && ($value != requestVar('nextaction')))
\r
74 $key = 'nextaction';
\r
75 // a nextaction of 'showlogin' makes no sense
\r
76 if (($key == 'nextaction') && ($value == 'showlogin'))
\r
78 if (($key != 'login') && ($key != 'password'))
\r
79 passVar($key, $value);
\r
81 foreach ($HTTP_GET_VARS as $key => $value) {
\r
82 if (($key == 'action') && ($value != requestVar('nextaction')))
\r
83 $key = 'nextaction';
\r
84 // a nextaction of 'showlogin' makes no sense
\r
85 if (($key == 'nextaction') && ($value == 'showlogin'))
\r
87 if (($key != 'login') && ($key != 'password'))
\r
88 passVar($key, $value);
\r
92 function postFileInfo($name) {
\r
93 global $HTTP_POST_FILES;
\r
94 return $HTTP_POST_FILES[$name];
\r
97 function setOldAction($value) {
\r
98 global $HTTP_POST_VARS;
\r
99 $HTTP_POST_VARS['oldaction'] = $value;
\r