Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

deactivated_super_global.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 2.93 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\request;
015   
016  /**
017  * Replacement for a superglobal (like $_GET or $_POST) which calls
018  * trigger_error on all operations but isset, overloads the [] operator with SPL.
019  */
020  class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAggregate
021  {
022      /**
023      * @var    string    Holds the name of the superglobal this is replacing.
024      */
025      private $name;
026   
027      /**
028      * @var    \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE    Super global constant.
029      */
030      private $super_global;
031   
032      /**
033      * @var    \phpbb\request\request_interface    The request class instance holding the actual request data.
034      */
035      private $request;
036   
037      /**
038      * Constructor generates an error message fitting the super global to be used within the other functions.
039      *
040      * @param    \phpbb\request\request_interface    $request    A request class instance holding the real super global data.
041      * @param    string                    $name        Name of the super global this is a replacement for - e.g. '_GET'.
042      * @param    \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE    $super_global    The variable's super global constant.
043      */
044      public function __construct(\phpbb\request\request_interface $request, $name, $super_global)
045      {
046          $this->request = $request;
047          $this->name = $name;
048          $this->super_global = $super_global;
049      }
050   
051      /**
052      * Calls trigger_error with the file and line number the super global was used in.
053      */
054      private function error()
055      {
056          $file = '';
057          $line = 0;
058   
059          $message = 'Illegal use of $' . $this->name . '. You must use the request class or request_var() to access input data. Found in %s on line %d. This error message was generated by deactivated_super_global.';
060   
061          $backtrace = debug_backtrace();
062          if (isset($backtrace[1]))
063          {
064              $file = $backtrace[1]['file'];
065              $line = $backtrace[1]['line'];
066          }
067          trigger_error(sprintf($message, $file, $line), E_USER_ERROR);
068      }
069   
070      /**
071      * Redirects isset to the correct request class call.
072      *
073      * @param    string    $offset    The key of the super global being accessed.
074      *
075      * @return    bool    Whether the key on the super global exists.
076      */
077      public function offsetExists($offset)
078      {
079          return $this->request->is_set($offset, $this->super_global);
080      }
081   
082      /**#@+
083      * Part of the \ArrayAccess implementation, will always result in a FATAL error.
084      */
085      public function offsetGet($offset)
086      {
087          $this->error();
088      }
089   
090      public function offsetSet($offset, $value)
091      {
092          $this->error();
093      }
094   
095      public function offsetUnset($offset)
096      {
097          $this->error();
098      }
099      /**#@-*/
100   
101      /**
102      * Part of the \Countable implementation, will always result in a FATAL error
103      */
104      public function count()
105      {
106          $this->error();
107      }
108   
109      /**
110      * Part of the Traversable/IteratorAggregate implementation, will always result in a FATAL error
111      */
112      public function getIterator()
113      {
114          $this->error();
115      }
116  }
117