1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/plugins/service/PluginFinderService.php Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,163 @@ 1.4 +<?php 1.5 +/* -*- Mode: php; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/// config bits: 1.11 +$db_server = ""; 1.12 +$db_user = ""; 1.13 +$db_pass = ""; 1.14 +$db_name = ""; 1.15 + 1.16 +// error handling 1.17 +function bail ($errstr) { 1.18 + die("Error: " . $errstr); 1.19 +} 1.20 + 1.21 + 1.22 +// major.minor.release.build[+] 1.23 +// make sure this is a valid version 1.24 +function expandversion ($vstr) { 1.25 + $v = explode('.', $vstr); 1.26 + 1.27 + if ($vstr == '' || count($v) == 0 || count($v) > 4) { 1.28 + bail ('Bogus version.'); 1.29 + } 1.30 + 1.31 + $vlen = count($v); 1.32 + $ret = array(); 1.33 + $hasplus = 0; 1.34 + 1.35 + for ($i = 0; $i < 4; $i++) { 1.36 + if ($i > $vlen-1) { 1.37 + // this version chunk was not specified; give 0 1.38 + $ret[] = 0; 1.39 + } else { 1.40 + $s = $v[$i]; 1.41 + if ($i == 3) { 1.42 + // need to check for + 1.43 + $slen = strlen($s); 1.44 + if ($s{$slen-1} == '+') { 1.45 + $s = substr($s, 0, $slen-1); 1.46 + $hasplus = 1; 1.47 + } 1.48 + } 1.49 + 1.50 + $ret[] = intval($s); 1.51 + } 1.52 + } 1.53 + 1.54 + $ret[] = $hasplus; 1.55 + 1.56 + return $ret; 1.57 +} 1.58 + 1.59 +function vercmp ($a, $b) { 1.60 + if ($a == $b) 1.61 + return 0; 1.62 + 1.63 + $va = expandversion($a); 1.64 + $vb = expandversion($b); 1.65 + 1.66 + for ($i = 0; $i < 5; $i++) 1.67 + if ($va[$i] != $vb[$i]) 1.68 + return ($vb[$i] - $va[$i]); 1.69 + 1.70 + return 0; 1.71 +} 1.72 + 1.73 + 1.74 +// 1.75 +// These are passed in the GET string 1.76 +// 1.77 + 1.78 +if (!array_key_exists('mimetype', $_GET)) 1.79 + bail ("Invalid request."); 1.80 + 1.81 +$mimetype = $_GET['mimetype']; 1.82 + 1.83 +if (!array_key_exists('appID', $_GET) 1.84 + || !array_key_exists('appVersion', $_GET) 1.85 + || !array_key_exists('clientOS', $_GET)) 1.86 + || !array_key_exists('chromeLocale', $_GET)) 1.87 + ) 1.88 + bail ("Invalid request."); 1.89 + 1.90 +$reqTargetAppGuid = $_GET['appID']; 1.91 +$reqTargetAppVersion = $_GET['appVersion']; 1.92 +$clientOS = $_GET['clientOS']; 1.93 +$chromeLocale = $_GET['chromeLocale']; 1.94 + 1.95 +// check args 1.96 +if (empty($reqTargetAppVersion) || empty($reqTargetAppGuid)) { 1.97 + bail ("Invalid request."); 1.98 +} 1.99 + 1.100 +// 1.101 +// Now to spit out the RDF. We hand-generate because the data is pretty simple. 1.102 +// 1.103 + 1.104 +if ($mimetype == "application/x-mtx") { 1.105 + $name = "Viewpoint Media Player"; 1.106 + $guid = "{03F998B2-0E00-11D3-A498-00104B6EB52E}"; 1.107 + $version = "5.0"; 1.108 + $iconUrl = ""; 1.109 + $XPILocation = "http://www.nexgenmedia.net/flashlinux/invalid.xpi"; 1.110 + $InstallerShowsUI = false; 1.111 + $manualInstallationURL = "http://www.viewpoint.com/pub/products/vmp.html"; 1.112 + $licenseURL = "http://www.viewpoint.com/pub/privacy.html"; 1.113 +} else if ($mimetype == "application/x-shockwave-flash") { 1.114 + $name = "Flash Player"; 1.115 + $guid = "{D27CDB6E-AE6D-11cf-96B8-444553540000}"; 1.116 + $version = "7.0.16"; 1.117 + $iconUrl = "http://goat.austin.ibm.com:8080/flash.gif"; 1.118 + $XPILocation = "http://www.nexgenmedia.net/flashlinux/flash-linux.xpi"; 1.119 + $InstallerShowsUI = "false"; 1.120 + $manualInstallationURL = "http://www.macromedia.com/go/getflashplayer"; 1.121 + $licenseURL = "http://www.macromedia.com/shockwave/download/license/desktop/"; 1.122 +} else { 1.123 + $name = ""; 1.124 + $guid = "-1"; 1.125 + $version = ""; 1.126 + $iconUrl = ""; 1.127 + $XPILocation = ""; 1.128 + $InstallerShowsUI = ""; 1.129 + $manualInstallationURL = ""; 1.130 + $licenseURL = ""; 1.131 +} 1.132 + 1.133 +header("Content-type: application/xml"); 1.134 +print "<?xml version=\"1.0\"?>\n"; 1.135 +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"; 1.136 + 1.137 +print "<RDF:Description about=\"urn:mozilla:plugin-results:{$mimetype}\">\n"; 1.138 + 1.139 +// output list of matching plugins 1.140 +print " <pfs:plugins><RDF:Seq>\n"; 1.141 +print " <RDF:li resource=\"urn:mozilla:plugin:{$guid}\"/>\n"; 1.142 +print " </RDF:Seq></pfs:plugins>\n"; 1.143 +print "</RDF:Description>\n\n"; 1.144 + 1.145 +print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}\">\n"; 1.146 +print " <pfs:updates><RDF:Seq>\n"; 1.147 +print " <RDF:li resource=\"urn:mozilla:plugin:{$guid}:{$version}\"/>\n"; 1.148 +print " </RDF:Seq></pfs:updates>\n"; 1.149 +print "</RDF:Description>\n\n"; 1.150 + 1.151 +print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}:{$version}\">\n"; 1.152 +print " <pfs:name>{$name}</pfs:name>\n"; 1.153 +print " <pfs:requestedMimetype>{$mimetype}</pfs:requestedMimetype>\n"; 1.154 +print " <pfs:guid>{$guid}</pfs:guid>\n"; 1.155 +print " <pfs:version>{$version}</pfs:version>\n"; 1.156 +print " <pfs:IconUrl>{$iconUrl}</pfs:IconUrl>\n"; 1.157 +print " <pfs:XPILocation>{$XPILocation}</pfs:XPILocation>\n"; 1.158 +print " <pfs:InstallerShowsUI>{$InstallerShowsUI}</pfs:InstallerShowsUI>\n"; 1.159 +print " <pfs:manualInstallationURL>{$manualInstallationURL}</pfs:manualInstallationURL>\n"; 1.160 +print " <pfs:licenseURL>{$licenseURL}</pfs:licenseURL>\n"; 1.161 +print "</RDF:Description>\n\n"; 1.162 + 1.163 +print "</RDF:RDF>\n"; 1.164 + 1.165 +?> 1.166 +