#!/sw/bin/perl #!/sw/bin/perl -w #use strict; ## ## Script to automatically insert hyperlinks to user pages ## into a web page via a registration form ## ## Copyright (C) 1996 - 1999 by Steffen Beyer ## ## ## Version history: ## ## Version Date Name What's new ## ------- -------- -------------------- ----------------------------------- ## 1.0.0 20.11.96 Steffen Beyer First release ## 1.1.0 21.11.96 Steffen Beyer Check for uniqueness, parametrized ## 1.1.1 19.10.99 Steffen Beyer Adjusted for brazilian professionals ## ## ## Global variables: ## my $notify = 'sb@engelschall.com'; my $domain = 'engelschall.com'; my $subject = 'Inscricao profissional brasileiro'; my $exception = ''; my $paragraph = ''; my $confirm = 0; my $self = $0; my $okay = 0; my @max = (); my @name = (); my @item = (); my @text = (); my @value = (); my @select = (); my @button = (); my %valid_name = (); my %valid_item = (); ## ## Configuration: ## sub init_config { my($i); $self =~ s!^.*/!!; $name[1] = 'name'; $max[1] = 40; $name[2] = 'mail'; $name[3] = 'text'; $max[3] = 80; $name[4] = 'link'; $name[5] = 'type'; $name[6] = 'okay'; for ( $i = 1; $i <= $#name; $i++ ) { $valid_name{$name[$i]} = $i; $value[$i] = ''; } $item[ 1] = 'fun'; $item[ 2] = 'cons'; $item[ 3] = 'publ'; $item[ 4] = 'tech'; $item[ 5] = 'food'; $item[ 6] = 'gast'; $item[ 7] = 'tour'; $item[ 8] = 'pres'; $item[ 9] = 'arte'; $item[10] = 'misc'; for ( $i = 1; $i <= $#item; $i++ ) { $valid_item{$item[$i]} = $i; $select[$i] = ''; } $text[ 1] = 'Lazer'; $text[ 2] = 'Consultas'; $text[ 3] = 'Entidades Públicas'; $text[ 4] = 'Equipamentos e Serviços Técnicos'; $text[ 5] = 'Produtos Alimentícios'; $text[ 6] = 'Gastronomia, Partyservice'; $text[ 7] = 'Agências de Turismo'; $text[ 8] = 'Mídia'; $text[ 9] = 'Arte'; $text[10] = 'Diversos'; $button[0] = 'Deixe-me ver como fica!'; $button[1] = 'Agora registre esse link!'; } ## ## Subroutines: ## sub process_data { my($i,$text,$sum,$max,$len,@now,$date); if (($value[1] ne '') && ($value[3] ne '') && ($value[5] > 0)) { $okay = 1; $confirm = 1; } foreach $i (1, 3) { next if (length($value[$i]) <= $max[$i]); $okay = 0; $text = $value[$i]; $value[$i] = ''; $sum = 0; while ($sum < $max[$i]) { $max = $max[$i] - $sum; if ($text =~ m!(&[a-zA-Z][a-z]+;)!) { $text = $'; $len = length($`); if ($len >= $max) { $value[$i] .= substr($`, 0, $max); $sum += $max; } else { $value[$i] .= $` . $1; $sum += ++$len; } } else { $value[$i] .= substr($text, 0, $max); $sum += $max; } } } @now = (localtime())[3,4,5,2,1,0]; $now[1]++; $now[2] %= 100; $date = sprintf("%02d.%02d.%02d %02d:%02d:%02d", @now); $paragraph = qq,
"$text[$value[5]]"
foi bem-sucedida:
"$1"
já existe na categoria
"$text[$value[5]]"!,;
return 0;
}
}
unless (close(READ))
{
$exception = "Erro interno: Não consigo fechar o arquivo '$file': $!";
return 0;
}
}
# if (-e "$file.bak")
# {
# $exception = "Erro interno: O arquivo '$file.bak' já existe!";
# return 0;
# }
# unless (rename($file, "$file.bak"))
# {
# $exception = "Erro interno: Não consigo mudar o nome do arquivo '$file' para '$file.bak': $!";
# return 0;
# }
unless (open(PIPE, "| /sw/bin/sendmail -t"))
{
$exception = "Erro interno: Não consigo abrir o pipe: $!";
return 0;
}
$i = (getpwuid($<))[0];
print PIPE <<"VERBATIM";
From: $i\@$domain
Reply-To: $notify
To: $notify
Subject: $subject
X-Sender: $0
$paragraph
VERBATIM
unless (close(PIPE))
{
$exception = "Erro interno: Não consigo fechar o pipe: $!";
return 0;
}
unless (open(WRITE, ">>$file"))
{
$exception = "Erro interno: Não consigo escrever para o arquivo '$file': $!";
return 0;
}
print WRITE "$paragraph\n\n";
# unless (open(READ, "<$file.bak"))
# {
# close(WRITE);
# $exception = "Erro interno: Não consigo ler o arquivo '$file.bak': $!";
# return 0;
# }
# while (