示例#1
0
use FeedWriter\RSS2;
if ($_GET['id']) {
    $name = $_GET['id'];
    $sql = "SELECT * FROM list WHERE name = '{$name}'";
    mysql_query('set names utf8');
    mysql_query("set character set 'utf8'");
    $retval = mysql_query($sql);
    $row = mysql_fetch_array($retval, MYSQL_ASSOC);
    $TestFeed = new RSS2();
    $TestFeed->setTitle($row['name']);
    $TestFeed->setLink($row['link']);
    $TestFeed->setDescription($row['description']);
    $TestFeed->setChannelElement('language', 'zh-CN');
    $TestFeed->setDate(date(DATE_RSS, time()));
    $TestFeed->setChannelElement('copyright', $row['account']);
    $TestFeed->addGenerator();
    mysql_query("set character set 'utf8'");
    $sql = "SELECT * FROM `{$name}` ORDER BY lastModified DESC";
    mysql_select_db('weixincrawler');
    $retval = mysql_query($sql);
    if (!$retval) {
        die('Could not get data: ' . mysql_error());
    }
    while ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
        $newItem = $TestFeed->createNewItem();
        $newItem->setTitle($row["title"]);
        $newItem->setLink($row["url"]);
        $newItem->setDescription($row["description"]);
        $newItem->setDate($row["lastModified"]);
        $newItem->setAuthor($name);
        $newItem->setId($row["url"], true);
示例#2
0
$urlParams = parse_url($_GET["url"]);
if (!empty($urlParams["query"])) {
    parse_str($urlParams["query"], $aQuery);
    if (!empty($aQuery["q"])) {
        $title .= " - " . $aQuery["q"];
    }
}
$feeds = new RSS2();
$feeds->setTitle($siteConfig->getOption("site_name"));
$feeds->setLink($siteConfig->getOption("site_url"));
$feeds->setSelfLink(!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? "https" : "http" . "://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$feeds->setDescription("Flux RSS de la recherche : " . $_GET["url"]);
$feeds->setChannelElement("language", "fr-FR");
// The date when this feed was lastly updated. The publication date is also set.
$feeds->setDate(date(DATE_RSS, time()));
$feeds->setChannelElement("pubDate", date(\DATE_RSS, strtotime("2013-04-06")));
$feeds->addGenerator();
if (count($ads)) {
    foreach ($ads as $ad) {
        $item = $feeds->createNewItem();
        $item->setTitle($ad->getTitle());
        $item->setLink($ad->getLink());
        $item->setDescription(require DOCUMENT_ROOT . "/app/rss/views/rss-ad.phtml");
        $item->setDate($ad->getDate());
        $item->setId(md5($ad->getId()));
        $feeds->addItem($item);
    }
}
$content = $feeds->generateFeed();
file_put_contents($cache_filename, $content);
echo $content;