зеркало из https://github.com/mozilla/pjs.git
Bug 278016 VersionCheck should support multiple items in one pass
Patch by Ted Mielczarek (luser) <ted.mielczarek@gmail.com>, r=me
This commit is contained in:
Родитель
4365a39770
Коммит
d6ad344e3f
|
@ -21,6 +21,7 @@
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||||
|
* Ted Mielczarek <ted.mielczarek@gmail.com>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
@ -105,38 +106,41 @@ function vercmp ($a, $b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// These are passed in the GET string
|
// These are passed in the GET string / POST request
|
||||||
//
|
//
|
||||||
|
|
||||||
if (!array_key_exists('reqVersion', $_GET))
|
if (!array_key_exists('reqVersion', $_REQUEST))
|
||||||
bail ("Invalid request.");
|
bail ("Invalid request.");
|
||||||
|
|
||||||
$reqVersion = $_GET['reqVersion'];
|
$reqVersion = $_REQUEST['reqVersion'];
|
||||||
|
|
||||||
if ($reqVersion == 1) {
|
if ($reqVersion == 1) {
|
||||||
|
|
||||||
if (!array_key_exists('id', $_GET) ||
|
if (!array_key_exists('id', $_REQUEST) ||
|
||||||
!array_key_exists('version', $_GET) ||
|
!array_key_exists('version', $_REQUEST) ||
|
||||||
!array_key_exists('maxAppVersion', $_GET) ||
|
!array_key_exists('maxAppVersion', $_REQUEST) ||
|
||||||
!array_key_exists('appID', $_GET) ||
|
!array_key_exists('appID', $_REQUEST) ||
|
||||||
!array_key_exists('appVersion', $_GET))
|
!array_key_exists('appVersion', $_REQUEST))
|
||||||
bail ("Invalid request.");
|
bail ("Invalid request.");
|
||||||
|
|
||||||
$reqItemGuid = mysql_real_escape_string($_GET['id']);
|
// these three can have multiple values
|
||||||
$reqItemVersion = mysql_real_escape_string($_GET['version']);
|
$reqItemGuid = explode(",",mysql_real_escape_string($_REQUEST['id']));
|
||||||
$reqItemMaxAppVersion = mysql_real_escape_string($_GET['maxAppVersion']);
|
$reqItemVersion = explode(",",mysql_real_escape_string($_REQUEST['version']));
|
||||||
$reqTargetAppGuid = mysql_real_escape_string($_GET['appID']);
|
// are we even using this?
|
||||||
$reqTargetAppVersion = mysql_real_escape_string($_GET['appVersion']);
|
$reqItemMaxAppVersion = explode(",",mysql_real_escape_string($_REQUEST['maxAppVersion']));
|
||||||
|
$reqTargetAppGuid = mysql_real_escape_string($_REQUEST['appID']);
|
||||||
|
$reqTargetAppVersion = mysql_real_escape_string($_REQUEST['appVersion']);
|
||||||
|
|
||||||
// For backwards compatibility, not required.
|
// For backwards compatibility, not required.
|
||||||
$reqTargetOS = mysql_real_escape_string($_GET['appOS']);
|
$reqTargetOS = mysql_real_escape_string($_REQUEST['appOS']);
|
||||||
} else {
|
} else {
|
||||||
// bail
|
// bail
|
||||||
bail ("Bad request version received");
|
bail ("Bad request version received");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check args
|
// check args
|
||||||
if (empty($reqItemGuid) || empty($reqItemVersion) || empty($reqTargetAppGuid)) {
|
if (empty($reqItemGuid) || empty($reqItemVersion) || empty($reqTargetAppGuid)
|
||||||
|
|| (count($reqItemGuid) != count($reqItemVersion))) {
|
||||||
bail ("Invalid request.");
|
bail ("Invalid request.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +207,32 @@ if ( ( $reqTargetOS == 'WINNT' )
|
||||||
$osid = 6;
|
$osid = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now to spit out the RDF. We hand-generate because the data is pretty simple.
|
||||||
|
//
|
||||||
|
|
||||||
|
print "<?xml version=\"1.0\"?>\n";
|
||||||
|
print "<RDF:RDF xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:em=\"http://www.mozilla.org/2004/em-rdf#\">\n\n";
|
||||||
|
|
||||||
|
function print_update ($data) {
|
||||||
|
global $ext_typemap;
|
||||||
|
$dataItemType = $ext_typemap[$data['exttype']];
|
||||||
|
print "<RDF:Description about=\"urn:mozilla:{$dataItemType}:{$data['extguid']}:{$data['extversion']}\">\n";
|
||||||
|
print " <em:version>{$data['extversion']}</em:version>\n";
|
||||||
|
print " <em:targetApplication>\n";
|
||||||
|
print " <RDF:Description>\n";
|
||||||
|
print " <em:id>{$data['appguid']}</em:id>\n";
|
||||||
|
print " <em:minVersion>{$data['appminver']}</em:minVersion>\n";
|
||||||
|
print " <em:maxVersion>{$data['appmaxver']}</em:maxVersion>\n";
|
||||||
|
print " <em:updateLink>{$data['exturi']}</em:updateLink>\n";
|
||||||
|
print " </RDF:Description>\n";
|
||||||
|
print " </em:targetApplication>\n";
|
||||||
|
print "</RDF:Description>\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// now we query for each item
|
||||||
|
for($i=0; $i < count($reqItemGuid); $i++)
|
||||||
|
{
|
||||||
$query =
|
$query =
|
||||||
"SELECT main.guid AS extguid,
|
"SELECT main.guid AS extguid,
|
||||||
main.type AS exttype,
|
main.type AS exttype,
|
||||||
|
@ -218,7 +248,7 @@ $query =
|
||||||
/* We want to filter the results so that only OS=ALL and OS specific
|
/* We want to filter the results so that only OS=ALL and OS specific
|
||||||
results show up. */
|
results show up. */
|
||||||
|
|
||||||
$where = " WHERE main.guid = '" . $reqItemGuid . "'
|
$where = " WHERE main.guid = '" . $reqItemGuid[$i] . "'
|
||||||
AND applications.guid = '" . $reqTargetAppGuid . "'
|
AND applications.guid = '" . $reqTargetAppGuid . "'
|
||||||
AND (version.OSID = 1 OR version.OSID = " . $osid . ")
|
AND (version.OSID = 1 OR version.OSID = " . $osid . ")
|
||||||
AND version.approved = 'YES'";
|
AND version.approved = 'YES'";
|
||||||
|
@ -249,7 +279,7 @@ while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we already have the current or a newer one?
|
// Do we already have the current or a newer one?
|
||||||
if (vercmp($line['extversion'], $reqItemVersion) <= 0) {
|
if (vercmp($line['extversion'], $reqItemVersion[$i]) <= 0) {
|
||||||
$thisVersionData = $line;
|
$thisVersionData = $line;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -263,23 +293,14 @@ while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||||
// Keep going until we find one that is
|
// Keep going until we find one that is
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_free_result ($result);
|
print "<RDF:Description about=\"urn:mozilla:{$itemType}:{$reqItemGuid[$i]}\">\n";
|
||||||
|
|
||||||
//
|
|
||||||
// Now to spit out the RDF. We hand-generate because the data is pretty simple.
|
|
||||||
//
|
|
||||||
|
|
||||||
print "<?xml version=\"1.0\"?>\n";
|
|
||||||
print "<RDF:RDF xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:em=\"http://www.mozilla.org/2004/em-rdf#\">\n\n";
|
|
||||||
|
|
||||||
print "<RDF:Description about=\"urn:mozilla:{$itemType}:{$reqItemGuid}\">\n";
|
|
||||||
|
|
||||||
// output list of updates (just highest and this)
|
// output list of updates (just highest and this)
|
||||||
print " <em:updates><RDF:Seq>\n";
|
print " <em:updates><RDF:Seq>\n";
|
||||||
if (!empty($thisVersionData))
|
if (!empty($thisVersionData))
|
||||||
print " <RDF:li resource=\"urn:mozilla:{$itemType}:{$reqItemGuid}:{$thisVersionData['extversion']}\"/>\n";
|
print " <RDF:li resource=\"urn:mozilla:{$itemType}:{$reqItemGuid[$i]}:{$thisVersionData['extversion']}\"/>\n";
|
||||||
if (!empty($highestVersionData))
|
if (!empty($highestVersionData))
|
||||||
print " <RDF:li resource=\"urn:mozilla:{$itemType}:{$reqItemGuid}:{$highestVersionData['extversion']}\"/>\n";
|
print " <RDF:li resource=\"urn:mozilla:{$itemType}:{$reqItemGuid[$i]}:{$highestVersionData['extversion']}\"/>\n";
|
||||||
print " </RDF:Seq></em:updates>\n";
|
print " </RDF:Seq></em:updates>\n";
|
||||||
|
|
||||||
// output compat bits for firefox 0.9
|
// output compat bits for firefox 0.9
|
||||||
|
@ -290,27 +311,14 @@ if (!empty($highestVersionData)) {
|
||||||
|
|
||||||
print "</RDF:Description>\n\n";
|
print "</RDF:Description>\n\n";
|
||||||
|
|
||||||
function print_update ($data) {
|
|
||||||
global $ext_typemap;
|
|
||||||
$dataItemType = $ext_typemap[$data['exttype']];
|
|
||||||
print "<RDF:Description about=\"urn:mozilla:{$dataItemType}:{$data['extguid']}:{$data['extversion']}\">\n";
|
|
||||||
print " <em:version>{$data['extversion']}</em:version>\n";
|
|
||||||
print " <em:targetApplication>\n";
|
|
||||||
print " <RDF:Description>\n";
|
|
||||||
print " <em:id>{$data['appguid']}</em:id>\n";
|
|
||||||
print " <em:minVersion>{$data['appminver']}</em:minVersion>\n";
|
|
||||||
print " <em:maxVersion>{$data['appmaxver']}</em:maxVersion>\n";
|
|
||||||
print " <em:updateLink>{$data['exturi']}</em:updateLink>\n";
|
|
||||||
print " </RDF:Description>\n";
|
|
||||||
print " </em:targetApplication>\n";
|
|
||||||
print "</RDF:Description>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($thisVersionData))
|
if (!empty($thisVersionData))
|
||||||
print_update ($thisVersionData);
|
print_update ($thisVersionData);
|
||||||
if (!empty($highestVersionData))
|
if (!empty($highestVersionData))
|
||||||
print_update ($highestVersionData);
|
print_update ($highestVersionData);
|
||||||
|
|
||||||
|
mysql_free_result ($result);
|
||||||
|
}
|
||||||
|
|
||||||
print "</RDF:RDF>\n";
|
print "</RDF:RDF>\n";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче