OSDN Git Service

merge from utf-8
[nucleus-jp/nucleus-jp-ancient.git] / euc / nucleus / libs / vars4.1.0.php
index f6893fa..22b2934 100755 (executable)
-<?php\r
-\r
-/**\r
-  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) \r
-  * Copyright (C) 2002-2005 The Nucleus Group\r
-  *\r
-  * This program is free software; you can redistribute it and/or\r
-  * modify it under the terms of the GNU General Public License\r
-  * as published by the Free Software Foundation; either version 2\r
-  * of the License, or (at your option) any later version.\r
-  * (see nucleus/documentation/index.html#license for more info)\r
-  *\r
-  * $Id: vars4.1.0.php,v 1.4 2005-03-16 08:10:35 kimitake Exp $\r
-  * $NucleusJP: vars4.1.0.php,v 1.5 2005/03/12 06:19:05 kimitake Exp $\r
-  */\r
-  \r
-function getVar($name) {\r
-       return undoMagic($_GET[$name]);\r
-}\r
-\r
-function postVar($name) {\r
-       return undoMagic($_POST[$name]);\r
-}\r
-\r
-function cookieVar($name) {    \r
-       return undoMagic($_COOKIE[$name]);\r
-}\r
-\r
-function requestVar($name) {\r
-       if(array_key_exists($name,$_REQUEST))\r
-               return undoMagic($_REQUEST[$name]);\r
-       elseif( array_key_exists($name,$_GET))   \r
-               return undoMagic($_GET[$name]);\r
-       elseif( array_key_exists($name,$_POST))   \r
-               return undoMagic($_POST[$name]);\r
-       else\r
-               return;\r
-}\r
-\r
-function serverVar($name) {\r
-       return $_SERVER[$name];\r
-}\r
-\r
-// removes magic quotes if that option is enabled\r
-function undoMagic($data) {\r
-       return get_magic_quotes_gpc() ? stripslashes_array($data) : $data;\r
-}\r
-\r
-function stripslashes_array($data) {\r
-       return is_array($data) ? array_map('stripslashes', $data) : stripslashes($data);\r
-}\r
-\r
-// integer array from request\r
-function requestIntArray($name) {\r
-       return $_REQUEST[$name];        \r
-}\r
-\r
-// array from request. Be sure to call undoMagic on the strings inside\r
-function requestArray($name) {\r
-       return $_REQUEST[$name];        \r
-}\r
-\r
-// add all the variables from the request as hidden input field\r
-// @see globalfunctions.php#passVar\r
-function passRequestVars() {\r
-       foreach ($_REQUEST as $key => $value) {\r
-               if (($key == 'action') && ($value != requestVar('nextaction')))\r
-                       $key = 'nextaction';\r
-                       \r
-               // a nextaction of 'showlogin' makes no sense\r
-               if (($key == 'nextaction') && ($value == 'showlogin'))\r
-                       continue;\r
-                       \r
-               if (($key != 'login') && ($key != 'password'))\r
-                       passVar($key, $value);\r
-       }\r
-}\r
-\r
-function postFileInfo($name) {\r
-       return $_FILES[$name];\r
-}\r
-\r
-function setOldAction($value) {\r
-       $_POST['oldaction'] = $value;   \r
-}\r
-\r
-?>\r
+<?php
+
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2007 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2007 The Nucleus Group
+ * @version $Id: vars4.1.0.php,v 1.6.2.1 2008-01-29 07:05:06 kimitake Exp $
+ * @version $NucleusJP: vars4.1.0.php,v 1.10.2.2 2007/10/30 19:01:33 kmorimatsu Exp $
+ */
+
+
+// Remove $_COOKIE keys in $_REQUEST
+// This is for maintaining the compatibility with PHP 4.0.6
+// and also for avoiding bugs of plugins due to cookie keys
+if (isset($_REQUEST) and isset($_COOKIE)) {
+       foreach($_COOKIE as $key=>$value) {
+               if (isset($_REQUEST[$key])) unset($_REQUEST[$key]);
+       }
+}
+
+function getVar($name) {
+       if (!isset($_GET[$name])) {
+               return;
+       }
+
+       return undoMagic($_GET[$name]);
+}
+
+function postVar($name) {
+       if (!isset($_POST[$name])) {
+               return;
+       }
+
+       return undoMagic($_POST[$name]);
+}
+
+function cookieVar($name) {
+       if (!isset($_COOKIE[$name])) {
+               return;
+       }
+
+       return undoMagic($_COOKIE[$name]);
+}
+
+function requestVar($name) {
+       if(array_key_exists($name,$_REQUEST))
+               return undoMagic($_REQUEST[$name]);
+       elseif( array_key_exists($name,$_GET))
+               return undoMagic($_GET[$name]);
+       elseif( array_key_exists($name,$_POST))
+               return undoMagic($_POST[$name]);
+       else
+               return;
+}
+
+function serverVar($name) {
+       if (!isset($_SERVER[$name])) {
+               return false;
+       }
+
+       return $_SERVER[$name];
+}
+
+// removes magic quotes if that option is enabled
+function undoMagic($data) {
+       if (!get_magic_quotes_gpc())
+               return $data;
+       if (ini_get('magic_quotes_sybase') != 1)
+               return stripslashes_array($data);
+       else
+               return undoSybaseQuotes_array($data);
+}
+
+function stripslashes_array($data) {
+       return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
+}
+
+function undoSybaseQuotes_array($data) {
+       return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data);
+}
+
+function undoSybaseQuotes($data) {
+       return str_replace("''", "'", $data);
+}
+
+// integer array from request
+function requestIntArray($name) {
+       if (!isset($_REQUEST[$name])) {
+               return;
+       }
+
+       return $_REQUEST[$name];
+}
+
+// array from request. Be sure to call undoMagic on the strings inside
+function requestArray($name) {
+       if (!isset($_REQUEST[$name])) {
+               return;
+       }
+
+       return $_REQUEST[$name];
+}
+
+// add all the variables from the request as hidden input field
+// @see globalfunctions.php#passVar
+function passRequestVars() {
+       foreach ($_REQUEST as $key => $value) {
+               if (($key == 'action') && ($value != requestVar('nextaction')))
+                       $key = 'nextaction';
+
+               // a nextaction of 'showlogin' makes no sense
+               if (($key == 'nextaction') && ($value == 'showlogin'))
+                       continue;
+
+               if (($key != 'login') && ($key != 'password'))
+                       passVar($key, $value);
+       }
+}
+
+function postFileInfo($name) {
+       if (!isset($_FILES[$name])) {
+               return;
+       }
+
+       return $_FILES[$name];
+}
+
+function setOldAction($value) {
+       $_POST['oldaction'] = $value;
+}
+
+
+?>
\ No newline at end of file