function fof_db_is_subscribed($user_id, $feed_url) { global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_ITEM_TAG_TABLE; $safeurl = mysql_escape_string($feed_url); $result = fof_do_query("select {$FOF_SUBSCRIPTION_TABLE}.feed_id from {$FOF_FEED_TABLE}, {$FOF_SUBSCRIPTION_TABLE} where feed_url='{$safeurl}' and {$FOF_SUBSCRIPTION_TABLE}.feed_id = {$FOF_FEED_TABLE}.feed_id and {$FOF_SUBSCRIPTION_TABLE}.user_id = {$user_id}"); if (mysql_num_rows($result) == 0) { return false; } return true; }
* Copyright (C) 2004 Stephen Minutillo * steve@minutillo.com - http://minutillo.com/steve/ * * Distributed under the GPL - see LICENSE * */ include_once "../init.php"; header("Content-Type: text/html; charset=utf-8"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>feed on feeds - delete</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="fof-frames.css" media="screen" /> <script src="fof.js" type="text/javascript"></script> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> </head> <body> <?php $feed = $_GET['feed']; $result = fof_do_query("delete from {$FOF_FEED_TABLE} where id = {$feed}"); $result = fof_do_query("delete from {$FOF_ITEM_TABLE} where feed_id = {$feed}"); ?> Deleted. <a href="view.php">Return to new items.</a> </body></html>
<link rel="stylesheet" href="fof.css" media="screen" /> <script src="fof.js" type="text/javascript"></script> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> </head> <body id="panel-page"> <?php if ($_GET['really']) { $query = <<<EOQ DROP TABLE `{$FOF_FEED_TABLE}`; EOQ; fof_do_query($query); $query = <<<EOQ DROP TABLE `{$FOF_ITEM_TABLE}`; EOQ; fof_do_query($query); echo 'Done. Now just delete this entire directory and we\'ll forget this ever happened.'; } else { ?> <script> if(confirm('Do you really want to uninstall Feed on Feeds?')) { document.location = document.location + '?really=really'; } </script> <a href="."><b>panel</b></a> </body></html> <?php }
/* * This file is part of FEED ON FEEDS - http://feedonfeeds.com/ * * mark-read.php - marks a single item or all items in a feed as read * * * Copyright (C) 2004 Stephen Minutillo * steve@minutillo.com - http://minutillo.com/steve/ * * Distributed under the GPL - see LICENSE * */ include_once "init.php"; header("Content-Type: text/html; charset=utf-8"); $feed = $_GET['feed']; $item = $_GET['item']; $sql = "update " . FOF_ITEM_TABLE . " set `read` = 1, timestamp=timestamp "; if ($feed) { $sql .= 'where `feed_id` = ' . $feed; } else { if ($item) { $sql .= 'where `id` = ' . $item; } } $result = fof_do_query($sql); if ($item) { header("Status: 204 Yatta"); } else { Header("Location: " . dirname($_SERVER['PHP_SELF']) . "/"); }
* * * Copyright (C) 2004 Stephen Minutillo * steve@minutillo.com - http://minutillo.com/steve/ * * Distributed under the GPL - see LICENSE * */ include_once "../init.php"; header("Content-Type: text/html; charset=utf-8"); if ($_POST['action'] == 'read') { $sql = "update " . FOF_ITEM_TABLE . " set `read` = 1, timestamp=timestamp where "; } if ($_POST['action'] == 'unread') { $sql = "update " . FOF_ITEM_TABLE . " set `read` = null, timestamp=timestamp where "; } $first = true; while (list($key, $val) = each($_POST)) { if ($val == "checked") { $key = substr($key, 1); if (!$first) { $sql .= " or "; } $first = false; $sql .= " `id` = {$key} "; } } if (!$first) { fof_do_query($sql); } header("Location: " . urldecode($_POST['return']));
function fof_update_feed($url) { global $FOF_FEED_TABLE, $FOF_ITEM_TABLE; $FOF_FEED_TABLE = FOF_FEED_TABLE; $FOF_ITEM_TABLE = FOF_ITEM_TABLE; if (!$url) { return 0; } $rss = fetch_rss($url); if (!$rss) { print "Error: <B>" . magpie_error() . "</b> "; print "<a href=\"http://feeds.archive.org/validator/check?url={$url}\">try to validate it?</a> "; return 0; } $title = mysql_escape_string($rss->channel['title']); $link = $rss->channel['link']; $description = mysql_escape_string($rss->channel['description']); $safeurl = mysql_escape_string($url); $result = fof_do_query("select id, url from {$FOF_FEED_TABLE} where url='{$safeurl}'"); $row = mysql_fetch_array($result); $feed_id = $row['id']; $items = $rss->items; foreach ($items as $item) { if (AMP_CONTENT_RSS_CUSTOMFORMAT == 'true') { $link = mysql_escape_string($item['source']); $contacts = mysql_escape_string($item['contacts']); $subtitle = mysql_escape_string($item['subtitle']); $custom1 = mysql_escape_string($item['media_text']); } else { $link = mysql_escape_string($item['link']); } $title = mysql_escape_string($item['title']); $content = mysql_escape_string($item['description']); if ($item['content']['encoded']) { $content = mysql_escape_string($item['content']['encoded']); } if ($item['atom_content']) { $content = mysql_escape_string($item['atom_content']); } if (isset($item['dc'])) { $dcdate = strtotime(mysql_escape_string($item['dc']['date'])); $dcdate = date("Y-m-d", $dcdate); $dccreator = mysql_escape_string($item['dc']['creator']); $dcsubject = mysql_escape_string($item['dc']['subject']); } else { $pubdate = isset($item['pubdate']) ? $item['pubdate'] : (isset($item['pubDate']) ? $item['pubDate'] : false); if ($pubdate) { $dcdate = strtotime(mysql_escape_string($pubdate)); $dcdate = date("Y-m-d", $dcdate); } $dccreator = mysql_escape_string($item['author']); $dcsubject = mysql_escape_string($item['category']); } if (!$link) { $link = $item['guid']; } if (!$title) { $title = "[no title]"; } $result = fof_do_query("select id from {$FOF_ITEM_TABLE} where feed_id='{$feed_id}' and link='{$link}'"); $row = mysql_fetch_array($result); $id = $row['id']; if (mysql_num_rows($result) == 0) { $n++; if (AMP_CONTENT_RSS_CUSTOMFORMAT == 'true') { $sql = "insert into {$FOF_ITEM_TABLE} (feed_id,link,title,content,dcdate,dccreator,dcsubject,contacts,subtitle,custom1) values ('{$feed_id}','{$link}','{$title}','{$content}','{$dcdate}','{$dccreator}','{$dcsubject}','{$contacts}','{$subtitle}','{$custom1}')"; } else { $sql = "insert into {$FOF_ITEM_TABLE} (feed_id,link,title,content,dcdate,dccreator,dcsubject) values ('{$feed_id}','{$link}','{$title}','{$content}','{$dcdate}','{$dccreator}','{$dcsubject}')"; } $result = fof_do_query($sql); } else { $ids[] = $id; } } if (defined('FOF_KEEP_DAYS')) { $keep_days = FOF_KEEP_DAYS; if (count($ids) != 0) { $first = 1; foreach ($ids as $id) { if ($first) { $stat = "({$id}"; $first = 0; } else { $stat .= ", {$id}"; } } $stat .= ")"; $sql = "delete from {$FOF_ITEM_TABLE} where feed_id = {$feed_id} and `read`=1 and id not in {$stat} and to_days( CURDATE( ) ) - to_days( timestamp ) > {$keep_days}"; fof_do_query($sql); } } return $n; }
<?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();
PRIMARY KEY (`id`) ) TYPE=MyISAM; EOQ; if (!fof_do_query($query, 1) && mysql_errno() != 1050) { exit("Can't create table. MySQL says: <b>" . mysql_error() . "</b><br>"); } ?> Tables exist.<br><br> Creating indexes...<br> <?php if (!fof_do_query("ALTER TABLE `{$FOF_ITEM_TABLE}` ADD INDEX `feed_id_idx` ( `feed_id` )", 1) && mysql_errno() != 1061) { exit("Can't create index. MySQL says: <b>" . mysql_error() . "</b><br>"); } if (!fof_do_query("ALTER TABLE `{$FOF_ITEM_TABLE}` ADD INDEX `read_idx` ( `read` )", 1) && mysql_errno() != 1061) { exit("Can't create index. MySQL says: <b>" . mysql_error() . "</b><br>"); } ?> Indexes exist.<br><br> Checking cache directory...<br> <?php if (!file_exists("cache")) { $status = @mkdir("cache", 0755); if (!$status) { echo "Can't create directory <code>" . getcwd() . "/cache/</code>.<br>You will need to create it yourself, and make it writeable by your PHP process.<br>Then, reload this page."; exit; } } if (!is_writable("cache")) {
* * Copyright (C) 2004 Stephen Minutillo * steve@minutillo.com - http://minutillo.com/steve/ * * Distributed under the GPL - see LICENSE * */ header("Content-Type: text/xml; charset=utf-8"); include_once "init.php"; echo '<?xml version="1.0"?>'; ?> <opml> <body> <?php $result = fof_do_query("select url, title, link, description from " . FOF_FEED_TABLE . " order by title"); while ($row = mysql_fetch_array($result)) { $url = htmlspecialchars($row['url']); $title = htmlspecialchars($row['title']); $link = htmlspecialchars($row['link']); $description = htmlspecialchars($row['description']); echo <<<HEYO <outline description="{$description}" htmlurl="{$link}" title="{$title}" xmlUrl="{$url}" /> HEYO; } ?>
$query = <<<EOQ CREATE TABLE `{$FOF_ITEM_TABLE}` ( `id` int(11) NOT NULL auto_increment, `feed_id` int(11) NOT NULL default '0', `timestamp` timestamp(14) NOT NULL, `link` text, `title` varchar(250) default NULL, `content` text, `dcdate` text, `dccreator` text, `dcsubject` text, `read` tinyint(4) default NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM; EOQ; if (!fof_do_query($query, 1) && mysql_errno() != 1050) { exit("Can't create table. MySQL says: <b>" . mysql_error() . "</b><br>"); } ?> Tables exist.<br><br> Checking cache directory...<br> <?php if (!file_exists("cache")) { $status = @mkdir("cache", 0755); if (!$status) { echo "Can't create directory <code>" . getcwd() . "/cache/</code>.<br>You will need to create it yourself, and make it writeable by your PHP process.<br>Then, reload this page."; exit; } } if (!is_writable("cache")) { echo "The directory <code>" . getcwd() . "/cache/</code> exists, but is not writable.<br>You will need to make it writeable by your PHP process.<br>Then, reload this page.";
function fof_update_feed($url) { global $FOF_FEED_TABLE; # # Get feed data. # if (!$url) { return 0; } if (!empty($url)) { $piefeed = new SimplePie(); $piefeed->set_feed_url($url); } else { return 0; } $piefeed->set_cache_location(FOF_CACHE_DIR); // echo "Memory usage after set cache: " . number_format(memory_get_usage()); $piefeed->init(); //echo "Memory usage after set init: " . number_format(memory_get_usage()); $piefeed->handle_content_type(); //echo "Memory usage after contenttype: " . number_format(memory_get_usage()); if (!$piefeed->data) { //print "<font color=\"red\">" . _("error was") . "</font>: <B>" . $piefeed->error . "</b> "; //print "<a href=\"http://feedvalidator.org/check?url=$url\">" . _("try to validate it?") . "</a> "; //unset($piefeed); $piefeed->__destruct(); // Do what PHP should be doing on it's own. return 0; } $title = $piefeed->get_title(); $link = $piefeed->get_link(); $description = $piefeed->get_description(); $safeurl = mysql_escape_string($url); $result = fof_do_query("select id, url, aging from feeds where url='{$safeurl}'"); $row = mysql_fetch_array($result); mysql_free_result($result); // echo "Memory usage after first query: " . number_format(memory_get_usage()); $feed_id = $row['id']; $keep_days = $row['aging']; if ($keep_days < 0) { $keep_days = 60; } // $result2 = fof_do_query("select image from feeds where `id`='$feed_id'"); // $row2 = mysql_fetch_array($result2); // mysql_free_result($result); //echo "Memory usage after second query: " . number_format(memory_get_usage()); // $image2 = $row2['image']; /* if (!$image2) { $imagelink = $piefeed->get_favicon(true, ''); $HTTPRequest = @fopen($imagelink, 'r'); if ($HTTPRequest) { stream_set_timeout($HTTPRequest, 0.1); $favicon = fread($HTTPRequest, 8192); $HTTPRequestData = stream_get_meta_data($HTTPRequest); fclose($HTTPRequest); if (!$HTTPRequestData['timed_out'] && strlen($favicon) < 42) { $imagelink = ""; } } else { $imagelink = $piefeed->get_image_url(); $HTTPRequest = @fopen($imagelink, 'r'); if ($HTTPRequest) { stream_set_timeout($HTTPRequest, 0.1); $favicon = fread($HTTPRequest, 8192); $HTTPRequestData = stream_get_meta_data($HTTPRequest); fclose($HTTPRequest); if (!$HTTPRequestData['timed_out'] && strlen($favicon) < 42) { $imagelink = ""; } } else { $imagelink=""; } } $sql = "update `$FOF_FEED_TABLE` set `image`='$imagelink' where `id`='$feed_id'"; $result = fof_do_query($sql); mysql_free_result($result); } // closes image */ # # Get article items and attributes # foreach ($piefeed->get_items() as $item) { $ageflag = "0"; $dccreator = ""; $dcsubject = ""; $link = mysql_escape_string($item->get_permalink()); if (!$link) { $link = $item->get_id(); } $title = mysql_escape_string($item->get_title()); if (!$title) { $title = "[" . _("no title") . "]"; } # get <dc:creator> or <author> foreach ($item->get_authors() as $author) { $authorname = $author->get_name() . " " . $author->get_email(); if (!empty($authorname)) { $dccreator .= $authorname . ', '; } } $dccreator = mysql_escape_string(substr("{$dccreator}", 0, -2)); # get <dc:date> and <pubdate> $dcdate = mysql_escape_string($item->get_date()); $dcdate = eregi_replace(",", "", $dcdate); # get <dc:subject> or <category> $category_array = $item->get_category(); $category_array = array_unique($category_array); foreach ($category_array as $category) { if (!empty($category)) { $dcsubject .= $category . ', '; } } $dcsubject = substr(mysql_escape_string($dcsubject), 0, -2); unset($category_array); # get article content $content = mysql_escape_string($item->get_description()); $content = str_replace('"?i=http', '"http', $content); # dont know why # this creeps in if ($enclosure = $item->get_enclosure(0)) { $content .= '<br />(' . $enclosure->get_type() . '; ' . $enclosure->get_size() . ' MB)<br />'; } # # Now manage the article data # $sql = "select id from items where feed_id='{$feed_id}' and link='{$link}'"; #print "<br />" . $sql . "<br />"; $result = fof_do_query($sql); $row = mysql_fetch_array($result); $id = $row['id']; //mysql_free_result($result); # if the item does not already exist, add it if (mysql_num_rows($result) == 0) { # dcdate : August 2, 2006, 1:30 am # timestamp: 2006-09-16 15:51:53 # add it only if it's not older than keep_days $dcdatetime = strtotime($dcdate); # We set ageflag == 1 if its OK to add the item to the database if ($dcdatetime < 1) { $dcdatetime = NULL; $ageflag = 1; } else { if (time() - $dcdatetime < $keep_days * 24 * 60 * 60) { $ageflag = 1; } } if ($ageflag) { //$n++; $sql = "insert into items (feed_id,link,title,content,dcdate,dccreator,dcsubject) values ('{$feed_id}','{$link}','{$title}','{$content}','{$dcdatetime}','{$dccreator}','{$dcsubject}')"; #print "<br />" . $sql . "<br />"; $result = fof_do_query($sql); mysql_free_result($result); $ids[] = $id; #keep track of it so we don't delete it below $ageflag = 0; } } //echo "Memory usage after item foreach loop: " . number_format(memory_get_usage()); } // closes opening foreach loop //unset($piefeed); $piefeed->__destruct(); // Do what PHP should be doing on it's own. //unset($item); //unset($feed); unset($title); unset($link); unset($description); unset($content); unset($dcdatetime); unset($dccreator); unset($dcsubject); //return $n; }