+ //
+ // function pwdHash($new_password)
+ // Return a hash for the given password.
+ //
+ // function pwdVerify($password_to_verify, $user)
+ // Return true if the password verifies against the pwdhash field of the user, false if not.
+ //
+ // function pwdNeedsRehash($user)
+ // Return true if the pwdhash field of the user uses an outdated standard and needs to be rehashed.
+
+ function __construct($settings, $db) {
+ // *** constructor ***
+ $this->db = $db;
+ $this->running_on_localhost = preg_match('/^((.+\.)?localhost|127\.0\.0\.\d+)$/', $_SERVER['SERVER_NAME']);
+ if (array_key_exists('pwd_cost', $settings)) {
+ $this->pwd_cost = $settings['pwd_cost'];
+ }
+ if (array_key_exists('pwd_nonces', $settings)) {
+ $this->pwd_nonces = $settings['pwd_nonces'];
+ }
+ }
+
+ public $db = null;
+ public $running_on_localhost = false;
+ private $pwd_cost = 10;
+ private $pwd_nonces = array();
+
+ function log($code, $info) {
+ $result = $this->db->prepare('INSERT INTO `auth_log` (`code`, `info`, `ip_addr`) VALUES (:code, :info, :ipaddr);');
+ if (!$result->execute(array(':code' => $code, ':info' => $info, ':ipaddr' => $_SERVER['REMOTE_ADDR']))) {
+ // print($result->errorInfo()[2]);
+ }
+ }