]> git.mxchange.org Git - friendica.git/blob - library/simplepie/demo/index.php
Merge branch 'master' of https://github.com/friendica/friendica
[friendica.git] / library / simplepie / demo / index.php
1 <?php
2 // Start counting time for the page load
3 $starttime = explode(' ', microtime());
4 $starttime = $starttime[1] + $starttime[0];
5
6 // Include SimplePie
7 // Located in the parent directory
8 include_once('../simplepie.inc');
9 include_once('../idn/idna_convert.class.php');
10
11 // Create a new instance of the SimplePie object
12 $feed = new SimplePie();
13
14 //$feed->force_fsockopen(true);
15
16 // Make sure that page is getting passed a URL
17 if (isset($_GET['feed']) && $_GET['feed'] !== '')
18 {
19         // Strip slashes if magic quotes is enabled (which automatically escapes certain characters)
20         if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
21         {
22                 $_GET['feed'] = stripslashes($_GET['feed']);
23         }
24         
25         // Use the URL that was passed to the page in SimplePie
26         $feed->set_feed_url($_GET['feed']);
27         
28         // XML dump
29         $feed->enable_xml_dump(isset($_GET['xmldump']) ? true : false);
30 }
31
32 // Allow us to change the input encoding from the URL string if we want to. (optional)
33 if (!empty($_GET['input']))
34 {
35         $feed->set_input_encoding($_GET['input']);
36 }
37
38 // Allow us to choose to not re-order the items by date. (optional)
39 if (!empty($_GET['orderbydate']) && $_GET['orderbydate'] == 'false')
40 {
41         $feed->enable_order_by_date(false);
42 }
43
44 // Allow us to cache images in feeds.  This will also bypass any hotlink blocking put in place by the website.
45 if (!empty($_GET['image']) && $_GET['image'] == 'true')
46 {
47         $feed->set_image_handler('./handler_image.php');
48 }
49
50 // We'll enable the discovering and caching of favicons.
51 $feed->set_favicon_handler('./handler_image.php');
52
53 // Initialize the whole SimplePie object.  Read the feed, process it, parse it, cache it, and 
54 // all that other good stuff.  The feed's information will not be available to SimplePie before 
55 // this is called.
56 $success = $feed->init();
57
58 // We'll make sure that the right content type and character encoding gets set automatically.
59 // This function will grab the proper character encoding, as well as set the content type to text/html.
60 $feed->handle_content_type();
61
62 // When we end our PHP block, we want to make sure our DOCTYPE is on the top line to make 
63 // sure that the browser snaps into Standards Mode.
64 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
65
66 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
67 <head>
68 <title>SimplePie: Demo</title>
69
70 <link rel="stylesheet" href="./for_the_demo/sIFR-screen.css" type="text/css" media="screen">
71 <link rel="stylesheet" href="./for_the_demo/sIFR-print.css" type="text/css" media="print">
72 <link rel="stylesheet" href="./for_the_demo/simplepie.css" type="text/css" media="screen, projector" />
73
74 <script type="text/javascript" src="./for_the_demo/sifr.js"></script>
75 <script type="text/javascript" src="./for_the_demo/sifr-config.js"></script>
76 <script type="text/javascript" src="./for_the_demo/sleight.js"></script>
77
78 </head>
79
80 <body id="bodydemo">
81
82 <div id="header">
83         <div id="headerInner">
84                 <div id="logoContainer">
85                         <div id="logoContainerInner">
86                                 <div align="center"><a href="http://simplepie.org"><img src="./for_the_demo/logo_simplepie_demo.png" alt="SimplePie Demo: PHP-based RSS and Atom feed handling" title="SimplePie Demo: PHP-based RSS and Atom feed handling" border="0" /></a></div>
87                                 <div class="clearLeft"></div>
88                         </div>
89
90                 </div>
91                 <div id="menu">
92                 <!-- I know, I know, I know... tables for layout, I know.  If a web standards evangelist (like me) has to resort 
93                 to using tables for something, it's because no other possible solution could be found.  This issue?  No way to 
94                 do centered floats purely with CSS. The table box model allows for a dynamic width while centered, while the 
95                 CSS box model for DIVs doesn't allow for it. :( -->
96                 <table cellpadding="0" cellspacing="0" border="0"><tbody><tr><td>
97 <ul><li id="demo"><a href="./">SimplePie Demo</a></li><li><a href="http://simplepie.org/wiki/faq/start">FAQ/Troubleshooting</a></li><li><a href="http://simplepie.org/support/">Support Forums</a></li><li><a href="http://simplepie.org/wiki/reference/start">API Reference</a></li><li><a href="http://simplepie.org/blog/">Weblog</a></li><li><a href="../test/test.php">Unit Tests</a></li></ul>
98
99                         <div class="clearLeft"></div>
100                 </td></tr></tbody></table>
101                 </div>
102         </div>
103 </div>
104
105 <div id="site">
106
107         <div id="content">
108
109                 <div class="chunk">
110                         <form action="" method="get" name="sp_form" id="sp_form">
111                                 <div id="sp_input">
112
113
114                                         <!-- If a feed has already been passed through the form, then make sure that the URL remains in the form field. -->
115                                         <p><input type="text" name="feed" value="<?php if ($feed->subscribe_url()) echo $feed->subscribe_url(); ?>" class="text" id="feed_input" />&nbsp;<input type="submit" value="Read" class="button" /></p>
116
117
118                                 </div>
119                         </form>
120
121
122                         <?php
123                         // Check to see if there are more than zero errors (i.e. if there are any errors at all)
124                         if ($feed->error())
125                         {
126                                 // If so, start a <div> element with a classname so we can style it.
127                                 echo '<div class="sp_errors">' . "\r\n";
128
129                                         // ... and display it.
130                                         echo '<p>' . htmlspecialchars($feed->error()) . "</p>\r\n";
131
132                                 // Close the <div> element we opened.
133                                 echo '</div>' . "\r\n";
134                         }
135                         ?>
136
137                         <!-- Here are some sample feeds. -->
138                         <p class="sample_feeds"><strong>Or try one of the following:</strong> 
139                         <a href="?feed=http://www.詹姆斯.com/atomtests/iri/everything.atom" title="Test: International Domain Name support">詹姆斯.com</a>, 
140                         <a href="?feed=http://www.adultswim.com/williams/podcast/tools/xml/video_rss.xml" title="Humor from the people who make [adult swim] cartoons.">adult swim</a>, 
141                         <a href="?feed=http://afterdawn.com/news/afterdawn_rss.xml" title="Ripping, Burning, DRM, and the Dark Side of Consumer Electronics Media">Afterdawn</a>, 
142                         <a href="?feed=http://feeds.feedburner.com/ajaxian" title="AJAX and Scripting News">Ajaxian</a>, 
143                         <a href="?feed=http://www.andybudd.com/index.rdf&amp;image=true" title="Test: Bypass Image Hotlink Blocking">Andy Budd</a>, 
144                         <a href="?feed=http://feeds.feedburner.com/AskANinja" title="Test: Embedded Enclosures">Ask a Ninja</a>, 
145                         <a href="?feed=http://www.atomenabled.org/atom.xml" title="Test: Atom 1.0 Support">AtomEnabled.org</a>, 
146                         <a href="?feed=http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml" title="World News">BBC News</a>, 
147                         <a href="?feed=http://newsrss.bbc.co.uk/rss/arabic/news/rss.xml" title="Test: Windows-1256 Encoding">BBC Arabic</a>, 
148                         <a href="?feed=http://newsrss.bbc.co.uk/rss/chinese/simp/news/rss.xml" title="Test: GB2312 Encoding">BBC China</a>, 
149                         <a href="?feed=http://newsrss.bbc.co.uk/rss/russian/news/rss.xml" title="Test: Windows-1251 Encoding">BBC Russia</a>, 
150                         <a href="?feed=http://inessential.com/xml/rss.xml" title="Developer of NetNewsWire">Brent Simmons</a>, 
151                         <a href="?feed=http://www.channelfrederator.com/rss" title="Test: Embedded Enclosures">Channel Frederator</a>, 
152                         <a href="?feed=http://rss.cnn.com/rss/cnn_topstories.rss" title="World News">CNN</a>, 
153                         <a href="?feed=http://digg.com/rss/index.xml" title="Tech news. Better than Slashdot.">Digg</a>, 
154                         <a href="?feed=http://revision3.com/diggnation/feed/quicktime-large" title="Tech and industry videocast.">Diggnation</a>, 
155                         <a href="?feed=http://www.flickr.com/services/feeds/photos_public.gne?format=rss2" title="Flickr Photos">Flickr</a>, 
156                         <a href="?feed=http://news.google.com/?output=rss" title="World News">Google News</a>, 
157                         <a href="?feed=http://video.google.com/videofeed?type=top100new&num=20&output=rss" title="Test: Media RSS Support">Google Video</a>, 
158                         <a href="?feed=http://blogs.law.harvard.edu/home/feed/rdf/" title="Test: Tag Stripping">Harvard Law</a>, 
159                         <a href="?feed=http://hagada.org.il/hagada/html/backend.php" title="Test: Window-1255 Encoding">Hebrew Language</a>, 
160                         <a href="?feed=http://www.infoworld.com/rss/news.xml" title="Test: Ad Stripping">InfoWorld</a>, 
161                         <a href="?feed=http://phobos.apple.com/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/rss.xml&orderbydate=false" title="Test: Tag Stripping">iTunes</a>, 
162                         <a href="?feed=http://blog.japan.cnet.com/lessig/index.rdf" title="Test: EUC-JP Encoding">Japanese Language</a>, 
163                         <a href="?feed=http://nurapt.kaist.ac.kr/~jamaica/htmls/blog/rss.php&amp;input=EUC-KR" title="Test: EUC-KR Encoding">Korean Language</a>, 
164                         <a href="?feed=http://mir.aculo.us/xml/rss/feed.xml" title="Weblog for the developer of Scriptaculous">mir.aculo.us</a>, 
165                         <a href="?feed=http://images.apple.com/trailers/rss/newtrailers.rss" title="Apple's QuickTime movie trailer site">Movie Trailers</a>, 
166                         <a href="?feed=http://www.newspond.com/rss/main.xml" title="Tech and Science News">Newspond</a>, 
167                         <a href="?feed=http://nick.typepad.com/blog/index.rss" title="Developer of TopStyle and FeedDemon">Nick Bradbury</a>, 
168                         <a href="?feed=http://feeds.feedburner.com/ok-cancel" title="Usability comics and commentary">OK/Cancel</a>, 
169                         <a href="?feed=http://osnews.com/files/recent.rdf" title="News about every OS ever">OS News</a>, 
170                         <a href="?feed=http://weblog.philringnalda.com/feed/" title="Test: Atom 1.0 Support">Phil Ringnalda</a>, 
171                         <a href="?feed=http://kabili.libsyn.com/rss" title="Test: Improved enclosure type sniffing">Photoshop Videocast</a>, 
172                         <a href="?feed=http://www.pariurisportive.com/blog/xmlsrv/rss2.php?blog=2" title="Test: ISO-8859-1 Encoding">Romanian Language</a>, 
173                         <a href="?feed=http://www.erased.info/rss2.php" title="Test: KOI8-R Encoding">Russian Language</a>, 
174                         <a href="?feed=http://www.upsaid.com/isis/index.rdf" title="Test: BIG5 Encoding">Traditional Chinese Language</a>, 
175                         <a href="?feed=http://technorati.com/watchlists/rss.html?wid=29290" title="Technorati watch for SimplePie">Technorati</a>, 
176                         <a href="?feed=http://www.tbray.org/ongoing/ongoing.atom" title="Test: Atom 1.0 Support">Tim Bray</a>, 
177                         <a href="?feed=http://tuaw.com/rss.xml" title="Apple News">TUAW</a>, 
178                         <a href="?feed=http://www.tvgasm.com/atom.xml&amp;image=true" title="Test: Bypass Image Hotlink Blocking">TVgasm</a>, 
179                         <a href="?feed=http://uneasysilence.com/feed/" title="Interesting tech randomness">UNEASYsilence</a>, 
180                         <a href="?feed=http://feeds.feedburner.com/web20Show" title="Test: Embedded Enclosures">Web 2.0 Show</a>, 
181                         <a href="?feed=http://windowsvistablog.com/blogs/MainFeed.aspx" title="Test: Tag Stripping">Windows Vista Blog</a>, 
182                         <a href="?feed=http://xkcd.com/rss.xml" title="Test: LightHTTPd and GZipping">XKCD</a>, 
183                         <a href="?feed=http://rss.news.yahoo.com/rss/topstories" title="World News">Yahoo! News</a>, 
184                         <a href="?feed=http://youtube.com/rss/global/top_favorites.rss" title="Funny user-submitted videos">You Tube</a>, 
185                         <a href="?feed=http://zeldman.com/rss/" title="The father of the web standards movement">Zeldman</a></p>
186
187                 </div>
188
189                 <div id="sp_results">
190
191                         <!-- As long as the feed has data to work with... -->
192                         <?php if ($success): ?>
193                                 <div class="chunk focus" align="center">
194
195                                         <!-- If the feed has a link back to the site that publishes it (which 99% of them do), link the feed's title to it. -->
196                                         <h3 class="header"><?php if ($feed->get_link()) echo '<a href="' . $feed->get_link() . '">'; echo $feed->get_title(); if ($feed->get_link()) echo '</a>'; ?></h3>
197
198                                         <!-- If the feed has a description, display it. -->
199                                         <?php echo $feed->get_description(); ?>
200
201                                 </div>
202
203                                 <!-- Add subscribe links for several different aggregation services -->
204                                 <p class="subscribe"><strong>Subscribe:</strong> <a href="<?php echo $feed->subscribe_bloglines(); ?>">Bloglines</a>, <a href="<?php echo $feed->subscribe_google(); ?>">Google Reader</a>, <a href="<?php echo $feed->subscribe_msn(); ?>">My MSN</a>, <a href="<?php echo $feed->subscribe_netvibes(); ?>">Netvibes</a>, <a href="<?php echo $feed->subscribe_newsburst(); ?>">Newsburst</a><br /><a href="<?php echo $feed->subscribe_newsgator(); ?>">Newsgator</a>, <a href="<?php echo $feed->subscribe_odeo(); ?>">Odeo</a>, <a href="<?php echo $feed->subscribe_podnova(); ?>">Podnova</a>, <a href="<?php echo $feed->subscribe_rojo(); ?>">Rojo</a>, <a href="<?php echo $feed->subscribe_yahoo(); ?>">My Yahoo!</a>, <a href="<?php echo $feed->subscribe_feed(); ?>">Desktop Reader</a></p>
205
206
207                                 <!-- Let's begin looping through each individual news item in the feed. -->
208                                 <?php foreach($feed->get_items() as $item): ?>
209                                         <div class="chunk">
210
211                                                 <?php
212                                                 // Let's add a favicon for each item. If one doesn't exist, we'll use an alternate one.
213                                                 if (!$favicon = $feed->get_favicon())
214                                                 {
215                                                         $favicon = './for_the_demo/favicons/alternate.png';
216                                                 }
217                                                 ?>
218
219                                                 <!-- If the item has a permalink back to the original post (which 99% of them do), link the item's title to it. -->
220                                                 <h4><img src="<?php echo $favicon; ?>" alt="Favicon" class="favicon" /><?php if ($item->get_permalink()) echo '<a href="' . $item->get_permalink() . '">'; echo $item->get_title(); if ($item->get_permalink()) echo '</a>'; ?>&nbsp;<span class="footnote"><?php echo $item->get_date('j M Y, g:i a'); ?></span></h4>
221
222                                                 <!-- Display the item's primary content. -->
223                                                 <?php echo $item->get_content(); ?>
224
225                                                 <?php
226                                                 // Check for enclosures.  If an item has any, set the first one to the $enclosure variable.
227                                                 if ($enclosure = $item->get_enclosure(0))
228                                                 {
229                                                         // Use the embed() method to embed the enclosure into the page inline.
230                                                         echo '<div align="center">';
231                                                         echo '<p>' . $enclosure->embed(array(
232                                                                 'audio' => './for_the_demo/place_audio.png',
233                                                                 'video' => './for_the_demo/place_video.png',
234                                                                 'mediaplayer' => './for_the_demo/mediaplayer.swf',
235                                                                 'altclass' => 'download'
236                                                         )) . '</p>';
237
238                                                         if ($enclosure->get_link() && $enclosure->get_type())
239                                                         {
240                                                                 echo '<p class="footnote" align="center">(' . $enclosure->get_type();
241                                                                 if ($enclosure->get_size())
242                                                                 {
243                                                                         echo '; ' . $enclosure->get_size() . ' MB';                                                             
244                                                                 }
245                                                                 echo ')</p>';
246                                                         }
247                                                         if ($enclosure->get_thumbnail())
248                                                         {
249                                                                 echo '<div><img src="' . $enclosure->get_thumbnail() . '" alt="" /></div>';
250                                                         }
251                                                         echo '</div>';
252                                                 }
253                                                 ?>
254
255                                                 <!-- Add links to add this post to one of a handful of services. -->
256                                                 <p class="footnote favicons" align="center">
257                                                         <a href="<?php echo $item->add_to_blinklist(); ?>" title="Add post to Blinklist"><img src="./for_the_demo/favicons/blinklist.png" alt="Blinklist" /></a>
258                                                         <a href="<?php echo $item->add_to_blogmarks(); ?>" title="Add post to Blogmarks"><img src="./for_the_demo/favicons/blogmarks.png" alt="Blogmarks" /></a>
259                                                         <a href="<?php echo $item->add_to_delicious(); ?>" title="Add post to del.icio.us"><img src="./for_the_demo/favicons/delicious.png" alt="del.icio.us" /></a>
260                                                         <a href="<?php echo $item->add_to_digg(); ?>" title="Digg this!"><img src="./for_the_demo/favicons/digg.png" alt="Digg" /></a>
261                                                         <a href="<?php echo $item->add_to_magnolia(); ?>" title="Add post to Ma.gnolia"><img src="./for_the_demo/favicons/magnolia.png" alt="Ma.gnolia" /></a>
262                                                         <a href="<?php echo $item->add_to_myweb20(); ?>" title="Add post to My Web 2.0"><img src="./for_the_demo/favicons/myweb2.png" alt="My Web 2.0" /></a>
263                                                         <a href="<?php echo $item->add_to_newsvine(); ?>" title="Add post to Newsvine"><img src="./for_the_demo/favicons/newsvine.png" alt="Newsvine" /></a>
264                                                         <a href="<?php echo $item->add_to_reddit(); ?>" title="Add post to Reddit"><img src="./for_the_demo/favicons/reddit.png" alt="Reddit" /></a>
265                                                         <a href="<?php echo $item->add_to_segnalo(); ?>" title="Add post to Segnalo"><img src="./for_the_demo/favicons/segnalo.png" alt="Segnalo" /></a>
266                                                         <a href="<?php echo $item->add_to_simpy(); ?>" title="Add post to Simpy"><img src="./for_the_demo/favicons/simpy.png" alt="Simpy" /></a>
267                                                         <a href="<?php echo $item->add_to_spurl(); ?>" title="Add post to Spurl"><img src="./for_the_demo/favicons/spurl.png" alt="Spurl" /></a>
268                                                         <a href="<?php echo $item->add_to_wists(); ?>" title="Add post to Wists"><img src="./for_the_demo/favicons/wists.png" alt="Wists" /></a>
269                                                         <a href="<?php echo $item->search_technorati(); ?>" title="Who's linking to this post?"><img src="./for_the_demo/favicons/technorati.png" alt="Technorati" /></a>
270                                                 </p>
271
272                                         </div>
273
274                                 <!-- Stop looping through each item once we've gone through all of them. -->
275                                 <?php endforeach; ?>
276
277                         <!-- From here on, we're no longer using data from the feed. -->
278                         <?php endif; ?>
279
280                 </div>
281
282                 <div>
283                         <!-- Display how fast the page was rendered. -->
284                         <p class="footnote">Page processed in <?php $mtime = explode(' ', microtime()); echo round($mtime[0] + $mtime[1] - $starttime, 3); ?> seconds.</p>
285
286                         <!-- Display the version of SimplePie being loaded. -->
287                         <p class="footnote">Powered by <a href="<?php echo SIMPLEPIE_URL; ?>"><?php echo SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . ', Build ' . SIMPLEPIE_BUILD; ?></a>.  Run the <a href="../compatibility_test/sp_compatibility_test.php">SimplePie Compatibility Test</a>.  SimplePie is &copy; 2004&ndash;<?php echo date('Y'); ?>, Ryan Parman and Geoffrey Sneddon, and licensed under the <a href="http://www.opensource.org/licenses/bsd-license.php">BSD License</a>.</p>
288                 </div>
289
290         </div>
291
292 </div>
293
294 </body>
295 </html>