Slight improvements to file security (scan for more bad characters)
[moodle.git] / auth / db / lib.php
CommitLineData
dce48fc8 1<?PHP // $Id$
2 // Authentication by looking up an external database table
3
d5b94ef4 4// This code is completely untested so far - IT NEEDS TESTERS!
dce48fc8 5// Looks like it should work though ...
6
dce48fc8 7
8function auth_user_login ($username, $password) {
9// Returns true if the username and password work
10// and false if they are wrong or don't exist.
11
12 global $CFG;
13
d1b4e172 14 ADOLoadCode($CFG->auth_dbtype);
dce48fc8 15 $authdb = &ADONewConnection();
d1b4e172 16 $authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
dce48fc8 17
18
d1b4e172 19 $rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
20 WHERE $CFG->auth_dbfielduser = '$username'
21 AND $CFG->auth_dbfieldpass = '$password' ");
dce48fc8 22 if (!$rs) {
23 notify("Could not connect to the specified authentication database...");
24 return false;
25 }
26
27 if ( $rs->RecordCount() ) {
28 return true;
29 } else {
30 return false;
31 }
32}
33
34
35?>