7b7db2d7c8dc14d128dd33e3cf7dd1d5fb9fa0ec
[cacert-devel.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(`orgdomaincerts`.`revoked`) as `revoked`,
82 if (`orgdomaincerts`.`expire`=0,CURRENT_TIMESTAMP(),`orgdomaincerts`.`modified`) as `modified`,
83 `CN`,
84 `orgdomaincerts`.`serial`,
85 `orgdomaincerts`.`id` as `id`,
86 `orgdomaincerts`.`description`, `orginfo`.`O`
87 from `orgdomaincerts`,`org`, `orginfo`
88 where `org`.`memid`='".intval($_SESSION['profile']['id'])."'
89 and `orgdomaincerts`.`orgid`=`org`.`orgid` and `orginfo`.`id` = `org`.`orgid`";
90
91 if($orgfilterid>0)
92 {
93 $query .= "AND `org`.`orgid`=$orgfilterid ";
94 }
95
96 if(0==$status)
97 {
98 $query .= "AND `revoked`=0 AND `renewed`=0 ";
99 $query .= "HAVING `timeleft` > 0 or `expires` = 0 ";
100 }
101 switch ($sorting){
102 case 0:
103 $query .= "ORDER BY `orginfo`.`O`, `modified` desc";
104 break;
105 case 1:
106 $query .= "ORDER BY `orginfo`.`O`, `orgdomaincerts`.`CN`, `modified` desc";
107 break;
108 }
109
110
111 //echo $query."<br>\n";
112 $res = mysql_query($query);
113 if(mysql_num_rows($res) <= 0)
114 {
115 ?>
116 <tr>
117 <td colspan="8" class="DataTD"><?=_("No domains are currently listed.")?></td>
118 </tr>
119 <? } else {
120 $orgname='';
121 while($row = mysql_fetch_assoc($res))
122 {
123 if ($row['O']<>$orgname) {
124 $orgname=$row['O'];?>
125 <tr>
126 <td colspan="9" class="title"></td>
127 </tr>
128 <tr>
129 <td colspan="9" class="title"><? printf(_("Certificates for %s"), $orgname)?> </td>
130 </tr>
131 <tr>
132 <td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
133 <td class="DataTD"><?=_("Status")?></td>
134 <td class="DataTD"><?=_("CommonName")?></td>
135 <td class="DataTD"><?=_("SerialNumber")?></td>
136 <td class="DataTD"><?=_("Revoked")?></td>
137 <td class="DataTD"><?=_("Expires")?></td>
138 <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
139 </tr>
140 <?
141 }
142 if($row['timeleft'] > 0)
143 $verified = _("Valid");
144 if($row['timeleft'] < 0)
145 $verified = _("Expired");
146 if($row['expired'] == 0)
147 $verified = _("Pending");
148 if($row['revoked'] > 0)
149 $verified = _("Revoked");
150 if($row['revoked'] == 0)
151 $row['revoke'] = _("Not Revoked");
152 ?>
153 <tr>
154 <? if($verified == _("Valid") || $verified == _("Expired")) { ?>
155 <td class="DataTD"><input type="checkbox" name="revokeid[]" value="<?=$row['id']?>"></td>
156 <? } else if($verified == _("Pending")) { ?>
157 <td class="DataTD"><input type="checkbox" name="delid[]" value="<?=$row['id']?>"></td>
158 <? } else { ?>
159 <td class="DataTD">&nbsp;</td>
160 <? } ?>
161 <td class="DataTD"><?=$verified?></td>
162 <td class="DataTD"><a href="account.php?id=23&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
163 <td class="DataTD"><?=$row['serial']?></td>
164 <td class="DataTD"><?=$row['revoke']?></td>
165 <td class="DataTD"><?=$row['expires']?></td>
166 <td class="DataTD"><input name="comment_<?=$row['id']?>" type="text" value="<?=htmlspecialchars($row['description'])?>" /></td>
167 <td class="DataTD"><input type="checkbox" name="check_comment_<?=$row['id']?>" /></td>
168 </tr>
169 <? } ?>
170 <tr>
171 <td class="DataTD" colspan="8">
172 <?=_('* 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".')?>
173 </td>
174 </tr>
175 <tr>
176 <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>" />&#160;&#160;&#160;&#160;
177 <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>" /></td>
178 <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>" /> </td>
179 </tr>
180 <tr>
181 <td class="DataTD" colspan="9"><?=_("From here you can delete pending requests, or revoke valid certificates.")?></td>
182 </tr>
183 <? } ?>
184 </table>
185 <input type="hidden" name="oldid" value="<?=$id?>" />
186 <input type="hidden" name="csrf" value="<?=make_csrf('orgsrvcerchange')?>" />
187 </form>
188