Merge branch 'bug-976' into release
[cacert-devel.git] / pages / account / 18.php
1 <? /*
2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */ ?>
18 <? $viewall=0; if(array_key_exists('viewall',$_REQUEST)) $viewall=intval($_REQUEST['viewall']); ?>
19 <form method="post" action="account.php">
20 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
21 <tr>
22 <td colspan="6" class="title"><?=_("Client Certificates")?> - <a href="account.php?id=18&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
23 </tr>
24 <tr>
25 <td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
26 <td class="DataTD"><?=_("Status")?></td>
27 <td class="DataTD"><?=_("CommonName")?></td>
28 <td class="DataTD"><?=_("SerialNumber")?></td>
29 <td class="DataTD"><?=_("Revoked")?></td>
30 <td class="DataTD"><?=_("Expires")?></td>
31
32 <?
33 $query = "select UNIX_TIMESTAMP(`oemail`.`created`) as `created`,
34 UNIX_TIMESTAMP(`oemail`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
35 UNIX_TIMESTAMP(`oemail`.`expire`) as `expired`,
36 `oemail`.`expire` as `expires`, `oemail`.`revoked` as `revoke`,
37 UNIX_TIMESTAMP(`oemail`.`revoked`) as `revoked`,
38 `oemail`.`CN`, `oemail`.`serial`, `oemail`.`id`
39 from `orgemailcerts` as `oemail`, `org`
40 where `org`.`memid`='".intval($_SESSION['profile']['id'])."' and
41 `org`.`orgid`=`oemail`.`orgid` ";
42 if($viewall != 1)
43 {
44 $query .= "AND `oemail`.`revoked`=0 AND `oemail`.`renewed`=0 ";
45 $query .= "HAVING `timeleft` > 0 AND `revoked`=0 ";
46 }
47 $query .= "ORDER BY `oemail`.`modified` desc";
48 $res = mysql_query($query);
49 if(mysql_num_rows($res) <= 0)
50 {
51 ?>
52 <tr>
53 <td colspan="6" class="DataTD"><?=_("No client certificates are currently listed.")?></td>
54 </tr>
55 <? } else {
56 while($row = mysql_fetch_assoc($res))
57 {
58 if($row['timeleft'] > 0)
59 $verified = _("Valid");
60 if($row['timeleft'] < 0)
61 $verified = _("Expired");
62 if($row['expired'] == 0)
63 $verified = _("Pending");
64 if($row['revoked'] > 0)
65 $verified = _("Revoked");
66 if($row['revoked'] == 0)
67 $row['revoke'] = _("Not Revoked");
68 ?>
69 <tr>
70 <? if($verified == _("Valid") || $verified == _("Expired")) { ?>
71 <td class="DataTD"><input type="checkbox" name="revokeid[]" value="<?=$row['id']?>"></td>
72 <td class="DataTD"><?=$verified?></td>
73 <td class="DataTD"><a href="account.php?id=19&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
74 <? } else if($verified == _("Pending")) { ?>
75 <td class="DataTD"><input type="checkbox" name="delid[]" value="<?=$row['id']?>"></td>
76 <td class="DataTD"><?=$verified?></td>
77 <td class="DataTD"><?=$row['CN']?></td>
78 <? } else { ?>
79 <td class="DataTD">&nbsp;</td>
80 <td class="DataTD"><?=$verified?></td>
81 <td class="DataTD"><a href="account.php?id=19&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
82 <? } ?>
83 <td class="DataTD"><?=$row['serial']?></td>
84 <td class="DataTD"><?=$row['revoke']?></td>
85 <td class="DataTD"><?=$row['expires']?></td>
86 </tr>
87 <? } ?>
88 <tr>
89 <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>">&#160;&#160;&#160;&#160;
90 <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td>
91 </tr>
92 <? } ?>
93 </table>
94 <input type="hidden" name="oldid" value="<?=$id?>">
95 <input type="hidden" name="csrf" value="<?=make_csrf('clicerchange')?>" />
96 </form>
97 <p><?=_("From here you can delete pending requests, or revoke valid certificates.")?></p>