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