| author | plurSKI <black.gavin@gmail.com> | 2010-10-16 17:34:54 (GMT) |
|---|---|---|
| committer | plurSKI <black.gavin@gmail.com> | 2010-10-16 17:34:54 (GMT) |
| commit | 10d44884dee138366a9b934cedfa7a4963b77b67 (patch) | |
| tree | 06339e5fb9fa1200ffd14253092515f73835fa01 | |
| parent | 076070b24521a803bf5b5fcb4ad50a3b585803d1 (diff) | |
| download | lampSite-master.zip lampSite-master.tar.gz | |
Added rss feed sourcemaster
| -rw-r--r-- | comments.php | 47 | ||||
| -rw-r--r-- | devrand.php | 42 |
2 files changed, 89 insertions, 0 deletions
diff --git a/comments.php b/comments.php new file mode 100644 index 0000000..94b5dea --- a/dev/null +++ b/comments.php @@ -0,0 +1,47 @@ +<!The comment tag around "rss version" prevents this page + from being interpretted as an rss feed. It would need to be + removed if actually being used > + +<! +<rss version="2.0"> +> + +<channel> +<title>devrand comments</title> +<description>Recent comments on devrand</description> +<link>http://www.devrand.org/</link> + +<?php + $username="common"; + $password="common"; + $database="testDB"; + $typ = $_GET['page']; + if( $typ == "" ) $typ = "News"; + mysql_connect('devrand.db', $username, $password); + @mysql_select_db($database) or die ("Unable to select database"); + $query = "SELECT * FROM comments LEFT JOIN items ON comments.item_id = items.id ORDER BY comments.time DESC"; + $result = mysql_query($query); + $num = mysql_numrows($result); + $i = 0; + while ( $i < $num && $i <= 25 ){ + $name = mysql_result($result,$i,"name"); + $item = mysql_result($result,$i,"item_id"); + $time = mysql_result($result,$i,"comments.time"); + $title = mysql_result($result,$i,"title"); + $comment = mysql_result($result,$i,"comment"); + $name = preg_replace('/ /m', ' ', $name); + $name = preg_replace('/&/m', ' and ', $name); + $name = preg_replace('/</m', ' ', $name); + $name = preg_replace('/>/m', ' ', $name); + echo "<item>\n"; + echo " <title>$name ($title)</title>\n"; + echo " <description><![CDATA[$time: $comment]]></description>\n"; + echo " <link>http://www.devrand.org/show_item.html?item=$item</link>\n"; + echo "</item>\n"; + $i ++; + } + mysql_close(); +?> + +</channel> +</rss> diff --git a/devrand.php b/devrand.php new file mode 100644 index 0000000..1138347 --- a/dev/null +++ b/devrand.php @@ -0,0 +1,42 @@ +<!The comment tag around "rss version" prevents this page + from being interpretted as an rss feed. It would need to be + removed if actually being used > + +<! +<rss version="2.0"> +> + +<channel> +<title>devrand</title> +<description>Recent activity on devrand</description> +<link>http://www.devrand.org/</link> + +<?php + $username="common"; + $password="common"; + $database="testDB"; + $typ = $_GET['page']; + if( $typ == "" ) $typ = "News"; + mysql_connect('devrand.db', $username, $password); + @mysql_select_db($database) or die ("Unable to select database"); + $query = "SELECT * FROM items where visible=true ORDER BY time DESC"; + $result = mysql_query($query); + $num = mysql_numrows($result); + $i = 0; + while ( $i < $num && $i <= 25 ){ + $title = mysql_result($result,$i,"title"); + $item = mysql_result($result,$i,"id"); + $typ = mysql_result($result,$i,"type"); + $body = substr(mysql_result($result,$i,"body"), 0, 255); + echo "<item>\n"; + echo " <title>$title ($typ)</title>\n"; + echo " <description><![CDATA[$body]]>...</description>\n"; + echo " <link>http://www.devrand.org/show_item.html?item=$item</link>\n"; + echo "</item>\n"; + $i ++; + } + mysql_close(); +?> + +</channel> +</rss> |
