dce48fc8 |
1 | <?PHP // $Id$ |
2 | // Authentication by looking up an external database table |
3 | |
4 | // This code is completely untested so far - I'm just jotting down ideas ... |
5 | // Looks like it should work though ... |
6 | |
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"; |
15 | |
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. |
19 | |
20 | global $CFG; |
21 | |
22 | ADOLoadCode($CFG->authdbtype); |
23 | $authdb = &ADONewConnection(); |
24 | $authdb->PConnect($CFG->authdbhost,$CFG->authdbuser,$CFG->authdbpass,$CFG->authdbname); |
25 | |
26 | |
27 | $rs = $authdb->Execute("SELECT * FROM $CFG->authdbtable |
28 | WHERE $CFG->authdbfielduser = '$username' |
29 | AND $CFG->authdbfieldpass = '$password' "); |
30 | if (!$rs) { |
31 | notify("Could not connect to the specified authentication database..."); |
32 | return false; |
33 | } |
34 | |
35 | if ( $rs->RecordCount() ) { |
36 | return true; |
37 | } else { |
38 | return false; |
39 | } |
40 | } |
41 | |
42 | |
43 | ?> |