vars4.0.6.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  */
00025 function getVar($name) {
00026         global $HTTP_GET_VARS;
00027 
00028         if (!isset($HTTP_GET_VARS[$name])) {
00029                 return;
00030         }
00031 
00032         return undoMagic($HTTP_GET_VARS[$name]);
00033 }
00034 
00035 function postVar($name) {
00036         global $HTTP_POST_VARS;
00037 
00038         if (!isset($HTTP_POST_VARS[$name])) {
00039                 return;
00040         }
00041 
00042         return undoMagic($HTTP_POST_VARS[$name]);
00043 }
00044 
00045 function cookieVar($name) {
00046         global $HTTP_COOKIE_VARS;
00047 
00048         if (!isset($HTTP_COOKIE_VARS[$name])) {
00049                 return;
00050         }
00051 
00052         return undoMagic($HTTP_COOKIE_VARS[$name]);
00053 }
00054 
00055 // request: either POST or GET
00056 function requestVar($name) {
00057         return (postVar($name)) ? postVar($name) : getVar($name);
00058 }
00059 
00060 function serverVar($name) {
00061         global $HTTP_SERVER_VARS;
00062 
00063         if (!isset($HTTP_SERVER_VARS[$name])) {
00064                 return;
00065         }
00066 
00067         return $HTTP_SERVER_VARS[$name];
00068 }
00069 
00070 // removes magic quotes if that option is enabled
00071 function undoMagic($data) {
00072         if (!get_magic_quotes_gpc())
00073                 return $data;
00074         if (ini_get('magic_quotes_sybase') != 1)
00075                 return stripslashes_array($data);
00076         else
00077                 return undoSybaseQuotes_array($data);
00078 }
00079 
00080 function stripslashes_array($data) {
00081         return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
00082 }
00083 
00084 function undoSybaseQuotes_array($data) {
00085         return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data);
00086 }
00087 
00088 function undoSybaseQuotes($data) {
00089         return str_replace("''", "'", $data);
00090 }
00091 
00092 // integer array from request
00093 function requestIntArray($name) {
00094         global $HTTP_POST_VARS;
00095 
00096         if (!isset($HTTP_POST_VARS[$name])) {
00097                 return;
00098         }
00099 
00100         return $HTTP_POST_VARS[$name];
00101 }
00102 
00103 // array from request. Be sure to call undoMagic on the strings inside
00104 function requestArray($name) {
00105         global $HTTP_POST_VARS;
00106 
00107         if (!isset($HTTP_POST_VARS[$name])) {
00108                 return;
00109         }
00110 
00111         return $HTTP_POST_VARS[$name];
00112 }
00113 
00114 
00115 // add all the variables from the request as hidden input field
00116 // @see globalfunctions.php#passVar
00117 function passRequestVars() {
00118         global $HTTP_POST_VARS, $HTTP_GET_VARS;
00119         foreach ($HTTP_POST_VARS as $key => $value) {
00120                 if (($key == 'action') && ($value != requestVar('nextaction')))
00121                         $key = 'nextaction';
00122                 // a nextaction of 'showlogin' makes no sense
00123                 if (($key == 'nextaction') && ($value == 'showlogin'))
00124                         continue;
00125                 if (($key != 'login') && ($key != 'password'))
00126                         passVar($key, $value);
00127         }
00128         foreach ($HTTP_GET_VARS as $key => $value) {
00129                 if (($key == 'action') && ($value != requestVar('nextaction')))
00130                         $key = 'nextaction';
00131                 // a nextaction of 'showlogin' makes no sense
00132                 if (($key == 'nextaction') && ($value == 'showlogin'))
00133                         continue;
00134                 if (($key != 'login') && ($key != 'password'))
00135                         passVar($key, $value);
00136         }
00137 }
00138 
00139 function postFileInfo($name) {
00140         global $HTTP_POST_FILES;
00141 
00142         if (!isset($HTTP_POST_FILES[$name])) {
00143                 return;
00144         }
00145 
00146         return $HTTP_POST_FILES[$name];
00147 }
00148 
00149 function setOldAction($value) {
00150         global $HTTP_POST_VARS;
00151         $HTTP_POST_VARS['oldaction'] = $value;
00152 }
00153 
00154 ?>



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