@@ 187-202 (lines=16) @@ | ||
184 | * |
|
185 | * @return int|false $uid |
|
186 | */ |
|
187 | public function getSessionUID($hash = false) |
|
188 | { |
|
189 | if (false === $hash) { |
|
190 | $cookie = new Cookie($this->cookieName); |
|
191 | $hash = $cookie->getValue(); |
|
192 | } |
|
193 | ||
194 | $stmt = $this->pdo->prepare("SELECT user_id FROM {$this->table} WHERE cookie = ?"); |
|
195 | $stmt->execute(array($hash)); |
|
196 | ||
197 | if ($stmt->rowCount() == 0) { |
|
198 | return false; |
|
199 | } |
|
200 | ||
201 | return $stmt->fetch(\PDO::FETCH_ASSOC)['user_id']; |
|
202 | } |
|
203 | ||
204 | /** |
|
205 | * Hash cookie hash. |
@@ 123-149 (lines=27) @@ | ||
120 | * |
|
121 | * @return array|bool |
|
122 | */ |
|
123 | public function getUser($uid = false) |
|
124 | { |
|
125 | if (false === $uid) { |
|
126 | $uid = $this->session->getSessionUID(); |
|
127 | } |
|
128 | ||
129 | $stmt = $this->pdo->prepare(" |
|
130 | SELECT id, |
|
131 | nick, |
|
132 | first_name, |
|
133 | surname, |
|
134 | email, |
|
135 | active, |
|
136 | dt |
|
137 | FROM {$this->table} |
|
138 | WHERE id = :uid |
|
139 | "); |
|
140 | $stmt->bindValue(':uid', $uid, \PDO::PARAM_INT); |
|
141 | $stmt->execute(); |
|
142 | ||
143 | $data = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
144 | if (empty($data)) { |
|
145 | return false; |
|
146 | } |
|
147 | ||
148 | return $data; |
|
149 | } |
|
150 | ||
151 | /** |
|
152 | * Get password hash. |