Improved fix for https://bugs.cacert.org/view.php?id=922
CAcert application code problem causing missing "certificate about to expire messages"
This commit is contained in:
parent
d6c92c4877
commit
e870b86839
2 changed files with 66 additions and 16 deletions
|
@ -622,10 +622,31 @@
|
||||||
{
|
{
|
||||||
$row = mysql_fetch_assoc($res);
|
$row = mysql_fetch_assoc($res);
|
||||||
echo $row['domain']."<br>\n";
|
echo $row['domain']."<br>\n";
|
||||||
mysql_query("update `domains` set `deleted`=NOW() where `id`='$id'");
|
|
||||||
$dres = mysql_query("select * from `domlink` where `domid`='$id'");
|
$dres = mysql_query(
|
||||||
|
"select `domaincerts`.`id`
|
||||||
|
from `domaincerts`
|
||||||
|
where `domaincerts`.`domid` = '$id'
|
||||||
|
union distinct
|
||||||
|
select `domaincerts`.`id`
|
||||||
|
from `domaincerts`, `domlink`
|
||||||
|
where `domaincerts`.`id` = `domlink`.`certid`
|
||||||
|
and `domlink`.`domid` = '$id'");
|
||||||
while($drow = mysql_fetch_assoc($dres))
|
while($drow = mysql_fetch_assoc($dres))
|
||||||
mysql_query("update `domaincerts` set `revoked`='1970-01-01 10:00:01' where `id`='".$drow['certid']."' and `revoked`=0 and UNIX_TIMESTAMP(`expire`)-UNIX_TIMESTAMP() > 0");
|
{
|
||||||
|
mysql_query(
|
||||||
|
"update `domaincerts`
|
||||||
|
set `revoked`='1970-01-01 10:00:01'
|
||||||
|
where `id` = '".$drow['id']."'
|
||||||
|
and `revoked` = 0
|
||||||
|
and UNIX_TIMESTAMP(`expire`) -
|
||||||
|
UNIX_TIMESTAMP() > 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_query(
|
||||||
|
"update `domains`
|
||||||
|
set `deleted`=NOW()
|
||||||
|
where `id` = '$id'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
foreach($days as $day => $warning)
|
foreach($days as $day => $warning)
|
||||||
{
|
{
|
||||||
$query = "SELECT `emailcerts`.`id`,`users`.`fname`,`users`.`lname`,`users`.`email`,`emailcerts`.`memid`,
|
$query = "SELECT `emailcerts`.`id`,`users`.`fname`,`users`.`lname`,`users`.`email`,`emailcerts`.`memid`,
|
||||||
`emailcerts`.`subject`, `emailcerts`.`crt_name`,`emailcerts`.`CN`,
|
`emailcerts`.`subject`, `emailcerts`.`crt_name`,`emailcerts`.`CN`, `emailcerts`.`serial`,
|
||||||
(UNIX_TIMESTAMP(`emailcerts`.`expire`) - UNIX_TIMESTAMP(NOW())) / 86400 as `daysleft`
|
(UNIX_TIMESTAMP(`emailcerts`.`expire`) - UNIX_TIMESTAMP(NOW())) / 86400 as `daysleft`
|
||||||
FROM `users`,`emailcerts`
|
FROM `users`,`emailcerts`
|
||||||
WHERE UNIX_TIMESTAMP(`emailcerts`.`expire`) - UNIX_TIMESTAMP(NOW()) > -7 * 86400 and
|
WHERE UNIX_TIMESTAMP(`emailcerts`.`expire`) - UNIX_TIMESTAMP(NOW()) > -7 * 86400 and
|
||||||
|
@ -56,7 +56,11 @@
|
||||||
$body = sprintf(_("Hi %s"), $row['fname']).",\n\n";
|
$body = sprintf(_("Hi %s"), $row['fname']).",\n\n";
|
||||||
$body .= _("You are receiving this email as you are the listed contact for:")."\n\n";
|
$body .= _("You are receiving this email as you are the listed contact for:")."\n\n";
|
||||||
$body .= $row['subject']."\n\n";
|
$body .= $row['subject']."\n\n";
|
||||||
$body .= sprintf(_("Your certificate is set to expire in approximately %s days time, you can renew this by going to the following URL:"), $row['daysleft'])."\n\n";
|
$body .= sprintf(_("Your certificate with the serial number %s is ".
|
||||||
|
"set to expire in approximately %s days time. You can ".
|
||||||
|
"renew it by going to the following URL:"),
|
||||||
|
$row['serial'],
|
||||||
|
$row['daysleft'])."\n\n";
|
||||||
$body .= "https://www.cacert.org/account.php?id=5\n\n";
|
$body .= "https://www.cacert.org/account.php?id=5\n\n";
|
||||||
$body .= _("Best Regards")."\n"._("CAcert Support");
|
$body .= _("Best Regards")."\n"._("CAcert Support");
|
||||||
sendmail($row['email'], "[CAcert.org] "._("Your Certificate is about to expire"), $body, "support@cacert.org", "", "", "CAcert Support");
|
sendmail($row['email'], "[CAcert.org] "._("Your Certificate is about to expire"), $body, "support@cacert.org", "", "", "CAcert Support");
|
||||||
|
@ -68,16 +72,37 @@ echo $row['fname']." ".$row['lname']." <".$row['email']."> (memid: ".$row['memid
|
||||||
|
|
||||||
foreach($days as $day => $warning)
|
foreach($days as $day => $warning)
|
||||||
{
|
{
|
||||||
$query = "SELECT `domaincerts`.`id`, `users`.`fname`, `users`.`lname`, `users`.`email`,
|
$select_clause =
|
||||||
`domains`.`memid`, `domaincerts`.`subject`, `domaincerts`.`crt_name`,
|
"`domaincerts`.`id`,
|
||||||
|
`users`.`fname`, `users`.`lname`, `users`.`email`,
|
||||||
|
`domains`.`memid`,
|
||||||
|
`domaincerts`.`subject`, `domaincerts`.`crt_name`,
|
||||||
`domaincerts`.`CN`,
|
`domaincerts`.`CN`,
|
||||||
(UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP(NOW())) / 86400 AS `daysleft`
|
`domaincerts`.`serial`,
|
||||||
FROM `users`, `domaincerts`, `domlink`, `domains`
|
(UNIX_TIMESTAMP(`domaincerts`.`expire`) -
|
||||||
WHERE UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP(NOW()) > -7 * 86400 AND
|
UNIX_TIMESTAMP(NOW())) / 86400 AS `daysleft`";
|
||||||
UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP(NOW()) < $day * 86400 AND
|
$where_clause =
|
||||||
`domaincerts`.`renewed`=0 AND `domaincerts`.`warning` <= '$warning' AND
|
"UNIX_TIMESTAMP(`domaincerts`.`expire`) -
|
||||||
`domaincerts`.`revoked`=0 AND `users`.`id` = `domains`.`memid` AND
|
UNIX_TIMESTAMP(NOW()) > -7 * 86400
|
||||||
`domlink`.`certid` = `domaincerts`.`id` AND `domains`.`id` = `domlink`.`domid`";
|
AND UNIX_TIMESTAMP(`domaincerts`.`expire`) -
|
||||||
|
UNIX_TIMESTAMP(NOW()) < $day * 86400
|
||||||
|
AND `domaincerts`.`renewed` = 0
|
||||||
|
AND `domaincerts`.`warning` <= '$warning'
|
||||||
|
AND `domaincerts`.`revoked` = 0
|
||||||
|
AND `domains`.`memid` = `users`.`id`";
|
||||||
|
$query =
|
||||||
|
"SELECT $select_clause
|
||||||
|
FROM `users`, `domaincerts`, `domains`
|
||||||
|
WHERE $where_clause
|
||||||
|
AND `domaincerts`.`domid` = `domains`.`id`
|
||||||
|
UNION DISTINCT
|
||||||
|
SELECT $select_clause
|
||||||
|
FROM `users`,
|
||||||
|
`domaincerts` LEFT JOIN `domlink` ON
|
||||||
|
(`domaincerts`.`id` = `domlink`.`certid`),
|
||||||
|
`domains`
|
||||||
|
WHERE $where_clause
|
||||||
|
AND `domlink`.`domid` = `domains`.`id`";
|
||||||
$res = mysql_query($query);
|
$res = mysql_query($query);
|
||||||
while($row = mysql_fetch_assoc($res))
|
while($row = mysql_fetch_assoc($res))
|
||||||
{
|
{
|
||||||
|
@ -88,7 +113,11 @@ echo $row['fname']." ".$row['lname']." <".$row['email']."> (memid: ".$row['memid
|
||||||
$body = sprintf(_("Hi %s"), $row['fname']).",\n\n";
|
$body = sprintf(_("Hi %s"), $row['fname']).",\n\n";
|
||||||
$body .= _("You are receiving this email as you are the listed contact for:")."\n\n";
|
$body .= _("You are receiving this email as you are the listed contact for:")."\n\n";
|
||||||
$body .= $row['subject']."\n\n";
|
$body .= $row['subject']."\n\n";
|
||||||
$body .= sprintf(_("Your certificate is set to expire in approximately %s days time, you can renew this by going to the following URL:"), $row['daysleft'])."\n\n";
|
$body .= sprintf(_("Your certificate with the serial number %s is ".
|
||||||
|
"set to expire in approximately %s days time. You can ".
|
||||||
|
"renew it by going to the following URL:"),
|
||||||
|
$row['serial'],
|
||||||
|
$row['daysleft'])."\n\n";
|
||||||
$body .= "https://www.cacert.org/account.php?id=12\n\n";
|
$body .= "https://www.cacert.org/account.php?id=12\n\n";
|
||||||
$body .= _("Best Regards")."\n"._("CAcert Support");
|
$body .= _("Best Regards")."\n"._("CAcert Support");
|
||||||
sendmail($row['email'], "[CAcert.org] "._("Your Certificate is about to expire"), $body, "support@cacert.org", "", "", "CAcert Support");
|
sendmail($row['email'], "[CAcert.org] "._("Your Certificate is about to expire"), $body, "support@cacert.org", "", "", "CAcert Support");
|
||||||
|
|
Loading…
Reference in a new issue