NP_RandomFeed.php (Code)

<?
 
/**
  * This plugin can be used to insert a random line of text on your page.
  *
  * History:
  *	  v1.0: initial plugin
  *       v1.1: support for multiple random files
  */
 
class NP_RandomFeed extends NucleusPlugin {
 
	/**
	  * Plugin data to be shown on the plugin list
	  */
	function getName() { 			return 'RandomFeed'; }
	function getURL()  { 			return 'http://www.xiffy.nl/weblog/'; }
	function getVersion() {			return '0.91'; }
	function getDescription() { 
		return 'Displays a random rssfeed from a text file by using &lt;%RandomFeed(feeds.txt)%&gt;. After that you can do a parsedinclude from $DIR_MEDIA/cache/randfeed.inc).';
	}
 
 
	function doSkinVar($skinType) {
		global $manager, $blog, $CONF, $DIR_MEDIA;
		$params = func_get_args();
 
        	$filename   = random.txt; // defaults to the file random.txt
 
		if ($params[1]){                        
            $filename = $params[1];
			$b =& $blog;
        } else if ($blog) $b =& $blog;
		  else $b =& $manager->getBlog($CONF['DefaultBlog']);
 
		// randomize
        srand((double)microtime()*1000000);
 
        $lines = file("$filename") ;
        $feed = $lines[array_rand($lines)];
        $feed = "<%Newsfeed(". trim($feed) .")%>";
        $incfile = $DIR_MEDIA. "/cache/random.inc";
 
	    $writer = @fopen($incfile, "w");
	    if ($writer) {
	        fwrite($writer, $feed);
	        fclose($writer);%0 GPS         }
	}
}
?>

:: Plugins ::

nprandomfeed.txt · Last modified: 2006/07/05 13:03 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki