Hi Maxim,
> 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...
right... you look like Blair and Clinton saying the Human Genome has been
'completely' discovered. Simple, but....
## the first part is not needed in PHP, untile the ###### line
> #!/usr/bin/perl
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
Until here he reads in the URL variables into the array $pair. I know the
famous formmail from Matts' script archive (free and translated to php
somewhere) has a good routine to read either GET or POST variables. Check
the formmail.php to see if that part is translated to php.
> $value =~ tr/+/ /;
change plus to space.
If you use a form with the GET method the variables are put in this line in
the URL (path/file.php?var1=words&var2=123&var3=a good day)
But var3 has spaces between the words so the browser usually replaces the
spaces in a form element with %20 but sometimes (old browsers? at altavista
you could see it, maybe still) the space was changed to a plus. So this is
just changing the value back.
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
So if the space was turned into %20 change it back to a space. And same for
other characters that were safely changed to a %00 to %FF code in the URL
(tabs, new lines etc) using some mystery pack function.
The equivalent of this line in PHP is urldecode($value); (see php manual)
It looks like this is specially for the way you have to deal with this in
CGI.
> if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
> else { $INPUT{$name} = $value; }
> }
##########################
Everything up till here is NOT NECESSARY IN PHP!
PHP has some built-in functionality making form handling a lot simpler.
If you use a form, give every elemant a name. Use method=POST and all names
are available in the called php page as $name. (For arrays look at this
newslist archives). No need for translations of variable values.
> $pid = fork();
I've seen the question on this mailing list more often from previous perl
programmes: 'how can i fork.' and it seemed as if they meant to call another
function and have two functions run simultaneously.
I'ld say, ignore it. Just make sure you don't overload the server with too
many emails at once, if you syuspect that build in a break after sending one
mail, i think function pause() does that. Many PHPeople use qmail, don't
know why.
> print "Content-type: text/html \n\n fork failed: $!" unless defined $pid;
Apparently when you call fork the message has to split up in several
simultaneous runs and the print line is only read when that fails.
Ignore it, it seems not necessary for PHP and sendmail.
> if ($pid) {
>
> ... bla bla bla
>
> }
> else {
>
> close (STDOUT);
Finally the Perl script is finished woth the variables. Praise PHP!
> open(LIST,"$INPUT{'address_file'}");
> @addresses=<LIST>;
> close(LIST);
here he reads in a list of adresses form a file defined in the form in a
field called address_file. Check the PHP manual for reading in lines from
files like this.
> foreach $line(@addresses) {
for every email address he found
> chomp($line);
probably trim() the read line to remove spaces. Perl tends to be anarchistic
in choosing function names.
> open(MAIL, "|$INPUT{'mail_prog'} -t") || &error("Could not send out
> print MAIL "\n\n";
> close (MAIL);
The part between open and close (MAIL) do the mailing. In the open line you
see he checks which email program to use. In PHP in stead of
print MAIL.=
use
$message.=
First complete the $message then use sendmail() instead.
for this:
> if ($INPUT{'html'}) {
use
if isset($html)
>[EMAIL PROTECTED]
shit have i been working for an inc?
Damn.
That'll be $FF (hex) then please! 8-P
Chris
--------------------------------------------------------------------
-- C.Hayes Droevendaal 35 6708 PB Wageningen the Netherlands --
--------------------------------------------------------------------
--
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]