| @@ 62-77 (lines=16) @@ | ||
| 59 | return $userList; |
|
| 60 | } |
|
| 61 | ||
| 62 | public function getUserCertificateInfo($commonName) |
|
| 63 | { |
|
| 64 | $stmt = $this->db->prepare( |
|
| 65 | 'SELECT |
|
| 66 | u.external_user_id AS user_id, |
|
| 67 | u.is_disabled AS user_is_disabled, |
|
| 68 | c.display_name AS display_name, |
|
| 69 | c.is_disabled AS certificate_is_disabled |
|
| 70 | FROM |
|
| 71 | users u, certificates c |
|
| 72 | WHERE |
|
| 73 | u.user_id = c.user_id AND |
|
| 74 | c.common_name = :common_name' |
|
| 75 | ); |
|
| 76 | ||
| 77 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 78 | $stmt->execute(); |
|
| 79 | ||
| 80 | return $stmt->fetch(PDO::FETCH_ASSOC); |
|
| @@ 225-235 (lines=11) @@ | ||
| 222 | return 1 === $stmt->rowCount(); |
|
| 223 | } |
|
| 224 | ||
| 225 | public function deleteUser($externalUserId) |
|
| 226 | { |
|
| 227 | $stmt = $this->db->prepare( |
|
| 228 | 'DELETE FROM users WHERE external_user_id = :external_user_id' |
|
| 229 | ); |
|
| 230 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 231 | ||
| 232 | $stmt->execute(); |
|
| 233 | ||
| 234 | return 1 === $stmt->rowCount(); |
|
| 235 | } |
|
| 236 | ||
| 237 | public function addCertificate($externalUserId, $commonName, $displayName, $validFrom, $validTo) |
|
| 238 | { |
|
| @@ 279-289 (lines=11) @@ | ||
| 276 | return $certificateList; |
|
| 277 | } |
|
| 278 | ||
| 279 | public function disableCertificate($commonName) |
|
| 280 | { |
|
| 281 | $stmt = $this->db->prepare( |
|
| 282 | 'UPDATE certificates SET is_disabled = 1 WHERE common_name = :common_name' |
|
| 283 | ); |
|
| 284 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 285 | ||
| 286 | $stmt->execute(); |
|
| 287 | ||
| 288 | return 1 === $stmt->rowCount(); |
|
| 289 | } |
|
| 290 | ||
| 291 | public function deleteCertificate($commonName) |
|
| 292 | { |
|
| @@ 291-301 (lines=11) @@ | ||
| 288 | return 1 === $stmt->rowCount(); |
|
| 289 | } |
|
| 290 | ||
| 291 | public function deleteCertificate($commonName) |
|
| 292 | { |
|
| 293 | $stmt = $this->db->prepare( |
|
| 294 | 'DELETE FROM certificates WHERE common_name = :common_name' |
|
| 295 | ); |
|
| 296 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 297 | ||
| 298 | $stmt->execute(); |
|
| 299 | ||
| 300 | return 1 === $stmt->rowCount(); |
|
| 301 | } |
|
| 302 | ||
| 303 | public function enableCertificate($commonName) |
|
| 304 | { |
|
| @@ 303-315 (lines=13) @@ | ||
| 300 | return 1 === $stmt->rowCount(); |
|
| 301 | } |
|
| 302 | ||
| 303 | public function enableCertificate($commonName) |
|
| 304 | { |
|
| 305 | $stmt = $this->db->prepare( |
|
| 306 | 'UPDATE certificates SET is_disabled = 0 WHERE common_name = :common_name' |
|
| 307 | ); |
|
| 308 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 309 | ||
| 310 | $stmt->execute(); |
|
| 311 | ||
| 312 | return 1 === $stmt->rowCount(); |
|
| 313 | } |
|
| 314 | ||
| 315 | public function disableUser($externalUserId) |
|
| 316 | { |
|
| 317 | $stmt = $this->db->prepare( |
|
| 318 | 'UPDATE users SET is_disabled = 1 WHERE external_user_id = :external_user_id' |
|
| @@ 315-327 (lines=13) @@ | ||
| 312 | return 1 === $stmt->rowCount(); |
|
| 313 | } |
|
| 314 | ||
| 315 | public function disableUser($externalUserId) |
|
| 316 | { |
|
| 317 | $stmt = $this->db->prepare( |
|
| 318 | 'UPDATE users SET is_disabled = 1 WHERE external_user_id = :external_user_id' |
|
| 319 | ); |
|
| 320 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 321 | ||
| 322 | $stmt->execute(); |
|
| 323 | ||
| 324 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 325 | // modified? |
|
| 326 | return 1 === $stmt->rowCount(); |
|
| 327 | } |
|
| 328 | ||
| 329 | public function enableUser($externalUserId) |
|
| 330 | { |
|
| @@ 329-341 (lines=13) @@ | ||
| 326 | return 1 === $stmt->rowCount(); |
|
| 327 | } |
|
| 328 | ||
| 329 | public function enableUser($externalUserId) |
|
| 330 | { |
|
| 331 | $stmt = $this->db->prepare( |
|
| 332 | 'UPDATE users SET is_disabled = 0 WHERE external_user_id = :external_user_id' |
|
| 333 | ); |
|
| 334 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 335 | ||
| 336 | $stmt->execute(); |
|
| 337 | ||
| 338 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 339 | // modified? |
|
| 340 | return 1 === $stmt->rowCount(); |
|
| 341 | } |
|
| 342 | ||
| 343 | public function isDisabledUser($externalUserId) |
|
| 344 | { |
|
| @@ 448-463 (lines=16) @@ | ||
| 445 | return 1 === $stmt->rowCount(); |
|
| 446 | } |
|
| 447 | ||
| 448 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 449 | { |
|
| 450 | $stmt = $this->db->prepare( |
|
| 451 | 'SELECT external_user_id, profile_id, common_name, ip4, ip6, connected_at, disconnected_at |
|
| 452 | FROM connection_log |
|
| 453 | WHERE |
|
| 454 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 455 | AND connected_at < :date_time_unix |
|
| 456 | AND (disconnected_at > :date_time_unix OR disconnected_at IS NULL)' |
|
| 457 | ); |
|
| 458 | $stmt->bindValue(':ip_address', $ipAddress, PDO::PARAM_STR); |
|
| 459 | $stmt->bindValue(':date_time_unix', $dateTimeUnix, PDO::PARAM_STR); |
|
| 460 | $stmt->execute(); |
|
| 461 | ||
| 462 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | } |
|
| 464 | ||
| 465 | public function recordTotpKey($externalUserId, $totpKey, $timeUnix) |
|
| 466 | { |
|
| @@ 495-507 (lines=13) @@ | ||
| 492 | return true; |
|
| 493 | } |
|
| 494 | ||
| 495 | public function cleanConnectionLog($timeUnix) |
|
| 496 | { |
|
| 497 | $stmt = $this->db->prepare( |
|
| 498 | sprintf( |
|
| 499 | 'DELETE FROM connection_log |
|
| 500 | WHERE |
|
| 501 | connected_at < :time_unix |
|
| 502 | AND |
|
| 503 | disconnected_at IS NOT NULL' |
|
| 504 | ) |
|
| 505 | ); |
|
| 506 | ||
| 507 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 508 | ||
| 509 | return $stmt->execute(); |
|
| 510 | } |
|
| @@ 512-524 (lines=13) @@ | ||
| 509 | return $stmt->execute(); |
|
| 510 | } |
|
| 511 | ||
| 512 | public function cleanTotpLog($timeUnix) |
|
| 513 | { |
|
| 514 | $stmt = $this->db->prepare( |
|
| 515 | sprintf( |
|
| 516 | 'DELETE FROM totp_log |
|
| 517 | WHERE time_unix < :time_unix' |
|
| 518 | ) |
|
| 519 | ); |
|
| 520 | ||
| 521 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 522 | ||
| 523 | return $stmt->execute(); |
|
| 524 | } |
|
| 525 | ||
| 526 | public function motd() |
|
| 527 | { |
|