OSDN Git Service

* modified MEDIA::isValidCollection() to support read only folder
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / libs / vars4.0.6.php
index 624e028..c4ea1a0 100755 (executable)
@@ -1,18 +1,22 @@
 <?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)
+ */
 /**
-  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
-  * Copyright (C) 2002-2004 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)
-  *
-  * $Id: vars4.0.6.php,v 1.1.1.1 2005-02-28 07:14:53 kimitake Exp $
-  */
-  
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2007 The Nucleus Group
+ * @version $Id: vars4.0.6.php,v 1.11 2008-02-08 09:31:22 kimitake Exp $
+ * @version $NucleusJP: vars4.0.6.php,v 1.10.2.1 2007/09/05 07:46:30 kimitake Exp $
+ */
+
 /**
   * The purpose of the functions below is to avoid declaring HTTP_ vars to be global
   * everywhere, plus to offer support for php versions before 4.1.0, that do not
   */
 function getVar($name) {
        global $HTTP_GET_VARS;
+
+       if (!isset($HTTP_GET_VARS[$name])) {
+               return;
+       }
+
        return undoMagic($HTTP_GET_VARS[$name]);
 }
 
 function postVar($name) {
        global $HTTP_POST_VARS;
+
+       if (!isset($HTTP_POST_VARS[$name])) {
+               return;
+       }
+
        return undoMagic($HTTP_POST_VARS[$name]);
 }
 
-function cookieVar($name) {    
+function cookieVar($name) {
        global $HTTP_COOKIE_VARS;
+
+       if (!isset($HTTP_COOKIE_VARS[$name])) {
+               return;
+       }
+
        return undoMagic($HTTP_COOKIE_VARS[$name]);
 }
 
@@ -40,28 +59,56 @@ function requestVar($name) {
 
 function serverVar($name) {
        global $HTTP_SERVER_VARS;
+
+       if (!isset($HTTP_SERVER_VARS[$name])) {
+               return;
+       }
+
        return $HTTP_SERVER_VARS[$name];
 }
 
 // removes magic quotes if that option is enabled
 function undoMagic($data) {
-       return get_magic_quotes_gpc() ? stripslashes_array($data) : $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', $data) : stripslashes($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) {
        global $HTTP_POST_VARS;
-       return $HTTP_POST_VARS[$name];  
+
+       if (!isset($HTTP_POST_VARS[$name])) {
+               return;
+       }
+
+       return $HTTP_POST_VARS[$name];
 }
 
 // array from request. Be sure to call undoMagic on the strings inside
 function requestArray($name) {
        global $HTTP_POST_VARS;
-       return $HTTP_POST_VARS[$name];  
+
+       if (!isset($HTTP_POST_VARS[$name])) {
+               return;
+       }
+
+       return $HTTP_POST_VARS[$name];
 }
 
 
@@ -91,12 +138,17 @@ function passRequestVars() {
 
 function postFileInfo($name) {
        global $HTTP_POST_FILES;
+
+       if (!isset($HTTP_POST_FILES[$name])) {
+               return;
+       }
+
        return $HTTP_POST_FILES[$name];
 }
 
 function setOldAction($value) {
        global $HTTP_POST_VARS;
-       $HTTP_POST_VARS['oldaction'] = $value;  
+       $HTTP_POST_VARS['oldaction'] = $value;
 }
 
 ?>
\ No newline at end of file