www.pudn.com > cadisrch.zip > cadi_out.pl
#! /usr/local/bin/perl
#############################################################
# CADI-Search Version 0.07 beta #
# Copyright 1997 Philippe Cadic #
# #
# Please read the header of cadi_in.pl for conditions #
# of use. #
# #
# Copyright 1997 - Ph.Cadic ccadic@planetepc.fr #
# Po Box 2887 - 41028 Blois Cedex - France #
# Tel: +33-2-54560876 #
# #
#############################################################
# Var for configuration
# You may change the VAR values
#
# Think of chmod in 777 'base.txt'
# Think of chmod in 755 cadi_in.pl
# Si il y a des images
$base ='/home/www/cgi-local/base.txt'; # The location of the database
$urlcadi = 'http://www.provider.com/cadisearch'; #URL of the Cadi-Search directory
# The main page of this directory is suppposed called index.html
$master = 'your@email.com'; # Place your email here
$cgirep = 'http://www.provider.com/cgi-local'; # The URL of your cgi programs
# Routine d'entete de resultat
sub entete
{
print "Content-type: text/html\n\n";
print ("
CADI-Search(


"); }
#routine de fin de page html
sub finhtml
{
print("
© 1997 Philippe
Cadic.
All images, html and
source codes are copyright 1997
For source code, please e-mail
")
}
# Routine de bas de resultat
# Routine d'erreur fichier de base introuvable
sub error
{ &entete;
print ("CADI-Search's database not found
");
&finhtml;
exit;
}
# Suce les mots cle de la page web
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webifie les signes plus et %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# regarde si il y a du boulot a faire - chaine non vide
if ($FORM{'mots'} eq "" | $FORM{'mots'} =~ /^ /)
{
&entete;
print ("
");
if ($FORM{'mots'} eq "")
{
print "You didn\'t submit a search string.";
}
else
{
print "Your search string started with a space.";
}
print '
';
print 'Please press the "back" button and try again.
';
print "Please contact the Webmaster, $master ";
print "if you need further assistance.
";
print ("
");
&finhtml;
exit 0;
}
# Lecture complete de la base de donnee
# Integration de celle ci dans un tableau
unless (open (LABASE,"$base")) {die (&error);}
@input = ;
&entete;
#Compte les donnees URL dans la base
$nombre = @input;
print ("Number of URL in the database: $nombre ");
print ("
Result of the Search");
print ("
");
# Recherche du mot ou des mots cle(s) dans la base
# Comparaison de FORM {'mots'} avec la base
# Parametre de recherche du mot cle $ligne =~ /$FORM{'mots'}/g;
$compte = 0;
print (""); #Fixe la fonte de car
until ($compte == $nombre) {
# Si le mot clé est trouvé dans la ligne
if ($input[$compte] =~ /$FORM{'mots'}/g){
@data = split (/::/,$input[$compte]); #On decompose en elements
print ("- URL : $data[0]
");
print ("Descr: $data[1]");
}
++$compte;
}
print("
"); #restaure la fonte de car
print ("
");
&finhtml;