Документ взят из кэша поисковой машины. Адрес оригинального документа : http://hea.iki.rssi.ru/Z-90/z90-culdb.pl~
Дата изменения: Fri Nov 19 11:03:34 2004
Дата индексирования: Mon Oct 1 20:36:23 2012
Кодировка:
#!/usr/bin/perl

#use Text::BibTeX;


require "bp.pl";

# get current time and data
@TIME = localtime(time);
$DATE = @TIME[3].".".(@TIME[4]+1).".".(@TIME[5]+1900);
$time = @TIME[2].":".@TIME[1].":".@TIME[0];


$bib_file="/tmp/z90-form.bib";
$head="/export/web/www/Z-90/head.html";
$tail="/export/web/www/Z-90/tail.html";
$form="form";

@TIME = localtime(time);
$DATE = @TIME[3].".".(@TIME[4]+1).".".(@TIME[5]+1900);
$time = @TIME[2].":".@TIME[1].":".@TIME[0];
$query;

if($ENV{'REQUEST_METHOD'} eq 'GET'){
$query = $ENV{'QUERY_STRING'};
}elsif($ENV{'REQUEST_METHOD'} eq 'POST'){
sysread(STDIN,$query,$ENV{'CONTENT_LENGTH'});
}
$query=urldecode($query);



if($query ne ''){
@fvalues = split(/&/,$query);

foreach $i (0 .. $#fvalues){
$str=$fvalues[$i];
($name,$val) = split(/=/,$fvalues[$i],2);
$name=&urldecode($name);
$val=&urldecode($val);
$field{$name} = $val;
}
}


print "Content-Type: text/html\n\n";


# my $bibfile = new Text::BibTeX::File "/tmp/foo.bib";
# my $newfile = new Text::BibTeX::File ">/tmp/newfoo.bib";
# while ($entry = new Text::BibTeX::Entry $bibfile)
# {
# next unless $entry->parse_ok;
# print "
".$entry->key."
";
# $entry->write ($newfile);
# }
# exit 0;



if(checkf($head)){
open FD,"<$head" ;
while (){
print;
}close FD;
}

&check ($bib_file);

if(checkf($tail)){
open FD,"<$tail" ;
while (){
print;
}close FD;
}


sub urldecode{
local($val)=@_;
$val =~ s/\+/ /g;
$val =~ s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
return $val;
}


sub check{
&bib'format("auto");

%prelist=();

print "";
foreach $file ($_[0]) {
next unless &bib'open($file);
$totrecs = 0;

while ($record = &bib'read($file) ) {

%entry = &bib'explode($record);

#
# split author name to extract last name and make shorter first name.
#

@l = split " ",$entry{'author'};
$key = pop @l;
push @l," $key";
if( defined $prelist{$key}){
$key.=$idx;
$idx++;
}

# if(scalar(@l)>1){
# $name = shift @l;
# unshift @l," ".(uc(substr $name,0,1)).".";
# }

$prelist{$key} ="\n \n".join(" ",@l)
if(defined($entry{'author'}));
$prelist{$key}.="\n".$entry{'attendence'}."\n"
if(defined($entry{'attendence'}));

# $prelist{$key}.="\n".$entry{'title'}."
\n"
# if(defined($entry{'title'}));
$totrecs++;
}
&bib'close($file);
}

print "";

print "";

foreach $i (keys %prelist){
print "$prelist{$i}";
}
print "
ParticipantProbability of attendance
";


print "
Total number of pre-registered partisipants is $totrecs.

";

print "";

}

sub checkf{
unless (-f $_[0]){
print "ERROR: Can\'t open file \"$_[0]\"" ;
return false;
}else{
return true;
}
}