Created
April 3, 2010 13:40
-
-
Save tsudot/354487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//resides in the webapp folder. | |
require_once ('config.webapp.inc.php'); | |
ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.$INCLUDE_PATH); | |
require_once ("init.php"); | |
$THINKTANK_CFG['site_url'] = 'http://localhost'; //this will go in config.inc.php | |
$db = new Database($THINKTANK_CFG); | |
$conn = $db->getConnection(); | |
$pd = new PostDAO($db); | |
$count = 15; | |
if (isset($_REQUEST['page'])) { | |
$page = $_REQUEST['page']; | |
} else { | |
$page = 1; | |
} | |
if (isset($_REQUEST['v'])) { | |
$view = $_REQUEST['v']; | |
switch ($view) { | |
case 'timeline': | |
$posts = $pd->getPostsByPublicInstances($page, $count); | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | |
echo "<rss xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\" xmlns:georss=\"http://www.georss.org/georss\">\n"; | |
echo "<channel>\n"; | |
echo "<title>Public Timeline</title>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?v=timeline</link>\n"; | |
echo "<atom:link type=\"application/rss+xml\" href=\"".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."rss.php?v=timeline\" rel=\"self\"/>\n"; | |
echo "<description>The latest from ThinkTank</description>\n"; | |
echo "<language>en</language>\n"; | |
foreach ($posts as $post) { | |
echo "<item>\n"; | |
echo "<title>".$post->author_username.":".$post->post_text."</title>\n"; | |
echo "<description>".$post->author_username.":".$post->post_text."</description>\n"; | |
echo "<guid>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</guid>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</link>\n"; | |
echo "</item>\n"; | |
} | |
echo "</channel>\n"; | |
echo "</rss>\n"; | |
break; | |
case 'mostretweets': | |
$posts = $pd->getMostRetweetedPostsByPublicInstances($page, $count); | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | |
echo "<rss xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\" xmlns:georss=\"http://www.georss.org/georss\">\n"; | |
echo "<channel>\n"; | |
echo "<title>Public Timeline</title>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?v=timeline</link>\n"; | |
echo "<atom:link type=\"application/rss+xml\" href=\"".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."rss.php?v=timeline\" rel=\"self\"/>\n"; | |
echo "<description>The latest from ThinkTank</description>\n"; | |
echo "<language>en</language>\n"; | |
foreach ($posts as $post) { | |
echo "<item>\n"; | |
echo "<title>".$post->author_username.":".$post->post_text."</title>\n"; | |
echo "<description>".$post->author_username.":".$post->post_text."</description>\n"; | |
echo "<guid>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</guid>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</link>\n"; | |
echo "</item>\n"; | |
} | |
echo "</channel>\n"; | |
echo "</rss>\n"; | |
break; | |
case 'mostreplies': | |
$posts = $pd->getMostRepliedToPostsByPublicInstances($page, $count); | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | |
echo "<rss xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\" xmlns:georss=\"http://www.georss.org/georss\">\n"; | |
echo "<channel>\n"; | |
echo "<title>Public Timeline</title>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?v=timeline</link>\n"; | |
echo "<atom:link type=\"application/rss+xml\" href=\"".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."rss.php?v=timeline\" rel=\"self\"/>\n"; | |
echo "<description>The latest from ThinkTank</description>\n"; | |
echo "<language>en</language>\n"; | |
foreach ($posts as $post) { | |
echo "<item>\n"; | |
echo "<title>".$post->author_username.":".$post->post_text."</title>\n"; | |
echo "<description>".$post->author_username.":".$post->post_text."</description>\n"; | |
echo "<guid>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</guid>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</link>\n"; | |
echo "</item>\n"; | |
} | |
echo "</channel>\n"; | |
echo "</rss>\n"; | |
break; | |
case 'photos': | |
$posts = $pd->getPhotoPostsByPublicInstances($page, $count); | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | |
echo "<rss xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\" xmlns:georss=\"http://www.georss.org/georss\">\n"; | |
echo "<channel>\n"; | |
echo "<title>Public Timeline</title>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?v=timeline</link>\n"; | |
echo "<atom:link type=\"application/rss+xml\" href=\"".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."rss.php?v=timeline\" rel=\"self\"/>\n"; | |
echo "<description>The latest from ThinkTank</description>\n"; | |
echo "<language>en</language>\n"; | |
foreach ($posts as $post) { | |
echo "<item>\n"; | |
echo "<title>".$post->author_username.":".$post->post_text."</title>\n"; | |
echo "<description>".$post->author_username.":".$post->post_text."</description>\n"; | |
echo "<guid>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</guid>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</link>\n"; | |
echo "</item>\n"; | |
} | |
echo "</channel>\n"; | |
echo "</rss>\n"; | |
break; | |
case 'links': | |
$posts = $pd->getLinkPostsByPublicInstances($page, $count); | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | |
echo "<rss xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\" xmlns:georss=\"http://www.georss.org/georss\">\n"; | |
echo "<channel>\n"; | |
echo "<title>Public Timeline</title>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?v=timeline</link>\n"; | |
echo "<atom:link type=\"application/rss+xml\" href=\"".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."rss.php?v=timeline\" rel=\"self\"/>\n"; | |
echo "<description>The latest from ThinkTank</description>\n"; | |
echo "<language>en</language>\n"; | |
foreach ($posts as $post) { | |
echo "<item>\n"; | |
echo "<title>".$post->author_username.":".$post->post_text."</title>\n"; | |
echo "<description>".$post->author_username.":".$post->post_text."</description>\n"; | |
echo "<guid>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</guid>\n"; | |
echo "<link>".$THINKTANK_CFG['site_url'].$THINKTANK_CFG['site_root_path']."public.php?t=".$post->post_id."</link>\n"; | |
echo "</item>\n"; | |
} | |
echo "</channel>\n"; | |
echo "</rss>\n"; | |
break; | |
} | |
} else { | |
header('location: http://localhost/thinktank/public.php'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment