summaryrefslogtreecommitdiff
path: root/scripts/cron/warning.php
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2012-04-18 18:28:40 +0200
committerMichael Tänzer <neo@nhng.de>2012-04-18 18:28:40 +0200
commitb41f35ea6ed4bef7cb15ffb665c08d1987adcc69 (patch)
tree760e8ebecd8a8ec46dd740f7154edc9d8fd0328f /scripts/cron/warning.php
parent2f25d338d1f7ffe9b0b1e843fa5650f284b0c52a (diff)
downloadcacert-devel-b41f35ea6ed4bef7cb15ffb665c08d1987adcc69.tar.gz
cacert-devel-b41f35ea6ed4bef7cb15ffb665c08d1987adcc69.tar.xz
cacert-devel-b41f35ea6ed4bef7cb15ffb665c08d1987adcc69.zip
bug 922: take care of missing domlink entries or wrongly set domids in
expiration reminder script Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'scripts/cron/warning.php')
-rwxr-xr-xscripts/cron/warning.php33
1 files changed, 24 insertions, 9 deletions
diff --git a/scripts/cron/warning.php b/scripts/cron/warning.php
index 18e89da..8d59ddf 100755
--- a/scripts/cron/warning.php
+++ b/scripts/cron/warning.php
@@ -68,16 +68,31 @@ echo $row['fname']." ".$row['lname']." <".$row['email']."> (memid: ".$row['memid
foreach($days as $day => $warning)
{
- $query = "SELECT `domaincerts`.`id`, `users`.`fname`, `users`.`lname`, `users`.`email`,
- `domains`.`memid`, `domaincerts`.`subject`, `domaincerts`.`crt_name`,
- `domaincerts`.`CN`,
- (UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP(NOW())) / 86400 AS `daysleft`
+ $query =
+ "SELECT `domaincerts`.`id`,
+ `users`.`fname`, `users`.`lname`, `users`.`email`,
+ `domains`.`memid`,
+ `domaincerts`.`subject`, `domaincerts`.`crt_name`,
+ `domaincerts`.`CN`,
+ (UNIX_TIMESTAMP(`domaincerts`.`expire`) -
+ UNIX_TIMESTAMP(NOW())) / 86400 AS `daysleft`
+
FROM `users`, `domaincerts`, `domlink`, `domains`
- WHERE UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP(NOW()) > -7 * 86400 AND
- UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP(NOW()) < $day * 86400 AND
- `domaincerts`.`renewed`=0 AND `domaincerts`.`warning` <= '$warning' AND
- `domaincerts`.`revoked`=0 AND `users`.`id` = `domains`.`memid` AND
- `domlink`.`certid` = `domaincerts`.`id` AND `domains`.`id` = `domlink`.`domid`";
+ WHERE UNIX_TIMESTAMP(`domaincerts`.`expire`) -
+ UNIX_TIMESTAMP(NOW()) > -7 * 86400
+ AND UNIX_TIMESTAMP(`domaincerts`.`expire`) -
+ UNIX_TIMESTAMP(NOW()) < $day * 86400
+ AND `domaincerts`.`renewed` = 0
+ AND `domaincerts`.`warning` <= '$warning'
+ AND `domaincerts`.`revoked` = 0
+ AND (
+ `domaincerts`.`domid` = `domains`.`id`
+ OR (
+ `domaincerts`.`id` = `domlink`.`certid`
+ AND `domlink`.`domid` = `domains`.id`
+ )
+ )
+ AND `domains`.`memid` = `users`.`id`";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
{