<?php
/*
PARAMETERS:
?config=&version=&revision=&os=&pack_type=msi&edition=&rel_type=
*/
$config=$_REQUEST['config'];
$version=$_REQUEST['version'];
$revision=$_REQUEST['revision'];
$os=$_REQUEST['os']; // possible values: win32
// lower-case hack to convert Uppercase-edition-inf for ftp-servers
$edition=strtolower($_REQUEST['edition']);
$rel_type=$_REQUEST['rel_type'];

$guid=$_REQUEST['addon'];
$addon_version=$_REQUEST['addon_version'];
$addon_min_ver=$_REQUEST['addon_min_ver'];
$addon_max_ver=$_REQUEST['addon_max_ver'];
$addon_part=strtolower($_REQUEST['addon_part']);

if ($addon_part == 'package')
  $file_ext= 'zip';
else
{
  $file_ext= 'xml';

  //! TODO: determine most recent version satisfying to given restrictions (min_ver/max_ver)
  //$ver_a = explode(".", $addon_min_ver);
  if ($addon_version == '')
  {
    if ($addon_max_ver != '')
      $addon_version= $addon_max_ver;
    else
      $addon_version= $addon_min_ver;
  }
}
$file_path= 'addons/' . $os . '/' . $guid . '-' . $addon_version . '.' . $file_ext;
header('Location: ' . $file_path);
?>
