2 // Authentication by looking up an external database table
4 // This code is completely untested so far - I'm just jotting down ideas ...
5 // Looks like it should work though ...
7 $CFG->authdbhost = "localhost";
8 $CFG->authdbtype = "mysql"; // (postgresql, etc)
9 $CFG->authdbname = "authtest";
10 $CFG->authdbtable = "users";
11 $CFG->authdbuser = "user";
12 $CFG->authdbpass = "pass";
13 $CFG->authdbfielduser = "user";
14 $CFG->authdbfieldpass = "pass";
16 function auth_user_login ($username, $password) {
17 // Returns true if the username and password work
18 // and false if they are wrong or don't exist.
22 ADOLoadCode($CFG->authdbtype);
23 $authdb = &ADONewConnection();
24 $authdb->PConnect($CFG->authdbhost,$CFG->authdbuser,$CFG->authdbpass,$CFG->authdbname);
27 $rs = $authdb->Execute("SELECT * FROM $CFG->authdbtable
28 WHERE $CFG->authdbfielduser = '$username'
29 AND $CFG->authdbfieldpass = '$password' ");
31 notify("Could not connect to the specified authentication database...");
35 if ( $rs->RecordCount() ) {