OSDN Git Service

a5f9fe91bcba1602f2695917355c670772db1cc2
[nucleus-jp/nucleus-jp-ancient.git] / euc / nucleus / libs / vars4.0.6.php
1 <?php\r
2 \r
3 /**\r
4   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) \r
5   * Copyright (C) 2002-2004 The Nucleus Group\r
6   *\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
12   *\r
13   * $Id: vars4.0.6.php,v 1.2 2005-03-08 09:32:13 kimitake Exp $\r
14   */\r
15   \r
16 /**\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
20   */\r
21 function getVar($name) {\r
22         global $HTTP_GET_VARS;\r
23         return undoMagic($HTTP_GET_VARS[$name]);\r
24 }\r
25 \r
26 function postVar($name) {\r
27         global $HTTP_POST_VARS;\r
28         return undoMagic($HTTP_POST_VARS[$name]);\r
29 }\r
30 \r
31 function cookieVar($name) {     \r
32         global $HTTP_COOKIE_VARS;\r
33         return undoMagic($HTTP_COOKIE_VARS[$name]);\r
34 }\r
35 \r
36 // request: either POST or GET\r
37 function requestVar($name) {\r
38         return (postVar($name)) ? postVar($name) : getVar($name);\r
39 }\r
40 \r
41 function serverVar($name) {\r
42         global $HTTP_SERVER_VARS;\r
43         return $HTTP_SERVER_VARS[$name];\r
44 }\r
45 \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
49 }\r
50 \r
51 function stripslashes_array($data) {\r
52         return is_array($data) ? array_map('stripslashes', $data) : stripslashes($data);\r
53 }\r
54 \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
59 }\r
60 \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
65 }\r
66 \r
67 \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
77                         continue;\r
78                 if (($key != 'login') && ($key != 'password'))\r
79                         passVar($key, $value);\r
80         }\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
86                         continue;\r
87                 if (($key != 'login') && ($key != 'password'))\r
88                         passVar($key, $value);\r
89         }\r
90 }\r
91 \r
92 function postFileInfo($name) {\r
93         global $HTTP_POST_FILES;\r
94         return $HTTP_POST_FILES[$name];\r
95 }\r
96 \r
97 function setOldAction($value) {\r
98         global $HTTP_POST_VARS;\r
99         $HTTP_POST_VARS['oldaction'] = $value;  \r
100 }\r
101 \r
102 ?>