@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | */ |
11 | 11 | $style_path = 'media/style/' . $modx->config['manager_theme'] . '/images/'; |
12 | 12 | $modx->config['mgr_date_picker_path'] = 'media/calendar/datepicker.inc.php'; |
13 | -if(!$modx->config['lang_code']) { |
|
13 | +if(!$modx->config['lang_code']) { |
|
14 | 14 | global $modx_lang_attribute; |
15 | 15 | $modx->config['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; |
16 | 16 | } |
17 | 17 | |
18 | -if($_GET['a'] == 2) { |
|
18 | +if($_GET['a'] == 2) { |
|
19 | 19 | include_once('welcome.php'); |
20 | 20 | } |
21 | 21 | |
@@ -262,68 +262,68 @@ discard block |
||
262 | 262 | |
263 | 263 | // actions buttons templates |
264 | 264 | $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; |
265 | -if (!empty($modx->config['global_tabs']) && !isset($_SESSION['stay'])) { |
|
265 | +if (!empty($modx->config['global_tabs']) && !isset($_SESSION['stay'])) { |
|
266 | 266 | $_REQUEST['stay'] = 2; |
267 | 267 | } |
268 | -if (isset($_REQUEST['stay'])) { |
|
268 | +if (isset($_REQUEST['stay'])) { |
|
269 | 269 | $_SESSION['stay'] = $_REQUEST['stay']; |
270 | -} else if (isset($_SESSION['stay'])) { |
|
270 | +} else if (isset($_SESSION['stay'])) { |
|
271 | 271 | $_REQUEST['stay'] = $_SESSION['stay']; |
272 | 272 | } |
273 | 273 | $stay = isset($_REQUEST['stay']) ? $_REQUEST['stay'] : ''; |
274 | 274 | $addnew = 0; |
275 | 275 | $run = 0; |
276 | -switch($action) { |
|
276 | +switch($action) { |
|
277 | 277 | case '3': |
278 | 278 | case '4': |
279 | 279 | case '27': |
280 | 280 | case '72': |
281 | - if($modx->hasPermission('new_document')) { |
|
281 | + if($modx->hasPermission('new_document')) { |
|
282 | 282 | $addnew = 1; |
283 | 283 | } |
284 | 284 | break; |
285 | 285 | case '16': |
286 | 286 | case '19': |
287 | - if($modx->hasPermission('new_template')) { |
|
287 | + if($modx->hasPermission('new_template')) { |
|
288 | 288 | $addnew = 1; |
289 | 289 | } |
290 | 290 | break; |
291 | 291 | case '300': |
292 | 292 | case '301': |
293 | - if($modx->hasPermission('new_snippet') && $modx->hasPermission('new_chunk') && $modx->hasPermission('new_plugin')) { |
|
293 | + if($modx->hasPermission('new_snippet') && $modx->hasPermission('new_chunk') && $modx->hasPermission('new_plugin')) { |
|
294 | 294 | $addnew = 1; |
295 | 295 | } |
296 | 296 | break; |
297 | 297 | case '77': |
298 | 298 | case '78': |
299 | - if($modx->hasPermission('new_chunk')) { |
|
299 | + if($modx->hasPermission('new_chunk')) { |
|
300 | 300 | $addnew = 1; |
301 | 301 | } |
302 | 302 | break; |
303 | 303 | case '22': |
304 | 304 | case '23': |
305 | - if($modx->hasPermission('new_snippet')) { |
|
305 | + if($modx->hasPermission('new_snippet')) { |
|
306 | 306 | $addnew = 1; |
307 | 307 | } |
308 | 308 | break; |
309 | 309 | case '101': |
310 | 310 | case '102': |
311 | - if($modx->hasPermission('new_plugin')) { |
|
311 | + if($modx->hasPermission('new_plugin')) { |
|
312 | 312 | $addnew = 1; |
313 | 313 | } |
314 | 314 | break; |
315 | 315 | case '106': |
316 | 316 | case '107': |
317 | 317 | case '108': |
318 | - if($modx->hasPermission('new_module')) { |
|
318 | + if($modx->hasPermission('new_module')) { |
|
319 | 319 | $addnew = 1; |
320 | 320 | } |
321 | - if($modx->hasPermission('exec_module')) { |
|
321 | + if($modx->hasPermission('exec_module')) { |
|
322 | 322 | $run = 1; |
323 | 323 | } |
324 | 324 | break; |
325 | 325 | case '88': |
326 | - if($modx->hasPermission('new_web_user')) { |
|
326 | + if($modx->hasPermission('new_web_user')) { |
|
327 | 327 | $addnew = 1; |
328 | 328 | } |
329 | 329 | break; |
@@ -1,8 +1,11 @@ |
||
1 | 1 | <?php |
2 | -class DATEPICKER { |
|
3 | - function __construct() { |
|
2 | +class DATEPICKER |
|
3 | +{ |
|
4 | + function __construct() |
|
5 | + { |
|
4 | 6 | } |
5 | - function getDP() { |
|
7 | + function getDP() |
|
8 | + { |
|
6 | 9 | global $modx,$_lang; |
7 | 10 | |
8 | 11 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | NOTE: http://www.w3.org/TR/NOTE-datetime |
23 | 23 | \*======================================================================*/ |
24 | 24 | |
25 | -function parse_w3cdtf ( $date_str ) { |
|
25 | +function parse_w3cdtf ( $date_str ) |
|
26 | +{ |
|
26 | 27 | |
27 | 28 | # regex to match wc3dtf |
28 | 29 | $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; |
@@ -37,8 +38,7 @@ discard block |
||
37 | 38 | $offset = 0; |
38 | 39 | if ( $match[10] == 'Z' ) { |
39 | 40 | # zulu time, aka GMT |
40 | - } |
|
41 | - else { |
|
41 | + } else { |
|
42 | 42 | list( $tz_mod, $tz_hour, $tz_min ) = |
43 | 43 | array( $match[8], $match[9], $match[10]); |
44 | 44 | |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | $epoch = $epoch + $offset; |
60 | 60 | return $epoch; |
61 | - } |
|
62 | - else { |
|
61 | + } else { |
|
63 | 62 | return -1; |
64 | 63 | } |
65 | 64 | } |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | * see: rss_fetch.inc for a simpler interface with integrated caching support |
32 | 32 | * |
33 | 33 | */ |
34 | -class MagpieRSS { |
|
34 | +class MagpieRSS |
|
35 | +{ |
|
35 | 36 | var $parser; |
36 | 37 | |
37 | 38 | var $current_item = array(); // item currently being parsed |
@@ -92,8 +93,8 @@ discard block |
||
92 | 93 | * |
93 | 94 | */ |
94 | 95 | function __construct($source, $output_encoding='ISO-8859-1', |
95 | - $input_encoding=null, $detect_encoding=true) |
|
96 | - { |
|
96 | + $input_encoding=null, $detect_encoding=true) |
|
97 | + { |
|
97 | 98 | # if PHP xml isn't compiled in, die |
98 | 99 | # |
99 | 100 | if (!function_exists('xml_parser_create')) { |
@@ -143,7 +144,8 @@ discard block |
||
143 | 144 | $this->normalize(); |
144 | 145 | } |
145 | 146 | |
146 | - function feed_start_element($p, $element, &$attrs) { |
|
147 | + function feed_start_element($p, $element, &$attrs) |
|
148 | + { |
|
147 | 149 | $el = $element = strtolower($element); |
148 | 150 | $attrs = array_change_key_case($attrs, CASE_LOWER); |
149 | 151 | |
@@ -163,12 +165,10 @@ discard block |
||
163 | 165 | if ( $el == 'rdf' ) { |
164 | 166 | $this->feed_type = RSS; |
165 | 167 | $this->feed_version = '1.0'; |
166 | - } |
|
167 | - elseif ( $el == 'rss' ) { |
|
168 | + } elseif ( $el == 'rss' ) { |
|
168 | 169 | $this->feed_type = RSS; |
169 | 170 | $this->feed_version = $attrs['version']; |
170 | - } |
|
171 | - elseif ( $el == 'feed' ) { |
|
171 | + } elseif ( $el == 'feed' ) { |
|
172 | 172 | $this->feed_type = ATOM; |
173 | 173 | $this->feed_version = $attrs['version']; |
174 | 174 | $this->inchannel = true; |
@@ -176,12 +176,9 @@ discard block |
||
176 | 176 | return; |
177 | 177 | } |
178 | 178 | |
179 | - if ( $el == 'channel' ) |
|
180 | - { |
|
179 | + if ( $el == 'channel' ) { |
|
181 | 180 | $this->inchannel = true; |
182 | - } |
|
183 | - elseif ($el == 'item' or $el == 'entry' ) |
|
184 | - { |
|
181 | + } elseif ($el == 'item' or $el == 'entry' ) { |
|
185 | 182 | $this->initem = true; |
186 | 183 | if ( isset($attrs['rdf:about']) ) { |
187 | 184 | $this->current_item['about'] = $attrs['rdf:about']; |
@@ -193,22 +190,17 @@ discard block |
||
193 | 190 | elseif ( |
194 | 191 | $this->feed_type == RSS and |
195 | 192 | $this->current_namespace == '' and |
196 | - $el == 'textinput' ) |
|
197 | - { |
|
193 | + $el == 'textinput' ) { |
|
198 | 194 | $this->intextinput = true; |
199 | - } |
|
200 | - |
|
201 | - elseif ( |
|
195 | + } elseif ( |
|
202 | 196 | $this->feed_type == RSS and |
203 | 197 | $this->current_namespace == '' and |
204 | - $el == 'image' ) |
|
205 | - { |
|
198 | + $el == 'image' ) { |
|
206 | 199 | $this->inimage = true; |
207 | 200 | } |
208 | 201 | |
209 | 202 | # handle atom content constructs |
210 | - elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
211 | - { |
|
203 | + elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { |
|
212 | 204 | // avoid clashing w/ RSS mod_content |
213 | 205 | if ($el == 'content' ) { |
214 | 206 | $el = 'atom_content'; |
@@ -220,8 +212,7 @@ discard block |
||
220 | 212 | } |
221 | 213 | |
222 | 214 | // if inside an Atom content construct (e.g. content or summary) field treat tags as text |
223 | - elseif ($this->feed_type == ATOM and $this->incontent ) |
|
224 | - { |
|
215 | + elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
225 | 216 | // if tags are inlined, then flatten |
226 | 217 | $attrs_str = join(' ', |
227 | 218 | array_map('map_attrs', |
@@ -237,13 +228,10 @@ discard block |
||
237 | 228 | // Magpie treats link elements of type rel='alternate' |
238 | 229 | // as being equivalent to RSS's simple link element. |
239 | 230 | // |
240 | - elseif ($this->feed_type == ATOM and $el == 'link' ) |
|
241 | - { |
|
242 | - if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) |
|
243 | - { |
|
231 | + elseif ($this->feed_type == ATOM and $el == 'link' ) { |
|
232 | + if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) { |
|
244 | 233 | $link_el = 'link'; |
245 | - } |
|
246 | - else { |
|
234 | + } else { |
|
247 | 235 | $link_el = 'link_' . $attrs['rel']; |
248 | 236 | } |
249 | 237 | |
@@ -257,63 +245,51 @@ discard block |
||
257 | 245 | |
258 | 246 | |
259 | 247 | |
260 | - function feed_cdata ($p, $text) { |
|
261 | - if ($this->feed_type == ATOM and $this->incontent) |
|
262 | - { |
|
248 | + function feed_cdata ($p, $text) |
|
249 | + { |
|
250 | + if ($this->feed_type == ATOM and $this->incontent) { |
|
263 | 251 | $this->append_content( $text ); |
264 | - } |
|
265 | - else { |
|
252 | + } else { |
|
266 | 253 | $current_el = join('_', array_reverse($this->stack)); |
267 | 254 | $this->append($current_el, $text); |
268 | 255 | } |
269 | 256 | } |
270 | 257 | |
271 | - function feed_end_element ($p, $el) { |
|
258 | + function feed_end_element ($p, $el) |
|
259 | + { |
|
272 | 260 | $el = strtolower($el); |
273 | 261 | |
274 | - if ( $el == 'item' or $el == 'entry' ) |
|
275 | - { |
|
262 | + if ( $el == 'item' or $el == 'entry' ) { |
|
276 | 263 | $this->items[] = $this->current_item; |
277 | 264 | $this->current_item = array(); |
278 | 265 | $this->initem = false; |
279 | - } |
|
280 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
281 | - { |
|
266 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) { |
|
282 | 267 | $this->intextinput = false; |
283 | - } |
|
284 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
285 | - { |
|
268 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) { |
|
286 | 269 | $this->inimage = false; |
287 | - } |
|
288 | - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
289 | - { |
|
270 | + } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { |
|
290 | 271 | $this->incontent = false; |
291 | - } |
|
292 | - elseif ($el == 'channel' or $el == 'feed' ) |
|
293 | - { |
|
272 | + } elseif ($el == 'channel' or $el == 'feed' ) { |
|
294 | 273 | $this->inchannel = false; |
295 | - } |
|
296 | - elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
274 | + } elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
297 | 275 | // balance tags properly |
298 | 276 | // note: i don't think this is actually neccessary |
299 | - if ( $this->stack[0] == $el ) |
|
300 | - { |
|
277 | + if ( $this->stack[0] == $el ) { |
|
301 | 278 | $this->append_content("</$el>"); |
302 | - } |
|
303 | - else { |
|
279 | + } else { |
|
304 | 280 | $this->append_content("<$el />"); |
305 | 281 | } |
306 | 282 | |
307 | 283 | array_shift( $this->stack ); |
308 | - } |
|
309 | - else { |
|
284 | + } else { |
|
310 | 285 | array_shift( $this->stack ); |
311 | 286 | } |
312 | 287 | |
313 | 288 | $this->current_namespace = false; |
314 | 289 | } |
315 | 290 | |
316 | - function concat (&$str1, $str2="") { |
|
291 | + function concat (&$str1, $str2="") |
|
292 | + { |
|
317 | 293 | if (!isset($str1) ) { |
318 | 294 | $str1=""; |
319 | 295 | } |
@@ -322,53 +298,46 @@ discard block |
||
322 | 298 | |
323 | 299 | |
324 | 300 | |
325 | - function append_content($text) { |
|
301 | + function append_content($text) |
|
302 | + { |
|
326 | 303 | if ( $this->initem ) { |
327 | 304 | $this->concat( $this->current_item[ $this->incontent ], $text ); |
328 | - } |
|
329 | - elseif ( $this->inchannel ) { |
|
305 | + } elseif ( $this->inchannel ) { |
|
330 | 306 | $this->concat( $this->channel[ $this->incontent ], $text ); |
331 | 307 | } |
332 | 308 | } |
333 | 309 | |
334 | 310 | // smart append - field and namespace aware |
335 | - function append($el, $text) { |
|
311 | + function append($el, $text) |
|
312 | + { |
|
336 | 313 | if (!$el) { |
337 | 314 | return; |
338 | 315 | } |
339 | - if ( $this->current_namespace ) |
|
340 | - { |
|
316 | + if ( $this->current_namespace ) { |
|
341 | 317 | if ( $this->initem ) { |
342 | 318 | $this->concat( |
343 | 319 | $this->current_item[ $this->current_namespace ][ $el ], $text); |
344 | - } |
|
345 | - elseif ($this->inchannel) { |
|
320 | + } elseif ($this->inchannel) { |
|
346 | 321 | $this->concat( |
347 | 322 | $this->channel[ $this->current_namespace][ $el ], $text ); |
348 | - } |
|
349 | - elseif ($this->intextinput) { |
|
323 | + } elseif ($this->intextinput) { |
|
350 | 324 | $this->concat( |
351 | 325 | $this->textinput[ $this->current_namespace][ $el ], $text ); |
352 | - } |
|
353 | - elseif ($this->inimage) { |
|
326 | + } elseif ($this->inimage) { |
|
354 | 327 | $this->concat( |
355 | 328 | $this->image[ $this->current_namespace ][ $el ], $text ); |
356 | 329 | } |
357 | - } |
|
358 | - else { |
|
330 | + } else { |
|
359 | 331 | if ( $this->initem ) { |
360 | 332 | $this->concat( |
361 | 333 | $this->current_item[ $el ], $text); |
362 | - } |
|
363 | - elseif ($this->intextinput) { |
|
334 | + } elseif ($this->intextinput) { |
|
364 | 335 | $this->concat( |
365 | 336 | $this->textinput[ $el ], $text ); |
366 | - } |
|
367 | - elseif ($this->inimage) { |
|
337 | + } elseif ($this->inimage) { |
|
368 | 338 | $this->concat( |
369 | 339 | $this->image[ $el ], $text ); |
370 | - } |
|
371 | - elseif ($this->inchannel) { |
|
340 | + } elseif ($this->inchannel) { |
|
372 | 341 | $this->concat( |
373 | 342 | $this->channel[ $el ], $text ); |
374 | 343 | } |
@@ -376,16 +345,19 @@ discard block |
||
376 | 345 | } |
377 | 346 | } |
378 | 347 | |
379 | - function normalize () { |
|
348 | + function normalize () |
|
349 | + { |
|
380 | 350 | // if atom populate rss fields |
381 | 351 | if ( $this->is_atom() ) { |
382 | 352 | $this->channel['description'] = $this->channel['tagline']; |
383 | 353 | for ( $i = 0; $i < count($this->items); $i++) { |
384 | 354 | $item = $this->items[$i]; |
385 | - if ( isset($item['summary']) ) |
|
386 | - $item['description'] = $item['summary']; |
|
387 | - if ( isset($item['atom_content'])) |
|
388 | - $item['content']['encoded'] = $item['atom_content']; |
|
355 | + if ( isset($item['summary']) ) { |
|
356 | + $item['description'] = $item['summary']; |
|
357 | + } |
|
358 | + if ( isset($item['atom_content'])) { |
|
359 | + $item['content']['encoded'] = $item['atom_content']; |
|
360 | + } |
|
389 | 361 | |
390 | 362 | $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified']; |
391 | 363 | if ( $atom_date ) { |
@@ -397,23 +369,23 @@ discard block |
||
397 | 369 | |
398 | 370 | $this->items[$i] = $item; |
399 | 371 | } |
400 | - } |
|
401 | - elseif ( $this->is_rss() ) { |
|
372 | + } elseif ( $this->is_rss() ) { |
|
402 | 373 | $this->channel['tagline'] = $this->channel['description']; |
403 | 374 | for ( $i = 0; $i < count($this->items); $i++) { |
404 | 375 | $item = $this->items[$i]; |
405 | - if ( isset($item['description'])) |
|
406 | - $item['summary'] = $item['description']; |
|
407 | - if ( isset($item['content']['encoded'] ) ) |
|
408 | - $item['atom_content'] = $item['content']['encoded']; |
|
376 | + if ( isset($item['description'])) { |
|
377 | + $item['summary'] = $item['description']; |
|
378 | + } |
|
379 | + if ( isset($item['content']['encoded'] ) ) { |
|
380 | + $item['atom_content'] = $item['content']['encoded']; |
|
381 | + } |
|
409 | 382 | |
410 | 383 | if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) { |
411 | 384 | $epoch = @parse_w3cdtf($item['dc']['date']); |
412 | 385 | if ($epoch and $epoch > 0) { |
413 | 386 | $item['date_timestamp'] = $epoch; |
414 | 387 | } |
415 | - } |
|
416 | - elseif ( isset($item['pubdate']) ) { |
|
388 | + } elseif ( isset($item['pubdate']) ) { |
|
417 | 389 | $epoch = @strtotime($item['pubdate']); |
418 | 390 | if ($epoch > 0) { |
419 | 391 | $item['date_timestamp'] = $epoch; |
@@ -426,20 +398,20 @@ discard block |
||
426 | 398 | } |
427 | 399 | |
428 | 400 | |
429 | - function is_rss () { |
|
401 | + function is_rss () |
|
402 | + { |
|
430 | 403 | if ( $this->feed_type == RSS ) { |
431 | 404 | return $this->feed_version; |
432 | - } |
|
433 | - else { |
|
405 | + } else { |
|
434 | 406 | return false; |
435 | 407 | } |
436 | 408 | } |
437 | 409 | |
438 | - function is_atom() { |
|
410 | + function is_atom() |
|
411 | + { |
|
439 | 412 | if ( $this->feed_type == ATOM ) { |
440 | 413 | return $this->feed_version; |
441 | - } |
|
442 | - else { |
|
414 | + } else { |
|
443 | 415 | return false; |
444 | 416 | } |
445 | 417 | } |
@@ -448,11 +420,11 @@ discard block |
||
448 | 420 | * return XML parser, and possibly re-encoded source |
449 | 421 | * |
450 | 422 | */ |
451 | - function create_parser($source, $out_enc, $in_enc, $detect) { |
|
423 | + function create_parser($source, $out_enc, $in_enc, $detect) |
|
424 | + { |
|
452 | 425 | if ( substr(phpversion(),0,1) == 5) { |
453 | 426 | $parser = $this->php5_create_parser($in_enc, $detect); |
454 | - } |
|
455 | - else { |
|
427 | + } else { |
|
456 | 428 | list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); |
457 | 429 | } |
458 | 430 | if ($out_enc) { |
@@ -472,12 +444,12 @@ discard block |
||
472 | 444 | * All hail libxml2! |
473 | 445 | * |
474 | 446 | */ |
475 | - function php5_create_parser($in_enc, $detect) { |
|
447 | + function php5_create_parser($in_enc, $detect) |
|
448 | + { |
|
476 | 449 | // by default php5 does a fine job of detecting input encodings |
477 | 450 | if(!$detect && $in_enc) { |
478 | 451 | return xml_parser_create($in_enc); |
479 | - } |
|
480 | - else { |
|
452 | + } else { |
|
481 | 453 | return xml_parser_create(''); |
482 | 454 | } |
483 | 455 | } |
@@ -497,7 +469,8 @@ discard block |
||
497 | 469 | * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
498 | 470 | * |
499 | 471 | */ |
500 | - function php4_create_parser($source, $in_enc, $detect) { |
|
472 | + function php4_create_parser($source, $in_enc, $detect) |
|
473 | + { |
|
501 | 474 | if ( !$detect ) { |
502 | 475 | return array(xml_parser_create($in_enc), $source); |
503 | 476 | } |
@@ -506,8 +479,7 @@ discard block |
||
506 | 479 | if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
507 | 480 | $in_enc = strtoupper($m[1]); |
508 | 481 | $this->source_encoding = $in_enc; |
509 | - } |
|
510 | - else { |
|
482 | + } else { |
|
511 | 483 | $in_enc = 'UTF-8'; |
512 | 484 | } |
513 | 485 | } |
@@ -522,7 +494,7 @@ discard block |
||
522 | 494 | // cast the XML to a known encoding |
523 | 495 | // @see http://php.net/iconv |
524 | 496 | |
525 | - if (function_exists('iconv')) { |
|
497 | + if (function_exists('iconv')) { |
|
526 | 498 | $encoded_source = iconv($in_enc,'UTF-8', $source); |
527 | 499 | if ($encoded_source) { |
528 | 500 | return array(xml_parser_create('UTF-8'), $encoded_source); |
@@ -546,25 +518,25 @@ discard block |
||
546 | 518 | return array(xml_parser_create(), $source); |
547 | 519 | } |
548 | 520 | |
549 | - function known_encoding($enc) { |
|
521 | + function known_encoding($enc) |
|
522 | + { |
|
550 | 523 | $enc = strtoupper($enc); |
551 | 524 | if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) { |
552 | 525 | return $enc; |
553 | - } |
|
554 | - else { |
|
526 | + } else { |
|
555 | 527 | return false; |
556 | 528 | } |
557 | 529 | } |
558 | 530 | |
559 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
531 | + function error ($errormsg, $lvl=E_USER_WARNING) |
|
532 | + { |
|
560 | 533 | // append PHP's error message if track_errors enabled |
561 | - if ( isset($php_errormsg) ) { |
|
534 | + if ( isset($php_errormsg) ) { |
|
562 | 535 | $errormsg .= " ($php_errormsg)"; |
563 | 536 | } |
564 | 537 | if ( MAGPIE_DEBUG ) { |
565 | 538 | trigger_error( $errormsg, $lvl); |
566 | - } |
|
567 | - else { |
|
539 | + } else { |
|
568 | 540 | error_log( $errormsg, 0); |
569 | 541 | } |
570 | 542 | |
@@ -579,7 +551,8 @@ discard block |
||
579 | 551 | |
580 | 552 | } // end class RSS |
581 | 553 | |
582 | -function map_attrs($k, $v) { |
|
554 | +function map_attrs($k, $v) |
|
555 | +{ |
|
583 | 556 | return "$k=\"$v\""; |
584 | 557 | } |
585 | 558 | |
@@ -591,9 +564,13 @@ discard block |
||
591 | 564 | define("CASE_LOWER",0); |
592 | 565 | |
593 | 566 | |
594 | - function array_change_key_case($array,$case=CASE_LOWER) { |
|
595 | - if ($case=CASE_LOWER) $cmd=strtolower; |
|
596 | - elseif ($case=CASE_UPPER) $cmd=strtoupper; |
|
567 | + function array_change_key_case($array,$case=CASE_LOWER) |
|
568 | + { |
|
569 | + if ($case=CASE_LOWER) { |
|
570 | + $cmd=strtolower; |
|
571 | + } elseif ($case=CASE_UPPER) { |
|
572 | + $cmd=strtoupper; |
|
573 | + } |
|
597 | 574 | foreach($array as $key=>$value) { |
598 | 575 | $output[$cmd($key)]=$value; |
599 | 576 | } |
@@ -89,7 +89,8 @@ discard block |
||
89 | 89 | |
90 | 90 | $MAGPIE_ERROR = ""; |
91 | 91 | |
92 | -function fetch_rss ($url) { |
|
92 | +function fetch_rss ($url) |
|
93 | +{ |
|
93 | 94 | // initialize constants |
94 | 95 | init(); |
95 | 96 | |
@@ -104,8 +105,7 @@ discard block |
||
104 | 105 | $resp = _fetch_remote_file( $url ); |
105 | 106 | if ( is_success( $resp->status ) ) { |
106 | 107 | return _response_to_rss( $resp ); |
107 | - } |
|
108 | - else { |
|
108 | + } else { |
|
109 | 109 | error("Failed to fetch $url and cache is off"); |
110 | 110 | return false; |
111 | 111 | } |
@@ -174,8 +174,7 @@ discard block |
||
174 | 174 | // reset cache on 304 (at minutillo insistent prodding) |
175 | 175 | $cache->set($cache_key, $rss); |
176 | 176 | return $rss; |
177 | - } |
|
178 | - elseif ( is_success( $resp->status ) ) { |
|
177 | + } elseif ( is_success( $resp->status ) ) { |
|
179 | 178 | $rss = _response_to_rss( $resp ); |
180 | 179 | if ( $rss ) { |
181 | 180 | if (MAGPIE_DEBUG > 1) { |
@@ -185,24 +184,20 @@ discard block |
||
185 | 184 | $cache->set( $cache_key, $rss ); |
186 | 185 | return $rss; |
187 | 186 | } |
188 | - } |
|
189 | - else { |
|
187 | + } else { |
|
190 | 188 | $errormsg = "Failed to fetch $url "; |
191 | 189 | if ( $resp->status == '-100' ) { |
192 | 190 | $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; |
193 | - } |
|
194 | - elseif ( $resp->error ) { |
|
191 | + } elseif ( $resp->error ) { |
|
195 | 192 | # compensate for Snoopy's annoying habbit to tacking |
196 | 193 | # on '\n' |
197 | 194 | $http_error = substr($resp->error, 0, -2); |
198 | 195 | $errormsg .= "(HTTP Error: $http_error)"; |
199 | - } |
|
200 | - else { |
|
196 | + } else { |
|
201 | 197 | $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
202 | 198 | } |
203 | 199 | } |
204 | - } |
|
205 | - else { |
|
200 | + } else { |
|
206 | 201 | $errormsg = "Unable to retrieve RSS file for unknown reasons."; |
207 | 202 | } |
208 | 203 | |
@@ -229,11 +224,12 @@ discard block |
||
229 | 224 | Purpose: set MAGPIE_ERROR, and trigger error |
230 | 225 | \*=======================================================================*/ |
231 | 226 | |
232 | -function error ($errormsg, $lvl=E_USER_WARNING) { |
|
227 | +function error ($errormsg, $lvl=E_USER_WARNING) |
|
228 | +{ |
|
233 | 229 | global $MAGPIE_ERROR; |
234 | 230 | |
235 | 231 | // append PHP's error message if track_errors enabled |
236 | - if ( isset($php_errormsg) ) { |
|
232 | + if ( isset($php_errormsg) ) { |
|
237 | 233 | $errormsg .= " ($php_errormsg)"; |
238 | 234 | } |
239 | 235 | if ( $errormsg ) { |
@@ -243,7 +239,8 @@ discard block |
||
243 | 239 | } |
244 | 240 | } |
245 | 241 | |
246 | -function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
242 | +function debug ($debugmsg, $lvl=E_USER_NOTICE) |
|
243 | +{ |
|
247 | 244 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
248 | 245 | } |
249 | 246 | |
@@ -251,10 +248,11 @@ discard block |
||
251 | 248 | Function: magpie_error |
252 | 249 | Purpose: accessor for the magpie error variable |
253 | 250 | \*=======================================================================*/ |
254 | -function magpie_error ($errormsg="") { |
|
251 | +function magpie_error ($errormsg="") |
|
252 | +{ |
|
255 | 253 | global $MAGPIE_ERROR; |
256 | 254 | |
257 | - if ( isset($errormsg) and $errormsg ) { |
|
255 | + if ( isset($errormsg) and $errormsg ) { |
|
258 | 256 | $MAGPIE_ERROR = $errormsg; |
259 | 257 | } |
260 | 258 | |
@@ -268,7 +266,8 @@ discard block |
||
268 | 266 | headers to send along with the request (optional) |
269 | 267 | Output: an HTTP response object (see Snoopy.class.inc) |
270 | 268 | \*=======================================================================*/ |
271 | -function _fetch_remote_file ($url, $headers = "" ) { |
|
269 | +function _fetch_remote_file ($url, $headers = "" ) |
|
270 | +{ |
|
272 | 271 | // Snoopy is an HTTP client in PHP |
273 | 272 | $client = new Snoopy(); |
274 | 273 | $client->agent = MAGPIE_USER_AGENT; |
@@ -289,7 +288,8 @@ discard block |
||
289 | 288 | Input: an HTTP response object (see Snoopy) |
290 | 289 | Output: parsed RSS object (see rss_parse) |
291 | 290 | \*=======================================================================*/ |
292 | -function _response_to_rss ($resp) { |
|
291 | +function _response_to_rss ($resp) |
|
292 | +{ |
|
293 | 293 | $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
294 | 294 | |
295 | 295 | // if RSS parsed successfully |
@@ -300,8 +300,7 @@ discard block |
||
300 | 300 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
301 | 301 | if (strpos($h, ": ")) { |
302 | 302 | list($field, $val) = explode(": ", $h, 2); |
303 | - } |
|
304 | - else { |
|
303 | + } else { |
|
305 | 304 | $field = $h; |
306 | 305 | $val = ""; |
307 | 306 | } |
@@ -334,11 +333,11 @@ discard block |
||
334 | 333 | Purpose: setup constants with default values |
335 | 334 | check for user overrides |
336 | 335 | \*=======================================================================*/ |
337 | -function init () { |
|
336 | +function init () |
|
337 | +{ |
|
338 | 338 | if ( defined('MAGPIE_INITALIZED') ) { |
339 | 339 | return; |
340 | - } |
|
341 | - else { |
|
340 | + } else { |
|
342 | 341 | define('MAGPIE_INITALIZED', true); |
343 | 342 | } |
344 | 343 | |
@@ -360,7 +359,9 @@ discard block |
||
360 | 359 | |
361 | 360 | if ( !defined('MAGPIE_OUTPUT_ENCODING') ) { |
362 | 361 | global $modx_manager_charset; |
363 | - if(empty($modx_manager_charset)) $modx_manager_charset = 'ISO-8859-1'; |
|
362 | + if(empty($modx_manager_charset)) { |
|
363 | + $modx_manager_charset = 'ISO-8859-1'; |
|
364 | + } |
|
364 | 365 | define('MAGPIE_OUTPUT_ENCODING', $modx_manager_charset); |
365 | 366 | } |
366 | 367 | |
@@ -381,8 +382,7 @@ discard block |
||
381 | 382 | |
382 | 383 | if ( MAGPIE_CACHE_ON ) { |
383 | 384 | $ua = $ua . ')'; |
384 | - } |
|
385 | - else { |
|
385 | + } else { |
|
386 | 386 | $ua = $ua . '; No cache)'; |
387 | 387 | } |
388 | 388 | |
@@ -417,7 +417,8 @@ discard block |
||
417 | 417 | Function: is_info |
418 | 418 | Purpose: return true if Informational status code |
419 | 419 | \*=======================================================================*/ |
420 | -function is_info ($sc) { |
|
420 | +function is_info ($sc) |
|
421 | +{ |
|
421 | 422 | return $sc >= 100 && $sc < 200; |
422 | 423 | } |
423 | 424 | |
@@ -425,7 +426,8 @@ discard block |
||
425 | 426 | Function: is_success |
426 | 427 | Purpose: return true if Successful status code |
427 | 428 | \*=======================================================================*/ |
428 | -function is_success ($sc) { |
|
429 | +function is_success ($sc) |
|
430 | +{ |
|
429 | 431 | return $sc >= 200 && $sc < 300; |
430 | 432 | } |
431 | 433 | |
@@ -433,7 +435,8 @@ discard block |
||
433 | 435 | Function: is_redirect |
434 | 436 | Purpose: return true if Redirection status code |
435 | 437 | \*=======================================================================*/ |
436 | -function is_redirect ($sc) { |
|
438 | +function is_redirect ($sc) |
|
439 | +{ |
|
437 | 440 | return $sc >= 300 && $sc < 400; |
438 | 441 | } |
439 | 442 | |
@@ -441,7 +444,8 @@ discard block |
||
441 | 444 | Function: is_error |
442 | 445 | Purpose: return true if Error status code |
443 | 446 | \*=======================================================================*/ |
444 | -function is_error ($sc) { |
|
447 | +function is_error ($sc) |
|
448 | +{ |
|
445 | 449 | return $sc >= 400 && $sc < 600; |
446 | 450 | } |
447 | 451 | |
@@ -449,7 +453,8 @@ discard block |
||
449 | 453 | Function: is_client_error |
450 | 454 | Purpose: return true if Error status code, and its a client error |
451 | 455 | \*=======================================================================*/ |
452 | -function is_client_error ($sc) { |
|
456 | +function is_client_error ($sc) |
|
457 | +{ |
|
453 | 458 | return $sc >= 400 && $sc < 500; |
454 | 459 | } |
455 | 460 | |
@@ -457,7 +462,8 @@ discard block |
||
457 | 462 | Function: is_client_error |
458 | 463 | Purpose: return true if Error status code, and its a server error |
459 | 464 | \*=======================================================================*/ |
460 | -function is_server_error ($sc) { |
|
465 | +function is_server_error ($sc) |
|
466 | +{ |
|
461 | 467 | return $sc >= 500 && $sc < 600; |
462 | 468 | } |
463 | 469 | ?> |
@@ -121,14 +121,18 @@ discard block |
||
121 | 121 | { |
122 | 122 | |
123 | 123 | $URI_PARTS = parse_url($URI); |
124 | - if (!empty($URI_PARTS["user"])) |
|
125 | - $this->user = $URI_PARTS["user"]; |
|
126 | - if (!empty($URI_PARTS["pass"])) |
|
127 | - $this->pass = $URI_PARTS["pass"]; |
|
128 | - if (empty($URI_PARTS["query"])) |
|
129 | - $URI_PARTS["query"] = ''; |
|
130 | - if (empty($URI_PARTS["path"])) |
|
131 | - $URI_PARTS["path"] = ''; |
|
124 | + if (!empty($URI_PARTS["user"])) { |
|
125 | + $this->user = $URI_PARTS["user"]; |
|
126 | + } |
|
127 | + if (!empty($URI_PARTS["pass"])) { |
|
128 | + $this->pass = $URI_PARTS["pass"]; |
|
129 | + } |
|
130 | + if (empty($URI_PARTS["query"])) { |
|
131 | + $URI_PARTS["query"] = ''; |
|
132 | + } |
|
133 | + if (empty($URI_PARTS["path"])) { |
|
134 | + $URI_PARTS["path"] = ''; |
|
135 | + } |
|
132 | 136 | |
133 | 137 | $fp = null; |
134 | 138 | |
@@ -142,8 +146,9 @@ discard block |
||
142 | 146 | case "http": |
143 | 147 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
144 | 148 | $this->host = $URI_PARTS["host"]; |
145 | - if (!empty($URI_PARTS["port"])) |
|
146 | - $this->port = $URI_PARTS["port"]; |
|
149 | + if (!empty($URI_PARTS["port"])) { |
|
150 | + $this->port = $URI_PARTS["port"]; |
|
151 | + } |
|
147 | 152 | if ($this->_connect($fp)) { |
148 | 153 | if ($this->_isproxy) { |
149 | 154 | // using proxy, send entire URI |
@@ -177,8 +182,9 @@ discard block |
||
177 | 182 | if ($this->_framedepth < $this->maxframes) { |
178 | 183 | $this->fetch($frameurl); |
179 | 184 | $this->_framedepth++; |
180 | - } else |
|
181 | - break; |
|
185 | + } else { |
|
186 | + break; |
|
187 | + } |
|
182 | 188 | } |
183 | 189 | } |
184 | 190 | } else { |
@@ -213,14 +219,18 @@ discard block |
||
213 | 219 | $postdata = $this->_prepare_post_body($formvars, $formfiles); |
214 | 220 | |
215 | 221 | $URI_PARTS = parse_url($URI); |
216 | - if (!empty($URI_PARTS["user"])) |
|
217 | - $this->user = $URI_PARTS["user"]; |
|
218 | - if (!empty($URI_PARTS["pass"])) |
|
219 | - $this->pass = $URI_PARTS["pass"]; |
|
220 | - if (empty($URI_PARTS["query"])) |
|
221 | - $URI_PARTS["query"] = ''; |
|
222 | - if (empty($URI_PARTS["path"])) |
|
223 | - $URI_PARTS["path"] = ''; |
|
222 | + if (!empty($URI_PARTS["user"])) { |
|
223 | + $this->user = $URI_PARTS["user"]; |
|
224 | + } |
|
225 | + if (!empty($URI_PARTS["pass"])) { |
|
226 | + $this->pass = $URI_PARTS["pass"]; |
|
227 | + } |
|
228 | + if (empty($URI_PARTS["query"])) { |
|
229 | + $URI_PARTS["query"] = ''; |
|
230 | + } |
|
231 | + if (empty($URI_PARTS["path"])) { |
|
232 | + $URI_PARTS["path"] = ''; |
|
233 | + } |
|
224 | 234 | |
225 | 235 | switch (strtolower($URI_PARTS["scheme"])) { |
226 | 236 | case "https": |
@@ -232,8 +242,9 @@ discard block |
||
232 | 242 | case "http": |
233 | 243 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
234 | 244 | $this->host = $URI_PARTS["host"]; |
235 | - if (!empty($URI_PARTS["port"])) |
|
236 | - $this->port = $URI_PARTS["port"]; |
|
245 | + if (!empty($URI_PARTS["port"])) { |
|
246 | + $this->port = $URI_PARTS["port"]; |
|
247 | + } |
|
237 | 248 | if ($this->_connect($fp)) { |
238 | 249 | if ($this->_isproxy) { |
239 | 250 | // using proxy, send entire URI |
@@ -249,18 +260,22 @@ discard block |
||
249 | 260 | if ($this->_redirectaddr) { |
250 | 261 | /* url was redirected, check if we've hit the max depth */ |
251 | 262 | if ($this->maxredirs > $this->_redirectdepth) { |
252 | - if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) |
|
253 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
263 | + if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) { |
|
264 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
265 | + } |
|
254 | 266 | |
255 | 267 | // only follow redirect if it's on this site, or offsiteok is true |
256 | 268 | if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
257 | 269 | /* follow the redirect */ |
258 | 270 | $this->_redirectdepth++; |
259 | 271 | $this->lastredirectaddr = $this->_redirectaddr; |
260 | - if (strpos($this->_redirectaddr, "?") > 0) |
|
261 | - $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get |
|
262 | - else |
|
263 | - $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
272 | + if (strpos($this->_redirectaddr, "?") > 0) { |
|
273 | + $this->fetch($this->_redirectaddr); |
|
274 | + } |
|
275 | + // the redirect has changed the request method from post to get |
|
276 | + else { |
|
277 | + $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
278 | + } |
|
264 | 279 | } |
265 | 280 | } |
266 | 281 | } |
@@ -273,8 +288,9 @@ discard block |
||
273 | 288 | if ($this->_framedepth < $this->maxframes) { |
274 | 289 | $this->fetch($frameurl); |
275 | 290 | $this->_framedepth++; |
276 | - } else |
|
277 | - break; |
|
291 | + } else { |
|
292 | + break; |
|
293 | + } |
|
278 | 294 | } |
279 | 295 | } |
280 | 296 | |
@@ -302,19 +318,24 @@ discard block |
||
302 | 318 | function fetchlinks($URI) |
303 | 319 | { |
304 | 320 | if ($this->fetch($URI) !== false) { |
305 | - if ($this->lastredirectaddr) |
|
306 | - $URI = $this->lastredirectaddr; |
|
321 | + if ($this->lastredirectaddr) { |
|
322 | + $URI = $this->lastredirectaddr; |
|
323 | + } |
|
307 | 324 | if (is_array($this->results)) { |
308 | - for ($x = 0; $x < count($this->results); $x++) |
|
309 | - $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
310 | - } else |
|
311 | - $this->results = $this->_striplinks($this->results); |
|
325 | + for ($x = 0; $x < count($this->results); $x++) { |
|
326 | + $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
327 | + } |
|
328 | + } else { |
|
329 | + $this->results = $this->_striplinks($this->results); |
|
330 | + } |
|
312 | 331 | |
313 | - if ($this->expandlinks) |
|
314 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
332 | + if ($this->expandlinks) { |
|
333 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
334 | + } |
|
315 | 335 | return $this; |
316 | - } else |
|
317 | - return false; |
|
336 | + } else { |
|
337 | + return false; |
|
338 | + } |
|
318 | 339 | } |
319 | 340 | |
320 | 341 | /*======================================================================*\ |
@@ -330,14 +351,17 @@ discard block |
||
330 | 351 | if ($this->fetch($URI) !== false) { |
331 | 352 | |
332 | 353 | if (is_array($this->results)) { |
333 | - for ($x = 0; $x < count($this->results); $x++) |
|
334 | - $this->results[$x] = $this->_stripform($this->results[$x]); |
|
335 | - } else |
|
336 | - $this->results = $this->_stripform($this->results); |
|
354 | + for ($x = 0; $x < count($this->results); $x++) { |
|
355 | + $this->results[$x] = $this->_stripform($this->results[$x]); |
|
356 | + } |
|
357 | + } else { |
|
358 | + $this->results = $this->_stripform($this->results); |
|
359 | + } |
|
337 | 360 | |
338 | 361 | return $this; |
339 | - } else |
|
340 | - return false; |
|
362 | + } else { |
|
363 | + return false; |
|
364 | + } |
|
341 | 365 | } |
342 | 366 | |
343 | 367 | |
@@ -352,13 +376,16 @@ discard block |
||
352 | 376 | { |
353 | 377 | if ($this->fetch($URI) !== false) { |
354 | 378 | if (is_array($this->results)) { |
355 | - for ($x = 0; $x < count($this->results); $x++) |
|
356 | - $this->results[$x] = $this->_striptext($this->results[$x]); |
|
357 | - } else |
|
358 | - $this->results = $this->_striptext($this->results); |
|
379 | + for ($x = 0; $x < count($this->results); $x++) { |
|
380 | + $this->results[$x] = $this->_striptext($this->results[$x]); |
|
381 | + } |
|
382 | + } else { |
|
383 | + $this->results = $this->_striptext($this->results); |
|
384 | + } |
|
359 | 385 | return $this; |
360 | - } else |
|
361 | - return false; |
|
386 | + } else { |
|
387 | + return false; |
|
388 | + } |
|
362 | 389 | } |
363 | 390 | |
364 | 391 | /*======================================================================*\ |
@@ -371,22 +398,26 @@ discard block |
||
371 | 398 | function submitlinks($URI, $formvars = "", $formfiles = "") |
372 | 399 | { |
373 | 400 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
374 | - if ($this->lastredirectaddr) |
|
375 | - $URI = $this->lastredirectaddr; |
|
401 | + if ($this->lastredirectaddr) { |
|
402 | + $URI = $this->lastredirectaddr; |
|
403 | + } |
|
376 | 404 | if (is_array($this->results)) { |
377 | 405 | for ($x = 0; $x < count($this->results); $x++) { |
378 | 406 | $this->results[$x] = $this->_striplinks($this->results[$x]); |
379 | - if ($this->expandlinks) |
|
380 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
407 | + if ($this->expandlinks) { |
|
408 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
409 | + } |
|
381 | 410 | } |
382 | 411 | } else { |
383 | 412 | $this->results = $this->_striplinks($this->results); |
384 | - if ($this->expandlinks) |
|
385 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
413 | + if ($this->expandlinks) { |
|
414 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
415 | + } |
|
386 | 416 | } |
387 | 417 | return $this; |
388 | - } else |
|
389 | - return false; |
|
418 | + } else { |
|
419 | + return false; |
|
420 | + } |
|
390 | 421 | } |
391 | 422 | |
392 | 423 | /*======================================================================*\ |
@@ -399,22 +430,26 @@ discard block |
||
399 | 430 | function submittext($URI, $formvars = "", $formfiles = "") |
400 | 431 | { |
401 | 432 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
402 | - if ($this->lastredirectaddr) |
|
403 | - $URI = $this->lastredirectaddr; |
|
433 | + if ($this->lastredirectaddr) { |
|
434 | + $URI = $this->lastredirectaddr; |
|
435 | + } |
|
404 | 436 | if (is_array($this->results)) { |
405 | 437 | for ($x = 0; $x < count($this->results); $x++) { |
406 | 438 | $this->results[$x] = $this->_striptext($this->results[$x]); |
407 | - if ($this->expandlinks) |
|
408 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
439 | + if ($this->expandlinks) { |
|
440 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
441 | + } |
|
409 | 442 | } |
410 | 443 | } else { |
411 | 444 | $this->results = $this->_striptext($this->results); |
412 | - if ($this->expandlinks) |
|
413 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
445 | + if ($this->expandlinks) { |
|
446 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
447 | + } |
|
414 | 448 | } |
415 | 449 | return $this; |
416 | - } else |
|
417 | - return false; |
|
450 | + } else { |
|
451 | + return false; |
|
452 | + } |
|
418 | 453 | } |
419 | 454 | |
420 | 455 | |
@@ -468,13 +503,15 @@ discard block |
||
468 | 503 | // catenate the non-empty matches from the conditional subpattern |
469 | 504 | |
470 | 505 | while (list($key, $val) = each($links[2])) { |
471 | - if (!empty($val)) |
|
472 | - $match[] = $val; |
|
506 | + if (!empty($val)) { |
|
507 | + $match[] = $val; |
|
508 | + } |
|
473 | 509 | } |
474 | 510 | |
475 | 511 | while (list($key, $val) = each($links[3])) { |
476 | - if (!empty($val)) |
|
477 | - $match[] = $val; |
|
512 | + if (!empty($val)) { |
|
513 | + $match[] = $val; |
|
514 | + } |
|
478 | 515 | } |
479 | 516 | |
480 | 517 | // return the links |
@@ -619,23 +656,28 @@ discard block |
||
619 | 656 | function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "") |
620 | 657 | { |
621 | 658 | $cookie_headers = ''; |
622 | - if ($this->passcookies && $this->_redirectaddr) |
|
623 | - $this->setcookies(); |
|
659 | + if ($this->passcookies && $this->_redirectaddr) { |
|
660 | + $this->setcookies(); |
|
661 | + } |
|
624 | 662 | |
625 | 663 | $URI_PARTS = parse_url($URI); |
626 | - if (empty($url)) |
|
627 | - $url = "/"; |
|
664 | + if (empty($url)) { |
|
665 | + $url = "/"; |
|
666 | + } |
|
628 | 667 | $headers = $http_method . " " . $url . " " . $this->_httpversion . "\r\n"; |
629 | 668 | if (!empty($this->host) && !isset($this->rawheaders['Host'])) { |
630 | 669 | $headers .= "Host: " . $this->host; |
631 | - if (!empty($this->port) && $this->port != '80') |
|
632 | - $headers .= ":" . $this->port; |
|
670 | + if (!empty($this->port) && $this->port != '80') { |
|
671 | + $headers .= ":" . $this->port; |
|
672 | + } |
|
633 | 673 | $headers .= "\r\n"; |
634 | 674 | } |
635 | - if (!empty($this->agent)) |
|
636 | - $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
637 | - if (!empty($this->accept)) |
|
638 | - $headers .= "Accept: " . $this->accept . "\r\n"; |
|
675 | + if (!empty($this->agent)) { |
|
676 | + $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
677 | + } |
|
678 | + if (!empty($this->accept)) { |
|
679 | + $headers .= "Accept: " . $this->accept . "\r\n"; |
|
680 | + } |
|
639 | 681 | if ($this->use_gzip) { |
640 | 682 | // make sure PHP was built with --with-zlib |
641 | 683 | // and we can handle gzipp'ed data |
@@ -648,11 +690,13 @@ discard block |
||
648 | 690 | E_USER_NOTICE); |
649 | 691 | } |
650 | 692 | } |
651 | - if (!empty($this->referer)) |
|
652 | - $headers .= "Referer: " . $this->referer . "\r\n"; |
|
693 | + if (!empty($this->referer)) { |
|
694 | + $headers .= "Referer: " . $this->referer . "\r\n"; |
|
695 | + } |
|
653 | 696 | if (!empty($this->cookies)) { |
654 | - if (!is_array($this->cookies)) |
|
655 | - $this->cookies = (array)$this->cookies; |
|
697 | + if (!is_array($this->cookies)) { |
|
698 | + $this->cookies = (array)$this->cookies; |
|
699 | + } |
|
656 | 700 | |
657 | 701 | reset($this->cookies); |
658 | 702 | if (count($this->cookies) > 0) { |
@@ -664,32 +708,39 @@ discard block |
||
664 | 708 | } |
665 | 709 | } |
666 | 710 | if (!empty($this->rawheaders)) { |
667 | - if (!is_array($this->rawheaders)) |
|
668 | - $this->rawheaders = (array)$this->rawheaders; |
|
669 | - while (list($headerKey, $headerVal) = each($this->rawheaders)) |
|
670 | - $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
711 | + if (!is_array($this->rawheaders)) { |
|
712 | + $this->rawheaders = (array)$this->rawheaders; |
|
713 | + } |
|
714 | + while (list($headerKey, $headerVal) = each($this->rawheaders)) { |
|
715 | + $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
716 | + } |
|
671 | 717 | } |
672 | 718 | if (!empty($content_type)) { |
673 | 719 | $headers .= "Content-type: $content_type"; |
674 | - if ($content_type == "multipart/form-data") |
|
675 | - $headers .= "; boundary=" . $this->_mime_boundary; |
|
720 | + if ($content_type == "multipart/form-data") { |
|
721 | + $headers .= "; boundary=" . $this->_mime_boundary; |
|
722 | + } |
|
676 | 723 | $headers .= "\r\n"; |
677 | 724 | } |
678 | - if (!empty($body)) |
|
679 | - $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
680 | - if (!empty($this->user) || !empty($this->pass)) |
|
681 | - $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
725 | + if (!empty($body)) { |
|
726 | + $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
727 | + } |
|
728 | + if (!empty($this->user) || !empty($this->pass)) { |
|
729 | + $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
730 | + } |
|
682 | 731 | |
683 | 732 | //add proxy auth headers |
684 | - if (!empty($this->proxy_user)) |
|
685 | - $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
733 | + if (!empty($this->proxy_user)) { |
|
734 | + $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
735 | + } |
|
686 | 736 | |
687 | 737 | |
688 | 738 | $headers .= "\r\n"; |
689 | 739 | |
690 | 740 | // set the read timeout if needed |
691 | - if ($this->read_timeout > 0) |
|
692 | - socket_set_timeout($fp, $this->read_timeout); |
|
741 | + if ($this->read_timeout > 0) { |
|
742 | + socket_set_timeout($fp, $this->read_timeout); |
|
743 | + } |
|
693 | 744 | $this->timed_out = false; |
694 | 745 | |
695 | 746 | fwrite($fp, $headers . $body, strlen($headers . $body)); |
@@ -706,8 +757,9 @@ discard block |
||
706 | 757 | return false; |
707 | 758 | } |
708 | 759 | |
709 | - if ($currentHeader == "\r\n") |
|
710 | - break; |
|
760 | + if ($currentHeader == "\r\n") { |
|
761 | + break; |
|
762 | + } |
|
711 | 763 | |
712 | 764 | // if a header begins with Location: or URI:, set the redirect |
713 | 765 | if (preg_match("/^(Location:|URI:)/i", $currentHeader)) { |
@@ -718,12 +770,14 @@ discard block |
||
718 | 770 | // no host in the path, so prepend |
719 | 771 | $this->_redirectaddr = $URI_PARTS["scheme"] . "://" . $this->host . ":" . $this->port; |
720 | 772 | // eliminate double slash |
721 | - if (!preg_match("|^/|", $matches[2])) |
|
722 | - $this->_redirectaddr .= "/" . $matches[2]; |
|
723 | - else |
|
724 | - $this->_redirectaddr .= $matches[2]; |
|
725 | - } else |
|
726 | - $this->_redirectaddr = $matches[2]; |
|
773 | + if (!preg_match("|^/|", $matches[2])) { |
|
774 | + $this->_redirectaddr .= "/" . $matches[2]; |
|
775 | + } else { |
|
776 | + $this->_redirectaddr .= $matches[2]; |
|
777 | + } |
|
778 | + } else { |
|
779 | + $this->_redirectaddr = $matches[2]; |
|
780 | + } |
|
727 | 781 | } |
728 | 782 | |
729 | 783 | if (preg_match("|^HTTP/|", $currentHeader)) { |
@@ -770,14 +824,17 @@ discard block |
||
770 | 824 | // have we hit our frame depth and is there frame src to fetch? |
771 | 825 | if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) { |
772 | 826 | $this->results[] = $results; |
773 | - for ($x = 0; $x < count($match[1]); $x++) |
|
774 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
827 | + for ($x = 0; $x < count($match[1]); $x++) { |
|
828 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
829 | + } |
|
775 | 830 | } // have we already fetched framed content? |
776 | - elseif (is_array($this->results)) |
|
777 | - $this->results[] = $results; |
|
831 | + elseif (is_array($this->results)) { |
|
832 | + $this->results[] = $results; |
|
833 | + } |
|
778 | 834 | // no framed content |
779 | - else |
|
780 | - $this->results = $results; |
|
835 | + else { |
|
836 | + $this->results = $results; |
|
837 | + } |
|
781 | 838 | |
782 | 839 | return $this; |
783 | 840 | } |
@@ -790,8 +847,9 @@ discard block |
||
790 | 847 | function setcookies() |
791 | 848 | { |
792 | 849 | for ($x = 0; $x < count($this->headers); $x++) { |
793 | - if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) |
|
794 | - $this->cookies[$match[1]] = urldecode($match[2]); |
|
850 | + if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) { |
|
851 | + $this->cookies[$match[1]] = urldecode($match[2]); |
|
852 | + } |
|
795 | 853 | } |
796 | 854 | return $this; |
797 | 855 | } |
@@ -852,10 +910,12 @@ discard block |
||
852 | 910 | 'disable_compression' => true, |
853 | 911 | ); |
854 | 912 | |
855 | - if (isset($this->cafile)) |
|
856 | - $context_opts['ssl']['cafile'] = $this->cafile; |
|
857 | - if (isset($this->capath)) |
|
858 | - $context_opts['ssl']['capath'] = $this->capath; |
|
913 | + if (isset($this->cafile)) { |
|
914 | + $context_opts['ssl']['cafile'] = $this->cafile; |
|
915 | + } |
|
916 | + if (isset($this->capath)) { |
|
917 | + $context_opts['ssl']['capath'] = $this->capath; |
|
918 | + } |
|
859 | 919 | } |
860 | 920 | |
861 | 921 | $host = 'ssl://' . $host; |
@@ -864,8 +924,9 @@ discard block |
||
864 | 924 | $context = stream_context_create($context_opts); |
865 | 925 | |
866 | 926 | if (version_compare(PHP_VERSION, '5.0.0', '>')) { |
867 | - if($this->scheme == 'http') |
|
868 | - $host = "tcp://" . $host; |
|
927 | + if($this->scheme == 'http') { |
|
928 | + $host = "tcp://" . $host; |
|
929 | + } |
|
869 | 930 | $fp = stream_socket_client( |
870 | 931 | "$host:$port", |
871 | 932 | $errno, |
@@ -929,8 +990,9 @@ discard block |
||
929 | 990 | settype($formfiles, "array"); |
930 | 991 | $postdata = ''; |
931 | 992 | |
932 | - if (count($formvars) == 0 && count($formfiles) == 0) |
|
933 | - return; |
|
993 | + if (count($formvars) == 0 && count($formfiles) == 0) { |
|
994 | + return; |
|
995 | + } |
|
934 | 996 | |
935 | 997 | switch ($this->_submit_type) { |
936 | 998 | case "application/x-www-form-urlencoded": |
@@ -940,8 +1002,9 @@ discard block |
||
940 | 1002 | while (list($cur_key, $cur_val) = each($val)) { |
941 | 1003 | $postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&"; |
942 | 1004 | } |
943 | - } else |
|
944 | - $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
1005 | + } else { |
|
1006 | + $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
1007 | + } |
|
945 | 1008 | } |
946 | 1009 | break; |
947 | 1010 | |
@@ -967,7 +1030,9 @@ discard block |
||
967 | 1030 | while (list($field_name, $file_names) = each($formfiles)) { |
968 | 1031 | settype($file_names, "array"); |
969 | 1032 | while (list(, $file_name) = each($file_names)) { |
970 | - if (!is_readable($file_name)) continue; |
|
1033 | + if (!is_readable($file_name)) { |
|
1034 | + continue; |
|
1035 | + } |
|
971 | 1036 | |
972 | 1037 | $fp = fopen($file_name, "r"); |
973 | 1038 | $file_content = fread($fp, filesize($file_name)); |
@@ -16,12 +16,14 @@ discard block |
||
16 | 16 | * |
17 | 17 | */ |
18 | 18 | |
19 | -class RSSCache { |
|
19 | +class RSSCache |
|
20 | +{ |
|
20 | 21 | var $BASE_CACHE = './cache'; // where the cache files are stored |
21 | 22 | var $MAX_AGE = 3600; // when are files stale, default one hour |
22 | 23 | var $ERROR = ""; // accumulate error messages |
23 | 24 | |
24 | - function __construct($base='', $age='') { |
|
25 | + function __construct($base='', $age='') |
|
26 | + { |
|
25 | 27 | if ( $base ) { |
26 | 28 | $this->BASE_CACHE = $base; |
27 | 29 | } |
@@ -48,7 +50,8 @@ discard block |
||
48 | 50 | Input: url from wich the rss file was fetched |
49 | 51 | Output: true on sucess |
50 | 52 | \*=======================================================================*/ |
51 | - function set ($url, $rss) { |
|
53 | + function set ($url, $rss) |
|
54 | + { |
|
52 | 55 | $this->ERROR = ""; |
53 | 56 | $cache_file = $this->file_name( $url ); |
54 | 57 | $fp = @fopen( $cache_file, 'w' ); |
@@ -74,7 +77,8 @@ discard block |
||
74 | 77 | Input: url from wich the rss file was fetched |
75 | 78 | Output: cached object on HIT, false on MISS |
76 | 79 | \*=======================================================================*/ |
77 | - function get ($url) { |
|
80 | + function get ($url) |
|
81 | + { |
|
78 | 82 | $this->ERROR = ""; |
79 | 83 | $cache_file = $this->file_name( $url ); |
80 | 84 | |
@@ -110,7 +114,8 @@ discard block |
||
110 | 114 | Input: url from wich the rss file was fetched |
111 | 115 | Output: cached object on HIT, false on MISS |
112 | 116 | \*=======================================================================*/ |
113 | - function check_cache ( $url ) { |
|
117 | + function check_cache ( $url ) |
|
118 | + { |
|
114 | 119 | $this->ERROR = ""; |
115 | 120 | $filename = $this->file_name( $url ); |
116 | 121 | |
@@ -122,26 +127,24 @@ discard block |
||
122 | 127 | if ( $this->MAX_AGE > $age ) { |
123 | 128 | // object exists and is current |
124 | 129 | return 'HIT'; |
125 | - } |
|
126 | - else { |
|
130 | + } else { |
|
127 | 131 | // object exists but is old |
128 | 132 | return 'STALE'; |
129 | 133 | } |
130 | - } |
|
131 | - else { |
|
134 | + } else { |
|
132 | 135 | // object does not exist |
133 | 136 | return 'MISS'; |
134 | 137 | } |
135 | 138 | } |
136 | 139 | |
137 | - function cache_age( $cache_key ) { |
|
140 | + function cache_age( $cache_key ) |
|
141 | + { |
|
138 | 142 | $filename = $this->file_name( $url ); |
139 | 143 | if ( file_exists( $filename ) ) { |
140 | 144 | $mtime = filemtime( $filename ); |
141 | 145 | $age = time() - $mtime; |
142 | 146 | return $age; |
143 | - } |
|
144 | - else { |
|
147 | + } else { |
|
145 | 148 | return -1; |
146 | 149 | } |
147 | 150 | } |
@@ -149,14 +152,16 @@ discard block |
||
149 | 152 | /*=======================================================================*\ |
150 | 153 | Function: serialize |
151 | 154 | \*=======================================================================*/ |
152 | - function serialize ( $rss ) { |
|
155 | + function serialize ( $rss ) |
|
156 | + { |
|
153 | 157 | return serialize( $rss ); |
154 | 158 | } |
155 | 159 | |
156 | 160 | /*=======================================================================*\ |
157 | 161 | Function: unserialize |
158 | 162 | \*=======================================================================*/ |
159 | - function unserialize ( $data ) { |
|
163 | + function unserialize ( $data ) |
|
164 | + { |
|
160 | 165 | return unserialize( $data ); |
161 | 166 | } |
162 | 167 | |
@@ -166,7 +171,8 @@ discard block |
||
166 | 171 | Input: url from wich the rss file was fetched |
167 | 172 | Output: a file name |
168 | 173 | \*=======================================================================*/ |
169 | - function file_name ($url) { |
|
174 | + function file_name ($url) |
|
175 | + { |
|
170 | 176 | $filename = md5( $url ); |
171 | 177 | return join( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) ); |
172 | 178 | } |
@@ -175,21 +181,22 @@ discard block |
||
175 | 181 | Function: error |
176 | 182 | Purpose: register error |
177 | 183 | \*=======================================================================*/ |
178 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
184 | + function error ($errormsg, $lvl=E_USER_WARNING) |
|
185 | + { |
|
179 | 186 | // append PHP's error message if track_errors enabled |
180 | - if ( isset($php_errormsg) ) { |
|
187 | + if ( isset($php_errormsg) ) { |
|
181 | 188 | $errormsg .= " ($php_errormsg)"; |
182 | 189 | } |
183 | 190 | $this->ERROR = $errormsg; |
184 | 191 | if ( MAGPIE_DEBUG ) { |
185 | 192 | trigger_error( $errormsg, $lvl); |
186 | - } |
|
187 | - else { |
|
193 | + } else { |
|
188 | 194 | error_log( $errormsg, 0); |
189 | 195 | } |
190 | 196 | } |
191 | 197 | |
192 | - function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
198 | + function debug ($debugmsg, $lvl=E_USER_NOTICE) |
|
199 | + { |
|
193 | 200 | if ( MAGPIE_DEBUG ) { |
194 | 201 | $this->error("MagpieRSS [debug] $debugmsg", $lvl); |
195 | 202 | } |
@@ -61,9 +61,13 @@ discard block |
||
61 | 61 | $mgr_dir = substr($self_dir,strrpos($self_dir,'/')+1); |
62 | 62 | $base_path = str_replace($mgr_dir . '/index.php','',$self); |
63 | 63 | $site_mgr_path = $base_path . 'assets/cache/siteManager.php'; |
64 | -if(is_file($site_mgr_path)) include_once($site_mgr_path); |
|
64 | +if(is_file($site_mgr_path)) { |
|
65 | + include_once($site_mgr_path); |
|
66 | +} |
|
65 | 67 | $site_hostnames_path = $base_path . 'assets/cache/siteHostnames.php'; |
66 | -if(is_file($site_hostnames_path)) include_once($site_hostnames_path); |
|
68 | +if(is_file($site_hostnames_path)) { |
|
69 | + include_once($site_hostnames_path); |
|
70 | +} |
|
67 | 71 | if(!defined('MGR_DIR') || MGR_DIR!==$mgr_dir) { |
68 | 72 | $src = "<?php\n"; |
69 | 73 | $src .= "define('MGR_DIR', '{$mgr_dir}');\n"; |
@@ -117,9 +121,15 @@ discard block |
||
117 | 121 | $incPath = str_replace("\\","/",dirname(__FILE__)."/includes/"); // Mod by Raymond |
118 | 122 | set_include_path(get_include_path() . PATH_SEPARATOR . $incPath); |
119 | 123 | |
120 | -if (!defined("ENT_COMPAT")) define("ENT_COMPAT", 2); |
|
121 | -if (!defined("ENT_NOQUOTES")) define("ENT_NOQUOTES", 0); |
|
122 | -if (!defined("ENT_QUOTES")) define("ENT_QUOTES", 3); |
|
124 | +if (!defined("ENT_COMPAT")) { |
|
125 | + define("ENT_COMPAT", 2); |
|
126 | +} |
|
127 | +if (!defined("ENT_NOQUOTES")) { |
|
128 | + define("ENT_NOQUOTES", 0); |
|
129 | +} |
|
130 | +if (!defined("ENT_QUOTES")) { |
|
131 | + define("ENT_QUOTES", 3); |
|
132 | +} |
|
123 | 133 | |
124 | 134 | // set the document_root :| |
125 | 135 | if(!isset($_SERVER["DOCUMENT_ROOT"]) || empty($_SERVER["DOCUMENT_ROOT"])) { |
@@ -182,10 +192,11 @@ discard block |
||
182 | 192 | |
183 | 193 | $s = array('[+MGR_DIR+]'); |
184 | 194 | $r = array(MGR_DIR); |
185 | -foreach($_lang as $k=>$v) |
|
186 | -{ |
|
187 | - if(strpos($v,'[+')!==false) $_lang[$k] = str_replace($s, $r, $v); |
|
188 | -} |
|
195 | +foreach($_lang as $k=>$v) { |
|
196 | + if(strpos($v,'[+')!==false) { |
|
197 | + $_lang[$k] = str_replace($s, $r, $v); |
|
198 | + } |
|
199 | + } |
|
189 | 200 | |
190 | 201 | // send the charset header |
191 | 202 | header('Content-Type: text/html; charset='.$modx_manager_charset); |
@@ -198,7 +209,7 @@ discard block |
||
198 | 209 | include_once "accesscontrol.inc.php"; |
199 | 210 | |
200 | 211 | // double check the session |
201 | -if(!isset($_SESSION['mgrValidated'])){ |
|
212 | +if(!isset($_SESSION['mgrValidated'])) { |
|
202 | 213 | echo "Not Logged In!"; |
203 | 214 | exit; |
204 | 215 | } |
@@ -215,7 +226,9 @@ discard block |
||
215 | 226 | } |
216 | 227 | |
217 | 228 | // Initialize System Alert Message Queque |
218 | -if (!isset($_SESSION['SystemAlertMsgQueque'])) $_SESSION['SystemAlertMsgQueque'] = array(); |
|
229 | +if (!isset($_SESSION['SystemAlertMsgQueque'])) { |
|
230 | + $_SESSION['SystemAlertMsgQueque'] = array(); |
|
231 | +} |
|
219 | 232 | $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque']; |
220 | 233 | |
221 | 234 | // first we check to see if this is a frameset request |
@@ -223,7 +236,7 @@ discard block |
||
223 | 236 | // this looks to be a top-level frameset request, so let's serve up a frameset |
224 | 237 | if(is_file(MODX_MANAGER_PATH."media/style/".$manager_theme."/frames/1.php")) { |
225 | 238 | include_once "media/style/".$manager_theme."/frames/1.php"; |
226 | - }else{ |
|
239 | + } else { |
|
227 | 240 | include_once "frames/1.php"; |
228 | 241 | } |
229 | 242 | exit; |
@@ -231,10 +244,15 @@ discard block |
||
231 | 244 | |
232 | 245 | // OK, let's retrieve the action directive from the request |
233 | 246 | $option = array('min_range'=>1,'max_range'=>2000); |
234 | -if(isset($_GET['a']) && isset($_POST['a'])) $modx->webAlertAndQuit($_lang['error_double_action']); |
|
235 | -elseif(isset($_GET['a'])) $action = filter_input(INPUT_GET, 'a',FILTER_VALIDATE_INT,$option); |
|
236 | -elseif(isset($_POST['a'])) $action = filter_input(INPUT_POST,'a',FILTER_VALIDATE_INT,$option); |
|
237 | -else $action = null; |
|
247 | +if(isset($_GET['a']) && isset($_POST['a'])) { |
|
248 | + $modx->webAlertAndQuit($_lang['error_double_action']); |
|
249 | +} elseif(isset($_GET['a'])) { |
|
250 | + $action = filter_input(INPUT_GET, 'a',FILTER_VALIDATE_INT,$option); |
|
251 | +} elseif(isset($_POST['a'])) { |
|
252 | + $action = filter_input(INPUT_POST,'a',FILTER_VALIDATE_INT,$option); |
|
253 | +} else { |
|
254 | + $action = null; |
|
255 | +} |
|
238 | 256 | |
239 | 257 | if (isset($_POST['updateMsgCount']) && $modx->hasPermission('messages')) { |
240 | 258 | include_once 'messageCount.inc.php'; |
@@ -264,11 +282,12 @@ discard block |
||
264 | 282 | $modx->invokeEvent("OnManagerPageInit", array("action" => $action)); |
265 | 283 | |
266 | 284 | // return element filepath |
267 | -function includeFileProcessor ($filepath,$manager_theme) { |
|
285 | +function includeFileProcessor ($filepath,$manager_theme) |
|
286 | +{ |
|
268 | 287 | $element = ""; |
269 | 288 | if(is_file(MODX_MANAGER_PATH."media/style/".$manager_theme."/".$filepath)) { |
270 | 289 | $element = MODX_MANAGER_PATH."media/style/".$manager_theme."/".$filepath; |
271 | - }else{ |
|
290 | + } else { |
|
272 | 291 | $element = $filepath; |
273 | 292 | } |
274 | 293 | return $element; |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | if(file_exists(MODX_BASE_PATH . 'assets/cache/installProc.inc.php')) { |
22 | 22 | include_once(MODX_BASE_PATH . 'assets/cache/installProc.inc.php'); |
23 | 23 | if(isset($installStartTime)) { |
24 | - if((time() - $installStartTime) > 5 * 60) { // if install flag older than 5 minutes, discard |
|
24 | + if((time() - $installStartTime) > 5 * 60) { |
|
25 | +// if install flag older than 5 minutes, discard |
|
25 | 26 | unset($installStartTime); |
26 | 27 | @ chmod(MODX_BASE_PATH . 'assets/cache/installProc.inc.php', 0755); |
27 | 28 | unlink(MODX_BASE_PATH . 'assets/cache/installProc.inc.php'); |
@@ -155,7 +156,8 @@ discard block |
||
155 | 156 | } elseif(is_file($theme_path . 'templates/actions/login.tpl')) { |
156 | 157 | $target = $theme_path . 'templates/actions/login.tpl'; |
157 | 158 | $login_tpl = file_get_contents($target); |
158 | - } elseif(is_file($theme_path . 'html/login.html')) { // ClipperCMS compatible |
|
159 | + } elseif(is_file($theme_path . 'html/login.html')) { |
|
160 | +// ClipperCMS compatible |
|
159 | 161 | $target = $theme_path . 'html/login.html'; |
160 | 162 | $login_tpl = file_get_contents($target); |
161 | 163 | } else { |