예제 #1
0
    $rssFeed->setLastBuildDate(date('Y-m-d'));
    // Set the feed webmaster
    $rssFeed->setWebMaster('*****@*****.**', 'John Doe');
    // Set the feed managing editor
    $rssFeed->setManagingEditor('*****@*****.**', 'John Doe');
    // Set the feed image
    $rssFeed->setImage('http://www.mywebsite.com/image/logo.jpg', 'My Logo', 'My blog', 100, 200);
    // Adding items
    $request = mysql_query('SELECT post_id, post_title, post_description, post_author_email, post_author_name, post_date FROM post WHERE post_valid=1 LIMIT 10');
    while ($row = mysql_fetch_object($request)) {
        // Creating a new feed item
        $rssItem = new RSSFeedItem();
        $rssItem->setTitle($row->post_title);
        $rssItem->setDescription($row->post_description);
        $rssItem->setLink('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id);
        $rssItem->setGuid('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id, true);
        $rssItem->setComments('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id . '#comments');
        $rssItem->setAuthor($row->post_author_email, $row->post_author_name);
        $rssItem->setPubDate($row->post_date);
        // Add the item to the feed
        $rssFeed->appendItem($rssItem);
    }
    // Save the feed
    $rssFeed->save();
    // SQL connection closing
    mysql_close();
    // Send headers to the browser
    header('Content-Type: text/xml; charset=utf-8');
    // Display the feed
    $rssFeed->display();
} catch (RSSFeedException $e) {
예제 #2
0
    $oRssItem->setTitle('Le cahier de textes est vide');
    $oRssItem->setDescription('Rien à afficher -> Il faut toujours revoir les leçons du jour.');
    $oRssItem->setLink($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php');
    $oRssItem->setGuid($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php', true);
    if (!empty($sEmail)) {
        $oRssItem->setAuthor($sEmail, 'ADMIN');
    }
    $oRssItem->setPubDate(date("Y-m-d h:i:s"));
    $oRssFeed->appendItem($oRssItem);
    $oRssItem = null;
} else {
    // Récupération de l'email
    //$sEmail = getSettingValue("gepiSchoolEmail");
    $sEmail = $rss_email_defaut;
    $oRssItem = new RSSFeedItem();
    $oRssItem->setTitle('ERREUR sur le CDT');
    $oRssItem->setDescription('Rien à afficher -> Il faut toujours apprendre les leçons du jour.');
    $oRssItem->setLink($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php');
    $oRssItem->setGuid($ServerProtocole . $_SERVER["SERVER_NAME"] . $gepiPath . '/login.php', true);
    if (!empty($sEmail)) {
        $oRssItem->setAuthor($sEmail, 'ADMIN');
    }
    $oRssItem->setPubDate(date("Y-m-d h:i:s"));
    $oRssFeed->appendItem($oRssItem);
    $oRssItem = null;
}
// Sauvegarde du flux RSS
$oRssFeed->save('../temp/rss-news.xml');
// Affichage sur la sortie standard
header('Content-Type: text/xml; charset=UTF-8');
$oRssFeed->display();