[ Index ]

PHP Cross Reference of Nucleus CMS 3.32

title

Body

[close]

/nucleus/libs/ -> vars4.1.0.php (source)

   1  <?php
   2  
   3  /*
   4   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
   5   * Copyright (C) 2002-2007 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  /**
  14   * @license http://nucleuscms.org/license.txt GNU General Public License
  15   * @copyright Copyright (C) 2002-2007 The Nucleus Group
  16   * @version $Id: vars4.1.0.php 1153 2007-05-20 23:18:22Z kaigreve $
  17   */
  18  
  19  function getVar($name) {
  20      if (!isset($_GET[$name])) {
  21          return;
  22      }
  23  
  24      return undoMagic($_GET[$name]);
  25  }
  26  
  27  function postVar($name) {
  28      if (!isset($_POST[$name])) {
  29          return;
  30      }
  31  
  32      return undoMagic($_POST[$name]);
  33  }
  34  
  35  function cookieVar($name) {
  36      if (!isset($_COOKIE[$name])) {
  37          return;
  38      }
  39  
  40      return undoMagic($_COOKIE[$name]);
  41  }
  42  
  43  function requestVar($name) {
  44      if(array_key_exists($name,$_REQUEST))
  45          return undoMagic($_REQUEST[$name]);
  46      elseif( array_key_exists($name,$_GET))
  47          return undoMagic($_GET[$name]);
  48      elseif( array_key_exists($name,$_POST))
  49          return undoMagic($_POST[$name]);
  50      else
  51          return;
  52  }
  53  
  54  function serverVar($name) {
  55      if (!isset($_SERVER[$name])) {
  56          return false;
  57      }
  58  
  59      return $_SERVER[$name];
  60  }
  61  
  62  // removes magic quotes if that option is enabled
  63  function undoMagic($data) {
  64      if (!get_magic_quotes_gpc())
  65          return $data;
  66      if (ini_get('magic_quotes_sybase') != 1)
  67          return stripslashes_array($data);
  68      else
  69          return undoSybaseQuotes_array($data);
  70  }
  71  
  72  function stripslashes_array($data) {
  73      return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data);
  74  }
  75  
  76  function undoSybaseQuotes_array($data) {
  77      return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data);
  78  }
  79  
  80  function undoSybaseQuotes($data) {
  81      return str_replace("''", "'", $data);
  82  }
  83  
  84  // integer array from request
  85  function requestIntArray($name) {
  86      if (!isset($_REQUEST[$name])) {
  87          return;
  88      }
  89  
  90      return $_REQUEST[$name];
  91  }
  92  
  93  // array from request. Be sure to call undoMagic on the strings inside
  94  function requestArray($name) {
  95      if (!isset($_REQUEST[$name])) {
  96          return;
  97      }
  98  
  99      return $_REQUEST[$name];
 100  }
 101  
 102  // add all the variables from the request as hidden input field
 103  // @see globalfunctions.php#passVar
 104  function passRequestVars() {
 105      foreach ($_REQUEST as $key => $value) {
 106          if (($key == 'action') && ($value != requestVar('nextaction')))
 107              $key = 'nextaction';
 108  
 109          // a nextaction of 'showlogin' makes no sense
 110          if (($key == 'nextaction') && ($value == 'showlogin'))
 111              continue;
 112  
 113          if (($key != 'login') && ($key != 'password'))
 114              passVar($key, $value);
 115      }
 116  }
 117  
 118  function postFileInfo($name) {
 119      if (!isset($_FILES[$name])) {
 120          return;
 121      }
 122  
 123      return $_FILES[$name];
 124  }
 125  
 126  function setOldAction($value) {
 127      $_POST['oldaction'] = $value;
 128  }
 129  
 130  
 131  ?>


Generated: Tue Feb 12 15:34:36 2008 Cross-referenced by PHPXref 0.7