@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /* |
|
2 | + /* |
|
3 | 3 | * MODX Manager Home Page Implmentation by pixelchutes (www.pixelchutes.com) |
4 | 4 | * Based on kudo's kRSS Module v1.0.72 |
5 | 5 | * |
@@ -30,43 +30,43 @@ discard block |
||
30 | 30 | require_once(MODX_MANAGER_PATH.'media/rss/rss_fetch.inc'); |
31 | 31 | // Convert relative path into absolute url |
32 | 32 | function rel2abs( $rel, $base ) { |
33 | - // parse base URL and convert to local variables: $scheme, $host, $path |
|
34 | - extract( parse_url( $base ) ); |
|
35 | - if ( strpos( $rel,"//" ) === 0 ) { |
|
36 | - return $scheme . ':' . $rel; |
|
37 | - } |
|
38 | - // return if already absolute URL |
|
39 | - if ( parse_url( $rel, PHP_URL_SCHEME ) != '' ) { |
|
40 | - return $rel; |
|
41 | - } |
|
42 | - // queries and anchors |
|
43 | - if ( $rel[0] == '#' || $rel[0] == '?' ) { |
|
44 | - return $base . $rel; |
|
45 | - } |
|
46 | - // remove non-directory element from path |
|
47 | - $path = preg_replace( '#/[^/]*$#', '', $path ); |
|
48 | - // destroy path if relative url points to root |
|
49 | - if ( $rel[0] == '/' ) { |
|
50 | - $path = ''; |
|
51 | - } |
|
52 | - // dirty absolute URL |
|
53 | - $abs = $host . $path . "/" . $rel; |
|
54 | - // replace '//' or '/./' or '/foo/../' with '/' |
|
55 | - $abs = preg_replace( "/(\/\.?\/)/", "/", $abs ); |
|
56 | - $abs = preg_replace( "/\/(?!\.\.)[^\/]+\/\.\.\//", "/", $abs ); |
|
57 | - // absolute URL is ready! |
|
58 | - return $scheme . '://' . $abs; |
|
33 | + // parse base URL and convert to local variables: $scheme, $host, $path |
|
34 | + extract( parse_url( $base ) ); |
|
35 | + if ( strpos( $rel,"//" ) === 0 ) { |
|
36 | + return $scheme . ':' . $rel; |
|
37 | + } |
|
38 | + // return if already absolute URL |
|
39 | + if ( parse_url( $rel, PHP_URL_SCHEME ) != '' ) { |
|
40 | + return $rel; |
|
41 | + } |
|
42 | + // queries and anchors |
|
43 | + if ( $rel[0] == '#' || $rel[0] == '?' ) { |
|
44 | + return $base . $rel; |
|
45 | + } |
|
46 | + // remove non-directory element from path |
|
47 | + $path = preg_replace( '#/[^/]*$#', '', $path ); |
|
48 | + // destroy path if relative url points to root |
|
49 | + if ( $rel[0] == '/' ) { |
|
50 | + $path = ''; |
|
51 | + } |
|
52 | + // dirty absolute URL |
|
53 | + $abs = $host . $path . "/" . $rel; |
|
54 | + // replace '//' or '/./' or '/foo/../' with '/' |
|
55 | + $abs = preg_replace( "/(\/\.?\/)/", "/", $abs ); |
|
56 | + $abs = preg_replace( "/\/(?!\.\.)[^\/]+\/\.\.\//", "/", $abs ); |
|
57 | + // absolute URL is ready! |
|
58 | + return $scheme . '://' . $abs; |
|
59 | 59 | } |
60 | 60 | $feedData = array(); |
61 | 61 | |
62 | 62 | // create Feed |
63 | 63 | foreach ($urls as $section=>$url) { |
64 | - $output = ''; |
|
64 | + $output = ''; |
|
65 | 65 | $rss = @fetch_rss($url); |
66 | 66 | if( !$rss ){ |
67 | - $feedData[$section] = 'Failed to retrieve ' . $url; |
|
68 | - continue; |
|
69 | - } |
|
67 | + $feedData[$section] = 'Failed to retrieve ' . $url; |
|
68 | + continue; |
|
69 | + } |
|
70 | 70 | $output .= '<ul>'; |
71 | 71 | |
72 | 72 | $items = array_slice($rss->items, 0, $itemsNumber); |
@@ -84,5 +84,5 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | $output .= '</ul>'; |
87 | - $feedData[$section] = $output; |
|
87 | + $feedData[$section] = $output; |
|
88 | 88 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Message Quit Template |
4 | 4 | * |
5 | 5 | */ |
6 | -if(IN_MANAGER_MODE!="true" && IN_PARSER_MODE!="true") die("<b>INCLUDE ACCESS ERROR</b><br /><br />Direct access to this file prohibited."); |
|
6 | +if (IN_MANAGER_MODE != "true" && IN_PARSER_MODE != "true") die("<b>INCLUDE ACCESS ERROR</b><br /><br />Direct access to this file prohibited."); |
|
7 | 7 | |
8 | 8 | $parsedMessageString = " |
9 | 9 | <html><head><title>EVO Content Manager $version » $release_date</title> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | </script> |
19 | 19 | </head><body> |
20 | 20 | "; |
21 | -if($is_error) { |
|
21 | +if ($is_error) { |
|
22 | 22 | $parsedMessageString .= "<h3 style='color:red;background:#e0e0e0;padding:2px;'> MODX Parse Error </h3> |
23 | 23 | <table border='0' cellpadding='1' cellspacing='0'> |
24 | 24 | <tr><td colspan='3'>MODX encountered the following error while attempting to parse the requested resource:</td></tr> |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | <tr><td colspan='3'><b style='color:#003399;'>« $msg »</b></td></tr>"; |
31 | 31 | } |
32 | 32 | |
33 | -if(!empty($query)) { |
|
33 | +if (!empty($query)) { |
|
34 | 34 | $parsedMessageString .= "<tr><td colspan='3'><hr size='1' width='98%' style='color:#e0e0e0'/><b style='color:#999;font-size: 9px;border-left:1px solid #c0c0c0; margin-left:10px;'> SQL: <span id='sqlHolder'>$query</span></b><hr size='1' width='98%' style='color:#e0e0e0'/> |
35 | 35 | <a href='javascript:copyToClip();' style='color:#821517;font-size: 9px; text-decoration: none'>[Copy SQL to ClipBoard]</a><textarea id='holdtext' style='display:none;'></textarea></td></tr>"; |
36 | 36 | } |
37 | 37 | |
38 | -if($text!='') { |
|
38 | +if ($text != '') { |
|
39 | 39 | |
40 | - $errortype = array ( |
|
40 | + $errortype = array( |
|
41 | 41 | E_ERROR => "Error", |
42 | 42 | E_WARNING => "Warning", |
43 | 43 | E_PARSE => "Parsing Error", |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $parsedMessageString .= "<tr><td> Line: </td>"; |
69 | 69 | $parsedMessageString .= "<td colspan='2'>$line</td><td> </td>"; |
70 | 70 | $parsedMessageString .= "</tr>"; |
71 | - if($source!='') { |
|
71 | + if ($source != '') { |
|
72 | 72 | $parsedMessageString .= "<tr><td valign='top'> Line $line source: </td>"; |
73 | 73 | $parsedMessageString .= "<td colspan='2'>$source</td><td> </td>"; |
74 | 74 | $parsedMessageString .= "</tr>"; |
@@ -3,7 +3,9 @@ |
||
3 | 3 | * Message Quit Template |
4 | 4 | * |
5 | 5 | */ |
6 | -if(IN_MANAGER_MODE!="true" && IN_PARSER_MODE!="true") die("<b>INCLUDE ACCESS ERROR</b><br /><br />Direct access to this file prohibited."); |
|
6 | +if(IN_MANAGER_MODE!="true" && IN_PARSER_MODE!="true") { |
|
7 | + die("<b>INCLUDE ACCESS ERROR</b><br /><br />Direct access to this file prohibited."); |
|
8 | +} |
|
7 | 9 | |
8 | 10 | $parsedMessageString = " |
9 | 11 | <html><head><title>EVO Content Manager $version » $release_date</title> |
@@ -11,18 +11,18 @@ |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | function secureWebDocument($docid='') { |
14 | - global $modx; |
|
14 | + global $modx; |
|
15 | 15 | |
16 | - $modx->db->update('privateweb = 0', $modx->getFullTableName("site_content"), ($docid>0 ? "id='$docid'":"privateweb = 1")); |
|
17 | - $rs = $modx->db->select( |
|
18 | - 'DISTINCT sc.id', |
|
19 | - $modx->getFullTableName("site_content")." sc |
|
16 | + $modx->db->update('privateweb = 0', $modx->getFullTableName("site_content"), ($docid>0 ? "id='$docid'":"privateweb = 1")); |
|
17 | + $rs = $modx->db->select( |
|
18 | + 'DISTINCT sc.id', |
|
19 | + $modx->getFullTableName("site_content")." sc |
|
20 | 20 | LEFT JOIN ".$modx->getFullTableName("document_groups")." dg ON dg.document = sc.id |
21 | 21 | LEFT JOIN ".$modx->getFullTableName("webgroup_access")." wga ON wga.documentgroup = dg.document_group", |
22 | - ($docid>0 ? " sc.id='{$docid}' AND ":"")."wga.id>0" |
|
23 | - ); |
|
24 | - $ids = $modx->db->getColumn("id",$rs); |
|
25 | - if(count($ids)>0) { |
|
26 | - $modx->db->update('privateweb = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ",$ids).")"); |
|
27 | - } |
|
22 | + ($docid>0 ? " sc.id='{$docid}' AND ":"")."wga.id>0" |
|
23 | + ); |
|
24 | + $ids = $modx->db->getColumn("id",$rs); |
|
25 | + if(count($ids)>0) { |
|
26 | + $modx->db->update('privateweb = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ",$ids).")"); |
|
27 | + } |
|
28 | 28 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Secure Web Documents |
@@ -10,19 +10,19 @@ discard block |
||
10 | 10 | * |
11 | 11 | */ |
12 | 12 | |
13 | -function secureWebDocument($docid='') { |
|
13 | +function secureWebDocument($docid = ''){ |
|
14 | 14 | global $modx; |
15 | 15 | |
16 | - $modx->db->update('privateweb = 0', $modx->getFullTableName("site_content"), ($docid>0 ? "id='$docid'":"privateweb = 1")); |
|
16 | + $modx->db->update('privateweb = 0', $modx->getFullTableName("site_content"), ($docid > 0 ? "id='$docid'" : "privateweb = 1")); |
|
17 | 17 | $rs = $modx->db->select( |
18 | 18 | 'DISTINCT sc.id', |
19 | 19 | $modx->getFullTableName("site_content")." sc |
20 | 20 | LEFT JOIN ".$modx->getFullTableName("document_groups")." dg ON dg.document = sc.id |
21 | 21 | LEFT JOIN ".$modx->getFullTableName("webgroup_access")." wga ON wga.documentgroup = dg.document_group", |
22 | - ($docid>0 ? " sc.id='{$docid}' AND ":"")."wga.id>0" |
|
22 | + ($docid > 0 ? " sc.id='{$docid}' AND " : "")."wga.id>0" |
|
23 | 23 | ); |
24 | - $ids = $modx->db->getColumn("id",$rs); |
|
25 | - if(count($ids)>0) { |
|
26 | - $modx->db->update('privateweb = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ",$ids).")"); |
|
24 | + $ids = $modx->db->getColumn("id", $rs); |
|
25 | + if (count($ids) > 0) { |
|
26 | + $modx->db->update('privateweb = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ", $ids).")"); |
|
27 | 27 | } |
28 | 28 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | // ajax response |
11 | 11 | if (isset($_POST['updateMsgCount'])) { |
12 | - header("Content-Type: application/json; charset=utf-8"); |
|
13 | - print $nrnewmessages.','.$nrtotalmessages; |
|
14 | - exit; |
|
12 | + header("Content-Type: application/json; charset=utf-8"); |
|
13 | + print $nrnewmessages.','.$nrtotalmessages; |
|
14 | + exit; |
|
15 | 15 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | 3 | |
4 | 4 | // get the settings from the database. |
5 | 5 | $settings = array(); |
6 | -if ($modx && count($modx->config)>0) $settings = $modx->config; |
|
7 | -else{ |
|
6 | +if ($modx && count($modx->config) > 0) $settings = $modx->config; |
|
7 | +else { |
|
8 | 8 | $rs = $modx->db->select('setting_name, setting_value', $modx->getFullTableName('system_settings')); |
9 | 9 | while ($row = $modx->db->getRow($rs)) { |
10 | 10 | $settings[$row['setting_name']] = $row['setting_value']; |
@@ -14,4 +14,4 @@ discard block |
||
14 | 14 | extract($settings, EXTR_OVERWRITE); |
15 | 15 | |
16 | 16 | // setup default site id - new installation should generate a unique id for the site. |
17 | -if(!isset($site_id)) $site_id = "MzGeQ2faT4Dw06+U49x3"; |
|
17 | +if (!isset($site_id)) $site_id = "MzGeQ2faT4Dw06+U49x3"; |
@@ -1,10 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if(IN_MANAGER_MODE!="true") { |
|
3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
4 | +} |
|
3 | 5 | |
4 | 6 | // get the settings from the database. |
5 | 7 | $settings = array(); |
6 | -if ($modx && count($modx->config)>0) $settings = $modx->config; |
|
7 | -else{ |
|
8 | +if ($modx && count($modx->config)>0) { |
|
9 | + $settings = $modx->config; |
|
10 | +} else { |
|
8 | 11 | $rs = $modx->db->select('setting_name, setting_value', $modx->getFullTableName('system_settings')); |
9 | 12 | while ($row = $modx->db->getRow($rs)) { |
10 | 13 | $settings[$row['setting_name']] = $row['setting_value']; |
@@ -14,4 +17,6 @@ discard block |
||
14 | 17 | extract($settings, EXTR_OVERWRITE); |
15 | 18 | |
16 | 19 | // setup default site id - new installation should generate a unique id for the site. |
17 | -if(!isset($site_id)) $site_id = "MzGeQ2faT4Dw06+U49x3"; |
|
20 | +if(!isset($site_id)) { |
|
21 | + $site_id = "MzGeQ2faT4Dw06+U49x3"; |
|
22 | +} |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | // load template |
24 | 24 | if(!isset($modx->config['manager_lockout_tpl']) || empty($modx->config['manager_lockout_tpl'])) { |
25 | - $modx->config['manager_lockout_tpl'] = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
25 | + $modx->config['manager_lockout_tpl'] = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $target = $modx->config['manager_lockout_tpl']; |
@@ -30,40 +30,40 @@ discard block |
||
30 | 30 | $target = $modx->mergeSettingsContent($target); |
31 | 31 | |
32 | 32 | if(substr($target,0,1)==='@') { |
33 | - if(substr($target,0,6)==='@CHUNK') { |
|
34 | - $target = trim(substr($target,7)); |
|
35 | - $lockout_tpl = $modx->getChunk($target); |
|
36 | - } |
|
37 | - elseif(substr($target,0,5)==='@FILE') { |
|
38 | - $target = trim(substr($target,6)); |
|
39 | - $lockout_tpl = file_get_contents($target); |
|
40 | - } |
|
41 | - } else { |
|
42 | - $chunk = $modx->getChunk($target); |
|
43 | - if($chunk!==false && !empty($chunk)) { |
|
44 | - $lockout_tpl = $chunk; |
|
45 | - } |
|
46 | - elseif(is_file(MODX_BASE_PATH . $target)) { |
|
47 | - $target = MODX_BASE_PATH . $target; |
|
48 | - $lockout_tpl = file_get_contents($target); |
|
49 | - } |
|
50 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) { |
|
51 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl'; |
|
52 | - $lockout_tpl = file_get_contents($target); |
|
53 | - } |
|
54 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) { |
|
55 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl'; |
|
56 | - $login_tpl = file_get_contents($target); |
|
57 | - } |
|
58 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) { // ClipperCMS compatible |
|
59 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html'; |
|
60 | - $lockout_tpl = file_get_contents($target); |
|
61 | - } |
|
62 | - else { |
|
63 | - $target = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
64 | - $lockout_tpl = file_get_contents($target); |
|
65 | - } |
|
66 | - } |
|
33 | + if(substr($target,0,6)==='@CHUNK') { |
|
34 | + $target = trim(substr($target,7)); |
|
35 | + $lockout_tpl = $modx->getChunk($target); |
|
36 | + } |
|
37 | + elseif(substr($target,0,5)==='@FILE') { |
|
38 | + $target = trim(substr($target,6)); |
|
39 | + $lockout_tpl = file_get_contents($target); |
|
40 | + } |
|
41 | + } else { |
|
42 | + $chunk = $modx->getChunk($target); |
|
43 | + if($chunk!==false && !empty($chunk)) { |
|
44 | + $lockout_tpl = $chunk; |
|
45 | + } |
|
46 | + elseif(is_file(MODX_BASE_PATH . $target)) { |
|
47 | + $target = MODX_BASE_PATH . $target; |
|
48 | + $lockout_tpl = file_get_contents($target); |
|
49 | + } |
|
50 | + elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) { |
|
51 | + $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl'; |
|
52 | + $lockout_tpl = file_get_contents($target); |
|
53 | + } |
|
54 | + elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) { |
|
55 | + $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl'; |
|
56 | + $login_tpl = file_get_contents($target); |
|
57 | + } |
|
58 | + elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) { // ClipperCMS compatible |
|
59 | + $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html'; |
|
60 | + $lockout_tpl = file_get_contents($target); |
|
61 | + } |
|
62 | + else { |
|
63 | + $target = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
64 | + $lockout_tpl = file_get_contents($target); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | // merge placeholders |
69 | 69 | $lockout_tpl = $modx->mergePlaceholderContent($lockout_tpl); |
@@ -1,73 +1,73 @@ |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | 3 | |
4 | -if($modx->manager->action!='8' && isset($_SESSION['mgrValidated'])){ |
|
4 | +if ($modx->manager->action != '8' && isset($_SESSION['mgrValidated'])) { |
|
5 | 5 | |
6 | - $homeurl = $modx->makeUrl($manager_login_startup>0 ? $manager_login_startup:$site_start); |
|
6 | + $homeurl = $modx->makeUrl($manager_login_startup > 0 ? $manager_login_startup : $site_start); |
|
7 | 7 | $logouturl = MODX_MANAGER_URL.'index.php?a=8'; |
8 | 8 | |
9 | - $modx->setPlaceholder('modx_charset',$modx_manager_charset); |
|
10 | - $modx->setPlaceholder('theme',$manager_theme); |
|
9 | + $modx->setPlaceholder('modx_charset', $modx_manager_charset); |
|
10 | + $modx->setPlaceholder('theme', $manager_theme); |
|
11 | 11 | |
12 | - $modx->setPlaceholder('site_name',$site_name); |
|
13 | - $modx->setPlaceholder('logo_slogan',$_lang["logo_slogan"]); |
|
14 | - $modx->setPlaceholder('manager_lockout_message',$_lang["manager_lockout_message"]); |
|
12 | + $modx->setPlaceholder('site_name', $site_name); |
|
13 | + $modx->setPlaceholder('logo_slogan', $_lang["logo_slogan"]); |
|
14 | + $modx->setPlaceholder('manager_lockout_message', $_lang["manager_lockout_message"]); |
|
15 | 15 | |
16 | - $modx->setPlaceholder('home',$_lang["home"]); |
|
17 | - $modx->setPlaceholder('homeurl',$homeurl); |
|
18 | - $modx->setPlaceholder('logout',$_lang["logout"]); |
|
19 | - $modx->setPlaceholder('logouturl',$logouturl); |
|
20 | - $modx->setPlaceholder('manager_theme_url',MODX_MANAGER_URL . 'media/style/' . $modx->config['manager_theme'] . '/'); |
|
21 | - $modx->setPlaceholder('year',date('Y')); |
|
16 | + $modx->setPlaceholder('home', $_lang["home"]); |
|
17 | + $modx->setPlaceholder('homeurl', $homeurl); |
|
18 | + $modx->setPlaceholder('logout', $_lang["logout"]); |
|
19 | + $modx->setPlaceholder('logouturl', $logouturl); |
|
20 | + $modx->setPlaceholder('manager_theme_url', MODX_MANAGER_URL.'media/style/'.$modx->config['manager_theme'].'/'); |
|
21 | + $modx->setPlaceholder('year', date('Y')); |
|
22 | 22 | |
23 | 23 | // load template |
24 | - if(!isset($modx->config['manager_lockout_tpl']) || empty($modx->config['manager_lockout_tpl'])) { |
|
25 | - $modx->config['manager_lockout_tpl'] = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
24 | + if (!isset($modx->config['manager_lockout_tpl']) || empty($modx->config['manager_lockout_tpl'])) { |
|
25 | + $modx->config['manager_lockout_tpl'] = MODX_MANAGER_PATH.'media/style/common/manager.lockout.tpl'; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $target = $modx->config['manager_lockout_tpl']; |
29 | 29 | $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target); |
30 | 30 | $target = $modx->mergeSettingsContent($target); |
31 | 31 | |
32 | - if(substr($target,0,1)==='@') { |
|
33 | - if(substr($target,0,6)==='@CHUNK') { |
|
34 | - $target = trim(substr($target,7)); |
|
32 | + if (substr($target, 0, 1) === '@') { |
|
33 | + if (substr($target, 0, 6) === '@CHUNK') { |
|
34 | + $target = trim(substr($target, 7)); |
|
35 | 35 | $lockout_tpl = $modx->getChunk($target); |
36 | 36 | } |
37 | - elseif(substr($target,0,5)==='@FILE') { |
|
38 | - $target = trim(substr($target,6)); |
|
37 | + elseif (substr($target, 0, 5) === '@FILE') { |
|
38 | + $target = trim(substr($target, 6)); |
|
39 | 39 | $lockout_tpl = file_get_contents($target); |
40 | 40 | } |
41 | 41 | } else { |
42 | 42 | $chunk = $modx->getChunk($target); |
43 | - if($chunk!==false && !empty($chunk)) { |
|
43 | + if ($chunk !== false && !empty($chunk)) { |
|
44 | 44 | $lockout_tpl = $chunk; |
45 | 45 | } |
46 | - elseif(is_file(MODX_BASE_PATH . $target)) { |
|
47 | - $target = MODX_BASE_PATH . $target; |
|
46 | + elseif (is_file(MODX_BASE_PATH.$target)) { |
|
47 | + $target = MODX_BASE_PATH.$target; |
|
48 | 48 | $lockout_tpl = file_get_contents($target); |
49 | 49 | } |
50 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl')) { |
|
51 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/manager.lockout.tpl'; |
|
50 | + elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/manager.lockout.tpl')) { |
|
51 | + $target = MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/manager.lockout.tpl'; |
|
52 | 52 | $lockout_tpl = file_get_contents($target); |
53 | 53 | } |
54 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl')) { |
|
55 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates/actions/manager.lockout.tpl'; |
|
54 | + elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/templates/actions/manager.lockout.tpl')) { |
|
55 | + $target = MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/templates/actions/manager.lockout.tpl'; |
|
56 | 56 | $login_tpl = file_get_contents($target); |
57 | 57 | } |
58 | - elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html')) { // ClipperCMS compatible |
|
59 | - $target = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/manager.lockout.html'; |
|
58 | + elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/manager.lockout.html')) { // ClipperCMS compatible |
|
59 | + $target = MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/manager.lockout.html'; |
|
60 | 60 | $lockout_tpl = file_get_contents($target); |
61 | 61 | } |
62 | 62 | else { |
63 | - $target = MODX_MANAGER_PATH . 'media/style/common/manager.lockout.tpl'; |
|
63 | + $target = MODX_MANAGER_PATH.'media/style/common/manager.lockout.tpl'; |
|
64 | 64 | $lockout_tpl = file_get_contents($target); |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | 68 | // merge placeholders |
69 | 69 | $lockout_tpl = $modx->mergePlaceholderContent($lockout_tpl); |
70 | - $regx = strpos($lockout_tpl,'[[+')!==false ? '~\[\[\+(.*?)\]\]~' : '~\[\+(.*?)\+\]~'; // little tweak for newer parsers |
|
70 | + $regx = strpos($lockout_tpl, '[[+') !== false ? '~\[\[\+(.*?)\]\]~' : '~\[\+(.*?)\+\]~'; // little tweak for newer parsers |
|
71 | 71 | $lockout_tpl = preg_replace($regx, '', $lockout_tpl); //cleanup |
72 | 72 | |
73 | 73 | echo $lockout_tpl; |
@@ -11,18 +11,18 @@ |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | function secureMgrDocument($docid='') { |
14 | - global $modx; |
|
14 | + global $modx; |
|
15 | 15 | |
16 | - $modx->db->update('privatemgr = 0', $modx->getFullTableName("site_content"), ($docid>0 ? "id='$docid'":"privatemgr = 1")); |
|
17 | - $rs = $modx->db->select( |
|
18 | - 'DISTINCT sc.id', |
|
19 | - $modx->getFullTableName("site_content")." sc |
|
16 | + $modx->db->update('privatemgr = 0', $modx->getFullTableName("site_content"), ($docid>0 ? "id='$docid'":"privatemgr = 1")); |
|
17 | + $rs = $modx->db->select( |
|
18 | + 'DISTINCT sc.id', |
|
19 | + $modx->getFullTableName("site_content")." sc |
|
20 | 20 | LEFT JOIN ".$modx->getFullTableName("document_groups")." dg ON dg.document = sc.id |
21 | 21 | LEFT JOIN ".$modx->getFullTableName("membergroup_access")." mga ON mga.documentgroup = dg.document_group", |
22 | - ($docid>0 ? " sc.id='{$docid}' AND ":"")."mga.id>0" |
|
23 | - ); |
|
24 | - $ids = $modx->db->getColumn("id",$rs); |
|
25 | - if(count($ids)>0) { |
|
26 | - $modx->db->update('privatemgr = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ",$ids).")"); |
|
27 | - } |
|
22 | + ($docid>0 ? " sc.id='{$docid}' AND ":"")."mga.id>0" |
|
23 | + ); |
|
24 | + $ids = $modx->db->getColumn("id",$rs); |
|
25 | + if(count($ids)>0) { |
|
26 | + $modx->db->update('privatemgr = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ",$ids).")"); |
|
27 | + } |
|
28 | 28 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
2 | +if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Secure Manager Documents |
@@ -10,19 +10,19 @@ discard block |
||
10 | 10 | * |
11 | 11 | */ |
12 | 12 | |
13 | -function secureMgrDocument($docid='') { |
|
13 | +function secureMgrDocument($docid = ''){ |
|
14 | 14 | global $modx; |
15 | 15 | |
16 | - $modx->db->update('privatemgr = 0', $modx->getFullTableName("site_content"), ($docid>0 ? "id='$docid'":"privatemgr = 1")); |
|
16 | + $modx->db->update('privatemgr = 0', $modx->getFullTableName("site_content"), ($docid > 0 ? "id='$docid'" : "privatemgr = 1")); |
|
17 | 17 | $rs = $modx->db->select( |
18 | 18 | 'DISTINCT sc.id', |
19 | 19 | $modx->getFullTableName("site_content")." sc |
20 | 20 | LEFT JOIN ".$modx->getFullTableName("document_groups")." dg ON dg.document = sc.id |
21 | 21 | LEFT JOIN ".$modx->getFullTableName("membergroup_access")." mga ON mga.documentgroup = dg.document_group", |
22 | - ($docid>0 ? " sc.id='{$docid}' AND ":"")."mga.id>0" |
|
22 | + ($docid > 0 ? " sc.id='{$docid}' AND " : "")."mga.id>0" |
|
23 | 23 | ); |
24 | - $ids = $modx->db->getColumn("id",$rs); |
|
25 | - if(count($ids)>0) { |
|
26 | - $modx->db->update('privatemgr = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ",$ids).")"); |
|
24 | + $ids = $modx->db->getColumn("id", $rs); |
|
25 | + if (count($ids) > 0) { |
|
26 | + $modx->db->update('privatemgr = 1', $modx->getFullTableName("site_content"), "id IN (".implode(", ", $ids).")"); |
|
27 | 27 | } |
28 | 28 | } |
@@ -22,35 +22,35 @@ |
||
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 | # regex to match wc3dtf |
28 | 28 | $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; |
29 | 29 | |
30 | - if ( preg_match( $pat, $date_str, $match ) ) { |
|
31 | - list( $year, $month, $day, $hours, $minutes, $seconds) = |
|
32 | - array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); |
|
30 | + if (preg_match($pat, $date_str, $match)) { |
|
31 | + list($year, $month, $day, $hours, $minutes, $seconds) = |
|
32 | + array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); |
|
33 | 33 | |
34 | 34 | # calc epoch for current date assuming GMT |
35 | - $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); |
|
35 | + $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year); |
|
36 | 36 | |
37 | 37 | $offset = 0; |
38 | - if ( $match[10] == 'Z' ) { |
|
38 | + if ($match[10] == 'Z') { |
|
39 | 39 | # zulu time, aka GMT |
40 | 40 | } |
41 | 41 | else { |
42 | - list( $tz_mod, $tz_hour, $tz_min ) = |
|
43 | - array( $match[8], $match[9], $match[10]); |
|
42 | + list($tz_mod, $tz_hour, $tz_min) = |
|
43 | + array($match[8], $match[9], $match[10]); |
|
44 | 44 | |
45 | 45 | # zero out the variables |
46 | - if ( ! $tz_hour ) { $tz_hour = 0; } |
|
47 | - if ( ! $tz_min ) { $tz_min = 0; } |
|
46 | + if (!$tz_hour) { $tz_hour = 0; } |
|
47 | + if (!$tz_min) { $tz_min = 0; } |
|
48 | 48 | |
49 | - $offset_secs = (($tz_hour*60)+$tz_min)*60; |
|
49 | + $offset_secs = (($tz_hour * 60) + $tz_min) * 60; |
|
50 | 50 | |
51 | 51 | # is timezone ahead of GMT? then subtract offset |
52 | 52 | # |
53 | - if ( $tz_mod == '+' ) { |
|
53 | + if ($tz_mod == '+') { |
|
54 | 54 | $offset_secs = $offset_secs * -1; |
55 | 55 | } |
56 | 56 |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | if (!defined('MAGPIE_DIR')) { |
27 | - define('MAGPIE_DIR', dirname(__FILE__) . DIR_SEP); |
|
27 | + define('MAGPIE_DIR', dirname(__FILE__).DIR_SEP); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | if (!defined('MAGPIE_CACHE_DIR')) { |
31 | - define('MAGPIE_CACHE_DIR', MODX_BASE_PATH . 'assets/cache/rss'); |
|
31 | + define('MAGPIE_CACHE_DIR', MODX_BASE_PATH.'assets/cache/rss'); |
|
32 | 32 | } |
33 | 33 | |
34 | -require_once( MAGPIE_DIR . 'rss_parse.inc' ); |
|
35 | -require_once( MAGPIE_DIR . 'rss_cache.inc' ); |
|
34 | +require_once(MAGPIE_DIR.'rss_parse.inc'); |
|
35 | +require_once(MAGPIE_DIR.'rss_cache.inc'); |
|
36 | 36 | |
37 | 37 | // for including 3rd party libraries |
38 | -define('MAGPIE_EXTLIB', MAGPIE_DIR . 'extlib' . DIR_SEP); |
|
39 | -require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc'); |
|
38 | +define('MAGPIE_EXTLIB', MAGPIE_DIR.'extlib'.DIR_SEP); |
|
39 | +require_once(MAGPIE_EXTLIB.'Snoopy.class.inc'); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /* |
@@ -89,21 +89,21 @@ discard block |
||
89 | 89 | |
90 | 90 | $MAGPIE_ERROR = ""; |
91 | 91 | |
92 | -function fetch_rss ($url) { |
|
92 | +function fetch_rss($url){ |
|
93 | 93 | // initialize constants |
94 | 94 | init(); |
95 | 95 | |
96 | - if ( !isset($url) ) { |
|
96 | + if (!isset($url)) { |
|
97 | 97 | error("fetch_rss called without a url"); |
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
101 | 101 | // if cache is disabled |
102 | - if ( !MAGPIE_CACHE_ON ) { |
|
102 | + if (!MAGPIE_CACHE_ON) { |
|
103 | 103 | // fetch file, and parse it |
104 | - $resp = _fetch_remote_file( $url ); |
|
105 | - if ( is_success( $resp->status ) ) { |
|
106 | - return _response_to_rss( $resp ); |
|
104 | + $resp = _fetch_remote_file($url); |
|
105 | + if (is_success($resp->status)) { |
|
106 | + return _response_to_rss($resp); |
|
107 | 107 | } |
108 | 108 | else { |
109 | 109 | error("Failed to fetch $url and cache is off"); |
@@ -118,34 +118,34 @@ discard block |
||
118 | 118 | // 3. if cached obj fails freshness check, fetch remote |
119 | 119 | // 4. if remote fails, return stale object, or error |
120 | 120 | |
121 | - $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); |
|
121 | + $cache = new RSSCache(MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE); |
|
122 | 122 | |
123 | 123 | if (MAGPIE_DEBUG and $cache->ERROR) { |
124 | 124 | debug($cache->ERROR, E_USER_WARNING); |
125 | 125 | } |
126 | 126 | |
127 | 127 | |
128 | - $cache_status = 0; // response of check_cache |
|
128 | + $cache_status = 0; // response of check_cache |
|
129 | 129 | $request_headers = array(); // HTTP headers to send with fetch |
130 | - $rss = 0; // parsed RSS object |
|
131 | - $errormsg = 0; // errors, if any |
|
130 | + $rss = 0; // parsed RSS object |
|
131 | + $errormsg = 0; // errors, if any |
|
132 | 132 | |
133 | 133 | // store parsed XML by desired output encoding |
134 | 134 | // as character munging happens at parse time |
135 | - $cache_key = $url . MAGPIE_OUTPUT_ENCODING; |
|
135 | + $cache_key = $url.MAGPIE_OUTPUT_ENCODING; |
|
136 | 136 | |
137 | 137 | if (!$cache->ERROR) { |
138 | 138 | // return cache HIT, MISS, or STALE |
139 | - $cache_status = $cache->check_cache( $cache_key); |
|
139 | + $cache_status = $cache->check_cache($cache_key); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // if object cached, and cache is fresh, return cached obj |
143 | - if ( $cache_status == 'HIT' ) { |
|
144 | - $rss = $cache->get( $cache_key ); |
|
145 | - if ( isset($rss) and $rss ) { |
|
143 | + if ($cache_status == 'HIT') { |
|
144 | + $rss = $cache->get($cache_key); |
|
145 | + if (isset($rss) and $rss) { |
|
146 | 146 | // should be cache age |
147 | 147 | $rss->from_cache = 1; |
148 | - if ( MAGPIE_DEBUG > 1) { |
|
148 | + if (MAGPIE_DEBUG > 1) { |
|
149 | 149 | debug("MagpieRSS: Cache HIT", E_USER_NOTICE); |
150 | 150 | } |
151 | 151 | return $rss; |
@@ -155,50 +155,50 @@ discard block |
||
155 | 155 | // else attempt a conditional get |
156 | 156 | |
157 | 157 | // setup headers |
158 | - if ( $cache_status == 'STALE' ) { |
|
159 | - $rss = $cache->get( $cache_key ); |
|
160 | - if ( $rss and $rss->etag and $rss->last_modified ) { |
|
158 | + if ($cache_status == 'STALE') { |
|
159 | + $rss = $cache->get($cache_key); |
|
160 | + if ($rss and $rss->etag and $rss->last_modified) { |
|
161 | 161 | $request_headers['If-None-Match'] = $rss->etag; |
162 | 162 | $request_headers['If-Last-Modified'] = $rss->last_modified; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - $resp = _fetch_remote_file( $url, $request_headers ); |
|
166 | + $resp = _fetch_remote_file($url, $request_headers); |
|
167 | 167 | |
168 | 168 | if (isset($resp) and $resp) { |
169 | - if ($resp->status == '304' ) { |
|
169 | + if ($resp->status == '304') { |
|
170 | 170 | // we have the most current copy |
171 | - if ( MAGPIE_DEBUG > 1) { |
|
171 | + if (MAGPIE_DEBUG > 1) { |
|
172 | 172 | debug("Got 304 for $url"); |
173 | 173 | } |
174 | 174 | // reset cache on 304 (at minutillo insistent prodding) |
175 | 175 | $cache->set($cache_key, $rss); |
176 | 176 | return $rss; |
177 | 177 | } |
178 | - elseif ( is_success( $resp->status ) ) { |
|
179 | - $rss = _response_to_rss( $resp ); |
|
180 | - if ( $rss ) { |
|
178 | + elseif (is_success($resp->status)) { |
|
179 | + $rss = _response_to_rss($resp); |
|
180 | + if ($rss) { |
|
181 | 181 | if (MAGPIE_DEBUG > 1) { |
182 | 182 | debug("Fetch successful"); |
183 | 183 | } |
184 | 184 | // add object to cache |
185 | - $cache->set( $cache_key, $rss ); |
|
185 | + $cache->set($cache_key, $rss); |
|
186 | 186 | return $rss; |
187 | 187 | } |
188 | 188 | } |
189 | 189 | else { |
190 | 190 | $errormsg = "Failed to fetch $url "; |
191 | - if ( $resp->status == '-100' ) { |
|
192 | - $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; |
|
191 | + if ($resp->status == '-100') { |
|
192 | + $errormsg .= "(Request timed out after ".MAGPIE_FETCH_TIME_OUT." seconds)"; |
|
193 | 193 | } |
194 | - elseif ( $resp->error ) { |
|
194 | + elseif ($resp->error) { |
|
195 | 195 | # compensate for Snoopy's annoying habbit to tacking |
196 | 196 | # on '\n' |
197 | 197 | $http_error = substr($resp->error, 0, -2); |
198 | 198 | $errormsg .= "(HTTP Error: $http_error)"; |
199 | 199 | } |
200 | 200 | else { |
201 | - $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
|
201 | + $errormsg .= "(HTTP Response: ".$resp->response_code.')'; |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | |
211 | 211 | // attempt to return cached object |
212 | 212 | if ($rss) { |
213 | - if ( MAGPIE_DEBUG ) { |
|
213 | + if (MAGPIE_DEBUG) { |
|
214 | 214 | debug("Returning STALE object for $url"); |
215 | 215 | } |
216 | 216 | return $rss; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // else we totally failed |
220 | - error( $errormsg ); |
|
220 | + error($errormsg); |
|
221 | 221 | |
222 | 222 | return false; |
223 | 223 | |
@@ -229,21 +229,21 @@ discard block |
||
229 | 229 | Purpose: set MAGPIE_ERROR, and trigger error |
230 | 230 | \*=======================================================================*/ |
231 | 231 | |
232 | -function error ($errormsg, $lvl=E_USER_WARNING) { |
|
232 | +function error($errormsg, $lvl = E_USER_WARNING){ |
|
233 | 233 | global $MAGPIE_ERROR; |
234 | 234 | |
235 | 235 | // append PHP's error message if track_errors enabled |
236 | - if ( isset($php_errormsg) ) { |
|
236 | + if (isset($php_errormsg)) { |
|
237 | 237 | $errormsg .= " ($php_errormsg)"; |
238 | 238 | } |
239 | - if ( $errormsg ) { |
|
239 | + if ($errormsg) { |
|
240 | 240 | $errormsg = "MagpieRSS: $errormsg"; |
241 | 241 | $MAGPIE_ERROR = $errormsg; |
242 | - trigger_error( $errormsg, $lvl); |
|
242 | + trigger_error($errormsg, $lvl); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | -function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
246 | +function debug($debugmsg, $lvl = E_USER_NOTICE){ |
|
247 | 247 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
248 | 248 | } |
249 | 249 | |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | Function: magpie_error |
252 | 252 | Purpose: accessor for the magpie error variable |
253 | 253 | \*=======================================================================*/ |
254 | -function magpie_error ($errormsg="") { |
|
254 | +function magpie_error($errormsg = ""){ |
|
255 | 255 | global $MAGPIE_ERROR; |
256 | 256 | |
257 | - if ( isset($errormsg) and $errormsg ) { |
|
257 | + if (isset($errormsg) and $errormsg) { |
|
258 | 258 | $MAGPIE_ERROR = $errormsg; |
259 | 259 | } |
260 | 260 | |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | headers to send along with the request (optional) |
269 | 269 | Output: an HTTP response object (see Snoopy.class.inc) |
270 | 270 | \*=======================================================================*/ |
271 | -function _fetch_remote_file ($url, $headers = "" ) { |
|
271 | +function _fetch_remote_file($url, $headers = ""){ |
|
272 | 272 | // Snoopy is an HTTP client in PHP |
273 | 273 | $client = new Snoopy(); |
274 | 274 | $client->agent = MAGPIE_USER_AGENT; |
275 | 275 | $client->read_timeout = MAGPIE_FETCH_TIME_OUT; |
276 | 276 | $client->use_gzip = MAGPIE_USE_GZIP; |
277 | - if (is_array($headers) ) { |
|
277 | + if (is_array($headers)) { |
|
278 | 278 | $client->rawheaders = $headers; |
279 | 279 | } |
280 | 280 | |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | Input: an HTTP response object (see Snoopy) |
290 | 290 | Output: parsed RSS object (see rss_parse) |
291 | 291 | \*=======================================================================*/ |
292 | -function _response_to_rss ($resp) { |
|
293 | - $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
|
292 | +function _response_to_rss($resp){ |
|
293 | + $rss = new MagpieRSS($resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING); |
|
294 | 294 | |
295 | 295 | // if RSS parsed successfully |
296 | - if ( $rss and !$rss->ERROR) { |
|
296 | + if ($rss and !$rss->ERROR) { |
|
297 | 297 | |
298 | 298 | // find Etag, and Last-Modified |
299 | - foreach($resp->headers as $h) { |
|
299 | + foreach ($resp->headers as $h) { |
|
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); |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | $val = ""; |
307 | 307 | } |
308 | 308 | |
309 | - if ( $field == 'ETag' ) { |
|
309 | + if ($field == 'ETag') { |
|
310 | 310 | $rss->etag = $val; |
311 | 311 | } |
312 | 312 | |
313 | - if ( $field == 'Last-Modified' ) { |
|
313 | + if ($field == 'Last-Modified') { |
|
314 | 314 | $rss->last_modified = $val; |
315 | 315 | } |
316 | 316 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $errormsg = "Failed to parse RSS file."; |
322 | 322 | |
323 | 323 | if ($rss) { |
324 | - $errormsg .= " (" . $rss->ERROR . ")"; |
|
324 | + $errormsg .= " (".$rss->ERROR.")"; |
|
325 | 325 | } |
326 | 326 | error($errormsg); |
327 | 327 | |
@@ -334,67 +334,67 @@ discard block |
||
334 | 334 | Purpose: setup constants with default values |
335 | 335 | check for user overrides |
336 | 336 | \*=======================================================================*/ |
337 | -function init () { |
|
338 | - if ( defined('MAGPIE_INITALIZED') ) { |
|
337 | +function init(){ |
|
338 | + if (defined('MAGPIE_INITALIZED')) { |
|
339 | 339 | return; |
340 | 340 | } |
341 | 341 | else { |
342 | 342 | define('MAGPIE_INITALIZED', true); |
343 | 343 | } |
344 | 344 | |
345 | - if ( !defined('MAGPIE_CACHE_ON') ) { |
|
345 | + if (!defined('MAGPIE_CACHE_ON')) { |
|
346 | 346 | define('MAGPIE_CACHE_ON', true); |
347 | 347 | } |
348 | 348 | |
349 | - if ( !defined('MAGPIE_CACHE_DIR') ) { |
|
349 | + if (!defined('MAGPIE_CACHE_DIR')) { |
|
350 | 350 | define('MAGPIE_CACHE_DIR', './cache'); |
351 | 351 | } |
352 | 352 | |
353 | - if ( !defined('MAGPIE_CACHE_AGE') ) { |
|
354 | - define('MAGPIE_CACHE_AGE', 60*60); // one hour |
|
353 | + if (!defined('MAGPIE_CACHE_AGE')) { |
|
354 | + define('MAGPIE_CACHE_AGE', 60 * 60); // one hour |
|
355 | 355 | } |
356 | 356 | |
357 | - if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { |
|
357 | + if (!defined('MAGPIE_CACHE_FRESH_ONLY')) { |
|
358 | 358 | define('MAGPIE_CACHE_FRESH_ONLY', false); |
359 | 359 | } |
360 | 360 | |
361 | - if ( !defined('MAGPIE_OUTPUT_ENCODING') ) { |
|
361 | + if (!defined('MAGPIE_OUTPUT_ENCODING')) { |
|
362 | 362 | global $modx_manager_charset; |
363 | - if(empty($modx_manager_charset)) $modx_manager_charset = 'ISO-8859-1'; |
|
363 | + if (empty($modx_manager_charset)) $modx_manager_charset = 'ISO-8859-1'; |
|
364 | 364 | define('MAGPIE_OUTPUT_ENCODING', $modx_manager_charset); |
365 | 365 | } |
366 | 366 | |
367 | - if ( !defined('MAGPIE_INPUT_ENCODING') ) { |
|
367 | + if (!defined('MAGPIE_INPUT_ENCODING')) { |
|
368 | 368 | define('MAGPIE_INPUT_ENCODING', null); |
369 | 369 | } |
370 | 370 | |
371 | - if ( !defined('MAGPIE_DETECT_ENCODING') ) { |
|
371 | + if (!defined('MAGPIE_DETECT_ENCODING')) { |
|
372 | 372 | define('MAGPIE_DETECT_ENCODING', true); |
373 | 373 | } |
374 | 374 | |
375 | - if ( !defined('MAGPIE_DEBUG') ) { |
|
375 | + if (!defined('MAGPIE_DEBUG')) { |
|
376 | 376 | define('MAGPIE_DEBUG', 0); |
377 | 377 | } |
378 | 378 | |
379 | - if ( !defined('MAGPIE_USER_AGENT') ) { |
|
380 | - $ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net'; |
|
379 | + if (!defined('MAGPIE_USER_AGENT')) { |
|
380 | + $ua = 'MagpieRSS/'.MAGPIE_VERSION.' (+http://magpierss.sf.net'; |
|
381 | 381 | |
382 | - if ( MAGPIE_CACHE_ON ) { |
|
383 | - $ua = $ua . ')'; |
|
382 | + if (MAGPIE_CACHE_ON) { |
|
383 | + $ua = $ua.')'; |
|
384 | 384 | } |
385 | 385 | else { |
386 | - $ua = $ua . '; No cache)'; |
|
386 | + $ua = $ua.'; No cache)'; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | define('MAGPIE_USER_AGENT', $ua); |
390 | 390 | } |
391 | 391 | |
392 | - if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { |
|
392 | + if (!defined('MAGPIE_FETCH_TIME_OUT')) { |
|
393 | 393 | define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout |
394 | 394 | } |
395 | 395 | |
396 | 396 | // use gzip encoding to fetch rss files if supported? |
397 | - if ( !defined('MAGPIE_USE_GZIP') ) { |
|
397 | + if (!defined('MAGPIE_USE_GZIP')) { |
|
398 | 398 | define('MAGPIE_USE_GZIP', true); |
399 | 399 | } |
400 | 400 | } |
@@ -417,7 +417,7 @@ 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 | return $sc >= 100 && $sc < 200; |
422 | 422 | } |
423 | 423 | |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | Function: is_success |
426 | 426 | Purpose: return true if Successful status code |
427 | 427 | \*=======================================================================*/ |
428 | -function is_success ($sc) { |
|
428 | +function is_success($sc){ |
|
429 | 429 | return $sc >= 200 && $sc < 300; |
430 | 430 | } |
431 | 431 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | Function: is_redirect |
434 | 434 | Purpose: return true if Redirection status code |
435 | 435 | \*=======================================================================*/ |
436 | -function is_redirect ($sc) { |
|
436 | +function is_redirect($sc){ |
|
437 | 437 | return $sc >= 300 && $sc < 400; |
438 | 438 | } |
439 | 439 | |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | Function: is_error |
442 | 442 | Purpose: return true if Error status code |
443 | 443 | \*=======================================================================*/ |
444 | -function is_error ($sc) { |
|
444 | +function is_error($sc){ |
|
445 | 445 | return $sc >= 400 && $sc < 600; |
446 | 446 | } |
447 | 447 | |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | Function: is_client_error |
450 | 450 | Purpose: return true if Error status code, and its a client error |
451 | 451 | \*=======================================================================*/ |
452 | -function is_client_error ($sc) { |
|
452 | +function is_client_error($sc){ |
|
453 | 453 | return $sc >= 400 && $sc < 500; |
454 | 454 | } |
455 | 455 | |
@@ -457,6 +457,6 @@ discard block |
||
457 | 457 | Function: is_client_error |
458 | 458 | Purpose: return true if Error status code, and its a server error |
459 | 459 | \*=======================================================================*/ |
460 | -function is_server_error ($sc) { |
|
460 | +function is_server_error($sc){ |
|
461 | 461 | return $sc >= 500 && $sc < 600; |
462 | 462 | } |
@@ -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,7 +224,8 @@ 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 |
@@ -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,7 +248,8 @@ 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 | 255 | if ( isset($errormsg) and $errormsg ) { |
@@ -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,6 +462,7 @@ 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 | } |