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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
config_php_file.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;
015
016 class config_php_file
017 {
018 /** @var string phpBB Root Path */
019 protected $phpbb_root_path;
020
021 /** @var string php file extension */
022 protected $php_ext;
023
024 /**
025 * Indicates whether the php config file has been loaded.
026 *
027 * @var bool
028 */
029 protected $config_loaded = false;
030
031 /**
032 * The content of the php config file
033 *
034 * @var array
035 */
036 protected $config_data = array();
037
038 /**
039 * The path to the config file. (Default: $phpbb_root_path . 'config.' . $php_ext)
040 *
041 * @var string
042 */
043 protected $config_file;
044
045 private $defined_vars;
046
047 /**
048 * Constructor
049 *
050 * @param string $phpbb_root_path phpBB Root Path
051 * @param string $php_ext php file extension
052 */
053 function __construct($phpbb_root_path, $php_ext)
054 {
055 $this->phpbb_root_path = $phpbb_root_path;
056 $this->php_ext = $php_ext;
057 $this->config_file = $this->phpbb_root_path . 'config.' . $this->php_ext;
058 }
059
060 /**
061 * Set the path to the config file.
062 *
063 * @param string $config_file
064 */
065 public function set_config_file($config_file)
066 {
067 $this->config_file = $config_file;
068 $this->config_loaded = false;
069 }
070
071 /**
072 * Returns an associative array containing the variables defined by the config file.
073 *
074 * @return array Return the content of the config file or an empty array if the file does not exists.
075 */
076 public function get_all()
077 {
078 $this->load_config_file();
079
080 return $this->config_data;
081 }
082
083 /**
084 * Return the value of a variable defined into the config.php file or null if the variable does not exist.
085 *
086 * @param string $variable The name of the variable
087 * @return mixed Value of the variable or null if the variable is not defined.
088 */
089 public function get($variable)
090 {
091 $this->load_config_file();
092
093 return isset($this->config_data[$variable]) ? $this->config_data[$variable] : null;
094 }
095
096 /**
097 * Load the config file and store the information.
098 *
099 * @return null
100 */
101 protected function load_config_file()
102 {
103 if (!$this->config_loaded && file_exists($this->config_file))
104 {
105 $this->defined_vars = get_defined_vars();
106
107 require($this->config_file);
108 $this->config_data = array_diff_key(get_defined_vars(), $this->defined_vars);
109
110 $this->config_loaded = true;
111 }
112 }
113
114 /**
115 * Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name.
116 *
117 * If $dbms is a valid 3.1 db driver class name, returns it unchanged.
118 * Otherwise prepends phpbb\db\driver\ to the dbms to convert a 3.0 dbms
119 * to 3.1 db driver class name.
120 *
121 * @param string $dbms dbms parameter
122 * @return string driver class
123 * @throws \RuntimeException
124 */
125 public function convert_30_dbms_to_31($dbms)
126 {
127 // Note: this check is done first because mysqli extension
128 // supplies a mysqli class, and class_exists($dbms) would return
129 // true for mysqli class.
130 // However, per the docblock any valid 3.1 driver name should be
131 // recognized by this function, and have priority over 3.0 dbms.
132 if (strpos($dbms, 'phpbb\db\driver') === false && class_exists('phpbb\db\driver\\' . $dbms))
133 {
134 return 'phpbb\db\driver\\' . $dbms;
135 }
136
137 if (class_exists($dbms))
138 {
139 // Additionally we could check that $dbms extends phpbb\db\driver\driver.
140 // http://php.net/manual/en/class.reflectionclass.php
141 // Beware of possible performance issues:
142 // http://stackoverflow.com/questions/294582/php-5-reflection-api-performance
143 // We could check for interface implementation in all paths or
144 // only when we do not prepend phpbb\db\driver\.
145
146 /*
147 $reflection = new \ReflectionClass($dbms);
148
149 if ($reflection->isSubclassOf('phpbb\db\driver\driver'))
150 {
151 return $dbms;
152 }
153 */
154
155 return $dbms;
156 }
157
158 throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
159 }
160 }
161