PageRenderTime 34ms CodeModel.GetById 7ms app.highlight 21ms RepoModel.GetById 2ms app.codeStats 0ms

/toolkit/mozapps/plugins/service/PluginFinderService.php

http://github.com/zpao/v8monkey
PHP | 196 lines | 114 code | 31 blank | 51 comment | 30 complexity | 9775ef249daaf0c3abb5bd29c4604b28 MD5 | raw file
  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
  5 *
  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/
 10 *
 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.
 15 *
 16 * The Original Code is the Plugin Finder Service.
 17 *
 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.
 21 *
 22 * Contributor(s):
 23 *  Vladimir Vukicevic <vladimir@pobox.com>
 24 *  Doron Rosenberg <doronr@us.ibm.com>
 25 *
 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.
 37 *
 38 * ***** END LICENSE BLOCK ***** */
 39
 40/// config bits:
 41$db_server = "";
 42$db_user = "";
 43$db_pass = "";
 44$db_name = "";
 45
 46// error handling
 47function bail ($errstr) {
 48    die("Error: " . $errstr);
 49}
 50
 51
 52// major.minor.release.build[+]
 53// make sure this is a valid version
 54function expandversion ($vstr) {
 55    $v = explode('.', $vstr);
 56
 57    if ($vstr == '' || count($v) == 0 || count($v) > 4) {
 58        bail ('Bogus version.');
 59    }
 60
 61    $vlen = count($v);
 62    $ret = array();
 63    $hasplus = 0;
 64
 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;
 77                }
 78            }
 79
 80            $ret[] = intval($s);
 81        }
 82    }
 83
 84    $ret[] = $hasplus;
 85
 86    return $ret;
 87}
 88
 89function vercmp ($a, $b) {
 90    if ($a == $b)
 91        return 0;
 92
 93    $va = expandversion($a);
 94    $vb = expandversion($b);
 95
 96    for ($i = 0; $i < 5; $i++)
 97        if ($va[$i] != $vb[$i])
 98            return ($vb[$i] - $va[$i]);
 99
100    return 0;
101}
102
103
104//
105// These are passed in the GET string
106//
107
108if (!array_key_exists('mimetype', $_GET))
109    bail ("Invalid request.");
110
111$mimetype = $_GET['mimetype'];
112
113if (!array_key_exists('appID', $_GET) 
114    || !array_key_exists('appVersion', $_GET)
115    || !array_key_exists('clientOS', $_GET))    
116    || !array_key_exists('chromeLocale', $_GET))
117   )
118    bail ("Invalid request.");
119
120$reqTargetAppGuid = $_GET['appID'];
121$reqTargetAppVersion = $_GET['appVersion'];
122$clientOS = $_GET['clientOS'];
123$chromeLocale = $_GET['chromeLocale'];
124
125// check args
126if (empty($reqTargetAppVersion) || empty($reqTargetAppGuid)) {
127    bail ("Invalid request.");
128}
129
130//
131// Now to spit out the RDF.  We hand-generate because the data is pretty simple.
132//
133
134if ($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 = "";
161}
162
163header("Content-type: application/xml");
164print "<?xml version=\"1.0\"?>\n";
165print "<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";
166
167print "<RDF:Description about=\"urn:mozilla:plugin-results:{$mimetype}\">\n";
168
169// output list of matching plugins
170print " <pfs:plugins><RDF:Seq>\n";
171print "   <RDF:li resource=\"urn:mozilla:plugin:{$guid}\"/>\n";
172print " </RDF:Seq></pfs:plugins>\n";
173print "</RDF:Description>\n\n";
174
175print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}\">\n";
176print " <pfs:updates><RDF:Seq>\n";
177print "   <RDF:li resource=\"urn:mozilla:plugin:{$guid}:{$version}\"/>\n";
178print " </RDF:Seq></pfs:updates>\n";
179print "</RDF:Description>\n\n";
180
181print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}:{$version}\">\n";
182print " <pfs:name>{$name}</pfs:name>\n";
183print " <pfs:requestedMimetype>{$mimetype}</pfs:requestedMimetype>\n";
184print " <pfs:guid>{$guid}</pfs:guid>\n";
185print " <pfs:version>{$version}</pfs:version>\n";
186print " <pfs:IconUrl>{$iconUrl}</pfs:IconUrl>\n";
187print " <pfs:XPILocation>{$XPILocation}</pfs:XPILocation>\n";
188print " <pfs:InstallerShowsUI>{$InstallerShowsUI}</pfs:InstallerShowsUI>\n";
189print " <pfs:manualInstallationURL>{$manualInstallationURL}</pfs:manualInstallationURL>\n";
190print " <pfs:licenseURL>{$licenseURL}</pfs:licenseURL>\n";
191print "</RDF:Description>\n\n";
192
193print "</RDF:RDF>\n";
194
195?>
196