OSDN Git Service

sync with UTF-8
[nucleus-jp/nucleus-jp-ancient.git] / euc / nucleus / libs / vars4.1.0.php
1 <?php
2
3 /*
4  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5  * Copyright (C) 2002-2007 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-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 $
18  */
19
20 function getVar($name) {
21         if (!isset($_GET[$name])) {
22                 return;
23         }
24
25         return undoMagic($_GET[$name]);
26 }
27
28 function postVar($name) {
29         if (!isset($_POST[$name])) {
30                 return;
31         }
32
33         return undoMagic($_POST[$name]);
34 }
35
36 function cookieVar($name) {
37         if (!isset($_COOKIE[$name])) {
38                 return;
39         }
40
41         return undoMagic($_COOKIE[$name]);
42 }
43
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]);
51         else
52                 return;
53 }
54
55 function serverVar($name) {
56         if (!isset($_SERVER[$name])) {
57                 return false;
58         }
59
60         return $_SERVER[$name];
61 }
62
63 // removes magic quotes if that option is enabled
64 function undoMagic($data) {
65         if (!get_magic_quotes_gpc())
66                 return $data;
67         if (ini_get('magic_quotes_sybase') != 1)
68                 return stripslashes_array($data);
69         else
70                 return undoSybaseQuotes_array($data);
71 }
72
73 function stripslashes_array($data) {
74         return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
75 }
76
77 function undoSybaseQuotes_array($data) {
78         return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data);
79 }
80
81 function undoSybaseQuotes($data) {
82         return str_replace("''", "'", $data);
83 }
84
85 // integer array from request
86 function requestIntArray($name) {
87         if (!isset($_REQUEST[$name])) {
88                 return;
89         }
90
91         return $_REQUEST[$name];
92 }
93
94 // array from request. Be sure to call undoMagic on the strings inside
95 function requestArray($name) {
96         if (!isset($_REQUEST[$name])) {
97                 return;
98         }
99
100         return $_REQUEST[$name];
101 }
102
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')))
108                         $key = 'nextaction';
109
110                 // a nextaction of 'showlogin' makes no sense
111                 if (($key == 'nextaction') && ($value == 'showlogin'))
112                         continue;
113
114                 if (($key != 'login') && ($key != 'password'))
115                         passVar($key, $value);
116         }
117 }
118
119 function postFileInfo($name) {
120         if (!isset($_FILES[$name])) {
121                 return;
122         }
123
124         return $_FILES[$name];
125 }
126
127 function setOldAction($value) {
128         $_POST['oldaction'] = $value;
129 }
130
131
132 ?>