OSDN Git Service

FIX: デバッグ動作時に発生する警告に対処
[nucleus-jp/nucleus-jp-ancient.git] / nucleus / libs / vars4.1.0.php
1 <?php
2
3 /*
4  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5  * Copyright (C) 2002-2011 The Nucleus Group
6  *
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)
12  */
13 /**
14  * @license http://nucleuscms.org/license.txt GNU General Public License
15  * @copyright Copyright (C) 2002-2011 The Nucleus Group
16  * @version $Id$
17  * @version $NucleusJP: vars4.1.0.php,v 1.10.2.2 2007/10/30 19:01:33 kmorimatsu Exp $
18  */
19
20
21 // Remove $_COOKIE keys in $_REQUEST
22 // This is for maintaining the compatibility with PHP 4.0.6
23 // and also for avoiding bugs of plugins due to cookie keys
24 if (isset($_REQUEST) and isset($_COOKIE)) {
25         foreach($_COOKIE as $key=>$value) {
26                 if (isset($_REQUEST[$key])) unset($_REQUEST[$key]);
27         }
28 }
29
30 function getVar($name) {
31         if (!isset($_GET[$name])) {
32                 return;
33         }
34
35         return undoMagic($_GET[$name]);
36 }
37
38 function postVar($name) {
39         if (!isset($_POST[$name])) {
40                 return;
41         }
42
43         return undoMagic($_POST[$name]);
44 }
45
46 function cookieVar($name) {
47         if (!isset($_COOKIE[$name])) {
48                 return;
49         }
50
51         return undoMagic($_COOKIE[$name]);
52 }
53
54 function requestVar($name) {
55         if(array_key_exists($name,$_REQUEST))
56                 return undoMagic($_REQUEST[$name]);
57         elseif( array_key_exists($name,$_GET))
58                 return undoMagic($_GET[$name]);
59         elseif( array_key_exists($name,$_POST))
60                 return undoMagic($_POST[$name]);
61         else
62                 return;
63 }
64
65 function serverVar($name) {
66         if (!isset($_SERVER[$name])) {
67                 return false;
68         }
69
70         return $_SERVER[$name];
71 }
72
73 // removes magic quotes if that option is enabled
74 function undoMagic($data) {
75         if (!get_magic_quotes_gpc())
76                 return $data;
77         if (ini_get('magic_quotes_sybase') != 1)
78                 return stripslashes_array($data);
79         else
80                 return undoSybaseQuotes_array($data);
81 }
82
83 function stripslashes_array($data) {
84         return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
85 }
86
87 function undoSybaseQuotes_array($data) {
88         return is_array($data) ? array_map('undoSybaseQuotes_array', $data) : str_replace("''", "'", $data);
89 }
90
91 function undoSybaseQuotes($data) {
92         return str_replace("''", "'", $data);
93 }
94
95 // integer array from request
96 function requestIntArray($name) {
97         if (!isset($_REQUEST[$name])) {
98                 return;
99         }
100
101         return $_REQUEST[$name];
102 }
103
104 // array from request. Be sure to call undoMagic on the strings inside
105 function requestArray($name) {
106         if (!isset($_REQUEST[$name])) {
107                 return;
108         }
109
110         return $_REQUEST[$name];
111 }
112
113 // add all the variables from the request as hidden input field
114 // @see globalfunctions.php#passVar
115 function passRequestVars() {
116         foreach ($_REQUEST as $key => $value) {
117                 if (($key == 'action') && ($value != requestVar('nextaction')))
118                         $key = 'nextaction';
119
120                 // a nextaction of 'showlogin' makes no sense
121                 if (($key == 'nextaction') && ($value == 'showlogin'))
122                         continue;
123
124                 if (($key != 'login') && ($key != 'password'))
125                         passVar($key, $value);
126         }
127 }
128
129 function postFileInfo($name) {
130         if (!isset($_FILES[$name])) {
131                 return;
132         }
133
134         return $_FILES[$name];
135 }
136
137 function setOldAction($value) {
138         $_POST['oldaction'] = $value;
139 }
140
141
142 ?>