Armed with knowledge gained on this list that route y login does not
have anything to do with javascript, and with Trevan's information about
the live http headers plugin for firefox, I was able to construct a
simple php function that follows the mess of byu's redirects and is able
to return a simple true or false answer when I need to verify a user's
route Y credentials. It is below. Right now it works except for one
issue. If the password contains a "&" or a "+" I don't believe it will
work properly. I will look into this and maybe properly pre-encode the
fields.
function authenticate_routey($username, $password) {
$c=curl_init();
$cookiejar=tempnam("/tmp","ry");
curl_setopt($c, CURLOPT_COOKIEJAR, $cookiejar);
curl_setopt($c, CURLOPT_COOKIEFILE, $cookiejar);
curl_setopt($c, CURLOPT_RETURNTRANSFER,1);
curl_setopt($c, CURLOPT_HEADER,1);
curl_setopt($c, CURLOPT_URL,
"https://login.byu.edu/login/html/login.fcc");
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS,
"target=http://nonexistant.chem.byu.edu&USER=$username&PASSWORD=$password");
$result=curl_exec($c);
$e=curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
unlink($cookiejar);
/* if the route y login succeeded, curl is redirected to a nonexistant
url
which will error out, either with a 404, or with a 500 proxy error.
If
the login was a failure, BYU's login url will redirect us to a route
y
login page. Thus ultimate http failure means the login was
successful.
*/
if ($e >=200 and $e < 300) { //we got the route y login page
return False;
} else {
return True; //we got the non-existant page
}
}
--------------------
BYU Unix Users Group
http://uug.byu.edu/
The opinions expressed in this message are the responsibility of their
author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list