Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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

SqliteProfilerStorage.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 5.06 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\Profiler;
 013   
 014  @trigger_error('The '.__NAMESPACE__.'\SqliteProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
 015   
 016  /**
 017   * SqliteProfilerStorage stores profiling information in a SQLite database.
 018   *
 019   * @author Fabien Potencier <fabien@symfony.com>
 020   *
 021   * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
 022   *             Use {@link FileProfilerStorage} instead.
 023   */
 024  class SqliteProfilerStorage extends PdoProfilerStorage
 025  {
 026      /**
 027       * @throws \RuntimeException When neither of SQLite3 or PDO_SQLite extension is enabled
 028       */
 029      protected function initDb()
 030      {
 031          if (null === $this->db || $this->db instanceof \SQLite3) {
 032              if (0 !== strpos($this->dsn, 'sqlite')) {
 033                  throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Sqlite with an invalid dsn "%s". The expected format is "sqlite:/path/to/the/db/file".', $this->dsn));
 034              }
 035              if (class_exists('SQLite3')) {
 036                  $db = new \SQLite3(substr($this->dsn, 7, strlen($this->dsn)), \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE);
 037                  if (method_exists($db, 'busyTimeout')) {
 038                      // busyTimeout only exists for PHP >= 5.3.3
 039                      $db->busyTimeout(1000);
 040                  }
 041              } elseif (class_exists('PDO') && in_array('sqlite', \PDO::getAvailableDrivers(), true)) {
 042                  $db = new \PDO($this->dsn);
 043              } else {
 044                  throw new \RuntimeException('You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.');
 045              }
 046   
 047              $db->exec('PRAGMA temp_store=MEMORY; PRAGMA journal_mode=MEMORY;');
 048              $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token STRING, data STRING, ip STRING, method STRING, url STRING, time INTEGER, parent STRING, created_at INTEGER, status_code INTEGER)');
 049              $db->exec('CREATE INDEX IF NOT EXISTS data_created_at ON sf_profiler_data (created_at)');
 050              $db->exec('CREATE INDEX IF NOT EXISTS data_ip ON sf_profiler_data (ip)');
 051              $db->exec('CREATE INDEX IF NOT EXISTS data_method ON sf_profiler_data (method)');
 052              $db->exec('CREATE INDEX IF NOT EXISTS data_url ON sf_profiler_data (url)');
 053              $db->exec('CREATE INDEX IF NOT EXISTS data_parent ON sf_profiler_data (parent)');
 054              $db->exec('CREATE UNIQUE INDEX IF NOT EXISTS data_token ON sf_profiler_data (token)');
 055   
 056              $this->db = $db;
 057          }
 058   
 059          return $this->db;
 060      }
 061   
 062      protected function exec($db, $query, array $args = array())
 063      {
 064          if ($db instanceof \SQLite3) {
 065              $stmt = $this->prepareStatement($db, $query);
 066              foreach ($args as $arg => $val) {
 067                  $stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT);
 068              }
 069   
 070              $res = $stmt->execute();
 071              if (false === $res) {
 072                  throw new \RuntimeException(sprintf('Error executing SQLite query "%s"', $query));
 073              }
 074              $res->finalize();
 075          } else {
 076              parent::exec($db, $query, $args);
 077          }
 078      }
 079   
 080      protected function fetch($db, $query, array $args = array())
 081      {
 082          $return = array();
 083   
 084          if ($db instanceof \SQLite3) {
 085              $stmt = $this->prepareStatement($db, $query);
 086              foreach ($args as $arg => $val) {
 087                  $stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT);
 088              }
 089              $res = $stmt->execute();
 090              while ($row = $res->fetchArray(\SQLITE3_ASSOC)) {
 091                  $return[] = $row;
 092              }
 093              $res->finalize();
 094              $stmt->close();
 095          } else {
 096              $return = parent::fetch($db, $query, $args);
 097          }
 098   
 099          return $return;
 100      }
 101   
 102      /**
 103       * {@inheritdoc}
 104       */
 105      protected function buildCriteria($ip, $url, $start, $end, $limit, $method)
 106      {
 107          $criteria = array();
 108          $args = array();
 109   
 110          if ($ip = preg_replace('/[^\d\.]/', '', $ip)) {
 111              $criteria[] = 'ip LIKE :ip';
 112              $args[':ip'] = '%'.$ip.'%';
 113          }
 114   
 115          if ($url) {
 116              $criteria[] = 'url LIKE :url ESCAPE "\"';
 117              $args[':url'] = '%'.addcslashes($url, '%_\\').'%';
 118          }
 119   
 120          if ($method) {
 121              $criteria[] = 'method = :method';
 122              $args[':method'] = $method;
 123          }
 124   
 125          if (!empty($start)) {
 126              $criteria[] = 'time >= :start';
 127              $args[':start'] = $start;
 128          }
 129   
 130          if (!empty($end)) {
 131              $criteria[] = 'time <= :end';
 132              $args[':end'] = $end;
 133          }
 134   
 135          return array($criteria, $args);
 136      }
 137   
 138      protected function close($db)
 139      {
 140          if ($db instanceof \SQLite3) {
 141              $db->close();
 142          }
 143      }
 144  }
 145