Skip to content

Commit

Permalink
Added support for private feeds. Use at your own risk!
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 26, 2011
1 parent c8b1ea2 commit 078fbcf
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
49 changes: 49 additions & 0 deletions feed/index.php
Expand Up @@ -237,6 +237,55 @@ function verify_cache($fname, $url, $subreddit, $maxage)

$feedurl .= '.rss';

// Private feeds look like this:
// http://www.reddit.com/.rss?feed=<some_sha1_looking_hash>=&user=<your_reddit_login_name>
// This exposes your private feeds to the world! Use these at your own risk!
if (isset($_REQUEST['feed']))
{
if (isset($_REQUEST['subreddit']))
{
header('HTTP/1.0 400 Bad Request');
header('Connection: close');
header('Content-Type: text/plain');
print("\n\nCan't specify a subreddit AND a feed.\n\n");
exit(0);
} // if

if (!isset($_REQUEST['user']))
{
header('HTTP/1.0 400 Bad Request');
header('Connection: close');
header('Content-Type: text/plain');
print("\n\nRequested feed without username.\n\n");
exit(0);
} // if

$feed = $_REQUEST['feed'];
if ((strlen($feed) != 40) || (preg_match('/^[a-zA-Z0-9]+$/', $feed) != 1))
{
header('HTTP/1.0 400 Bad Request');
header('Connection: close');
header('Content-Type: text/plain');
print("\n\nBogus feed hash.\n\n");
exit(0);
} // if

$user = $_REQUEST['user'];
if ((strlen($user) > 64) || (preg_match('/^[a-zA-Z0-9\-_]+$/', $user) != 1))
{
header('HTTP/1.0 400 Bad Request');
header('Connection: close');
header('Content-Type: text/plain');
print("\n\nBogus feed username.\n\n");
exit(0);
} // if

$cachefname = "feed-$feed-user-$user-$cachefname";
$feedurl .= "?feed=$feed&user=$user";
$subreddit = "private feed $feed for user $user";
$use_google = false;
} // if

// Use Google Reader's republication of reddit's stream, since they can spare
// the resources. :) Also, they tend to pick up items that pop into
// reddit's RSS feed for a brief time, so you get more content in general.
Expand Down
10 changes: 9 additions & 1 deletion index.html
Expand Up @@ -45,11 +45,19 @@
should work with any feed catcher.

<p>
<b>subreddits:</b>You get them like this:
<b>subreddits:</b> You get them like this:
<a href="feed/?subreddit=AskReddit">
http://inline-reddit.com/feed/?subreddit=AskReddit
</a>

<p>
<b>private feeds:</b> You get the feed info <a href="http://www.reddit.com/prefs/feeds/">here</a>, and use it like this:<br/>
http://inline-reddit.com/feed/?feed=&lt;some_sha1_looking_hash&gt;&amp;user=&lt;your_reddit_login_name&gt;<br/>
<b>DO THIS AT YOUR OWN RISK.</b><br/>
This means we'll be republishing possibly-personal information.<br/>
If you give these URLs to Google Reader, they will be discoverable by search.</br>
If you change your password, the URLs will change too, but Google Reader caches any old feed items forever.

<p>
<b>source code:</b>
is <a href="http://hg.icculus.org/icculus/inline-reddit/">here</a>.
Expand Down

0 comments on commit 078fbcf

Please sign in to comment.