#!/usr/bin/perl -w
#---------------------------------------------------------------
# Study Log: Submit House CGI
# By Crystal White modified by Michael Pierce and Todd Vandenbark
# April 4, 2009 (last modified April 26, 2009)
# Task:
# -bring up a page with a drop down menu for the student to select a greek organization
# -Information is going to go into the file for our information
# -submit to the confirmHouse.cgi
# -print confirmation page
# -use cookies to maintain the state of pages
# Input: Greek House
# Output: Greek House, information from ldap.txt and cookie
#---------------------------------------------------------------
use CGI qw(:standard -debug);
use CGI::Carp qw(fatalsToBrowser);
# --- retrieve cookie ---------------------------------- #
$cookiedata=cookie("id");
# ---- define variables ------------------------ #
$stf= "../ldap.txt"; # LDAP verification file
$gkf = '../org.txt'; #list of greek organizations
@greeks = (); # array to hold Greek list
$incorrect = 0; # error flag: bad Greek org
$bsuname=""; # new user BSU username
$fname=""; # student's first name
$lname=""; # student's last name
$mismatch=1; # LDAP not matched
$adduser=""; # add student to Study Log
# Set stylesheet
$css = '';
# ---- begin code ----------------------------- #
# ---- HTML form ----
$form1= "http://studylog.firesidelibrarian.com/manualid.html";
# ---- get form input ---- #
$greekhouse= param("greekhouse");
$greekhouse =~ s/_/ /g;
$greekhouse = &cleaninput($greekhouse);
$id = $cookiedata;
$id = &cleaninput($id);
if (-r $stf) {
# read in LDAP file
open(IN,$stf) || die "can't read $stf";
@sts = ;
close IN;
chomp @sts;
# seek matching student ID #
foreach $key (@sts) {
($idnum2,$user2,$first2,$last2) = split(/:/,$key);
if ($id eq $idnum2) { # if match found, retrieve info
$bsuname = $user2; # and exit foreach
$fname = $first2;
$lname = $last2;
$mismatch = 0;
last; }
else { $mismatch =1; } # no LDAP match found
} # end foreach
} # end if (-r $stf)...
# ---- test for valid input ----------------------- #
open(IN, $gkf) ||
die "Can't open file $gkf: $! \n";
@gkf = ;
close IN;
chomp @gkf;
if (!$greekhouse) { $missing = "Greek House"; }
else { # ---- look for matching Greek org name ---- #
foreach $key (@gkf) {
($orgname1,$contact1,$email1,$phone1) = split(/:/, $key);
if ($greekhouse eq $orgname1) { # match found
$incorrect=0;
last; }
else { $incorrect=1; } # no match found
}
# reprompt for input if missing
if ($missing) {
$title = "Missing input";
$subtitle = "Incomplete input";
$content = "
';
&pgprint();
exit;
}
# check for validity, reprompt for invalid input
if ($incorrect) {
$invalid= "Greek House";
$title = 'Invalid input';
$subtitle = "You did not enter a valid $invalid<\/b>.";
$content = "