#!/usr/bin/perl
######################### Settings #############################
# The UNIX Location to the list.dat
$list ='http://www.londrinaonline.com.br/cgi-bin/classi.pl';
# The Website URL to the Search Engine Page
$urlsearch = 'http://www.londrinaonline.com.br';	
# The Main Page is index.html so make sure to put it in the above directory
#################################################################

# Error Handler
sub error
{    print "Content-type: text/html\n\n";
print "<html><head><title>Error</title></head>\n";
print "<body>/n";
print "<center><h2>Error no cadastro</h2></center>\n";
print "Pressione o botão 'Back' e re-adcione\n";
print "</body></html>";
exit;
}
# Check to see what Request Method was used
if ($ENV{'REQUEST_METHOD'} ne "POST") {$error;
exit;
}
# Get Variables
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Decode Form information
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# Make sure http:// was included
# if ($FORM{'url'}=~ /http:\/\//) {} else {&error};
# Add to Database
$line = join ("::","$FORM{'nome'}","$FORM{'email'}","$FORM{'telefone'}","$FORM{'cidade'}","$FORM{'estado'}","$FORM{'assunto'}","$FORM{'descricao'}","$FORM{'data'}","$FORM{'preco'}","$FORM{'condicoes'}");
open (DBASE,">>$list" );
print DBASE ("$line \n");

# start of HTML
print "Content-type: text/html\n\n";
print ("
<head>
<title>Adiciona links na página</title>
</head>
<body bgcolor=\"white\">
<meta http-equiv=\"refresh\" content=\"0; URL=http://www.londrinaonline.com.br/add-classi.html\">
<b>aguarde gravando arquivo....</b>
</body>
</html>
");