/**
  * download a package from the distribution server and move the downloaded file in the temporary directory
  *
  * @param	url				url to download
  * @param	application		string identifying the application name
  * @param	version			string identifying the application version
  * @return	success true/error false
  */
 private function DownloadPackage($Url, $Application, $Version)
 {
     $Downloads = self::FetchSubUrls($Url . '/');
     //make url valid
     $path = dirname($Url);
     $file = urlencode(basename($Url));
     $file_url = 'http://' . $this->RequestDomain . $path . '/' . $file . '.aps' . $Downloads[0];
     //get content from website url
     $this->_cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Downloading '" . $file_url . "'");
     $Content = @file_get_contents($file_url);
     if ($Content != false) {
         //open file to write contents on disk
         $FileHandle = fopen($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 'wb');
         if ($FileHandle == true) {
             //write results to disk
             fwrite($FileHandle, $Content);
             fclose($FileHandle);
             //set right permissions
             chmod($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 0664);
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }