Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

Esi.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.60 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\HttpKernel\HttpCache;
013   
014  use Symfony\Component\HttpFoundation\Request;
015  use Symfony\Component\HttpFoundation\Response;
016   
017  /**
018   * Esi implements the ESI capabilities to Request and Response instances.
019   *
020   * For more information, read the following W3C notes:
021   *
022   *  * ESI Language Specification 1.0 (http://www.w3.org/TR/esi-lang)
023   *
024   *  * Edge Architecture Specification (http://www.w3.org/TR/edge-arch)
025   *
026   * @author Fabien Potencier <fabien@symfony.com>
027   */
028  class Esi extends AbstractSurrogate
029  {
030      public function getName()
031      {
032          return 'esi';
033      }
034   
035      /**
036       * {@inheritdoc}
037       */
038      public function addSurrogateControl(Response $response)
039      {
040          if (false !== strpos($response->getContent(), '<esi:include')) {
041              $response->headers->set('Surrogate-Control', 'content="ESI/1.0"');
042          }
043      }
044   
045      /**
046       * {@inheritdoc}
047       */
048      public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '')
049      {
050          $html = sprintf('<esi:include src="%s"%s%s />',
051              $uri,
052              $ignoreErrors ? ' onerror="continue"' : '',
053              $alt ? sprintf(' alt="%s"', $alt) : ''
054          );
055   
056          if (!empty($comment)) {
057              return sprintf("<esi:comment text=\"%s\" />\n%s", $comment, $html);
058          }
059   
060          return $html;
061      }
062   
063      /**
064       * {@inheritdoc}
065       */
066      public function process(Request $request, Response $response)
067      {
068          $type = $response->headers->get('Content-Type');
069          if (empty($type)) {
070              $type = 'text/html';
071          }
072   
073          $parts = explode(';', $type);
074          if (!\in_array($parts[0], $this->contentTypes)) {
075              return $response;
076          }
077   
078          // we don't use a proper XML parser here as we can have ESI tags in a plain text response
079          $content = $response->getContent();
080          $content = preg_replace('#<esi\:remove>.*?</esi\:remove>#s', '', $content);
081          $content = preg_replace('#<esi\:comment[^>]+>#s', '', $content);
082   
083          $chunks = preg_split('#<esi\:include\s+(.*?)\s*(?:/|</esi\:include)>#', $content, -1, \PREG_SPLIT_DELIM_CAPTURE);
084          $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]);
085   
086          $i = 1;
087          while (isset($chunks[$i])) {
088              $options = [];
089              preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, \PREG_SET_ORDER);
090              foreach ($matches as $set) {
091                  $options[$set[1]] = $set[2];
092              }
093   
094              if (!isset($options['src'])) {
095                  throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.');
096              }
097   
098              $chunks[$i] = sprintf('<?php echo $this->surrogate->handle($this, %s, %s, %s) ?>'."\n",
099                  var_export($options['src'], true),
100                  var_export(isset($options['alt']) ? $options['alt'] : '', true),
101                  isset($options['onerror']) && 'continue' === $options['onerror'] ? 'true' : 'false'
102              );
103              ++$i;
104              $chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]);
105              ++$i;
106          }
107          $content = implode('', $chunks);
108   
109          $response->setContent($content);
110          $response->headers->set('X-Body-Eval', 'ESI');
111   
112          // remove ESI/1.0 from the Surrogate-Control header
113          $this->removeFromControl($response);
114   
115          return $response;
116      }
117  }
118