81 lines
2.3 KiB
Text
81 lines
2.3 KiB
Text
<? /*
|
|
Copyright (C) 2004 by Duane Groth <duane_at_CAcert_dot_org>
|
|
|
|
This file is part of LibreSSL.
|
|
|
|
LibreSSL has been released under a LibreSSL license
|
|
which can be found included with these source files or can
|
|
be downloaded from the internet from the following address:
|
|
http://www.cacert.org/src-lic.php
|
|
|
|
LibreSSL is distributed WITHOUT ANY WARRANTY; without even
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
PARTICULAR PURPOSE. See the License for more details.
|
|
*/
|
|
|
|
mysql_connect("localhost", "username", "password");
|
|
mysql_select_db("database");
|
|
|
|
$_SESSION['_config']['securehostname'] = "secure.cacert.org";
|
|
$_SESSION['_config']['normalhostname'] = "www.cacert.org";
|
|
|
|
function sendmail($to, $subject, $message, $from, $replyto = "", $toname = "", $fromname = "")
|
|
{
|
|
$lines = explode('\n', $message);
|
|
foreach($lines as $line)
|
|
{
|
|
$line = trim($line);
|
|
if($line == ".")
|
|
$message .= " .\n";
|
|
else
|
|
$message .= $line."\n";
|
|
}
|
|
|
|
if($replyto == "")
|
|
$replyto = $from;
|
|
if($fromname == "")
|
|
$fromname = $from;
|
|
|
|
$bits = explode(",", $to);
|
|
|
|
foreach($bits as $user)
|
|
{
|
|
$user = trim($user);
|
|
if($toname == "")
|
|
$toname = $user;
|
|
|
|
$smtp = fsockopen("localhost", 25);
|
|
$InputBuffer = fgets($smtp, 1024);
|
|
fputs($smtp, "HELO hlin.cacert.org\n");
|
|
$InputBuffer = fgets($smtp, 1024);
|
|
fputs($smtp, "MAIL FROM: <$replyto>\n");
|
|
$InputBuffer = fgets($smtp, 1024);
|
|
fputs($smtp, "RCPT TO: <$user>\n");
|
|
$InputBuffer = fgets($smtp, 1024);
|
|
fputs($smtp, "DATA\n");
|
|
$InputBuffer = fgets($smtp, 1024);
|
|
fputs($smtp, "Reply-To: $to\n");
|
|
fputs($smtp, "From: \"$fromname\" <$from>\n");
|
|
fputs($smtp, "To: $to\n");
|
|
fputs($smtp, "Subject: $subject\n\n");
|
|
fputs($smtp, "$message\r\n.\r\n");
|
|
fputs($smtp, "QUIT\n");
|
|
$InputBuffer = fgets($smtp, 1024);
|
|
fclose($smtp);
|
|
}
|
|
}
|
|
|
|
function make_hash()
|
|
{
|
|
if(function_exists("dio_open"))
|
|
{
|
|
$rnd = dio_open("/dev/urandom",O_RDONLY);
|
|
$hash = md5(dio_read($rnd,64));
|
|
dio_close($rnd);
|
|
} else {
|
|
$rnd = fopen("/dev/urandom", "r");
|
|
$hash = md5(fgets($rnd, 64));
|
|
fclose($rnd);
|
|
}
|
|
}
|
|
?>
|