0413da045c446be67ad451b988ff6f2983c40c4c
[cacert.git] / pages / account / 22.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('dorgfilterid',$_SESSION['_config']) ? intval($_SESSION['_config']['dorgfilterid']) : 0;
20 $sorting = array_key_exists('dsorting',$_SESSION['_config']) ? intval($_SESSION['_config']['dsorting']) : 0;
21 $status = array_key_exists('dstatus',$_SESSION['_config']) ? intval($_SESSION['_config']['dstatus']) : 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="8" class="title"><?=_("Organisation Server Certificates")?> </td>
27 </tr>
28 <tr>
29 <td colspan="8" class="title"><?=_("Filter/Sorting")?></td>
30 </tr>
31 <tr>
32 <td class="DataTD"><?=_("Organisation")?></td>
33 <td colspan="7" class="DataTD" >
34 <select name="dorgfilterid">
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="7" class="DataTD" >
52 <select name="dsorting">
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" : "" ,_("Common name, expire date (desc)")) ?>
55 </select>
56 </td>
57 </tr>
58 <tr>
59 <td class="DataTD"><?=_("Certificate status")?></td>
60 <td colspan="7" class="DataTD" >
61 <select name="dstatus">
62 <?=sprintf('<option value="%d"%s>%s</option>',0, 0 == $status ? " selected" : "" ,_("Current/Active")) ?>
63 <?=sprintf('<option value="%d"%s>%s</option>',1, 1 == $status ? " selected" : "" ,_("All")) ?>
64 </select>
65 </td>
66 </tr>
67 <tr>
68 <td class="DataTD" colspan="8"><input type="submit" name="reset" value="<?=_("Reset")?>" />&nbsp;&nbsp;&nbsp;&nbsp;
69 <input type="submit" name="filter" value="<?=_("Apply filter/sort")?>" /></td>
70 </tr>
71 <tr>
72 <td colspan="9" class="DataTD"> </td>
73 </tr>
74
75
76 <?
77 $query = "select UNIX_TIMESTAMP(`orgdomaincerts`.`created`) as `created`,
78 UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
79 UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) as `expired`,
80 `orgdomaincerts`.`expire` as `expires`, `revoked` as `revoke`,
81 UNIX_TIMESTAMP(`revoked`) as `revoked`, `CN`,
82 `orgdomaincerts`.`serial`,
83 `orgdomaincerts`.`id` as `id`,
84 `orgdomaincerts`.`description`, `orginfo`.`O`
85 from `orgdomaincerts`,`org`, `orginfo`
86 where `org`.`memid`='".intval($_SESSION['profile']['id'])."'
87 and `orgdomaincerts`.`orgid`=`org`.`orgid` and `orginfo`.`id` = `org`.`orgid`";
88
89 if($orgfilterid>0)
90 {
91 $query .= "AND `org`.`orgid`=$orgfilterid ";
92 }
93
94 if(0==$status)
95 {
96 $query .= "AND `revoked`=0 AND `renewed`=0 ";
97 $query .= "HAVING `timeleft` > 0 ";
98 }
99 switch ($sorting){
100 case 0:
101 $query .= "ORDER BY `orginfo`.`O`, `orgdomaincerts`.`expire` desc";
102 break;
103 case 1:
104 $query .= "ORDER BY `orginfo`.`O`, `orgdomaincerts`.`CN`, `orgdomaincerts`.`expire` desc";
105 break;
106 }
107
108
109 //echo $query."<br>\n";
110 $res = mysql_query($query);
111 if(mysql_num_rows($res) <= 0)
112 {
113 ?>
114 <tr>
115 <td colspan="8" class="DataTD"><?=_("No domains are currently listed.")?></td>
116 </tr>
117 <? } else {
118 $orgname='';
119 while($row = mysql_fetch_assoc($res))
120 {
121 if ($row['O']<>$orgname) {
122 $orgname=$row['O'];?>
123 <tr>
124 <td colspan="9" class="title"></td>
125 </tr>
126 <tr>
127 <td colspan="9" class="title"><? printf(_("Certificates for %s"), $orgname)?> </td>
128 </tr>
129 <tr>
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 <? if($verified == _("Valid") || $verified == _("Expired")) { ?>
153 <td class="DataTD"><input type="checkbox" name="revokeid[]" value="<?=$row['id']?>"></td>
154 <? } else if($verified == _("Pending")) { ?>
155 <td class="DataTD"><input type="checkbox" name="delid[]" value="<?=$row['id']?>"></td>
156 <? } else { ?>
157 <td class="DataTD">&nbsp;</td>
158 <? } ?>
159 <td class="DataTD"><?=$verified?></td>
160 <td class="DataTD"><a href="account.php?id=23&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
161 <td class="DataTD"><?=$row['serial']?></td>
162 <td class="DataTD"><?=$row['revoke']?></td>
163 <td class="DataTD"><?=$row['expires']?></td>
164 <td class="DataTD"><input name="comment_<?=$row['id']?>" type="text" value="<?=htmlspecialchars($row['description'])?>" /></td>
165 <td class="DataTD"><input type="checkbox" name="check_comment_<?=$row['id']?>" /></td>
166 </tr>
167 <? } ?>
168 <tr>
169 <td class="DataTD" colspan="8">
170 <?=_('* 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".')?>
171 </td>
172 </tr>
173 <tr>
174 <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>" />&#160;&#160;&#160;&#160;
175 <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>" /></td>
176 <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>" /> </td>
177 </tr>
178 <tr>
179 <td class="DataTD" colspan="9"><?=_("From here you can delete pending requests, or revoke valid certificates.")?></td>
180 </tr>
181 <? } ?>
182 </table>
183 <input type="hidden" name="oldid" value="<?=$id?>" />
184 <input type="hidden" name="csrf" value="<?=make_csrf('orgsrvcerchange')?>" />
185 </form>
186