2 // Authentication by looking up an external database table
5 function auth_user_login ($username, $password) {
6 // Returns true if the username and password work
7 // and false if they are wrong or don't exist.
11 ADOLoadCode($CFG->auth_dbtype);
12 $authdb = &ADONewConnection();
13 $authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
15 switch ($CFG->auth_dbpasstype) { // Re-format password accordingly
17 $password = md5($password);
21 $rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
22 WHERE $CFG->auth_dbfielduser = '$username'
23 AND $CFG->auth_dbfieldpass = '$password' ");
25 notify("Could not connect to the specified authentication database...");
29 if ( $rs->RecordCount() ) {
37 function auth_get_userinfo($username){
38 // Reads any other information for a user from external database,
39 // then returns it in an array
42 $config = (array) $CFG;
44 ADOLoadCode($CFG->auth_dbtype);
45 $authdb = &ADONewConnection();
46 $authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
48 $fields = array("firstname", "lastname", "email", "phone1", "phone2",
49 "department", "address", "city", "country", "description",
54 foreach ($fields as $field) {
55 if ($config["auth_user_$field"]) {
56 if ($rs = $authdb->Execute("SELECT ".$config["auth_user_$field"]." FROM $CFG->auth_dbtable
57 WHERE $CFG->auth_dbfielduser = '$username'")) {
58 if ( $rs->RecordCount() == 1 ) {
59 $result["$field"] = $rs->fields[$config["auth_user_$field"]];