18 include_once (
"WHAT/Class.Provider.php");
25 $dbh = pg_connect($this->parms{
'connection'});
27 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: failed connection to database");
31 $stmt = pg_prepare($dbh,
"check_bug_639",
"SELECT login FROM users WHERE login = \$1 AND password !~ '^[a-zA-Z0-9./]{2}'");
33 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: pg_preapare(check_bug_639) returned false");
37 $res = pg_execute($dbh,
"check_bug_639", array(
41 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: pg_execute(check_bug_639) returned false. User $username not found ?");
45 if (pg_num_rows($res) > 0) {
46 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: found bug #639 for user '$username'");
51 $stmt = pg_prepare($dbh,
"get_password",
'SELECT password FROM users WHERE login = $1');
53 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: pg_prepare(get_password) returned false");
57 $res = pg_execute($dbh,
"get_password", array(
61 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: pg_execute(get_password) returned false. User $username not found ?");
65 $encrypted_password = pg_fetch_result($res, 0);
66 if ($encrypted_password ==
"") {
67 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: User $username not found");
71 $ret = preg_match(
"/^(..)/", $encrypted_password, $salt);
73 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: could not get salt from encrypted password for user $username");
77 if ($encrypted_password == crypt(
$password, $salt[0])) {
81 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " . sprintf(
"Password mismatch for user %s", $username));
88 if (!array_key_exists(
'username', $opt)) {
89 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Missing username key in opt array");
93 $dbh = pg_connect($this->parms{
'connection'});
95 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error connecting to database");
99 $stmt = pg_prepare($dbh,
"get_status",
'SELECT status FROM users WHERE login = $1');
100 if ($stmt == FALSE) {
101 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error preparing select statement");
105 $res = pg_execute($dbh,
"get_status", array(
109 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error in result of get_status");
113 $status = pg_fetch_result($res, 0);
114 if ($status ==
'D') {
115 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Account " . $opt[
'username'] .
" has been suspended");