| 1 | <?php |
|---|
| 2 | require('../scripts/database.php'); |
|---|
| 3 | |
|---|
| 4 | $action = $_GET['action']; |
|---|
| 5 | $version = $_GET['version']; |
|---|
| 6 | if (empty($action) || empty($version) || !eregi('([0-9]+).([0-9]+).([0-9]+).([0-9]+)', $version)) |
|---|
| 7 | exit; |
|---|
| 8 | |
|---|
| 9 | 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 * FROM downloads WHERE |
|---|
| 26 | (MinVersion IS NULL AND MaxVersion IS NULL) OR |
|---|
| 27 | (MinVersion IS NULL AND MaxVersion > \'%1$s\') OR |
|---|
| 28 | (MinVersion <= \'%1$s\' AND MaxVersion IS NULL) OR |
|---|
| 29 | (MinVersion <= \'%1$s\' AND MaxVersion > \'%1$s\') |
|---|
| 30 | ORDER BY `Type` ASC', $version)); |
|---|
| 31 | |
|---|
| 32 | $lastItemType = null; |
|---|
| 33 | while ($row = mysql_fetch_array($query)) |
|---|
| 34 | { |
|---|
| 35 | if ($row['Type'] != $lastItemType) |
|---|
| 36 | { |
|---|
| 37 | if ($lastItemType !== null) |
|---|
| 38 | printf(' </%s>' . "\n", $lastItemType); |
|---|
| 39 | printf(' <%s>' . "\n", $row['Type']); |
|---|
| 40 | $lastItemType = $row['Type']; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | printf(' <item name="%s" version="%s" publisher="%s" architecture="%s" filesize="%d">%s</item> |
|---|
| 44 | ', htmlentities($row['Name']), $row['Version'], htmlentities($row['Publisher']), $row['Architecture'], |
|---|
| 45 | $row['Filesize'], htmlentities($row['Link'])); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | echo '</updateList> |
|---|
| 49 | '; |
|---|
| 50 | ?> |
|---|