Changeset 1761
- Timestamp:
- 2/8/2010 5:24:47 AM (2 years ago)
- Location:
- trunk/website/scripts
- Files:
-
- 1 added
- 1 edited
-
updates.php (added)
-
updates/index.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/website/scripts/updates/index.php
r1461 r1761 1 1 <?php 2 2 require('../database.php'); 3 require('../updates.php'); 3 4 4 5 $action = $_GET['action']; 5 6 $version = $_GET['version']; 6 if (empty($action) || empty($version) || !eregi('([0-9]+).([0-9]+).([0-9]+).([0-9]+)', $version)) 7 $versionMatch = array(); 8 if (empty($action) || empty($version) || !preg_match('/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/', $version, $versionMatch)) 7 9 exit; 8 10 9 11 header('content-type: application/xml'); 10 echo '<?xml version="1.0"?> 11 <updateList version="1.0">' . "\n"; 12 13 //Output the list of mirrors 14 $query = mysql_query('SELECT * FROM mirrors ORDER By Continent, Country, City'); 15 echo ' <mirrors> 16 <mirror location="(automatically decide)">http://downloads.sourceforge.net/eraser/</mirror>' . "\n"; 17 while ($row = mysql_fetch_array($query)) 18 { 19 printf(' <mirror location="%s, %s">%s</mirror>' . "\n", $row['City'], $row['Country'], 20 $row['URL']); 21 } 22 echo ' </mirrors>'; 23 24 //Prepare the list of updates 25 $query = mysql_query(sprintf('SELECT downloads.*, publishers.Name as PublisherName 26 FROM downloads 27 INNER JOIN publishers ON 28 downloads.PublisherID=publishers.PublisherID 29 WHERE 30 (Superseded = 0) AND 31 (`Type` <> \'build\') AND 32 ( 33 (MinVersion IS NULL AND MaxVersion IS NULL) OR 34 (MinVersion IS NULL AND MaxVersion > \'%1$s\') OR 35 (MinVersion <= \'%1$s\' AND MaxVersion IS NULL) OR 36 (MinVersion <= \'%1$s\' AND MaxVersion > \'%1$s\') 37 ) 38 ORDER BY `Type` ASC', $version)); 39 40 $lastItemType = null; 41 while ($row = mysql_fetch_array($query)) 42 { 43 if ($row['Type'] != $lastItemType) 44 { 45 if ($lastItemType !== null) 46 printf(' </%s>' . "\n", $lastItemType); 47 printf(' <%s>' . "\n", $row['Type']); 48 $lastItemType = $row['Type']; 49 } 50 51 //Get the link to the download. We got three forms, relative, absolute and query. 52 //Relative links are mirrored by SF. 53 //Absolute links... are absolute links. 54 //Query links are prefixed with ?, they are handled by download.php on the Eraser website. 55 if (substr($row['Link'], 0, 1) == '?') 56 $link = 'http://' . $_SERVER['SERVER_NAME'] . '/download.php?id=' . $row['DownloadID']; 57 else 58 $link = $row['Link']; 59 printf(' <item name="%s" version="%s" publisher="%s" architecture="%s" filesize="%d">%s</item> 60 ', htmlentities($row['Name']), $row['Version'], htmlentities($row['PublisherName']), $row['Architecture'], 61 $row['Filesize'], htmlentities($link)); 62 } 63 64 if (!empty($lastItemType)) 65 printf(' </%s>' . "\n", $lastItemType); 66 echo '</updateList> 67 '; 12 $downloadsList = intval($versionMatch[2]) == 0 ? new UpdateList1() : new UpdateList1_1(); 13 $downloadsList->Output($version); 68 14 ?>
Note: See TracChangeset
for help on using the changeset viewer.
