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

Revision 660, 2.2 KB checked in by lowjoel, 6 years ago (diff)

Added support for local downloads, where the downloads are hosted on the Eraser website itself (sensitive stuff, like certificates etc.)

RevLine 
[622]1<?php
[643]2require('../scripts/database.php');
[622]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
[646]14$query = mysql_query('SELECT * FROM mirrors ORDER By Continent, Country, City');
[622]15echo '  <mirrors>
[646]16        <mirror location="(automatically decide)">http://downloads.sourceforge.net/eraser/</mirror>' . "\n";
[622]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
[646]25$query = mysql_query(sprintf('SELECT downloads.*, publishers.Name as PublisherName
26    FROM downloads
27    INNER JOIN publishers ON
28        downloads.PublisherID=publishers.PublisherID
[645]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\')
[622]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
[660]47    //Get the link to the download. We got three forms, relative, absolute and query.
48    //Relative links are mirrored by SF.
49    //Absolute links... are absolute links.
50    //Query links are prefixed with ?, they are handled by download.php on the Eraser website.
51    if (substr($row['Link'], 0, 1) == '?')
52        $link = $_SERVER['SERVER_NAME'] . '/download.php?id=' . $row['DownloadID'];
53    else
54        $link = $row['Link'];
[622]55    printf('        <item name="%s" version="%s" publisher="%s" architecture="%s" filesize="%d">%s</item>
[646]56', htmlentities($row['Name']), $row['Version'], htmlentities($row['PublisherName']), $row['Architecture'],
[660]57            $row['Filesize'], htmlentities($link));
[622]58}
59
[646]60if (!empty($lastItemType))
61    printf('    </%s>' . "\n", $lastItemType);
[622]62echo '</updateList>
63';
64?>
Note: See TracBrowser for help on using the repository browser.