#!/usr/bin/perl

print "Content-type: text/html\n\n";
       print "<html>\n <head>\n</head> <body>";
      print "</body> </html>\n";

open DATA, "<data";
$data = "";
while ($line = <DATA>) {
  $data = "$data $line";
}  

$data =~ /netid=(.*?);/;
$netid = $1;
$data =~ /personalizedEmailAddress=(.*?);/;
$personalizedEmailAddress= $1;
$data =~ /retiringEmailAddress=(.*?);/;
$retiringEmailAddress= $1;
$data =~ /retirementDate=(.*?);/;
$retirementDate= $1;
$data =~ /assignedEmailService=(.*?);/;
$assignedEmailService = $1;
$data =~ /secondaryEmailService=(.*?);/;
$secondaryEmailService= $1;
$data =~ /officialEmailAddress=(.*?);/;
$officialEmailAddress = $1;



print "<b><center>Manage email </b> </center><br>";
print "  Users are encouraged to establish a personalized email address and to list this address in the Rutgers Directory.  Please review and complete each of the following sections</center> <br>";

print "<br><br>";
print "netid= $netid<br>\n";
print "personalizedEmailAddress= $personalizedEmailAddress<br>\n";
print "retiringEmailAddress= $retiringEmailAddress<br>\n";
print "retirementDate = $retirementDate<br>\n";
print "assignedEmailService = $assignedEmailService<br>\n";
print "secondaryEmailService=$secondaryEmailService<br>\n";
print "officialEmailAddress= $officialEmailAddress<br>\n";

print "<br><br><hr>";
print "<b> Personalized  Email address</b> <br><br> ";
print "Messages sent to  a personalized email address will be placed in the inbox of your rutgers email service. <br><br> ";


if ($personalizedEmailAddress eq "" && $retiringEmailAddress eq "") {
# register a personalized email address
  print "You have not registered a personalized email address.  <button onclick=\"location.href='gpea.html'\">Register a personalized email address</button>";
}
if ($personalizedEmailAddress ne "" && $retiringEmailAddress eq "") {
#  update the personalized address
 print "$personalizedEmailAddress is your personalized email address.  <button> Update your personalized email address</button>";
}
if ($personalizedEmailAddress ne "" && $retiringEmailAddress ne "") {
  print "$personalizedEmailAddress is your personalized email address.  Your previous personalized email address, $retiringEmailAddress, will continue to accept messages ";
  print " until $retirementDate after which it will be retired.  No further changes may be made to your personal email address until after  $retirementDate";
}

print "<br><br><hr>";
print "<b>RutgersEmail Service</b>";
print "<br><br><hr>";
print "<b>Secondary Email Service</b>";
print "<br><br><hr>";
print "<b>Official Email Address</b>";

print "<form>";
if ($personalizedEmailAddress ne "") {
 print "<input type=\"radio\"'> $personalizedEmailAddress\@rutgers.edu</input><br>";
}
if ($assignedEmailService ne "") {
    $tmp = "$netid\@$assignedEmailService";
 print "<input type=\"radio\"'> $tmp</input><br>";
}
print "</form>";

print "</body> </html>"

