Skip to content
Snippets Groups Projects
planetposts.php 755 B
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    // number of recent planet entries we want to return
    $num_entries = 5;
    
    unset($result);
    $planetposts = array();
    
    
    $xmldata = @file_get_contents("../htdocs/planet/atom.xml");
    
    if (!$xmldata) {
    	trigger_error("No planet atom.xml data loaded", E_USER_WARNING);
    	return;
    } 
    
    
    $simplexml = simplexml_load_string($xmldata);
    $xml = $simplexml->children('http://www.w3.org/2005/Atom');
    
    foreach ($xml->entry as $entry) {
    	$planetposts[] = array(
    		"post" => $entry->title, 
    		"post_uri" => $entry->link->attributes()->href, 
    		"user" => $entry->author->name,
    		"user_uri" => $entry->author->uri
    		);
    }
    
    $planetposts = array_slice($planetposts, 0, $num_entries);
    
    $smarty->assign('planetposts', $planetposts);
    $result = $smarty->fetch('planetposts.tpl');
    
    ?>