Updated code in mysql.php to the sample file

pull/1/head
root 17 years ago
parent 9410aa9173
commit fbc5288931

@ -1,14 +1,14 @@
<? /* <? /*
Copyright (C) 2004 by Duane Groth <duane_at_CAcert_dot_org> Copyright (C) 2004 by Duane Groth <duane_at_CAcert_dot_org>
This file is part of LibreSSL. This file is part of CAcert.
LibreSSL has been released under a LibreSSL license CAcert has been released under a CAcert Source License
which can be found included with these source files or can which can be found included with these source files or can
be downloaded from the internet from the following address: be downloaded from the internet from the following address:
http://www.cacert.org/src-lic.php http://www.cacert.org/src-lic.php
LibreSSL is distributed WITHOUT ANY WARRANTY; without even CAcert is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the License for more details. PARTICULAR PURPOSE. See the License for more details.
*/ */
@ -16,13 +16,14 @@
mysql_connect("localhost", "username", "password"); mysql_connect("localhost", "username", "password");
mysql_select_db("database"); mysql_select_db("database");
$_SESSION['_config']['securehostname'] = "secure.cacert.org";
$_SESSION['_config']['normalhostname'] = "www.cacert.org"; $_SESSION['_config']['normalhostname'] = "www.cacert.org";
$_SESSION['_config']['securehostname'] = "secure.cacert.org";
$_SESSION['_config']['tverify'] = "tverify.cacert.org"; $_SESSION['_config']['tverify'] = "tverify.cacert.org";
function sendmail($to, $subject, $message, $from, $replyto = "", $toname = "", $fromname = "") function sendmail($to, $subject, $message, $from, $replyto = "", $toname = "", $fromname = "", $errorsto = "returns@cacert.org", $extra="")
{ {
$lines = explode('\n', $message); $lines = explode('\n', $message);
$message = "";
foreach($lines as $line) foreach($lines as $line)
{ {
$line = trim($line); $line = trim($line);
@ -32,39 +33,66 @@
$message .= $line."\n"; $message .= $line."\n";
} }
if($replyto == "")
$replyto = $from;
if($fromname == "") if($fromname == "")
$fromname = $from; $fromname = $from;
$bits = explode(",", $to); $bits = explode(",", $from);
$from = addslashes($bits['0']);
foreach($bits as $user) $fromname = addslashes($fromname);
{
$user = trim($user);
if($toname == "")
$toname = $user;
$smtp = fsockopen("localhost", 25); $smtp = fsockopen("localhost", 25);
if(!$smtp)
{
echo("Could not connect to mailserver at localhost:25\n");
return;
}
$InputBuffer = fgets($smtp, 1024); $InputBuffer = fgets($smtp, 1024);
fputs($smtp, "HELO hlin.cacert.org\n"); fputs($smtp, "HELO hlin.cacert.org\r\n");
$InputBuffer = fgets($smtp, 1024); $InputBuffer = fgets($smtp, 1024);
fputs($smtp, "MAIL FROM: <$replyto>\n"); fputs($smtp, "MAIL FROM: <returns@cacert.org>\r\n");
$InputBuffer = fgets($smtp, 1024); $InputBuffer = fgets($smtp, 1024);
fputs($smtp, "RCPT TO: <$user>\n"); $bits = explode(",", $to);
foreach($bits as $user)
fputs($smtp, "RCPT TO: <".trim($user).">\r\n");
$InputBuffer = fgets($smtp, 1024); $InputBuffer = fgets($smtp, 1024);
fputs($smtp, "DATA\n"); fputs($smtp, "DATA\r\n");
$InputBuffer = fgets($smtp, 1024); $InputBuffer = fgets($smtp, 1024);
fputs($smtp, "Reply-To: $to\n"); fputs($smtp, "X-Mailer: CAcert.org Website\r\n");
fputs($smtp, "From: \"$fromname\" <$from>\n"); fputs($smtp, "X-OriginatingIP: ".$_SERVER["REMOTE_ADDR"]."\r\n");
fputs($smtp, "To: $to\n"); fputs($smtp, "Sender: $errorsto\r\n");
fputs($smtp, "Subject: $subject\n\n"); fputs($smtp, "Errors-To: $errorsto\r\n");
fputs($smtp, "$message\r\n.\r\n"); if($replyto != "")
fputs($smtp, "Reply-To: $replyto\r\n");
else
fputs($smtp, "Reply-To: $from\r\n");
fputs($smtp, "From: $from\r\n");
fputs($smtp, "To: $to\r\n");
if(preg_match("/[^a-zA-Z0-9 .-\[\]!_@]/",$subject))
{
fputs($smtp, "Subject: =?utf-8?B?".base64_encode(recode("html..utf-8", $subject))."?=\r\n");
}
else
{
fputs($smtp, "Subject: $subject\r\n");
}
fputs($smtp, "Mime-Version: 1.0\r\n");
if($extra == "")
{
fputs($smtp, "Content-Type: text/plain; charset=\"utf-8\"\r\n");
fputs($smtp, "Content-Transfer-Encoding: 8bit\r\n");
} else {
fputs($smtp, "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n");
fputs($smtp, "Content-Transfer-Encoding: quoted-printable\r\n");
fputs($smtp, "Content-Disposition: inline\r\n");
}
// fputs($smtp, "Content-Transfer-Encoding: BASE64\r\n");
fputs($smtp, "\r\n");
// fputs($smtp, chunk_split(base64_encode(recode("html..utf-8", $message)))."\r\n.\r\n");
fputs($smtp, recode("html..utf-8", $message)."\r\n.\r\n");
fputs($smtp, "QUIT\n"); fputs($smtp, "QUIT\n");
$InputBuffer = fgets($smtp, 1024); $InputBuffer = fgets($smtp, 1024);
fclose($smtp); fclose($smtp);
} }
}
function make_hash() function make_hash()
{ {
@ -78,6 +106,7 @@
$hash = md5(fgets($rnd, 64)); $hash = md5(fgets($rnd, 64));
fclose($rnd); fclose($rnd);
} }
return($hash);
} }
function clean_csr($CSR) function clean_csr($CSR)

Loading…
Cancel
Save