Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.52 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use DBI;
  5. use DBD::Pg;
  6. use DateTime;
  7. use CGI ':standard';
  8.  
  9. my $username = $ENV{"HTTP_CAS_USER"}; # username from the environment
  10. my $password = "";
  11. my $effective = 0;
  12. my $expiry = 0;
  13. my $comment = "";
  14. my $email = "";
  15. my $state = "active";
  16. my $sponsor = $username;              # for now, the sponsor is the uw user
  17.  
  18. sub expiry {
  19.  
  20.     # in this subroutine we want to define different sponsorship
  21.     # periods depending on who the sponsor is (professor vs
  22.     # ungergraduates and so forth
  23.  
  24.     my $startDate = $_[0];
  25.     my $duration = DateTime::Duration->new ( months => 1);
  26.  
  27.     return ($startDate + $duration);
  28. }
  29.  
  30. my ($cday, $cmonth, $cyear) = (localtime)[3,4,5];
  31. my $cdate = ($cyear+1900)."-".($cmonth+1)."-".($cday);
  32. my $currentTime = DateTime->from_epoch( epoch => time());
  33. my $expiryDate = expiry($currentTime)->date;
  34. print header;
  35. print start_html("NetID Activation");
  36.  
  37.     print start_form;
  38.  
  39.     print "<table border=\"1\" cellpadding=\"2\" frame=\"void\">\n<tr>\n<th align=\"left\">UW ID:</th><th>";
  40.     print textfield(-name=>'uwid',
  41.                     -value=>$username,
  42.                     -size=>35,
  43.                     -maxlength=>30);
  44.     print "</th>\n</tr>\n<tr>\n<th align=\"left\">Password</th><th>";
  45.     print password_field(-name=>'password',
  46.                          -value=>'',
  47.                          -size=>'35',
  48.                          -maxlength=>'80');
  49.     print "</th>\n</tr>\n<tr><th align=\"left\">E-mail</th><th>";
  50.     print textfield(-name=>'email',
  51.                     -value=>'',
  52.                     -size=>35,
  53.                     -maxlength=>50);
  54.     print "</th>\n</tr>\n<tr><th align=\"left\">Sponsor</th><th>";
  55.     print textfield(-name=>'sponsor',
  56.                     -value=>$username,
  57.                     -size=>35,
  58.                     -maxlength=>50,
  59.                     -disabled=>1);
  60.     print "</th>\n</tr>\n<tr><th align=\"left\">Effective</th><th>";
  61.     print textfield(-name=>'effective',
  62.                     -value=>$cdate,
  63.                     -size=>35,
  64.                     -maxlength=>15,
  65.                     -disabled=>1);
  66.     print "</th>\n</tr>\n<tr><th>Expiry</th><th>";
  67.     print textfield(-name=>'expiry',
  68.                     -value=>$expiryDate,
  69.                     -size=>35,
  70.                     -maxlength=>15,
  71.                     -disabled=>1);
  72.     print "</th>\n</tr>\n</table>\n";
  73.  
  74.     print "<p>",reset;
  75.     print submit('Action','Activate Net ID');
  76.  
  77.     print end_form;
  78.     print "<hr>\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement