bug 782: Added comment update for all certificate view pages
authorINOPIAE <inopiae@cacert.org>
Tue, 14 May 2013 20:59:46 +0000 (22:59 +0200)
committerINOPIAE <inopiae@cacert.org>
Tue, 14 May 2013 20:59:46 +0000 (22:59 +0200)
includes/account.php
pages/account/12.php
pages/account/18.php
pages/account/22.php
pages/account/5.php
pages/gpg/2.php
www/gpg.php

index df5fadd..a53cdc7 100644 (file)
                exit;
        }
 
+       if($oldid == 12 && array_key_exists('change',$_REQUEST) && $_REQUEST['change'] != "")
+       {
+       showheader(_("My CAcert.org Account!"));
+       foreach($_REQUEST as $id => $val)
+       {
+               if(substr($id,0,14)=="check_comment_")
+               {
+                       $cid = intval(substr($id,14));
+                       if(!empty($_REQUEST['check_comment_'.$cid])) {
+                               $comment=trim(mysql_real_escape_string(stripslashes($_REQUEST['comment_'.$cid])));
+                               mysql_query("update `domaincerts` set `description`='$comment' where `id`='$cid' and `memid`='".$_SESSION['profile']['id']."'");
+                       }
+               }
+       }
+       echo(_("Certificate settings have been changed.")."<br/>\n");
+       showfooter();
+       exit;
+       }
+
+
        if($oldid == 5 && array_key_exists('renew',$_REQUEST) && $_REQUEST['renew'] != "")
        {
                showheader(_("My CAcert.org Account!"));
                exit;
        }
 
+       if($oldid == 18 && array_key_exists('change',$_REQUEST) && $_REQUEST['change'] != "")
+       {
+       showheader(_("My CAcert.org Account!"));
+       foreach($_REQUEST as $id => $val)
+       {
+               if(substr($id,0,14)=="check_comment_")
+               {
+                       $cid = intval(substr($id,14));
+                       if(!empty($_REQUEST['check_comment_'.$cid])) {
+                               $comment=trim(mysql_real_escape_string(stripslashes($_REQUEST['comment_'.$cid])));
+                               mysql_query("update `orgemailcerts` set `description`='$comment' where `id`='$cid' and `memid`='".$_SESSION['profile']['id']."'");
+                       }
+               }
+       }
+       echo(_("Certificate settings have been changed.")."<br/>\n");
+       showfooter();
+       exit;
+       }
+
+
        if($process != "" && $oldid == 20)
        {
                $CSR = clean_csr($_REQUEST['CSR']);
                exit;
        }
 
+       if($oldid == 22 && array_key_exists('change',$_REQUEST) && $_REQUEST['change'] != "")
+       {
+       showheader(_("My CAcert.org Account!"));
+       foreach($_REQUEST as $id => $val)
+       {
+               if(substr($id,0,14)=="check_comment_")
+               {
+                       $cid = intval(substr($id,14));
+                       if(!empty($_REQUEST['check_comment_'.$cid])) {
+                               $comment=trim(mysql_real_escape_string(stripslashes($_REQUEST['comment_'.$cid])));
+                               mysql_query("update `orgdomaincerts` set `description`='$comment' where `id`='$cid' and `memid`='".$_SESSION['profile']['id']."'");
+                       }
+               }
+       }
+       echo(_("Certificate settings have been changed.")."<br/>\n");
+       showfooter();
+       exit;
+       }
+
+
        if(($id == 24 || $oldid == 24 || $id == 25 || $oldid == 25 || $id == 26 || $oldid == 26 ||
                $id == 27 || $oldid == 27 || $id == 28 || $oldid == 28 || $id == 29 || $oldid == 29 ||
                $id == 30 || $oldid == 30 || $id == 31 || $oldid == 31) &&
index 35ae6c2..44c5739 100644 (file)
 <form method="post" action="account.php">
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
-    <td colspan="6" class="title"><?=_("Domain Certificates")?> - <a href="account.php?id=12&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
+    <td colspan="8" class="title"><?=_("Domain Certificates")?> - <a href="account.php?id=12&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
   </tr>
   <tr>
     <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"><?=_("Comment")?></td>
+    <td class="DataTD"><?=_("SerialNumber")?></td>
     <td class="DataTD"><?=_("Revoked")?></td>
     <td class="DataTD"><?=_("Expires")?></td>
+    <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
   </tr>
 <?
        $query = "select UNIX_TIMESTAMP(`domaincerts`.`created`) as `created`,
@@ -51,7 +51,7 @@
        {
 ?>
   <tr>
-    <td colspan="6" class="DataTD"><?=_("No domains are currently listed.")?></td>
+    <td colspan="8" class="DataTD"><?=_("No domains are currently listed.")?></td>
   </tr>
 <? } else {
        while($row = mysql_fetch_assoc($res))
@@ -64,8 +64,8 @@
                        $verified = _("Pending");
                if($row['revoked'] > 0)
                        $verified = _("Revoked");
-                if($row['revoked'] == 0)
-                        $row['revoke'] = _("Not Revoked");
+               if($row['revoked'] == 0)
+                       $row['revoke'] = _("Not Revoked");
 ?>
   <tr>
 <? if($verified != _("Pending") && $verified != _("Revoked")) { ?>
 <? } ?>
     <td class="DataTD"><?=$verified?></td>
     <td class="DataTD"><a href="account.php?id=15&amp;cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
-         <td class="DataTD"><?=$row['serial']?></td>
-               <td class="DataTD"><?=$row['description']?></td>
+    <td class="DataTD"><?=$row['serial']?></td>
     <td class="DataTD"><?=$row['revoke']?></td>
     <td class="DataTD"><?=$row['expires']?></td>
+    <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>
 <? } ?>
   <tr>
+    <td class="DataTD" colspan="8">
+      <?=_("* Comment is NOT included in the certificate as it is inteded for your personal reference only. To change the comment go to the certificate view with hitting email address.")?>
+    </td>
+  </tr>
+  <tr>
     <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>">&#160;&#160;&#160;&#160;
            <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td>
+       <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>"> </td>
   </tr>
 <? } ?>
 </table>
index 45e3be9..e736977 100644 (file)
@@ -19,7 +19,7 @@
 <form method="post" action="account.php">
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
-    <td colspan="6" class="title"><?=_("Client Certificates")?> - <a href="account.php?id=18&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
+    <td colspan="8" class="title"><?=_("Client Certificates")?> - <a href="account.php?id=18&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
   </tr>
   <tr>
     <td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
@@ -52,7 +52,7 @@
        {
 ?>
   <tr>
-    <td colspan="6" class="DataTD"><?=_("No client certificates are currently listed.")?></td>
+    <td colspan="8" class="DataTD"><?=_("No client certificates are currently listed.")?></td>
   </tr>
 <? } else {
        while($row = mysql_fetch_assoc($res))
     <td class="DataTD"><a href="account.php?id=19&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
 <? } ?>
          <td class="DataTD"><?=$row['serial']?></td>
-               <td class="DataTD"><?=$row['description']?></td>
     <td class="DataTD"><?=$row['revoke']?></td>
     <td class="DataTD"><?=$row['expires']?></td>
+    <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>
 <? } ?>
   <tr>
+    <td class="DataTD" colspan="8">
+      <?=_("* Comment is NOT included in the certificate as it is inteded for your personal reference only. To change the comment go to the certificate view with hitting email address.")?>
+    </td>
+  </tr>
+  <tr>
     <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>">&#160;&#160;&#160;&#160;
                        <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td>
+    <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>"> </td>
   </tr>
 <? } ?>
 </table>
index ac7a645..5d53582 100644 (file)
 <form method="post" action="account.php">
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
-    <td colspan="6" class="title"><?=_("Domain Certificates")?> - <a href="account.php?id=22&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
+    <td colspan="8" class="title"><?=_("Domain Certificates")?> - <a href="account.php?id=22&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
   </tr>
   <tr>
     <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"><?=_("Comment")?></td>
+    <td class="DataTD"><?=_("SerialNumber")?></td>
     <td class="DataTD"><?=_("Revoked")?></td>
     <td class="DataTD"><?=_("Expires")?></td>
-
+    <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
 <?
        $query = "select UNIX_TIMESTAMP(`orgdomaincerts`.`created`) as `created`,
                        UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
@@ -53,7 +52,7 @@
        {
 ?>
   <tr>
-    <td colspan="6" class="DataTD"><?=_("No domains are currently listed.")?></td>
+    <td colspan="8" class="DataTD"><?=_("No domains are currently listed.")?></td>
   </tr>
 <? } else {
        while($row = mysql_fetch_assoc($res))
 <? } ?>
     <td class="DataTD"><?=$verified?></td>
     <td class="DataTD"><a href="account.php?id=23&cert=<?=$row['id']?>"><?=$row['CN']?></a></td>
-         <td class="DataTD"><?=$row['serial']?></td>
-               <td class="DataTD"><?=$row['description']?></td>
+    <td class="DataTD"><?=$row['serial']?></td>
     <td class="DataTD"><?=$row['revoke']?></td>
     <td class="DataTD"><?=$row['expires']?></td>
+    <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>
 <? } ?>
   <tr>
+    <td class="DataTD" colspan="8">
+      <?=_("* Comment is NOT included in the certificate as it is inteded for your personal reference only. To change the comment go to the certificate view with hitting email address.")?>
+    </td>
+  </tr>
+  <tr>
     <td class="DataTD" colspan="6"><input type="submit" name="renew" value="<?=_("Renew")?>">&#160;&#160;&#160;&#160;
            <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>"></td>
+    <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>"> </td>
   </tr>
 <? } ?>
 </table>
index 133e0fe..515d33f 100644 (file)
@@ -57,7 +57,7 @@
        {
 ?>
   <tr>
-    <td colspan="8" class="DataTD"><?=_("No client certificates are currently listed.")?></td>
+    <td colspan="10" class="DataTD"><?=_("No client certificates are currently listed.")?></td>
   </tr>
 <? } else {
        while($row = mysql_fetch_assoc($res))
index fd26367..1773dfa 100644 (file)
 */ ?>
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
-    <td colspan="5" class="title"><?=_("OpenPGP Keys")?></td>
+    <td colspan="6" class="title"><?=_("OpenPGP Keys")?></td>
   </tr>
   <tr>
     <td class="DataTD"><?=_("Status")?></td>
     <td class="DataTD"><?=_("Email Address")?></td>
     <td class="DataTD"><?=_("Expires")?></td>
     <td class="DataTD"><?=_("Key ID")?></td>
-    <td class="DataTD"><?=_("Comment")?></td>
+    <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
 <?
        $query = "select UNIX_TIMESTAMP(`issued`) as `issued`,
                        UNIX_TIMESTAMP(`expire`) - UNIX_TIMESTAMP() as `timeleft`,
                        UNIX_TIMESTAMP(`expire`) as `expired`,
-                       `expire` as `expires`, `id`, `level`, 
+                       `expire` as `expires`, `id`, `level`,
                        `email`,`keyid`,`description` from `gpg` where `memid`='".intval($_SESSION['profile']['id'])."'
                        ORDER BY `issued` desc";
        $res = mysql_query($query);
@@ -37,7 +37,7 @@
        {
 ?>
   <tr>
-    <td colspan="5" class="DataTD"><?=_("No OpenPGP keys are currently listed.")?></td>
+    <td colspan="6" class="DataTD"><?=_("No OpenPGP keys are currently listed.")?></td>
   </tr>
 <? } else {
        while($row = mysql_fetch_assoc($res))
 <? } ?>
     <td class="DataTD"><?=$row['expires']?></td>
     <td class="DataTD"><a href="gpg.php?id=3&amp;cert=<?=$row['id']?>"><?=$row['keyid']?></a></td>
-    <td class="DataTD"><?=$row['description']?></td>
+    <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>
 <? } ?>
 <? } ?>
+  <tr>
+    <td class="DataTD" colspan="6">
+      <?=_("* Comment is NOT included in the certificate as it is inteded for your personal reference only. To change the comment go to the certificate view with hitting email address.")?>
+    </td>
+  </tr>
+  <tr>
+    <td class="DataTD" colspan="6"><input type="submit" name="change" value="<?=_("Change settings")?>"> </td>
+  </tr>
 </table>
 <input type="hidden" name="oldid" value="<?=$id?>">
 </form>
index fcc0742..132e522 100644 (file)
@@ -52,7 +52,7 @@ if(0)
   {
     showheader(_("Welcome to CAcert.org"));
     echo "The OpenPGP signing system is currently shutdown due to a maintenance. We hope to get it fixed within the next few hours. We are very sorry for the inconvenience.";
-  
+
     exit(0);
   }
 }
@@ -143,7 +143,7 @@ function verifyEmail($email)
                        $uidformatwrong=0;
 
                        if(sizeof($bits)<10) $uidformatwrong=1;
-                       
+
                        if(preg_match("/\@.*\@/",$bits[9]))
                        {
                                showheader(_("Welcome to CAcert.org"));
@@ -248,7 +248,7 @@ function verifyEmail($email)
                        $resulttable.="</tr>\n";
 
                        if($emailok) $multiple++;
-                       
+
                        if(trim($_REQUEST['description']) == ""){
        $description= trim(mysql_real_escape_string(stripslashes($_REQUEST['description'])));
       }else{
@@ -286,7 +286,7 @@ function verifyEmail($email)
                                                `level`='1',
                                                `expires`='".mysql_real_escape_string($expires)."',
                                                `multiple`='".mysql_real_escape_string($multiple)."',
-                                               `keyid`='".mysql_real_escape_string($keyid)."', 
+                                               `keyid`='".mysql_real_escape_string($keyid)."',
                                                `description`='".mysql_real_escape_string($description)."'";
                mysql_query($query);
                $id = mysql_insert_id();
@@ -349,7 +349,7 @@ function verifyEmail($email)
                                {
                                        //echo "Not found!\n";
                                }
-       
+
                                $emailok=verifyEmail($mail);
 
                                $uidid=$bits[7];
@@ -403,14 +403,14 @@ function verifyEmail($email)
                        1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
                        2 => array("pipe", "w") // stderr is a file to write to
                );
-               $stderr = fopen('php://stderr', 'w'); 
+
+               $stderr = fopen('php://stderr', 'w');
 
 
                //echo "Keyid: $keyid\n";
 
                $process = proc_open("/usr/bin/gpg --homedir $cwd --no-tty --command-fd 0 --status-fd 1 --logger-fd 2 --edit-key $keyid", $descriptorspec, $pipes);
+
                //echo "Process: $process\n";
                //fputs($stderr,"Process: $process\n");
 
@@ -420,7 +420,7 @@ function verifyEmail($email)
                // 0 => writeable handle connected to child stdin
                // 1 => readable handle connected to child stdout
                // Any error output will be appended to /tmp/error-output.txt
-                       while (!feof($pipes[1])) 
+                       while (!feof($pipes[1]))
                        {
                                $buffer = fgets($pipes[1], 4096);
                                //echo $buffer;
@@ -472,14 +472,14 @@ function verifyEmail($email)
                        }
                        //echo "Fertig\n";
                        fclose($pipes[0]);
+
                        //echo stream_get_contents($pipes[1]);
                        fclose($pipes[1]);
+
                        // It is important that you close any pipes before calling
                        // proc_close in order to avoid a deadlock
                        $return_value = proc_close($process);
+
                        //echo "command returned $return_value\n";
                }
                else
@@ -515,6 +515,25 @@ function verifyEmail($email)
                exit;
        }
 
+if($oldid == 2 && array_key_exists('change',$_REQUEST) && $_REQUEST['change'] != "")
+{
+       showheader(_("My CAcert.org Account!"));
+       foreach($_REQUEST as $id => $val)
+       {
+               if(substr($id,0,14)=="check_comment_")
+               {
+                       $cid = intval(substr($id,14));
+                       if(!empty($_REQUEST['check_comment_'.$cid])) {
+                               $comment=trim(mysql_real_escape_string(stripslashes($_REQUEST['comment_'.$cid])));
+                               mysql_query("update `gpg` set `description`='$comment' where `id`='$cid' and `memid`='".$_SESSION['profile']['id']."'");
+                       }
+               }
+       }
+       echo(_("Certificate settings have been changed.")."<br/>\n");
+       showfooter();
+       exit;
+}
+
        $id = intval($id);
 
        showheader(_("Welcome to CAcert.org"));