Example #1
0
function fof_add_feed($url)
{
    if (!$url) {
        return;
    }
    global $FOF_FEED_TABLE, $FOF_ITEM_TABLE;
    $FOF_FEED_TABLE = FOF_FEED_TABLE;
    $FOF_ITEM_TABLE = FOF_ITEM_TABLE;
    $url = trim($url);
    if (substr($url, 0, 7) != 'http://') {
        $url = 'http://' . $url;
    }
    print "Attempting to subscribe to <a href=\"{$url}\">{$url}</a>...<br>";
    if ($row = fof_is_subscribed($url)) {
        print "You are already subscribed to " . fof_render_feed_link($row) . "<br><br>";
        return true;
    }
    $rss = fetch_rss($url);
    if (!$rss->channel && !$rss->items) {
        echo "&nbsp;&nbsp;<font color=\"darkgoldenrod\">URL is not RSS or is invalid.</font><br>";
        if (!$rss) {
            echo "&nbsp;&nbsp;(error was: <B>" . magpie_error() . "</b>)<br>";
        }
        echo "&nbsp;&nbsp;<a href=\"http://feeds.archive.org/validator/check?url={$url}\">The validator may give more information.</a><br>";
        echo "<br>Attempting autodiscovery...<br><br>";
        $r = _fetch_remote_file($url);
        $c = $r->results;
        if ($c && $r->status >= 200 && $r->status < 300) {
            $l = fof_getRSSLocation($c, $url);
            if ($l) {
                echo "Autodiscovery found <a href=\"{$l}\">{$l}</a>.<br>";
                echo "Attempting to subscribe to <a href=\"{$l}\">{$l}</a>...<br>";
                if ($row = fof_is_subscribed($l)) {
                    print "<br>You are already subscribed to " . fof_render_feed_link($row) . "<br>";
                    return true;
                }
                $rss = fetch_rss($l);
                if (!$rss->channel && !$rss->items) {
                    echo "&nbsp;&nbsp;<font color=\"red\">URL is not RSS, giving up.</font><br>";
                    echo "&nbsp;&nbsp;(error was: <B>" . magpie_error() . "</b>)<br>";
                    echo "&nbsp;&nbsp;<a href=\"http://feeds.archive.org/validator/check?url={$l}\">The validator may give more information.</a><br>";
                } else {
                    fof_actually_add_feed($l, $rss);
                    echo "&nbsp;&nbsp;<font color=\"green\"><b>Subscribed.</b></font><br><br>";
                }
            } else {
                echo "<font color=\"red\"><b>Autodiscovery failed.  Giving up.</b></font><br>";
            }
        } else {
            echo "<font color=\"red\"><b>Can't load URL.  Giving up.</b></font><br>";
        }
    } else {
        fof_actually_add_feed($url, $rss);
        echo "<font color=\"green\"><b>Subscribed.</b></font><br>";
    }
}
Example #2
0
    $items = $row['items'];
    $agestr = $row['agestr'];
    if (++$t % 2) {
        print "<tr class=\"odd-row\">";
    } else {
        print "<tr>";
    }
    print "<td>{$agestr}</td>";
    $u = "view.php?feed={$id}";
    if ($unread) {
        print "<td>&nbsp;&nbsp;(<a class=\"unread\" href=\"{$u}\">{$unread} new</a> / ";
    } else {
        print "<td>&nbsp;&nbsp;(0 new / ";
    }
    print "<a href=\"{$u}&amp;what=all\">{$items}</a>)</td>";
    print "<td>&nbsp;&nbsp;" . fof_render_feed_link($row) . "</td>";
    print "<td>&nbsp;&nbsp;<a href=\"update.php?feed={$id}\">update</a></td>";
    print "<td>&nbsp;&nbsp;<a href=\"mark-read.php?feed={$id}\">mark all read</a></td>";
    print "<td>&nbsp;&nbsp;<a href=\"delete.php?feed={$id}\" onclick=\"return confirm('What-- Are you SURE?')\">delete</a></td>";
    print "</tr>";
}
?>

</table>

<?php 
readfile("panel-menu.html");
?>

	</body>
</html>
Example #3
0
    if ($fof_user_id == 1) {
        $result = fof_db_get_feeds_needing_attempt();
    } else {
        $result = fof_db_get_subscriptions(fof_current_user(), true);
    }
    while (($feed = fof_db_get_row($result)) !== false) {
        if (time() - $feed['feed_cache_date'] < $admin_prefs['manualtimeout'] * 60) {
            list($timestamp) = fof_nice_time_stamp($feed['feed_cache_date']);
            $feed_status = " was just updated {$timestamp}!";
        } else {
            if (time() < $feed['feed_cache_next_attempt']) {
                list($timestamp) = fof_nice_time_stamp($feed['feed_cache_next_attempt']);
                $feed_status = " isn't due for an update for {$timestamp}.";
            } else {
                $feeds[] = $feed;
                $feed_status = " is waiting to update...";
            }
        }
        echo '<div id="feed_id_' . $feed['feed_id'] . '">' . fof_render_feed_link($feed) . ' ' . $feed_status . "</div>\n";
    }
}
$feeds = fof_multi_sort($feeds, 'feed_cache_attempt_date', false);
$feedjson = array();
foreach ($feeds as $feed) {
    $feedjson[] = json_encode(array('id' => $feed['feed_id'], 'title' => $feed['feed_title']));
}
echo "<script>\nwindow.onload = ajaxupdate;\nfeedslist = [ " . implode(', ', $feedjson) . " ];\n</script>\n";
include 'footer.php';
?>

<?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_id = $_POST['feed'];
list($count, $error) = fof_update_feed($feed_id);
$feed = fof_db_get_feed_by_id($feed_id);
if ($count) {
    echo "<span style=\"color:green\">" . fof_render_feed_link($feed) . " has {$count} new items.</span>";
} else {
    echo "<span>" . fof_render_feed_link($feed) . " has no new items.</span>";
}
if ($error) {
    echo " <span style=\"color:red\">{$error}</span>";
}
Example #5
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>';
    }
}
Example #6
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";
}