print "Ensemble Participant Manager
";
$tc = isset($_GET['tc'])? $_GET['tc'] : $_POST['tc'] ;
//obtain current get string to pass back to this script if desired.
$getStr = sprintf("?tc=%s",$tc);
if(isset($_GET['id'])) {
$getStr = $getStr . sprintf("&id=%s",$_GET['id']);
}
$printUsage = FALSE;
//at initial entry, make sure that required $_GET variables are assigned
if(empty($tc)) {
print('ERROR: Missing ticket code (tc) GET variable
');
$printUsage = TRUE;
}
if($printUsage) {
print "USAGE:
";
print (empty($_SERVER['HTTPS']))? "http://" : "https://";
printf("%s%s?tc=512fb1b3f336
",$_SERVER['HTTP_HOST'],$_SERVER['PHP_SELF']);
die();
}
$enc_key = subinfo_encryption_key();
//authenticate the participant if username and password entered or if it is stored in $_SESSION
if($login_posted || $login_saved) {
$username = ($login_posted)? $_POST['username'] : $_SESSION['pman_username'];
$passcode = ($login_posted)? $_POST['passcode'] : mysql_aes_decrypt($_SESSION['pman_passcode'],$enc_key);
$sql_check_passcode = sprintf("select aes_decrypt(`passphrase`,'%s') as passphrase from subject " .
"left join subject_x_attribute using (subject_id) left join attribute using (attribute_id) ".
"where subject_id = '%s' and attribute.name = 'person_type' and ".
"attribute_value_text = 'caregiver'",$enc_key,$username);
$row_passcode = mysql_select($sql_check_passcode);
if(strcmp($row_passcode['passphrase'],$passcode) != 0) {
print "Incorrect Username/Passcode Entered.
";
unset($_SESSION['pman_username']);
unset($_SESSION['pman_passcode']);
unset($_SESSION['wing_assignment']);
}
elseif($login_posted) {
$_SESSION['pman_username'] = $_POST['username'];
$_SESSION['pman_passcode'] = mysql_aes_encrypt($_POST['passcode'],$enc_key);
}
}
//if username and password are not stored in $_SESSION, display the login form
if(!isset($_SESSION['pman_username']) || !isset($_SESSION['pman_passcode'])) {
//display username and password fields
printf("