bug 1276: Allow more name variants according to PracticeOnNames when signing a PGP key
[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
19 $orgfilterid = array_key_exists('orgfilterid',$_SESSION['_config']) ? intval($_SESSION['_config']['orgfilterid']) : 0;
20 $sorting = array_key_exists('sorting',$_SESSION['_config']) ? intval($_SESSION['_config']['sorting']) : 0;
21 $status = array_key_exists('status',$_SESSION['_config']) ? intval($_SESSION['_config']['status']) : 0;
22 ?>
23 <form method="post" action="account.php">
24 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
25 <tr>
26 <td colspan="9" class="title"><?=_("Organisation Client Certificates")?> </td>
27 </tr>
28 <tr>
29 <td colspan="9" class="title"><?=_("Filter/Sorting")?></td>
30 </tr>
31 <tr>
32 <td class="DataTD"><?=_("Organisation")?></td>
33 <td colspan="8" class="DataTD" >
34 <select name="orgfilterid">
35 <?=sprintf('<option value="%d"%s>%s</option>',0, 0 == $orgfilterid ? " selected" : "" ,_("All")) ?>
36 <? $query = "select `orginfo`.`O`, `orginfo`.`id`
37 from `org`, `orginfo`
38 where `org`.`memid`='".intval($_SESSION['profile']['id'])."' and `orginfo`.`id` = `org`.`orgid`
39 ORDER BY `orginfo`.`O` ";
40 $reso = mysql_query($query);
41 if(mysql_num_rows($reso) >= 1){
42 while($row = mysql_fetch_assoc($reso)){
43 printf('<option value="%d"%s>%s</option>',$row['id'], $row['id'] == $orgfilterid ? " selected" : "" , $row['O']);
44 }
45 }?>
46 </select>
47 </td>
48 </tr>
49 <tr>
50 <td class="DataTD"><?=_("Sorting")?></td>
51 <td colspan="8" class="DataTD" >
52 <select name="sorting">
53 <?=sprintf('<option value="%d"%s>%s</option>',0, 0 == $sorting ? " selected" : "" ,_("expire date (desc)")) ?>
54 <?=sprintf('<option value="%d"%s>%s</option>',1, 1 == $sorting ? " selected" : "" ,_("OU, expire date (desc)")) ?>
55 <?=sprintf('<option value="%d"%s>%s</option>',2, 2 == $sorting ? " selected" : "" ,_("Common name, expire date (desc)")) ?>
56 </select>
57 </td>
58 </tr>
59 <tr>
60 <td class="DataTD"><?=_("Certificate status")?></td>
61 <td colspan="8" class="DataTD" >
62 <select name="status">
63 <?=sprintf('<option value="%d"%s>%s</option>',0, 0 == $status ? " selected" : "" ,_("Current/Active")) ?>
64 <?=sprintf('<option value="%d"%s>%s</option>',1, 1 == $status ? " selected" : "" ,_("All")) ?>
65 </select>
66 </td>
67 </tr>
68 <tr>
69 <td class="DataTD" colspan="9"><input type="submit" name="reset" value="<?=_("Reset")?>" />&nbsp;&nbsp;&nbsp;&nbsp;
70 <input type="submit" name="filter" value="<?=_("Apply filter/sort")?>" /></td>
71 </tr>
72 <tr>
73 <td colspan="9" class="DataTD"> </td>
74 </tr>
75
76 <?
77 $query = "select UNIX_TIMESTAMP(`oemail`.`created`) as `created`,
78 UNIX_TIMESTAMP(`oemail`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
79 UNIX_TIMESTAMP(`oemail`.`expire`) as `expired`,
80 `oemail`.`expire` as `expires`, `oemail`.`revoked` as `revoke`,
81 UNIX_TIMESTAMP(`oemail`.`revoked`) as `revoked`,
82 `oemail`.`CN`, `oemail`.`serial`, `oemail`.`id`,
83 `oemail`.`description`, `oemail`.`ou`, `orginfo`.`O`
84 from `orgemailcerts` as `oemail`, `org`, `orginfo`
85 where `org`.`memid`='".intval($_SESSION['profile']['id'])."' and
86 `org`.`orgid`=`oemail`.`orgid` and `orginfo`.`id` = `org`.`orgid`";
87 if($orgfilterid>0)
88 {
89 $query .= "AND `org`.`orgid`=$orgfilterid ";
90 }
91
92 if(0==$status)
93 {
94 $query .= "AND `oemail`.`revoked`=0 AND `oemail`.`renewed`=0 ";
95 $query .= "HAVING `timeleft` > 0 AND `revoked`=0 ";
96 }
97 switch ($sorting){
98 case 0:
99 $query .= "ORDER BY `orginfo`.`O`, `oemail`.`expire` desc";
100 break;
101 case 1:
102 $query .= "ORDER BY `orginfo`.`O`, `oemail`.`ou`, `oemail`.`expire` desc";
103 break;
104 case 2:
105 $query .= "ORDER BY `orginfo`.`O`, `oemail`.`CN`, `oemail`.`expire` desc";
106 break;
107 }
108 $res = mysql_query($query);
109 if(mysql_num_rows($res) <= 0)
110 {
111 ?>
112
113 <tr>
114 <td colspan="9" class="DataTD"><?=_("No client certificates are currently listed.")?></td>
115 </tr>
116 <? } else {
117 $orgname='';
118 while($row = mysql_fetch_assoc($res))
119 {
120 if ($row['O']<>$orgname) {
121 $orgname=$row['O'];?>
122 <tr>
123 <td colspan="9" class="title"></td>
124 </tr>
125 <tr>
126 <td colspan="9" class="title"><? printf(_("Certificates for %s"), $orgname)?> </td>
127 </tr>
128 <tr>
129 <td class="DataTD"><?=_("OU/Department")?></td>
130 <td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
131 <td class="DataTD"><?=_("Status")?></td>
132 <td class="DataTD"><?=_("CommonName")?></td>
133 <td class="DataTD"><?=_("SerialNumber")?></td>
134 <td class="DataTD"><?=_("Revoked")?></td>
135 <td class="DataTD"><?=_("Expires")?></td>
136 <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
137 </tr>
138 <?
139 }
140 if($row['timeleft'] > 0)
141 $verified = _("Valid");
142 if($row['timeleft'] < 0)
143 $verified = _("Expired");
144 if($row['expired'] == 0)
145 $verified = _("Pending");
146 if($row['revoked'] > 0)
147 $verified = _("Revoked");
148 if($row['revoked'] == 0)
149 $row['revoke'] = _("Not Revoked");
150 ?>
151 <tr>
152 <td class="DataTD"><?=$row['ou']?></td>
153 <? if($verified == _("Valid") || $verified == _("Expired")) { ?>
154 <td class="DataTD"><input type="checkbox" name="revokeid[]" value="<?=$row['id']?>"></td>
155 <td class="DataTD"><?=$verified?></td>
156 <td class="DataTD"><a href="account.php?id=19&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
157 <? } else if($verified == _("Pending")) { ?>
158 <td class="DataTD"><input type="checkbox" name="delid[]" value="<?=$row['id']?>"></td>
159 <td class="DataTD"><?=$verified?></td>
160 <td class="DataTD"><?=$row['CN']?></td>
161 <? } else { ?>
162 <td class="DataTD">&nbsp;</td>
163 <td class="DataTD"><?=$verified?></td>
164 <td class="DataTD"><a href="account.php?id=19&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
165 <? } ?>
166 <td class="DataTD"><?=$row['serial']?></td>
167 <td class="DataTD"><?=$row['revoke']?></td>
168 <td class="DataTD"><?=$row['expires']?></td>
169 <td class="DataTD"><input name="comment_<?=$row['id']?>" type="text" value="<?=htmlspecialchars($row['description'])?>" /></td>
170 <td class="DataTD"><input type="checkbox" name="check_comment_<?=$row['id']?>" /></td>
171 </tr>
172 <? } ?>
173 <tr>
174 <td class="DataTD" colspan="9">
175 <?=_('* Comment is NOT included in the certificate as it is intended for your personal reference only. To change the comment tick the checkbox and hit "Change Settings".')?>
176 </td>
177 </tr>
178 <tr>
179 <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>">&#160;&#160;&#160;&#160;
180 <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td>
181 <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>"> </td>
182 </tr>
183 <tr>
184 <td class="DataTD" colspan="9"><?=_("From here you can delete pending requests, or revoke valid certificates.")?></td>
185 </tr>
186 <? } ?>
187 </table>
188 <input type="hidden" name="oldid" value="<?=$id?>">
189 <input type="hidden" name="csrf" value="<?=make_csrf('clicerchange')?>" />
190 </form>