54 |
|
|
55 |
// select the correct password for the supplied |
// select the correct password for the supplied |
56 |
// node from the DB |
// node from the DB |
57 |
$sql = "SELECT password from users WHERE username='" . $username . "'"; |
$sql = "SELECT password, confirm from users WHERE username='" . $username . "'"; |
58 |
|
|
59 |
$loc_db->query ( $sql ); |
$loc_db->query ( $sql ); |
60 |
|
|
64 |
// move to the record |
// move to the record |
65 |
$loc_db->next_record(); |
$loc_db->next_record(); |
66 |
|
|
67 |
|
// if the user hasnt confirmed yet |
68 |
|
if (!$loc_db->f("confirm")) { |
69 |
|
|
70 |
|
//user cant login yet |
71 |
|
return false; |
72 |
|
|
73 |
// if the password from the DB matches the one supplied |
// if the password from the DB matches the one supplied |
74 |
if ($loc_db->f("password") == $password) { |
} elseif ($loc_db->f("password") == $password) { |
75 |
|
|
76 |
// user is authenticated |
// user is authenticated |
77 |
return true; |
return true; |
95 |
|
|
96 |
} // end login() |
} // end login() |
97 |
|
|
98 |
|
|
99 |
|
function logout() { |
100 |
|
|
101 |
|
session_destroy(); |
102 |
|
|
103 |
|
} |
104 |
|
|
105 |
/* |
/* |
106 |
* email_password() |
* email_password() |
107 |
* |
* |
165 |
} // end email_password() |
} // end email_password() |
166 |
|
|
167 |
} |
} |
168 |
|
|
169 |
|
function register_user($username, $full_name, $email, $notify_updates, $password) { |
170 |
|
|
171 |
|
// create DB class |
172 |
|
$loc_db = new locDatabase; |
173 |
|
|
174 |
|
if ($notify_updates == "on") { |
175 |
|
|
176 |
|
$notify_updates = 1; |
177 |
|
|
178 |
|
} else { |
179 |
|
|
180 |
|
$notify_updates = 0; |
181 |
|
|
182 |
|
} |
183 |
|
|
184 |
|
$sql = "INSERT into users (username, name, email, notify_updates, password, confirm) VALUES('$username', '$fullname', '$email', $notify_updates, '" . md5($password) . "', 0)"; |
185 |
|
|
186 |
|
$loc_db->query($sql); |
187 |
|
|
188 |
|
return true; |
189 |
|
|
190 |
|
} |
191 |
?> |
?> |