Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / toolkit / mozapps / plugins / service / PluginFinderService.php
blobca8d5e18292adef0402ca3175cdb2341a866ebaa
1 <?php
2 /* -*- Mode: php; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is the Plugin Finder Service.
18 * The Initial Developer of the Original Code is Vladimir Vukicevic.
19 * Portions created by the Initial Developer are Copyright (C) 2004
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Vladimir Vukicevic <vladimir@pobox.com>
24 * Doron Rosenberg <doronr@us.ibm.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 /// config bits:
41 $db_server = "";
42 $db_user = "";
43 $db_pass = "";
44 $db_name = "";
46 // error handling
47 function bail ($errstr) {
48 die("Error: " . $errstr);
52 // major.minor.release.build[+]
53 // make sure this is a valid version
54 function expandversion ($vstr) {
55 $v = explode('.', $vstr);
57 if ($vstr == '' || count($v) == 0 || count($v) > 4) {
58 bail ('Bogus version.');
61 $vlen = count($v);
62 $ret = array();
63 $hasplus = 0;
65 for ($i = 0; $i < 4; $i++) {
66 if ($i > $vlen-1) {
67 // this version chunk was not specified; give 0
68 $ret[] = 0;
69 } else {
70 $s = $v[$i];
71 if ($i == 3) {
72 // need to check for +
73 $slen = strlen($s);
74 if ($s{$slen-1} == '+') {
75 $s = substr($s, 0, $slen-1);
76 $hasplus = 1;
80 $ret[] = intval($s);
84 $ret[] = $hasplus;
86 return $ret;
89 function vercmp ($a, $b) {
90 if ($a == $b)
91 return 0;
93 $va = expandversion($a);
94 $vb = expandversion($b);
96 for ($i = 0; $i < 5; $i++)
97 if ($va[$i] != $vb[$i])
98 return ($vb[$i] - $va[$i]);
100 return 0;
105 // These are passed in the GET string
108 if (!array_key_exists('mimetype', $_GET))
109 bail ("Invalid request.");
111 $mimetype = $_GET['mimetype'];
113 if (!array_key_exists('appID', $_GET)
114 || !array_key_exists('appVersion', $_GET)
115 || !array_key_exists('clientOS', $_GET))
116 || !array_key_exists('chromeLocale', $_GET))
118 bail ("Invalid request.");
120 $reqTargetAppGuid = $_GET['appID'];
121 $reqTargetAppVersion = $_GET['appVersion'];
122 $clientOS = $_GET['clientOS'];
123 $chromeLocale = $_GET['chromeLocale'];
125 // check args
126 if (empty($reqTargetAppVersion) || empty($reqTargetAppGuid)) {
127 bail ("Invalid request.");
131 // Now to spit out the RDF. We hand-generate because the data is pretty simple.
134 if ($mimetype == "application/x-mtx") {
135 $name = "Viewpoint Media Player";
136 $guid = "{03F998B2-0E00-11D3-A498-00104B6EB52E}";
137 $version = "5.0";
138 $iconUrl = "";
139 $XPILocation = "http://www.nexgenmedia.net/flashlinux/invalid.xpi";
140 $InstallerShowsUI = false;
141 $manualInstallationURL = "http://www.viewpoint.com/pub/products/vmp.html";
142 $licenseURL = "http://www.viewpoint.com/pub/privacy.html";
143 } else if ($mimetype == "application/x-shockwave-flash") {
144 $name = "Flash Player";
145 $guid = "{D27CDB6E-AE6D-11cf-96B8-444553540000}";
146 $version = "7.0.16";
147 $iconUrl = "http://goat.austin.ibm.com:8080/flash.gif";
148 $XPILocation = "http://www.nexgenmedia.net/flashlinux/flash-linux.xpi";
149 $InstallerShowsUI = "false";
150 $manualInstallationURL = "http://www.macromedia.com/go/getflashplayer";
151 $licenseURL = "http://www.macromedia.com/shockwave/download/license/desktop/";
152 } else {
153 $name = "";
154 $guid = "-1";
155 $version = "";
156 $iconUrl = "";
157 $XPILocation = "";
158 $InstallerShowsUI = "";
159 $manualInstallationURL = "";
160 $licenseURL = "";
163 header("Content-type: application/xml");
164 print "<?xml version=\"1.0\"?>\n";
165 print "<RDF:RDF xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:pfs=\"http://www.mozilla.org/2004/pfs-rdf#\">\n\n";
167 print "<RDF:Description about=\"urn:mozilla:plugin-results:{$mimetype}\">\n";
169 // output list of matching plugins
170 print " <pfs:plugins><RDF:Seq>\n";
171 print " <RDF:li resource=\"urn:mozilla:plugin:{$guid}\"/>\n";
172 print " </RDF:Seq></pfs:plugins>\n";
173 print "</RDF:Description>\n\n";
175 print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}\">\n";
176 print " <pfs:updates><RDF:Seq>\n";
177 print " <RDF:li resource=\"urn:mozilla:plugin:{$guid}:{$version}\"/>\n";
178 print " </RDF:Seq></pfs:updates>\n";
179 print "</RDF:Description>\n\n";
181 print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}:{$version}\">\n";
182 print " <pfs:name>{$name}</pfs:name>\n";
183 print " <pfs:requestedMimetype>{$mimetype}</pfs:requestedMimetype>\n";
184 print " <pfs:guid>{$guid}</pfs:guid>\n";
185 print " <pfs:version>{$version}</pfs:version>\n";
186 print " <pfs:IconUrl>{$iconUrl}</pfs:IconUrl>\n";
187 print " <pfs:XPILocation>{$XPILocation}</pfs:XPILocation>\n";
188 print " <pfs:InstallerShowsUI>{$InstallerShowsUI}</pfs:InstallerShowsUI>\n";
189 print " <pfs:manualInstallationURL>{$manualInstallationURL}</pfs:manualInstallationURL>\n";
190 print " <pfs:licenseURL>{$licenseURL}</pfs:licenseURL>\n";
191 print "</RDF:Description>\n\n";
193 print "</RDF:RDF>\n";