All pastes #258216 Raw Edit

Sid

public php v1 · immutable
#258216 ·published 2006-11-26 07:33 UTC
rendered paste body
<?phpfunction simplenow($feedurl, $articles){// Include SimplePie// Located in the parent directoryinclude_once('simplepie/simplepie.inc');include_once('simplepie/idn/idna_convert.class.php');// Create a new instance of the SimplePie object$feed = new SimplePie();// Set these Configuration Options$feed->strip_ads(true);//$_GET['feed'] = $feedurl// Make sure that page is getting passed a URLif (!empty($feedurl)) {	// Strip slashes if magic quotes is enabled (which automatically escapes certain characters)	if (get_magic_quotes_gpc())	{		$feedurl = stripslashes($feedurl);	}		// Use the URL that was passed to the page in SimplePie	$feed->feed_url($feedurl);}// Allow us to change the input encoding from the URL string if we want to. (optional)if (!empty($_GET['input'])) {	$feed->input_encoding($_GET['input']);}// Allow us to snap into IHBB mode.if (!empty($_GET['image'])) {	$feed->bypass_image_hotlink('i');	$feed->bypass_image_hotlink_page('./ihbb.php');}// Initialize the whole SimplePie object.  Read the feed, process it, parse it, cache it, and // all that other good stuff.  The feed's information will not be available to SimplePie before // this is called.$feed->init();// We'll make sure that the right content type and character encoding gets set automatically.// This function will grab the proper character encoding, as well as set the content type to text/html.$feed->handle_content_type();// When we end our PHP block, we want to make sure our DOCTYPE is on the top line to make // sure that the browser snaps into Standards Mode.?>					<span id="feedurl" style="display: none;">Feed URL:</strong>&nbsp;<?php if ($feed->subscribe_url()) echo htmlspecialchars($feed->subscribe_url()); ?></span>			<?php			// Check to see if there are more than zero errors (i.e. if there are any errors at all)			if (isset($feed->error)) {				// If so, start a <div> element with a classname so we can style it.				echo '<div class="sp_errors" style="display: none;">' . "\r\n";					// ... and display it.					echo '<p>' . htmlspecialchars($feed->error) . "</p>\r\n";				// Close the <div> element we opened.				echo '</div>' . "\r\n";			}			?>		<div id="results">			<?php if ($feed->data): ?>				<div>					<span id="feedname" style="display: none;"><?php if ($feed->get_feed_link()) 					echo '<a href="' . $feed->get_feed_link() . '">';					echo $feed->get_feed_title(); 					if ($feed->get_feed_link()) 						echo '</a>'; ?></span>					<?php echo $feed->get_feed_description(); ?>				</div>				<?php 			/*	if ($articles = 'all';){				foreach($feed->get_items() as $item): }				else { */			/*	if(isset($articles)){				$articles = $disarticles;				$disarticles = strip_tags($disartcles);			}			else {				$disarticles = "5";			}*/								$items = $feed->get_items();				if (empty($items[0]))				{					echo <<< ERROR					<div class="chunk">						There was an error while reading the RSS feed and we're calling it quits.					</div>ERROR;					die();				}				$articles = ($articles > count($items))? count($items):$articles;				for ($i=0; $i<$articles; $i++):					$item = $items[$i];						//	}		//		else {										$item->get_permalink();				?>					<div class="chunk">												<h4><?php if ($item->get_permalink()) echo '<a href="' . $item->get_permalink() . '">'; echo $item->get_title(); if ($item->get_permalink()) echo '</a>'; ?>&nbsp;<span class="date"><?php echo $item->get_date('j M Y'); ?></span></h4>						<?php echo $item->get_description(); ?>						<?php						// Check for enclosures.  If an item has any, set the first one to the $enclosure variable.						if ($enclosure = $item->get_enclosure(0)) {							// Use the embed() method to embed the enclosure into the page inline.							echo '<div align="center">';							echo '<p>' . $enclosure->embed(array(								'audio' => './for_the_demo/place_audio.png',								'video' => './for_the_demo/place_video.png',								'alt' => '<img src="./for_the_demo/mini_podcast.png" class="download" border="0" title="Download the Podcast (' . $enclosure->get_extension() . '; ' . $enclosure->get_size() . ' MB)" />',								'altclass' => 'download'							)) . '</p>';							echo '<p class="footnote" align="center">(' . $enclosure->get_type() . '; ' . $enclosure->get_size() . ' MB)</p>';							echo '</div>';						}							//				}						?>										</div>				<?php endfor; ?>			<?php endif; ?>		</div>	</div><?php } ?>