Документ взят из кэша поисковой машины. Адрес оригинального документа : http://vo.astronet.ru/ws/wcsfix/wcsfix_post.cgi
Дата изменения: Tue Dec 29 12:44:27 2009
Дата индексирования: Mon Oct 1 19:59:05 2012
Кодировка:

Поисковые слова: ngc 253
#!/usr/bin/perl -w

use CGI qw/:standard/;
use wcsfix;
use sextractor;
use File::Temp qw/ tempfile /;

my $globalError = undef;

if(param()){
my $upload = upload('file');
my $ra = param('ra');
my $dec = param('dec');
my $sr = param('sr');
my $catalog = param('catalog');

if($upload){
my ($tmphandle, $tmpfile) = tempfile();

while(<$upload>){
print $tmphandle $_;
}

close $tmphandle;

$res = processFile($tmpfile, $sr, $ra, $dec, $catalog);

if($res){
print header('application/fits');

open(FILE, "<".$tmpfile) or die "Temp file does not exists!";

while(){
print $_;
}

close(FILE);
} else {
print header('text/html');

print $globalError;
}

unlink $tmpfile;
} else {
print header('text/html');

print "No file uploaded!\n";
}
} else {
print header('text/html');

print "No params given\n";
}

sub processFile
{
my $filename = $_[0];
my $sr = $_[1];
my $ra = $_[2];
my $dec = $_[3];
my $catalog = $_[4];

$globalError = wcsfix::fixFileWCS($filename, $sr, $ra, $dec, $catalog);

# FIXME: Is "" equal to undef?..
# FIXME: Does Perl have TRUE and FALSE constants?
if(!$globalError){
return 1;
} else {
return 0;
}
}