bug 1138: added function get_server_certs
authorINOPIAE <inopiae@cacert.org>
Sun, 8 Dec 2013 16:00:30 +0000 (17:00 +0100)
committerINOPIAE <inopiae@cacert.org>
Sun, 8 Dec 2013 16:00:30 +0000 (17:00 +0100)
includes/notary.inc.php
pages/account/59.php

index be725f8..d20368b 100644 (file)
@@ -1267,6 +1267,26 @@ function get_client_certs($userid,$viewall=0){
        return mysql_query($query);
 }
 
+function get_server_certs($userid,$viewall=0){
+       //add to account/12.php
+       $userid = intval($userid);
+       $query = "select UNIX_TIMESTAMP(`domaincerts`.`created`) as `created`,
+                       UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
+                       UNIX_TIMESTAMP(`domaincerts`.`expire`) as `expired`,
+                       `domaincerts`.`expire` as `expires`, `revoked` as `revoke`,
+                       UNIX_TIMESTAMP(`revoked`) as `revoked`, `CN`, `domaincerts`.`serial`, `domaincerts`.`id` as `id`,
+                       `domaincerts`.`description`
+                       from `domaincerts`,`domains`
+                       where `memid`='".$userid."' and `domaincerts`.`domid`=`domains`.`id` ";
+       if($viewall != 1)
+       {
+               $query .= "AND `revoked`=0 AND `renewed`=0 ";
+               $query .= "HAVING `timeleft` > 0 ";
+       }
+       $query .= "ORDER BY `domaincerts`.`modified` desc";
+       return mysql_query($query);
+}
+
 
 
 function output_log_email_header(){
@@ -1416,7 +1436,7 @@ function output_client_cert_header($support=0){
 }
 
 function output_client_cert($row, $support=0){
-       //should be entered in account/55.php
+       //should be entered in account/5.php
        $verified="";
        if($row['timeleft'] > 0)
                $verified = _("Valid");
@@ -1428,7 +1448,7 @@ function output_client_cert($row, $support=0){
                $verified = _("Revoked");
        if($row['revoked'] == 0)
                $row['revoke'] = _("Not Revoked");
-?>
+       ?>
        <tr>
        <?
        if($verified != _("Pending") && $verified != _("Revoked")) {
@@ -1476,4 +1496,62 @@ function output_client_cert($row, $support=0){
        </tr>
 
        <?
+}
+
+function output_log_server_certs_header($support=0){
+       ?>
+       //should be entered in account/12.php
+       <tr>
+               <?if ($support !=1) { ?>
+                       <td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
+               <? } ?>
+               <td class="DataTD"><?=_("Status")?></td>
+               <td class="DataTD"><?=_("CommonName")?></td>
+               <td class="DataTD"><?=_("SerialNumber")?></td>
+               <td class="DataTD"><?=_("Revoked")?></td>
+               <td class="DataTD"><?=_("Expires")?></td>
+               <?if ($support !=1) { ?>
+                       <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
+               <? } ?>
+       </tr>
+       <?
+}
+
+function output_log_server_certs($row, $support=0){
+       //should be entered in account/12.php
+       if($row['timeleft'] > 0)
+               $verified = _("Valid");
+       if($row['timeleft'] < 0)
+               $verified = _("Expired");
+       if($row['expired'] == 0)
+               $verified = _("Pending");
+       if($row['revoked'] > 0)
+               $verified = _("Revoked");
+       if($row['revoked'] == 0)
+               $row['revoke'] = _("Not Revoked");
+       ?>
+       <tr>
+               <? if ($support !=1) {
+                       if($verified != _("Pending") && $verified != _("Revoked")) { ?>
+                               <td class="DataTD"><input type="checkbox" name="revokeid[]" value="<?=$row['id']?>"/></td>
+                       <? } else if($verified != _("Revoked")) { ?>
+                               <td class="DataTD"><input type="checkbox" name="delid[]" value="<?=$row['id']?>"/></td>
+                       <? } else { ?>
+                               <td class="DataTD">&nbsp;</td>
+                       <? }
+               }?>
+               <td class="DataTD"><?=$verified?></td>
+               <?if ($support !=1) { ?>
+                       <td class="DataTD"><a href="account.php?id=15&amp;cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
+               <? }ELSE{ ?>
+                       <td class="DataTD"><?=$row['CN']?></td>
+               <?}?>
+               <td class="DataTD"><?=$row['serial']?></td>
+               <td class="DataTD"><?=$row['revoke']?></td>
+               <td class="DataTD"><?=$row['expires']?></td>
+               <?if ($support !=1) { ?>
+                       <td class="DataTD"><input name="comment_<?=$row['id']?>" type="text" value="<?=htmlspecialchars($row['description'])?>" /></td>
+                       <td class="DataTD"><input type="checkbox" name="check_comment_<?=$row['id']?>" /></td>
+               <?}?>
+       </tr>
 }
\ No newline at end of file
index 907be36..e8509df 100644 (file)
@@ -177,7 +177,7 @@ if(mysql_num_rows($dres) > 0) {
 </table>
 <br/>
 <?
-$dres = get_se_log($userid);
+$dres = get_client_certs($userid);
 $colspan=10;
 if (1==$support) {
        $colspan=7;
@@ -189,10 +189,33 @@ if (1==$support) {
   </tr>
 <?
 if(mysql_num_rows($dres) > 0) {
-       output_log_se_header($support);
+       output_client_cert_header($support);
        while($drow = mysql_fetch_assoc($dres))
        {
-               output_log_se($drow,$support);
+               output_client_cert($drow,$support);
+       }ELSE{
+               ?><td colspan="<? $colspan?>" ><?=_('no entry avialable')?></td><?
+       }
+}?>
+</table>
+<br/>
+       <?
+       $dres = get_server_certs($userid);
+$colspan=8;
+if (1==$support) {
+       $colspan=5;
+}
+?>
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+  <tr>
+    <td colspan="<? $colspan?>" class="title"><?=_('Server certificates')?></td>
+  </tr>
+<?
+if(mysql_num_rows($dres) > 0) {
+       output_log_server_certs_header($support);
+       while($drow = mysql_fetch_assoc($dres))
+       {
+               output_log_server_certs($drow,$support);
        }ELSE{
                ?><td colspan="<? $colspan?>" ><?=_('no entry avialable')?></td><?
        }
@@ -202,9 +225,7 @@ if(mysql_num_rows($dres) > 0) {
 
 <table>
 
-  <tr>
-    <td colspan="<? $colspandefault ?>" class="title"><?=_('Server certificates')?></td>
-  </tr>
+
   <tr>
     <td colspan="<? $colspandefault ?>" class="title"><?=_('GPG certificates')?></td>
   </tr>