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

base.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 4.27 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\cache\driver;
015   
016  abstract class base implements \phpbb\cache\driver\driver_interface
017  {
018      var $vars = array();
019      var $is_modified = false;
020   
021      var $sql_rowset = array();
022      var $sql_row_pointer = array();
023      var $cache_dir = '';
024   
025      /**
026      * {@inheritDoc}
027      */
028      function purge()
029      {
030          // Purge all phpbb cache files
031          try
032          {
033              $iterator = new \DirectoryIterator($this->cache_dir);
034          }
035          catch (\Exception $e)
036          {
037              return;
038          }
039   
040          foreach ($iterator as $fileInfo)
041          {
042              if ($fileInfo->isDot())
043              {
044                  continue;
045              }
046              $filename = $fileInfo->getFilename();
047              if ($fileInfo->isDir())
048              {
049                  $this->remove_dir($fileInfo->getPathname());
050              }
051              else if (strpos($filename, 'container_') === 0 ||
052                  strpos($filename, 'url_matcher') === 0 ||
053                  strpos($filename, 'sql_') === 0 ||
054                  strpos($filename, 'data_') === 0)
055              {
056                  $this->remove_file($fileInfo->getPathname());
057              }
058          }
059   
060          unset($this->vars);
061          unset($this->sql_rowset);
062          unset($this->sql_row_pointer);
063   
064          $this->vars = array();
065          $this->sql_rowset = array();
066          $this->sql_row_pointer = array();
067   
068          $this->is_modified = false;
069      }
070   
071      /**
072      * {@inheritDoc}
073      */
074      function unload()
075      {
076          $this->save();
077          unset($this->vars);
078          unset($this->sql_rowset);
079          unset($this->sql_row_pointer);
080   
081          $this->vars = array();
082          $this->sql_rowset = array();
083          $this->sql_row_pointer = array();
084      }
085   
086      /**
087      * {@inheritDoc}
088      */
089      function sql_load($query)
090      {
091          // Remove extra spaces and tabs
092          $query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
093   
094          if (($rowset = $this->_read('sql_' . md5($query))) === false)
095          {
096              return false;
097          }
098   
099          $query_id = sizeof($this->sql_rowset);
100          $this->sql_rowset[$query_id] = $rowset;
101          $this->sql_row_pointer[$query_id] = 0;
102   
103          return $query_id;
104      }
105   
106      /**
107      * {@inheritDoc}
108      */
109      function sql_exists($query_id)
110      {
111          return isset($this->sql_rowset[$query_id]);
112      }
113   
114      /**
115      * {@inheritDoc}
116      */
117      function sql_fetchrow($query_id)
118      {
119          if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
120          {
121              return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
122          }
123   
124          return false;
125      }
126   
127      /**
128      * {@inheritDoc}
129      */
130      function sql_fetchfield($query_id, $field)
131      {
132          if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
133          {
134              return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++][$field] : false;
135          }
136   
137          return false;
138      }
139   
140      /**
141      * {@inheritDoc}
142      */
143      function sql_rowseek($rownum, $query_id)
144      {
145          if ($rownum >= sizeof($this->sql_rowset[$query_id]))
146          {
147              return false;
148          }
149   
150          $this->sql_row_pointer[$query_id] = $rownum;
151          return true;
152      }
153   
154      /**
155      * {@inheritDoc}
156      */
157      function sql_freeresult($query_id)
158      {
159          if (!isset($this->sql_rowset[$query_id]))
160          {
161              return false;
162          }
163   
164          unset($this->sql_rowset[$query_id]);
165          unset($this->sql_row_pointer[$query_id]);
166   
167          return true;
168      }
169   
170      /**
171      * Removes/unlinks file
172      *
173      * @param string $filename Filename to remove
174      * @param bool $check Check file permissions
175      * @return bool True if the file was successfully removed, otherwise false
176      */
177      function remove_file($filename, $check = false)
178      {
179          if (!function_exists('phpbb_is_writable'))
180          {
181              global $phpbb_root_path, $phpEx;
182              include($phpbb_root_path . 'includes/functions.' . $phpEx);
183          }
184   
185          if ($check && !phpbb_is_writable($this->cache_dir))
186          {
187              // E_USER_ERROR - not using language entry - intended.
188              trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR);
189          }
190   
191          return @unlink($filename);
192      }
193   
194      /**
195      * Remove directory
196      *
197      * @param string $dir Directory to remove
198      *
199      * @return null
200      */
201      protected function remove_dir($dir)
202      {
203          try
204          {
205              $iterator = new \DirectoryIterator($dir);
206          }
207          catch (\Exception $e)
208          {
209              return;
210          }
211   
212          foreach ($iterator as $fileInfo)
213          {
214              if ($fileInfo->isDot())
215              {
216                  continue;
217              }
218   
219              if ($fileInfo->isDir())
220              {
221                  $this->remove_dir($fileInfo->getPathname());
222              }
223              else
224              {
225                  $this->remove_file($fileInfo->getPathname());
226              }
227          }
228   
229          @rmdir($dir);
230      }
231  }
232