Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/vendors/Textpattern/Server/Config.php - 132 lines - 2704 bytes - Summary - Text - Print

Description: Access server configuration variables.

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * http://textpattern.com
   6   *
   7   * Copyright (C) 2016 The Textpattern Development Team
   8   *
   9   * This file is part of Textpattern.
  10   *
  11   * Textpattern is free software; you can redistribute it and/or
  12   * modify it under the terms of the GNU General Public License
  13   * as published by the Free Software Foundation, version 2.
  14   *
  15   * Textpattern is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with Textpattern. If not, see <http://www.gnu.org/licenses/>.
  22   */
  23  
  24  /**
  25   * Access server configuration variables.
  26   *
  27   * <code>
  28   * Txp::get('Textpattern\Server\Config')->getVariable('REQUEST_URI');
  29   * </code>
  30   *
  31   * @since   4.6.0
  32   * @package Server
  33   */
  34  
  35  namespace Textpattern\Server;
  36  
  37  class Config
  38  {
  39      /**
  40       * Magic quotes GPC status.
  41       *
  42       * @var bool
  43       */
  44  
  45      private $magicQuotesGpc = false;
  46  
  47      /**
  48       * Magic quotes runtime status.
  49       *
  50       * @var bool
  51       */
  52  
  53      private $magicQuotesRuntime = false;
  54  
  55      /**
  56       * Register globals status.
  57       *
  58       * @var bool
  59       */
  60  
  61      private $registerGlobals = false;
  62  
  63      /**
  64       * Constructor.
  65       */
  66  
  67      public function __construct()
  68      {
  69          if (version_compare(PHP_VERSION, '5.4.0') < 0) {
  70              $this->magicQuotesGpc = @get_magic_quotes_gpc();
  71              $this->magicQuotesRuntime = @get_magic_quotes_runtime();
  72              $this->registerGlobals = @ini_get('register_globals');
  73          }
  74      }
  75  
  76      /**
  77       * Gets a server configuration variable.
  78       *
  79       * @param  string $name The variable
  80       * @return mixed The variable
  81       */
  82  
  83      public function getVariable($name)
  84      {
  85          if (isset($_SERVER[$name])) {
  86              return $_SERVER[$name];
  87          }
  88  
  89          return false;
  90      }
  91  
  92      /**
  93       * Magic quotes.
  94       *
  95       * @return bool
  96       */
  97  
  98      public function getMagicQuotesGpc()
  99      {
 100          return (bool)$this->magicQuotesGpc;
 101      }
 102  
 103      /**
 104       * Gets register globals status.
 105       *
 106       * @return bool
 107       */
 108  
 109      public function getRegisterGlobals()
 110      {
 111          return (bool)$this->registerGlobals;
 112      }
 113  
 114      /**
 115       * Turn runtime magic quotes off.
 116       *
 117       * <code>
 118       * Txp::get('\Textpattern\Server\Config')->setMagicQuotesOff();
 119       * </code>
 120       *
 121       * @return \Textpattern\Server\Config
 122       */
 123  
 124      public function setMagicQuotesOff()
 125      {
 126          if ($this->magicQuotesRuntime) {
 127              @set_magic_quotes_runtime(0);
 128          }
 129  
 130          return $this;
 131      }
 132  }

title

Description

title

Description

title

Description

title

title

Body