]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | <?php\r |
2 | // this is an example server-side proxy to load feeds\r | |
3 | $feed = $_REQUEST['feed'];\r | |
4 | if (!empty($feed) && preg_match('#((https?)://(\S*?\.\S*?))([\s)\[\]{},;"\':<]|\.\s|$)#i', $feed)) {\r | |
5 | header('Content-Type: text/xml');\r | |
6 | $xml = file_get_contents($feed);\r | |
7 | \r | |
8 | // Clean up our own RSS feeds\r | |
9 | if (strPos($feed, 'feeds.feedburner.com/sencha') || strPos($feed, 'sencha.com/forum')) {\r | |
10 | // Cut out extraneous whitespace to aid in checking for existing CDATA tags below\r | |
11 | $xml = preg_replace('/[\\n\\r]/', '', $xml);\r | |
12 | $xml = preg_replace('/>\s+</', '><', $xml);\r | |
13 | \r | |
14 | // Make textual items XML safe by enclosing them with CDATA sections unless it's already been done\r | |
15 | $xml = preg_replace('/<title>(?!<\\!\\[CDATA\\[)/', '<title><![CDATA[', $xml);\r | |
16 | $xml = preg_replace('/([^\\]][^\\]][^>])<\\/title>/', '$1]]></title>', $xml);\r | |
17 | $xml = preg_replace('/<author>(?!<\\!\\[CDATA\\[)/', '<author><![CDATA[', $xml);\r | |
18 | $xml = preg_replace('/([^\\]][^\\]][^>])<\\/author>/', '$1]]></author>', $xml);\r | |
19 | $xml = preg_replace('/<description>(?!<\\!\\[CDATA\\[)/', '<description><![CDATA[', $xml);\r | |
20 | $xml = preg_replace('/([^\\]][^\\]][^>])<\\/description>/', '$1]]></description>', $xml);\r | |
21 | $xml = preg_replace('/<link>(?!<\\!\\[CDATA\\[)/', '<link><![CDATA[', $xml);\r | |
22 | $xml = preg_replace('/([^\\]][^\\]][^>])<\\/link>/', '$1]]></link>', $xml);\r | |
23 | }\r | |
24 | \r | |
25 | $xml = str_replace('<content:encoded>', '<content>', $xml);\r | |
26 | $xml = str_replace('</content:encoded>', '</content>', $xml);\r | |
27 | $xml = str_replace('</dc:creator>', '</author>', $xml);\r | |
28 | echo str_replace('<dc:creator', '<author', $xml);\r | |
29 | return;\r | |
30 | }\r |