vars4.1.0.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
00005  * Copyright (C) 2002-2007 The Nucleus Group
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * (see nucleus/documentation/index.html#license for more info)
00012  */
00021 // Remove $_COOKIE keys in $_REQUEST
00022 // This is for maintaining the compatibility with PHP 4.0.6
00023 // and also for avoiding bugs of plugins due to cookie keys
00024 if (isset($_REQUEST) and isset($_COOKIE)) {
00025         foreach($_COOKIE as $key=>$value) {
00026                 if (isset($_REQUEST[$key])) unset($_REQUEST[$key]);
00027         }
00028 }
00029 
00030 function getVar($name) {
00031         if (!isset($_GET[$name])) {
00032                 return;
00033         }
00034 
00035         return undoMagic($_GET[$name]);
00036 }
00037 
00038 function postVar($name) {
00039         if (!isset($_POST[$name])) {
00040                 return;
00041         }
00042 
00043         return undoMagic($_POST[$name]);
00044 }
00045 
00046 function cookieVar($name) {
00047         if (!isset($_COOKIE[$name])) {
00048                 return;
00049         }
00050 
00051         return undoMagic($_COOKIE[$name]);
00052 }
00053 
00054 function requestVar($name) {
00055         if(array_key_exists($name,$_REQUEST))
00056                 return undoMagic($_REQUEST[$name]);
00057         elseif( array_key_exists($name,$_GET))
00058                 return undoMagic($_GET[$name]);
00059         elseif( array_key_exists($name,$_POST))
00060                 return undoMagic($_POST[$name]);
00061         else
00062                 return;
00063 }
00064 
00065 function serverVar($name) {
00066         if (!isset($_SERVER[$name])) {
00067                 return false;
00068         }
00069 
00070         return $_SERVER[$name];
00071 }
00072 
00073 // removes magic quotes if that option is enabled
00074 function undoMagic($data) {
00075         if (!get_magic_quotes_gpc())
00076                 return $data;
00077         if (ini_get('magic_quotes_sybase') != 1)
00078                 return stripslashes_array($data);
00079         else
00080                 return undoSybaseQuotes_array($data);
00081 }
00082 
00083 function stripslashes_array($data) {
00084         return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
00085 }
00086 
00087 function undoSybaseQuotes_array($data) {
00088         return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data);
00089 }
00090 
00091 function undoSybaseQuotes($data) {
00092         return str_replace("''", "'", $data);
00093 }
00094 
00095 // integer array from request
00096 function requestIntArray($name) {
00097         if (!isset($_REQUEST[$name])) {
00098                 return;
00099         }
00100 
00101         return $_REQUEST[$name];
00102 }
00103 
00104 // array from request. Be sure to call undoMagic on the strings inside
00105 function requestArray($name) {
00106         if (!isset($_REQUEST[$name])) {
00107                 return;
00108         }
00109 
00110         return $_REQUEST[$name];
00111 }
00112 
00113 // add all the variables from the request as hidden input field
00114 // @see globalfunctions.php#passVar
00115 function passRequestVars() {
00116         foreach ($_REQUEST as $key => $value) {
00117                 if (($key == 'action') && ($value != requestVar('nextaction')))
00118                         $key = 'nextaction';
00119 
00120                 // a nextaction of 'showlogin' makes no sense
00121                 if (($key == 'nextaction') && ($value == 'showlogin'))
00122                         continue;
00123 
00124                 if (($key != 'login') && ($key != 'password'))
00125                         passVar($key, $value);
00126         }
00127 }
00128 
00129 function postFileInfo($name) {
00130         if (!isset($_FILES[$name])) {
00131                 return;
00132         }
00133 
00134         return $_FILES[$name];
00135 }
00136 
00137 function setOldAction($value) {
00138         $_POST['oldaction'] = $value;
00139 }
00140 
00141 
00142 ?>



Generated on Wed Jun 25 17:25:59 2008 by  doxygen 1.5.5