| <?php |
| require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_projectinfo_ro.class.php"; |
| require_once "/home/data/httpd/eclipse-php-classes/system/app.class.php"; |
| |
| #***************************************************************************** |
| # |
| # rssfeed_downloads.php |
| # |
| # Author: Karl Matthias |
| # Date: 2006-11-16 |
| # |
| # Description: Controller for RSS v2 feed |
| # |
| # HISTORY: 2007-08-30 - Now hits the ProjectInfo table to generate the feed |
| # 2007-09-10 - Moved to /downloads from committertools |
| # |
| #***************************************************************************** |
| |
| $App = new App(); |
| $App->runStdWebAppCacheable(); |
| $ErrorMessage = ""; |
| |
| function globalDisplayErrorHandler($errno, $errmsg, $filename, $linenum, $vars) { |
| $errortype = array ( |
| E_ERROR => 'Error', |
| E_WARNING => 'Warning', |
| E_PARSE => 'Parsing Error', |
| E_NOTICE => 'Notice', |
| E_CORE_ERROR => 'Core Error', |
| E_CORE_WARNING => 'Core Warning', |
| E_COMPILE_ERROR => 'Compile Error', |
| E_COMPILE_WARNING => 'Compile Warning', |
| E_USER_ERROR => 'User Error', |
| E_USER_WARNING => 'User Warning', |
| E_USER_NOTICE => 'User Notice', |
| E_STRICT => 'Runtime Notice', |
| E_RECOVERABLE_ERROR => 'Catchable Fatal Error'); |
| switch($errno) { |
| case E_NOTICE: // discard NOTICEs |
| case E_STRICT: // discard RUNTIME notices for deprecated usages |
| return; |
| default: |
| ob_end_clean(); |
| echo "<p><table cellpadding=10 width=400 bgcolor=#ffcccc><tr><td><font size=+2>Trouble: </font>"; |
| echo "PHP $errortype[$errno]:<br>$errmsg<br>$filename ($linenum)"; |
| $mysql_error_func = 'mysql_error_check'; |
| if(function_exists($mysql_error_func)) { |
| $mysql_error_func(); |
| } |
| echo "</table></p>\n"; |
| } |
| } |
| |
| # Set a real error handler |
| set_error_handler("globalDisplayErrorHandler"); |
| |
| # Start output buffering so we can print errors in HTML and output in XML |
| ob_start(); |
| |
| # Start of XML |
| echo "<?xml version=\"1.0\"?>"; |
| |
| ?> |
| <rss version="2.0"> |
| <channel> |
| <title>Eclipse.org Downloads</title> |
| <link>http://www.eclipse.org/downloads/</link> |
| <description>New downloads from Eclipse.org in the last 2 weeks.</description> |
| <language>en-us</language> |
| <pubDate><?= date("D, j M Y H:i:s T", time()); ?></pubDate> |
| <lastBuildDate><?= date("D, j M Y H:i:s T", time()); ?></lastBuildDate> |
| <generator>org.eclipse.php.rssfeed_downloads</generator> |
| <managingEditor>webmaster@eclipse.org</managingEditor> |
| <webMaster>webmaster@eclipse.org</webMaster> |
| |
| <?php |
| |
| # Connect to database |
| $dbc = new DBConnectionProjectInfo(); |
| $dbh = $dbc->connect(); |
| |
| # Find the list of ProjectInfoIDs where a release was noted in the last 6 months |
| $sql = "SELECT ProjectID, ProjectInfo.ProjectInfoID AS ID FROM ProjectInfo, ProjectInfoValues |
| WHERE ProjectInfo.ProjectInfoID = ProjectInfoValues.ProjectInfoID |
| AND MainKey = 'release' |
| AND date(Value) > now() - interval 183 day |
| ORDER BY date(Value)"; |
| |
| # Fetch complete resultset |
| $result = mysql_query($sql, $dbh); |
| |
| # Iterate the resultset and output each record |
| while($row = mysql_fetch_assoc($result)) { |
| if(getProjInfValue($row['ID'], 'release', 'status') == 'completed') { |
| $name = getProjInfValue($row['ID'], 'release', 'name'); |
| $url = getProjInfValue($row['ID'], 'release', 'download'); |
| $date = date("D, j M Y H:i:s T", strtotime(getProjInfValue($row['ID'], 'release', 'date'))); |
| |
| if(!preg_match('/http:\/\//', $url)) { |
| $url = "http://www.eclipse.org/$url"; |
| } |
| ?> |
| <item> |
| <title> |
| <?= $row['ProjectID'] . " " . $name ?> |
| </title> |
| <link><?= $url ?></link> |
| <description>New file download for the <?= $row['ProjectID'] ?> project. |
| <?= $url ?> |
| </description> |
| <pubDate><?= $date ?></pubDate> |
| <guid><?= $url ?></guid> |
| </item> |
| <?php |
| } |
| } |
| |
| # We're done with the DB |
| mysql_free_result($result); |
| $dbc->disconnect(); |
| ?> |
| </channel> |
| </rss> |
| <?php |
| |
| # Clean up |
| $rs = null; |
| $rs_info = null; |
| $dbh = null; |
| $dbc = null; |
| |
| # We need to output XML, not HTML |
| header('Content-type: application/xml'); |
| |
| # Send the buffer |
| ob_end_flush(); |
| |
| # Return the requested ProjectInfoValue |
| function getProjInfValue($ProjectInfoID, $MainKey, $SubKey) { |
| global $dbh; |
| |
| if($SubKey != NULL) { |
| $SubKey = "AND SubKey = '$SubKey'"; |
| } |
| $query = "SELECT Value FROM ProjectInfo as PI, ProjectInfoValues as PIV " . |
| "WHERE PI.ProjectInfoID = PIV.ProjectInfoID " . |
| "AND MainKey = '$MainKey' $SubKey " . |
| "AND PI.ProjectInfoID = $ProjectInfoID"; |
| $result = mysql_query($query, $dbh); |
| if(!$result) { |
| ob_end_clean(); |
| echo "busted! $query"; |
| } |
| $row = mysql_fetch_assoc($result); |
| return $row['Value']; |
| } |
| |
| ?> |
| |