| @@ 69-84 (lines=16) @@ | ||
| 66 | return $userList; |
|
| 67 | } |
|
| 68 | ||
| 69 | public function getUserCertificateInfo($commonName) |
|
| 70 | { |
|
| 71 | $stmt = $this->db->prepare( |
|
| 72 | <<< 'SQL' |
|
| 73 | SELECT |
|
| 74 | u.user_id AS user_id, |
|
| 75 | u.is_disabled AS user_is_disabled, |
|
| 76 | c.display_name AS display_name, |
|
| 77 | c.is_disabled AS certificate_is_disabled |
|
| 78 | FROM |
|
| 79 | users u, certificates c |
|
| 80 | WHERE |
|
| 81 | u.user_id = c.user_id AND |
|
| 82 | c.common_name = :common_name |
|
| 83 | SQL |
|
| 84 | ); |
|
| 85 | ||
| 86 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 87 | $stmt->execute(); |
|
| @@ 111-129 (lines=19) @@ | ||
| 108 | return $stmt->fetchColumn(); |
|
| 109 | } |
|
| 110 | ||
| 111 | public function setVootToken($userId, $vootToken) |
|
| 112 | { |
|
| 113 | $this->addUser($userId); |
|
| 114 | $stmt = $this->db->prepare( |
|
| 115 | <<< 'SQL' |
|
| 116 | INSERT INTO voot_tokens |
|
| 117 | (user_id, voot_token) |
|
| 118 | VALUES |
|
| 119 | (:user_id, :voot_token) |
|
| 120 | SQL |
|
| 121 | ); |
|
| 122 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_STR); |
|
| 123 | $stmt->bindValue(':voot_token', $vootToken, PDO::PARAM_STR); |
|
| 124 | ||
| 125 | $stmt->execute(); |
|
| 126 | ||
| 127 | // XXX deal with errors! |
|
| 128 | return 1 === $stmt->rowCount(); |
|
| 129 | } |
|
| 130 | ||
| 131 | public function hasVootToken($userId) |
|
| 132 | { |
|
| @@ 318-328 (lines=11) @@ | ||
| 315 | return $certificateList; |
|
| 316 | } |
|
| 317 | ||
| 318 | public function disableCertificate($commonName) |
|
| 319 | { |
|
| 320 | $stmt = $this->db->prepare( |
|
| 321 | <<< 'SQL' |
|
| 322 | UPDATE |
|
| 323 | certificates |
|
| 324 | SET |
|
| 325 | is_disabled = 1 |
|
| 326 | WHERE |
|
| 327 | common_name = :common_name |
|
| 328 | SQL |
|
| 329 | ); |
|
| 330 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 331 | ||
| @@ 337-347 (lines=11) @@ | ||
| 334 | return 1 === $stmt->rowCount(); |
|
| 335 | } |
|
| 336 | ||
| 337 | public function deleteCertificate($commonName) |
|
| 338 | { |
|
| 339 | $stmt = $this->db->prepare( |
|
| 340 | <<< 'SQL' |
|
| 341 | DELETE FROM |
|
| 342 | certificates |
|
| 343 | WHERE |
|
| 344 | common_name = :common_name |
|
| 345 | SQL |
|
| 346 | ); |
|
| 347 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 348 | ||
| 349 | $stmt->execute(); |
|
| 350 | // XXX |
|
| @@ 354-364 (lines=11) @@ | ||
| 351 | return 1 === $stmt->rowCount(); |
|
| 352 | } |
|
| 353 | ||
| 354 | public function enableCertificate($commonName) |
|
| 355 | { |
|
| 356 | $stmt = $this->db->prepare( |
|
| 357 | <<< 'SQL' |
|
| 358 | UPDATE |
|
| 359 | certificates |
|
| 360 | SET |
|
| 361 | is_disabled = 0 |
|
| 362 | WHERE |
|
| 363 | common_name = :common_name |
|
| 364 | SQL |
|
| 365 | ); |
|
| 366 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 367 | ||
| @@ 546-561 (lines=16) @@ | ||
| 543 | return 1 === $stmt->rowCount(); |
|
| 544 | } |
|
| 545 | ||
| 546 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 547 | { |
|
| 548 | $stmt = $this->db->prepare( |
|
| 549 | <<< 'SQL' |
|
| 550 | SELECT |
|
| 551 | user_id, |
|
| 552 | profile_id, |
|
| 553 | common_name, |
|
| 554 | ip4, |
|
| 555 | ip6, |
|
| 556 | connected_at, |
|
| 557 | disconnected_at |
|
| 558 | FROM |
|
| 559 | connection_log |
|
| 560 | WHERE |
|
| 561 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 562 | AND |
|
| 563 | connected_at < :date_time_unix |
|
| 564 | AND |
|
| @@ 620-634 (lines=15) @@ | ||
| 617 | return true; |
|
| 618 | } |
|
| 619 | ||
| 620 | public function cleanConnectionLog(DateTime $dateTime) |
|
| 621 | { |
|
| 622 | $stmt = $this->db->prepare( |
|
| 623 | <<< 'SQL' |
|
| 624 | DELETE FROM |
|
| 625 | connection_log |
|
| 626 | WHERE |
|
| 627 | connected_at < :date_time |
|
| 628 | AND |
|
| 629 | disconnected_at IS NOT NULL |
|
| 630 | SQL |
|
| 631 | ); |
|
| 632 | ||
| 633 | $stmt->bindValue(':date_time', $dateTime->format('Y-m-d H:i:s'), PDO::PARAM_STR); |
|
| 634 | ||
| 635 | return $stmt->execute(); |
|
| 636 | } |
|
| 637 | ||
| @@ 638-652 (lines=15) @@ | ||
| 635 | return $stmt->execute(); |
|
| 636 | } |
|
| 637 | ||
| 638 | public function cleanUserMessages(DateTime $dateTime) |
|
| 639 | { |
|
| 640 | $stmt = $this->db->prepare( |
|
| 641 | <<< 'SQL' |
|
| 642 | DELETE FROM |
|
| 643 | user_messages |
|
| 644 | WHERE |
|
| 645 | date_time < :date_time |
|
| 646 | SQL |
|
| 647 | ); |
|
| 648 | ||
| 649 | $stmt->bindValue(':date_time', $dateTime->format('Y-m-d H:i:s'), PDO::PARAM_STR); |
|
| 650 | ||
| 651 | return $stmt->execute(); |
|
| 652 | } |
|
| 653 | ||
| 654 | public function cleanTotpLog(DateTime $dateTime) |
|
| 655 | { |
|
| @@ 654-668 (lines=15) @@ | ||
| 651 | return $stmt->execute(); |
|
| 652 | } |
|
| 653 | ||
| 654 | public function cleanTotpLog(DateTime $dateTime) |
|
| 655 | { |
|
| 656 | $stmt = $this->db->prepare( |
|
| 657 | <<< 'SQL' |
|
| 658 | DELETE FROM |
|
| 659 | totp_log |
|
| 660 | WHERE |
|
| 661 | date_time < :date_time |
|
| 662 | SQL |
|
| 663 | ); |
|
| 664 | ||
| 665 | $stmt->bindValue(':date_time', $dateTime->format('Y-m-d H:i:s'), PDO::PARAM_STR); |
|
| 666 | ||
| 667 | return $stmt->execute(); |
|
| 668 | } |
|
| 669 | ||
| 670 | public function systemMessages($type) |
|
| 671 | { |
|
| @@ 670-687 (lines=18) @@ | ||
| 667 | return $stmt->execute(); |
|
| 668 | } |
|
| 669 | ||
| 670 | public function systemMessages($type) |
|
| 671 | { |
|
| 672 | $stmt = $this->db->prepare( |
|
| 673 | <<< 'SQL' |
|
| 674 | SELECT |
|
| 675 | id, message, date_time |
|
| 676 | FROM |
|
| 677 | system_messages |
|
| 678 | WHERE |
|
| 679 | type = :type |
|
| 680 | SQL |
|
| 681 | ); |
|
| 682 | ||
| 683 | $stmt->bindValue(':type', $type, PDO::PARAM_STR); |
|
| 684 | $stmt->execute(); |
|
| 685 | ||
| 686 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 687 | } |
|
| 688 | ||
| 689 | public function addSystemMessage($type, $message) |
|
| 690 | { |
|
| @@ 708-722 (lines=15) @@ | ||
| 705 | return 1 === $stmt->rowCount(); |
|
| 706 | } |
|
| 707 | ||
| 708 | public function deleteSystemMessage($messageId) |
|
| 709 | { |
|
| 710 | $stmt = $this->db->prepare( |
|
| 711 | <<< 'SQL' |
|
| 712 | DELETE FROM |
|
| 713 | system_messages |
|
| 714 | WHERE id = :message_id |
|
| 715 | SQL |
|
| 716 | ); |
|
| 717 | ||
| 718 | $stmt->bindValue(':message_id', $messageId, PDO::PARAM_INT); |
|
| 719 | $stmt->execute(); |
|
| 720 | ||
| 721 | return 1 === $stmt->rowCount(); |
|
| 722 | } |
|
| 723 | ||
| 724 | public function userMessages($userId) |
|
| 725 | { |
|