anmaco has asked for the wisdom of the Perl Monks concerning the following question:
AND#!/usr/bin/perl # Ouvrir le fichier $i=0; if (open (FICHIER, "<gbook.txt") != false) { # flock (FICHIER, 1); # verrouille en lecture $max=0; while (<FICHIER>) { push(@Lignes,$_); $max++; } # flock (FICHIER, 8); # déverrouille close (FICHIER); # Sortie vers le navigateur : print "Content-type: text/html\n\n"; print <<html_fin; <HTML> <HEAD> <TITLE>Visitor's Book</TITLE> </HEAD> <body bgcolor="#FFFFFF" background="../Backgrounds/parch2.jpg"> <img src="../Pictures/ourvisitorsbook2.jpg" width="758" height="231"> <p align="center"> </p> <p align="center"><font face="Comic Sans MS, Arial" size="+2" color="# +652C16">Here are the messages we have received</font></p> <p> </p> html_fin for ($i=0; $i<$max; $i+=6) { $time = @Lignes[$i+0]; $PNom = @Lignes[$i+1]; $NomFam = @Lignes[$i+2]; $email = @Lignes[$i+3]; $subject = @Lignes[$i+4]; $body = @Lignes[$i+5]; print "<B>", $PNom, " ", $NomFam, "</B> (<B><A HREF=\"mailto:", $email, "\">", $email, "</A></B>)<BR><BR>\n"; print "wrote on <B>", $time, "</B> on the subject <B>", $subject, "</B>:<BR><BR>\n"; print "<I>", $body, "</I><HR>\n"; } print <<html_fin; <p align="center"><font face="Comic Sans MS, Arial" color="#652C16">"I +f you would like, you can also <a href="../Drop_us_a_line.htm">write +a message</a> in our Visitor's Book, or <a href="../Index.htm">go bac +k</a> to the Homepage.</font> </p> <p> </p> <p align="center"><font face="Comic Sans MS, Arial" color="#652C16"><i +><font size="+1"><b><u>Have fun!</u></b<</font></i></font></p> <p> </p> </BODY> </HTML> html_fin } else # erreur fichier { print <<html_fin; <HTML> <HEAD> <TITLE>Erreur</TITLE> </HEAD> <BODY> <B>Impossible to read the Visitor's Book</B> <P> Please <A HREF="../index.html">go back</A> to the Homepage. <P> <I><B>Have fun!</B></I> </BODY> </HTML> html_fin } exit;
#!/usr/bin/perl # Exploiter les variables d'environnement : if($ENV{'REQUEST_METHOD'} eq 'GET') { $Data = $ENV{'QUERY_STRING'} } else { read(STDIN, $Data, $ENV{'CONTENT_LENGTH'}) } $i=0; @ChampsFormulaire = split(/&/, $Data); foreach $Champ (@ChampsFormulaire) { ($name, $value) = split(/=/, $Champ); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; $value =~ s/\n/<BR>/g; # transformer Newline en <BR> $Formulaire[$i] = $name; $i = $i + 1; $Formulaire[$i] = $value; $i = $i + 1; } # Extraire date et heure $ValActu = time(); $HeureActu = localtime($ValActu); # ouvre le fichier pour l'adjonction if (open (FICHIER, ">>gbook.txt") != false) { # flock (FICHIER, 2); # verouille en écriture print FICHIER "$HeureActu\n"; for ($i=0; $i<=$#Formulaire; $i=$i+2) { print FICHIER $Formulaire[$i+1], "\n"; } # flock (FICHIER, 8); # déverrouille close (FICHIER); # Sortie vers le navigateur : print "Content-type: text/html\n\n"; print <<html_fin; <HTML> <HEAD> <TITLE>Merci</TITLE> </HEAD> <BODY> <B>Thank you for adding to my Visitor's Book.</B> <P> You can now ' <A HREF="read_lo.pl">read</A> your message, and all the others... or <A HREF="../index.html">return</A> to my Homepage. <P> <I><B>Have fun !</B></I> </BODY> </HTML> html_fin } else # erreur fichier { # Sortie vers le navigateur : print "Content-type: text/html\n\n"; print <<html_fin; <HTML> <HEAD> <TITLE>Erreur</TITLE> </HEAD> <BODY> <B>Impossible to write in the Visitor's Book</B> <P> You can <A HREF="../index.html">return</A> to my Homepage. <P> <I><B>Have fun !</B></I> </BODY> </HTML> html_fin } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Server Error Messages
by BigJoe (Curate) on Jun 25, 2000 at 23:13 UTC | |
by anmaco (Novice) on Jun 25, 2000 at 23:37 UTC |