Hello guys,
I *know* it is totally OT, but, I need your help...
 
Below is a piece of PERL code that I am trying to "translate" into PHP. It
is quite simple code needed to send emails within a newsletter.
I kind of tried to rewrite it in PHP but since I know *nothing* about Perl I
found myself asking what does that means and what this...
 
Could anyone who knows Perl that well write me a sketch of the equal script
in PHP?
 
It is simple, I can see it, but I do not understand what is that RegEx for,
what is $pid ( fork() ) and where does it actually send emails... 
 
Thanks in advance,
Maxim Maletsky
 
 
 
 
 
<snip>
 
#!/usr/bin/perl

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;
 if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
 else { $INPUT{$name} = $value; }
}
 
$pid = fork();
print "Content-type: text/html \n\n fork failed: $!" unless defined $pid;
 
if ($pid) {
 
... bla bla bla
 
}
 else {
 
 close (STDOUT);
 open(LIST,"$INPUT{'address_file'}");
 @addresses=<LIST>;
 close(LIST);
 
 foreach $line(@addresses) {
  chomp($line);
 
  open(MAIL, "|$INPUT{'mail_prog'} -t") || &error("Could not send out
emails");
  print MAIL "To: $line \n";
  print MAIL "From: $INPUT{'listname'} <$INPUT{'from'}>\n";
  print MAIL "Subject: $INPUT{'subject'}\n";
  if ($INPUT{'html'}) {
  print MAIL "MIME-Version: 1.0\n"; 
  print MAIL "Content-Type: text/html;\n"; 
  print MAIL "Content-Transfer-Encoding: 7bit\n\n"; 
  }
  print MAIL "$INPUT{'body'}";
  print MAIL "\n\n";
  if ($INPUT{'unsubchk'}) {
   print MAIL
"===========================================================\n";
   print MAIL "You have received this email because you subscribed to the
$INPUT{'listname'} Mailing Service. To unsubscribe simply visit the link
below.\n";
   print MAIL "$INPUT{'url'}/unsub.phtml?list=$INPUT{'list'}&email=$line\n";
  }
  print MAIL "\n\n";
  close (MAIL);
 }
} 
 
</snip>
 
 

Maxim Maletsky - [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
Webmaster, J-Door.com / J@pan Inc.
LINC Media, Inc.
TEL: 03-3499-2175 x 1271
FAX: 03-3499-3109

http://www.j-door.com <http://www.j-door.com/> 
http://www.japaninc.net <http://www.japaninc.net/> 
http://www.lincmedia.co.jp <http://www.lincmedia.co.jp/> 


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to