OSDN Git Service

This commit was generated by cvs2svn to compensate for changes in r4,
[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-2004 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   * $Id: vars4.1.0.php,v 1.1.1.1 2005-02-28 07:14:14 kimitake Exp $
14   */
15   
16 function getVar($name) {
17         return undoMagic($_GET[$name]);
18 }
19
20 function postVar($name) {
21         return undoMagic($_POST[$name]);
22 }
23
24 function cookieVar($name) {     
25         return undoMagic($_COOKIE[$name]);
26 }
27
28 function requestVar($name) {
29         if(array_key_exists($name,$_REQUEST))
30                 return undoMagic($_REQUEST[$name]);
31         elseif( array_key_exists($name,$_GET))   
32                 return undoMagic($_GET[$name]);
33         elseif( array_key_exists($name,$_POST))   
34                 return undoMagic($_POST[$name]);
35         else
36                 return;
37 }
38
39 function serverVar($name) {
40         return $_SERVER[$name];
41 }
42
43 // removes magic quotes if that option is enabled
44 function undoMagic($data) {
45         return get_magic_quotes_gpc() ? stripslashes_array($data) : $data;
46 }
47
48 function stripslashes_array($data) {
49         return is_array($data) ? array_map('stripslashes', $data) : stripslashes($data);
50 }
51
52 // integer array from request
53 function requestIntArray($name) {
54         return $_REQUEST[$name];        
55 }
56
57 // array from request. Be sure to call undoMagic on the strings inside
58 function requestArray($name) {
59         return $_REQUEST[$name];        
60 }
61
62 // add all the variables from the request as hidden input field
63 // @see globalfunctions.php#passVar
64 function passRequestVars() {
65         foreach ($_REQUEST as $key => $value) {
66                 if (($key == 'action') && ($value != requestVar('nextaction')))
67                         $key = 'nextaction';
68                         
69                 // a nextaction of 'showlogin' makes no sense
70                 if (($key == 'nextaction') && ($value == 'showlogin'))
71                         continue;
72                         
73                 if (($key != 'login') && ($key != 'password'))
74                         passVar($key, $value);
75         }
76 }
77
78 function postFileInfo($name) {
79         return $_FILES[$name];
80 }
81
82 function setOldAction($value) {
83         $_POST['oldaction'] = $value;   
84 }
85
86 ?>