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

Revision 643, 1.6 KB checked in by lowjoel, 6 years ago (diff)

Moved the Database file to the Scripts folder, for which access is non-accessible to the public.

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 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 * 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;
33while ($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
48echo '</updateList>
49';
50?>
Note: See TracBrowser for help on using the repository browser.