diff options
author | INOPIAE <inopiae@cacert.org> | 2013-07-13 19:57:24 +0200 |
---|---|---|
committer | INOPIAE <inopiae@cacert.org> | 2013-07-13 19:57:24 +0200 |
commit | f8eece94c2047e0eb2a68b05d3d5a2b047a7e430 (patch) | |
tree | e89fbd360ff6acbf87d51c579fc1cbe6a3c39d9f | |
parent | 4f1f7055134f36d32697d0353ae48e09c0fe8399 (diff) | |
download | cacert-devel-f8eece94c2047e0eb2a68b05d3d5a2b047a7e430.tar.gz cacert-devel-f8eece94c2047e0eb2a68b05d3d5a2b047a7e430.tar.xz cacert-devel-f8eece94c2047e0eb2a68b05d3d5a2b047a7e430.zip |
bug 1010: used trinary operator for variable declaration, changed white space /tabs, typo and added orginfo.O to order in SQL statement
-rw-r--r-- | includes/account.php | 34 | ||||
-rw-r--r-- | pages/account/18.php | 155 | ||||
-rw-r--r-- | pages/account/22.php | 138 |
3 files changed, 161 insertions, 166 deletions
diff --git a/includes/account.php b/includes/account.php index 99e62b1..3b9e685 100644 --- a/includes/account.php +++ b/includes/account.php @@ -1834,7 +1834,7 @@ exit; } - if($oldid == 18 && array_key_exists('filter',$_REQUEST) && $_REQUEST['filter']!= "") + if($oldid == 18 && array_key_exists('filter',$_REQUEST) && $_REQUEST['filter']!= "") { $id=18; $_SESSION['_config']['orgfilterid']=$_REQUEST['orgfilterid']; @@ -1842,7 +1842,7 @@ $_SESSION['_config']['status']=$_REQUEST['status']; } - if($oldid == 18 && array_key_exists('reset',$_REQUEST) && $_REQUEST['reset']!= "") + if($oldid == 18 && array_key_exists('reset',$_REQUEST) && $_REQUEST['reset']!= "") { $id=18; $_SESSION['_config']['orgfilterid']=0; @@ -2205,21 +2205,21 @@ exit; } -if($oldid == 22 && array_key_exists('filter',$_REQUEST) && $_REQUEST['filter']!= "") -{ - $id=22; - $_SESSION['_config']['orgfilterid']=$_REQUEST['orgfilterid']; - $_SESSION['_config']['sorting']=$_REQUEST['sorting']; - $_SESSION['_config']['status']=$_REQUEST['status']; -} - -if($oldid == 22 && array_key_exists('reset',$_REQUEST) && $_REQUEST['reset']!= "") -{ - $id=22; - $_SESSION['_config']['orgfilterid']=0; - $_SESSION['_config']['sorting']=0; - $_SESSION['_config']['status']=0; -} + if($oldid == 22 && array_key_exists('filter',$_REQUEST) && $_REQUEST['filter']!= "") + { + $id=22; + $_SESSION['_config']['orgfilterid']=$_REQUEST['orgfilterid']; + $_SESSION['_config']['sorting']=$_REQUEST['sorting']; + $_SESSION['_config']['status']=$_REQUEST['status']; + } + + if($oldid == 22 && array_key_exists('reset',$_REQUEST) && $_REQUEST['reset']!= "") + { + $id=22; + $_SESSION['_config']['orgfilterid']=0; + $_SESSION['_config']['sorting']=0; + $_SESSION['_config']['status']=0; + } if(($id == 24 || $oldid == 24 || $id == 25 || $oldid == 25 || $id == 26 || $oldid == 26 || diff --git a/pages/account/18.php b/pages/account/18.php index 05f30de..b4cee40 100644 --- a/pages/account/18.php +++ b/pages/account/18.php @@ -16,12 +16,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -$orgfilterid=0; -if(array_key_exists('orgfilterid',$_SESSION['_config'])) $orgfilterid=intval($_SESSION['_config']['orgfilterid']); -$sorting=0; -if(array_key_exists('sorting',$_SESSION['_config'])) $sorting=intval($_SESSION['_config']['sorting']); -$status=0; -if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_config']['status']); +$orgfilterd = array_key_exists('orgfilterid',$_SESSION['_config']) ? intval($_SESSION['_config']['orgfilterid']) : 0; +$sorting = array_key_exists('sorting',$_SESSION['_config']) ? intval($_SESSION['_config']['sorting']) : 0; +$status = array_key_exists('status',$_SESSION['_config']) ? intval($_SESSION['_config']['status']) : 0; ?> <form method="post" action="account.php"> <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper"> @@ -36,22 +33,22 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c <td colspan="8" class="DataTD" > <select name="orgfilterid"> <option value="0"<? - if (0==$orgfilterid) { - ?> selected <? - } - ?>><?=_("All")?></option> <? - $query = "select `orginfo`.`O`, `orginfo`.`id` - from `org`, `orginfo` - where `org`.`memid`='".intval($_SESSION['profile']['id'])."' `orginfo`.`id` = `org`.`orgid` - ORDER BY `oemail`.`modified` desc"; - $reso = mysql_query($query); - if(mysql_num_rows($reso) >= 1){ - while($row = mysql_fetch_assoc($res)){ - ?><option <?if ($row['id']==$orgfilterid) { - ?> selected <? - }?> value="><?=$row['id']?>"><?=$row['O']?></option> - <?} - }?> + if (0==$orgfilterid) { + ?> selected <? + } + ?>><?=_("All")?></option> <? + $query = "select `orginfo`.`O`, `orginfo`.`id` + from `org`, `orginfo` + where `org`.`memid`='".intval($_SESSION['profile']['id'])."' `orginfo`.`id` = `org`.`orgid` + ORDER BY `oemail`.`modified` desc"; + $reso = mysql_query($query); + if(mysql_num_rows($reso) >= 1){ + while($row = mysql_fetch_assoc($res)){ + ?><option <?if ($row['id']==$orgfilterid) { + ?> selected <? + }?> value="><?=$row['id']?>"><?=$row['O']?></option> + <?} + }?> </select> </td> </tr> @@ -60,13 +57,13 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c <td colspan="8" class="DataTD" > <select name="sorting"> <option <?if (0==$sorting) { - ?> selected <? + ?> selected <? }?>value="0"><?=_("expire date (desc)")?></option> <option <?if (1==$sorting) { - ?> selected <? + ?> selected <? }?>value="1"><?=_("OU, expire date (desc)")?></option> <option <?if (2==$sorting) { - ?> selected <? + ?> selected <? }?>value="2"><?=_("Common name, expire date (desc)")?></option> </select> </td> @@ -76,10 +73,10 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c <td colspan="8" class="DataTD" > <select name="status"> <option <?if (0==$status) { - ?> selected <? + ?> selected <? }?>value="0"><?=_("Actual")?></option> <option <?if (0==$status) { - ?> selected <? + ?> selected <? }?>value="1"><?=_("All")?></option> </select> </td> @@ -92,51 +89,51 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c </tr> <? - $query = "select UNIX_TIMESTAMP(`oemail`.`created`) as `created`, - UNIX_TIMESTAMP(`oemail`.`expire`) - UNIX_TIMESTAMP() as `timeleft`, - UNIX_TIMESTAMP(`oemail`.`expire`) as `expired`, - `oemail`.`expire` as `expires`, `oemail`.`revoked` as `revoke`, - UNIX_TIMESTAMP(`oemail`.`revoked`) as `revoked`, - `oemail`.`CN`, `oemail`.`serial`, `oemail`.`id`, - `oemail`.`description`, `oemail`.`ou`, `orginfo`.`O` - from `orgemailcerts` as `oemail`, `org`, `orginfo` - where `org`.`memid`='".intval($_SESSION['profile']['id'])."' and - `org`.`orgid`=`oemail`.`orgid` and `orginfo`.`id` = `org`.`orgid`"; - if($orgfilterid>0) - { - $query .= "AND `org`.`orgid`=$orgfilterid "; - } + $query = "select UNIX_TIMESTAMP(`oemail`.`created`) as `created`, + UNIX_TIMESTAMP(`oemail`.`expire`) - UNIX_TIMESTAMP() as `timeleft`, + UNIX_TIMESTAMP(`oemail`.`expire`) as `expired`, + `oemail`.`expire` as `expires`, `oemail`.`revoked` as `revoke`, + UNIX_TIMESTAMP(`oemail`.`revoked`) as `revoked`, + `oemail`.`CN`, `oemail`.`serial`, `oemail`.`id`, + `oemail`.`description`, `oemail`.`ou`, `orginfo`.`O` + from `orgemailcerts` as `oemail`, `org`, `orginfo` + where `org`.`memid`='".intval($_SESSION['profile']['id'])."' and + `org`.`orgid`=`oemail`.`orgid` and `orginfo`.`id` = `org`.`orgid`"; + if($orgfilterid>0) + { + $query .= "AND `org`.`orgid`=$orgfilterid "; + } - if(1==$status) - { - $query .= "AND `oemail`.`revoked`=0 AND `oemail`.`renewed`=0 "; - $query .= "HAVING `timeleft` > 0 AND `revoked`=0 "; - } - switch ($sorting){ - case 0: - $query .= "ORDER BY `oemail`.`expire` desc"; - break; - case 1: - $query .= "ORDER BY `oemail`.`ou`, `oemail`.`expire` desc"; - break; - case 2: - $query .= "ORDER BY `oemail`.`CN`, `oemail`.`expire` desc"; - break; - } - $res = mysql_query($query); - if(mysql_num_rows($res) <= 0) - { + if(1==$status) + { + $query .= "AND `oemail`.`revoked`=0 AND `oemail`.`renewed`=0 "; + $query .= "HAVING `timeleft` > 0 AND `revoked`=0 "; + } + switch ($sorting){ + case 0: + $query .= "ORDER BY `orginfo`.`O`, `oemail`.`expire` desc"; + break; + case 1: + $query .= "ORDER BY `orginfo`.`O`, `oemail`.`ou`, `oemail`.`expire` desc"; + break; + case 2: + $query .= "ORDER BY `orginfo`.`O`, `oemail`.`CN`, `oemail`.`expire` desc"; + break; + } + $res = mysql_query($query); + if(mysql_num_rows($res) <= 0) + { ?> <tr> <td colspan="9" class="DataTD"><?=_("No client certificates are currently listed.")?></td> </tr> <? } else { - $orgname=''; - while($row = mysql_fetch_assoc($res)) - { - if ($row['O']<>$orgname) { - $orgname=$row['O'];?> + $orgname=''; + while($row = mysql_fetch_assoc($res)) + { + if ($row['O']<>$orgname) { + $orgname=$row['O'];?> <tr> <td colspan="9" class="title"></td> </tr> @@ -153,18 +150,18 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c <td class="DataTD"><?=_("Expires")?></td> <td colspan="2" class="DataTD"><?=_("Comment *")?></td> </tr> - <? - } - if($row['timeleft'] > 0) - $verified = _("Valid"); - if($row['timeleft'] < 0) - $verified = _("Expired"); - if($row['expired'] == 0) - $verified = _("Pending"); - if($row['revoked'] > 0) - $verified = _("Revoked"); - if($row['revoked'] == 0) - $row['revoke'] = _("Not Revoked"); + <? + } + if($row['timeleft'] > 0) + $verified = _("Valid"); + if($row['timeleft'] < 0) + $verified = _("Expired"); + if($row['expired'] == 0) + $verified = _("Pending"); + if($row['revoked'] > 0) + $verified = _("Revoked"); + if($row['revoked'] == 0) + $row['revoke'] = _("Not Revoked"); ?> <tr> <td class="DataTD"><?=$row['ou']?></td> @@ -181,7 +178,7 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c <td class="DataTD"><?=$verified?></td> <td class="DataTD"><a href="account.php?id=19&cert=<?=$row['id']?>"><?=$row['CN']?></a></td> <? } ?> - <td class="DataTD"><?=$row['serial']?></td> + <td class="DataTD"><?=$row['serial']?></td> <td class="DataTD"><?=$row['revoke']?></td> <td class="DataTD"><?=$row['expires']?></td> <td class="DataTD"><input name="comment_<?=$row['id']?>" type="text" value="<?=htmlspecialchars($row['description'])?>" /></td> @@ -195,7 +192,7 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c </tr> <tr> <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>">     - <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td> + <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td> <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>"> </td> </tr> <tr> diff --git a/pages/account/22.php b/pages/account/22.php index 72e3dff..7ad56bb 100644 --- a/pages/account/22.php +++ b/pages/account/22.php @@ -16,12 +16,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -$orgfilterid=0; -if(array_key_exists('dorgfilterid',$_SESSION['_config'])) $orgfilterid=intval($_SESSION['_config']['dorgfilterid']); -$sorting=0; -if(array_key_exists('dsorting',$_SESSION['_config'])) $sorting=intval($_SESSION['_config']['dsorting']); -$status=0; -if(array_key_exists('dstatus',$_SESSION['_config'])) $status=intval($_SESSION['_config']['dstatus']); ?> +$orgfilterd = array_key_exists('dorgfilterid',$_SESSION['_config']) ? intval($_SESSION['_config']['dorgfilterid']) : 0; +$sorting = array_key_exists('dsorting',$_SESSION['_config']) ? intval($_SESSION['_config']['dsorting']) : 0; +$status = array_key_exists('dstatus',$_SESSION['_config']) ? intval($_SESSION['_config']['dstatus']) : 0; +?> <form method="post" action="account.php"> <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper"> <td colspan="8" class="title"><?=_("Organisation Server Certificates")?> </td> @@ -34,21 +32,21 @@ if(array_key_exists('dstatus',$_SESSION['_config'])) $status=intval($_SESSION['_ <td colspan="7" class="DataTD" > <select name="dorgfilterid"> <option value="0"<? - if (0==$orgfilterid) { - ?> selected <? - } - ?>><?=_("All")?></option> <? - $query = "select `orginfo`.`O`, `orginfo`.`id` - from `org`, `orginfo` - where `org`.`memid`='".intval($_SESSION['profile']['id'])."' `orginfo`.`id` = `org`.`orgid` - ORDER BY `oemail`.`modified` desc"; + if (0==$orgfilterid) { + ?> selected <? + } + ?>><?=_("All")?></option> <? + $query = "select `orginfo`.`O`, `orginfo`.`id` + from `org`, `orginfo` + where `org`.`memid`='".intval($_SESSION['profile']['id'])."' `orginfo`.`id` = `org`.`orgid` + ORDER BY `oemail`.`modified` desc"; $reso = mysql_query($query); if(mysql_num_rows($reso) >= 1){ - while($row = mysql_fetch_assoc($res)){ - ?><option <?if ($row['id']==$orgfilterid) { - ?> selected <? - }?> value="><?=$row['id']?>"><?=$row['O']?></option> - <?} + while($row = mysql_fetch_assoc($res)){ + ?><option <?if ($row['id']==$orgfilterid) { + ?> selected <? + }?> value="><?=$row['id']?>"><?=$row['O']?></option> + <?} }?> </select> </td> @@ -58,10 +56,10 @@ if(mysql_num_rows($reso) >= 1){ <td colspan="7" class="DataTD" > <select name="dsorting"> <option <?if (0==$sorting) { - ?> selected <? + ?> selected <? }?>value="0"><?=_("expire date (desc)")?></option> <option <?if (1==$sorting) { - ?> selected <? + ?> selected <? }?>value="1"><?=_("Common name, expire date (desc)")?></option> </select> </td> @@ -71,10 +69,10 @@ if(mysql_num_rows($reso) >= 1){ <td colspan="7" class="DataTD" > <select name="dstatus"> <option <?if (0==$status) { - ?> selected <? + ?> selected <? }?>value="0"><?=_("Actual")?></option> <option <?if (0==$status) { - ?> selected <? + ?> selected <? }?>value="1"><?=_("All")?></option> </select> </td> @@ -88,52 +86,52 @@ if(mysql_num_rows($reso) >= 1){ <? - $query = "select UNIX_TIMESTAMP(`orgdomaincerts`.`created`) as `created`, - UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`, - UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) as `expired`, - `orgdomaincerts`.`expire` as `expires`, `revoked` as `revoke`, - UNIX_TIMESTAMP(`revoked`) as `revoked`, `CN`, - `orgdomaincerts`.`serial`, - `orgdomaincerts`.`id` as `id`, - `orgdomaincerts`.`description`, `orginfo`.`O` - from `orgdomaincerts`,`org`, `orginfo` - where `org`.`memid`='".intval($_SESSION['profile']['id'])."' - and `orgdomaincerts`.`orgid`=`org`.`orgid` and `orginfo`.`id` = `org`.`orgid`"; + $query = "select UNIX_TIMESTAMP(`orgdomaincerts`.`created`) as `created`, + UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`, + UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) as `expired`, + `orgdomaincerts`.`expire` as `expires`, `revoked` as `revoke`, + UNIX_TIMESTAMP(`revoked`) as `revoked`, `CN`, + `orgdomaincerts`.`serial`, + `orgdomaincerts`.`id` as `id`, + `orgdomaincerts`.`description`, `orginfo`.`O` + from `orgdomaincerts`,`org`, `orginfo` + where `org`.`memid`='".intval($_SESSION['profile']['id'])."' + and `orgdomaincerts`.`orgid`=`org`.`orgid` and `orginfo`.`id` = `org`.`orgid`"; - if($dorgfilterid>0) - { - $query .= "AND `org`.`orgid`=$dorgfilterid "; - } + if($dorgfilterid>0) + { + $query .= "AND `org`.`orgid`=$dorgfilterid "; + } - if(1==$dstatus) - { - $query .= "AND `revoked`=0 AND `renewed`=0 "; - $query .= "HAVING `timeleft` > 0 "; - } - switch ($dsorting){ - case 0: - $query .= "ORDER BY `orgdomaincerts`.`expire` desc"; - break; - case 1: - $query .= "ORDER BY `orgdomaincerts`.`CN`, `orgdomaincerts`.`expire` desc"; - break; - } + if(1==$dstatus) + { + $query .= "AND `revoked`=0 AND `renewed`=0 "; + $query .= "HAVING `timeleft` > 0 "; + } + switch ($dsorting){ + case 0: + $query .= "ORDER BY `orginfo`.`O`, `orgdomaincerts`.`expire` desc"; + break; + case 1: + $query .= "ORDER BY `orginfo`.`O`, `orgdomaincerts`.`CN`, `orgdomaincerts`.`expire` desc"; + break; + } //echo $query."<br>\n"; - $res = mysql_query($query); - if(mysql_num_rows($res) <= 0) - { + $res = mysql_query($query); + if(mysql_num_rows($res) <= 0) + { ?> <tr> <td colspan="8" class="DataTD"><?=_("No domains are currently listed.")?></td> </tr> <? } else { - $orgname=''; - while($row = mysql_fetch_assoc($res)) - { - if ($row['O']<>$orgname) { - $orgname=$row['O'];?> + $orgname=''; + while($row = mysql_fetch_assoc($res)) + { + if ($row['O']<>$orgname) { + $orgname=$row['O'];?> <tr> <td colspan="9" class="title"></td> </tr> @@ -149,16 +147,16 @@ if(mysql_num_rows($reso) >= 1){ <td class="DataTD"><?=_("Expires")?></td> <td colspan="2" class="DataTD"><?=_("Comment *")?></td> </tr> - <? - } - if($row['timeleft'] > 0) - $verified = _("Valid"); - if($row['timeleft'] < 0) - $verified = _("Expired"); - if($row['expired'] == 0) - $verified = _("Pending"); - if($row['revoked'] > 0) - $verified = _("Revoked"); + <? + } + if($row['timeleft'] > 0) + $verified = _("Valid"); + if($row['timeleft'] < 0) + $verified = _("Expired"); + if($row['expired'] == 0) + $verified = _("Pending"); + if($row['revoked'] > 0) + $verified = _("Revoked"); if($row['revoked'] == 0) $row['revoke'] = _("Not Revoked"); ?> @@ -186,7 +184,7 @@ if(mysql_num_rows($reso) >= 1){ </tr> <tr> <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>" />     - <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>" /></td> + <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>" /></td> <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>" /> </td> </tr> <tr> |