| @@ 100-115 (lines=16) @@ | ||
| 97 | return $userList; |
|
| 98 | } |
|
| 99 | ||
| 100 | public function getUserCertificateInfo($commonName) |
|
| 101 | { |
|
| 102 | $stmt = $this->db->prepare( |
|
| 103 | <<< 'SQL' |
|
| 104 | SELECT |
|
| 105 | u.user_id AS user_id, |
|
| 106 | u.is_disabled AS user_is_disabled, |
|
| 107 | c.display_name AS display_name, |
|
| 108 | c.is_disabled AS certificate_is_disabled |
|
| 109 | FROM |
|
| 110 | users u, certificates c |
|
| 111 | WHERE |
|
| 112 | u.id = c.user_id AND |
|
| 113 | c.common_name = :common_name |
|
| 114 | SQL |
|
| 115 | ); |
|
| 116 | ||
| 117 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 118 | $stmt->execute(); |
|
| @@ 349-359 (lines=11) @@ | ||
| 346 | return $certificateList; |
|
| 347 | } |
|
| 348 | ||
| 349 | public function disableCertificate($commonName) |
|
| 350 | { |
|
| 351 | $stmt = $this->db->prepare( |
|
| 352 | <<< 'SQL' |
|
| 353 | UPDATE |
|
| 354 | certificates |
|
| 355 | SET |
|
| 356 | is_disabled = 1 |
|
| 357 | WHERE |
|
| 358 | common_name = :common_name |
|
| 359 | SQL |
|
| 360 | ); |
|
| 361 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 362 | ||
| @@ 368-378 (lines=11) @@ | ||
| 365 | return 1 === $stmt->rowCount(); |
|
| 366 | } |
|
| 367 | ||
| 368 | public function deleteCertificate($commonName) |
|
| 369 | { |
|
| 370 | $stmt = $this->db->prepare( |
|
| 371 | <<< 'SQL' |
|
| 372 | DELETE FROM |
|
| 373 | certificates |
|
| 374 | WHERE |
|
| 375 | common_name = :common_name |
|
| 376 | SQL |
|
| 377 | ); |
|
| 378 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 379 | ||
| 380 | $stmt->execute(); |
|
| 381 | // XXX |
|
| @@ 385-395 (lines=11) @@ | ||
| 382 | return 1 === $stmt->rowCount(); |
|
| 383 | } |
|
| 384 | ||
| 385 | public function enableCertificate($commonName) |
|
| 386 | { |
|
| 387 | $stmt = $this->db->prepare( |
|
| 388 | <<< 'SQL' |
|
| 389 | UPDATE |
|
| 390 | certificates |
|
| 391 | SET |
|
| 392 | is_disabled = 0 |
|
| 393 | WHERE |
|
| 394 | common_name = :common_name |
|
| 395 | SQL |
|
| 396 | ); |
|
| 397 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 398 | ||
| @@ 577-592 (lines=16) @@ | ||
| 574 | return 1 === $stmt->rowCount(); |
|
| 575 | } |
|
| 576 | ||
| 577 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 578 | { |
|
| 579 | $stmt = $this->db->prepare( |
|
| 580 | <<< 'SQL' |
|
| 581 | SELECT |
|
| 582 | user_id, |
|
| 583 | profile_id, |
|
| 584 | common_name, |
|
| 585 | ip4, |
|
| 586 | ip6, |
|
| 587 | connected_at, |
|
| 588 | disconnected_at |
|
| 589 | FROM |
|
| 590 | connection_log |
|
| 591 | WHERE |
|
| 592 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 593 | AND |
|
| 594 | connected_at < :date_time_unix |
|
| 595 | AND |
|
| @@ 651-665 (lines=15) @@ | ||
| 648 | return true; |
|
| 649 | } |
|
| 650 | ||
| 651 | public function cleanConnectionLog(DateTime $dateTime) |
|
| 652 | { |
|
| 653 | $stmt = $this->db->prepare( |
|
| 654 | <<< 'SQL' |
|
| 655 | DELETE FROM |
|
| 656 | connection_log |
|
| 657 | WHERE |
|
| 658 | connected_at < :date_time |
|
| 659 | AND |
|
| 660 | disconnected_at IS NOT NULL |
|
| 661 | SQL |
|
| 662 | ); |
|
| 663 | ||
| 664 | $stmt->bindValue(':date_time', $dateTime->format('Y-m-d H:i:s'), PDO::PARAM_STR); |
|
| 665 | ||
| 666 | return $stmt->execute(); |
|
| 667 | } |
|
| 668 | ||
| @@ 669-683 (lines=15) @@ | ||
| 666 | return $stmt->execute(); |
|
| 667 | } |
|
| 668 | ||
| 669 | public function cleanUserMessages(DateTime $dateTime) |
|
| 670 | { |
|
| 671 | $stmt = $this->db->prepare( |
|
| 672 | <<< 'SQL' |
|
| 673 | DELETE FROM |
|
| 674 | user_messages |
|
| 675 | WHERE |
|
| 676 | date_time < :date_time |
|
| 677 | SQL |
|
| 678 | ); |
|
| 679 | ||
| 680 | $stmt->bindValue(':date_time', $dateTime->format('Y-m-d H:i:s'), PDO::PARAM_STR); |
|
| 681 | ||
| 682 | return $stmt->execute(); |
|
| 683 | } |
|
| 684 | ||
| 685 | public function cleanTotpLog(DateTime $dateTime) |
|
| 686 | { |
|
| @@ 685-699 (lines=15) @@ | ||
| 682 | return $stmt->execute(); |
|
| 683 | } |
|
| 684 | ||
| 685 | public function cleanTotpLog(DateTime $dateTime) |
|
| 686 | { |
|
| 687 | $stmt = $this->db->prepare( |
|
| 688 | <<< 'SQL' |
|
| 689 | DELETE FROM |
|
| 690 | totp_log |
|
| 691 | WHERE |
|
| 692 | date_time < :date_time |
|
| 693 | SQL |
|
| 694 | ); |
|
| 695 | ||
| 696 | $stmt->bindValue(':date_time', $dateTime->format('Y-m-d H:i:s'), PDO::PARAM_STR); |
|
| 697 | ||
| 698 | return $stmt->execute(); |
|
| 699 | } |
|
| 700 | ||
| 701 | public function systemMessages($type) |
|
| 702 | { |
|
| @@ 701-718 (lines=18) @@ | ||
| 698 | return $stmt->execute(); |
|
| 699 | } |
|
| 700 | ||
| 701 | public function systemMessages($type) |
|
| 702 | { |
|
| 703 | $stmt = $this->db->prepare( |
|
| 704 | <<< 'SQL' |
|
| 705 | SELECT |
|
| 706 | id, message, date_time |
|
| 707 | FROM |
|
| 708 | system_messages |
|
| 709 | WHERE |
|
| 710 | type = :type |
|
| 711 | SQL |
|
| 712 | ); |
|
| 713 | ||
| 714 | $stmt->bindValue(':type', $type, PDO::PARAM_STR); |
|
| 715 | $stmt->execute(); |
|
| 716 | ||
| 717 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 718 | } |
|
| 719 | ||
| 720 | public function addSystemMessage($type, $message, DateTime $dateTime) |
|
| 721 | { |
|
| @@ 739-753 (lines=15) @@ | ||
| 736 | return 1 === $stmt->rowCount(); |
|
| 737 | } |
|
| 738 | ||
| 739 | public function deleteSystemMessage($messageId) |
|
| 740 | { |
|
| 741 | $stmt = $this->db->prepare( |
|
| 742 | <<< 'SQL' |
|
| 743 | DELETE FROM |
|
| 744 | system_messages |
|
| 745 | WHERE id = :message_id |
|
| 746 | SQL |
|
| 747 | ); |
|
| 748 | ||
| 749 | $stmt->bindValue(':message_id', $messageId, PDO::PARAM_INT); |
|
| 750 | $stmt->execute(); |
|
| 751 | ||
| 752 | return 1 === $stmt->rowCount(); |
|
| 753 | } |
|
| 754 | ||
| 755 | public function userMessages($userId) |
|
| 756 | { |
|