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

Sandbox.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.55 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of Twig.
 005   *
 006   * (c) 2009 Fabien Potencier
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011  class Twig_Extension_Sandbox extends Twig_Extension
 012  {
 013      protected $sandboxedGlobally;
 014      protected $sandboxed;
 015      protected $policy;
 016   
 017      public function __construct(Twig_Sandbox_SecurityPolicyInterface $policy, $sandboxed = false)
 018      {
 019          $this->policy            = $policy;
 020          $this->sandboxedGlobally = $sandboxed;
 021      }
 022   
 023      /**
 024       * Returns the token parser instances to add to the existing list.
 025       *
 026       * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
 027       */
 028      public function getTokenParsers()
 029      {
 030          return array(new Twig_TokenParser_Sandbox());
 031      }
 032   
 033      /**
 034       * Returns the node visitor instances to add to the existing list.
 035       *
 036       * @return array An array of Twig_NodeVisitorInterface instances
 037       */
 038      public function getNodeVisitors()
 039      {
 040          return array(new Twig_NodeVisitor_Sandbox());
 041      }
 042   
 043      public function enableSandbox()
 044      {
 045          $this->sandboxed = true;
 046      }
 047   
 048      public function disableSandbox()
 049      {
 050          $this->sandboxed = false;
 051      }
 052   
 053      public function isSandboxed()
 054      {
 055          return $this->sandboxedGlobally || $this->sandboxed;
 056      }
 057   
 058      public function isSandboxedGlobally()
 059      {
 060          return $this->sandboxedGlobally;
 061      }
 062   
 063      public function setSecurityPolicy(Twig_Sandbox_SecurityPolicyInterface $policy)
 064      {
 065          $this->policy = $policy;
 066      }
 067   
 068      public function getSecurityPolicy()
 069      {
 070          return $this->policy;
 071      }
 072   
 073      public function checkSecurity($tags, $filters, $functions)
 074      {
 075          if ($this->isSandboxed()) {
 076              $this->policy->checkSecurity($tags, $filters, $functions);
 077          }
 078      }
 079   
 080      public function checkMethodAllowed($obj, $method)
 081      {
 082          if ($this->isSandboxed()) {
 083              $this->policy->checkMethodAllowed($obj, $method);
 084          }
 085      }
 086   
 087      public function checkPropertyAllowed($obj, $method)
 088      {
 089          if ($this->isSandboxed()) {
 090              $this->policy->checkPropertyAllowed($obj, $method);
 091          }
 092      }
 093   
 094      public function ensureToStringAllowed($obj)
 095      {
 096          if (is_object($obj)) {
 097              $this->policy->checkMethodAllowed($obj, '__toString');
 098          }
 099   
 100          return $obj;
 101      }
 102   
 103      /**
 104       * Returns the name of the extension.
 105       *
 106       * @return string The extension name
 107       */
 108      public function getName()
 109      {
 110          return 'sandbox';
 111      }
 112  }
 113