toolkit/mozapps/plugins/service/PluginFinderService.php

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?php
michael@0 2 /* -*- Mode: php; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /// config bits:
michael@0 8 $db_server = "";
michael@0 9 $db_user = "";
michael@0 10 $db_pass = "";
michael@0 11 $db_name = "";
michael@0 12
michael@0 13 // error handling
michael@0 14 function bail ($errstr) {
michael@0 15 die("Error: " . $errstr);
michael@0 16 }
michael@0 17
michael@0 18
michael@0 19 // major.minor.release.build[+]
michael@0 20 // make sure this is a valid version
michael@0 21 function expandversion ($vstr) {
michael@0 22 $v = explode('.', $vstr);
michael@0 23
michael@0 24 if ($vstr == '' || count($v) == 0 || count($v) > 4) {
michael@0 25 bail ('Bogus version.');
michael@0 26 }
michael@0 27
michael@0 28 $vlen = count($v);
michael@0 29 $ret = array();
michael@0 30 $hasplus = 0;
michael@0 31
michael@0 32 for ($i = 0; $i < 4; $i++) {
michael@0 33 if ($i > $vlen-1) {
michael@0 34 // this version chunk was not specified; give 0
michael@0 35 $ret[] = 0;
michael@0 36 } else {
michael@0 37 $s = $v[$i];
michael@0 38 if ($i == 3) {
michael@0 39 // need to check for +
michael@0 40 $slen = strlen($s);
michael@0 41 if ($s{$slen-1} == '+') {
michael@0 42 $s = substr($s, 0, $slen-1);
michael@0 43 $hasplus = 1;
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 $ret[] = intval($s);
michael@0 48 }
michael@0 49 }
michael@0 50
michael@0 51 $ret[] = $hasplus;
michael@0 52
michael@0 53 return $ret;
michael@0 54 }
michael@0 55
michael@0 56 function vercmp ($a, $b) {
michael@0 57 if ($a == $b)
michael@0 58 return 0;
michael@0 59
michael@0 60 $va = expandversion($a);
michael@0 61 $vb = expandversion($b);
michael@0 62
michael@0 63 for ($i = 0; $i < 5; $i++)
michael@0 64 if ($va[$i] != $vb[$i])
michael@0 65 return ($vb[$i] - $va[$i]);
michael@0 66
michael@0 67 return 0;
michael@0 68 }
michael@0 69
michael@0 70
michael@0 71 //
michael@0 72 // These are passed in the GET string
michael@0 73 //
michael@0 74
michael@0 75 if (!array_key_exists('mimetype', $_GET))
michael@0 76 bail ("Invalid request.");
michael@0 77
michael@0 78 $mimetype = $_GET['mimetype'];
michael@0 79
michael@0 80 if (!array_key_exists('appID', $_GET)
michael@0 81 || !array_key_exists('appVersion', $_GET)
michael@0 82 || !array_key_exists('clientOS', $_GET))
michael@0 83 || !array_key_exists('chromeLocale', $_GET))
michael@0 84 )
michael@0 85 bail ("Invalid request.");
michael@0 86
michael@0 87 $reqTargetAppGuid = $_GET['appID'];
michael@0 88 $reqTargetAppVersion = $_GET['appVersion'];
michael@0 89 $clientOS = $_GET['clientOS'];
michael@0 90 $chromeLocale = $_GET['chromeLocale'];
michael@0 91
michael@0 92 // check args
michael@0 93 if (empty($reqTargetAppVersion) || empty($reqTargetAppGuid)) {
michael@0 94 bail ("Invalid request.");
michael@0 95 }
michael@0 96
michael@0 97 //
michael@0 98 // Now to spit out the RDF. We hand-generate because the data is pretty simple.
michael@0 99 //
michael@0 100
michael@0 101 if ($mimetype == "application/x-mtx") {
michael@0 102 $name = "Viewpoint Media Player";
michael@0 103 $guid = "{03F998B2-0E00-11D3-A498-00104B6EB52E}";
michael@0 104 $version = "5.0";
michael@0 105 $iconUrl = "";
michael@0 106 $XPILocation = "http://www.nexgenmedia.net/flashlinux/invalid.xpi";
michael@0 107 $InstallerShowsUI = false;
michael@0 108 $manualInstallationURL = "http://www.viewpoint.com/pub/products/vmp.html";
michael@0 109 $licenseURL = "http://www.viewpoint.com/pub/privacy.html";
michael@0 110 } else if ($mimetype == "application/x-shockwave-flash") {
michael@0 111 $name = "Flash Player";
michael@0 112 $guid = "{D27CDB6E-AE6D-11cf-96B8-444553540000}";
michael@0 113 $version = "7.0.16";
michael@0 114 $iconUrl = "http://goat.austin.ibm.com:8080/flash.gif";
michael@0 115 $XPILocation = "http://www.nexgenmedia.net/flashlinux/flash-linux.xpi";
michael@0 116 $InstallerShowsUI = "false";
michael@0 117 $manualInstallationURL = "http://www.macromedia.com/go/getflashplayer";
michael@0 118 $licenseURL = "http://www.macromedia.com/shockwave/download/license/desktop/";
michael@0 119 } else {
michael@0 120 $name = "";
michael@0 121 $guid = "-1";
michael@0 122 $version = "";
michael@0 123 $iconUrl = "";
michael@0 124 $XPILocation = "";
michael@0 125 $InstallerShowsUI = "";
michael@0 126 $manualInstallationURL = "";
michael@0 127 $licenseURL = "";
michael@0 128 }
michael@0 129
michael@0 130 header("Content-type: application/xml");
michael@0 131 print "<?xml version=\"1.0\"?>\n";
michael@0 132 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";
michael@0 133
michael@0 134 print "<RDF:Description about=\"urn:mozilla:plugin-results:{$mimetype}\">\n";
michael@0 135
michael@0 136 // output list of matching plugins
michael@0 137 print " <pfs:plugins><RDF:Seq>\n";
michael@0 138 print " <RDF:li resource=\"urn:mozilla:plugin:{$guid}\"/>\n";
michael@0 139 print " </RDF:Seq></pfs:plugins>\n";
michael@0 140 print "</RDF:Description>\n\n";
michael@0 141
michael@0 142 print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}\">\n";
michael@0 143 print " <pfs:updates><RDF:Seq>\n";
michael@0 144 print " <RDF:li resource=\"urn:mozilla:plugin:{$guid}:{$version}\"/>\n";
michael@0 145 print " </RDF:Seq></pfs:updates>\n";
michael@0 146 print "</RDF:Description>\n\n";
michael@0 147
michael@0 148 print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}:{$version}\">\n";
michael@0 149 print " <pfs:name>{$name}</pfs:name>\n";
michael@0 150 print " <pfs:requestedMimetype>{$mimetype}</pfs:requestedMimetype>\n";
michael@0 151 print " <pfs:guid>{$guid}</pfs:guid>\n";
michael@0 152 print " <pfs:version>{$version}</pfs:version>\n";
michael@0 153 print " <pfs:IconUrl>{$iconUrl}</pfs:IconUrl>\n";
michael@0 154 print " <pfs:XPILocation>{$XPILocation}</pfs:XPILocation>\n";
michael@0 155 print " <pfs:InstallerShowsUI>{$InstallerShowsUI}</pfs:InstallerShowsUI>\n";
michael@0 156 print " <pfs:manualInstallationURL>{$manualInstallationURL}</pfs:manualInstallationURL>\n";
michael@0 157 print " <pfs:licenseURL>{$licenseURL}</pfs:licenseURL>\n";
michael@0 158 print "</RDF:Description>\n\n";
michael@0 159
michael@0 160 print "</RDF:RDF>\n";
michael@0 161
michael@0 162 ?>
michael@0 163

mercurial