Jag undrar hur man gör för att sensurera vissa ord eller namn i ett cgi skript? alltså när de skriver ett visst namn så kommer den inte upp på sidan utan ett annat namn eller bara **** visas när de skriver det namnet, det är en never ending story jag har där jag inte vill att de ska skriva vissa namn...
skriptet ser ut så här:
#!/usr/bin/perl
# Enter the server path to the story page.
$path = "/web/sites/343/6suryoye/www.6suryoye.f2s.com/cgi-bin/story/story.html";
# If you want to force people to use their names when adding to the story,
# change the 0 in the next line to a 1.
$usename = 0;
# If you want to force people to use their e-mail addresses when adding to the
# story, change the 0 in the next line to a 1.
$useemail = 0;
##############################################################################
# If you don't want the script to tell you every time someone adds to the #
# story, you're done! #
##############################################################################
# If you want the script to tell you every time someone adds to the story,
# remove the # in front of the next line.
#$tellme = -1;
# Enter the path to your mail program
$mailprogram = "/usr/lib/sendmail";
# Enter your e-mail address here. Put a backslash (\) before the @.
$youremail = "you\@yourdomain.com";
##############################################################################
# Congratulations! You've finished defining the variables. If you want to, #
# you can continue screwing with the script, but it isn't necessary. #
##############################################################################
if ($usename) {
unless ($FORM{'name'}) {
print "<html><head><title>Please enter your name.</title></head>\n";
print "<body background=\"http://www.utsikten.com/abraham/bglejon.jpg\\"><h1>Name required</h1>Please click back and enter\n";
print "your name.\n";
&sig;
}
}
if ($useemail) {
$temp = $FORM{'email'};
$temp =~ s/_/a/g; $temp =~ s/-/a/g;
unless ($temp =~ /\w+@\w+\.\w\w+/) {
print "<html><head><title>Please enter your e-mail.</title></head>\n";
print "<body background=\"http://www.utsikten.com/abraham/bglejon.jpg\\"><h1>E-mail required</h1>Please click back and enter\n";
print "your e-mail address.\n";
&sig;
}
}
unless ($FORM{'story'}) {
print "<html><head><title>You forgot something.</title></head>\n";
print "<body background=\"http://www.utsikten.com/abraham/bglejon.jpg\\"><h1>Please add to the story</h1>You're trying to\n";
print "add to the story. You can't do that unless you write\n";
print "something.\n";
&sig;
}
print "<html><head><title>TACKAR!</title></head><body background=\"http://www.utsikten.com/abraham/bglejon.jpg\\"\>\\n";
print "Tack för att du la dit din fortsättning! Klicka på back knappen och uppdatera sidan\n";
print "för att se din fortsättning. Om inte din fortsättning dyker upp på en gång så dyker den upp senare, du beöver inte klicka på add story knappen flera gånger, din fortsättning kommer upp, jag lova!!!\n";
if ($tellme) {
open (MAIL,"|$mailprogram -t");
print MAIL "To: $youremail\n";
print MAIL "From: \"$FORM{'name'}\" <$FORM{'email'}>\n";
print MAIL "Subject: Someone added to the story!\n\n";
print MAIL "Hello. This is just to let you know that someone added\n";
print MAIL "to your never ending story. They wrote:\n\n$FORM{'story'}\n";
close(MAIL);
}
&sig;
sub sig {
# Please do NOT change this sub or any place in this script where this sub
# is called
print "<center><a hr";
print "ef=\"http://\" target=\"new\">";
print "</a>, <a href=\"\" ta";
print "rget=\"new\"></a>, ";
print " <a href=\"\" ";
print "arget=\"new\"></a><";
print "</center></body></html>\n";
exit;
}
Det var nog jag som stirrade mig lite blind på att det var namn som skulle censureras, så det blev $FORM{'name'} som censurerades... Redigerade inlägget ovan, så nu bör det censurera rätt formulärfält :).