<?php
require("includes/.htconfig.php");
if (array_key_exists("command",$_REQUEST) and ($_REQUEST["command"] == "Please sign my PersonalNDA"))
{
  define("CEOKEY",HARDTOGET."/ValID/ceo.key.pem");
  define("CEOCERT",HARDTOGET."/ValID/ceo.crt.pem");
  define("NDASUBJECT","Your signed NonDisclosure Agreement");
  define("MIMEBOUNDARY","--Identity is the Foundation of Security");
  define("SECONDBOUNDARY","--Have identities before you manage them");
  $key=openssl_pkey_get_private("file://".CEOKEY);
  $pdfname=NDASTORAGE."/$enrollee_id.pdf";
  $nda=file_get_contents($pdfname);
  $signame=NDASTORAGE."/$enrollee_id.p7s";
  $headers=array("To"=>$enrollee["email"],
                "From"=>EMAILFROM,
                "Subject"=>NDASUBJECT);
  if (openssl_pkcs7_sign($pdfname,$signame,"file://".CEOCERT,$key,$headers ))
  {
    loggywoggy("Signature for NDA $enrollee_id created at $signame.");
    $sig=file_get_contents($signame);
    if (fromREQUEST("emailme") == "1")
    {
      $headers="From: ".EMAILFROM
        ."\nMIME-Version: 1.0"
        ."\nContent-Type: multipart/mixed;
        boundary=\"".MIMEBOUNDARY."\"";
      $message="--".MIMEBOUNDARY."\nContent-Type: text/plain;
	charset=\"us-ascii\"
Content-Transfer-Encoding: quoted-printable

Attached to this message will be your NonDisclosure Agreement (NDA) "
        ."and the digital signature of our CEO, ".OURCEONAME."."
        ."\n\n--".MIMEBOUNDARY
        ."\nContent-Type:multipart/signed; protocol=\"application/x-pkcs7-signature\"; micalg=sha1; boundary=\"".SECONDBOUNDARY."\""
        ."\n\n"
        ."--".SECONDBOUNDARY
        ."\nContent-Type: application/pdf; name=\"NDA.pdf\""
        ."\nContent-Transfer-Encoding: base64"
        ."\nContent-Disposition: attachment; filename=\"NDA.pdf\""
        ."\n\n"
        .base64_encode($nda)
        ."\n\n--".SECONDBOUNDARY
        ."\nContent-Type: application/x-pkcs7-signature; name=\"NDA.p7s\""
        ."\nContent-Transfer-Encoding: base64"
        ."\nContent-Disposition: attachment; filename=\"NDA.p7s\""
        ."\nContent-Description: S/MIME Cryptographic Signature"
        ."\n\n"
        .base64_encode($sig)
        ."\n\n--".SECONDBOUNDARY
        ."\n\n--".MIMEBOUNDARY;
      if(mail($enrollee["email"],NDASUBJECT,$message,$headers))
        loggywoggy("Signed NDA sent to $enrollee_id.");
    }
    #advancePage($enrollee_id,$newby);
  }
  else
    echo "<BR>The signing did not work with certificate at ".CEOCERT.".";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="./style/design.css" rel="stylesheet" type="text/css" />

<style type="text/css">
<!--
.style1 {font-size: 0.8em}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nondisclosure Agreement</title>

</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center" valign="top">
<?php
include_once("includes/header.php");
?>
	<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">	 
	 <tr>
	   <td width="30%" valign="top">
		<div class="bodySubHeader">
		<span class="bsht03">Establishing your Identity Fortress: Step 3</span>		
		</div>
		</td>
	 </tr> 
	</table>	

	<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="DarkLightBox">	
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">
<h2>
Gathering the information to be protected. </h2>
<br />
The next step is to gather the basic informaton that will serve as the
beginning of your personal autobiographical work. <br /><br />But first, you'll
want an authorized member of our firm to sign your PersonalNDA. Since
you have made no edits to our recommended terms and conditions we can
use
an automated process to sign your Personal Nondisclosure Agreement.
<br />
<br />
       I hereby request that you sign my Personal Nondisclosure Agreement.
       <br/><form method="post" action="<?=$script?>">
       <br/><input type="checkbox" name="emailme" value="1"/>Pleae also send me an email containing the NDA and your signature.
         <input value="Please sign my PersonalNDA" type="submit" name="command" />
       </form>
<br />
<br />
	   </td>	   
	 </tr>	
	</table>
<?php
include_once("includes/footer.php");
?>
		</td>
	</tr>
</table>
</body>
</html>