Philip_Clark November 3rd, 2000, 02:25 I've been looking around for a simple postcard script that doesn't have a "preview" page and creates an html page on the fly. To pick it up you don't have to enter a "number" or anything, you just click on the link in the email you're sent.
Does anyone know of a postcard script like this that exists?
A response is really needed ASAP. Thanks.
Cheers
Philip
cds November 3rd, 2000, 14:53 This is not exactly what you want...there is a preview page...HOWEVER..just change the sub call and you can skip it...
It does allow the reciever to do a one click to get to the page. The way the script is originally setup is that the reciever gets an email saying EITHER go to this page and type the number OR just click this link. To get it to do what you want, just change the email message so it only displays the latter.
Anyway, I haven't really looked at this script that much but you can prob change it to do what you want it to do, right?
Oh, its in PHP...is this ok for you? If so, here's the link:
http://www.openconcept.on.ca/guide-cards.phtml
Philip_Clark November 3rd, 2000, 15:51 Hi Cds,
Thanks a lot for your suggestion. Really is appreciated.
However I really need the script to be in Perl. At the moment i'm using this script that works perfectly for me except it has a "preview" feature. Is it a quick fix to remove it? Can you help me remove it?:
#!/usr/bin/perl
use Socket;
$|=1;
@okaydomains=("");
$DAYS=11;
$SEND_MAIL="/usr/bin/sendmail -t";
$BASEDIR="cards";
$BASEURL="http://server5.hypermart.net/philipclark/cards";
$SITEURL="http://server5.hypermart.net/philipclark";
$SITENAME="Test";
$EXT=".html";
$PROGNAME="http://server5.hypermart.net/philipclark";
$MAILLOG="maillog";
$SUBJECT ="You have a postcard waiting for you!";
&main_driver;
sub thank_you
{
if ($MAILLOG ne "")
{
open (ML,">>$BASEDIR/$MAILLOG");
print ML "$fields{'recip_email'}\n";
print ML "$fields{'sender_email'}\n";
close(ML);
}
print "Content-type: text/html\n\n";
print <<__STOP_OF_THANKS__;
<CENTER>
<font face="Comic Sans MS, Verdana, Arial, sans-serif" size="2"><font size="3" color="#013FC4"><B>THANKS!</B></font><br><br>
Your card notification has been sent to $fields{'recip_name'}<BR><br>
The URL of this card is:
<A HREF="$URL_NAME">$URL_NAME</A>
<P>
__STOP_OF_THANKS__
}
sub setup_letter
{
$msgtext =<<__STOP_OF_MESSAGE__;
A South Seas postcard from $fields{'sender_name'} has been sent to you!
To pick-up your postcard, go to the following URL:
$URL_NAME
__STOP_OF_MESSAGE__
}
sub make_body
{
$cardbody =<<__END_OF_CARD_BODY__;
$BODYTAG
$params
</html>
<html>
<body bgcolor="#FFFFFF" link="#013FC4" vlink="#013FC4" alink="#013FC4">
<div align=center>
<table width="100%" border="0" cellspacing="0" cellpadding=0" background="bkgnd.gif">
<tr align="center">
<td valign="top"><font size="6" face="Tahoma, Arial, sans-serif"><i><i><i><font face="Garamond, Times New Roman, serif" color="#FFFFFF"></font></i><font face="Garamond, Times New Roman, serif" color="#FFFFFF">A
Postcard from the South Seas</font></i><font face="Garamond, Times New Roman, serif" color="#FFFFFF"></font></i></font></td>
</tr>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="0" width="410">
<tr>
<td align="center"><IMG SRC=$BASEURL/$fields{'pic_select'} BORDER=0></td>
</tr>
<tr>
<td>
<p><font face="Comic Sans MS, Verdana, Arial, sans-serif" size="2"><font size="3" color="#013FC4">
Dear $fields{'recip_name'},</font><br>
$fields{'the_message'}<br>
<br>
<font size="3" color="#013FC4"> From $fields{'sender_name'}</font></font></p>
</td>
</tr>
</table>
<br>
<br>
<font face="Comic Sans MS, Verdana, Arial, sans-serif" size="2"><a href="http://www.ecomsystems.net.nz/ssvpostcard/intro.htm">Reply
or send a South Sea Postcard to someone...</a><br>
<br>
<a href="http://www.southseavacations.com">Take a look at the great South Sea
Vacation deals available...</a></font><br>
</div>
__END_OF_CARD_BODY__
}
sub pass_params
{
$params=<<__END_OF_PARAMS__;
<CENTER>
<TABLE WIDTH=500>
<TR>
<TD>
<font face="Comic Sans MS, Verdana, Arial, sans-serif" size="2">
To send your E-Card, click on the Send Card button. To make changes please press your
browser's back button.
<P>
<P>
<CENTER>
<FORM METHOD="POST" ACTION="$PROGNAME">
<INPUT TYPE="HIDDEN" NAME="action_code" VALUE="SENDCARD">
<INPUT TYPE="HIDDEN" VALUE="$fields{'pic_select'}" NAME="pic_select">
<INPUT TYPE="HIDDEN" VALUE="$fields{'sender_name'}" NAME="sender_name">
<INPUT TYPE="HIDDEN" VALUE="$fields{'sender_email'}" NAME="sender_email">
<INPUT TYPE="HIDDEN" VALUE="$fields{'recip_name'}" NAME="recip_name">
<INPUT TYPE="HIDDEN" VALUE="$fields{'recip_email'}" NAME="recip_email">
<INPUT TYPE="HIDDEN" VALUE="$fields{'text_color'}" NAME="text_color">
<INPUT TYPE="HIDDEN" VALUE="$fields{'back_color'}" NAME="back_color">
<INPUT TYPE="HIDDEN" VALUE="$fields{'the_title'}" NAME="the_title">
<INPUT TYPE="HIDDEN" VALUE="$fields{'the_message'}" NAME="the_message">
<INPUT TYPE="HIDDEN" VALUE="$fields{'sig_line'}" NAME="sig_line">
<INPUT TYPE="HIDDEN" VALUE="$fields{'midifile'}" NAME="midifile">
<INPUT TYPE="HIDDEN" VALUE="$fields{'background'}" NAME="background">
<INPUT TYPE="HIDDEN" VALUE="$ENV{'HTTP_REFERER'}" NAME="parent">
<INPUT TYPE="submit" VALUE="Send Card">
</FORM>
</CENTER>
</TD>
</TR>
</TABLE>
<P>
<font face="Comic Sans MS, Verdana, Arial, sans-serif" size="2"><CENTER>The E-Card that will be sent is shown below:</CENTER>
__END_OF_PARAMS__
}
sub sendmail {
my ($fromaddr, $replyaddr, $to, $smtp, $subject, $message) = @_;
$to =~ s/[ \t]+/, /g; # pack spaces and add comma
$fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from email address
$replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply email address
$replyaddr =~ s/^([^\s]+).*/$1/; # use first address
$message =~ s/^\./\.\./gm; # handle . as first character
$message =~ s/\r\n/\n/g; # handle line ending
$message =~ s/\n/\r\n/g;
$smtp =~ s/^\s+//g; # remove spaces around $smtp
$smtp =~ s/\s+$//g;
if (!$to)
{
return(-8);
}
if ($SMTP_SERVER ne "")
{
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr))
{
return(-1);
}
if (!socket(MAIL, AF_INET, SOCK_STREAM, $proto))
{
return(-2);
}
if (!connect(MAIL, pack('Sna4x8', AF_INET, $port, $smtpaddr)))
{
return(-3);
}
my($oldfh) = select(MAIL);
$| = 1;
select($oldfh);
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-4);
}
print MAIL "helo $SMTP_SERVER\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-5);
}
print MAIL "mail from: <$fromaddr>\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-5);
}
foreach (split(/, /, $to))
{
print MAIL "rcpt to: <$_>\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-6);
}
}
print MAIL "data\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close MAIL;
return(-5);
}
}
if ($SEND_MAIL ne "")
{
open (MAIL,"| $SEND_MAIL");
}
print MAIL "To: $to\n";
print MAIL "From: $fromaddr\n";
print MAIL "Reply-to: $replyaddr\n" if $replyaddr;
print MAIL "X-Mailer: Perl Powered Socket Mailer\n";
print MAIL "Subject: $subject\n\n";
print MAIL "$message";
print MAIL "\n.\n";
if ($SMTP_SERVER ne "")
{
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-7);
}
print MAIL "quit\r\n";
$_ = <MAIL>;
}
close(MAIL);
return(1);
}
sub no_email
{
print <<__STOP_OF_NOMAIL__;
Content-type: text/html
<FONT FACE=Arial SIZE="2">
<B>
Sorry! Your request could not be processed because of missing
e-mail address(es). Please use your browser's back button to
correct the problem.
</B>
</FONT>
__STOP_OF_NOMAIL__
}
sub send_mail
{
&setup_letter;
$mailresult=&sendmail($fields{sender_email}, $fields{sender_email}, $fields{recip_email}, $SMTP_SERVER, $SUBJECT, $msgtext);
}
sub card_expire
{
local(@items, $item);
opendir(CARDDIR, "$BASEDIR");
@items = grep(/[0-9]$EXT/,readdir(CARDDIR));
closedir(CARDDIR);
foreach $item (@items)
{
if (-M "$BASEDIR/$item" > $DAYS)
{
unlink("$BASEDIR/$item");
}
}
}
sub valid_address
{
$testmail = $fields{'recip_email'};
if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$testmail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
return 0;
}
else
{
return 1;
}
}
sub bad_email
{
print <<__STOP_OF_BADMAIL__;
Content-type: text/html
<FONT SIZE="+1">
<B>
Sorry! Your request could not be processed because of an improper
recipient's e-mail address. Please use your back button to correct the problem.
</B>
</FONT>
__STOP_OF_BADMAIL__
}
sub test_basedir
{
if (not -w $BASEDIR)
{
print <<__STOP_OF_BADBASE__;
Content-type: text/html
<FONT SIZE="+1">
<B>
wrong basedir
</B>
</FONT>
__STOP_OF_BADBASE__
exit;
}
}
############################################################ ######
sub valid_page
{
if (@okaydomains == 0) {return;}
$DOMAIN_OK=0;
$RF=$ENV{'HTTP_REFERER'};
$RF=~tr/A-Z/a-z/;
foreach $ts (@okaydomains)
{
if ($RF =~ /$ts/)
{ $DOMAIN_OK=1; }
}
if ( $DOMAIN_OK == 0)
{ print "Content-type: text/html\n\n Sorry, cant run it from here....";
exit;
}
}
sub decode_vars
{
#This part of the program splits up our data and gets it
#ready for formatting.
$i=0;
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$content =~ s/<!--(.|\n)*-->//g;
$fields{$key}=$content;
$i++;
$item{$i}=$key;
$response{$i}=$content;
}
}
sub get_file_name
{
$proc=$$;
$newnum=time;
$newnum=substr($newnum,4,5);
$date=localtime(time);
($day, $month, $num, $time, $year) = split(/\s+/,$date);
$month=~tr/A-Z/a-z/;
$PREF = "$month$num-";
$FILE_NAME="$BASEDIR/$PREF$newnum$proc$EXT";
$URL_NAME="$BASEURL/$PREF$newnum$proc$EXT";
}
#Write out our HTML FILE
sub create_file
{
open(OUTFILE,">$FILE_NAME") ;
print OUTFILE "$cardbody\n";
close (OUTFILE);
}
#Set up our HTML Preview Form
sub do_preview
{
$count = 1;
$fields{'the_message'} =~s/\"/\'/g;
&pass_params;
&make_body;
print "Content-type: text/html\n\n";
print "$cardbody\n";
$count = 0;
}
sub main_driver
{
&valid_page;
&test_basedir;
&decode_vars;
if ($fields{'recip_email'} eq "")
{ &no_email; exit; }
if (&valid_address == 0)
{ &bad_email; exit; }
if ($fields{'sender_email'} eq "")
{ &no_email; exit; }
if ($fields{'action_code'} eq "NEW")
{ &do_preview; }
if ($fields{'background'} ne "")
{ $BODYTAG="<BODY BACKGROUND=\"$BASEURL/$fields{'background'}\">";}
else { $BODYTAG="<body bgcolor=\"#FFFFFF\" link=\"#013FC4\" vlink=\"#013FC4\" alink=\"#013FC4\">"; }
if ($fields{'action_code'} eq "SENDCARD")
{
&make_body;
&get_file_name;
&create_file;
&setup_letter;
$mailresult=&sendmail($fields{sender_email}, $fields{sender_email}, $fields{recip_email}, $SMTP_SERVER, $SUBJECT, $msgtext);
&thank_you;
if ($DAYS > 0)
{&card_expire;}
}
}
If you want to see the script in action go to http://cgi-bin.spaceports.com/~nixonja/card.html
[Edited by Philip_Clark on 11-03-2000 at 05:12 PM]
cds November 3rd, 2000, 16:09 First of all..congrats on the longest post ever..haha :)
Yeah, it looks pretty easy to fix. On the HTML page (not CGI script) that sends the info to the CGI...look for:
<INPUT TYPE="HIDDEN" NAME="action_code" VALUE="NEW">
and change it to:
<INPUT TYPE="HIDDEN" NAME="action_code" VALUE="SENDCARD">
This should make it skip the preview function.
Hope this works... CDS
Philip_Clark November 3rd, 2000, 16:15 :D
Thanks a lot. I'm off to try it out now.. I'll let you know whether it worked... Thanks :)
cds November 3rd, 2000, 16:16 No prob. If it doesn't work, send me all the files via email to save the sanity of this BBoard...hehe... :)
Philip_Clark November 3rd, 2000, 16:19 Yes it's working!!!!!!!!!!!!!! Thanks a lot for that!!! :) :)
I didn't think it would that simple..
Cheers
Philip_Clark November 3rd, 2000, 16:20 I was getting ready to give you access to my spaceports account actually :)
cds November 3rd, 2000, 20:53 Hehe...no problem, glad to help you out. Incidentally, you may want to check the post on spaceports.com in the html design forum. Seems like its popup city on a 404: no page error... Just so you know :)
[Edited by cds on 11-03-2000 at 11:02 PM]
Philip_Clark November 4th, 2000, 15:00 Cool. Thanks again :)
Hehehe... Try this: http://cgi-bin.spaceports.com/~nixonja/card.html
Hmm... It doesn't seem to like it if you click on the link above but if you copy and paste it into another window it works fine. Wierd...
[Edited by Philip_Clark on 11-04-2000 at 04:05 PM]
cds November 4th, 2000, 17:22 Uh Oh!!!
Looks like your site has been hit by the now infamous spaceport SPAM fullscreen AD popup 404 error (wow that was a long name :)
cds November 4th, 2000, 19:48 Oh nevermind...i got it going...
yeah for some reason they must check the referer and if it comes from any site other than your main site, it hits the 404 error (so people dont leach their site for CGI and so forth).
By the way, Im a huge Star Wars fan, so automatically I love your site :D
Philip_Clark November 4th, 2000, 20:26 Yeah that SPAM ad screen pops up about 3-4 times if you click on the link in my previous message.
God it hard to get rid of as well. Grr...
Well thats great although I've only done the postcard part :)
Philip_Clark November 6th, 2000, 15:26 Hi Cds,
I've just noticed a problem with the script which I hope you can help me with. With the
"message text area" field it doesn't carry through line breaks, e.g. if you enter
"star wars
is
one
great
movie"
it would appear as "star wars is one great movie" when I don't want it to.
Is there something we can add to make it carry through line breaks?
cds November 6th, 2000, 18:47 Yeah, get the variable that holds the main body. Lets say it is $body.
Then, just do this:
$body =~ s/\n/<br>/g;
Hope this works :)
Philip_Clark November 6th, 2000, 19:54 Thanks for that but where do I put it? The name of the variable is "$the_message".
Have a look at the code in one of my earlier posts. :)
cds November 6th, 2000, 19:56 right after you get it in... (or somewhere before you print it out). Just replace $body with $the_message in my example.
[Edited by cds on 11-06-2000 at 09:21 PM]
Philip_Clark November 6th, 2000, 22:29 ok thanks :)
I'll try it out and let you know.
Philip_Clark November 6th, 2000, 23:37 I've tried out the code but it doesn't make any difference. I've copied and pasted the code below:
#!/usr/local/bin/perl
use Socket;
$|=1;
@okaydomains=("http://cgi-bin.spaceports.com/~nixonja/");
$DAYS=11;
$SEND_MAIL="/usr/sbin/sendmail -t";
$BASEDIR="../cards";
$BASEURL="http://cgi-bin.spaceports.com/~nixonja/cards";
$SITEURL="http://cgi-bin.spaceports.com/~nixonja/";
$SITENAME="Test";
$EXT=".html";
$PROGNAME="http://cgi-bin.spaceports.com/~nixonja/cgi-bin/card.cgi";
$MAILLOG="maillog";
$SUBJECT ="You have an e-card waiting for you!";
&main_driver;
sub thank_you
{
if ($MAILLOG ne "")
{
open (ML,">>$BASEDIR/$MAILLOG");
print ML "$fields{'recip_email'}\n";
print ML "$fields{'sender_email'}\n";
close(ML);
}
print "Content-type: text/html\n\n";
print <<__STOP_OF_THANKS__;
<CENTER>
<H2><B>THANKS!</B></H2>
<b>Your card notification has been sent to $fields{'recip_name'}<BR>
The URL of this card is<P>
<A HREF="$URL_NAME">$URL_NAME</A></b>
<P>
__STOP_OF_THANKS__
}
sub setup_letter
{
$msgtext =<<__STOP_OF_MESSAGE__;
Hello,
A postcard from $fields{'sender_name'} is waiting for you at http://cgi-bin.spaceports.com/~nixonja/card.html
To pick-up your postcard, go to the following URL:
$URL_NAME
Thank you!
__STOP_OF_MESSAGE__
}
sub make_body
{
$cardbody =<<__END_OF_CARD_BODY__;
<SCRIPT LANGUAGE="JavaScript">
<!--
if(navigator.userAgent.indexOf("MSIE") != -1)
document.writeln ('');
else
document.writeln ('<EMBED SRC="$BASEURL/$fields{'midifile'}" AUTOSTART="true" HIDDEN="true" VOLUME="80%">');
//-->
</SCRIPT>
<BGSOUND SRC="$BASEURL/$fields{'midifile'}">
$BODYTAG
$params
<CENTER>
<P>
<TABLE WIDTH=580 BGCOLOR=$fields{'back_color'} BORDER=5>
<TR>
<TD>
<TABLE WIDTH=580 BGCOLOR=$fields{'back_color'}>
<TR>
<TD>
<TABLE WIDTH=200 BORDER=4>
<TR>
<TD ALIGN=CENTER VALIGN=CENTER>
<IMG SRC=$BASEURL/$fields{'pic_select'} BORDER=0><P>
</TD>
</TR>
</TABLE>
</TD>
<TD WIDTH=380 VALIGN=TOP >
<CENTER>
<FONT SIZE=+2 COLOR=$fields{'text_color'}
FACE=ARIAL><B>$fields{'the_title'}</B></FONT>
<HR WIDTH=200>
<TABLE WIDTH=355>
<TR>
<TD><FONT FACE=ARIAL COLOR=$fields{'text_color'}>
$fields{'the_message'}
<P ALIGN=CENTER>
<I>$fields{'sig_line'}
</I>
</P>
</FONT>
</TD>
</TR>
</TABLE>
</CENTER>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<P>
</BODY>
</HTML>
__END_OF_CARD_BODY__
}
sub pass_params
{
$params=<<__END_OF_PARAMS__;
<CENTER>
<TABLE WIDTH=500>
<TR>
<TD>
<FONT FACE="Arial" Size=2>
<B>To send your E-Card, click on the Send Card button. To make changes please press your
browser's back button.
</B>
<P>
<CENTER>
<FORM METHOD="POST" ACTION="$PROGNAME">
<INPUT TYPE="HIDDEN" NAME="action_code" VALUE="SENDCARD">
<INPUT TYPE="HIDDEN" VALUE="$fields{'pic_select'}" NAME="pic_select">
<INPUT TYPE="HIDDEN" VALUE="$fields{'sender_name'}" NAME="sender_name">
<INPUT TYPE="HIDDEN" VALUE="$fields{'sender_email'}" NAME="sender_email">
<INPUT TYPE="HIDDEN" VALUE="$fields{'recip_name'}" NAME="recip_name">
<INPUT TYPE="HIDDEN" VALUE="$fields{'recip_email'}" NAME="recip_email">
<INPUT TYPE="HIDDEN" VALUE="$fields{'text_color'}" NAME="text_color">
<INPUT TYPE="HIDDEN" VALUE="$fields{'back_color'}" NAME="back_color">
<INPUT TYPE="HIDDEN" VALUE="$fields{'the_title'}" NAME="the_title">
<INPUT TYPE="HIDDEN" VALUE="$fields{'the_message'}" NAME="the_message">
<INPUT TYPE="HIDDEN" VALUE="$fields{'sig_line'}" NAME="sig_line">
<INPUT TYPE="HIDDEN" VALUE="$fields{'midifile'}" NAME="midifile">
<INPUT TYPE="HIDDEN" VALUE="$fields{'background'}" NAME="background">
<INPUT TYPE="HIDDEN" VALUE="$ENV{'HTTP_REFERER'}" NAME="parent">
<INPUT TYPE="submit" VALUE="Send Card">
</FORM>
</CENTER>
</TD>
</TR>
</TABLE>
<P>
<FONT FACE="Arial" Size=2><CENTER><B>The E-Card that will be sent is shown below:</B></CENTER>
__END_OF_PARAMS__
}
sub sendmail {
my ($fromaddr, $replyaddr, $to, $smtp, $subject, $message) = @_;
$to =~ s/[ \t]+/, /g; # pack spaces and add comma
$fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from email address
$replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply email address
$replyaddr =~ s/^([^\s]+).*/$1/; # use first address
$message =~ s/^\./\.\./gm; # handle . as first character
$message =~ s/\r\n/\n/g; # handle line ending
$message =~ s/\n/\r\n/g;
$smtp =~ s/^\s+//g; # remove spaces around $smtp
$smtp =~ s/\s+$//g;
if (!$to)
{
return(-8);
}
if ($SMTP_SERVER ne "")
{
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr))
{
return(-1);
}
if (!socket(MAIL, AF_INET, SOCK_STREAM, $proto))
{
return(-2);
}
if (!connect(MAIL, pack('Sna4x8', AF_INET, $port, $smtpaddr)))
{
return(-3);
}
my($oldfh) = select(MAIL);
$| = 1;
select($oldfh);
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-4);
}
print MAIL "helo $SMTP_SERVER\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-5);
}
print MAIL "mail from: <$fromaddr>\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-5);
}
foreach (split(/, /, $to))
{
print MAIL "rcpt to: <$_>\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-6);
}
}
print MAIL "data\r\n";
$_ = <MAIL>;
if (/^[45]/)
{
close MAIL;
return(-5);
}
}
if ($SEND_MAIL ne "")
{
open (MAIL,"| $SEND_MAIL");
}
print MAIL "To: $to\n";
print MAIL "From: $fromaddr\n";
print MAIL "Reply-to: $replyaddr\n" if $replyaddr;
print MAIL "X-Mailer: Perl Powered Socket Mailer\n";
print MAIL "Subject: $subject\n\n";
print MAIL "$message";
print MAIL "\n.\n";
if ($SMTP_SERVER ne "")
{
$_ = <MAIL>;
if (/^[45]/)
{
close(MAIL);
return(-7);
}
print MAIL "quit\r\n";
$_ = <MAIL>;
}
close(MAIL);
return(1);
}
sub no_email
{
print <<__STOP_OF_NOMAIL__;
Content-type: text/html
<FONT FACE=Arial SIZE="2">
<B>
Sorry! Your request could not be processed because of missing
e-mail address(es). Please use your browser's back button to
correct the problem.
</B>
</FONT>
__STOP_OF_NOMAIL__
}
sub send_mail
{
&setup_letter;
$mailresult=&sendmail($fields{sender_email}, $fields{sender_email}, $fields{recip_email}, $SMTP_SERVER, $SUBJECT, $msgtext);
}
sub card_expire
{
local(@items, $item);
opendir(CARDDIR, "$BASEDIR");
@items = grep(/[0-9]$EXT/,readdir(CARDDIR));
closedir(CARDDIR);
foreach $item (@items)
{
if (-M "$BASEDIR/$item" > $DAYS)
{
unlink("$BASEDIR/$item");
}
}
}
sub valid_address
{
$testmail = $fields{'recip_email'};
if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$testmail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
return 0;
}
else
{
return 1;
}
}
sub bad_email
{
print <<__STOP_OF_BADMAIL__;
Content-type: text/html
<FONT SIZE="+1">
<B>
Sorry! Your request could not be processed because of an improper
recipient's e-mail address. Please use your back button to correct the problem.
</B>
</FONT>
__STOP_OF_BADMAIL__
}
sub test_basedir
{
if (not -w $BASEDIR)
{
print <<__STOP_OF_BADBASE__;
Content-type: text/html
<FONT SIZE="+1">
<B>
wrong basedir
</B>
</FONT>
__STOP_OF_BADBASE__
exit;
}
}
############################################################ ######
sub valid_page
{
if (@okaydomains == 0) {return;}
$DOMAIN_OK=0;
$RF=$ENV{'HTTP_REFERER'};
$RF=~tr/A-Z/a-z/;
foreach $ts (@okaydomains)
{
if ($RF =~ /$ts/)
{ $DOMAIN_OK=1; }
}
if ( $DOMAIN_OK == 0)
{ print "Content-type: text/html\n\n Sorry, cant run it from here....";
exit;
}
}
sub decode_vars
{
#This part of the program splits up our data and gets it
#ready for formatting.
$i=0;
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$content =~ s/<!--(.|\n)*-->//g;
$fields{$key}=$content;
$i++;
$item{$i}=$key;
$response{$i}=$content;
}
}
sub get_file_name
{
$proc=$$;
$newnum=time;
$newnum=substr($newnum,4,5);
$date=localtime(time);
($day, $month, $num, $time, $year) = split(/\s+/,$date);
$month=~tr/A-Z/a-z/;
$PREF = "$month$num-";
$FILE_NAME="$BASEDIR/$PREF$newnum$proc$EXT";
$URL_NAME="$BASEURL/$PREF$newnum$proc$EXT";
}
#Write out our HTML FILE
sub create_file
{
open(OUTFILE,">$FILE_NAME") ;
print OUTFILE "$cardbody\n";
close (OUTFILE);
}
#Set up our HTML Preview Form
sub do_preview
{
$fields{'the_message'} =~s/\"/\'/g;
&pass_params;
&make_body;
print "Content-type: text/html\n\n";
print "$cardbody\n";
}
sub main_driver
{
&valid_page;
&test_basedir;
&decode_vars;
if ($fields{'recip_email'} eq "")
{ &no_email; exit; }
if (&valid_address == 0)
{ &bad_email; exit; }
if ($fields{'sender_email'} eq "")
{ &no_email; exit; }
if ($fields{'background'} ne "")
{ $BODYTAG="<BODY BACKGROUND=\"$BASEURL/$fields{'background'}\">";}
else { $BODYTAG="<BODY BGCOLOR=\"#FFFFFF\">"; }
if ($fields{'action_code'} eq "NEW")
{ &do_preview; }
if ($fields{'action_code'} eq "SENDCARD")
{
$the_message =~ s/\n/<br>/g;
&make_body;
&get_file_name;
&create_file;
&setup_letter;
$mailresult=&sendmail($fields{sender_email}, $fields{sender_email}, $fields{recip_email}, $SMTP_SERVER, $SUBJECT, $msgtext);
&thank_you;
if ($DAYS > 0)
{&card_expire;}
}
}
I've also just sent you an email with my username, password, etc if you need access to my spaceports account.
cds November 7th, 2000, 09:18 Ok, I fixed it. Happy card sending!! :)
Philip_Clark November 7th, 2000, 14:05 Thanks so much for doing that!!!!!!!!! :cool: :)
cds November 7th, 2000, 17:01 Oh, by the way, I deleted the email with your user and password information...but if you want to be sure, just change them :)
Good Luck and May the Force Be With You ;)
Philip_Clark November 7th, 2000, 23:08 I'm not worried at all. I trust you :)
NO may the force be with you :)
|
|