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.4 2005-03-08 06:48:31 kimitake Exp $
\r
18 * The purpose of the functions below is to avoid declaring HTTP_ vars to be global
\r
19 * everywhere, plus to offer support for php versions before 4.1.0, that do not
\r
20 * have the _GET etc vars
\r
22 function getVar($name) {
\r
23 global $HTTP_GET_VARS;
\r
24 return undoMagic($HTTP_GET_VARS[$name]);
\r
27 function postVar($name) {
\r
28 global $HTTP_POST_VARS;
\r
29 return undoMagic($HTTP_POST_VARS[$name]);
\r
32 function cookieVar($name) {
\r
33 global $HTTP_COOKIE_VARS;
\r
34 return undoMagic($HTTP_COOKIE_VARS[$name]);
\r
37 // request: either POST or GET
\r
38 function requestVar($name) {
\r
39 return (postVar($name)) ? postVar($name) : getVar($name);
\r
42 function serverVar($name) {
\r
43 global $HTTP_SERVER_VARS;
\r
44 return $HTTP_SERVER_VARS[$name];
\r
47 // removes magic quotes if that option is enabled
\r
48 function undoMagic($data) {
\r
49 return get_magic_quotes_gpc() ? stripslashes_array($data) : $data;
\r
52 function stripslashes_array($data) {
\r
53 return is_array($data) ? array_map('stripslashes', $data) : stripslashes($data);
\r
56 // integer array from request
\r
57 function requestIntArray($name) {
\r
58 global $HTTP_POST_VARS;
\r
59 return $HTTP_POST_VARS[$name];
\r
62 // array from request. Be sure to call undoMagic on the strings inside
\r
63 function requestArray($name) {
\r
64 global $HTTP_POST_VARS;
\r
65 return $HTTP_POST_VARS[$name];
\r
69 // add all the variables from the request as hidden input field
\r
70 // @see globalfunctions.php#passVar
\r
71 function passRequestVars() {
\r
72 global $HTTP_POST_VARS, $HTTP_GET_VARS;
\r
73 foreach ($HTTP_POST_VARS as $key => $value) {
\r
74 if (($key == 'action') && ($value != requestVar('nextaction')))
\r
75 $key = 'nextaction';
\r
76 // a nextaction of 'showlogin' makes no sense
\r
77 if (($key == 'nextaction') && ($value == 'showlogin'))
\r
79 if (($key != 'login') && ($key != 'password'))
\r
80 passVar($key, $value);
\r
82 foreach ($HTTP_GET_VARS as $key => $value) {
\r
83 if (($key == 'action') && ($value != requestVar('nextaction')))
\r
84 $key = 'nextaction';
\r
85 // a nextaction of 'showlogin' makes no sense
\r
86 if (($key == 'nextaction') && ($value == 'showlogin'))
\r
88 if (($key != 'login') && ($key != 'password'))
\r
89 passVar($key, $value);
\r
93 function postFileInfo($name) {
\r
94 global $HTTP_POST_FILES;
\r
95 return $HTTP_POST_FILES[$name];
\r
98 function setOldAction($value) {
\r
99 global $HTTP_POST_VARS;
\r
100 $HTTP_POST_VARS['oldaction'] = $value;
\r