Widok
Moderator-Следопыт | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Запускаете под кроном, настраиваете юзеров на локальный сервер и наслаждаетесь. Код: #!/usr/bin/perl use LWP; # path to store updates $PATH="/var/www/html/nod"; # username/password for updates registered users $LOGIN="AV-xxxxxxx"; $PASS="xxxxxxxx"; # URL for updates #$URL_UPD="http://u2.eset.com/nod_eval"; $URL_UPD="http://u2.eset.com/"; $URL_UPD =~ s/\/$//; $URL_UPD =~ m/(.*:\/\/)(.*?)(\/.*)/; $site = "$1$2"; if ($site =~ m//) { print "Enter correct URL\n"; return; } unlink("$PATH/update.ver","$PATH/update.tmp"); download($PATH,"$URL_UPD/update.ver",$LOGIN,$PASS); `/usr/local/bin/unrar e -y $PATH/update.ver $PATH 2> /dev/null`; rename("$PATH/update.ver","$PATH/update.tmp"); $ver = "$PATH/update.tmp"; $vers = "$PATH/update.ver"; open(VER, "< $ver") or die "Couldn't open $ver for reading: $!\n"; open(VERS, "> $vers") or die "Couldn't open $vers for writing: $!\n"; %files = (); %urls = (); while (defined($line = <VER>) ) { chomp $line; $line =~ s/^\s+//; $line =~ s/\s+$//; ($par,$val)=split /=/, $line; if ($par =~ /file/ ) { $name = $val; $name =~ s/\/.*\///; if ($name=~m/$val/) {$furl="$URL_UPD/$val";} else {$furl="$site$val";} $line="file=$name"; } if ($par =~ /size/ ) { $size = $val; $files{$name} = $size; $urls{$name} = "$furl"; } print VERS "$line\r\n"; } print "\n"; close(VER); close(VERS); foreach $f (keys %files) { if ( (-s ("$PATH/$f")) != $files{$f}){ download($PATH,$urls{$f},$LOGIN,$PASS); } } chmod(0644,"$PATH/*"); sub download() { my ($path, $url, $login, $pass) = @_; # use external downloader system("/usr/bin/lftp -c \"get -cO $path $url\""); return; # PERL downloader $url =~ m/(.*:\/\/)(.*)\/(.*)/; my $filename = $3; my $ua=LWP::UserAgent->new(); $ua->agent("PerlUA/0.1"); my $ua=LWP::UserAgent->new(); $ua->agent("PerlUA/0.1"); my $req = HTTP::Request->new(HEAD => "$url"); $req->authorization_basic($login, $pass); my $document=$ua->request($req); if($document->is_success) { if (!($document->content_length== -s("$path/$filename"))) { my $req = HTTP::Request->new(GET => "$url"); $req->authorization_basic('login', 'password'); my $document=$ua->request($req); if($document->is_success) { open(OUT, "> $path/$filename"); print OUT $document->content; close(OUT); print "Downloading $url "; print "- ok\n"; } else { print "$url ",$document->status_line,"\n"; } } else { # print "$filename - exist\n"; } } else { print "$url ",$document->status_line,"\n"; } } |
| Всего записей: 24190 | Зарегистр. 07-04-2002 | Отправлено: 13:28 21-07-2008 | Исправлено: XenoZ, 01:39 12-09-2009 |
|