This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php namespace Myth\Themers; |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | require_once dirname(__FILE__) .'/escape.php'; |
||
4 | |||
5 | /** |
||
6 | * Sprint |
||
7 | * |
||
8 | * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow. |
||
9 | * |
||
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
||
11 | * of this software and associated documentation files (the "Software"), to deal |
||
12 | * in the Software without restriction, including without limitation the rights |
||
13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
14 | * copies of the Software, and to permit persons to whom the Software is |
||
15 | * furnished to do so, subject to the following conditions: |
||
16 | * |
||
17 | * The above copyright notice and this permission notice shall be included in |
||
18 | * all copies or substantial portions of the Software. |
||
19 | * |
||
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||
26 | * THE SOFTWARE. |
||
27 | * |
||
28 | * @package Sprint |
||
29 | * @author Lonnie Ezell |
||
30 | * @copyright Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com) |
||
31 | * @license http://opensource.org/licenses/MIT (MIT) |
||
32 | * @link http://sprintphp.com |
||
33 | * @since Version 1.0 |
||
34 | */ |
||
35 | |||
36 | /** |
||
37 | * Class MetaCollection |
||
38 | * |
||
39 | * @package Myth\Themers |
||
40 | */ |
||
41 | class MetaCollection implements MetaInterface { |
||
42 | |||
43 | /** |
||
44 | * Stores the meta values the user has set. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $meta = []; |
||
49 | |||
50 | /** |
||
51 | * Stores the standard meta-value names |
||
52 | * Mostly here for reference, I guess. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $std_meta = [ |
||
57 | 'application-name', |
||
58 | 'author', |
||
59 | 'copyright', |
||
60 | 'description', |
||
61 | 'generator', |
||
62 | 'keywords', |
||
63 | 'robots', |
||
64 | 'googlebot' |
||
65 | ]; |
||
66 | |||
67 | /** |
||
68 | * Stores the HTTP-Equiv meta tags |
||
69 | * since they need to be rendered differently. |
||
70 | * |
||
71 | * @var array |
||
72 | */ |
||
73 | protected $http_equiv_meta = [ |
||
74 | 'cache-control', |
||
75 | 'content-language', |
||
76 | 'content-type', |
||
77 | 'default-style', |
||
78 | 'expires', |
||
79 | 'pragma', |
||
80 | 'refresh', |
||
81 | 'set-cookie' |
||
82 | ]; |
||
83 | |||
84 | /** |
||
85 | * Stores the document's character encoding. |
||
86 | * |
||
87 | * @var string |
||
88 | */ |
||
89 | public $charset = 'utf-8'; |
||
90 | |||
91 | //-------------------------------------------------------------------- |
||
92 | |||
93 | public function __construct($ci) |
||
94 | { |
||
95 | $ci->config->load('html_meta', true); |
||
96 | |||
97 | $config = $ci->config->item('html_meta'); |
||
98 | |||
99 | $this->meta = $config['meta']; |
||
100 | |||
101 | $this->http_equiv_meta = array_merge($this->http_equiv_meta, $config['http-equiv']); |
||
102 | } |
||
103 | |||
104 | //-------------------------------------------------------------------- |
||
105 | |||
106 | |||
107 | /** |
||
108 | * Sets a single meta item. |
||
109 | * $alias can also be an array of key/value pairs to set. |
||
110 | * |
||
111 | * @param string|array $alias |
||
112 | * @param null $value |
||
113 | * |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public function set($alias, $value=null, $escape=true) |
||
117 | { |
||
118 | if (is_array($alias)) |
||
119 | { |
||
120 | foreach ($alias as $key => $val) |
||
121 | { |
||
122 | $this->set($key, $val); |
||
123 | } |
||
124 | |||
125 | return $this; |
||
126 | } |
||
127 | |||
128 | // Charset |
||
129 | if (strtolower($alias) == 'charset') |
||
130 | { |
||
131 | $this->charset = $value; |
||
132 | |||
133 | return $this; |
||
134 | } |
||
135 | |||
136 | $this->meta[ strtolower($alias) ] = $escape ? esc($value, 'htmlAttr') : $value; |
||
137 | |||
138 | return $this; |
||
139 | } |
||
140 | |||
141 | //-------------------------------------------------------------------- |
||
142 | |||
143 | /** |
||
144 | * Returns a single meta item. |
||
145 | * |
||
146 | * @param $alias |
||
147 | * |
||
148 | * @return mixed |
||
149 | */ |
||
150 | public function get($alias) |
||
151 | { |
||
152 | $alias = strtolower($alias); |
||
153 | |||
154 | return isset($this->meta[ $alias ]) ? $this->meta[$alias] : null; |
||
155 | } |
||
156 | |||
157 | //-------------------------------------------------------------------- |
||
158 | |||
159 | /** |
||
160 | * Renders out all defined meta tags. |
||
161 | * |
||
162 | * @return mixed |
||
163 | */ |
||
164 | public function renderTags() |
||
165 | { |
||
166 | if (! count($this->meta)) |
||
167 | { |
||
168 | return null; |
||
169 | } |
||
170 | |||
171 | $output = ''; |
||
172 | |||
173 | // Character Encoding |
||
174 | $output .= "\t<meta charset=\"{$this->charset}\" >"; |
||
175 | |||
176 | // Everything else |
||
177 | foreach ($this->meta as $name => $content) |
||
178 | { |
||
179 | if (is_array($content)) |
||
180 | { |
||
181 | $content = implode(',', $content); |
||
182 | } |
||
183 | |||
184 | if (empty($content)) |
||
185 | { |
||
186 | continue; |
||
187 | } |
||
188 | |||
189 | // Http Equivalent meta tags. |
||
190 | if (in_array($name, $this->http_equiv_meta)) |
||
191 | { |
||
192 | $output .= "\t<meta http-equiv=\"{$name}\" content=\"{$content}\">\n"; |
||
193 | } |
||
194 | // Standard Meta Tag |
||
195 | else { |
||
196 | $output .= "\t<meta name=\"{$name}\" content=\"{$content}\">\n"; |
||
197 | } |
||
198 | } |
||
199 | |||
200 | return $output; |
||
201 | } |
||
202 | |||
203 | //-------------------------------------------------------------------- |
||
204 | |||
205 | /** |
||
206 | * Registers a new HTTP Equivalent meta tag so it can be |
||
207 | * rendered out properly. |
||
208 | * |
||
209 | * @param $name |
||
210 | * |
||
211 | * @return $this |
||
212 | */ |
||
213 | public function registerHTTPEquivTag($name) |
||
214 | { |
||
215 | if (is_null($name)) |
||
216 | { |
||
217 | return $this; |
||
218 | } |
||
219 | |||
220 | $this->http_equiv_meta[] = strtolower($name); |
||
221 | |||
222 | return $this; |
||
223 | } |
||
224 | |||
225 | //-------------------------------------------------------------------- |
||
226 | |||
227 | |||
228 | /** |
||
229 | * Convenience implementation to set a value |
||
230 | * as if it was a property of the class. |
||
231 | * |
||
232 | * @param $alias |
||
233 | * @param null $value |
||
234 | */ |
||
235 | public function __set($alias, $value=null) |
||
236 | { |
||
237 | $this->set($alias, $value); |
||
238 | } |
||
239 | |||
240 | //-------------------------------------------------------------------- |
||
241 | |||
242 | /** |
||
243 | * Convenience method to access a value |
||
244 | * as if it was a property of the class. |
||
245 | * |
||
246 | * @param $alias |
||
247 | * |
||
248 | * @return mixed |
||
249 | */ |
||
250 | public function __get($alias) |
||
251 | { |
||
252 | return $this->get($alias); |
||
253 | } |
||
254 | |||
255 | //-------------------------------------------------------------------- |
||
256 | |||
257 | |||
258 | |||
259 | } |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.