From 7df3644ad3525db4591585ac1736f2d6722c8c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Tue, 6 Dec 2011 18:30:47 +0100 Subject: bug 794: complete rewrite of the patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - explicitly query for valid certs - let MySQL figure out most of the stuff (don't use loops and subqueries in those loops and so on) - minor improvements Signed-off-by: Michael Tänzer --- pages/account/43.php | 558 +++++++++++++++++++++++++++------------------------ 1 file changed, 295 insertions(+), 263 deletions(-) diff --git a/pages/account/43.php b/pages/account/43.php index dc56c36..96d2a10 100644 --- a/pages/account/43.php +++ b/pages/account/43.php @@ -318,273 +318,305 @@
- 0) { - // select domid's - $query = "select `id` as `domids` from `domains` where `memid`='".intval($row['id'])."' "; - $dres = mysql_query($query); - $rcexpired = 0; - $rcrevoked = 0; - $rcexpiremax = "0000-00-00 00:00:00"; - while ($drow = mysql_fetch_assoc($dres)) { - $ndomid = intval($drow['domids']); - - $query2 = "select COUNT(`id`) as `dexpired` from `domaincerts` where `domid`='".$ndomid."' and `revoked` = '0000-00-00 00:00:00' and `expire` < now() "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpired += intval($drow2['dexpired']); - - $query2 = "select COUNT(`id`) as `drevoked` from `domaincerts` where `domid`='".$ndomid."' and `revoked` != '0000-00-00 00:00:00' "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcrevoked += intval($drow2['drevoked']); - - // For Arbitration purpose expiry dates of revoked certs are also relevant! - $query2 = "select `expire` as `mexpire` from `domaincerts` where `domid`='".$ndomid."' order by `expire` desc "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpiremax = max($rcexpiremax,$drow2['mexpire']); - - $rcactive = intval($rctotal)-intval($rcexpired)-intval($rcrevoked); - } - } -?> - - - - - - - - - - - - - - - - 0) { -?> - - - - - - - - - - 0) { - $rcexpired = 0; - $rcrevoked = 0; - $rcexpiremax = "0000-00-00 00:00:00"; - - $query2 = "select COUNT(`id`) as `eexpired` from `emailcerts` where `memid`='".intval($row['id'])."' and `revoked` = '0000-00-00 00:00:00' and `expire` < now() "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpired = intval($drow2['eexpired']); - - $query2 = "select COUNT(`id`) as `erevoked` from `emailcerts` where `memid`='".intval($row['id'])."' and `revoked` != '0000-00-00 00:00:00' "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcrevoked = intval($drow2['erevoked']); - - $query2 = "select `expire` as `eexpire` from `emailcerts` where `memid`='".intval($row['id'])."' order by `expire` desc "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpiremax = $drow2['eexpire']; - - $rcactive = intval($rctotal)-intval($rcexpired)-intval($rcrevoked); - -?> - - - - - - - - - - - - - - 0) { - $rcexpired = 0; - $rcexpiremax = "0000-00-00 00:00:00"; - - $query2 = "select COUNT(`id`) as `gexpired` from `gpg` where `memid`='".intval($row['id'])."' and `expire` < now() "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpired = intval($drow2['gexpired']); - -/* - $query2 = "select COUNT(`id`) as `erevoked` from `gpg` where `memid`='".intval($row['id'])."' and `revoked` != '0000-00-00 00:00:00' "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcrevoked = intval($drow2['erevoked']); - */ - - $query2 = "select `expire` as `gexpire` from `gpg` where `memid`='".intval($row['id'])."' order by `expire` desc "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpiremax = $drow2['gexpire']; - - $rcactive = intval($rctotal)-intval($rcexpired); -?> - - - - - - - - - - - - - - 0) { - // user account is linked into orgs - - // $query = "select COUNT(`orgdomaincerts`.`id`) as `orgcountdomaincerts` from `orgdomains` inner join `orgdomaincerts` on `orgdomaincerts`.`orgid` = `orgdomains`.`id` where `memid`='".intval($row['id'])."' "; - $query = "SELECT count(`orgdomaincerts`.`id`) as `countorgdomcerts` FROM `orgdomaincerts` inner join `orgdomains` on `orgdomaincerts`.`orgid`=`orgdomains`.`orgid` inner join `org` on `orgdomains`.`orgid`=`org`.`orgid` where `memid`='".intval($row['id'])."' "; - - $dres = mysql_query($query); - $drow = mysql_fetch_assoc($dres); - $rctotal = $drow['countorgdomcerts']; - if($rctotal > 0) { - // select domid's - $query = "select `orgdomains`.`orgid` as `orgdomorgids` from `orgdomains` inner join `org` on `orgdomains`.`orgid`=`org`.`orgid` where `memid`='".intval($row['id'])."' "; - $dres = mysql_query($query); - $rcexpired = 0; - $rcrevoked = 0; - $rcexpiremax = "0000-00-00 00:00:00"; - while ($drow = mysql_fetch_assoc($dres)) { - $ndomid = intval($drow['orgdomorgids']); - - $query2 = "select COUNT(`orgdomaincerts`.`id`) as `dexpired` from `orgdomaincerts` where `orgid`='".$ndomid."' and `revoked` = '0000-00-00 00:00:00' and `expire` < now() "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpired += intval($drow2['dexpired']); // active, but expired - - $query2 = "select COUNT(`orgdomaincerts`.`id`) as `drevoked` from `orgdomaincerts` where `orgid`='".$ndomid."' and `revoked` != '0000-00-00 00:00:00' "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcrevoked += intval($drow2['drevoked']); // revoked - - // For Arbitration purpose expiry dates of revoked certs are also relevant! - $query2 = "select `expire` as `mexpire` from `orgdomaincerts` where `orgid`='".$ndomid."' order by `expire` desc "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpiremax = max($rcexpiremax,$drow2['mexpire']); - - } - $rcactive = intval($rctotal)-intval($rcexpired)-intval($rcrevoked); - } - if($rctotal > 0) { -?> - - - - - - - - - - - - - - 0) { - $rcexpired = 0; - $rcrevoked = 0; - $rcexpiremax = "0000-00-00 00:00:00"; - $query2 = "select COUNT(`orgemailcerts`.`id`) as `eexpired` from `orgemailcerts` inner join `org` on `orgemailcerts`.`orgid`=`org`.`orgid` where `org`.`memid`='".intval($row['id'])."' and `revoked` = '0000-00-00 00:00:00' and `expire` < now() "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpired = intval($drow2['eexpired']); - - $query2 = "select COUNT(`orgemailcerts`.`id`) as `erevoked` from `orgemailcerts` inner join `org` on `orgemailcerts`.`orgid`=`org`.`orgid` where `org`.`memid`='".intval($row['id'])."' and `revoked` != '0000-00-00 00:00:00' "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcrevoked = intval($drow2['erevoked']); - - $query2 = "select `expire` as `eexpire` from `orgemailcerts` inner join `org` on `orgemailcerts`.`orgid`=`org`.`orgid` where `memid`='".intval($row['id'])."' order by `expire` desc "; - $dres2 = mysql_query($query2); - $drow2 = mysql_fetch_assoc($dres2); - $rcexpiremax = $drow2['eexpire']; - - $rcactive = intval($rctotal)-intval($rcexpired)-intval($rcrevoked); - -?> - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + 0) { + $query = "select COUNT(*) as `valid` + from `domains` inner join `domaincerts` + on `domains`.`id` = `domaincerts`.`domid` + where `domains`.`memid` = '".intval($row['id'])."' + and `revoked` = '0000-00-00 00:00:00' + and `expire` > NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $valid = $drow['valid']; + + $query = "select COUNT(*) as `expired` + from `domains` inner join `domaincerts` + on `domains`.`id` = `domaincerts`.`domid` + where `domains`.`memid` = '".intval($row['id'])."' + and `expire` <= NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $expired = $drow['expired']; + + $query = "select COUNT(*) as `revoked` + from `domains` inner join `domaincerts` + on `domains`.`id` = `domaincerts`.`domid` + where `domains`.`memid` = '".intval($row['id'])."' + and `revoked` != '0000-00-00 00:00:00'"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $revoked = $drow['revoked']; + ?> + + + + + + 0 + ?> + + + + + + + 0) { + $query = "select COUNT(*) as `valid` + from `emailcerts` + where `memid` = '".intval($row['id'])."' + and `revoked` = '0000-00-00 00:00:00' + and `expire` > NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $valid = $drow['valid']; + + $query = "select COUNT(*) as `expired` + from `emailcerts` + where `memid` = '".intval($row['id'])."' + and `expire` <= NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $expired = $drow['expired']; + + $query = "select COUNT(*) as `revoked` + from `emailcerts` + where `memid` = '".intval($row['id'])."' + and `revoked` != '0000-00-00 00:00:00'"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $revoked = $drow['revoked']; + ?> + + + + + + 0 + ?> + + + + + + + 0) { + $query = "select COUNT(*) as `valid` + from `gpg` + where `memid` = '".intval($row['id'])."' + and `expire` > NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $valid = $drow['valid']; + + $query = "select COUNT(*) as `expired` + from `emailcerts` + where `memid` = '".intval($row['id'])."' + and `expire` <= NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $expired = $drow['expired']; + + ?> + + + + + + 0 + ?> + + + + + + + 0) { + $query = "select COUNT(*) as `valid` + from `orgdomaincerts` as `orgcerts` inner join `org` + on `orgcerts`.`orgid` = `org`.`orgid` + where `org`.`memid` = '".intval($row['id'])."' + and `orgcerts`.`revoked` = '0000-00-00 00:00:00' + and `orgcerts`.`expire` > NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $valid = $drow['valid']; + + $query = "select COUNT(*) as `expired` + from `orgdomaincerts` as `orgcerts` inner join `org` + on `orgcerts`.`orgid` = `org`.`orgid` + where `org`.`memid` = '".intval($row['id'])."' + and `orgcerts`.`expire` <= NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $expired = $drow['expired']; + + $query = "select COUNT(*) as `revoked` + from `orgdomaincerts` as `orgcerts` inner join `org` + on `orgcerts`.`orgid` = `org`.`orgid` + where `org`.`memid` = '".intval($row['id'])."' + and `orgcerts`.`revoked` != '0000-00-00 00:00:00'"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $revoked = $drow['revoked']; + ?> + + + + + + 0 + ?> + + + + + + + 0) { + $query = "select COUNT(*) as `valid` + from `orgemailcerts` as `orgcerts` inner join `org` + on `orgcerts`.`orgid` = `org`.`orgid` + where `org`.`memid` = '".intval($row['id'])."' + and `orgcerts`.`revoked` = '0000-00-00 00:00:00' + and `orgcerts`.`expire` > NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $valid = $drow['valid']; + + $query = "select COUNT(*) as `expired` + from `orgemailcerts` as `orgcerts` inner join `org` + on `orgcerts`.`orgid` = `org`.`orgid` + where `org`.`memid` = '".intval($row['id'])."' + and `orgcerts`.`expire` <= NOW()"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $expired = $drow['expired']; + + $query = "select COUNT(*) as `revoked` + from `orgemailcerts` as `orgcerts` inner join `org` + on `orgcerts`.`orgid` = `org`.`orgid` + where `org`.`memid` = '".intval($row['id'])."' + and `orgcerts`.`revoked` != '0000-00-00 00:00:00'"; + $dres = mysql_query($query); + $drow = mysql_fetch_assoc($dres); + $revoked = $drow['revoked']; + ?> + + + + + + 0 + ?> + + +
:
:0)?"Pending":" ") ?>
:0)?"Pending":" ") ?>
:
: 0)?"Pending":" ") ?>
:
:0)?"Pending":" ") ?>
:
:0)?"Pending":" ") ?>
:
:
:
:
:
:
:
:

- - +