示例#1
0
 function update()
 {
     require_once 'FeedOnFeeds/init_adodb.php';
     if (!($url = $this->getURL())) {
         return false;
     }
     $count = fof_update_feed($this->getURL());
     if (!$count) {
         $count = '0';
     }
     $flash =& AMP_System_Flash::instance();
     $flash->add_message(sprintf(AMP_TEXT_CONTENT_RSS_ITEMS_ADDED, $count, $this->getName()));
     return true;
 }
示例#2
0
function fof_actually_add_feed($url, $rss)
{
    global $FOF_FEED_TABLE, $FOF_ITEM_TABLE;
    $FOF_FEED_TABLE = FOF_FEED_TABLE;
    $FOF_ITEM_TABLE = FOF_ITEM_TABLE;
    $title = mysql_escape_string($rss->channel['title']);
    $link = mysql_escape_string($rss->channel['link']);
    $description = mysql_escape_string($rss->channel['description']);
    $sql = "insert into {$FOF_FEED_TABLE} (url,title,link,description) values ('{$url}','{$title}','{$link}','{$description}')";
    fof_do_query($sql);
    fof_update_feed($url, 0);
}
示例#3
0
<?php

/*
 * This file is part of FEED ON FEEDS - http://feedonfeeds.com/
 *
 * update-quiet.php - updates all feeds without producing output
 *
 *
 * Copyright (C) 2004 Stephen Minutillo
 * steve@minutillo.com - http://minutillo.com/steve/
 *
 * Distributed under the GPL - see LICENSE
 *
 */
ob_start();
include_once "init.php";
$result = fof_do_query("select url, id, title from " . FOF_FEED_TABLE . " order by title");
while ($row = mysql_fetch_array($result)) {
    $title = $row['title'];
    $id = $row['id'];
    fof_update_feed($row['url']);
}
ob_end_clean();
function newdailyitems($todayfeeds, $firstupdateid)
{
    global $firstchow;
    global $lastchow;
    $fedalready = $firstupdateid - 1;
    foreach ($todayfeeds as $tfid => $turl) {
        unset($count);
        unset($curfeed);
        //   this function actives monekchow rss reader to see if new feed exist for this blog url
        $count = fof_update_feed($turl);
        $curfeed = $tfid;
        //  do scoring on a per blog post basis/ has any new blog posts been add for this feed?
        $db->query = "SELECT * FROM " . RSSDATA . ".items WHERE " . RSSDATA . ".items.feed_id = {$tfid} AND " . RSSDATA . ".items.id > {$fedalready} ORDER BY " . RSSDATA . ".items.id ASC LIMIT 1";
        //echo $db->query;
        $resultnewitemsfirst = mysql_query($db->query) or die(mysql_error());
        if (mysql_num_rows($resultnewitemsfirst) == 1) {
            $rowfirst = mysql_fetch_object($resultnewitemsfirst);
            $firstchow = $rowfirst->id;
            //echo $firstchow;
            //  find out id of last blog post added for this blog
            $db->query = "SELECT * FROM " . RSSDATA . ".items WHERE " . RSSDATA . ".items.feed_id = {$tfid} AND " . RSSDATA . ".items.id > {$firstupdateid} ORDER BY " . RSSDATA . ".items.id DESC LIMIT 1";
            //echo $db->query;
            $resultchowlast = mysql_query($db->query) or die(mysql_error());
            $rowsecond = mysql_fetch_object($resultchowlast);
            $lastchow = $rowsecond->id;
            //echo $lastchow;
        }
        //  closes if no new posts then skip
        if ($firstchow && $lastchow) {
            // create a list of posts for this individual
            $db->query = "SELECT * FROM " . RSSDATA . ".items WHERE " . RSSDATA . ".items.id BETWEEN {$firstchow}  AND {$lastchow} ";
            //echo $db->query;
            $resultitems = mysql_query($db->query) or die("Error in query: {$db->query}. " . mysql_error());
            if (mysql_num_rows($resultitems) > 0) {
                while ($row = mysql_fetch_object($resultitems)) {
                    //unset($rowfour->content);
                    $itemid = $row->id;
                    //echo $itemid;
                    $row->content = html_entity_decode($row->content);
                    //echo $row->content;
                    $rowtwo->content = strip_tags($row->content);
                    $remove = array("'", "-", ",", "(", ")", "?", ".", "&rsquo;", "&ldquo;", "&rsquo;", "&rdquo;", ":", "@", "!", "#", "^", "%", "/", "|", '\'', "+", "=", "{", "}", "[", "]", '"', ";", "<", ">", "_", "~", "<br />", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
                    $rowthree->content = str_replace($remove, " ", $rowtwo->content);
                    $rowfour->content = trim($rowthree->content);
                    // need to add regex to remove word starting with /  that databases don't like   add at  insert stage see below
                    $wlen = strlen($rowfour->content);
                    //echo $wlen;
                    $rowthreespace->content = str_replace($remove, " ", $rowtwo->content);
                    $rowfourspace->content = trim($rowthreespace->content);
                    $rowfive->content = explode(" ", $rowthree->content);
                    $postcontent = $rowfive->content;
                    //print_r($postcontent);
                    postwords($wlen, $postcontent, $itemid);
                }
                //  closes while loop containing list of blog posts
            }
            // closes if a post ready for word prep.
            // allocate votes/scoring based on wikipedia lifestyle definitions
            blostposttopfifty($firstchow, $lastchow);
            unset($firstchow);
            unset($lastchow);
        }
        // if there has been new post for this blog url
    }
    //closes foreach for each feed that needs split into single words and scored
}
示例#5
0
		<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
</head>
<body>

<BR>
<?php 
$feed = $_GET['feed'];
$sql = "select url, id, title from " . FOF_FEED_TABLE;
if ($feed) {
    $sql .= " where id = {$feed}";
}
$sql .= " order by title";
$result = fof_do_query($sql);
while ($row = mysql_fetch_array($result)) {
    $title = $row['title'];
    $id = $row['id'];
    print "Updating <b>{$title}</b>...";
    $count = fof_update_feed($row['url']);
    print "done. ";
    if ($count) {
        print "<b><font color=red>{$count} new items</font></b>";
    }
    print "<br>";
}
?>
<BR>

Update complete.  <a href="view.php">Return to new items.</a>

</body></html>
示例#6
0
<?php

/*
 * This file is part of FEED ON FEEDS - http://feedonfeeds.com/
 *
 * update-single.php - updates a single feed
 *
 *
 * Copyright (C) 2004-2007 Stephen Minutillo
 * steve@minutillo.com - http://minutillo.com/steve/
 *
 * Distributed under the GPL - see LICENSE
 *
 */
include_once "fof-main.php";
$feed = $_GET['feed'];
list($count, $error) = fof_update_feed($feed);
if ($count) {
    print "<b><font color=red>{$count} new items</font></b>";
}
if ($error) {
    print " {$error} <br>";
} else {
    print " Done.<br>";
}
示例#7
0
 * Copyright (C) 2013 Justin Wind <*****@*****.**>
 *
 * Distributed under the GPL - see LICENSE
 *
 */
include_once 'fof-main.php';
/* mark all items in feed as read, return updated sidebar entry */
if (!empty($_POST['read_feed'])) {
    fof_db_mark_feed_read(fof_current_user(), $_POST['read_feed']);
    $feed_row = fof_get_feed(fof_current_user(), $_POST['read_feed']);
    echo fof_render_feed_row($feed_row);
    exit;
}
/* update one feed, return replacement sidebar feed list content */
if (!empty($_POST['update_feedid'])) {
    list($count, $error) = fof_update_feed($_POST['update_feedid']);
    if (!empty($error)) {
        //header('Status: 500');
        echo '<img class="feed-icon" src="' . $fof_asset['alert_icon'] . '" title="' . htmlentities($error, ENT_QUOTES) . '" />';
    } else {
        $feed_row = fof_get_feed(fof_current_user(), $_POST['update_feedid']);
        echo fof_render_feed_row($feed_row);
    }
    exit;
}
/* returns a script block which updates a list of the subscribed sources for a tag */
if (!empty($_POST['update_tag_sources'])) {
    fof_set_content_type('application/javascript');
    $tag_id = fof_db_get_tag_by_name($_POST['update_tag_sources']);
    $subs = fof_db_subscriptions_by_tags(fof_current_user());
    /* FIXME: check timeouts, like below */
示例#8
0
 *
 * Distributed under the GPL - see LICENSE
 *
 */
ob_start();
$fof_no_login = true;
$fof_user_id = 1;
include_once "fof-main.php";
set_time_limit(FOF_UPDATE_TIME_LIMIT);
$p =& FoF_Prefs::instance();
$fof_admin_prefs = $p->prefs;
fof_log("=== update started, timeout = {$fof_admin_prefs['autotimeout']}, purge = {$fof_admin_prefs['purge']} ===", "update");
$result = fof_db_get_feeds_needing_attempt();
$feeds = array();
$now = time();
while (($feed = fof_db_get_row($result)) !== false) {
    if ($now - $feed['feed_cache_date'] > $fof_admin_prefs['autotimeout'] * 60 && $now > $feed['feed_cache_next_attempt']) {
        $feeds[] = $feed;
    } else {
        fof_log("skipping {$feed['feed_id']} {$feed['feed_url']}", 'update');
    }
}
$feeds = fof_multi_sort($feeds, 'feed_cache_attempt_date', false);
foreach ($feeds as $feed) {
    fof_log("updating {$feed['feed_id']} {$feed['feed_url']}", 'update');
    fof_update_feed($feed['feed_id']);
}
fof_log("optimizing database", "update");
fof_db_optimize();
fof_log("=== update complete ===", "update");
ob_end_clean();
示例#9
0
function fof_subscribe($user_id, $url, $unread = "today")
{
    if (!$url) {
        return false;
    }
    $url = fof_prepare_url($url);
    $feed = fof_db_get_feed_by_url($url);
    if (fof_is_subscribed($user_id, $url)) {
        return "You are already subscribed to " . fof_render_feed_link($feed) . "<br>";
    }
    if (fof_feed_exists($url)) {
        fof_db_add_subscription($user_id, $feed['feed_id']);
        fof_apply_plugin_tags($id, NULL, $user_id);
        fof_update_feed($feed['feed_id']);
        if ($unread != "no") {
            fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
        }
        return '<font color="green"><b>Subscribed.</b></font><br>';
    }
    $rss = fof_parse($url);
    if (isset($rss->error)) {
        return "Error: <B>" . $rss->error . "</b> <a href=\"http://feedvalidator.org/check?url={$url}\">try to validate it?</a><br>";
    } else {
        $url = html_entity_decode($rss->subscribe_url(), ENT_QUOTES);
        $self = $rss->get_link(0, 'self');
        if ($self) {
            $url = html_entity_decode($self, ENT_QUOTES);
        }
        if (fof_feed_exists($url)) {
            $feed = fof_db_get_feed_by_url($url);
            if (fof_is_subscribed($user_id, $url)) {
                return "You are already subscribed to " . fof_render_feed_link($feed) . "<br>";
            }
            fof_db_add_subscription($user_id, $feed['feed_id']);
            if ($unread != "no") {
                fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
            }
            return '<font color="green"><b>Subscribed.</b></font><br>';
        }
        $id = fof_add_feed($url, $rss->get_title(), $rss->get_link(), $rss->get_description());
        fof_update_feed($id);
        fof_db_add_subscription($user_id, $id);
        if ($unread != "no") {
            fof_db_mark_feed_unread($user_id, $id, $unread);
        }
        fof_apply_plugin_tags($id, NULL, $user_id);
        return '<font color="green"><b>Subscribed.</b></font><br>';
    }
}
示例#10
0
 *
 * Distributed under the GPL - see LICENSE
 *
 */
set_time_limit(60 * 10);
ob_start();
$fof_no_login = true;
$fof_user_id = 1;
include_once "fof-main.php";
$p =& FoF_Prefs::instance();
$fof_admin_prefs = $p->prefs;
fof_log("=== update started, timeout = {$fof_admin_prefs['autotimeout']}, purge = {$fof_admin_prefs['purge']} ===", "update");
$result = fof_db_get_feeds();
$feeds = array();
while ($feed = fof_db_get_row($result)) {
    if (time() - $feed["feed_cache_date"] > $fof_admin_prefs["autotimeout"] * 60) {
        $feeds[] = $feed;
    } else {
        fof_log("skipping {$feed['feed_url']}", "update");
    }
}
$feeds = fof_multi_sort($feeds, 'feed_cache_attempt_date', false);
foreach ($feeds as $feed) {
    $id = $feed['feed_id'];
    fof_log("updating {$feed['feed_url']}", "update");
    fof_update_feed($id);
}
fof_log("optimizing database", "update");
fof_db_optimize();
fof_log("=== update complete ===", "update");
ob_end_clean();
示例#11
0
function fof_actually_add_feed($url, $piefeed)
{
    $title = $piefeed->get_title();
    $title = str_replace('"', '', $title);
    $title = str_replace("'", '', $title);
    $title = htmlspecialchars($title, ENT_QUOTES);
    $title = htmlspecialchars($title);
    $link = $piefeed->get_link();
    $link = str_replace('"', '', $link);
    $link = str_replace("'", '', $link);
    #$link = htmlspecialchars($link, ENT_QUOTES);
    #$link = htmlspecialchars($link);
    $description = $piefeed->get_description();
    $description = str_replace('"', '', $description);
    $description = str_replace("'", '', $description);
    $description = htmlspecialchars($description, ENT_QUOTES);
    #$description = htmlspecialchars($description);
    #$description = htmlspecialchars_decode($description);
    #$description = htmlspecialchars_decode($description);
    $sql = "insert into feeds (url,title,link,description) values ('{$url}','{$title}','{$link}','{$description}')";
    //echo "$url $title $link $description<br />";
    //echo "$sql<br />";
    fof_do_query($sql);
    // need to find autoincrement
    fof_update_feed($url);
}
示例#12
0
function fof_subscribe($user_id, $url, $unread = 'today')
{
    fof_trace();
    $url = trim($url);
    if (empty($url)) {
        return "<span style=\"color:red\">Error: <b>cannot subscribe to nothing</b> (empty url?)</span><br>\n";
    }
    /* ensure url at least has a reasonable protocol */
    $url = fof_prepare_url($url);
    $feed = fof_db_get_feed_by_url($url);
    if (empty($feed)) {
        /* raw url does not exist, try cooking it with simplepie */
        if (($rss = fof_parse($url)) === false || $rss->error()) {
            $rss_error = isset($rss) && $rss->error() ? $rss->error() : '';
            return "<span style=\"color:red\">Error: <b>Failed to subscribe to '{$url}'</b>" . (!empty($rss_error) ? ": {$rss_error}</span> <span><a href=\"http://feedvalidator.org/check?url=" . urlencode($url) . "\">try to validate it?</a>" : "") . "</span><br>\n";
        }
        $self = $rss->get_link(0, 'self');
        $url = html_entity_decode($self ? $self : $rss->subscribe_url(), ENT_QUOTES);
        $feed = fof_db_get_feed_by_url($url);
        if (empty($feed)) {
            /* cooked url does not exist, add it */
            $new_feed_id = fof_db_add_feed($url, $rss->get_title(), $rss->get_link(), $rss->get_description());
            if (empty($new_feed_id)) {
                return "<span style=\"color:red\">Error: <b>Failed to subscribe to '{$url}'</b></span<br>\n";
            }
            $feed = fof_db_get_feed_by_id($new_feed_id);
            /* assert(!empty($feed)) */
        }
    }
    if (fof_db_is_subscribed($user_id, $url)) {
        return "<span>You are already subscribed to '" . fof_render_feed_link($feed) . "'.</span><br>\n";
    }
    /* subscribe to the feed */
    fof_db_add_subscription($user_id, $feed['feed_id']);
    /* update the feed */
    list($n, $err) = fof_update_feed($new_feed_id);
    if (!empty($err)) {
        return "<span style=\"color:red\">{$err}</span><br>\n";
    }
    /* set requested existing items unread */
    if ($unread != 'no') {
        fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
    }
    /* set tags for user on any existing items */
    fof_apply_plugin_tags($feed['feed_id'], NULL, $user_id);
    return "<span style=\"color:green\"><b>Subscribed to '" . fof_render_feed_link($feed) . "'.</b></span><br>\n";
}