From de7b4681c953982fb8e33a5f74eb93ee8e539108 Mon Sep 17 00:00:00 2001 From: Christoph Burschka Date: Thu, 16 Jan 2014 15:34:03 +0100 Subject: Finished session auth framework for now. (fixes #1) Doc changes and some implementations remain. --- plugins/session/BridgeSession.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'plugins/session/BridgeSession.php') diff --git a/plugins/session/BridgeSession.php b/plugins/session/BridgeSession.php index 700d545..58e2208 100644 --- a/plugins/session/BridgeSession.php +++ b/plugins/session/BridgeSession.php @@ -4,12 +4,12 @@ * Implements EjabberdAuthBridge. */ class BridgeSession extends EjabberdAuthBridge { - function __const($pdo, $config) { + function __construct($pdo, $config) { $this->db = $pdo; $this->timeout = $config['timeout']; - $this->table = mysqli::escape_string($config['mysql'['tablename']); + $this->table = $config['mysql']['tablename']; $this->_isuser = $this->db->prepare(sprintf('SELECT COUNT(*) FROM `%s` WHERE `username` = :user AND `created` >= :limit;', $this->table)); - $this->_auth = $this->db->prepare(sprintf('DELETE COUNT(*) FROM `%s` WHERE `username` = :user AND `secret` = :secret AND `created` >= :limit;', $this->table)); + $this->_auth = $this->db->prepare(sprintf('DELETE FROM `%s` WHERE `username` = :user AND `secret` = :secret AND `created` >= :limit;', $this->table)); $this->_prune = $this->db->prepare(sprintf('DELETE COUNT(*) FROM `%s` WHERE `created` < :limit;', $this->table)); $this->_create = $this->db->prepare(sprintf('INSERT INTO `%s` (`username`, `secret`, `created`) VALUES (:user, :secret, :time);', $this->table)); } @@ -24,12 +24,14 @@ class BridgeSession extends EjabberdAuthBridge { function isuser($username, $server) { $this->prune(); - return $this->_isuser->execute([':user' => $username, ':limit' => time() - $this->timeout])->fetch()[0] > 0; + $this->_isuser->execute([':user' => $username, ':limit' => time() - $this->timeout]); + return $this->_isuser->fetch()[0] > 0; } function auth($username, $server, $password) { $this->prune(); - return $this->_auth->execute([[':useer' => $username, ':secret' => $password, ':limit' => time() - $this->timeout])->rowCount() > 0; + $this->_auth->execute([':user' => $username, ':secret' => $password, ':limit' => time() - $this->timeout]); + return $this->_auth->rowCount() > 0; } function setpass($username, $server, $password) { -- cgit v1.1