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. |
|
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
config.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\config;
015
016 /**
017 * Configuration container class
018 */
019 class config implements \ArrayAccess, \IteratorAggregate, \Countable
020 {
021 /**
022 * The configuration data
023 * @var array<string,string>
024 */
025 protected $config;
026
027 /**
028 * Creates a configuration container with a default set of values
029 *
030 * @param array<string,string> $config The configuration data.
031 */
032 public function __construct(array $config)
033 {
034 $this->config = $config;
035 }
036
037 /**
038 * Retrieves an ArrayIterator over the configuration values.
039 *
040 * @return \ArrayIterator An iterator over all config data
041 */
042 public function getIterator()
043 {
044 return new \ArrayIterator($this->config);
045 }
046
047 /**
048 * Checks if the specified config value exists.
049 *
050 * @param string $key The configuration option's name.
051 * @return bool Whether the configuration option exists.
052 */
053 #[\ReturnTypeWillChange]
054 public function offsetExists($key)
055 {
056 return isset($this->config[$key]);
057 }
058
059 /**
060 * Retrieves a configuration value.
061 *
062 * @param string $key The configuration option's name.
063 * @return string The configuration value
064 */
065 #[\ReturnTypeWillChange]
066 public function offsetGet($key)
067 {
068 return (isset($this->config[$key])) ? $this->config[$key] : '';
069 }
070
071 /**
072 * Temporarily overwrites the value of a configuration variable.
073 *
074 * The configuration change will not persist. It will be lost
075 * after the request.
076 *
077 * @param string $key The configuration option's name.
078 * @param string $value The temporary value.
079 */
080 #[\ReturnTypeWillChange]
081 public function offsetSet($key, $value)
082 {
083 $this->config[$key] = $value;
084 }
085
086 /**
087 * Called when deleting a configuration value directly, triggers an error.
088 *
089 * @param string $key The configuration option's name.
090 */
091 #[\ReturnTypeWillChange]
092 public function offsetUnset($key)
093 {
094 trigger_error('Config values have to be deleted explicitly with the \phpbb\config\config::delete($key) method.', E_USER_ERROR);
095 }
096
097 /**
098 * Retrieves the number of configuration options currently set.
099 *
100 * @return int Number of config options
101 */
102 public function count()
103 {
104 return count($this->config);
105 }
106
107 /**
108 * Removes a configuration option
109 *
110 * @param String $key The configuration option's name
111 * @param bool $use_cache Whether this variable should be cached or if it
112 * changes too frequently to be efficiently cached
113 * @return null
114 */
115 public function delete($key, $use_cache = true)
116 {
117 unset($this->config[$key]);
118 }
119
120 /**
121 * Sets a configuration option's value
122 *
123 * @param string $key The configuration option's name
124 * @param string $value New configuration value
125 * @param bool $use_cache Whether this variable should be cached or if it
126 * changes too frequently to be efficiently cached.
127 */
128 public function set($key, $value, $use_cache = true)
129 {
130 $this->config[$key] = $value;
131 }
132
133 /**
134 * Sets a configuration option's value only if the old_value matches the
135 * current configuration value or the configuration value does not exist yet.
136 *
137 * @param string $key The configuration option's name
138 * @param string $old_value Current configuration value
139 * @param string $new_value New configuration value
140 * @param bool $use_cache Whether this variable should be cached or if it
141 * changes too frequently to be efficiently cached.
142 * @return bool True if the value was changed, false otherwise.
143 */
144 public function set_atomic($key, $old_value, $new_value, $use_cache = true)
145 {
146 if (!isset($this->config[$key]) || $this->config[$key] == $old_value)
147 {
148 $this->config[$key] = $new_value;
149 return true;
150 }
151 return false;
152 }
153
154 /**
155 * Checks configuration option's value only if the new_value matches the
156 * current configuration value and the configuration value does exist.Called
157 * only after set_atomic has been called.
158 *
159 * @param string $key The configuration option's name
160 * @param string $new_value New configuration value
161 * @throws \phpbb\exception\http_exception when config value is set and not equal to new_value.
162 * @return bool True if the value was changed, false otherwise.
163 */
164 public function ensure_lock($key, $new_value)
165 {
166 if (isset($this->config[$key]) && $this->config[$key] == $new_value)
167 {
168 return true;
169 }
170 throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.');
171 }
172
173 /**
174 * Increments an integer configuration value.
175 *
176 * @param string $key The configuration option's name
177 * @param int $increment Amount to increment by
178 * @param bool $use_cache Whether this variable should be cached or if it
179 * changes too frequently to be efficiently cached.
180 */
181 function increment($key, $increment, $use_cache = true)
182 {
183 if (!isset($this->config[$key]))
184 {
185 $this->config[$key] = 0;
186 }
187
188 $this->config[$key] += $increment;
189 }
190 }
191