source: branches/website/updates/index.php @ 645

Revision 645, 1.8 KB checked in by lowjoel, 6 years ago (diff)

Updated the schema a little.

Line 
1<?php
2require('../scripts/database.php');
3
4$action = $_GET['action'];
5$version = $_GET['version'];
6if (empty($action) || empty($version) || !eregi('([0-9]+).([0-9]+).([0-9]+).([0-9]+)', $version))
7    exit;
8
9header('content-type: application/xml');
10echo '<?xml version="1.0"?>
11<updateList version="1.0">' . "\n";
12
13//Output the list of mirrors
14$query = mysql_query('SELECT * FROM updater_mirrors ORDER By Continent, Country, City');
15echo '  <mirrors>
16    <mirror location="(automatically decide)">http://downloads.sourceforge.net/eraser/</mirror>' . "\n";
17while ($row = mysql_fetch_array($query))
18{
19    printf('        <mirror location="%s, %s">%s</mirror>' . "\n", $row['City'], $row['Country'],
20        $row['URL']);
21}
22echo '  </mirrors>';
23
24//Prepare the list of updates
25$query = mysql_query(sprintf('SELECT updater_downloads.*, updater_publishers.Name as PublisherName
26    FROM updater_downloads
27    INNER JOIN updater_publishers ON
28        updater_downloads.PublisherID=updater_publishers.PublisherID
29    WHERE
30        (MinVersion IS NULL AND MaxVersion IS NULL) OR
31        (MinVersion IS NULL AND MaxVersion > \'%1$s\') OR
32        (MinVersion <= \'%1$s\' AND MaxVersion IS NULL) OR
33        (MinVersion <= \'%1$s\' AND MaxVersion > \'%1$s\')
34    ORDER BY `Type` ASC', $version));
35
36$lastItemType = null;
37while ($row = mysql_fetch_array($query))
38{
39    if ($row['Type'] != $lastItemType)
40    {
41        if ($lastItemType !== null)
42            printf('    </%s>' . "\n", $lastItemType);
43        printf('    <%s>' . "\n", $row['Type']);
44        $lastItemType = $row['Type'];
45    }
46
47    printf('        <item name="%s" version="%s" publisher="%s" architecture="%s" filesize="%d">%s</item>
48', htmlentities($row['Name']), $row['Version'], htmlentities($row['Publisher']), $row['Architecture'],
49            $row['Filesize'], htmlentities($row['Link']));
50}
51
52echo '</updateList>
53';
54?>
Note: See TracBrowser for help on using the repository browser.