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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
base.php
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, 'autoload_') === 0 ||
053 strpos($filename, 'url_matcher') === 0 ||
054 strpos($filename, 'url_generator') === 0 ||
055 strpos($filename, 'sql_') === 0 ||
056 strpos($filename, 'data_') === 0)
057 {
058 $this->remove_file($fileInfo->getPathname());
059 }
060 }
061
062 unset($this->vars);
063 unset($this->sql_rowset);
064 unset($this->sql_row_pointer);
065
066 if (function_exists('opcache_reset'))
067 {
068 @opcache_reset();
069 }
070
071 $this->vars = array();
072 $this->sql_rowset = array();
073 $this->sql_row_pointer = array();
074
075 $this->is_modified = false;
076 }
077
078 /**
079 * {@inheritDoc}
080 */
081 function unload()
082 {
083 $this->save();
084 unset($this->vars);
085 unset($this->sql_rowset);
086 unset($this->sql_row_pointer);
087
088 $this->vars = array();
089 $this->sql_rowset = array();
090 $this->sql_row_pointer = array();
091 }
092
093 /**
094 * {@inheritDoc}
095 */
096 function sql_load($query)
097 {
098 // Remove extra spaces and tabs
099 $query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
100 $query_id = md5($query);
101
102 if (($result = $this->_read('sql_' . $query_id)) === false)
103 {
104 return false;
105 }
106
107 $this->sql_rowset[$query_id] = $result;
108 $this->sql_row_pointer[$query_id] = 0;
109
110 return $query_id;
111 }
112
113 /**
114 * {@inheritDoc}
115 */
116 function sql_exists($query_id)
117 {
118 return isset($this->sql_rowset[$query_id]);
119 }
120
121 /**
122 * {@inheritDoc}
123 */
124 function sql_fetchrow($query_id)
125 {
126 if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
127 {
128 return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
129 }
130
131 return false;
132 }
133
134 /**
135 * {@inheritDoc}
136 */
137 function sql_fetchfield($query_id, $field)
138 {
139 if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
140 {
141 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;
142 }
143
144 return false;
145 }
146
147 /**
148 * {@inheritDoc}
149 */
150 function sql_rowseek($rownum, $query_id)
151 {
152 if ($rownum >= sizeof($this->sql_rowset[$query_id]))
153 {
154 return false;
155 }
156
157 $this->sql_row_pointer[$query_id] = $rownum;
158 return true;
159 }
160
161 /**
162 * {@inheritDoc}
163 */
164 function sql_freeresult($query_id)
165 {
166 if (!isset($this->sql_rowset[$query_id]))
167 {
168 return false;
169 }
170
171 unset($this->sql_rowset[$query_id]);
172 unset($this->sql_row_pointer[$query_id]);
173
174 return true;
175 }
176
177 /**
178 * Removes/unlinks file
179 *
180 * @param string $filename Filename to remove
181 * @param bool $check Check file permissions
182 * @return bool True if the file was successfully removed, otherwise false
183 */
184 function remove_file($filename, $check = false)
185 {
186 global $phpbb_filesystem;
187
188 if ($check && !$phpbb_filesystem->is_writable($this->cache_dir))
189 {
190 // E_USER_ERROR - not using language entry - intended.
191 trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR);
192 }
193
194 return @unlink($filename);
195 }
196
197 /**
198 * Remove directory
199 *
200 * @param string $dir Directory to remove
201 *
202 * @return null
203 */
204 protected function remove_dir($dir)
205 {
206 try
207 {
208 $iterator = new \DirectoryIterator($dir);
209 }
210 catch (\Exception $e)
211 {
212 return;
213 }
214
215 foreach ($iterator as $fileInfo)
216 {
217 if ($fileInfo->isDot())
218 {
219 continue;
220 }
221
222 if ($fileInfo->isDir())
223 {
224 $this->remove_dir($fileInfo->getPathname());
225 }
226 else
227 {
228 $this->remove_file($fileInfo->getPathname());
229 }
230 }
231
232 @rmdir($dir);
233 }
234 }
235