| @@ 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 cleanTotpLog(DateTime $dateTime) |
|
| 673 | { |
|
| 674 | $stmt = $this->db->prepare( |
|
| 675 | <<< 'SQL' |
|
| 676 | DELETE FROM |
|
| 677 | totp_log |
|
| 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 systemMessages($type) |
|
| 689 | { |
|
| @@ 688-705 (lines=18) @@ | ||
| 685 | return $stmt->execute(); |
|
| 686 | } |
|
| 687 | ||
| 688 | public function systemMessages($type) |
|
| 689 | { |
|
| 690 | $stmt = $this->db->prepare( |
|
| 691 | <<< 'SQL' |
|
| 692 | SELECT |
|
| 693 | id, message, date_time |
|
| 694 | FROM |
|
| 695 | system_messages |
|
| 696 | WHERE |
|
| 697 | type = :type |
|
| 698 | SQL |
|
| 699 | ); |
|
| 700 | ||
| 701 | $stmt->bindValue(':type', $type, PDO::PARAM_STR); |
|
| 702 | $stmt->execute(); |
|
| 703 | ||
| 704 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 705 | } |
|
| 706 | ||
| 707 | public function addSystemMessage($type, $message, DateTime $dateTime) |
|
| 708 | { |
|
| @@ 726-740 (lines=15) @@ | ||
| 723 | return 1 === $stmt->rowCount(); |
|
| 724 | } |
|
| 725 | ||
| 726 | public function deleteSystemMessage($messageId) |
|
| 727 | { |
|
| 728 | $stmt = $this->db->prepare( |
|
| 729 | <<< 'SQL' |
|
| 730 | DELETE FROM |
|
| 731 | system_messages |
|
| 732 | WHERE id = :message_id |
|
| 733 | SQL |
|
| 734 | ); |
|
| 735 | ||
| 736 | $stmt->bindValue(':message_id', $messageId, PDO::PARAM_INT); |
|
| 737 | $stmt->execute(); |
|
| 738 | ||
| 739 | return 1 === $stmt->rowCount(); |
|
| 740 | } |
|
| 741 | ||
| 742 | public function init() |
|
| 743 | { |
|