+my $logging=0;
+my $repository='/var/updatecache';
+my $login='';
+my $dlrate='';
+my $uuid='';
+my %xlratorsettings=();
+my %proxysettings=();
+my @http_header=();
+my $remote_size=0;
+my $remote_mtime=0;
+my $updatefile='';
+my $unique=0;
+my $mirror=1;
+
+my %dlinfo=();
+my $wgetContinueFlag="";
+
+my $vendorid = $ARGV[0]; if (!defined($vendorid) || $vendorid eq '') { exit; }
+my $sourceurl = $ARGV[1]; if (!defined($sourceurl) || $sourceurl eq '') { exit; }
+my $cfmirror = $ARGV[2]; if (!defined($cfmirror) || $cfmirror eq '') { exit; }
+my $restartdl = defined($ARGV[3]) ? $ARGV[3] : 0;
+
+umask(0002);
+
+$sourceurl =~ s@\%2b@+@ig;
+$sourceurl =~ s@\%2f@/@ig;
+$sourceurl =~ s@\%7e@~@ig;
+$updatefile = substr($sourceurl,rindex($sourceurl,"/")+1);
+$updatefile =~ s@\%20@ @ig;
+$vendorid =~ tr/A-Z/a-z/;
+
+unless (-d "$repository/download/$vendorid")
+{
+ system("mkdir -p $repository/download/$vendorid");
+ system("chmod 775 $repository/download/$vendorid");
+}
+
+if($restartdl == 0)
+{
+ # this is a new download
+ exit if (-e "$repository/download/$vendorid/$updatefile");
+
+ # dotzball: Why is this necessary?
+ system("touch $repository/download/$vendorid/$updatefile");
+ $wgetContinueFlag = "-nc";
+
+}
+else
+{
+ # this is a restart of a previous (unfinished) download
+ # -> continue download
+ $wgetContinueFlag = "-c";
+ &writelog("Continue download: $updatefile");
+}
+
+
+if ($cfmirror)
+{
+ $uuid = `echo $updatefile | md5sum`;
+} else {
+ $uuid = `echo $sourceurl | md5sum`;
+}
+
+$uuid =~ s/[^0-9a-f]//g;
+$uuid =~ s/([a-f\d]{8})([a-f\d]{4})([a-f\d]{4})([a-f\d]{4})([a-f\d]{12})/$1-$2-$3-$4-$5/;
+
+if (-e "$UPDXLT::swroot/updatexlrator/settings")
+{
+ &UPDXLT::readhash("$UPDXLT::swroot/updatexlrator/settings", \%xlratorsettings);
+ if ($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') { $dlrate = "--limit-rate=" . int($xlratorsettings{'MAX_DOWNLOAD_RATE'} / 8) . "k" };
+}