summaryrefslogtreecommitdiff
path: root/scripts/cron/warning.php
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2013-06-04 22:48:03 +0200
committerMichael Tänzer <neo@nhng.de>2013-06-04 22:48:03 +0200
commitd2ad5c5c27f4daeabd3f53268cdeab2b706e6e97 (patch)
tree19cc6acef2edbb5261c49474db2fed9ee38aa47f /scripts/cron/warning.php
parentd26f9abb0a6e119250c42811e4b2f60aedf010a6 (diff)
parentde583d9e02a9395c6508301f36a3fa021103818d (diff)
downloadcacert-devel-d2ad5c5c27f4daeabd3f53268cdeab2b706e6e97.tar.gz
cacert-devel-d2ad5c5c27f4daeabd3f53268cdeab2b706e6e97.tar.xz
cacert-devel-d2ad5c5c27f4daeabd3f53268cdeab2b706e6e97.zip
Merge branch 'bug-922' into release
Diffstat (limited to 'scripts/cron/warning.php')
-rwxr-xr-xscripts/cron/warning.php43
1 files changed, 24 insertions, 19 deletions
diff --git a/scripts/cron/warning.php b/scripts/cron/warning.php
index 5cf7c31..0c97ba2 100755
--- a/scripts/cron/warning.php
+++ b/scripts/cron/warning.php
@@ -72,32 +72,37 @@ echo $row['fname']." ".$row['lname']." <".$row['email']."> (memid: ".$row['memid
foreach($days as $day => $warning)
{
- $query =
- "SELECT DISTINCT `domaincerts`.`id`,
+ $select_clause =
+ "`domaincerts`.`id`,
`users`.`fname`, `users`.`lname`, `users`.`email`,
`domains`.`memid`,
`domaincerts`.`subject`, `domaincerts`.`crt_name`,
`domaincerts`.`CN`,
`domaincerts`.`serial`,
- (UNIX_TIMESTAMP(`domaincerts`.`expire`) -
- UNIX_TIMESTAMP(NOW())) / 86400 AS `daysleft`
-
- FROM `users`, `domaincerts`, `domlink`, `domains`
- WHERE UNIX_TIMESTAMP(`domaincerts`.`expire`) -
+ (UNIX_TIMESTAMP(`domaincerts`.`expire`) -
+ UNIX_TIMESTAMP(NOW())) / 86400 AS `daysleft`";
+ $where_clause =
+ "UNIX_TIMESTAMP(`domaincerts`.`expire`) -
UNIX_TIMESTAMP(NOW()) > -7 * 86400
- AND UNIX_TIMESTAMP(`domaincerts`.`expire`) -
+ 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`";
+ 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);
while($row = mysql_fetch_assoc($res))
{