initial import of aus2 app portion

This commit is contained in:
mike.morgan%oregonstate.edu 2006-05-26 01:17:33 +00:00
Родитель b0373f4f1e
Коммит 45ec9979b6
9 изменённых файлов: 1049 добавлений и 0 удалений

14
webtools/aus/xml/README Normal file
Просмотреть файл

@ -0,0 +1,14 @@
AUS Lite
--------
Great taste, less filling. (tm)
Installation
------------
Copy ./inc/config-dist.php to ./inc/config.php. Configure it properly following the comments.
Set up the ./data symlink to point to the right location (/opt/aus2/incoming, for example).
Referencing ./ with the right parameters will get you the correct XML file.
NOTE: source files must follow a naming convention:
SOURCE_DIR/[product]/[platform]/[locale].txt
NOTE: adjust the .htaccess file's RewriteBase if you are having problems.

Просмотреть файл

@ -0,0 +1,8 @@
# TODO: Replace this with something simpler (Alias).
# TODO: Then use PHP to parse path using pathinfo() instead.
RewriteEngine On
RewriteBase /~morgamic/aus
RewriteRule ^update2/(.*)$ index.php?path=$1
RewriteRule ^update/(.*)$ index.php?path=$1
php_value error_reporting 2047
php_value display_errors 1

Просмотреть файл

@ -0,0 +1,68 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* Generic class definition for all AUS objects.
*
* @package aus
* @subpackage inc
* @author Mike Morgan
*/
class AUS_Object {
function AUS_Object() {
}
/**
* Set an object parameter.
* @param string $key
* @param mixed $val
* @param bool $overwrite
* @return boolean
*/
function setVar($key,$val,$overwrite=false) {
if (!isset($this->$key) || (isset($this->$key) && $overwrite)) {
$this->$key = $val;
return true;
} else {
return false;
}
}
}
?>

Просмотреть файл

@ -0,0 +1,88 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* Configuration file.
* @package auslite
* @subpackage inc
* @author Mike Morgan
*/
// define('SOURCE_DIR','/home/morgamic/public_html/auslite/source');
define('SOURCE_DIR',getcwd().'/data');
// This is the directory containin channel-specific updates.
// Snippets in this directory override normal updates.
define('OVERRIDE_DIR',getcwd().'/data/3');
// Uncomment this line in order to echo text debug information.
define('DEBUG',false);
// Define default for Update blocks.
define('UPDATE_TYPE','minor');
define('UPDATE_VERSION','1.0+');
define('UPDATE_EXTENSION_VERSION','1.0+');
// These are channels that have access to nightly updates.
// All other channels only have access to the OVERRIDE_DIR for update info.
$nightlyChannels = array(
'nightly'
);
// This hash defines the version->patch relationships.
// It determines which patches are associated to which incoming client versions.
// @todo replace this with a better datasource that can be easily managed via a GUI.
$branchVersions = array(
'1.0+' => '1.5',
'1.4' => '1.5',
'1.4.1'=> '1.5',
'1.5' => '1.5',
'1.5.0.1' => '1.5.0.1',
'1.5.0.2' => '1.5.0.2',
'1.5.0.3' => '1.5.0.3',
'1.5.0.4' => '1.5.0.4',
'1.6a1'=> 'trunk',
'2.0'=>'2.0',
'2.0a1'=>'2.0',
'2.0a2'=>'2.0',
'2.0b1'=>'2.0',
'2.0b2'=>'2.0',
'2.0a3'=>'2.0',
'3.0a1'=>'trunk'
);
?>

Просмотреть файл

@ -0,0 +1,56 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* Initialization script.
* @package aus
* @subpackage inc
* @author Mike Morgan
*
* This script reads config and includes core libraries.
* At no point should this ever output or modify data.
*/
ini_set('display_errors',1);
ini_set('error_reporting',E_ALL);
require_once('config.php'); // Read config file.
require_once('aus.class.php'); // Generic object definition.
require_once('xml.class.php'); // XML class for output generation.
require_once('update.class.php'); // Update class for each update.
require_once('patch.class.php'); // Patch class for update patches.
?>

Просмотреть файл

@ -0,0 +1,331 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* AUS Patch class.
* @package aus
* @subpackage inc
* @author Mike Morgan
*
* This class is for handling patch objects.
* These carry relevant information about partial or complete patches.
*/
class Patch extends AUS_Object {
// Patch metadata.
var $type;
var $url;
var $hashFunction;
var $hashValue;
var $size;
var $build;
// Array that maps versions onto their respective branches.
var $branchVersions;
// Array the defines which channels are flagged as 'nightly' channels.
var $nightlyChannels;
// Valid patch flag.
var $isPatch;
// Is this patch a complete or partial patch?
var $patchType;
// Update metadata, read from patch file.
var $updateType;
var $updateVersion;
var $updateExtensionVersion;
// Do we have Update metadata information?
var $hasUpdateInfo;
var $hasDetailsUrl;
/**
* Constructor.
*/
function Patch($branchVersions=array(),$nightlyChannels,$type='complete') {
$this->setBranchVersions($branchVersions);
$this->setNightlyChannels($nightlyChannels);
$this->setVar('isPatch',false);
$this->setVar('patchType',$type);
$this->setVar('hasUpdateInfo',false);
$this->setVar('hasDetailsUrl',false);
}
/**
* Set the filepath for the snippet based on product/platform/locale and
* SOURCE_DIR, which is set in config.
*
* @param string $product
* @param string $platform
* @param string $locale
* @param string $version
* @param string $build
* @param string $buildSource
* @param string $channel
*
* @return boolean
*/
function setPath ($product,$platform,$locale,$version=null,$build,$buildSource,$channel) {
switch($buildSource) {
case 3:
return $this->setVar('path',OVERRIDE_DIR.'/'.$product.'/'.$version.'/'.$platform.'/'.$build.'/'.$locale.'/'.$channel.'/'.$this->patchType.'.txt',true);
break;
case 2:
return $this->setVar('path',SOURCE_DIR.'/'.$buildSource.'/'.$product.'/'.$version.'/'.$platform.'/'.$build.'/'.$locale.'/'.$this->patchType.'.txt',true);
break;
}
return false;
}
/**
* Read the given file and store its contents in our Patch object.
*
* @param string $path
*
* @return boolean
*/
function setSnippet ($path) {
if ($file = explode("\n",file_get_contents($path,true))) {
$this->setVar('type',$file[0]);
$this->setVar('url',$file[1]);
$this->setVar('hashFunction',$file[2]);
$this->setVar('hashValue',$file[3]);
$this->setVar('size',$file[4]);
$this->setVar('build',$file[5]);
// Attempt to read update information.
// @TODO Add ability to set updateType, once it exists in the build snippet.
if ($this->isComplete() && isset($file[6]) && isset($file[7])) {
$this->setVar('updateVersion',$file[6],true);
$this->setVar('updateExtensionVersion',$file[7],true);
$this->setVar('hasUpdateInfo',true,true);
}
if ($this->isComplete() && isset($file[8])) {
$this->setVar('detailsUrl',$file[8],true);
$this->setVar('hasDetailsUrl',true,true);
}
return true;
}
return false;
}
/**
* Attempt to read and parse the designated source file.
* How and where the file is read depends on the client version.
*
* For more information on why this is a little complicated, see:
* https://intranet.mozilla.org/AUS:Version2:Roadmap:Multibranch
*
* @param string $product
* @param string $platform
* @param string $locale
* @param string $version
* @param string $build
* @param string $channel
*
* @return boolean
*/
function findPatch($product,$platform,$locale,$version,$build,$channel=null) {
// Determine the branch of the client's version.
$branchVersion = $this->getBranch($version);
// If a specific update exists for the specified channel, it takes priority over the branch update.
if (!empty($channel) && $this->setPath($product,$platform,$locale,$branchVersion,$build,3,$channel) && file_exists($this->path) && filesize($this->path) > 0) {
$this->setSnippet($this->path);
$this->setVar('isPatch',true,true);
return true;
}
// Otherwise, if it is a complete patch and a nightly channel, force the complete update to take the user to the latest build.
elseif ($this->isComplete() && $this->isNightlyChannel($channel)) {
// Get the latest build for this branch.
$latestbuild = $this->getLatestBuild($product,$branchVersion,$platform);
if ($this->setPath($product,$platform,$locale,$branchVersion,$latestbuild,2,$channel) && file_exists($this->path) && filesize($this->path) > 0) {
$this->setSnippet($this->path);
$this->setVar('isPatch',true,true);
return true;
}
}
// Otherwise, check for the partial snippet info. If an update exists, pass it along.
elseif ($this->isNightlyChannel($channel) && $this->setPath($product,$platform,$locale,$branchVersion,$build,2,$channel) && file_exists($this->path) && filesize($this->path) > 0) {
$this->setSnippet($this->path);
$this->setVar('isPatch',true,true);
return true;
}
// Note: Other data sets were made obsolete in 0.6. May incoming/0,1 rest in peace.
// If we get here, we know for sure that no updates exist for the current request..
// Return false by default, which prompts the "no updates" XML output.
return false;
}
/**
* Compare passed build to build in snippet.
* Returns true if the snippet build is newer than the client build.
*
* @param string $build
* @return boolean
*/
function isNewBuild($build) {
return ($this->build>$build) ? true : false;
}
/**
* Set the branch versions array.
*
* @param array $branchVersions
* @return boolean
*/
function setBranchVersions($branchVersions) {
return $this->setVar('branchVersions',$branchVersions);
}
/**
* Set the nightly channels array.
*
* @param array $branchVersions
* @return boolean
*/
function setNightlyChannels($nightlyChannels) {
return $this->setVar('nightlyChannels',$nightlyChannels);
}
/**
* Determine whether or not the given channel is flagged as nightly.
*
* @param string $channel
*
* @return bool
*/
function isNightlyChannel($channel) {
return in_array($channel,$this->nightlyChannels);
}
/**
* Determine whether or not the incoming version is a product BRANCH.
*
* @param string $version
* @return string|false
*/
function getBranch($version) {
return (isset($this->branchVersions[$version])) ? $this->branchVersions[$version] : false;
}
/**
* Determine whether or not something is Trunk.
*
* @param string $version
* @return boolean
*/
function isTrunk($version) {
return ($version == 'trunk') ? true : false;
}
/**
* Does this object contain a valid patch file?
*/
function isPatch() {
return $this->isPatch;
}
/**
* Determine whether or not this patch is complete.
*/
function isComplete() {
return ($this->patchType === 'complete') ? true : false;
}
/**
* Determine whether or not this patch has a details URL.
*/
function hasDetailsUrl() {
return $this->hasDetailsUrl;
}
/**
* Determine whether or not this patch has update information.
*/
function hasUpdateInfo() {
return $this->hasUpdateInfo;
}
/**
* Determine whether or not the to_build matches the latest build for a partial patch.
* @param string $build
*
* @return bool
*/
function isOneStepFromLatest($build) {
return ($this->build == $build) ? true : false;
}
/**
* Get the latest build for this branch.
* @param string $product
* @param string $branchVersion
* @param string $platform
*/
function getLatestBuild($product,$branchVersion,$platform) {
$files = array();
$fp = opendir(SOURCE_DIR.'/2/'.$product.'/'.$branchVersion.'/'.$platform);
while (false !== ($filename = readdir($fp))) {
if ($filename!='.' && $filename!='..') {
$files[] = $filename;
}
}
closedir($fp);
rsort($files,SORT_NUMERIC);
return $files[1];
}
}
?>

Просмотреть файл

@ -0,0 +1,124 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* @package aus
* @subpackage inc
* @author Mike Morgan
*/
class Update extends AUS_Object {
var $type;
var $version;
var $extensionVersion;
var $build;
/**
* Default constructor.
*/
function Update($type=UPDATE_TYPE,$version=UPDATE_VERSION,$extensionVersion=UPDATE_EXTENSION_VERSION) {
$this->setType($type);
$this->setVersion($version);
$this->setExtensionVersion($extensionVersion);
}
/**
* Set type.
* @param string $type
*/
function setType($type) {
$this->type = $type;
}
/**
* Set verison.
* @param string $type
*/
function setVersion($version) {
$this->version = $version;
}
/**
* Set extensionVersion.
* @param string $extensionVersion
*/
function setExtensionVersion($extensionVersion) {
$this->extensionVersion = $extensionVersion;
}
/**
* Set the build.
* @param string $build
*/
function setBuild($build) {
return $this->setVar('build',$build);
}
/**
* Set the details URL.
* @param string $details
*/
function setDetails($details) {
return $this->setVar('details',$details);
}
/**
* Get type.
* @return string
*/
function getType() {
return $this->type;
}
/**
* Get version.
* @return string
*/
function getVersion() {
return $this->version;
}
/**
* Get extension version.
* @return string
*/
function getExtensionVersion() {
return $this->extensionVersion;
}
}
?>

Просмотреть файл

@ -0,0 +1,143 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* @package aus
* @subpackage inc
* @author Mike Morgan
*/
class Xml extends AUS_Object {
var $xmlOutput;
var $xmlHeader;
var $xmlFooter;
var $xmlPatchLines;
/**
* Constructor, sets overall header and footer.
*/
function Xml() {
$this->xmlHeader = '<?xml version="1.0"?>'."\n".'<updates>';
$this->xmlFooter = "\n".'</updates>';
$this->xmlOutput = $this->xmlHeader;
$this->xmlPatchLines = '';
}
/**
* Start an update block.
* @param object $update
*/
function startUpdate($update) {
$type = htmlentities($update->type);
$version = htmlentities($update->version);
$extensionVersion = htmlentities($update->extensionVersion);
$build = htmlentities($update->build);
$details = htmlentities($update->details);
$details_xml = "";
if (strlen($details) > 0) {
$details_xml = " detailsURL=\"{$details}\"";
}
$this->xmlOutput .= <<<startUpdate
<update type="{$type}" version="{$version}" extensionVersion="{$extensionVersion}" buildID="{$build}" {$details_xml}>
startUpdate;
/**
* @TODO Add buildID attribute to <update> element.
*
* Right now it is pending QA on the client side, so we will leave it
* out for now.
*
* buildID="{$build}"
*/
}
/**
* Set a patch line. This pulls info from a patch object.
* @param object $patch
*/
function setPatchLine($patch) {
$type = htmlentities($patch->type);
$url = htmlentities($patch->url);
$hashFunction = htmlentities($patch->hashFunction);
$hashValue = htmlentities($patch->hashValue);
$size = htmlentities($patch->size);
$this->xmlPatchLines .= <<<patchLine
<patch type="{$type}" URL="{$url}" hashFunction="{$hashFunction}" hashValue="{$hashValue}" size="{$size}"/>
patchLine;
}
/**
* Determines whether or not patchLines have been set.
* @return bool
*/
function hasPatchLine() {
return (empty($this->xmlPatchLines)) ? false : true;
}
/**
* End an update block.
*/
function endUpdate() {
$this->xmlOutput .= <<<endUpdate
</update>
endUpdate;
}
/**
* Add patchLines to output.
*/
function drawPatchLines() {
$this->xmlOutput .= $this->xmlPatchLines;
}
/**
* Get XML output.
* @return $string $this->xmlOutput
*/
function getOutput() {
$this->xmlOutput .= $this->xmlFooter;
return $this->xmlOutput;
}
}
?>

217
webtools/aus/xml/index.php Normal file
Просмотреть файл

@ -0,0 +1,217 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
//
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is AUS.
//
// The Initial Developer of the Original Code is Mike Morgan.
//
// Portions created by the Initial Developer are Copyright (C) 2006
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Mike Morgan <morgamic@mozilla.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
/**
* AUS Lite main script.
* @package auslite
* @subpackage docs
* @author Mike Morgan
*
* This script handles incoming requests, reads the related build
* snippet and returns a properly formatted XML file for testing.
*/
// Require config and supporting libraries.
require_once('./inc/init.php');
// Instantiate XML object.
$xml = new Xml();
// Find everything between our CWD and 255 in QUERY_STRING.
$rawPath = substr(urldecode($_SERVER['QUERY_STRING']),5,255);
// Munge he resulting string and store it in $path.
$path = explode('/',$rawPath);
// Determine incoming request and clean inputs.
// These are common URL elements, agreed upon in revision 0.
$clean = Array();
$clean['updateVersion'] = isset($path[0]) ? intval($path[0]) : null;
$clean['product'] = isset($path[1]) ? trim($path[1]) : null;
$clean['version'] = isset($path[2]) ? urlencode($path[2]) : null;
$clean['build'] = isset($path[3]) ? trim($path[3]) : null;
$clean['platform'] = isset($path[4]) ? trim($path[4]) : null;
$clean['locale'] = isset($path[5]) ? trim($path[5]) : null;
// For each updateVersion, we will run separate code.
switch ($clean['updateVersion']) {
/*
* This is for the second revision of the URL schema, with %CHANNEL% added.
* /update2/1/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/update.xml
*/
case 1:
// Check for a set channel.
$clean['channel'] = isset($path[6]) ? trim($path[6]) : null;
// Instantiate Update object and set updateVersion.
$update = new Update();
// Instantiate our complete patch.
$completePatch = new Patch($branchVersions,$nightlyChannels,'complete');
// Find our complete patch.
$completePatch->findPatch($clean['product'],$clean['platform'],$clean['locale'],$clean['version'],$clean['build'],$clean['channel']);
// If our complete patch is valid, set the patch line.
if ($completePatch->isPatch() && $completePatch->isNewBuild($clean['build'])) {
// Set our patchLine.
$xml->setPatchLine($completePatch);
// If available, pull update information from the build snippet.
// @TODO Add ability to set updateType.
if ($completePatch->hasUpdateInfo()) {
$update->setVersion($completePatch->updateVersion);
$update->setExtensionVersion($completePatch->updateExtensionVersion);
$update->setBuild($completePatch->build);
}
if ($completePatch->hasDetailsUrl()) {
$update->setDetails($completePatch->detailsUrl);
}
}
// We only check for a partial patch if the complete patch was successfully retrieved.
if ($completePatch->isPatch()) {
// Instantiate our partial patch.
$partialPatch = new Patch($branchVersions,$nightlyChannels,'partial');
$partialPatch->findPatch($clean['product'],$clean['platform'],$clean['locale'],$clean['version'],$clean['build'],$clean['channel']);
// If our partial patch is valid, set the patch line.
// We only want to deliver the partial patch if the destination build for the partial patch is equal to the build in the complete patch (which will always point to the latest).
if ($partialPatch->isPatch() && $partialPatch->isNewBuild($clean['build']) && $partialPatch->isOneStepFromLatest($completePatch->build)) {
$xml->setPatchLine($partialPatch);
}
}
// If we have valid patchLine(s), set up our output.
if ($xml->hasPatchLine()) {
$xml->startUpdate($update);
$xml->drawPatchLines();
$xml->endUpdate();
}
break;
/*
* This is for the first revision of the URL schema.
* /update2/0/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/update.xml
*/
case 0:
default:
// Instantiate Update object and set updateVersion.
$update = new Update();
// Instantiate Patch object and set Path based on passed args.
$patch = new Patch($branchVersions,$nightlyChannels,'complete');
$patch->findPatch($clean['product'],$clean['platform'],$clean['locale'],$clean['version'],$clean['build'],null);
if ($patch->isPatch()) {
$xml->setPatchLine($patch);
}
// If we have a new build, draw the update block and patch line.
// If there is no valid patch file, client will receive no updates by default.
if ($xml->hasPatchLine() && $patch->isNewBuild($clean['build'])) {
$xml->startUpdate($update);
$xml->drawPatchLines();
$xml->endUpdate();
}
break;
}
// If we are debugging output plaintext and exit.
if ( defined('DEBUG') && DEBUG == true ) {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n";
echo '<head>'."\n";
echo '<title>AUS Debug Information</title>'."\n";
echo '</head>'."\n";
echo '<body>'."\n";
echo '<h1>AUS Debug Information</h1>'."\n";
echo '<h2>XML Output</h2>'."\n";
echo '<pre>'."\n";
echo htmlentities($xml->getOutput());
echo '</pre>'."\n";
if (!empty($clean)) {
echo '<h2>Inputs</h2>'."\n";
echo '<pre>'."\n";
print_r($clean);
echo '</pre>'."\n";
}
echo '<h2>Patch Objects</h2>'."\n";
echo '<pre>'."\n";
if (!empty($patch)) {
print_r($patch);
}
if (!empty($completePatch)) {
print_r($completePatch);
}
if (!empty($partialPatch)) {
print_r($partialPatch);
}
echo '</pre>'."\n";
if (!empty($update)) {
echo '<h2>Update Object</h2>'."\n";
echo '<pre>'."\n";
print_r($update);
echo '</pre>'."\n";
}
echo '</body>'."\n";
echo '</html>';
exit;
}
// Set header and send info.
// Default output will be a blank document (no updates available).
header('Content-type: text/xml;');
echo $xml->getOutput();
exit;
?>