diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2009-07-16 11:04:52 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2009-07-16 11:04:52 (GMT) |
commit | 1297de71f85072bf65d74d0dcb7eb663a4391605 (patch) | |
tree | bfb5bb7f423ddcb3256674046508a2fe5b5f134e | |
parent | 260db50bb569cbcf46dbfd1e1441511f05912824 (diff) |
Add appVersion parameter to update.php
-rw-r--r-- | site/app/webroot/services/update.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/site/app/webroot/services/update.php b/site/app/webroot/services/update.php index 80d8b2a..4d46e3e 100644 --- a/site/app/webroot/services/update.php +++ b/site/app/webroot/services/update.php @@ -56,6 +56,7 @@ * Require site config. */ require_once('../../config/config.php'); +require_once('../../config/config-local.php'); require_once('../../config/constants.php'); require_once('./functions.php'); @@ -69,6 +70,7 @@ require_once('./functions.php'); // Required variables that we need to run the script. $required_vars = array('id'); +$optional_vars = array('appVersion'); // Mapping of addontypes to addontype_id. // These are used in the urn, and should not be localized. @@ -159,6 +161,12 @@ if (empty($errors) && !$detect_installed) { $sql[$var] = mysql_real_escape_string($_GET[$var]); } + foreach ($optional_vars as $var) { + if (isset($_GET[$var])) { + $sql[$var] = mysql_real_escape_string($_GET[$var]); + } + } + // we are sugar $sql['appID'] = '{3ca105e0-2280-4897-99a0-c277d1b733d2}'; @@ -187,12 +195,19 @@ if (empty($errors) && !$detect_installed) { else { // Add-on GUID was found in the db $addon = mysql_fetch_array($id_res, MYSQL_ASSOC); + + $where = 'WHERE TRUE'; if ($addon['status'] == STATUS_PUBLIC) { // If public, we only pull public files - $where = 'WHERE files.status = '.STATUS_PUBLIC; + $where .= ' AND files.status = '.STATUS_PUBLIC; } - + + if (isset($sql['appVersion'])) { + $where .= " AND CAST('{$sql['appVersion']}' AS DECIMAL(2,2)) >= appmin.version"; + $where .= " AND CAST('{$sql['appVersion']}' AS DECIMAL(2,2)) <= appmax.version"; + } + $os_query = ($sql['os_id']) ? " OR files.platform_id = {$sql['os_id']}" : ''; // Set up os_id. // Query for possible updates. @@ -225,7 +240,7 @@ if (empty($errors) && !$detect_installed) { versions.id DESC LIMIT 1 "; - + $res = mysql_query($query); if (!$res) { |