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