source code taken from cacert-20090625.tar.bz2
[cacert.git] / cacert / pages / account / 5.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=5&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"><?=_("Email Address")?></td>
28 <td class="DataTD"><?=_("Revoked")?></td>
29 <td class="DataTD"><?=_("Expires")?></td>
30 <td class="DataTD"><?=_("Login")?></td>
31
32 <?
33 $query = "select UNIX_TIMESTAMP(`emailcerts`.`created`) as `created`,
34 UNIX_TIMESTAMP(`emailcerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
35 UNIX_TIMESTAMP(`emailcerts`.`expire`) as `expired`,
36 `emailcerts`.`expire` as `expires`,
37 `emailcerts`.`revoked` as `revoke`,
38 UNIX_TIMESTAMP(`emailcerts`.`revoked`) as `revoked`,
39 `emailcerts`.`id`,
40 `emailcerts`.`CN`,
41 emailcerts.disablelogin as `disablelogin`
42 from `emailcerts`
43 where `emailcerts`.`memid`='".$_SESSION['profile']['id']."'
44 ";
45 if($viewall != 1)
46 $query .= " AND `revoked`=0 AND `renewed`=0 ";
47 $query .= " GROUP BY `emailcerts`.`id` ";
48 if($viewall != 1)
49 $query .= " HAVING `timeleft` > 0 ";
50 $query .= " ORDER BY `emailcerts`.`modified` desc";
51 // echo $query."<br>\n";
52 $res = mysql_query($query);
53 if(mysql_num_rows($res) <= 0)
54 {
55 ?>
56 <tr>
57 <td colspan="5" class="DataTD"><?=_("No client certificates are currently listed.")?></td>
58 </tr>
59 <? } else {
60 while($row = mysql_fetch_assoc($res))
61 {
62 if($row['timeleft'] > 0)
63 $verified = _("Valid");
64 if($row['timeleft'] < 0)
65 $verified = _("Expired");
66 if($row['expired'] == 0)
67 $verified = _("Pending");
68 if($row['revoked'] > 0)
69 $verified = _("Revoked");
70 if($row['revoked'] == 0)
71 $row['revoke'] = _("Not Revoked");
72 ?>
73 <tr>
74 <? if($verified != _("Pending") && $verified != _("Revoked")) { ?>
75 <td class="DataTD"><input type="checkbox" name="revokeid[]" value="<?=$row['id']?>"></td>
76 <td class="DataTD"><?=$verified?></td>
77 <td class="DataTD"><a href="account.php?id=6&amp;cert=<?=$row['id']?>"><?=(trim($row['CN'])=="" ? _("empty") : $row['CN'])?></a></td>
78 <? } else if($verified != _("Revoked")) { ?>
79 <td class="DataTD"><input type="checkbox" name="delid[]" value="<?=$row['id']?>"></td>
80 <td class="DataTD"><?=$verified?></td>
81 <td class="DataTD"><?=(trim($row['CN'])=="" ? _("empty") : $row['CN'])?></td>
82 <? } else { ?>
83 <td class="DataTD">&nbsp;</td>
84 <td class="DataTD"><?=$verified?></td>
85 <td class="DataTD"><?=(trim($row['CN'])=="" ? _("empty") : $row['CN'])?></td>
86 <? } ?>
87 <td class="DataTD"><?=$row['revoke']?></td>
88 <td class="DataTD"><?=$row['expires']?></td>
89 <td class="DataTD">
90 <input type="checkbox" name="disablelogin_<?=$row['id']?>" value="1" <?=$row['disablelogin']?"":"checked='checked'"?>/>
91 <input type="hidden" name="cert_<?=$row['id']?>" value="1"/>
92 </td>
93 </tr>
94 <? } ?>
95 <tr>
96 <td class="DataTD" colspan="8">
97 <a href="account.php?id=5&amp;viewall=<?=!$viewall?>"><b><?=$viewall?_("Hide old certificates"):_("View all certificates")?></b></a>
98 </td>
99 </tr>
100
101 <tr>
102 <td class="DataTD" colspan="5"><input type="submit" name="renew" value="<?=_("Renew")?>">&#160;&#160;&#160;&#160;
103 <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td>
104
105 <td class="DataTD" colspan="3"><input type="submit" name="change" value="<?=_("Change settings")?>"> </td>
106
107 </tr>
108 <? } ?>
109 </table>
110 <input type="hidden" name="oldid" value="<?=$id?>">
111 <input type="hidden" name="csrf" value="<?=make_csrf('clicerchange')?>" />
112 </form>
113 <p><?=_("From here you can delete pending requests, or revoke valid certificates.")?></p>
114 <p><?=_("Login").": "._("By allowing certificate login, this certificate can be used to login into your account at https://secure.cacert.org/ .")?></p>