[Openfirst-cvscommit] www/htdocs news.php,NONE,1.1 index.php,1.3,1.4 news.sh,1.1,NONE news.txt,1.2,N
Brought to you by:
xtimg
From: Tim G. <xt...@us...> - 2005-05-24 22:10:05
|
Update of /cvsroot/openfirst/www/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31967 Modified Files: index.php Added Files: news.php Removed Files: news.sh news.txt Log Message: Change the news system to use RSS rather than the HTML feed; change the style of the news postings to be much more friendly looking with Hackergotchis. --- NEW FILE: news.php --- <?php /* * This file will get the news from SF.net and update the database. * */ include_once("../inc/headers.php"); mysql_selectdb("openfirst"); $inf = fopen("http://sourceforge.net/export/rss2_projnews.php?group_id=78233", "r"); mysql_query("DELETE FROM news WHERE 1;"); $lastTitle = true; $entered = false; $title = ""; $descripton = ""; $author = ""; $link = ""; $pubDate = ""; $comments = ""; while(! feof($inf)) { $line = fgets($inf, 2048); if(strpos($line, "<title>")) { if(strpos($line, "Project News: openFIRST") || strpos($line, "SourceForge.net logo")) { $lastTitle = false; } else { $lastTitle = true; } if($lastTitle) { $title = trim(str_replace("<title>", "", str_replace("</title>", "", $line))); } } if(strpos($line, "<description>") && $lastTitle) { $description = trim(str_replace("<description>", "", str_replace("</description>", "", $line))); } if(strpos($line, "<author>") && $lastTitle) { $author = trim(str_replace("<author>", "", str_replace("</author>", "", $line))); } if(strpos($line, "<link>") && $lastTitle) { $link = trim(str_replace("<link>", "", str_replace("</link>", "", $line))); } if(strpos($line, "<pubDate>") && $lastTitle) { $pubDate = trim(str_replace("<pubDate>", "", str_replace("</pubDate>", "", $line))); mysql_query("INSERT INTO news (title, description, author, link, pubDate, comments) VALUES (\"$title\", \"$description\", \"$author\", \"$link\", \"$pubDate\", \"$comments\");") || die(mysql_error()); echo "Added new news item to database.\n"; $title = ""; $descripton = ""; $author = ""; $link = ""; $pubDate = ""; $comments = ""; } } ?> --- news.txt DELETED --- Index: index.php =================================================================== RCS file: /cvsroot/openfirst/www/htdocs/index.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.php 31 Dec 2004 06:25:18 -0000 1.3 --- index.php 24 May 2005 22:09:45 -0000 1.4 *************** *** 3,8 **** src="/image/news_subscribe.png" alt="" title=""> News & Updates</h1> ! <?php ! include("news.txt"); ?> <hr> --- 3,41 ---- src="/image/news_subscribe.png" alt="" title=""> News & Updates</h1> ! <?php ! mysql_selectdb("openfirst"); ! ! $q = mysql_query("SELECT * FROM news ORDER BY id LIMIT 5;"); ! ! if(! $q) { ! echo("News is not available at the moment. Please try again later."); ! } else { ! echo "<table>"; ! ! while($n = mysql_fetch_object($q)) { ! echo "<tr>"; ! echo "<th colspan='2'>$n->title</th>"; ! echo "</tr>"; ! echo "<tr>"; ! $h = explode("@", $n->author); ! $hackergotchi = ""; ! // Hackergotchi images can be of a few different formats; and if we don't find one, we'll display a default. ! if(file_exists("image/hackergotchi/" . $h[0] . ".png")) { ! $hackergotchi = "http://www.openfirst.org/image/hackergotchi/" . $h[0] . ".png"; ! } else if(file_exists("image/hackergotchi/" . $h[0] . ".jpg")) { ! $hackergotchi = "http://www.openfirst.org/image/hackergotchi/" . $h[0] . ".jpg"; ! } else if(file_exists("image/hackergotchi/" . $h[0] . ".gif")) { ! $hackergotchi = "http://www.openfirst.org/image/hackergotchi/" . $h[0] . ".gif"; ! } else { ! $hackergotchi = "http://www.openfirst.org/image/hackergotchi/unknown.png"; ! } ! echo "<td valign='top'><img src='$hackergotchi' alt='[Hackergotchi]'><br><small>Posted: $n->pubDate by $h[0]</small></td><td valign='top'>" . str_replace("<", "<", str_replace(">", ">", str_replace(""", "\"", $n->description))) . "</td>"; ! echo "</tr>"; ! ! } ! ! echo "</table>"; ! } ! ?> <hr> --- news.sh DELETED --- |