# Print Release System # (c) 2009 Toby Norden and Steven Brewer include("config.php"); $attempt = $_POST["attempt"]; $button = $_POST["button"]; Function Auth($auth) { global $dit, $ldaphost; $username = strtolower($_POST["username"]); $passwd = $_POST["passwd"]; if($auth=="ldap") { $dn = "uid=${username},${dit}"; #ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); $lc = ldap_connect("$ldaphost"); #echo ldap_error($lc); ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($lc, LDAP_OPT_REFERRALS, 0); if($lc > 0) { # echo "$dn\n
"; $lb = ldap_bind($lc, $dn, $passwd); #echo ldap_error($lc); #echo ldap_errno($lc); if($lb) { $authenticated = "$username"; #echo "authenticated is $username\n"; } } } elseif($auth=="oit") { $mhost = "{mail-" . substr($username,0,1) . ".oit.umass.edu:993/imap/ssl/novalidate-cert}user.$username.[]"; $authenticated = @imap_open("$mhost", $username, $password); } else { $authenticated = @imap_open( "{localhost:143}", $username, $passwd, OP_HALFOPEN ); } if( $authenticated ) { if($auth == "imap") { @imap_close( $mbox ); } return("$username"); } else { return(0); } } if(strcmp($button, "Log out")==0) { unset($_SESSION); session_destroy(); } if(!strcmp($attempt, "true")!=0) { $auth_result = Auth($auth); #echo "got here\n"; if($auth_result) { #echo "got here too\n"; session_start() or die("There was an error. Please try again."); $_SESSION["id"] = rand(1, getrandmax()); $_SESSION["username"] = $auth_result; unset($_POST); header("Location: queue.php"); } else { $errortype = "Bad username or password."; } } include ("header.inc"); echo "
There was a problem: $errortype. Please try again.