Back to index

lightning-sunbird  0.9+nobinonly
PluginFinderService.php
Go to the documentation of this file.
00001 <?php
00002 /* -*- Mode: php; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Plugin Finder Service.
00017  *
00018  * The Initial Developer of the Original Code is Vladimir Vukicevic.
00019  * Portions created by the Initial Developer are Copyright (C) 2004
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *  Vladimir Vukicevic <vladimir@pobox.com>
00024  *  Doron Rosenberg <doronr@us.ibm.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00041 $db_server = "";
00042 $db_user = "";
00043 $db_pass = "";
00044 $db_name = "";
00045 
00046 // error handling
00047 function bail ($errstr) {
00048     die("Error: " . $errstr);
00049 }
00050 
00051 
00052 // major.minor.release.build[+]
00053 // make sure this is a valid version
00054 function expandversion ($vstr) {
00055     $v = explode('.', $vstr);
00056 
00057     if ($vstr == '' || count($v) == 0 || count($v) > 4) {
00058         bail ('Bogus version.');
00059     }
00060 
00061     $vlen = count($v);
00062     $ret = array();
00063     $hasplus = 0;
00064 
00065     for ($i = 0; $i < 4; $i++) {
00066         if ($i > $vlen-1) {
00067             // this version chunk was not specified; give 0
00068             $ret[] = 0;
00069         } else {
00070             $s = $v[$i];
00071             if ($i == 3) {
00072                 // need to check for +
00073                 $slen = strlen($s);
00074                 if ($s{$slen-1} == '+') {
00075                     $s = substr($s, 0, $slen-1);
00076                     $hasplus = 1;
00077                 }
00078             }
00079 
00080             $ret[] = intval($s);
00081         }
00082     }
00083 
00084     $ret[] = $hasplus;
00085 
00086     return $ret;
00087 }
00088 
00089 function vercmp ($a, $b) {
00090     if ($a == $b)
00091         return 0;
00092 
00093     $va = expandversion($a);
00094     $vb = expandversion($b);
00095 
00096     for ($i = 0; $i < 5; $i++)
00097         if ($va[$i] != $vb[$i])
00098             return ($vb[$i] - $va[$i]);
00099 
00100     return 0;
00101 }
00102 
00103 
00104 //
00105 // These are passed in the GET string
00106 //
00107 
00108 if (!array_key_exists('mimetype', $_GET))
00109     bail ("Invalid request.");
00110 
00111 $mimetype = $_GET['mimetype'];
00112 
00113 if (!array_key_exists('appID', $_GET) 
00114     || !array_key_exists('appVersion', $_GET)
00115     || !array_key_exists('clientOS', $_GET))    
00116     || !array_key_exists('chromeLocale', $_GET))
00117    )
00118     bail ("Invalid request.");
00119 
00120 $reqTargetAppGuid = $_GET['appID'];
00121 $reqTargetAppVersion = $_GET['appVersion'];
00122 $clientOS = $_GET['clientOS'];
00123 $chromeLocale = $_GET['chromeLocale'];
00124 
00125 // check args
00126 if (empty($reqTargetAppVersion) || empty($reqTargetAppGuid)) {
00127     bail ("Invalid request.");
00128 }
00129 
00130 //
00131 // Now to spit out the RDF.  We hand-generate because the data is pretty simple.
00132 //
00133 
00134 if ($mimetype == "application/x-mtx") {
00135   $name = "Viewpoint Media Player";
00136   $guid = "{03F998B2-0E00-11D3-A498-00104B6EB52E}";
00137   $version = "5.0";
00138   $iconUrl = "";
00139   $XPILocation = "http://www.nexgenmedia.net/flashlinux/invalid.xpi";
00140   $InstallerShowsUI = false;
00141   $manualInstallationURL = "http://www.viewpoint.com/pub/products/vmp.html";
00142   $licenseURL = "http://www.viewpoint.com/pub/privacy.html";
00143 } else if ($mimetype == "application/x-shockwave-flash") {
00144   $name = "Flash Player";
00145   $guid = "{D27CDB6E-AE6D-11cf-96B8-444553540000}";
00146   $version = "7.0.16";
00147   $iconUrl = "http://goat.austin.ibm.com:8080/flash.gif";
00148   $XPILocation = "http://www.nexgenmedia.net/flashlinux/flash-linux.xpi";
00149   $InstallerShowsUI = "false";
00150   $manualInstallationURL = "http://www.macromedia.com/go/getflashplayer";
00151   $licenseURL = "http://www.macromedia.com/shockwave/download/license/desktop/";
00152 } else {
00153   $name = "";
00154   $guid = "-1";
00155   $version = "";
00156   $iconUrl = "";
00157   $XPILocation = "";
00158   $InstallerShowsUI = "";
00159   $manualInstallationURL = "";
00160   $licenseURL = "";
00161 }
00162 
00163 header("Content-type: application/xml");
00164 print "<?xml version=\"1.0\"?>\n";
00165 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";
00166 
00167 print "<RDF:Description about=\"urn:mozilla:plugin-results:{$mimetype}\">\n";
00168 
00169 // output list of matching plugins
00170 print " <pfs:plugins><RDF:Seq>\n";
00171 print "   <RDF:li resource=\"urn:mozilla:plugin:{$guid}\"/>\n";
00172 print " </RDF:Seq></pfs:plugins>\n";
00173 print "</RDF:Description>\n\n";
00174 
00175 print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}\">\n";
00176 print " <pfs:updates><RDF:Seq>\n";
00177 print "   <RDF:li resource=\"urn:mozilla:plugin:{$guid}:{$version}\"/>\n";
00178 print " </RDF:Seq></pfs:updates>\n";
00179 print "</RDF:Description>\n\n";
00180 
00181 print "<RDF:Description about=\"urn:mozilla:plugin:{$guid}:{$version}\">\n";
00182 print " <pfs:name>{$name}</pfs:name>\n";
00183 print " <pfs:requestedMimetype>{$mimetype}</pfs:requestedMimetype>\n";
00184 print " <pfs:guid>{$guid}</pfs:guid>\n";
00185 print " <pfs:version>{$version}</pfs:version>\n";
00186 print " <pfs:IconUrl>{$iconUrl}</pfs:IconUrl>\n";
00187 print " <pfs:XPILocation>{$XPILocation}</pfs:XPILocation>\n";
00188 print " <pfs:InstallerShowsUI>{$InstallerShowsUI}</pfs:InstallerShowsUI>\n";
00189 print " <pfs:manualInstallationURL>{$manualInstallationURL}</pfs:manualInstallationURL>\n";
00190 print " <pfs:licenseURL>{$licenseURL}</pfs:licenseURL>\n";
00191 print "</RDF:Description>\n\n";
00192 
00193 print "</RDF:RDF>\n";
00194 
00195 ?>
00196