Forums
This topic is locked
story.html
Posted 16 Aug 2003 03:45:16
1
has voted
16 Aug 2003 03:45:16 Robert Lee posted:
#!/usr/bin/perl <---This is a progam that allows other people to add to a continuing story. what I need to know is, the area in bold, where would I locate that on my system and what perl is?here is the thing i am asking about##############################################################################
# Cliff's Never Ending Story Script Version 1.02 #
# Copyright 1998 Shaven Ferret Productions #
# Created 10/21/98 Last Modified 04/21/99 #
# Available at www.shavenferret.com/scripts #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998 Shaven Ferret Productions All Rights Reserved. #
# #
# This script can be used\modified free of charge as long as you don't #
# change this header thing, or the parts that generate the return links. If #
# you really need to change these things, go to #
# www.shavenferret.com/scripts/register.shtml . By using this script #
# you agree to indemnify me from any liability that might arise from its use.#
# In simple English, if this script somehow makes your computer run amuck #
# and kill the pope, it's not my fault. #
# #
# Redistributing\selling the code for this program without prior written #
# consent is expressly forbidden. #
##############################################################################
# Enter the server path to the story page.
$path = "/server/path/to/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 = 1;
# 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 = 1;
##############################################################################
# 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. #
##############################################################################
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;
$FORM{$name} = $value;
}
print "Content-type: text/html\n\n";
if ($usename) {
unless ($FORM{'name'}) {
print "<html><head><title>Please enter your name.</title></head>\n";
print "<body><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><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><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;
}
if ($FORM{'email'} && $FORM{'name'}) { $poster = "<a href=\"mailto:$FORM{'email'}\">$FORM{'name'}</a>"; }
elsif ($FORM{'name'}) { $poster = "$FORM{'name'}"; }
elsif ($FORM{'email'}) { $poster = "<a href=\"mailto:$FORM{'email'}\">$FORM{'email'}</a>"; }
else { $poster = "anonymous"; }
open(FILE,"$path"

@lines = <FILE>;
close(FILE);
open(FILE,">$path"

foreach $line(@lines) {
if (substr($line,0,10) eq "<!--add-->"

print FILE "<tr><td width=\"190\"><center>This paragraph is by\n";
print FILE "$poster</center></td><td width=\"350\">\n";
print FILE " $FORM{'story'}</td></tr>\n";
print FILE "<!--add-->\n";
}
else { print FILE "$line"; }
}
print "<html><head><title>Thank you!</title></head><body>\n";
print "Thanks for adding to the story! Please click back and hit reload\n";
print "to see your contribution.\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><hr width=\"70%\">Never Ending Story Script by <a hr";
print "ef=\"www.shavenferret.com/cliff/\" target=\"new\">Cli";
print "ff(tm)</a>, <a href=\"www.shavenferret.com\" ta";
print "rget=\"new\">Shaven Ferret Productions</a>, and availab";
print "le at <a href=\"www.shavenferret.com/scripts\" t";
print "arget=\"new\">www.shavenferret.com/scripts</a><h";
print "r width=\"70%\"></center></body></html>\n";
exit;
}
Replies
Replied 16 Aug 2003 07:24:35
16 Aug 2003 07:24:35 Mike McGuire replied:
First off, is this going on a windows or linux web server? Reason why I ask is, if you are going to be on a linux web server the #!/usr/bin/perl should stay at that setting unless you have installed perl somewhere else. But most likely it was a default install and that is were it is located. If on a windows web server then it would be (exp. c:/perl/bin) located differently and located differently on the top of the file. Hope this helps.
logizone
Edited by - logizone on 16 Aug 2003 07:30:28
logizone
Edited by - logizone on 16 Aug 2003 07:30:28
Replied 16 Aug 2003 19:18:01
16 Aug 2003 19:18:01 Robert Lee replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
#!/usr/bin/perl <---This is a progam that allows other people to add to a continuing story. what I need to know is, the area in bold, where would I locate that on my system and what perl is?here is the thing i am asking about
##############################################################################
# Cliff's Never Ending Story Script Version 1.02 #
# Copyright 1998 Shaven Ferret Productions #
# Created 10/21/98 Last Modified 04/21/99 #
# Available at www.shavenferret.com/scripts #
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
yes that does help, and its windows.
#!/usr/bin/perl <---This is a progam that allows other people to add to a continuing story. what I need to know is, the area in bold, where would I locate that on my system and what perl is?here is the thing i am asking about
##############################################################################
# Cliff's Never Ending Story Script Version 1.02 #
# Copyright 1998 Shaven Ferret Productions #
# Created 10/21/98 Last Modified 04/21/99 #
# Available at www.shavenferret.com/scripts #
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
yes that does help, and its windows.