/var/www/wordpress/wp-admin/includes/admin.php
/var/www/wordpress/wp-admin/includes/bookmark.php
/var/www/wordpress/wp-admin/includes/class-ftp-pure.php
/var/www/wordpress/wp-admin/includes/class-ftp-sockets.php
/var/www/wordpress/wp-admin/includes/class-ftp.php
/var/www/wordpress/wp-admin/includes/class-pclzip.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-base.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-direct.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php
/var/www/wordpress/wp-admin/includes/class-wp-importer.php
/var/www/wordpress/wp-admin/includes/class-wp-upgrader.php
/var/www/wordpress/wp-admin/includes/comment.php
/var/www/wordpress/wp-admin/includes/continents-cities.php
/var/www/wordpress/wp-admin/includes/dashboard.php
/var/www/wordpress/wp-admin/includes/deprecated.php
/var/www/wordpress/wp-admin/includes/export.php
/var/www/wordpress/wp-admin/includes/file.php
/var/www/wordpress/wp-admin/includes/image-edit.php
/var/www/wordpress/wp-admin/includes/image.php
/var/www/wordpress/wp-admin/includes/import.php
/var/www/wordpress/wp-admin/includes/manifest.php
/var/www/wordpress/wp-admin/includes/media.php
/var/www/wordpress/wp-admin/includes/meta-boxes.php
/var/www/wordpress/wp-admin/includes/misc.php
/var/www/wordpress/wp-admin/includes/ms-deprecated.php
/var/www/wordpress/wp-admin/includes/ms.php
/var/www/wordpress/wp-admin/includes/nav-menu.php
/var/www/wordpress/wp-admin/includes/plugin-install.php
/var/www/wordpress/wp-admin/includes/plugin.php
/var/www/wordpress/wp-admin/includes/post.php
/var/www/wordpress/wp-admin/includes/schema.php
/var/www/wordpress/wp-admin/includes/taxonomy.php
/var/www/wordpress/wp-admin/includes/template.php
/var/www/wordpress/wp-admin/includes/theme-install.php
/var/www/wordpress/wp-admin/includes/theme.php
/var/www/wordpress/wp-admin/includes/update-core.php
/var/www/wordpress/wp-admin/includes/update.php
/var/www/wordpress/wp-admin/includes/upgrade.php
/var/www/wordpress/wp-admin/includes/user.php
/var/www/wordpress/wp-admin/includes/widgets.php
/var/www/wordpress/wp-admin/js/revisions-js.php
/var/www/wordpress/wp-admin/maint/repair.php
/var/www/wordpress/wp-admin/admin-ajax.php
/var/www/wordpress/wp-admin/admin-footer.php
/var/www/wordpress/wp-admin/admin-functions.php
/var/www/wordpress/wp-admin/admin-header.php
/var/www/wordpress/wp-admin/admin-post.php
/var/www/wordpress/wp-admin/admin.php
/var/www/wordpress/wp-admin/async-upload.php
/var/www/wordpress/wp-admin/comment.php
/var/www/wordpress/wp-admin/custom-background.php
/var/www/wordpress/wp-admin/custom-header.php
/var/www/wordpress/wp-admin/edit-attachment-rows.php
/var/www/wordpress/wp-admin/edit-comments.php
/var/www/wordpress/wp-admin/edit-form-advanced.php
/var/www/wordpress/wp-admin/edit-form-comment.php
/var/www/wordpress/wp-admin/edit-link-categories.php
/var/www/wordpress/wp-admin/edit-link-category-form.php
/var/www/wordpress/wp-admin/edit-link-form.php
/var/www/wordpress/wp-admin/edit-post-rows.php
/var/www/wordpress/wp-admin/edit-tag-form.php
/var/www/wordpress/wp-admin/edit-tags.php
/var/www/wordpress/wp-admin/edit.php
/var/www/wordpress/wp-admin/export.php
/var/www/wordpress/wp-admin/gears-manifest.php
/var/www/wordpress/wp-admin/import.php
/var/www/wordpress/wp-admin/index-extra.php
/var/www/wordpress/wp-admin/index.php
/var/www/wordpress/wp-admin/install-helper.php
/var/www/wordpress/wp-admin/install.php
/var/www/wordpress/wp-admin/link-add.php
/var/www/wordpress/wp-admin/link-category.php
/var/www/wordpress/wp-admin/link-manager.php
/var/www/wordpress/wp-admin/link-parse-opml.php
/var/www/wordpress/wp-admin/link.php
/var/www/wordpress/wp-admin/load-scripts.php
/var/www/wordpress/wp-admin/load-styles.php
/var/www/wordpress/wp-admin/media-new.php
/var/www/wordpress/wp-admin/media-upload.php
/var/www/wordpress/wp-admin/media.php
/var/www/wordpress/wp-admin/menu-header.php
/var/www/wordpress/wp-admin/menu.php
/var/www/wordpress/wp-admin/moderation.php
/var/www/wordpress/wp-admin/ms-admin.php
/var/www/wordpress/wp-admin/ms-delete-site.php
/var/www/wordpress/wp-admin/ms-edit.php
/var/www/wordpress/wp-admin/ms-options.php
/var/www/wordpress/wp-admin/ms-sites.php
/var/www/wordpress/wp-admin/ms-themes.php
/var/www/wordpress/wp-admin/ms-upgrade-network.php
/var/www/wordpress/wp-admin/ms-users.php
/var/www/wordpress/wp-admin/my-sites.php
/var/www/wordpress/wp-admin/nav-menus.php
/var/www/wordpress/wp-admin/network.php
/var/www/wordpress/wp-admin/options-discussion.php
/var/www/wordpress/wp-admin/options-general.php
/var/www/wordpress/wp-admin/options-head.php
/var/www/wordpress/wp-admin/options-media.php
/var/www/wordpress/wp-admin/options-permalink.php
/var/www/wordpress/wp-admin/options-privacy.php
/var/www/wordpress/wp-admin/options-reading.php
/var/www/wordpress/wp-admin/options-writing.php
/var/www/wordpress/wp-admin/options.php
/var/www/wordpress/wp-admin/plugin-editor.php
/var/www/wordpress/wp-admin/plugin-install.php
/var/www/wordpress/wp-admin/plugins.php
/var/www/wordpress/wp-admin/post-new.php
/var/www/wordpress/wp-admin/post.php
/var/www/wordpress/wp-admin/press-this.php
/var/www/wordpress/wp-admin/profile.php
/var/www/wordpress/wp-admin/revision.php
/var/www/wordpress/wp-admin/setup-config.php
/var/www/wordpress/wp-admin/sidebar.php
/var/www/wordpress/wp-admin/theme-editor.php
/var/www/wordpress/wp-admin/theme-install.php
/var/www/wordpress/wp-admin/themes.php
/var/www/wordpress/wp-admin/tools.php
/var/www/wordpress/wp-admin/update-core.php
/var/www/wordpress/wp-admin/update.php
/var/www/wordpress/wp-admin/upgrade-functions.php
/var/www/wordpress/wp-admin/upgrade.php
/var/www/wordpress/wp-admin/upload.php
/var/www/wordpress/wp-admin/user-edit.php
/var/www/wordpress/wp-admin/user-new.php
/var/www/wordpress/wp-admin/users.php
/var/www/wordpress/wp-admin/widgets.php
/var/www/wordpress/wp-content/languages/ru_RU.php
/var/www/wordpress/wp-content/plugins/akismet/akismet.php
/var/www/wordpress/wp-content/plugins/rh/rh.php
/var/www/wordpress/wp-content/plugins/hello.php
/var/www/wordpress/wp-content/plugins/index.php
/var/www/wordpress/wp-content/themes/twentyten/404.php
/var/www/wordpress/wp-content/themes/twentyten/archive.php
/var/www/wordpress/wp-content/themes/twentyten/attachment.php
/var/www/wordpress/wp-content/themes/twentyten/author.php
/var/www/wordpress/wp-content/themes/twentyten/category.php
/var/www/wordpress/wp-content/themes/twentyten/comments.php
/var/www/wordpress/wp-content/themes/twentyten/footer.php
/var/www/wordpress/wp-content/themes/twentyten/functions.php
/var/www/wordpress/wp-content/themes/twentyten/header.php
/var/www/wordpress/wp-content/themes/twentyten/index.php
/var/www/wordpress/wp-content/themes/twentyten/loop.php
/var/www/wordpress/wp-content/themes/twentyten/onecolumn-page.php
/var/www/wordpress/wp-content/themes/twentyten/page.php
/var/www/wordpress/wp-content/themes/twentyten/search.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar-footer.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar.php
/var/www/wordpress/wp-content/themes/twentyten/single.php
/var/www/wordpress/wp-content/themes/twentyten/tag.php
/var/www/wordpress/wp-content/themes/index.php
/var/www/wordpress/wp-content/index.php
/var/www/wordpress/wp-includes/js/tinymce/langs/wp-langs.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/config.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/rpc.php
/var/www/wordpress/wp-includes/js/tinymce/wp-mce-help.php
/var/www/wordpress/wp-includes/js/tinymce/wp-tinymce.php
/var/www/wordpress/wp-includes/pomo/entry.php
/var/www/wordpress/wp-includes/pomo/mo.php
/var/www/wordpress/wp-includes/pomo/po.php
/var/www/wordpress/wp-includes/pomo/streams.php
/var/www/wordpress/wp-includes/pomo/translations.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/native.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/shell.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/string.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/xdiff.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer/inline.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer.php
/var/www/wordpress/wp-includes/Text/Diff.php
/var/www/wordpress/wp-includes/theme-compat/comments-popup.php
/var/www/wordpress/wp-includes/theme-compat/comments.php
/var/www/wordpress/wp-includes/theme-compat/footer.php
/var/www/wordpress/wp-includes/theme-compat/header.php
/var/www/wordpress/wp-includes/theme-compat/sidebar.php
/var/www/wordpress/wp-includes/atomlib.php
/var/www/wordpress/wp-includes/author-template.php
/var/www/wordpress/wp-includes/bookmark-template.php
/var/www/wordpress/wp-includes/bookmark.php
/var/www/wordpress/wp-includes/cache.php
/var/www/wordpress/wp-includes/canonical.php
/var/www/wordpress/wp-includes/capabilities.php
/var/www/wordpress/wp-includes/category-template.php
/var/www/wordpress/wp-includes/category.php
/var/www/wordpress/wp-includes/class-feed.php
/var/www/wordpress/wp-includes/class-http.php
/var/www/wordpress/wp-includes/class-IXR.php
/var/www/wordpress/wp-includes/class-json.php
/var/www/wordpress/wp-includes/class-oembed.php
/var/www/wordpress/wp-includes/class-phpass.php
/var/www/wordpress/wp-includes/class-phpmailer.php
/var/www/wordpress/wp-includes/class-pop3.php
/var/www/wordpress/wp-includes/class-simplepie.php
/var/www/wordpress/wp-includes/class-smtp.php
/var/www/wordpress/wp-includes/class-snoopy.php
/var/www/wordpress/wp-includes/class.wp-dependencies.php
/var/www/wordpress/wp-includes/class.wp-scripts.php
/var/www/wordpress/wp-includes/class.wp-styles.php
/var/www/wordpress/wp-includes/classes.php
/var/www/wordpress/wp-includes/comment-template.php
/var/www/wordpress/wp-includes/comment.php
/var/www/wordpress/wp-includes/compat.php
/var/www/wordpress/wp-includes/cron.php
/var/www/wordpress/wp-includes/default-constants.php
/var/www/wordpress/wp-includes/default-embeds.php
/var/www/wordpress/wp-includes/default-filters.php
/var/www/wordpress/wp-includes/default-widgets.php
/var/www/wordpress/wp-includes/deprecated.php
/var/www/wordpress/wp-includes/feed-atom-comments.php
/var/www/wordpress/wp-includes/feed-atom.php
/var/www/wordpress/wp-includes/feed-rdf.php
/var/www/wordpress/wp-includes/feed-rss.php
/var/www/wordpress/wp-includes/feed-rss2-comments.php
/var/www/wordpress/wp-includes/feed-rss2.php
/var/www/wordpress/wp-includes/feed.php
/var/www/wordpress/wp-includes/formatting.php
/var/www/wordpress/wp-includes/functions.php
/var/www/wordpress/wp-includes/functions.wp-scripts.php
/var/www/wordpress/wp-includes/functions.wp-styles.php
/var/www/wordpress/wp-includes/general-template.php
/var/www/wordpress/wp-includes/http.php
/var/www/wordpress/wp-includes/kses.php
/var/www/wordpress/wp-includes/l10n.php
/var/www/wordpress/wp-includes/link-template.php
/var/www/wordpress/wp-includes/load.php
/var/www/wordpress/wp-includes/locale.php
/var/www/wordpress/wp-includes/media.php
/var/www/wordpress/wp-includes/meta.php
/var/www/wordpress/wp-includes/ms-blogs.php
/var/www/wordpress/wp-includes/ms-default-constants.php
/var/www/wordpress/wp-includes/ms-default-filters.php
/var/www/wordpress/wp-includes/ms-deprecated.php
/var/www/wordpress/wp-includes/ms-files.php
/var/www/wordpress/wp-includes/ms-functions.php
/var/www/wordpress/wp-includes/ms-load.php
/var/www/wordpress/wp-includes/ms-settings.php
/var/www/wordpress/wp-includes/nav-menu-template.php
/var/www/wordpress/wp-includes/nav-menu.php
/var/www/wordpress/wp-includes/pluggable-deprecated.php
/var/www/wordpress/wp-includes/pluggable.php
/var/www/wordpress/wp-includes/plugin.php
/var/www/wordpress/wp-includes/post-template.php
/var/www/wordpress/wp-includes/post-thumbnail-template.php
/var/www/wordpress/wp-includes/post.php
/var/www/wordpress/wp-includes/query.php
/var/www/wordpress/wp-includes/registration-functions.php
/var/www/wordpress/wp-includes/registration.php
/var/www/wordpress/wp-includes/rewrite.php
/var/www/wordpress/wp-includes/rss-functions.php
/var/www/wordpress/wp-includes/rss.php
#CodeDescriptions
1<?php
2/**
3 * MagpieRSS: a simple RSS integration tool
4 *
5 * A compiled file for RSS syndication
6 *
7 * @author Kellan Elliott-McCrea <kellan@protest.net>
8 * @version 0.51
9 * @license GPL
10 *
11 * @package External
12 * @subpackage MagpieRSS
13 */
14
15/**
16 * Deprecated. Use SimplePie (class-simplepie.php) instead.
17 */
18_deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/class-simplepie.php' );
19
20/*
21 * Hook to use another RSS object instead of MagpieRSS
22 */
23do_action('load_feed_engine');
24
25/** RSS feed constant. */
26define('RSS', 'RSS');
27define('ATOM', 'Atom');
28define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']);
29
30class MagpieRSS {
31 var $parser;
32 var $current_item = array(); // item currently being parsed
33 var $items = array(); // collection of parsed items
34 var $channel = array(); // hash of channel fields
35 var $textinput = array();
36 var $image = array();
37 var $feed_type;
38 var $feed_version;
39
40 // parser variables
41 var $stack = array(); // parser stack
42 var $inchannel = false;
43 var $initem = false;
44 var $incontent = false; // if in Atom <content mode="xml"> field
45 var $intextinput = false;
46 var $inimage = false;
47 var $current_field = '';
48 var $current_namespace = false;
49
50 //var $ERROR = "";
51
52 var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
53
54 function MagpieRSS ($source) {
55
56 # if PHP xml isn't compiled in, die
57 #
58 if ( !function_exists('xml_parser_create') )
59 trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" );
60
61 $parser = @xml_parser_create();
62
63 if ( !is_resource($parser) )
64 trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php");
65
66
67 $this->parser = $parser;
68
69 # pass in parser, and a reference to this object
70 # set up handlers
71 #
72 xml_set_object( $this->parser, $this );
73 xml_set_element_handler($this->parser,
74 'feed_start_element', 'feed_end_element' );
75
76 xml_set_character_data_handler( $this->parser, 'feed_cdata' );
77
78 $status = xml_parse( $this->parser, $source );
79
80 if (! $status ) {
81 $errorcode = xml_get_error_code( $this->parser );
82 if ( $errorcode != XML_ERROR_NONE ) {
83 $xml_error = xml_error_string( $errorcode );
84 $error_line = xml_get_current_line_number($this->parser);
85 $error_col = xml_get_current_column_number($this->parser);
86 $errormsg = "$xml_error at line $error_line, column $error_col";
87
88 $this->error( $errormsg );
89 }
90 }
91
92 xml_parser_free( $this->parser );
93
94 $this->normalize();
95 }
96
97 function feed_start_element($p, $element, &$attrs) {
98 $el = $element = strtolower($element);
99 $attrs = array_change_key_case($attrs, CASE_LOWER);
100
101 // check for a namespace, and split if found
102 $ns = false;
103 if ( strpos( $element, ':' ) ) {
104 list($ns, $el) = split( ':', $element, 2);
105 }
106 if ( $ns and $ns != 'rdf' ) {
107 $this->current_namespace = $ns;
108 }
109
110 # if feed type isn't set, then this is first element of feed
111 # identify feed from root element
112 #
113 if (!isset($this->feed_type) ) {
114 if ( $el == 'rdf' ) {
115 $this->feed_type = RSS;
116 $this->feed_version = '1.0';
117 }
118 elseif ( $el == 'rss' ) {
119 $this->feed_type = RSS;
120 $this->feed_version = $attrs['version'];
121 }
122 elseif ( $el == 'feed' ) {
123 $this->feed_type = ATOM;
124 $this->feed_version = $attrs['version'];
125 $this->inchannel = true;
126 }
127 return;
128 }
129
130 if ( $el == 'channel' )
131 {
132 $this->inchannel = true;
133 }
134 elseif ($el == 'item' or $el == 'entry' )
135 {
136 $this->initem = true;
137 if ( isset($attrs['rdf:about']) ) {
138 $this->current_item['about'] = $attrs['rdf:about'];
139 }
140 }
141
142 // if we're in the default namespace of an RSS feed,
143 // record textinput or image fields
144 elseif (
145 $this->feed_type == RSS and
146 $this->current_namespace == '' and
147 $el == 'textinput' )
148 {
149 $this->intextinput = true;
150 }
151
152 elseif (
153 $this->feed_type == RSS and
154 $this->current_namespace == '' and
155 $el == 'image' )
156 {
157 $this->inimage = true;
158 }
159
160 # handle atom content constructs
161 elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
162 {
163 // avoid clashing w/ RSS mod_content
164 if ($el == 'content' ) {
165 $el = 'atom_content';
166 }
167
168 $this->incontent = $el;
169
170
171 }
172
173 // if inside an Atom content construct (e.g. content or summary) field treat tags as text
174 elseif ($this->feed_type == ATOM and $this->incontent )
175 {
176 // if tags are inlined, then flatten
177 $attrs_str = join(' ',
178 array_map(array('MagpieRSS', 'map_attrs'),
179 array_keys($attrs),
180 array_values($attrs) ) );
181
182 $this->append_content( "<$element $attrs_str>" );
183
184 array_unshift( $this->stack, $el );
185 }
186
187 // Atom support many links per containging element.
188 // Magpie treats link elements of type rel='alternate'
189 // as being equivalent to RSS's simple link element.
190 //
191 elseif ($this->feed_type == ATOM and $el == 'link' )
192 {
193 if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
194 {
195 $link_el = 'link';
196 }
197 else {
198 $link_el = 'link_' . $attrs['rel'];
199 }
200
201 $this->append($link_el, $attrs['href']);
202 }
203 // set stack[0] to current element
204 else {
205 array_unshift($this->stack, $el);
206 }
207 }
208
209
210
211 function feed_cdata ($p, $text) {
212
213 if ($this->feed_type == ATOM and $this->incontent)
214 {
215 $this->append_content( $text );
216 }
217 else {
218 $current_el = join('_', array_reverse($this->stack));
219 $this->append($current_el, $text);
220 }
221 }
222
223 function feed_end_element ($p, $el) {
224 $el = strtolower($el);
225
226 if ( $el == 'item' or $el == 'entry' )
227 {
228 $this->items[] = $this->current_item;
229 $this->current_item = array();
230 $this->initem = false;
231 }
232 elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
233 {
234 $this->intextinput = false;
235 }
236 elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
237 {
238 $this->inimage = false;
239 }
240 elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
241 {
242 $this->incontent = false;
243 }
244 elseif ($el == 'channel' or $el == 'feed' )
245 {
246 $this->inchannel = false;
247 }
248 elseif ($this->feed_type == ATOM and $this->incontent ) {
249 // balance tags properly
250 // note: i don't think this is actually neccessary
251 if ( $this->stack[0] == $el )
252 {
253 $this->append_content("</$el>");
254 }
255 else {
256 $this->append_content("<$el />");
257 }
258
259 array_shift( $this->stack );
260 }
261 else {
262 array_shift( $this->stack );
263 }
264
265 $this->current_namespace = false;
266 }
267
268 function concat (&$str1, $str2="") {
269 if (!isset($str1) ) {
270 $str1="";
271 }
272 $str1 .= $str2;
273 }
274
275 function append_content($text) {
276 if ( $this->initem ) {
277 $this->concat( $this->current_item[ $this->incontent ], $text );
278 }
279 elseif ( $this->inchannel ) {
280 $this->concat( $this->channel[ $this->incontent ], $text );
281 }
282 }
283
284 // smart append - field and namespace aware
285 function append($el, $text) {
286 if (!$el) {
287 return;
288 }
289 if ( $this->current_namespace )
290 {
291 if ( $this->initem ) {
292 $this->concat(
293 $this->current_item[ $this->current_namespace ][ $el ], $text);
294 }
295 elseif ($this->inchannel) {
296 $this->concat(
297 $this->channel[ $this->current_namespace][ $el ], $text );
298 }
299 elseif ($this->intextinput) {
300 $this->concat(
301 $this->textinput[ $this->current_namespace][ $el ], $text );
302 }
303 elseif ($this->inimage) {
304 $this->concat(
305 $this->image[ $this->current_namespace ][ $el ], $text );
306 }
307 }
308 else {
309 if ( $this->initem ) {
310 $this->concat(
311 $this->current_item[ $el ], $text);
312 }
313 elseif ($this->intextinput) {
314 $this->concat(
315 $this->textinput[ $el ], $text );
316 }
317 elseif ($this->inimage) {
318 $this->concat(
319 $this->image[ $el ], $text );
320 }
321 elseif ($this->inchannel) {
322 $this->concat(
323 $this->channel[ $el ], $text );
324 }
325
326 }
327 }
328
329 function normalize () {
330 // if atom populate rss fields
331 if ( $this->is_atom() ) {
332 $this->channel['descripton'] = $this->channel['tagline'];
333 for ( $i = 0; $i < count($this->items); $i++) {
334 $item = $this->items[$i];
335 if ( isset($item['summary']) )
336 $item['description'] = $item['summary'];
337 if ( isset($item['atom_content']))
338 $item['content']['encoded'] = $item['atom_content'];
339
340 $this->items[$i] = $item;
341 }
342 }
343 elseif ( $this->is_rss() ) {
344 $this->channel['tagline'] = $this->channel['description'];
345 for ( $i = 0; $i < count($this->items); $i++) {
346 $item = $this->items[$i];
347 if ( isset($item['description']))
348 $item['summary'] = $item['description'];
349 if ( isset($item['content']['encoded'] ) )
350 $item['atom_content'] = $item['content']['encoded'];
351
352 $this->items[$i] = $item;
353 }
354 }
355 }
356
357 function is_rss () {
358 if ( $this->feed_type == RSS ) {
359 return $this->feed_version;
360 }
361 else {
362 return false;
363 }
364 }
365
366 function is_atom() {
367 if ( $this->feed_type == ATOM ) {
368 return $this->feed_version;
369 }
370 else {
371 return false;
372 }
373 }
374
375 function map_attrs($k, $v) {
376 return "$k=\"$v\"";
377 }
378
379 function error( $errormsg, $lvl = E_USER_WARNING ) {
380 // append PHP's error message if track_errors enabled
381 if ( isset($php_errormsg) ) {
382 $errormsg .= " ($php_errormsg)";
383 }
384 if ( MAGPIE_DEBUG ) {
385 trigger_error( $errormsg, $lvl);
386 } else {
387 error_log( $errormsg, 0);//Connection Handling
388 }
389 }
390
391}
392
393if ( !function_exists('fetch_rss') ) :
394/**
395 * Build Magpie object based on RSS from URL.
396 *
397 * @since unknown
398 * @package External
399 * @subpackage MagpieRSS
400 *
401 * @param string $url URL to retrieve feed
402 * @return bool|MagpieRSS false on failure or MagpieRSS object on success.
403 */
404function fetch_rss ($url) {
405 // initialize constants
406 init();
407
408 if ( !isset($url) ) {
409 // error("fetch_rss called without a url");
410 return false;
411 }
412
413 // if cache is disabled
414 if ( !MAGPIE_CACHE_ON ) {
415 // fetch file, and parse it
416 $resp = _fetch_remote_file( $url );//Arbitrary file disclosing
417 if ( is_success( $resp->status ) ) {
418 return _response_to_rss( $resp );
419 }
420 else {
421 // error("Failed to fetch $url and cache is off");
422 return false;
423 }
424 }
425 // else cache is ON
426 else {
427 // Flow
428 // 1. check cache
429 // 2. if there is a hit, make sure its fresh
430 // 3. if cached obj fails freshness check, fetch remote
431 // 4. if remote fails, return stale object, or error
432
433 $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
434
435 if (MAGPIE_DEBUG and $cache->ERROR) {
436 debug($cache->ERROR, E_USER_WARNING);
437 }
438
439
440 $cache_status = 0; // response of check_cache
441 $request_headers = array(); // HTTP headers to send with fetch
442 $rss = 0; // parsed RSS object
443 $errormsg = 0; // errors, if any
444
445 if (!$cache->ERROR) {
446 // return cache HIT, MISS, or STALE
447 $cache_status = $cache->check_cache( $url );
448 }
449
450 // if object cached, and cache is fresh, return cached obj
451 if ( $cache_status == 'HIT' ) {
452 $rss = $cache->get( $url );
453 if ( isset($rss) and $rss ) {
454 $rss->from_cache = 1;
455 if ( MAGPIE_DEBUG > 1) {
456 debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
457 }
458 return $rss;
459 }
460 }
461
462 // else attempt a conditional get
463
464 // set up headers
465 if ( $cache_status == 'STALE' ) {
466 $rss = $cache->get( $url );
467 if ( isset($rss->etag) and $rss->last_modified ) {
468 $request_headers['If-None-Match'] = $rss->etag;
469 $request_headers['If-Last-Modified'] = $rss->last_modified;
470 }
471 }
472
473 $resp = _fetch_remote_file( $url, $request_headers );//Arbitrary file disclosing
474
475 if (isset($resp) and $resp) {
476 if ($resp->status == '304' ) {
477 // we have the most current copy
478 if ( MAGPIE_DEBUG > 1) {
479 debug("Got 304 for $url");
480 }
481 // reset cache on 304 (at minutillo insistent prodding)
482 $cache->set($url, $rss);
483 return $rss;
484 }
485 elseif ( is_success( $resp->status ) ) {
486 $rss = _response_to_rss( $resp );
487 if ( $rss ) {
488 if (MAGPIE_DEBUG > 1) {
489 debug("Fetch successful");
490 }
491 // add object to cache
492 $cache->set( $url, $rss );
493 return $rss;
494 }
495 }
496 else {
497 $errormsg = "Failed to fetch $url. ";
498 if ( $resp->error ) {
499 # compensate for Snoopy's annoying habbit to tacking
500 # on '\n'
501 $http_error = substr($resp->error, 0, -2);
502 $errormsg .= "(HTTP Error: $http_error)";
503 }
504 else {
505 $errormsg .= "(HTTP Response: " . $resp->response_code .')';
506 }
507 }
508 }
509 else {
510 $errormsg = "Unable to retrieve RSS file for unknown reasons.";
511 }
512
513 // else fetch failed
514
515 // attempt to return cached object
516 if ($rss) {
517 if ( MAGPIE_DEBUG ) {
518 debug("Returning STALE object for $url");
519 }
520 return $rss;
521 }
522
523 // else we totally failed
524 // error( $errormsg );
525
526 return false;
527
528 } // end if ( !MAGPIE_CACHE_ON ) {
529} // end fetch_rss()
530endif;
531
532/**
533 * Retrieve URL headers and content using WP HTTP Request API.
534 *
535 * @since unknown
536 * @package External
537 * @subpackage MagpieRSS
538 *
539 * @param string $url URL to retrieve
540 * @param array $headers Optional. Headers to send to the URL.
541 * @return Snoopy style response
542 */
543function _fetch_remote_file($url, $headers = "" ) {
544 $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
545 if ( is_wp_error($resp) ) {
546 $error = array_shift($resp->errors);
547
548 $resp = new stdClass;
549 $resp->status = 500;
550 $resp->response_code = 500;
551 $resp->error = $error[0] . "\n"; //\n = Snoopy compatibility
552 return $resp;
553 }
554
555 // Snoopy returns headers unprocessed.
556 // Also note, WP_HTTP lowercases all keys, Snoopy did not.
557 $return_headers = array();
558 foreach ( $resp['headers'] as $key => $value ) {
559 if ( !is_array($value) ) {
560 $return_headers[] = "$key: $value";
561 } else {
562 foreach ( $value as $v )
563 $return_headers[] = "$key: $v";
564 }
565 }
566
567 $response = new stdClass;
568 $response->status = $resp['response']['code'];
569 $response->response_code = $resp['response']['code'];
570 $response->headers = $return_headers;
571 $response->results = $resp['body'];
572
573 return $response;
574}
575
576/**
577 * Retrieve
578 *
579 * @since unknown
580 * @package External
581 * @subpackage MagpieRSS
582 *
583 * @param unknown_type $resp
584 * @return unknown
585 */
586function _response_to_rss ($resp) {
587 $rss = new MagpieRSS( $resp->results );
588
589 // if RSS parsed successfully
590 if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) {
591
592 // find Etag, and Last-Modified
593 foreach( (array) $resp->headers as $h) {
594 // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
595 if (strpos($h, ": ")) {
596 list($field, $val) = explode(": ", $h, 2);
597 }
598 else {
599 $field = $h;
600 $val = "";
601 }
602
603 if ( $field == 'etag' ) {
604 $rss->etag = $val;
605 }
606
607 if ( $field == 'last-modified' ) {
608 $rss->last_modified = $val;
609 }
610 }
611
612 return $rss;
613 } // else construct error message
614 else {
615 $errormsg = "Failed to parse RSS file.";
616
617 if ($rss) {
618 $errormsg .= " (" . $rss->ERROR . ")";
619 }
620 // error($errormsg);
621
622 return false;
623 } // end if ($rss and !$rss->error)
624}
625
626/**
627 * Set up constants with default values, unless user overrides.
628 *
629 * @since unknown
630 * @package External
631 * @subpackage MagpieRSS
632 */
633function init () {
634 if ( defined('MAGPIE_INITALIZED') ) {
635 return;
636 }
637 else {
638 define('MAGPIE_INITALIZED', 1);
639 }
640
641 if ( !defined('MAGPIE_CACHE_ON') ) {
642 define('MAGPIE_CACHE_ON', 1);
643 }
644
645 if ( !defined('MAGPIE_CACHE_DIR') ) {
646 define('MAGPIE_CACHE_DIR', './cache');
647 }
648
649 if ( !defined('MAGPIE_CACHE_AGE') ) {
650 define('MAGPIE_CACHE_AGE', 60*60); // one hour
651 }
652
653 if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
654 define('MAGPIE_CACHE_FRESH_ONLY', 0);
655 }
656
657 if ( !defined('MAGPIE_DEBUG') ) {
658 define('MAGPIE_DEBUG', 0);
659 }
660
661 if ( !defined('MAGPIE_USER_AGENT') ) {
662 $ua = 'WordPress/' . $GLOBALS['wp_version'];
663
664 if ( MAGPIE_CACHE_ON ) {
665 $ua = $ua . ')';
666 }
667 else {
668 $ua = $ua . '; No cache)';
669 }
670
671 define('MAGPIE_USER_AGENT', $ua);
672 }
673
674 if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
675 define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout
676 }
677
678 // use gzip encoding to fetch rss files if supported?
679 if ( !defined('MAGPIE_USE_GZIP') ) {
680 define('MAGPIE_USE_GZIP', true);
681 }
682}
683
684function is_info ($sc) {
685 return $sc >= 100 && $sc < 200;
686}
687
688function is_success ($sc) {
689 return $sc >= 200 && $sc < 300;
690}
691
692function is_redirect ($sc) {
693 return $sc >= 300 && $sc < 400;
694}
695
696function is_error ($sc) {
697 return $sc >= 400 && $sc < 600;
698}
699
700function is_client_error ($sc) {
701 return $sc >= 400 && $sc < 500;
702}
703
704function is_server_error ($sc) {
705 return $sc >= 500 && $sc < 600;
706}
707
708class RSSCache {
709 var $BASE_CACHE; // where the cache files are stored
710 var $MAX_AGE = 43200; // when are files stale, default twelve hours
711 var $ERROR = ''; // accumulate error messages
712
713 function RSSCache ($base='', $age='') {
714 $this->BASE_CACHE = WP_CONTENT_DIR . '/cache';
715 if ( $base ) {
716 $this->BASE_CACHE = $base;
717 }
718 if ( $age ) {
719 $this->MAX_AGE = $age;
720 }
721
722 }
723
724/*=======================================================================*\
725 Function: set
726 Purpose: add an item to the cache, keyed on url
727 Input: url from wich the rss file was fetched
728 Output: true on sucess
729\*=======================================================================*/
730 function set ($url, $rss) {
731 $cache_option = 'rss_' . $this->file_name( $url );
732
733 set_transient($cache_option, $rss, $this->MAX_AGE);
734
735 return $cache_option;
736 }
737
738/*=======================================================================*\
739 Function: get
740 Purpose: fetch an item from the cache
741 Input: url from wich the rss file was fetched
742 Output: cached object on HIT, false on MISS
743\*=======================================================================*/
744 function get ($url) {
745 $this->ERROR = "";
746 $cache_option = 'rss_' . $this->file_name( $url );
747
748 if ( ! $rss = get_transient( $cache_option ) ) {
749 $this->debug(
750 "Cache doesn't contain: $url (cache option: $cache_option)"
751 );
752 return 0;
753 }
754
755 return $rss;
756 }
757
758/*=======================================================================*\
759 Function: check_cache
760 Purpose: check a url for membership in the cache
761 and whether the object is older then MAX_AGE (ie. STALE)
762 Input: url from wich the rss file was fetched
763 Output: cached object on HIT, false on MISS
764\*=======================================================================*/
765 function check_cache ( $url ) {
766 $this->ERROR = "";
767 $cache_option = 'rss_' . $this->file_name( $url );
768
769 if ( get_transient($cache_option) ) {
770 // object exists and is current
771 return 'HIT';
772 } else {
773 // object does not exist
774 return 'MISS';
775 }
776 }
777
778/*=======================================================================*\
779 Function: serialize
780\*=======================================================================*/
781 function serialize ( $rss ) {
782 return serialize( $rss );
783 }
784
785/*=======================================================================*\
786 Function: unserialize
787\*=======================================================================*/
788 function unserialize ( $data ) {
789 return unserialize( $data );//Possible Control Flow
790 }
791
792/*=======================================================================*\
793 Function: file_name
794 Purpose: map url to location in cache
795 Input: url from wich the rss file was fetched
796 Output: a file name
797\*=======================================================================*/
798 function file_name ($url) {
799 return md5( $url );
800 }
801
802/*=======================================================================*\
803 Function: error
804 Purpose: register error
805\*=======================================================================*/
806 function error ($errormsg, $lvl=E_USER_WARNING) {
807 // append PHP's error message if track_errors enabled
808 if ( isset($php_errormsg) ) {
809 $errormsg .= " ($php_errormsg)";
810 }
811 $this->ERROR = $errormsg;
812 if ( MAGPIE_DEBUG ) {
813 trigger_error( $errormsg, $lvl);
814 }
815 else {
816 error_log( $errormsg, 0);//Connection Handling
817 }
818 }
819 function debug ($debugmsg, $lvl=E_USER_NOTICE) {
820 if ( MAGPIE_DEBUG ) {
821 $this->error("MagpieRSS [debug] $debugmsg", $lvl);
822 }
823 }
824}
825
826if ( !function_exists('parse_w3cdtf') ) :
827function parse_w3cdtf ( $date_str ) {
828
829 # regex to match wc3dtf
830 $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
831
832 if ( preg_match( $pat, $date_str, $match ) ) {
833 list( $year, $month, $day, $hours, $minutes, $seconds) =
834 array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[7]);
835
836 # calc epoch for current date assuming GMT
837 $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
838
839 $offset = 0;
840 if ( $match[11] == 'Z' ) {
841 # zulu time, aka GMT
842 }
843 else {
844 list( $tz_mod, $tz_hour, $tz_min ) =
845 array( $match[8], $match[9], $match[10]);
846
847 # zero out the variables
848 if ( ! $tz_hour ) { $tz_hour = 0; }
849 if ( ! $tz_min ) { $tz_min = 0; }
850
851 $offset_secs = (($tz_hour*60)+$tz_min)*60;
852
853 # is timezone ahead of GMT? then subtract offset
854 #
855 if ( $tz_mod == '+' ) {
856 $offset_secs = $offset_secs * -1;
857 }
858
859 $offset = $offset_secs;
860 }
861 $epoch = $epoch + $offset;
862 return $epoch;
863 }
864 else {
865 return -1;
866 }
867}
868endif;
869
870if ( !function_exists('wp_rss') ) :
871/**
872 * Display all RSS items in a HTML ordered list.
873 *
874 * @since unknown
875 * @package External
876 * @subpackage MagpieRSS
877 *
878 * @param string $url URL of feed to display. Will not auto sense feed URL.
879 * @param int $num_items Optional. Number of items to display, default is all.
880 */
881function wp_rss( $url, $num_items = -1 ) {
882 if ( $rss = fetch_rss( $url ) ) {
883 echo '<ul>';
884
885 if ( $num_items !== -1 ) {
886 $rss->items = array_slice( $rss->items, 0, $num_items );
887 }
888
889 foreach ( (array) $rss->items as $item ) {
890 printf(
891 '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
892 esc_url( $item['link'] ),
893 esc_attr( strip_tags( $item['description'] ) ),
894 htmlentities( $item['title'] )
895 );
896 }
897
898 echo '</ul>';
899 } else {
900 _e( 'An error has occurred, which probably means the feed is down. Try again later.' );
901 }
902}
903endif;
904
905if ( !function_exists('get_rss') ) :
906/**
907 * Display RSS items in HTML list items.
908 *
909 * You have to specify which HTML list you want, either ordered or unordered
910 * before using the function. You also have to specify how many items you wish
911 * to display. You can't display all of them like you can with wp_rss()
912 * function.
913 *
914 * @since unknown
915 * @package External
916 * @subpackage MagpieRSS
917 *
918 * @param string $url URL of feed to display. Will not auto sense feed URL.
919 * @param int $num_items Optional. Number of items to display, default is all.
920 * @return bool False on failure.
921 */
922function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
923 $rss = fetch_rss($url);
924 if ( $rss ) {
925 $rss->items = array_slice($rss->items, 0, $num_items);
926 foreach ( (array) $rss->items as $item ) {
927 echo "<li>\n";
928 echo "<a href='$item[link]' title='$item[description]'>";
929 echo htmlentities($item['title']);
930 echo "</a><br />\n";
931 echo "</li>\n";
932 }
933 } else {
934 return false;
935 }
936}
937endif;
938
939?>
940
/var/www/wordpress/wp-includes/script-loader.php
/var/www/wordpress/wp-includes/shortcodes.php
/var/www/wordpress/wp-includes/taxonomy.php
/var/www/wordpress/wp-includes/template-loader.php
/var/www/wordpress/wp-includes/theme.php
/var/www/wordpress/wp-includes/update.php
/var/www/wordpress/wp-includes/user.php
/var/www/wordpress/wp-includes/vars.php
/var/www/wordpress/wp-includes/version.php
/var/www/wordpress/wp-includes/widgets.php
/var/www/wordpress/wp-includes/wp-db.php
/var/www/wordpress/wp-includes/wp-diff.php
/var/www/wordpress/index.php
/var/www/wordpress/wp-activate.php
/var/www/wordpress/wp-app.php
/var/www/wordpress/wp-atom.php
/var/www/wordpress/wp-blog-header.php
/var/www/wordpress/wp-comments-post.php
/var/www/wordpress/wp-commentsrss2.php
/var/www/wordpress/wp-config-sample.php
/var/www/wordpress/wp-cron.php
/var/www/wordpress/wp-feed.php
/var/www/wordpress/wp-links-opml.php
/var/www/wordpress/wp-load.php
/var/www/wordpress/wp-login.php
/var/www/wordpress/wp-mail.php
/var/www/wordpress/wp-pass.php
/var/www/wordpress/wp-rdf.php
/var/www/wordpress/wp-register.php
/var/www/wordpress/wp-rss.php
/var/www/wordpress/wp-rss2.php
/var/www/wordpress/wp-settings.php
/var/www/wordpress/wp-signup.php
/var/www/wordpress/wp-trackback.php
/var/www/wordpress/xmlrpc.php